:root {
  --paper: #f6f0e2;
  --paper-2: #efe6d2;
  --card: #fffdf7;
  --ink: #1c2230;
  --ink-2: #3c4456;
  --muted: #6b7180;
  --line: #ded3bb;
  --gold: #b07d22;
  --gold-2: #d9a441;
  --wine: #7b2d2d;
  --green: #2f6b4f;
  --blue: #27476e;
  --danger: #a12d2d;
  --side: #161b26;
  --side-2: #212839;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28,34,48,.06), 0 6px 22px rgba(28,34,48,.07);
  --font-head: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
a:hover { color: var(--wine); }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 .9em; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 268px; flex-shrink: 0; background: var(--side); color: #e8e3d6; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 16px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; padding: 4px 8px 22px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 14px; }
.brand-mark { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 30% 30%, var(--gold-2), var(--gold)); color: #1b1408; font-family: var(--font-head); font-weight: 800; font-size: 17px; box-shadow: inset 0 0 0 3px rgba(255,255,255,.25); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-family: var(--font-head); font-size: 18px; }
.brand-text em { font-family: var(--font-head); font-style: italic; color: var(--gold-2); font-size: 20px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #cfd3dc; text-decoration: none; font-weight: 500; font-size: 15px; }
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.active { background: var(--side-2); color: #fff; box-shadow: inset 3px 0 0 var(--gold-2); }
.nav .ico { width: 22px; text-align: center; opacity: .9; }
.nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 4px; }
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.ai-status { font-size: 13px; color: #aab0bd; background: var(--side-2); border-radius: 10px; padding: 10px 12px; }
.ai-status b { color: #fff; }
.ai-status .ok { color: #8fd3a8; }
.ai-status .no { color: #f0b37e; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.view { flex: 1; padding: 40px 48px; max-width: 1180px; width: 100%; margin: 0 auto; outline: none; }
.topbar { display: none; }
.footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 22px 16px 28px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.footer .dot { opacity: .5; }

/* ---------- common UI ---------- */
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 700; color: var(--gold); margin-bottom: 8px; }
.lead { font-size: 1.1rem; color: var(--ink-2); max-width: 760px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.grid > .card + .card, .grid > * + .card, .res-list > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 14px; }
.page-head { margin-bottom: 28px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 10px; background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.new { background: #fff3d6; color: #7a5208; border-color: #ecd394; }
.badge.updated { background: #e3efe8; color: var(--green); border-color: #bcd7c6; }
.badge.web { background: #e4ebf5; color: var(--blue); border-color: #c3d1e6; }
.badge.ok { background: #e3efe8; color: var(--green); border-color: #bcd7c6; }
.badge.warn { background: #fbe9dc; color: #8a4613; border-color: #efc9a9; }
.badge.bad { background: #f6e0e0; color: var(--danger); border-color: #e6bcbc; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 11px 18px; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; transition: transform .05s, background .15s, box-shadow .15s; background: var(--ink); color: #fff; }
.btn:hover { background: #2b3446; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #1b1408; box-shadow: 0 2px 0 #8a611a; }
.btn.gold:hover { filter: brightness(1.05); color: #1b1408; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 7px 12px; font-size: 13.5px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; text-decoration: underline; font-size: inherit; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; width: 40px; height: 40px; font-size: 20px; cursor: pointer; }

label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--ink-2); }
.field { margin-bottom: 16px; }
.input, select.input, textarea.input { width: 100%; background: #fff; border: 1px solid #cfc3a8; border-radius: 10px; padding: 11px 13px; font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176,125,34,.18); }
.hint { font-size: 13px; color: var(--muted); margin-top: 5px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }
.alert { border-radius: 10px; padding: 12px 14px; font-size: 14.5px; margin-bottom: 14px; border: 1px solid; }
.alert.error { background: #f9e5e5; border-color: #e8bcbc; color: #7d1f1f; }
.alert.info { background: #eef3fa; border-color: #c7d5ea; color: #1f3a5c; }
.alert.ok { background: #e6f2eb; border-color: #bcd7c6; color: #1f4d37; }
.alert.warn { background: #fdf2e2; border-color: #ecd09f; color: #6c4810; }

/* ---------- auth ---------- */
.auth-wrap { min-height: calc(100vh - 90px); display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo .brand-mark { width: 64px; height: 64px; font-size: 24px; margin: 0 auto 12px; }
.auth-logo h1 { font-size: 1.9rem; margin: 0; }
.auth-logo h1 em { color: var(--gold); }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 14px; font-size: 14px; }

/* ---------- dashboard ---------- */
.hero { background: linear-gradient(135deg, #1c2230 0%, #2a3247 60%, #3a2f22 100%); color: #f3ecdc; border-radius: 18px; padding: 36px 38px; position: relative; overflow: hidden; margin-bottom: 26px; }
.hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%; border: 2px solid rgba(217,164,65,.35); box-shadow: 0 0 0 26px rgba(217,164,65,.06), 0 0 0 60px rgba(217,164,65,.04); }
.hero h1 { color: #fff; font-size: 2.3rem; }
.hero h1 em { color: var(--gold-2); }
.hero p { color: #d9d3c4; max-width: 640px; font-size: 1.05rem; }
.stat { text-align: left; }
.stat b { display: block; font-family: var(--font-head); font-size: 2rem; color: var(--ink); }
.stat span { color: var(--muted); font-size: 14px; }
.tile { display: block; text-decoration: none; color: inherit; transition: transform .12s, box-shadow .12s; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(28,34,48,.12); color: inherit; }
.tile .ico { font-size: 26px; margin-bottom: 8px; }
.tile h3 { margin-bottom: 6px; }
.tile p { color: var(--ink-2); font-size: 14.5px; margin: 0; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .tick { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; flex-shrink: 0; background: var(--paper-2); color: var(--muted); }
.checklist .tick.done { background: var(--green); color: #fff; }

/* ---------- methods ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 500; cursor: pointer; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.method-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; position: relative; }
.method-card:hover { color: inherit; }
.method-num { font-family: var(--font-head); font-size: 15px; color: var(--gold); font-weight: 700; }
.method-card h3 { font-size: 1.2rem; margin: 0; }
.method-card p { margin: 0; font-size: 14.5px; color: var(--ink-2); }
.method-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.method-head { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 24px; align-items: start; margin-bottom: 26px; }
.info-list { list-style: none; margin: 0; padding: 0; }
.info-list li { padding: 7px 0 7px 22px; position: relative; font-size: 14.5px; border-bottom: 1px dashed var(--line); }
.info-list li:last-child { border-bottom: 0; }
.info-list li::before { content: '✦'; position: absolute; left: 0; color: var(--gold); font-size: 12px; top: 10px; }
.project-bar { position: sticky; top: 0; z-index: 5; background: rgba(246,240,226,.94); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin-bottom: 22px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.project-bar select { max-width: 320px; }
.save-state { font-size: 13px; color: var(--muted); }
.step { display: grid; grid-template-columns: 52px minmax(0,1fr); gap: 16px; }
.step + .step { margin-top: 18px; }
.step-num { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-head); font-weight: 800; font-size: 18px; background: var(--ink); color: var(--gold-2); }
.step h3 { font-size: 1.25rem; margin-top: 8px; }
.ai-box { margin-top: 16px; border: 1px solid #d8c9a6; background: #fbf6ea; border-radius: 12px; padding: 18px; }
.ai-box-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; font-weight: 700; }
.ai-box-head .spark { color: var(--gold); }
.prompt-edit { margin-top: 10px; }
.prompt-edit textarea { min-height: 180px; font-size: 13.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ai-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.output { margin-top: 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; max-height: 620px; overflow: auto; }
.output.streaming::after { content: '▍'; animation: blink 1s steps(2) infinite; color: var(--gold); }
@keyframes blink { 50% { opacity: 0; } }
.output-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sources { margin-top: 12px; font-size: 13.5px; }
.sources ol { padding-left: 20px; margin: 6px 0 0; }
.notes textarea { min-height: 70px; }
details.more { margin-top: 10px; }
details.more summary { cursor: pointer; color: var(--blue); font-size: 14px; font-weight: 600; }

/* markdown */
.md h1, .md h2, .md h3, .md h4 { font-family: var(--font-head); margin: 1em 0 .5em; }
.md h1 { font-size: 1.5rem; } .md h2 { font-size: 1.3rem; } .md h3 { font-size: 1.12rem; } .md h4 { font-size: 1rem; }
.md > :first-child { margin-top: 0; }
.md ul, .md ol { padding-left: 22px; margin: 0 0 .9em; }
.md li { margin: 3px 0; }
.md code { background: var(--paper-2); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.md pre { background: #1c2230; color: #f1ead9; padding: 14px; border-radius: 10px; overflow: auto; white-space: pre-wrap; }
.md pre code { background: none; padding: 0; color: inherit; }
.md blockquote { border-left: 3px solid var(--gold); margin: 0 0 1em; padding: 4px 14px; color: var(--ink-2); background: #fbf6ea; }
.md table { border-collapse: collapse; width: 100%; margin: 0 0 1em; font-size: 14px; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
.md th { background: var(--paper-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }

/* ---------- library ---------- */
.search-bar { display: flex; gap: 10px; margin-bottom: 14px; }
.search-bar .input { font-size: 16px; padding: 13px 15px; }
.res-list { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.res { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; }
.res-top { display: flex; gap: 8px; align-items: flex-start; }
.res-top h3 { font-family: var(--font-body); font-size: 1.02rem; font-weight: 700; margin: 0; flex: 1; }
.res p { margin: 0; font-size: 14px; color: var(--ink-2); }
.res .url { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.res-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.star { background: none; border: 0; font-size: 20px; cursor: pointer; color: #c9bb98; line-height: 1; padding: 0 2px; }
.star.on { color: var(--gold); }
.section-note { font-size: 14px; }

/* ---------- checker ---------- */
.verdict { border-radius: 12px; padding: 18px 20px; border: 1px solid; }
.verdict h3 { font-family: var(--font-body); font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.verdict.yes { background: #e6f2eb; border-color: #a9cdb8; }
.verdict.no { background: #f9e5e5; border-color: #e3b5b5; }
.verdict.maybe { background: #fdf2e2; border-color: #ebcf9a; }
.verdict ul { margin: 6px 0 0; padding-left: 20px; font-size: 14.5px; }

/* ---------- releases ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 16px; font-weight: 600; cursor: pointer; color: var(--muted); font-size: 15px; }
.tab.active { color: var(--ink); border-color: var(--gold); }
.work-list { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 28px; }
.work-list li { break-inside: avoid; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; }
.work-list li b { font-weight: 600; }

/* ---------- tables (admin/projects) ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
table.data tr:hover td { background: #fbf7ec; }
.code-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; word-break: break-all; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(120px); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14.5px; box-shadow: 0 8px 30px rgba(0,0,0,.25); transition: transform .25s, opacity .25s; z-index: 50; max-width: 92vw; opacity: 0; pointer-events: none; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ---------- tablet ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .method-head { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; transform: translateX(-100%); transition: transform .22s; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .sidebar.open { transform: translateX(0); }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .topbar-brand { font-family: var(--font-head); font-weight: 700; text-decoration: none; color: var(--ink); font-size: 18px; }
  .topbar-brand em { color: var(--gold); }
  .view { padding: 28px 22px; }
  h1 { font-size: 1.75rem; }
  .hero { padding: 28px 24px; }
  .hero h1 { font-size: 1.85rem; letter-spacing: -.005em; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .res-list { grid-template-columns: 1fr; }
  .work-list { columns: 1; }
  .project-bar { position: static; }
}
/* ---------- mobile ---------- */
@media (max-width: 480px) {
  body { font-size: 15.5px; }
  .view { padding: 22px 14px; }
  .card { padding: 18px 16px; }
  .grid { gap: 12px; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 1.5rem; letter-spacing: 0; }
  .hero { padding: 24px 18px; border-radius: 14px; }
  .hero h1 { font-size: 1.55rem; letter-spacing: 0; }
  .eyebrow { letter-spacing: .08em; }
  .step { grid-template-columns: 1fr; gap: 8px; }
  .step-num { width: 36px; height: 36px; font-size: 15px; }
  .ai-box { padding: 14px; }
  .btn { width: 100%; }
  .btn.sm { width: auto; }
  .row .btn, .ai-actions .btn { width: 100%; }
  .output-actions .btn { width: auto; }
  .search-bar { flex-direction: column; }
  .page-head { margin-bottom: 18px; }
  .footer { flex-direction: column; align-items: center; gap: 4px; }
  .footer .dot { display: none; }
}

/* ---------- notice ---------- */
.notice-wrap { min-height: calc(100vh - 90px); display: grid; place-items: center; padding: 24px 0; }
.notice-card { max-width: 780px; width: 100%; }
.notice-list { padding-left: 22px; margin: 18px 0; }
.notice-list li { margin-bottom: 12px; line-height: 1.6; }
.notice-check { align-items: flex-start; background: #fbf6ea; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-weight: 500; }
.notice-check input { margin-top: 3px; flex-shrink: 0; }

/* ---------- checked books & whole-book mode ---------- */
.book-card { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; border: 1px solid #bcd7c6; background: #f6fbf8; border-left: 4px solid var(--green); border-radius: 10px; padding: 14px 16px; margin: 10px 0; }
.book-title { font-weight: 700; font-size: 1.02rem; }
.book-checks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.book-open { flex-shrink: 0; white-space: nowrap; }
.doc-panel { background: #fff; border: 1px dashed #cdb98f; border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.doc-label { font-weight: 700; font-size: 14px; margin-bottom: 8px; color: var(--ink-2); }
.doc-status { margin-top: 10px; }
.doc-loaded { display: flex; flex-direction: column; gap: 10px; background: #f6fbf8; border: 1px solid #bcd7c6; border-radius: 10px; padding: 12px 14px; }
.doc-prev { background: var(--paper-2); border-radius: 8px; padding: 10px; font-size: 13px; white-space: pre-wrap; max-height: 260px; overflow: auto; margin: 0; }
.file-btn { cursor: pointer; }
.bar { height: 6px; background: rgba(39,71,110,.15); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--blue); transition: width .3s; }
@media (max-width: 480px) {
  .book-card { flex-direction: column; }
  .book-open { width: 100%; }
}
