.weekly-form .heads th { position: relative; }
.th-ai,
.assess-head {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: 100%;
    gap: 8px;
}
.th-ai > :first-child,
.assess-head > :first-child {
    grid-column: 2;
    justify-self: center;
    text-align: center;
}
.th-ai > .ai-head,
.assess-head > .ai-head,
.assess-head > .assess-ai {
    grid-column: 3;
    justify-self: end;
}
.ai-head {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 22px;
    padding: 0 9px;
    border-radius: 999px;
    background: #2563eb;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.04em;
    text-decoration: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.ai-head:hover { background: #1d4ed8; color: #fff; }
.assess-form .import { display: inline; margin: 0; max-width: none; font-size: 12px; white-space: nowrap; }
.ai-words { width: min(100%, 560px); box-sizing: border-box; height: 36px; margin-top: 0; border: 1px solid #e5e7eb; border-radius: 8px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--text); }
.ai-word-row { display: flex; align-items: center; gap: 8px; }
.ai-word-row .ai-words { flex: 1; width: auto; max-width: none; }
.ai-word-row .ai-page-bar { margin-top: 0; flex: none; }
.ai-word-row .btn { height: 36px; padding: 0 14px; font-size: 14px; }
.ai-day { margin-top: 16px; }
.ai-day h2 { margin: 0 0 8px; font-size: 14px; font-weight: 650; line-height: 1.4; color: var(--text); }
.ai-lineframe { border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; background: #fff; }
.ai-linehead { display: grid; grid-template-columns: 1fr 1fr; background: #f8fafc; border-bottom: 1px solid #e5e7eb; color: #64748b; font-size: 13px; font-weight: 650; line-height: 1.4; }
.ai-linehead > div { padding: 8px 14px; }
.ai-linehead > div + div { border-left: 1px solid #e5e7eb; }
.ai-linebox { background: #fff; }
.ai-linerow { display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; }
.ai-linerow + .ai-linerow { border-top: 1px solid #eef2f7; }
.ai-cell { padding: 8px 14px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.7em; }
.ai-cell.before { background: #f8fafc; border-right: 1px solid #eef2f7; color: #334155; }
.ai-cell.after { outline: none; background: #fff; }
.ai-cell.change.before, .ai-cell.del { background: #fff7f7; }
.ai-cell.change.after, .ai-cell.add { background: #f3fbf6; }
.ai-cell.empty { background: #fafafa; }
mark.ai-del { background: #fecaca; color: #991b1b; border-radius: 2px; }
mark.ai-add { background: #bbf7d0; color: #166534; border-radius: 2px; }
.ai-blank { color: transparent; }
.ai-compare .side { padding: 8px 12px 10px; }
.ai-compare .ai-before, .ai-page .ai-compare textarea { min-height: 0; }
.ai-tools { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ai-tools select { height: 34px; border: 1px solid var(--input-line); border-radius: 8px; padding: 0 8px; background: white; }

.ai-page { max-width: 1080px; margin: 8px auto 40px; padding: 4px 12px 32px; color: var(--text); font-size: 14px; line-height: 1.6; }
.ai-compare { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #e5e7eb; border-radius: 12px; overflow: hidden; background: #fff; }
.ai-compare .side { min-width: 0; padding: 14px 16px 16px; }
.ai-compare .side.before { background: #f8fafc; border-right: 1px solid #e5e7eb; }
.ai-compare .ai-kicker { margin: 0 0 8px; font-size: 13px; font-weight: 650; line-height: 1.4; }
.ai-compare .ai-before { color: #374151; min-height: 96px; font-size: 14px; line-height: 1.7; }
.ai-page .ai-compare textarea { min-height: 120px; border: none; border-radius: 0; padding: 0; background: transparent; font-size: 14px; line-height: 1.7; }
.ai-back { color: #6b7280; font-size: 13px; line-height: 1.4; }
.ai-page h1 { margin: 10px 0 2px; font-size: 24px; font-weight: 650; line-height: 1.3; letter-spacing: 0; }
.ai-lead { margin: 0 0 16px; color: #6b7280; font-size: 13px; line-height: 1.5; }
.ai-hint { margin: 10px 0 12px; color: #6b7280; font-size: 13px; line-height: 1.6; }
.ai-ask { display: block; margin: 0 0 8px; font-size: 13px; font-weight: 650; line-height: 1.4; }
.ai-ask span, .ai-field-title label { font-weight: 400; color: #9ca3af; font-size: 13px; }
.ai-page textarea {
    width: 100%; box-sizing: border-box; display: block;
    border: 1px solid #e5e7eb; border-radius: 8px;
    background: #fff; resize: vertical; font: inherit;
    font-size: 14px; line-height: 1.6; min-height: 0; padding: 8px 10px;
}
.ai-page textarea:focus { outline: none; border-bottom-color: #111827; }
.ai-page-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 28px; }
.ai-status { min-height: 1.4em; margin: 8px 0 0; color: #6b7280; font-size: 13px; line-height: 1.5; }
.ai-check { display: flex; gap: 8px; align-items: center; margin-top: 14px; color: #374151; }
.ai-field { margin-top: 40px; }
.ai-field-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ai-field h2 { margin: 0; font-size: 22px; font-weight: 650; }
.ai-field h3 { margin: 22px 0 8px; font-size: 14px; color: #374151; }
.ai-piece + .ai-piece { margin-top: 8px; }
.ai-kicker { margin: 16px 0 6px; font-size: 12px; letter-spacing: .08em; color: #9ca3af; }
.ai-before, .ai-after-read { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.ai-before { color: #6b7280; }
.ai-after-read { color: #111827; }
.ai-empty { margin: 0; color: #9ca3af; }
.ai-history-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 16px 0; border-bottom: 1px solid #e5e7eb; }
@media (max-width: 800px) {
    .ai-compare, .ai-linerow { grid-template-columns: 1fr; }
    .ai-compare .side.before, .ai-cell.before { border-right: 0; border-bottom: 1px solid #eef2f7; }
}
@media print { .ai-tools, .ai-page { display: none !important; } }

.login {
    min-height: 100vh;
    justify-content: center;
    padding: 48px 16px 88px;
    background: #e7f2fb url("/static/login-bg.jpg?v=3") center / cover no-repeat;
}
.login-card {
    max-width: 440px;
    padding: 34px 32px 26px;
    border-radius: 18px;
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 22px 50px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
    position: relative;
    overflow: hidden;
}
.login-card::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 4px;
    background: linear-gradient(90deg, #1d4ed8, #38bdf8);
}
.site-foot {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 22px;
    z-index: 6;
    padding: 0 20px;
    text-align: center;
    background: none;
    border: 0;
}
.site-foot-line {
    margin: 0;
    font-size: 12px;
    line-height: 1.6;
    color: #5f6b7a;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}
@media (max-width: 860px) {
    .login { padding: 32px 16px 88px; }
}
.site-foot a { color: inherit; }
.site-foot a:hover { color: #6b7280; }
#app-view:not([hidden]) ~ .site-foot { position: static; margin-top: 28px; padding: 0 16px 28px; }
@media print { .site-foot { display: none !important; } }

.ai-set-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.ai-set-title-main { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.ai-set-title h2 { margin: 0; font-size: 18px; }
.ai-set-enable { margin-left: auto; min-height: 0; white-space: nowrap; }
.ai-settings .ai-set-enable input[type="checkbox"] { width: 16px; height: 16px; margin: 0; flex: 0 0 16px; }
.ai-link { align-items: center; margin-bottom: 16px; padding: 10px 14px; }
.ai-link strong { font-size: 16px; }
.ai-link p { margin: 2px 0 0; font-size: 13px; }
.ai-set-form { display: flex; flex-direction: column; gap: 14px; }
.ai-agents { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ai-agent { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 16px; background: #fff; display: flex; flex-direction: column; gap: 12px; }
.ai-agent.is-on { border-color: #16a34a; box-shadow: inset 0 0 0 1px #16a34a; }
.ai-agent.is-off { background: #f8fafc; }
.ai-login { display: inline-flex; align-items: center; justify-content: flex-start; gap: 8px; width: auto; max-width: 100%; cursor: pointer; }
.ai-settings .ai-login input[type="radio"] {
    width: 16px;
    height: 16px;
    min-width: 16px;
    max-width: 16px;
    flex: 0 0 16px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    box-shadow: none;
    background: transparent;
    accent-color: #2563eb;
}
.ai-login h3 { margin: 0; white-space: nowrap; line-height: 1.2; }
.ai-agent h3 { margin: 0; font-size: 15px; }
.ai-agent .muted { margin: 0; font-size: 12px; line-height: 1.5; }
.ai-agent-status { margin: 0; min-height: 1.4em; font-size: 13px; color: var(--muted); }
.ai-use { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.ai-set-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; }
@media (max-width: 860px) {
    .ai-agents, .ai-use, .ai-set-grid { grid-template-columns: 1fr; }
}
.ai-set-check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    color: var(--text);
    font-size: 14px;
}
.ai-set-actions { margin-top: 0; }
.ai-set-footer {
    display: flex;
    gap: 10px;
    margin-top: 4px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}
.ai-set-advanced,
.ai-set-recent {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8fafc;
    padding: 14px 16px 16px;
}
.ai-set-advanced h3,
.ai-set-recent h3 { margin: 0 0 12px; font-size: 14px; }
.ai-set-recent .ai-history-row { padding: 10px 0; }
.ai-set-recent .muted { margin: 0; }
.ai-link {
    display: flex;
    gap: 14px;
    align-items: center;
    margin: 0 0 18px;
    padding: 12px 16px;
    border: 2px solid transparent;
    border-radius: 10px;
}
.ai-link-mark {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}
.ai-link strong { display: block; font-size: 18px; line-height: 1.3; }
.ai-link p { margin: 4px 0 0; line-height: 1.5; }
.ai-link-ok { background: #e8f7ee; border-color: #16a34a; color: #14532d; }
.ai-link-ok .ai-link-mark { background: #16a34a; }
.ai-link-bad { background: #fef2f2; border-color: #dc2626; color: #7f1d1d; }
.ai-link-bad .ai-link-mark { background: #dc2626; }
.ai-link-wait { background: #eff6ff; border-color: #2563eb; color: #1e3a8a; }
.ai-link-wait .ai-link-mark { background: #2563eb; }
.ai-link-off, .ai-link-saved { background: #fff7ed; border-color: #d97706; color: #7c2d12; }
.ai-link-off .ai-link-mark, .ai-link-saved .ai-link-mark { background: #d97706; }
