/* SOP Sign-off. All colours are :root variables (light), redefined twice for dark
   as Code/.claude/theme-spec.md asks. House look from Skills-Matrix. */
:root {
  color-scheme: light;
  --orange: #f4792a;
  --head-bg: #3d3d3d; --head-sub: #d0d0d0;
  --page: #f6f5f3; --paper: #ffffff; --paper-2: #f9f9f9;
  --ink: #222222; --muted: #77777a; --charcoal: #3d3d3d;
  --rule: #d6d6d6; --rule-mid: #9a9a9a;
  --hl: #fdeadd; --row-hover: #faf8f6; --track: #eeece9;
  --ok-bg: #d5ecd4; --ok-fg: #1e6b25;
  --bad-bg: #f6d3cf; --bad-fg: #9b1c10;
  --warn-bg: #fdecc8; --warn-fg: #8a5200;
  --new-bg: #dbe8f8; --new-fg: #1d4f8c;
  --sel-bg: #3d3d3d; --sel-ink: #ffffff;
  --img-bg: #ffffff;
  --shadow: rgba(0, 0, 0, 0.08); --veil: rgba(20, 21, 23, 0.6);
}
@media screen and (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --head-bg: #1a1a19; --head-sub: #c3c2b7;
    --page: #0d0d0d; --paper: #1a1a19; --paper-2: #232321;
    --ink: #ffffff; --muted: #9a988f; --charcoal: #e4e3dc;
    --rule: #333331; --rule-mid: #4a4a47;
    --hl: #3a2810; --row-hover: #232321; --track: #2c2c2a;
    --ok-bg: #12301a; --ok-fg: #7fd486;
    --bad-bg: #3a1d1d; --bad-fg: #ff8a8a;
    --warn-bg: #3a2f14; --warn-fg: #f0c060;
    --new-bg: #15263c; --new-fg: #8cb8f0;
    --sel-bg: #e9e8e3; --sel-ink: #111111;
    --img-bg: #e9e8e3;
    --shadow: rgba(0, 0, 0, 0.5); --veil: rgba(0, 0, 0, 0.7);
  }
}
@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --head-bg: #1a1a19; --head-sub: #c3c2b7;
    --page: #0d0d0d; --paper: #1a1a19; --paper-2: #232321;
    --ink: #ffffff; --muted: #9a988f; --charcoal: #e4e3dc;
    --rule: #333331; --rule-mid: #4a4a47;
    --hl: #3a2810; --row-hover: #232321; --track: #2c2c2a;
    --ok-bg: #12301a; --ok-fg: #7fd486;
    --bad-bg: #3a1d1d; --bad-fg: #ff8a8a;
    --warn-bg: #3a2f14; --warn-fg: #f0c060;
    --new-bg: #15263c; --new-fg: #8cb8f0;
    --sel-bg: #e9e8e3; --sel-ink: #111111;
    --img-bg: #e9e8e3;
    --shadow: rgba(0, 0, 0, 0.5); --veil: rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page); color: var(--ink);
  font: 14px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif;
  display: flex; flex-direction: column;
}

/* ── header (as Skills-Matrix: charcoal, orange rule, logo) ── */
body > header {
  background: var(--head-bg); color: #fff; border-bottom: 4px solid var(--orange);
  display: flex; align-items: center; gap: 24px; padding: 14px 20px;
}
body > header img { height: 44px; }
body > header .title { flex: 1; min-width: 0; }
body > header h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: 0.01em; }
body > header .sub { color: var(--head-sub); font-size: 13px; }
.themebtn {
  flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.28); border-radius: 6px; background: transparent; color: #fff;
}
.themebtn:hover { background: rgba(255, 255, 255, 0.12); }
.themebtn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.steps { display: flex; gap: 4px; padding: 8px 20px; background: var(--paper); border-bottom: 1px solid var(--rule); font-size: 13px; overflow-x: auto; }
.steps span { padding: 3px 12px; border-radius: 999px; color: var(--muted); white-space: nowrap; }
.steps span.on { background: var(--sel-bg); color: var(--sel-ink); font-weight: 600; }

#banners:empty { display: none; }
#banners { padding: 10px 20px 0; display: flex; flex-direction: column; gap: 6px; }
.banner { border-radius: 6px; padding: 6px 12px; font-size: 13px; font-weight: 600; border: 1px solid var(--orange); background: var(--hl); color: var(--ink); }
.banner.bad { border-color: var(--bad-fg); background: var(--bad-bg); color: var(--bad-fg); }

main { flex: 1; min-height: 0; padding: 14px 20px; overflow: auto; }
main[data-screen="assign"] { overflow: hidden; }

/* ── shared bits ── */
h2 { margin: 0 0 6px; font-size: 18px; color: var(--charcoal); }
h3 { margin: 0; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.bad { color: var(--bad-fg); }
.warn { color: var(--warn-fg); }
.ok { color: var(--ok-fg); font-weight: 600; }
p { margin: 0 0 10px; }
.btn {
  font: inherit; font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--orange); background: var(--orange); color: #fff; white-space: nowrap;
}
.btn.ghost { background: var(--paper); color: var(--ink); border-color: var(--rule); font-weight: 400; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible, .link:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.link { border: 0; background: none; color: var(--orange); font: inherit; font-weight: 600; cursor: pointer; padding: 0 2px; text-decoration: underline; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--track); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.new { background: var(--new-bg); color: var(--new-fg); }
.pill.upd { background: var(--warn-bg); color: var(--warn-fg); }
.panel { max-width: 760px; margin: 0 auto; background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; padding: 22px; }
.panel.wide { max-width: 1100px; }

/* ── load + reading ── */
.drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 34px 16px; margin: 14px 0 8px;
  border: 2px dashed var(--rule-mid); border-radius: 10px; cursor: pointer; text-align: center; }
.drop:hover, .drop.over, .drop:focus-within { border-color: var(--orange); background: var(--hl); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop span { color: var(--muted); font-size: 13px; }
.bar { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; margin: 8px 0 14px; }
.bar span { display: block; height: 100%; background: var(--orange); transition: width 0.2s; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.thumbs figure { margin: 0; }
.thumbs img { width: 100%; border: 1px solid var(--rule); border-radius: 4px; display: block; background: var(--img-bg); }
.thumbs figcaption { font-size: 11px; text-align: center; color: var(--muted); }
.thumbs .unread figcaption { color: var(--bad-fg); font-weight: 600; }
img.rot { transform: rotate(180deg); }

/* ── assign: list | pages | form ── */
.assign { display: grid; grid-template-columns: 240px minmax(0, 1fr) 300px; gap: 14px; height: 100%; }
.list, .form, .pages-col { background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; min-height: 0; }
.list { display: flex; flex-direction: column; }
.listhead { padding: 10px 12px; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; font-size: 13px; }
.listhead b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list ol { list-style: none; margin: 0; padding: 4px 0; overflow: auto; flex: 1; min-height: 0; }
.list li { display: flex; gap: 8px; align-items: baseline; padding: 5px 12px; cursor: pointer; font-size: 13px; border-left: 3px solid transparent; }
.list li:hover { background: var(--row-hover); }
.list li .n { color: var(--muted); font-size: 11px; width: 20px; text-align: right; flex: none; }
.list li .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list li .p { color: var(--muted); font-size: 11px; flex: none; }
.list li.todo { background: var(--warn-bg); }
.list li.todo .t b { color: var(--warn-fg); }
.list li.done .t b { color: var(--ok-fg); }
.list li.saved .t { color: var(--ok-fg); }
.list li.skip .t { color: var(--muted); text-decoration: line-through; }
.list li.cur { background: var(--hl); border-left-color: var(--orange); }
.listfoot { padding: 10px 12px; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 6px; }

.pages-col { display: flex; flex-direction: column; overflow: hidden; }
.pagebar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--rule); font-size: 13px; }
.pagebar .grow { flex: 1; }
.zoom { display: inline-flex; gap: 4px; align-items: center; }
.zoom span { min-width: 42px; text-align: center; font-size: 12px; color: var(--muted); }
.pages { flex: 1; min-height: 0; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 16px; }
.pages figure { margin: 0; }
.pages figcaption { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px;
  padding-top: 10px; border-top: 2px dashed var(--rule); }
.pages figure:first-child figcaption { border-top: 0; padding-top: 0; }
.pages .img { overflow: auto; border: 1px solid var(--rule); border-radius: 4px; background: var(--img-bg); }
.pages img { display: block; max-width: none; cursor: zoom-in; }
.btn.split { padding: 5px 14px; font-size: 13px; }

.form { padding: 14px; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); cursor: pointer; margin-top: -4px; }
.form input:not([type="checkbox"]):not([type="radio"]) {
  font: inherit; font-size: 14px; padding: 7px 9px; border: 1px solid var(--rule-mid); border-radius: 6px; background: var(--paper); color: var(--ink); width: 100%;
}
.form input:focus { outline: 2px solid var(--orange); outline-offset: -1px; }
.form p { margin: -4px 0 0; }
.levels { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.levels legend { font-size: 12px; color: var(--muted); padding: 0; margin-bottom: 4px; }
.levels label { flex-direction: row; justify-content: center; align-items: center; gap: 0; border: 1px solid var(--rule-mid); border-radius: 6px; padding: 7px 4px; cursor: pointer; font-size: 13px; color: var(--ink); }
.levels input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.levels label:has(input:checked) { background: var(--sel-bg); border-color: var(--sel-bg); color: var(--sel-ink); font-weight: 600; }
.levels label:has(input:focus-visible) { outline: 2px solid var(--orange); outline-offset: 1px; }
.form .row { margin-top: 4px; }
.form .row .btn { flex: 1; }

/* ── review + results ── */
.tablewrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 8px; }
.table { border-collapse: collapse; width: 100%; font-size: 13px; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; background: var(--paper-2); }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.off td { color: var(--muted); }
.table tr.off td b { color: var(--muted); }
.table input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--orange); }

/* ── view key prompt (as Skills-Matrix) ── */
#keyprompt { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: var(--veil); }
#keyprompt form { width: 380px; max-width: 92vw; background: var(--paper); border-radius: 10px; padding: 22px; box-shadow: 0 10px 40px var(--shadow); }
#keyprompt h2 { margin: 0 0 6px; font-size: 18px; }
#keyprompt p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
#keyprompt .row { display: flex; gap: 6px; margin: 0; flex-wrap: nowrap; }
#keyprompt input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 7px 9px; border: 2px solid var(--orange); border-radius: 6px; background: var(--paper); color: var(--ink); }

/* ── narrow screens ── */
@media (max-width: 1000px) {
  .assign { grid-template-columns: 200px minmax(0, 1fr); }
  .form { grid-column: 1 / -1; }
  main[data-screen="assign"] { overflow: auto; }
  .assign { height: auto; }
  .pages-col { height: 75vh; }
}
@media (max-width: 700px) {
  body > header { padding: 12px 16px; gap: 12px; }
  body > header img { height: 34px; }
  body > header h1 { font-size: 18px; }
  body > header .sub { display: none; }
  .steps, main { padding-left: 16px; padding-right: 16px; }
  #banners { padding: 10px 16px 0; }
  .panel { padding: 16px; }
  .assign { display: flex; flex-direction: column; }
  .list ol { max-height: 180px; }
  .pages-col { height: 70vh; }
}
