/* Trellis styles: phone-first, plain CSS, light and dark. */
:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --accent: #1d4ed8; --accent-ink: #ffffff;
  --ok: #059669; --warn: #d97706; --bad: #dc2626; --sel: #dbeafe; --hover: #f1f5f9; --code: #334155; --shadow: 0 1px 2px rgba(15,23,42,.06);
  --radius: 10px; --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg: #0b1220; --panel: #111a2e; --ink: #e5e7eb; --muted: #94a3b8; --line: #243047; --accent: #60a5fa; --accent-ink: #0b1220; --sel: #1e3a8a; --hover: #182238; --code: #cbd5e1; --shadow: none; } }
:root[data-theme="dark"] { --bg: #0b1220; --panel: #111a2e; --ink: #e5e7eb; --muted: #94a3b8; --line: #243047; --accent: #60a5fa; --accent-ink: #0b1220; --sel: #1e3a8a; --hover: #182238; --code: #cbd5e1; --shadow: none; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; }
h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; margin-top: .8em; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-size: .78rem; }
p { margin: .4em 0; }
code, .mono { font-family: var(--mono); font-size: .9em; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 40px; max-width: 100%; }
input[type="checkbox"] { min-height: 0; width: 18px; height: 18px; }
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
ul.list { padding-left: 1.2em; } ul.list li { margin: .25em 0; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .error { color: var(--bad); } .warn-text { color: var(--warn); }
.row { display: flex; align-items: center; } .row.gap { gap: 8px; } .row.wrap { flex-wrap: wrap; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; } .grow { flex: 1 1 160px; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: inherit; text-decoration: underline; text-underline-offset: 2px; }
.linklike.small { font-size: .85rem; }

/* layout */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); padding-top: calc(10px + env(safe-area-inset-top)); }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); display: flex; align-items: center; gap: 6px; } .brand-mark { color: var(--accent); font-size: 1.3rem; }
.topnav { display: none; gap: 4px; } .topnav a { padding: 6px 10px; border-radius: 8px; color: var(--ink); } .topnav a.active { background: var(--sel); } .topnav a:hover { text-decoration: none; background: var(--hover); }
.top-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.main { flex: 1; padding: 12px 12px 90px; max-width: 1400px; width: 100%; margin: 0 auto; }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 4px 6px; font-size: .72rem; color: var(--muted); } .bottomnav a .icon { font-size: 1.2rem; line-height: 1.1; } .bottomnav a.active { color: var(--accent); } .bottomnav a:hover { text-decoration: none; }
@media (min-width: 900px) { .topnav { display: flex; } .bottomnav { display: none; } .main { padding-bottom: 24px; } }
.app-loading { min-height: 100dvh; display: grid; place-items: center; }
.page-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 8px; }
.doc-h { font-size: 1.15rem; } .crumbs { font-size: .85rem; color: var(--muted); }

/* cards & buttons */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin: 10px 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; } .card-head h3 { margin: 0; } .card-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card-body { padding: 12px 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; min-height: 40px; text-decoration: none; }
.btn:hover { background: var(--hover); text-decoration: none; } .btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); } .btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-danger { color: var(--bad); border-color: var(--bad); } .btn-ghost { border-color: transparent; background: transparent; } .btn-link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 0; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .88rem; }
.select-sm { min-height: 32px; padding: 4px 8px; font-size: .88rem; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); font-size: .74rem; background: var(--bg); color: var(--ink); white-space: nowrap; }
.badge-ok { background: #d1fae5; color: #065f46; border-color: #a7f3d0; } .badge-warn { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge.type { color: var(--muted); }
.conf { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.pill { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--sel); font-size: .74rem; } .pill.final { background: #fde68a; color: #78350f; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; min-width: 0; } .field-label { font-size: .82rem; color: var(--muted); } .field-inline { flex-direction: row; align-items: center; gap: 8px; } .hint { font-size: .78rem; color: var(--muted); }
.check { display: inline-flex; gap: 6px; align-items: center; margin: 4px 8px 4px 0; }
.help { margin: 6px 0 10px; font-size: .9rem; } .help summary { cursor: pointer; color: var(--accent); } .help > div { padding: 6px 10px; border-left: 3px solid var(--sel); margin-top: 4px; }
.empty { text-align: center; padding: 40px 12px; color: var(--muted); }
.spinner-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }
.progress { position: relative; height: 18px; background: var(--line); border-radius: 9px; overflow: hidden; margin: 6px 0; } .progress-fill { height: 100%; background: var(--accent); transition: width .3s; } .progress-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: .75rem; }
.toasts { position: fixed; left: 12px; right: 12px; bottom: 70px; display: flex; flex-direction: column; gap: 6px; z-index: 50; pointer-events: none; } @media (min-width: 900px) { .toasts { bottom: 16px; left: auto; width: 360px; } }
.toast { pointer-events: auto; padding: 10px 14px; border-radius: 8px; background: var(--ink); color: var(--bg); box-shadow: 0 4px 16px rgba(0,0,0,.2); font-size: .9rem; } .toast-ok { background: var(--ok); color: #fff; } .toast-warn { background: var(--warn); color: #fff; } .toast-error { background: var(--bad); color: #fff; }
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 40; display: grid; place-items: center; padding: 12px; }
.modal { background: var(--panel); border-radius: 12px; width: min(560px, 100%); max-height: 90dvh; overflow: auto; } .modal-wide { width: min(820px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); } .modal-head h3 { margin: 0; } .modal-body { padding: 14px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 6px 0 10px; scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 8px 12px; border: 0; background: none; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; } .tab.active { color: var(--accent); border-bottom-color: var(--accent); } .tab-badge { margin-left: 4px; background: var(--warn); color: #fff; border-radius: 999px; padding: 0 6px; font-size: .7rem; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; } .table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; } .table th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.table-wrap { overflow-x: auto; }
.code { font-family: var(--mono); font-size: .82em; color: var(--code); background: var(--bg); padding: 0 4px; border-radius: 4px; }

/* library */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px 16px; text-align: center; background: var(--panel); margin-bottom: 12px; } .dropzone.drag { border-color: var(--accent); background: var(--sel); }
.dropzone .row { justify-content: center; }
.import-progress { max-width: 420px; margin: 0 auto; }
.doc-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.doc-card .card-body { padding: 12px; } .doc-title { font-weight: 600; font-size: 1.02rem; cursor: pointer; } .doc-title:hover { color: var(--accent); }

/* review */
.filterbar { margin-bottom: 8px; }
.review-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.pane { min-width: 0; }
.review-grid.tab-tree .pane-page, .review-grid.tab-tree .pane-rules { display: none; }
.review-grid.tab-page .pane-tree, .review-grid.tab-page .pane-rules { display: none; }
.review-grid.tab-rules .pane-tree, .review-grid.tab-rules .pane-page { display: none; }
@media (min-width: 1000px) {
  .review-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  .review-grid .pane-tree, .review-grid .pane-page { display: block !important; }
  .review-grid.tab-rules .pane-page { display: none !important; } .review-grid.tab-rules .pane-rules { display: block !important; }
  .review-grid.tab-tree .pane-rules, .review-grid.tab-page .pane-rules { display: none !important; }
  .review-grid .tabs .tab:nth-child(2) { display: none; }
}
.toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; position: sticky; top: 56px; z-index: 5; margin-bottom: 6px; }
.tree { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; max-height: 70dvh; overflow: auto; }
.tree-row { display: flex; align-items: flex-start; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: .9rem; }
.tree-row:hover { background: var(--hover); } .tree-row.sel { background: var(--sel); } .tree-row.leaf .title { font-weight: 400; } .tree-row:not(.leaf) .title { font-weight: 600; }
.tree-row .title { flex: 1; min-width: 0; overflow-wrap: anywhere; } .tree-row .meta { display: flex; gap: 4px; align-items: center; flex: none; flex-wrap: wrap; justify-content: flex-end; max-width: 40%; }
.tree-row .conf { margin-top: 6px; }
.twisty { background: none; border: 0; width: 18px; padding: 0; color: var(--muted); cursor: pointer; flex: none; } .twisty.none { cursor: default; opacity: .4; }
.tree-editor .small.muted { font-size: .8rem; }
.node-summary { padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; } .node-title { font-weight: 600; margin-top: 4px; }
.pageview { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.pager { margin-bottom: 6px; }
.canvas-wrap { position: relative; margin: 0 auto; max-width: 100%; overflow: hidden; background: #fff; }
.canvas-wrap canvas { display: block; max-width: 100%; }
.hl { position: absolute; border: 1px solid rgba(37,99,235,.35); background: rgba(37,99,235,.06); border-radius: 2px; cursor: pointer; } .hl:hover { background: rgba(37,99,235,.15); } .hl.sel { border: 2px solid #2563eb; background: rgba(37,99,235,.18); z-index: 2; }
.pageview.docx .src { white-space: pre-wrap; background: var(--bg); padding: 10px; border-radius: 8px; font-size: .85rem; }
.split-words .word { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; margin: 2px; cursor: pointer; } .split-words .word:hover { background: var(--sel); }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 12px; }

/* curriculum */
.curr-grid { display: grid; gap: 12px; grid-template-columns: 1fr; } @media (min-width: 1000px) { .curr-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); } .pane-detail { position: sticky; top: 64px; align-self: start; max-height: calc(100dvh - 80px); overflow: auto; } }
.outline { list-style: none; margin: 0; padding: 0; }
.o-row { padding: 5px 8px; border-radius: 6px; cursor: pointer; display: flex; gap: 6px; align-items: baseline; } .o-row:hover { background: var(--hover); } .o-row.sel { background: var(--sel); }
.o-row .title { flex: 1; } .o-row .meta { display: flex; gap: 6px; align-items: center; flex: none; }
.o-row.d0 .title { font-weight: 700; font-size: 1.02rem; } .o-row.d1 .title { font-weight: 600; } .o-row:not(.leaf) .title { font-weight: 600; } .o-row.leaf .title { font-weight: 400; }
.node-detail { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; } .node-detail .block { margin-top: 10px; } .node-detail ul { margin: 4px 0; padding-left: 1.2em; }
.bloom-weights { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 8px 0; } .bloom-weights span { display: block; height: 100%; }
.bars .bar-row { display: grid; grid-template-columns: 90px 1fr 48px; gap: 8px; align-items: center; margin: 4px 0; } .bar { height: 14px; background: var(--line); border-radius: 7px; overflow: hidden; } .bar-fill { height: 100%; } .bar-val { text-align: right; font-size: .85rem; }

/* outputs */
.viability { padding: 8px 10px; border-radius: 8px; margin-top: 8px; font-size: .9rem; } .viability.ok { background: #d1fae5; color: #064e3b; } .viability.warn { background: #fef3c7; color: #78350f; } .viability.bad { background: #fee2e2; color: #7f1d1d; }
.weeks { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.week { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; } .week.holiday { opacity: .7; background: var(--bg); } .week-head { margin-bottom: 4px; }
.entry { display: flex; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); font-size: .9rem; } .entry .periods { flex: none; width: 30px; font-weight: 700; color: var(--accent); } .entry.review { color: var(--muted); }
.coverage td.statuses { white-space: nowrap; } .status { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 8px; font-size: .74rem; margin: 1px; cursor: pointer; min-height: 28px; } .status.on { font-weight: 600; }
@media (max-width: 700px) { .coverage tr { display: grid; } .coverage td { border-bottom: 0; padding: 4px 2px; } .coverage tr { border-bottom: 1px solid var(--line); padding: 4px 0; } }
.lesson-grid { display: grid; gap: 12px; grid-template-columns: 1fr; } @media (min-width: 1000px) { .lesson-grid { grid-template-columns: 320px minmax(0, 1fr); } }
.picklist { list-style: none; margin: 6px 0; padding: 0; max-height: 50dvh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); } .picklist li { padding: 6px 8px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: .88rem; } .picklist li.sel { background: var(--sel); } .picklist li:hover { background: var(--hover); }
.steps li { margin: 8px 0; } .writebox { height: 46px; border: 1px dashed var(--line); border-radius: 6px; margin-top: 4px; }
.blueprint td, .blueprint th { text-align: center; } .blueprint td:first-child, .blueprint th:first-child { text-align: left; } .blueprint tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
.shares .field-inline { margin-right: 6px; }
.study { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); } .study-day { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: .9rem; } .study-day.past { opacity: .6; } .study-day.exam { border-color: var(--warn); } .study-date { font-weight: 700; margin-bottom: 4px; } .study-day ul { margin: 0; padding-left: 1em; }
.checklist { white-space: pre-wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-family: var(--font); font-size: .92rem; }
.findings { list-style: none; padding: 0; margin: 0; } .findings li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .9rem; } .findings li.error .badge { background: #fee2e2; } .findings li.warn .badge { background: #fef3c7; }
.help-page .card p { font-size: .95rem; }

/* print */
.print { padding: 16px; max-width: 1000px; margin: 0 auto; background: #fff; color: #000; font-size: 12.5px; }
.print h1 { font-size: 20px; } .print h2 { font-size: 16px; } .print h3 { font-size: 13px; margin-top: 10px; }
.print-head { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 10px; } .print-head .right { text-align: right; }
.ptable { width: 100%; border-collapse: collapse; } .ptable th, .ptable td { border: 1px solid #999; padding: 4px 6px; vertical-align: top; text-align: left; } .ptable th { background: #eee; } .ptable tr.holiday td { background: #f3f4f6; color: #666; } .ptable tr.total td { font-weight: 700; } .ptable td.tall { height: 70px; } .ptable.kv th { width: 10%; } .ptable.kv td { width: 23%; height: 28px; }
.pnode { padding: 2px 0; } .pnode.d0 { font-weight: 700; font-size: 14px; margin-top: 10px; } .pnode.d1 { font-weight: 600; margin-top: 6px; } .pnode.leaf { font-weight: 400; } .pfield { margin-left: 10px; color: #333; }
.pchecklist { white-space: pre-wrap; font-family: var(--font); font-size: 13px; }
.pday { break-inside: avoid; } .pday ul { margin: 2px 0 8px; padding-left: 1.2em; }
.toolbar-print { margin-bottom: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.print-foot { margin-top: 16px; font-size: 10px; color: #666; border-top: 1px solid #ccc; padding-top: 4px; }
@media print { .noprint { display: none !important; } body { background: #fff; } .print { padding: 0; max-width: none; } @page { margin: 14mm; } .ptable tr { break-inside: avoid; } }

/* linker */
.atlas td.heat { text-align: center; min-width: 44px; font-variant-numeric: tabular-nums; }
.atlas tr.never td { color: var(--muted); } .atlas tr.unit-row td { background: var(--bg); font-weight: 600; padding-top: 10px; } .atlas tbody tr:not(.unit-row) { cursor: pointer; } .atlas tbody tr:not(.unit-row):hover td { background: var(--hover); }
.bars.two .bar.dual { position: relative; height: 18px; } .bars.two .bar.dual .bar-fill { position: absolute; left: 0; height: 50%; } .bars.two .bar.dual .bar-fill:first-child { top: 0; } .bars.two .bar.dual .bar-fill:last-child { top: 50%; }
.qtable tr.suggested td:last-child { background: #fffbeb; } :root[data-theme="dark"] .qtable tr.suggested td:last-child { background: #3b2f0b; }
.diff ins { background: #d1fae5; text-decoration: none; padding: 0 2px; } .diff del { background: #fee2e2; padding: 0 2px; }
:root[data-theme="dark"] .diff ins { background: #064e3b; } :root[data-theme="dark"] .diff del { background: #7f1d1d; }
.align td { text-align: center; } .align td:first-child { text-align: left; }
.picklist li .muted { float: right; }

/* tools */
.keygrid { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.keyrow { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; } .keyrow .qn { width: 26px; font-weight: 600; text-align: right; margin-right: 4px; } .keyrow.warn { background: #fef3c7; border-radius: 6px; } .keyrow .select-sm { max-width: 170px; }
.sheet-preview { max-width: 420px; border: 1px solid var(--line); background: #fff; } .sheet-preview svg { width: 100%; height: auto; display: block; }
.scan-grid { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 10px; } @media (min-width: 900px) { .scan-grid { grid-template-columns: 360px 1fr; } }
.scan-img { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.variants li { margin: 4px 0; }
.picklist.tall { max-height: 70dvh; } .picklist li.neg { background: #fee2e2; } :root[data-theme="dark"] .picklist li.neg { background: #7f1d1d; }
.coh td { text-align: center; } .coh td:first-child { text-align: left; }
.braille { font-size: 1.3rem; line-height: 1.5; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; }
.sql { font-size: .78rem; background: var(--bg); padding: 8px; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; }
textarea.def { min-height: 34px; width: 100%; font-size: .85rem; }
