:root {
  --ink: #18212c; --ink-2: #3a4553; --muted: #6a7482; --faint: #98a1ad;
  --line: #e2e5ea; --line-2: #eef0f3; --bg: #f5f6f8; --panel: #fff;
  --accent: #0f5c4d; --accent-2: #e6f1ee; --accent-ink: #0a4a3e;
  --st-pending: #8a94a3; --st-in_review: #2f6fdb; --st-needs_changes: #b8730a; --st-approved: #1d8348; --st-excluded: #b42318;
  --f-declarative: #3b5bdb; --f-evidence: #7048e8; --f-procedural: #0b7285; --f-metacognitive: #c2255c; --f-finance: #d9480f;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 6px 11px; cursor: pointer; line-height: 1.3; white-space: nowrap; }
.btn:hover { border-color: #c9ced6; background: #fafbfc; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.approve { background: var(--st-approved); border-color: var(--st-approved); color: #fff; }
.btn.warn { color: var(--st-needs_changes); border-color: #ecd3a6; background: #fffaf0; }
.btn.danger { color: var(--st-excluded); border-color: #f1c4bf; background: #fff6f5; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; background: #fff; width: 100%; }
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid #9cc9bd; outline-offset: 0; border-color: var(--accent); }
label.f { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }
kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: #fff; }

/* ---------- login */
.login { display: grid; place-items: center; height: 100vh; background: linear-gradient(160deg, #eef5f3, #f5f6f8 60%); }
.login form { width: 360px; background: #fff; padding: 28px; border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login h1 { font-size: 18px; margin: 12px 0 2px; }
.login .err { color: var(--st-excluded); min-height: 20px; margin-top: 10px; font-size: 13px; }
.logo { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }

/* ---------- shell */
.shell { display: grid; grid-template-rows: 52px 1fr; height: 100vh; }
.top { display: flex; align-items: center; gap: 14px; padding: 0 14px; background: #fff; border-bottom: 1px solid var(--line); }
.top .brand { display: flex; align-items: center; gap: 9px; font-weight: 650; }
.top .brand .logo { width: 28px; height: 28px; font-size: 14px; border-radius: 7px; }
.top select { width: auto; max-width: 300px; }
.progress { display: flex; align-items: center; gap: 10px; min-width: 260px; }
.pbar { display: flex; height: 8px; width: 180px; border-radius: 4px; overflow: hidden; background: var(--line-2); }
.pbar span { display: block; height: 100%; }
.top .spacer { flex: 1; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16,24,40,.12); min-width: 220px; padding: 6px; z-index: 30; }
.menu-pop button, .menu-pop a { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--ink); text-decoration: none; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--line-2); }
.menu-pop .sep { height: 1px; background: var(--line); margin: 5px 0; }

.body { display: grid; grid-template-columns: 340px minmax(0, 1fr) 330px; min-height: 0; }
@media (max-width: 1280px) { .body { grid-template-columns: 300px minmax(0, 1fr) 300px; } }

/* ---------- list */
.list { border-right: 1px solid var(--line); background: #fff; display: grid; grid-template-rows: auto auto 1fr; min-height: 0; }
.filters { padding: 10px 10px 6px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.filters .two { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.filters select { font-size: 12px; padding: 4px 6px; }
.list-meta { padding: 6px 12px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; border-bottom: 1px solid var(--line-2); }
.items { overflow-y: auto; }
.grp { position: sticky; top: 0; background: #f8f9fa; padding: 5px 12px; font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line-2); z-index: 1; }
.it { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.it:hover { background: #f7faf9; }
.it.sel { background: var(--accent-2); box-shadow: inset 3px 0 0 var(--accent); }
.it .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; }
.it .nm { font-weight: 550; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.it.excl .nm { text-decoration: line-through; color: var(--muted); }
.it .sub { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.it .rt { font-size: 11px; color: var(--muted); text-align: right; white-space: nowrap; }
.empty { padding: 30px 16px; color: var(--muted); text-align: center; }

/* ---------- chips */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); white-space: nowrap; line-height: 1.6; }
.chip.t { border-color: transparent; }
.chip.st { color: #fff; border-color: transparent; font-weight: 600; }
.chip.warn { background: #fff7e8; border-color: #f2d9a8; color: #8a5a00; }
.chip.ok { background: #eaf6ef; border-color: #bfe3cc; color: #17663a; }
.chip.bad { background: #fdeceb; border-color: #f4c7c3; color: #9b1c12; }
.chip.blue { background: #edf3fe; border-color: #c9dafc; color: #1f4fb0; }
.fam-declarative { background: #edf1fe; color: var(--f-declarative); }
.fam-evidence { background: #f1edfe; color: var(--f-evidence); }
.fam-procedural { background: #e6f5f7; color: var(--f-procedural); }
.fam-metacognitive { background: #fcecf2; color: var(--f-metacognitive); }
.fam-finance { background: #fff0e6; color: var(--f-finance); }

/* ---------- detail */
.detail { overflow-y: auto; min-height: 0; scroll-padding-top: 54px; }
.dhead { background: #fff; border-bottom: 1px solid var(--line); padding: 16px 24px 0; }
.dhead h1 { font-size: 21px; margin: 6px 0 2px; line-height: 1.3; }
.dhead .en { color: var(--muted); font-style: italic; }
.dhead .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.dhead .acts { display: flex; gap: 6px; margin-left: auto; }
.tabs { display: flex; gap: 2px; margin-top: 14px; position: sticky; top: 0; }
.tabs a { padding: 8px 12px; font-size: 13px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .n { font-size: 11px; color: var(--faint); margin-left: 3px; }
.sticky-tabs { position: sticky; top: 0; z-index: 5; background: #fff; border-bottom: 1px solid var(--line); padding: 0 24px; display: flex; }
.content { padding: 16px 24px 80px; max-width: 980px; }
.sec { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.sec > h2 { font-size: 13px; margin: 0; padding: 11px 16px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 8px; }
.sec > h2 .no { width: 20px; height: 20px; border-radius: 50%; background: var(--accent-2); color: var(--accent); display: grid; place-items: center; font-size: 11px; }
.sec > h2 .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.sec > h2 .r { margin-left: auto; }
.sec .in { padding: 14px 16px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; align-items: baseline; }
.kv > .k { color: var(--muted); font-size: 12px; }
.statement { font-size: 15px; line-height: 1.6; background: #fbfcfb; border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 0 6px 6px 0; margin: 0 0 10px; }
.md p { margin: 0 0 6px; line-height: 1.55; }
.md ul, .md ol { margin: 4px 0 6px; padding-left: 20px; line-height: 1.55; }
.md table { border-collapse: collapse; margin: 6px 0; font-size: 13px; }
.md td, .md th { border: 1px solid var(--line); padding: 4px 8px; vertical-align: top; }
.md th { background: #f6f7f9; }
.warns { display: grid; gap: 6px; margin-bottom: 12px; }
.warnline { background: #fff8eb; border: 1px solid #f2dcae; color: #74500a; border-radius: 6px; padding: 7px 10px; font-size: 13px; }
.infoline { background: #f0f5ff; border: 1px solid #cddcfb; color: #23468f; border-radius: 6px; padding: 7px 10px; font-size: 13px; }
.exclbanner { background: #fdeceb; border: 1px solid #f4c7c3; color: #7a1a12; border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center; }

/* Bloom ladder */
.ladder { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: 4px 0 10px; }
.rung { border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; background: #fafbfc; position: relative; min-height: 62px; }
.rung .lv { font-size: 11px; color: var(--faint); }
.rung .nm { font-weight: 600; font-size: 13px; }
.rung .pl { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.rung.below { background: #eef6f3; border-color: #cfe6dd; }
.rung.target { background: var(--accent); border-color: var(--accent); color: #fff; }
.rung.target .lv, .rung.target .pl { color: #d6ebe5; }
.rung .mk { position: absolute; top: -8px; right: 6px; font-size: 10px; padding: 0 5px; border-radius: 8px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.rung .mk.as { border-color: #c9dafc; color: #1f4fb0; }
.rung.pick { cursor: pointer; }
.rung.pick:hover { border-color: var(--accent); }

/* lists inside sections */
.tbl { width: 100%; border-collapse: collapse; }
.tbl td, .tbl th { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; font-size: 13px; }
.tbl th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tbl tr:last-child td { border-bottom: 0; }
.lessons { display: flex; flex-wrap: wrap; gap: 6px; }
.lesson { border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; background: #fff; font-size: 12px; max-width: 290px; }
.lesson b { font-family: var(--mono); font-size: 11px; }
.lesson.key { border-color: #9cc9bd; background: #f3faf8; }
.seglesson { margin-top: 12px; }
.seglesson > .h { font-size: 12px; font-weight: 650; color: var(--ink-2); margin-bottom: 6px; }
.seg { border: 1px solid var(--line-2); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; background: #fcfcfd; }
.seg .sh { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.seg .md { font-size: 13px; color: var(--ink-2); }
.seg.clamp .md { max-height: 88px; overflow: hidden; -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent); mask-image: linear-gradient(180deg, #000 60%, transparent); }
.seg img { max-width: 100%; max-height: 360px; border-radius: 4px; border: 1px solid var(--line); margin-top: 4px; display: block; }
.rel { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.rel:last-child { border-bottom: 0; }
.rel.rej .sent { opacity: .5; text-decoration: line-through; }
.rel .sent { line-height: 1.5; }
.rel .acts { display: flex; gap: 4px; align-items: flex-start; }
.kulink { color: var(--accent); cursor: pointer; text-decoration: none; font-weight: 550; }
.kulink:hover { text-decoration: underline; }
.relverb { background: var(--line-2); border-radius: 4px; padding: 0 6px; font-size: 12px; color: var(--ink-2); }
.subh { font-size: 12px; font-weight: 700; color: var(--muted); margin: 14px 0 4px; text-transform: uppercase; letter-spacing: .03em; }
.subh:first-child { margin-top: 0; }
.addrel { background: #f8f9fa; border: 1px dashed #cfd4db; border-radius: 6px; padding: 10px; margin-top: 12px; display: grid; gap: 8px; }
.addrel .row > * { flex: 1; }
.picker { position: relative; }
.picker .opts { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(16,24,40,.12); max-height: 260px; overflow-y: auto; }
.picker .opt { padding: 6px 10px; cursor: pointer; font-size: 13px; }
.picker .opt:hover, .picker .opt.on { background: var(--accent-2); }
.quote { border-left: 3px solid #e9b8c9; padding: 2px 10px; margin: 4px 0; color: var(--ink-2); font-style: italic; }
pre.json { background: #f6f7f9; border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: 12px; overflow-x: auto; margin: 0; white-space: pre-wrap; }

/* ---------- edit mode */
.editbar { position: sticky; bottom: 0; z-index: 6; background: #fff; border-top: 1px solid var(--line); padding: 10px 24px; display: flex; gap: 8px; align-items: center;
  box-shadow: 0 -4px 12px rgba(16,24,40,.06); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; border: 1px solid var(--line); border-radius: 6px; padding: 4px; background: #fff; }
.tags .tag { background: var(--line-2); border-radius: 4px; padding: 1px 6px; font-size: 12px; display: inline-flex; gap: 4px; align-items: center; }
.tags .tag button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0; }
.tags input { border: 0; flex: 1; min-width: 120px; padding: 3px; }
.tags input:focus { outline: none; }
.err-inline { color: var(--st-excluded); font-size: 12px; margin-top: 4px; }

/* ---------- review rail */
.rail { border-left: 1px solid var(--line); background: #fff; overflow-y: auto; min-height: 0; }
.rail .blk { padding: 14px; border-bottom: 1px solid var(--line); }
.rail h3 { font-size: 12px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.rail h3 .r { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; }
.bigstatus { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bigstatus .lbl { font-size: 16px; font-weight: 650; }
.votebar { display: flex; gap: 3px; margin: 6px 0 10px; }
.votebar span { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.votebar span.on { background: var(--st-approved); }
.vote { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 6px 0; font-size: 13px; }
.vote .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; color: #fff; }
.vote.old { opacity: .5; }
.vote .c { color: var(--ink-2); margin-top: 2px; white-space: pre-wrap; }
.btnstack { display: grid; gap: 6px; }
.cmt { padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.cmt.res { opacity: .55; }
.cmt .b { white-space: pre-wrap; margin-top: 3px; line-height: 1.45; }
.hist { font-size: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line-2); line-height: 1.45; }
.hist .chg { margin-top: 3px; color: var(--ink-2); }
.hist del { color: #9b1c12; background: #fdeceb; text-decoration: none; padding: 0 2px; }
.hist ins { color: #17663a; background: #eaf6ef; text-decoration: none; padding: 0 2px; }
.check { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(16,24,40,.35); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 12px; width: min(560px, 100%); max-height: 88vh; overflow: auto; box-shadow: 0 20px 50px rgba(16,24,40,.25); }
.modal.wide { width: min(900px, 100%); }
.modal header { padding: 16px 20px 0; font-size: 16px; font-weight: 650; }
.modal .mb { padding: 12px 20px; }
.modal footer { padding: 12px 20px 16px; display: flex; gap: 8px; justify-content: flex-end; }
#toast-root { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 6px; }
.toast { background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; }
.toast.err { background: #9b1c12; }
.welcome { padding: 60px 40px; color: var(--muted); max-width: 560px; line-height: 1.6; }
.welcome h2 { color: var(--ink); }
.it { scroll-margin-top: 30px; }
