/* Hệ thống thiết kế Novelscope (SPEC mục 11). Giá trị lấy từ docs/prototype/novelscope.html.
   Giao diện tối có chủ đích, không có chế độ sáng. */
:root {
  color-scheme: dark;
  --void: #141b2e;
  --deep: #19213a;
  --panel: #1f2843;
  --panel-2: #273250;
  --line: #39486e;
  --star: #f1ead8;
  --ink: #eeebe4;
  --muted: #aab2ca;
  --faint: #7e88a8;
  --lamp: #e8b65a;
  --lamp-soft: rgba(232, 182, 90, .14);
  --p-motif: #e8b65a;
  --p-fore: #e47f9d;
  --p-theme: #6ec9d6;
  --p-symbol: #a99cf0;
  --warn: #f0924a;
  --good: #82cf9e;
  --display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --ui: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --prose: "Literata", Georgia, "Times New Roman", serif;
  --topbar: 56px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--void); color: var(--ink); font-family: var(--ui); font-size: 14px; line-height: 1.5; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--lamp); }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; }

.topbar { height: var(--topbar); display: flex; align-items: center; gap: 20px; border-bottom: 1px solid var(--line); background: var(--deep);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { font-family: var(--display); font-size: 24px; font-weight: 600; color: var(--star); display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav { display: flex; gap: 2px; }
.nav a { color: var(--muted); text-decoration: none; padding: 7px 12px; border-radius: 6px; font-size: 13.5px; }
.nav a:hover { color: var(--ink); background: var(--panel); }
.nav a[aria-current="page"] { color: var(--star); background: var(--panel-2); }
.spacer { flex: 1; }
.topbar .btn { white-space: nowrap; }
.topbar .icon-btn { padding: 6px 8px; display: inline-grid; place-items: center; color: var(--muted); }
.topbar .icon-btn:hover, .topbar .icon-btn[aria-current="page"] { color: var(--star); }
.page { max-width: 1180px; margin: 0 auto; padding-block: 32px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.eyebrow { font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
h1.display { font-family: var(--display); font-weight: 600; font-size: clamp(32px, 5vw, 44px); line-height: 1.05; margin: 6px 0 24px; color: var(--star); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.btn { border: 1px solid var(--line); background: var(--panel); padding: 7px 13px; border-radius: 7px; font-size: 13px; text-decoration: none; color: var(--ink); display: inline-block; }
.btn.primary { background: var(--lamp); color: #1b1306; border-color: var(--lamp); font-weight: 600; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 8px; text-decoration: none; color: inherit; }
.card:hover { border-color: var(--faint); }
.card h3 { font-family: var(--display); font-size: 23px; font-weight: 600; margin: 0; color: var(--star); }
.card p { margin: 0; color: var(--muted); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input { background: var(--deep); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); padding: 9px 11px; font: inherit; }
.notice { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 14px 16px; color: var(--muted); }
.muted { color: var(--muted); }

/* Thành phần dùng chung giữa các màn hình (theo bản mẫu) */
.chip { white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-idea { color: var(--faint); }
.st-outline { color: var(--muted); }
.st-draft { color: var(--p-theme); }
.st-polished { color: var(--lamp); }
.st-done { color: var(--good); }
.st-revise { color: var(--p-symbol); }
.btn:hover { border-color: var(--faint); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--warn); border-color: rgba(240,146,74,.4); background: transparent; }
.btn.danger:hover { background: rgba(240,146,74,.1); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.meter { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; display: block; }
.meter i { display: block; height: 100%; background: var(--lamp); border-radius: 4px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 600; font-size: 15px; background: var(--panel-2); color: var(--star); border: 1px solid var(--line); flex: none; }
.prose-preview { font-family: var(--prose); font-size: 18px; line-height: 1.75; color: #ece7dc; max-width: 680px; margin: 24px 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

[x-cloak] { display: none !important; }
/* ---------- Thông báo dưới đáy (Hoàn tác 7 giây) ---------- */
.page-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 8px 8px 14px; display: flex; gap: 10px;
  align-items: center; font-size: 13px; box-shadow: 0 12px 40px rgba(0,0,0,.45); max-width: calc(100% - 32px); }
.page-toast.err { border-color: rgba(240,146,74,.6); }
.page-toast.err span { color: var(--warn); }
.page-toast .btn { border: 0; background: transparent; color: var(--lamp); font-weight: 600; padding: 5px 8px; }
.page-toast .btn:hover { background: var(--panel); }
.page-toast .x { border: 0; background: transparent; color: var(--muted); font-size: 18px; width: 28px; height: 28px; border-radius: 6px; }
.page-toast .x:hover { color: var(--ink); background: var(--panel); }
body.universe .page-toast { bottom: calc(108px + env(safe-area-inset-bottom, 0px)); }

/* Thẻ kết quả AI (dùng chung: trình soạn thảo, hạt giống, nhân vật, tinh đồ) */
.ai-card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 13px 14px; display: grid; gap: 9px; font-size: 13px; }
.ai-card header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-right: 22px; }
.ai-card header b { font-weight: 600; color: var(--star); font-size: 13px; }
.ai-card .ai-x { position: absolute; top: 8px; right: 8px; border: 0; background: transparent; color: var(--faint); font-size: 16px; width: 24px; height: 24px; border-radius: 6px; }
.ai-card .ai-x:hover { color: var(--ink); background: var(--panel-2); }
.ai-card .ai-body { line-height: 1.6; overflow-wrap: anywhere; }
.ai-card .ai-body p { margin: 0 0 6px; }
.ai-card .ai-body ul, .ai-card .ai-body ol { margin: 0 0 6px; padding-left: 18px; }
.ai-card .ai-body b { color: var(--star); font-weight: 600; }
.ai-card .ai-body h4 { font-family: var(--display); font-size: 17px; margin: 8px 0 2px; color: var(--star); }
.ai-card .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ai-card.resolved { opacity: .6; }
.ai-card .form-err { color: var(--warn); margin: 0; }
.ai-card .muted { color: var(--muted); margin: 0; }
.ai-card .hint-s { margin: 0; font-size: 11.5px; color: var(--faint); }


/* Nhãn mức hoàn thành (panel Toàn văn, bảng chương) */
.st-chip { display: inline-block; font: 11px/1.5 var(--ui); padding: 0 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; vertical-align: 1px; }
.st-chip.st-idea { color: var(--faint); border-style: dashed; }
.st-chip.st-draft { color: var(--lamp); border-color: rgba(232,182,90,.5); }
.st-chip.st-polished { color: var(--good); border-color: rgba(130,207,158,.5); }

/* Dấu của cảnh: bước ngoặt, hồi tưởng (bật / tắt; thẻ thông tin trên tinh đồ, trình soạn thảo) */
.marks { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 10px; }
.mark-btn { font: 12px var(--ui); padding: 3px 10px; border-radius: 999px; border: 1px dashed var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.mark-btn:hover { color: var(--star); border-color: var(--faint); }
.mark-btn[aria-pressed="true"] { border-style: solid; border-color: var(--faint); color: var(--star); background: var(--panel-2); }
