/* PH Content Studio · admin UI. No external fonts or frameworks (strict CSP, works offline).
   Design tokens first: every colour, radius and shadow below comes from them (light and dark). */
:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --surface-3: #eef1f7;
  --border: #e3e7f0;
  --border-strong: #cbd2e0;
  --text: #0f172a;
  --text-2: #3a4458;
  --muted: #6a7489;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-ink: #ffffff;
  --accent-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --focus: #6366f1;
  --ok: #0f8a5f;      --ok-soft: #e6f6ee;
  --warn: #b45309;    --warn-soft: #fdf3e2;
  --err: #d92d20;     --err-soft: #fdecea;
  --info: #2563eb;    --info-soft: #e8effd;
  --idle: #64748b;    --idle-soft: #eef1f6;
  --chart-bar: #5b5bd6;
  --chart-grid: #e4e6ee;
  --chart-axis: #8a8fa0;
  --side-bg: #0f172a;
  --side-bg-2: #1b1f4b;
  --side-text: #c4cbe0;
  --side-muted: #7f8aa8;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(129, 140, 248, .18);
  --side-active-text: #ffffff;
  --side-line: rgba(255, 255, 255, .08);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 6px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, .07), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-lg: 0 18px 44px rgba(15, 23, 42, .16);
  --ring: 0 0 0 3px color-mix(in srgb, var(--focus) 28%, transparent);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans Bengali",
          "Hind Siliguri", "Kohinoor Bangla", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --surface: #121a2c; --surface-2: #172137; --surface-3: #1c2740; --border: #24304a; --border-strong: #34425f;
    --text: #e8ecf6; --text-2: #b8c1d6; --muted: #8590a9;
    --accent: #818cf8; --accent-2: #a78bfa; --accent-hover: #a5b4fc; --accent-soft: #1f2452; --accent-ink: #0b1020;
    --accent-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --ok: #34d399; --ok-soft: #0f2e25; --warn: #fbbf24; --warn-soft: #33270f; --err: #f87171; --err-soft: #3a1618;
    --info: #60a5fa; --info-soft: #14254a; --idle: #94a3b8; --idle-soft: #1d2638;
    --chart-bar: #818cf8; --chart-grid: #26304a; --chart-axis: #8590a9;
    --side-bg: #080c18; --side-bg-2: #12173a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35); --shadow-md: 0 4px 16px rgba(0, 0, 0, .35); --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --surface: #121a2c; --surface-2: #172137; --surface-3: #1c2740; --border: #24304a; --border-strong: #34425f;
  --text: #e8ecf6; --text-2: #b8c1d6; --muted: #8590a9;
  --accent: #818cf8; --accent-2: #a78bfa; --accent-hover: #a5b4fc; --accent-soft: #1f2452; --accent-ink: #0b1020;
  --accent-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --ok: #34d399; --ok-soft: #0f2e25; --warn: #fbbf24; --warn-soft: #33270f; --err: #f87171; --err-soft: #3a1618;
  --info: #60a5fa; --info-soft: #14254a; --idle: #94a3b8; --idle-soft: #1d2638;
  --chart-bar: #818cf8; --chart-grid: #26304a; --chart-axis: #8590a9;
  --side-bg: #080c18; --side-bg-2: #12173a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35); --shadow-md: 0 4px 16px rgba(0, 0, 0, .35); --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 21px; font-weight: 720; letter-spacing: -.015em; }
h2 { font-size: 15.5px; font-weight: 660; letter-spacing: -.005em; }
h3 { font-size: 12px; font-weight: 680; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; overflow: auto; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.lead { font-size: 15px; max-width: 70ch; margin-bottom: 18px; color: var(--text-2); }
.error-text { color: var(--err); }
.warn-text { color: var(--warn); }
.link { color: var(--accent); text-decoration: none; font-weight: 560; }
.link:hover { text-decoration: underline; text-underline-offset: 2px; }
button.link { background: none; border: 0; padding: 0; min-height: 0; font: inherit; font-weight: 560; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

.icon { width: 18px; height: 18px; flex: none; }

/* ------------------------------------------------------------------ layout */
.shell { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 14px;
  padding: 18px 12px 14px; background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 140%); color: var(--side-text);
  overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; z-index: 30; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; padding: 2px 8px 6px; color: #fff; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px;
  background: var(--accent-grad); color: #fff; box-shadow: 0 6px 16px rgba(99, 102, 241, .45); }
.brand-mark .icon { width: 20px; height: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 14.5px; letter-spacing: -.01em; }
.brand-text small { color: var(--side-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .new-btn { margin: 0 4px; background: var(--accent-grad); color: #fff; box-shadow: 0 6px 18px rgba(99, 102, 241, .35); }
.sidebar .new-btn:hover { filter: brightness(1.08); background: var(--accent-grad); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-group { margin: 14px 10px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--side-muted); }
.nav-link { position: relative; display: flex; align-items: center; gap: 11px; min-height: 38px; padding: 7px 10px;
  border-radius: 9px; color: var(--side-text); text-decoration: none; font-weight: 520; font-size: 13.5px;
  transition: background .12s, color .12s; }
.nav-link .icon { width: 17px; height: 17px; opacity: .85; }
.nav-link:hover { background: var(--side-hover); color: #fff; }
.nav-link.active { background: var(--side-active); color: var(--side-active-text); font-weight: 600; }
.nav-link.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
  background: #a5b4fc; }
.nav-link.active .icon { opacity: 1; color: #c7d2fe; }
.nav-count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #6366f1;
  color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 20px; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-top: 1px solid var(--side-line); padding: 12px 4px 0; }
.whoami { display: flex; align-items: center; gap: 9px; line-height: 1.2; min-width: 0; }
.whoami strong { color: #fff; font-size: 13px; }
.whoami small { display: block; color: var(--side-muted); font-size: 11px; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--accent-grad); color: #fff; font-weight: 700; }
.sidebar-actions { display: flex; gap: 2px; }
.sidebar-actions form { margin: 0; }
.sidebar .btn-ghost { color: var(--side-text); }
.sidebar .btn-ghost:hover { background: var(--side-hover); color: #fff; }
.scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; min-height: 66px;
  padding: 12px 30px; background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border); }
.topbar-title { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.topbar-title h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-title > .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { flex: 0 1 auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; margin-left: auto; }
.topbar-actions form { margin: 0; }
.topbar .menu-btn { display: none; }
.title-block .subline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 3px; }
.content { padding: 26px 30px 56px; display: flex; flex-direction: column; gap: 20px; max-width: 1520px; width: 100%; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.two-col-wide { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* ------------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-actions, .inline-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card-actions form, .inline-actions form { margin: 0; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .btn { margin-top: 8px; }

/* ------------------------------------------------------------------ KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpis-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi { position: relative; display: flex; flex-direction: column; gap: 3px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; overflow: hidden; }
.kpi::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent-grad); opacity: .0; }
.kpi:first-child::after, .kpi-hero::after { opacity: 1; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 560; }
.kpi-value { font-size: 26px; font-weight: 720; letter-spacing: -.02em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12px; }
.kpi-hero .kpi-value { font-size: 30px; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ------------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px;
  padding: 7px 15px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s, filter .12s, transform .06s; }
.btn:active:not([disabled]) { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .12), 0 4px 12px color-mix(in srgb, var(--accent) 28%, transparent); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: 0 1px 2px rgba(15, 23, 42, .05); }
.btn-secondary:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong)); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger-outline { background: var(--surface); color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, transparent); }
.btn-danger-outline:hover { background: var(--err-soft); }
.btn-sm { min-height: 32px; padding: 4px 11px; font-size: 13px; border-radius: 9px; }
.btn-lg { min-height: 48px; font-size: 15px; padding: 10px 20px; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; }
.btn-sm.btn-icon { width: 32px; min-height: 32px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.new-btn { margin: 0 2px; }
.file-btn { position: relative; }

/* ------------------------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 620; background: var(--idle-soft); color: var(--idle); white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-done, .badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-cached { background: var(--info-soft); color: var(--info); }
.badge-running, .badge-typesetting, .badge-queued { background: var(--info-soft); color: var(--info); }
.badge-running .dot, .badge-typesetting .dot { animation: pulse 1.2s ease-in-out infinite; }
.badge-failed, .badge-error { background: var(--err-soft); color: var(--err); }
.badge-interrupted { background: var(--warn-soft); color: var(--warn); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--idle-soft); color: var(--text-2);
  font-size: 11px; font-weight: 620; vertical-align: middle; }
.conf { font-size: 12px; font-weight: 620; }
.conf-high { color: var(--ok); } .conf-medium { color: var(--warn); } .conf-low { color: var(--err); }
@keyframes pulse { 50% { opacity: .35; } }

/* ------------------------------------------------------------------ progress */
.progress { height: 8px; background: var(--idle-soft); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent-grad); border-radius: 99px; transition: width .4s ease; }
.progress.is-active .progress-fill { background-image: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent), var(--accent-grad);
  background-size: 200% 100%, 100% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0, 0 0; } to { background-position: -200% 0, 0 0; } }
.progress-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.progress-cell { min-width: 130px; }
.progress-cell .progress { margin-bottom: 3px; }
.active-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.active-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; }
.active-title { font-weight: 620; text-decoration: none; }
.active-progress { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.spinner { width: 28px; height: 28px; margin: 0 auto 10px; border-radius: 50%; border: 3px solid var(--idle-soft);
  border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 680; color: var(--muted); padding: 9px 10px; text-transform: uppercase;
  letter-spacing: .04em; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table thead th:first-child { border-top-left-radius: 8px; }
.table thead th:last-child { border-top-right-radius: 8px; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.total td { font-weight: 680; border-top: 1px solid var(--border-strong); }
.table-dense td { padding: 6px 10px; }
.table .notes { max-width: 340px; font-size: 12.5px; color: var(--text-2); }
.table .ua { max-width: 320px; font-size: 12.5px; }
.table .subrow td { background: var(--surface-2); padding: 6px 10px 10px; }
.row-title { font-weight: 620; text-decoration: none; }
.row-title:hover { color: var(--accent); }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions form { display: inline; margin: 0; }
.row-warn td { background: var(--warn-soft); }
.log-pre { max-height: 360px; font-size: 12px; white-space: pre-wrap; margin: 8px 0 0; }

/* ------------------------------------------------------------------ forms */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 11px; min-height: 40px; width: 100%; transition: border-color .12s, box-shadow .12s; }
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: color-mix(in srgb, var(--accent) 30%, var(--border-strong)); }
select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
select[multiple] { background-image: none; padding-right: 11px; }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; min-height: 0; accent-color: var(--accent); margin: 0; flex: none; cursor: pointer; }
input[type="color"] { width: 46px; padding: 3px; cursor: pointer; }
input[type="file"] { padding: 6px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: var(--ring); }
input:user-invalid { border-color: var(--err); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-wide { grid-column: 1 / -1; }
.help { color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; cursor: pointer; padding: 6px 0; }
.check input { margin-top: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; align-items: start; }
.form-grid-1 { grid-template-columns: 1fr; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0 0; }
.inline-form input:not([type="hidden"]), .inline-form select { width: auto; flex: 1 1 180px; }
.inline-field { display: flex; align-items: center; gap: 8px; }
.inline-field select { width: auto; }
.color-pair { display: flex; gap: 8px; }
.code-input { font-family: var(--mono); font-size: 20px; letter-spacing: .3em; text-align: center; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters input[type="search"] { flex: 1 1 260px; width: auto; }
.filters select { width: auto; }

.segmented { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-3); margin-bottom: 14px; flex-wrap: wrap; }
.segmented label { display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 9px; cursor: pointer; font-weight: 580; font-size: 13px; color: var(--text-2); }
.segmented label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); }
.segmented-links { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-3); align-self: flex-start; flex-wrap: wrap; }
.segmented-links a { padding: 6px 14px; border-radius: 9px; text-decoration: none; font-weight: 580; font-size: 13px; color: var(--text-2); }
.segmented-links a:hover { color: var(--text); }
.segmented-links a.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-md); }

.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 34px 18px; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer;
  transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--accent-grad); color: #fff;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent); }
.dropzone-icon .icon { width: 22px; height: 22px; }
.file-list { list-style: none; margin: 12px 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; background: var(--surface); }
.estimate { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--text); font-size: 13px; }
.estimate strong { color: var(--info); }

.style-form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.style-section { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.style-section > summary { cursor: pointer; padding: 12px 16px; font-weight: 640; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.style-section > summary::-webkit-details-marker { display: none; }
.style-section > summary:hover { background: var(--surface-2); }
.style-section > summary::after { content: "+"; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px;
  background: var(--surface-3); color: var(--muted); font-weight: 600; }
.style-section[open] > summary::after { content: "−"; background: var(--accent-soft); color: var(--accent); }
.style-section[open] > summary { border-bottom: 1px solid var(--border); }
.style-section > .form-grid { padding: 16px; }
.customize-panel { margin-top: 6px; }
.logo-picker { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.logo-picker select { flex: 1 1 200px; width: auto; }
.logo-thumb { height: 38px; max-width: 140px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: #fff; padding: 3px; }

/* ------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { font: inherit; font-weight: 600; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 10px 14px; cursor: pointer; white-space: nowrap; margin-bottom: -1px; border-radius: 8px 8px 0 0; }
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11px; background: var(--surface-3); color: var(--text-2); border-radius: 10px; padding: 1px 7px; margin-left: 4px; }

/* ------------------------------------------------------------------ PDF, library, styles */
.pdf-frame { width: 100%; height: min(82vh, 1100px); border: 1px solid var(--border); border-radius: var(--radius-sm); background: #525659; }
.pdf-card .card-head { margin-bottom: 12px; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.preview-card { position: sticky; top: 86px; }
.preview-card .pdf-frame { height: calc(100vh - 190px); }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.thumb-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s, border-color .15s; }
.thumb-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.thumb { display: block; aspect-ratio: 210 / 297; background: var(--surface-2); border-bottom: 1px solid var(--border); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; background: #fff; }
.thumb-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.thumb-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 10px; }
.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.style-card { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }
.style-card .card-head { margin: 0; }
.style-swatch { height: 72px; border-radius: 10px; border: 1px solid var(--border); border-left: 5px solid var(--swatch, var(--accent));
  background: var(--surface-2); padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.swatch-title { font-weight: 720; font-size: 16px; color: var(--swatch, var(--accent)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch-brand { font-weight: 650; font-size: 12px; color: var(--muted); }
.spec-list { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13px; }
.card-actions { margin-top: auto; }

/* ------------------------------------------------------------------ facts, log */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 18px; margin: 16px 0 12px; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 2px 0 0; font-weight: 620; overflow-wrap: anywhere; }
.facts-list { grid-template-columns: 1fr; gap: 8px; }
.facts-list > div { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; }
.facts-list dd { font-weight: 500; margin: 0; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.font-list li { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; }
.attempts li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.log { list-style: none; margin: 0; padding: 0; font-size: 13px; max-height: 70vh; overflow: auto; }
.log li { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; padding: 7px 4px; border-bottom: 1px solid var(--border); }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.log span { white-space: pre-wrap; overflow-wrap: anywhere; }
.log-warning span { color: var(--warn); }
.log-error span { color: var(--err); }
.qr { display: inline-block; padding: 8px; background: #fff; border-radius: 10px; border: 1px solid var(--border); margin: 6px 0 10px; }
.qr svg { display: block; }

/* ------------------------------------------------------------------ flash, notices */
.flash { padding: 12px 16px; border-radius: 12px; font-weight: 540; border: 1px solid transparent; border-left-width: 4px; box-shadow: var(--shadow); }
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); border-left-color: var(--ok); }
.flash-error { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); border-left-color: var(--err); }
.flash-warning { background: var(--warn-soft); color: var(--warn); margin-bottom: 12px; border-left-color: var(--warn); }
.flash .link, .flash a { color: inherit; text-decoration: underline; }
.notice { background: var(--warn-soft); border-radius: 12px; padding: 14px 16px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; }

/* ------------------------------------------------------------------ charts */
.chart-wrap { width: 100%; overflow: hidden; }
.chart { width: 100%; height: auto; display: block; font-family: var(--font); }
.chart-bar { fill: var(--chart-bar); }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-baseline { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis { fill: var(--chart-axis); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-hit { fill: transparent; cursor: default; outline: none; }
.chart-hit:hover, .chart-hit:focus { fill: color-mix(in srgb, var(--chart-bar) 8%, transparent); }
.tooltip { position: fixed; z-index: 50; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: var(--text);
  color: var(--surface); font-size: 12.5px; font-weight: 560; box-shadow: var(--shadow-lg); white-space: nowrap; }

/* ------------------------------------------------------------------ auth */
.bare { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; gap: 12px; align-content: center;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--accent-2) 20%, transparent), transparent 60%), var(--bg); }
.auth-card { width: min(410px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 30px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 16px; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand h1 { font-size: 19px; }
.auth-brand p { margin: 0; }
.auth-brand .brand-mark { flex: none; }
.bare > .flash { width: min(410px, 100%); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1200px) {
  .kpis-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .editor-layout { grid-template-columns: 1fr; }
  .preview-card { position: static; }
  .preview-card .pdf-frame { height: 80vh; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: min(290px, 86vw); transform: translateX(-104%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(8, 12, 24, .5); opacity: 0; pointer-events: none;
    transition: opacity .2s; backdrop-filter: blur(2px); }
  .sidebar.is-open ~ .scrim { opacity: 1; pointer-events: auto; }
  .topbar .menu-btn { display: inline-flex; flex: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .two-col-wide { grid-template-columns: 1fr; }
  .topbar { padding: 10px 16px; min-height: 58px; flex-wrap: wrap; }
  .content { padding: 18px 16px 48px; gap: 16px; }
  .card { padding: 16px; }
  .nav-link { min-height: 42px; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  input, select, textarea { font-size: 16px; }          /* no zoom-in on focus (iOS) */
  .kpis, .kpis-6 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 21px; }
  .kpi-hero .kpi-value { font-size: 24px; }
  h1 { font-size: 18px; }
  .facts-list > div { grid-template-columns: 1fr; gap: 0; }
  .log li { grid-template-columns: 1fr; gap: 2px; }
  .topbar-actions { width: 100%; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px;
    scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .topbar-actions .btn { flex: none; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .filters > * { flex: 1 1 100%; }
  .filters select, .filters .btn { width: 100%; }
  .segmented { display: flex; }
  .segmented label { flex: 1 1 auto; }
  .segmented-links { display: flex; overflow-x: auto; flex-wrap: nowrap; }
  .segmented-links a { white-space: nowrap; }
  .table { font-size: 13px; }
  .table-wrap > .table { min-width: 580px; }          /* scroll sideways instead of squeezing every column */
  .empty { padding: 28px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.retry-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.retry-form select { width: auto; min-height: 36px; }

/* ---------------------------------------------------------------- question bank */
.bank-add { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.bank-add-item { border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.bank-add-item h3 { margin: 0; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.bank-add-item p { margin: 0; }
.bank-add-item .btn { align-self: flex-start; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.stack-sm .btn { align-self: flex-start; }
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.bank-sections { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.bank-sections .is-active { text-decoration: underline; }
.bank-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 12px 0 4px; }
.bank-filter select[multiple] { min-height: 7em; }
.bank-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.bank-actions .card { margin: 0; }
.bank-upload-set { margin-top: 12px; }
.badge-warning { display: inline-block; padding: 0 6px; border-radius: 999px; font-size: 12px; background: #fff4db; color: #8a5a00; }
.pager { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
.pager .is-active { background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------- library, courses, syllabus */
.lib { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 18px; align-items: start; }
.lib-tree { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; padding: 10px; display: flex;
  flex-direction: column; gap: 1px; }
.lib-link { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; color: var(--text-2);
  text-decoration: none; font-size: 13.5px; line-height: 1.3; }
.lib-link span:first-of-type, .lib-link > span:not(.count) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.lib-link .icon { width: 16px; height: 16px; flex: none; color: var(--muted); }
.lib-link:hover { background: var(--surface-2); color: var(--text); }
.lib-link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.lib-link.is-active .icon { color: var(--accent); }
.lib-l2 { padding-left: 20px; font-weight: 550; }
.lib-l3 { padding-left: 32px; font-size: 13px; }
.count { flex: none; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  font-size: 11.5px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.count-warn { background: var(--warn-soft); color: var(--warn); }
.lib-head { display: flex; align-items: baseline; justify-content: space-between; margin: 12px 8px 4px; font-size: 11.5px;
  font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.lib-note { margin: 2px 8px 6px; }
.lib-subject > summary { list-style: none; cursor: pointer; }
.lib-subject > summary::-webkit-details-marker { display: none; }
.lib-subject > summary .lib-link { font-weight: 600; color: var(--text); }
.lib-archived { margin-top: 12px; border-top: 1px solid var(--border); border-radius: 0; padding-top: 10px; }
.lib-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.lib-main > form[data-lib-form] { display: flex; flex-direction: column; gap: 16px; }
.lib-group { padding-bottom: 6px; }
.lib-group-head h2 { margin: 0; }
.lib-books { list-style: none; margin: 0; padding: 0; }
.lib-book { display: grid; grid-template-columns: 26px 46px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px 6px; border-top: 1px solid var(--border); border-radius: 8px; }
.lib-book:hover { background: var(--surface-2); }
.lib-book.is-selected { background: var(--accent-soft); }
.lib-check { display: grid; place-items: center; cursor: pointer; }
.lib-thumb { width: 46px; height: 62px; border-radius: 5px; overflow: hidden; border: 1px solid var(--border); background: #fff;
  display: grid; place-items: center; }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.lib-thumb-empty { background: var(--surface-2); color: var(--muted); }
.lib-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lib-title { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.lib-actions { display: flex; gap: 2px; align-items: center; }
.lib-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-size: 12px; text-decoration: none; white-space: nowrap; margin: 1px 4px 1px 0; }
.chip .icon { width: 12px; height: 12px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-part { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.lib-suggest { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 4px; padding: 6px 8px;
  border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--surface); }
.lib-suggest select { flex: 1 1 260px; width: auto; }
.lib-part-input { width: 110px !important; flex: none; }
.bulkbar { position: sticky; bottom: 14px; z-index: 5; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--accent);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .18); }
.bulkbar select { width: auto; max-width: 340px; }
.merge-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.merge-row { display: grid; grid-template-columns: 28px 40px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.merge-n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent);
  color: var(--accent-ink); font-weight: 700; font-size: 13px; }
.merge-thumb { width: 40px; height: 54px; object-fit: cover; object-position: top; border-radius: 4px; border: 1px solid var(--border); background: #fff; }
.merge-info { min-width: 0; }
.merge-actions { display: flex; gap: 2px; }
.check-group { border: 1px solid var(--border); border-radius: 8px; padding: 4px 12px 6px; margin: 4px 0; }
.check-group legend { padding: 0 4px; }
.file-in { border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px 14px; margin: 14px 0 0; }
.file-in legend { padding: 0 6px; font-weight: 600; font-size: 13.5px; }
.filed-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; color: var(--text-2); }
.filed-line .icon { width: 14px; height: 14px; color: var(--muted); }
.course-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit;
  transition: border-color .15s, transform .15s; }
.course-card:hover { border-color: var(--accent); }
.course-card.is-archived { opacity: .65; }
.course-card-head { display: flex; gap: 12px; align-items: center; }
.course-mark { width: 38px; height: 38px; flex: none; }
.course-stats { display: flex; gap: 18px; flex-wrap: wrap; align-items: baseline; font-size: 13.5px; }
.course-edit { margin-top: 12px; }
.course-danger { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.plan-paper + .plan-paper { margin-top: 18px; }
.plan-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 6px; }
.plan-bar { flex: 0 0 160px; height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.plan-bar i { display: block; height: 100%; width: 0; background: var(--ok); }
.plan-no { width: 36px; color: var(--muted); }
.plan-missing td { color: var(--muted); }
.syllabus-help { margin: 0 0 4px; }
.syllabus-summary { cursor: pointer; padding: 2px 0; }
.syllabus-add { padding-top: 10px; border-top: 1px dashed var(--border); }
.syllabus-no { flex: 0 0 72px !important; }
.inline-edit { display: inline-block; }
.inline-edit[open] { display: block; }
.inline-edit > summary { list-style: none; display: inline-flex; }
.inline-edit > summary::-webkit-details-marker { display: none; }
.row-form { display: inline; margin: 0; }
@media (max-width: 960px) {
  .lib { grid-template-columns: 1fr; }
  .lib-tree { position: static; max-height: 320px; }
}
@media (max-width: 560px) {
  .lib-book { grid-template-columns: 24px minmax(0, 1fr); }
  .lib-thumb { display: none; }
  .lib-actions { grid-column: 2; }
}
.plan-paper .table { table-layout: fixed; }
.plan-paper .table td:nth-child(2) { width: 38%; }
.plan-paper .table td:nth-child(4) { width: 96px; }
@media (max-width: 560px) { .plan-paper .table td:nth-child(2) { width: 45%; } }

/* ---------------------------------------------------------------- question bank analysis */
.health { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.health-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  text-decoration: none; color: var(--text-2); background: var(--surface); }
.health-item strong { font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums; }
.health-item span { font-size: 12.5px; }
a.health-item:hover { border-color: var(--accent); }
.health-warn { background: var(--warn-soft); border-color: transparent; }
.health-warn strong { color: var(--warn); }
.health-ok { background: var(--ok-soft); border-color: transparent; }
.health-ok strong { color: var(--ok); }
.health-zero strong { color: var(--muted); }
.pivot-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.pivot-form .field { min-width: 200px; }
.pivot-presets { display: flex; gap: 4px; flex-wrap: wrap; flex-basis: 100%; }
.chip.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pivot-wrap { max-height: 70vh; overflow: auto; }
.pivot th, .pivot td { white-space: nowrap; }
.pivot thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.pivot tbody th { position: sticky; left: 0; background: var(--surface); font-weight: 550; text-align: left; max-width: 280px;
  overflow: hidden; text-overflow: ellipsis; }
.pivot td a { color: inherit; text-decoration: none; display: block; }
.pivot td a:hover { text-decoration: underline; }
.pivot tfoot td, .pivot tfoot th { border-top: 1px solid var(--border-strong); }
.heat-1 { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.heat-2 { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.heat-3 { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.heat-4 { background: color-mix(in srgb, var(--accent) 38%, transparent); }
.heat-5 { background: color-mix(in srgb, var(--accent) 52%, transparent); color: var(--text); font-weight: 650; }
.more-filters { margin: 12px 0 0; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.more-filters > summary { cursor: pointer; font-weight: 600; font-size: 13.5px; }
.more-filters[open] > summary { margin-bottom: 10px; }
.sort-field { flex-direction: row; align-items: center; gap: 8px; margin-right: auto; }
.sort-field select { width: auto; }
.glance-links { margin-top: 12px; }
.topic-box { margin-top: 4px; }
.topic-box > summary { cursor: pointer; display: inline; }
.topic-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.topic-list ul { padding-left: 16px; }
.add-books { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.read-modes { display: grid; gap: 8px; margin-bottom: 12px; }
.read-mode { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.read-mode:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.read-mode:has(input:disabled) { opacity: .5; cursor: default; }
.read-mode span { display: flex; flex-direction: column; gap: 2px; }
.read-mode small { color: var(--muted); font-size: 12.5px; }
.read-mode em { font-style: normal; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.read-again .card-head h2 { display: flex; align-items: center; gap: 6px; }
.file-list li.file-row { align-items: center; cursor: grab; }
.file-list li.file-row .file-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file-tools { display: inline-flex; gap: 2px; }
.file-list li.is-dragging { opacity: .45; }
.file-list li.is-drop { border-color: var(--accent); background: var(--accent-soft); }
.file-list li.file-list-bar { border: 0; padding: 0 2px; align-items: center; }

/* ---------------------------------------------------------------- question paper builder */
.paper-top { display: flex; flex-direction: column; gap: 12px; }
.paper-stats { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.paper-stat { display: flex; flex-direction: column; padding: 8px 14px; border: 1px solid var(--border); border-radius: 10px; min-width: 120px; }
.paper-stat span { font-size: 12px; color: var(--muted); }
.paper-stat strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.paper-stat.is-warn { border-color: var(--warn); background: var(--warn-soft); }
.paper-meta > summary { cursor: pointer; font-weight: 600; font-size: 13.5px; }
.paper-meta[open] > summary { margin-bottom: 10px; }
.paper-ai { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; padding-top: 10px; border-top: 1px solid var(--border); }
.paper-ai > strong { display: inline-flex; gap: 6px; align-items: center; align-self: center; }
.paper-ai .field { min-width: 150px; }
.paper-ai .help { flex-basis: 100%; }
.paper-bulk { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2, var(--surface)); }
.paper-bulk-pick, .paper-bulk-acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.paper-bulk-similar { display: inline-flex; gap: 6px; align-items: center; }
.paper-bulk-similar select { width: auto; height: 32px; }
.paper-tick { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.paper-q.is-picked { box-shadow: 0 0 0 2px var(--accent); }
.paper-bulk.is-floating { position: fixed; z-index: 40; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(1100px, calc(100vw - 32px)); margin: 0; background: var(--surface); box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.paper-bulk.is-floating > .help { display: none; }
.paper-layout { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 18px; align-items: start; }
.paper-add { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
.paper-filter { display: flex; flex-direction: column; gap: 8px; }
.paper-filter select[multiple] { min-height: 4.5em; }
.paper-filter-row { display: flex; gap: 8px; align-items: center; }
.paper-filter-row > * { flex: 1; min-width: 0; }
.paper-random { flex: 0 0 76px !important; }
.paper-results { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.paper-res { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; display: grid; gap: 4px; }
.paper-res-text { font-size: 13.5px; max-height: 4.6em; overflow: hidden; }
.paper-res .btn { justify-self: start; }
.paper-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.paper-cov { display: grid; grid-template-columns: 100px 1fr; gap: 8px; align-items: start; margin-bottom: 6px; }
.paper-cov-chips { display: flex; flex-wrap: wrap; gap: 2px; }
.chip.is-warn { border-color: var(--warn); color: var(--warn); }
.paper-sec { display: flex; flex-direction: column; gap: 12px; }
.paper-sec-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.paper-sec-title { font-weight: 700; font-size: 16px; flex: 1 1 200px; width: auto; }
.paper-q { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); }
.paper-q.is-variant { border-left: 4px solid #6c3483; }
.paper-q.is-generated { border-left: 4px solid #1f5fad; }
.paper-q.is-working { opacity: .75; }
.paper-q.is-failed { border-color: var(--err); }
.paper-q-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.paper-mode.is-variant { background: #f1e7f6; color: #6c3483; }
.paper-mode.is-generated { background: #e6eef9; color: #1f5fad; }
.paper-marks-field { display: inline-flex; gap: 4px; align-items: center; }
.paper-marks { width: 64px; }
.paper-status { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.paper-status.is-bad { color: var(--err); }
.paper-status .spinner { width: 16px; height: 16px; }
.paper-fb { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.paper-fb-line { display: grid; grid-template-columns: 110px 1fr; gap: 8px; }
.paper-fb-k { color: var(--muted); font-size: 12px; font-weight: 600; }
.paper-fb-warn { color: var(--warn); font-size: 13px; }
.paper-check { margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--border-strong); display: flex; flex-direction: column; gap: 4px; }
.paper-verdict { font-weight: 650; }
.paper-verdict.is-ok { color: var(--ok); }
.paper-verdict.is-bad { color: var(--err); }
.paper-verdict.is-warn { color: var(--warn); }
.paper-method { margin: 2px 0 2px 18px; padding: 0; }
.paper-pick { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding-top: 6px; }
.paper-tools { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
.paper-tools .danger { color: var(--err); }
.paper-move { width: auto; height: 30px; font-size: 12.5px; }
.paper-ask { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.paper-ask select { width: auto; }
.paper-note-input { flex: 1 1 300px; width: auto; }
.paper-toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 50; padding: 10px 16px; border-radius: 10px;
  background: #1f2937; color: #fff; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.paper-toast.is-bad { background: var(--err); }
@media (max-width: 1100px) { .paper-layout { grid-template-columns: 1fr; } .paper-add { position: static; max-height: none; } }

/* ------------------------------------------------------------------ AI desk, manage lists, syllabus import */
.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi-link { text-decoration: none; color: inherit; transition: border-color .15s; }
.kpi-link:hover { border-color: var(--accent); }
.ai-task-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.ai-task-card { display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); color: inherit; text-decoration: none; cursor: pointer; transition: border-color .15s, background .15s; }
.ai-task-card:hover { border-color: var(--accent); }
.ai-task-pick input { position: absolute; opacity: 0; pointer-events: none; }
.ai-task-pick { position: relative; }
.ai-task-pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.ai-task-pick:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.ai-new { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.ai-estimate { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 10px; }
.ai-est-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13.5px; }
.ai-est-grid dt { color: var(--muted); }
.ai-est-grid dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ai-preview pre, .ai-call-box pre { max-height: 300px; font-size: 11.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-preview h4, .ai-call-box h4 { margin: 10px 0 4px; }
.ai-system textarea, .ai-new textarea { font-family: inherit; }
.ai-system textarea[name="system"] { font-family: var(--mono); font-size: 12px; }
.ai-strip { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between; border-color: var(--accent); }
.ai-strip-head { display: flex; flex-direction: column; gap: 2px; }
.ai-strip-head strong { display: inline-flex; gap: 6px; align-items: center; }
.ai-strip-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-quick { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ai-quick li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ai-changes { display: flex; flex-direction: column; gap: 12px; }
.ai-change { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.ai-change.is-pending { border-color: var(--warn); }
.ai-change.is-applied { border-left: 4px solid var(--ok); }
.ai-change.is-failed { border-left: 4px solid var(--err); }
.ai-change.is-rejected, .ai-change.is-undone { opacity: .75; }
.ai-change-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.ai-change-head .inline-actions { margin-left: auto; }
.ai-change-q { margin: 8px 0 0; color: var(--text-2); max-height: 4.5em; overflow: hidden; }
.ai-change-note { margin: 8px 0 0; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--text); }
.ai-diff { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.ai-diff-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: start; }
.ai-diff-label { font-size: 12.5px; font-weight: 600; color: var(--muted); padding-top: 6px; }
.ai-diff-before, .ai-diff-after { position: relative; padding: 18px 10px 8px; border-radius: 8px; min-width: 0; overflow-wrap: anywhere; font-size: 13.5px; }
.ai-diff-before { background: var(--err-soft); }
.ai-diff-after { background: var(--ok-soft); }
.ai-diff-tag { position: absolute; top: 3px; left: 10px; font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ai-diff .pm-solution { margin: 0; }
.ai-opts { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; }
.ai-call-box { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.ai-log td { vertical-align: top; }
.badge-info { background: var(--info-soft); color: var(--info); }
.ai-change.is-replaced { opacity: .7; border-style: dashed; }
.ai-change.is-retry { margin-left: 22px; }
.ai-change.is-editing { border: 2px solid var(--accent); opacity: 1; }
.ai-tick { width: 16px; height: 16px; margin: 0; }
.ai-select-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; margin: 8px 0;
  border-radius: 10px; background: var(--accent-soft); position: sticky; top: 0; z-index: 5; }
.ai-select-all { display: inline-flex; margin: 6px 0; }
.ai-edit { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.ai-edit-row .ai-diff-label { display: flex; gap: 6px; align-items: flex-start; color: var(--text); cursor: pointer; }
.ai-edit-row.is-off .ai-diff-after { opacity: .35; pointer-events: none; }
.ai-edit-row.is-off .ai-diff-label { color: var(--muted); text-decoration: line-through; }
.ai-edit textarea, .ai-edit input[type="text"], .ai-edit select { width: 100%; font: inherit; }
.ai-edit .inline-form input[type="text"] { width: auto; flex: 1; }
.ai-chip-edit .chip { padding-right: 3px; }
.chip-x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1;
  padding: 0 4px; border-radius: 999px; }
.chip-x:hover { color: var(--err); background: var(--err-soft); }
.ai-item-edit { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 6px; align-items: start; }
.ai-sol-edit { display: flex; flex-direction: column; gap: 4px; }
.ai-sol-edit textarea { font-family: var(--mono); font-size: 12.5px; }
.ai-again { max-width: 560px; width: calc(100% - 32px); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 20px; background: var(--surface); color: var(--text); }
.ai-again::backdrop { background: rgba(0, 0, 0, .35); }
.ai-again form { display: flex; flex-direction: column; gap: 10px; }
.ai-again h2 { margin: 0; }
.ai-again textarea, .ai-again select { width: 100%; font: inherit; }
/* Download PDF dialog: plain or with a logo watermark, three pages previewed */
.pdf-dl { width: min(1080px, calc(100% - 32px)); max-height: calc(100vh - 32px); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 20px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.pdf-dl::backdrop { background: rgba(0, 0, 0, .4); }
.pdf-dl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.pdf-dl-head h2 { margin: 0; }
.pdf-dl-body { display: grid; grid-template-columns: minmax(250px, 320px) minmax(0, 1fr); gap: 20px; }
.pdf-dl-options { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pdf-dl-options .segmented { margin-bottom: 0; align-self: flex-start; }
.pdf-dl-wm { display: flex; flex-direction: column; gap: 12px; }
.pdf-dl-wm.is-off { opacity: .45; pointer-events: none; }
.pdf-dl-wm input[type=range] { width: 100%; accent-color: var(--accent); }
.pdf-dl-wm .check { padding: 0; }
.pdf-dl-wm .check .help { display: block; margin-top: 2px; }
.pdf-dl-shot a { display: block; width: 100%; cursor: zoom-in; }
.range-val { font-weight: 700; color: var(--accent); margin-left: 4px; font-variant-numeric: tabular-nums; }
.pdf-dl-note { margin: 0; }
.pdf-dl-preview { display: flex; flex-direction: column; gap: 8px; min-width: 0; background: var(--surface-3);
  border-radius: 10px; padding: 10px; }
.pdf-dl-pager { display: flex; justify-content: center; align-items: center; gap: 6px 10px; flex-wrap: wrap; }
.pdf-dl-pager > span, .pdf-dl-goto { white-space: nowrap; }
.pdf-dl-pages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pdf-dl-shot { margin: 0; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.pdf-dl-shot img { width: 100%; aspect-ratio: 210 / 297; object-fit: contain; background: #fff; border-radius: 4px;
  box-shadow: var(--shadow-md); transition: opacity .15s; }
.pdf-dl-shot.is-loading img { opacity: .35; }
.pdf-dl-shot.is-failed img { visibility: hidden; }
.pdf-dl-shot figcaption { font-size: 12px; color: var(--muted); }
.pdf-dl { overflow-y: auto; }
.pdf-dl-actions { margin-top: 14px; position: sticky; bottom: -18px; margin-bottom: -18px; padding-bottom: 18px;
  background: var(--surface); z-index: 1; }
.pdf-dl-skip { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px 10px; margin: 0;
  display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pdf-dl-skip legend { font-size: 13px; font-weight: 600; color: var(--text-2); padding: 0 4px; }
.pdf-dl-skip input[type=text] { width: 100%; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-row[hidden] { display: none; }
.chip-toggle { font: inherit; font-size: 12.5px; padding: 3px 10px; background: var(--surface); color: var(--text-2); cursor: pointer; }
.chip-toggle[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip-toggle[aria-pressed=true]::before { content: "✓"; }
.pdf-dl-goto { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; }
.pdf-dl .pdf-dl-goto input { width: 64px; height: 28px; min-height: 0; padding: 2px 6px; font-size: 13px; }
.pdf-dl-toggle { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.pdf-dl-shot a { position: relative; }
.pdf-dl-shot.is-skipped a::after { content: "No watermark"; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn);
  white-space: nowrap; }
.pdf-dl-actions .is-disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 760px) {
  .pdf-dl { padding: 14px 16px; }
  .pdf-dl-body { grid-template-columns: minmax(0, 1fr); }
  .pdf-dl-pages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pdf-dl-shot:nth-child(3) { display: none; }
}
/* Testmoz export dialog: what goes, what is left out, pictures before/after compression */
.tm-dl { width: min(980px, calc(100% - 32px)); }
.tm-body { display: flex; flex-direction: column; gap: 14px; }
.tm-count { margin: 0 0 6px; font-size: 15px; }
.tm-notes { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.tm-notes .is-warn, .tm-dl .help.is-warn { color: var(--warn); }
.tm-pics-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.tm-pics-title { font-size: 15px; }
.tm-all { margin: 0; min-width: 220px; }
.tm-table td { vertical-align: middle; }
.tm-pics .table-wrap { position: relative; z-index: 0; }
.tm-table select { min-width: 150px; }
.tm-thumb img { width: 72px; height: 54px; object-fit: contain; background: #fff; border: 1px solid var(--border);
  border-radius: 6px; display: block; }
.tm-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 12px;
  background: var(--surface-3); border-radius: 12px; }
.tm-compare figure { margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tm-compare figcaption { font-size: 13px; color: var(--text-2); }
.tm-compare img { max-width: 100%; max-height: 52vh; width: auto; height: auto; align-self: center; background: #fff;
  border-radius: 6px; border: 1px solid var(--border); }
.tm-compare-close { grid-column: 1 / -1; justify-self: end; }
.tm-result { margin: 0; }
.tm-folder { display: flex; flex-direction: column; gap: 4px; }
.tm-folder-field { margin: 0; }
.tm-folder-input { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); overflow: hidden; }
.tm-folder-input code { display: flex; align-items: center; padding: 0 8px; background: var(--surface-2, var(--bg));
  color: var(--text-2); border-right: 1px solid var(--border); font-size: 13px; white-space: nowrap; }
.tm-folder-input input { border: 0; border-radius: 0; flex: 1 1 auto; min-width: 0; }
.tm-folder .help { margin: 0; }
.tm-state { display: block; color: var(--text-2); }
.tm-state.is-new { color: var(--accent); }
@media (max-width: 760px) {
  .tm-compare { grid-template-columns: minmax(0, 1fr); }
  .tm-all { min-width: 0; width: 100%; }
  .tm-dl .pdf-dl-actions { z-index: 3; bottom: -14px; margin-bottom: -14px; padding-bottom: 14px; }
  .tm-dl .pdf-dl-actions .btn { flex: 1 1 auto; }
}
.ai-again-list { margin: 10px 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.ai-again-list .inline-form { display: inline-flex; margin: 0; }
.ai-filters { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; }
.ai-filter-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.ai-filter-row select, .ai-filter-row input[type="search"] { min-height: 34px; }
.ai-filter-row input[type="search"] { flex: 1; min-width: 200px; }
.ai-concern { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.ai-concern.is-disagrees { background: var(--err-soft); color: var(--err); }
p.ai-concern { display: inline-flex; margin: 0 0 8px; }
.ai-change.is-full { padding-bottom: 14px; }
.ai-full { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .6fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.ai-full-col { min-width: 0; border-radius: 10px; padding: 10px 12px; border: 1px solid var(--border); background: var(--surface); }
.ai-full-col.is-ai { background: var(--info-soft); border-color: transparent; align-self: start; position: sticky; top: 8px; }
.ai-full-title { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ai-full-col.is-after .ai-full-title { color: var(--ok); }
.ai-full-col.is-before .ai-full-title { color: var(--err); }
.ai-full-body { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.ai-full-part { border-radius: 8px; padding: 4px 6px; border: 2px solid transparent; min-width: 0; overflow-wrap: anywhere; }
.ai-full-part.is-changed { border-color: var(--ok); background: var(--ok-soft); }
.ai-full-part.is-old { border-color: var(--err); background: var(--err-soft); }
.ai-full-part .pm-question, .ai-full-part .pm-explain { margin: 0; }
.ai-full .pm-plain-options { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.ai-full .pm-plain-options li.is-right { font-weight: 600; color: var(--ok); }
.ai-right { color: var(--ok); font-weight: 700; }
.ai-full-answer.is-ungraded { color: var(--warn); }
.ai-full-facts { display: flex; flex-direction: column; gap: 4px; }
.ai-full-facts .chip { margin: 0 4px 2px 0; }
@media (max-width: 1200px) {
  .ai-full { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .ai-full-col.is-ai { grid-column: 1 / -1; grid-row: 1; position: static; }
}
@media (max-width: 700px) {
  .ai-full { grid-template-columns: 1fr; }
}
.exam-fields { border: 1px dashed var(--border-strong); border-radius: 10px; padding: 6px 10px; }
.exam-fields[open] { padding-bottom: 10px; }
.exam-fields .form-grid { margin-top: 8px; }
.manage-tabs { margin: 4px 0; }
tr.is-archived td { opacity: .6; }
.label-edit { margin: 0; flex-wrap: nowrap; }
.label-edit input:not([type="hidden"]) { min-height: 32px; padding: 5px 8px; }
.topic-tools { display: inline-block; }
.topic-tools[open] { display: block; margin: 4px 0 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; }
.topic-plan { margin: 0; padding-left: 0; list-style: none; font-size: 13px; }
.topic-plan ul { list-style: none; padding-left: 18px; }
.topic-plan .is-new, .topic-plan-key.is-new { color: var(--ok); }
.topic-plan .is-there, .topic-plan-key.is-there { color: var(--muted); }
.syllabus-paper-pick { min-width: 260px; }
.prompt-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 1100px) {
  .ai-new { grid-template-columns: 1fr; }
  .ai-estimate { position: static; }
  .kpis-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .ai-diff-row { grid-template-columns: 1fr; }
  .ai-call-box { grid-template-columns: 1fr; }
  .kpis-5 { grid-template-columns: 1fr 1fr; }
  .label-edit { flex-wrap: wrap; }
}
.ai-quick-flags { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ai-quick-flags a.chip { text-decoration: none; }
.paper-filter { display: flex; flex-direction: column; gap: 6px; }
.ai-full .pm-plain-options li.is-marked { color: var(--warn); }
.ai-full .pm-plain-options li.is-marked .ai-right { color: var(--warn); font-weight: 500; font-size: 12px; }
.ai-use-answer { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.ai-again input[name=title] { width: 100%; font: inherit; }
.ai-print-modes { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; }
.ai-print-modes legend { padding: 0 4px; color: var(--muted); }
.ai-print-modes .check { align-items: flex-start; }

/* ---- Syllabus map (/syllabus) ---- */
a.kpi { color: inherit; text-decoration: none; }
a.kpi:hover { border-color: var(--accent); }
.kpi-warn .kpi-value { color: var(--warn); }
.sx-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.sx-search { flex: 1 1 320px; min-width: 0; font: inherit; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); color: inherit; }
.sx-tools .help { flex-basis: 100%; margin: 0; }
.sx-unsorted { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sx-level { margin: 22px 0 8px; }
.sx-subject { padding: 0; }
.sx-subject > details > summary { padding: 14px 18px; cursor: pointer; }
.sx-head, .sx-paper-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.sx-count { display: inline-block; min-width: 2.2em; padding: 0 8px; border-radius: 999px; text-align: center;
  font-weight: 700; font-variant-numeric: tabular-nums; background: var(--accent-soft); color: var(--accent);
  text-decoration: none; }
a.sx-count:hover { outline: 1px solid var(--accent); }
.sx-paper { padding: 4px 18px 14px; border-top: 1px solid var(--border); }
.sx-paper-head { padding: 10px 0 6px; }
.sx-chapter { border: 1px solid var(--border); border-radius: 10px; margin: 6px 0; background: var(--surface); }
.sx-chapter > summary { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 8px 12px; cursor: pointer; list-style: none; }
.sx-chapter > summary::-webkit-details-marker { display: none; }
.sx-chapter[open] > summary { border-bottom: 1px solid var(--border); }
.sx-chapter.is-empty .sx-count { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.sx-num { font-weight: 700; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.sx-name { min-width: 0; }
.sx-stats { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px 10px; }
.sx-body { padding: 10px 12px 12px; }
.sx-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.sx-topics { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 4px 14px; }
.sx-topics li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px;
  border-radius: 8px; }
.sx-topics li:hover { background: var(--accent-soft); }
.sx-topics li a { color: inherit; text-decoration: none; min-width: 0; }
.sx-topics li.is-sub { padding-left: 22px; }
.sx-topics li.is-empty .sx-count { background: transparent; color: var(--muted); font-weight: 400; }
[data-tree-item].is-hidden { display: none; }
@media (max-width: 700px) {
  .sx-chapter > summary { grid-template-columns: 1.8em minmax(0, 1fr); }
  .sx-stats { grid-column: 2; justify-content: flex-start; }
  .sx-paper { padding: 4px 10px 12px; }
}
.nav-group { margin: 10px 10px 2px; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); }
.nav .nav-link { padding: 6px 10px; }

/* job page: time left and the request log */
.eta { display: inline-flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.calls-summary .kpis { margin: 0 0 12px; }
.calls-filter { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 10px; }
.calls-filter input[type="search"] { flex: 1 1 220px; max-width: 360px; }

/* ---------------------------------------------------------------- library polish, full book (2026-10-03) */
.lib-tree { background: var(--surface); }
.lib-row { display: flex; align-items: center; gap: 2px; }
.lib-row .lib-link { flex: 1; min-width: 0; }
.lib-mini { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 7px; color: var(--muted); }
.lib-mini .icon { width: 15px; height: 15px; }
.lib-mini:hover { background: var(--accent-soft); color: var(--accent); }
.lib-book { transition: background .12s; }
.lib-thumb { box-shadow: var(--shadow); }
.bulkbar { border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: var(--shadow-lg); border-radius: 14px; }

.fb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.fb-side { position: sticky; top: 86px; display: flex; flex-direction: column; gap: 14px; }
.fb-side .card-head { margin-bottom: 0; }
.steps-note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--text-2); }
.steps-note p { margin: 0; }
.step-dot { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--accent-grad);
  color: #fff; font-weight: 700; font-size: 13px; }
.fb-paper .card-head { align-items: flex-start; }
.fb-meter { flex: 0 0 150px; height: 8px; margin-top: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.fb-meter i { display: block; height: 100%; width: 0; background: var(--accent-grad); border-radius: 999px; }
.fb-chapters { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.fb-chapter { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 12px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); transition: border-color .15s, background .15s; }
.fb-chapter.is-picked { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.fb-chapter.is-missing { background: var(--surface-2); border-style: dashed; }
.fb-no { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-3); color: var(--text-2);
  font-weight: 750; font-size: 15px; font-variant-numeric: tabular-nums; }
.fb-chapter.is-picked .fb-no { background: var(--accent-grad); color: #fff; }
.fb-body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.fb-name { font-weight: 650; font-size: 14.5px; padding-top: 2px; }
.fb-books { display: flex; flex-direction: column; gap: 6px; }
.fb-book { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; }
.fb-book:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.fb-book:has(input:checked) { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.fb-book-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.fb-book-title { font-weight: 600; overflow-wrap: anywhere; }
.fb-empty { color: var(--muted); }
.fb-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fb-summary > div { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.fb-summary strong { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }
.fb-summary span { color: var(--muted); font-size: 12px; }
.fb-options { padding: 6px 12px 8px; }

@media (max-width: 1100px) {
  .fb-layout { grid-template-columns: 1fr; }
  .fb-side { position: static; }
}
@media (max-width: 960px) {
  .lib-tree { max-height: 300px; }
  .bulkbar { position: fixed; left: 12px; right: 12px; bottom: 12px; }
}
@media (max-width: 640px) {
  .fb-chapter { grid-template-columns: 34px minmax(0, 1fr); gap: 10px; padding: 10px; }
  .fb-no { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; }
  .fb-book { padding: 8px; }
  .fb-meter { flex-basis: 100%; }
  .bulkbar select { max-width: none; flex: 1 1 100%; }
  .lib-group-head .inline-actions { width: 100%; }
}
.lib-head .link { text-transform: none; letter-spacing: 0; font-size: 12px; }

/* a notice with a button (job page: add chapter titles) */
.flash-action { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.flash-action > span { flex: 1 1 320px; }

/* practice books of a full book: chapters with their topics folded */
.ps-chapters { display: grid; gap: 6px; max-height: 560px; overflow: auto; padding-right: 4px; }
.ps-part { margin: 10px 0 2px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.ps-chapter { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--surface-2); }
.ps-topics > summary { cursor: pointer; color: var(--accent); margin: 4px 0 0 28px; width: max-content; }
.ps-topics[open] { padding: 4px 0 2px 28px; }
.ps-topics[open] > summary { margin-left: 0; }
.ps-make { margin-top: 12px; }

/* ---------------------------------------------------------------- storage page */
.stg-bar { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: var(--idle-soft); }
.stg-bar .stg-seg { height: 100%; min-width: 3px; }
.stg-bar .stg-seg + .stg-seg { box-shadow: inset 2px 0 0 var(--surface); }
.stg-legend { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 18px; }
.stg-legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; font-size: 13px; }
.stg-legend i { width: 12px; height: 12px; border-radius: 4px; }
.stg-uploads { background: #4f46e5; } .stg-pdfs { background: #0ea5e9; } .stg-slides { background: #f59e0b; }
.stg-pdftools { background: #db2777; } .stg-other { background: #10b981; } .stg-previews { background: #94a3b8; }
.stg-db { background: #7c3aed; } .stg-cache { background: #64748b; }
.stg-compress-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin: 14px 0; }
.stg-compress-bar .segmented { margin: 0; }
.stg-progress { margin: 0 0 14px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--info-soft); }
.stg-progress p { margin: 6px 0 0; overflow-wrap: anywhere; }
.stg-tick { width: 34px; }
.stg-same { max-width: 240px; margin-left: auto; white-space: normal; }
.stg-list { list-style: none; margin: 0; padding: 0; }
.stg-list li { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.stg-list li:last-child { border-bottom: 0; }
.stg-list li > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stg-list form { margin: 0; flex: none; }
@media (max-width: 640px) { .stg-list li { flex-direction: column; align-items: flex-start; } .stg-compress-bar .inline-actions .btn { width: 100%; } }

/* Storage → Cloudflare R2 folders */
.stg-sub { margin: 18px 0 6px; font-size: 1rem; }
.r2-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.r2-actions form { margin: 0; }

/* Typists (My work, a typist's book) and Users & typists */
.quota-box { margin: 14px 4px 0; padding: 10px 12px; border-radius: 10px; background: var(--side-hover); border: 1px solid var(--side-line);
  color: var(--side-text); font-size: 12.5px; }
.quota-head { display: flex; justify-content: space-between; gap: 8px; }
.quota-box small { display: block; margin-top: 6px; color: var(--side-muted); font-size: 11.5px; }
.quota-bar, .day-bar { display: block; height: 6px; margin-top: 8px; border-radius: 999px; background: var(--side-line); overflow: hidden; }
.quota-bar i, .day-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent-grad); }
.quota-bar i.is-full, .day-bar i.is-full { background: var(--err); }
.day-bar { background: var(--surface-3); margin: 0; min-width: 120px; }
.usage-days .bar-cell { width: 70%; }
.steps-line { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.steps-line li { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); }
.steps-line strong { display: block; }
.steps-line small { color: var(--muted); font-size: 12px; }
.step-no { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-grad);
  color: #fff; font-weight: 700; font-size: 13px; }
.stack-form { display: flex; flex-direction: column; gap: 12px; }
.stack-form .segmented { margin-bottom: 0; align-self: flex-start; }
.page-viewer .inline-actions { margin-bottom: 10px; }
.page-viewer select { max-width: 100%; min-width: 0; flex: 1 1 160px; }
.page-viewer-img { display: block; width: 100%; height: auto; min-height: 200px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; cursor: zoom-in; }
.secret-box { display: flex; flex-direction: column; gap: 8px; }
.secret-line { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.secret-line span { min-width: 80px; color: var(--text-2); }
.secret-line code { font-size: 16px; padding: 4px 10px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border);
  user-select: all; }
tr.is-muted td { opacity: .6; }
tr.row-refused td { background: var(--err-soft); }
.table-compact td, .table-compact th { padding-top: 6px; padding-bottom: 6px; }
@media (max-width: 720px) {
  .steps-line { grid-template-columns: 1fr; }
}
