/* Typecase: tokens and components. See DESIGN.md. */
:root {
  --bg: #ffffff; --bg2: #f5f5f7; --bg3: #eeeef1; --line: #d9d9de; --text: #1d1d1f; --text2: #5f5f66;
  --accent: #0a5bd3; --on-accent: #ffffff; --accent-soft: #e4eefc;
  --ok: #1f7a3d; --warn: #8a5200; --bad: #b3261e; --bad-soft: #fbe9e7; --warn-soft: #fbf0dc;
  --shadow: 0 8px 28px rgba(0, 0, 0, .14), 0 1px 3px rgba(0, 0, 0, .08);
  --r: 8px; --r2: 12px; --chip-l: 93%; --chip-c: 42%; --chip-t: 24%;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --fr-accent: var(--accent); --fr-ink: var(--on-accent); --fr-font: var(--font); --fr-radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e; --bg2: #262628; --bg3: #323235; --line: #46464a; --text: #f5f5f7; --text2: #b4b4bc;
    --accent: #5aa2ff; --on-accent: #0b1220; --accent-soft: #1d3050;
    --ok: #5ad07c; --warn: #f0b14a; --bad: #ff8278; --bad-soft: #472320; --warn-soft: #3f3018;
    --shadow: 0 10px 32px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4); --chip-l: 28%; --chip-c: 38%; --chip-t: 92%;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 15px; font-weight: 650; margin: 0; }
h3 { font-size: 12px; font-weight: 600; color: var(--text2); margin: 18px 0 6px; }
p { margin: 0; } a { color: var(--accent); }
.muted { color: var(--text2); } .small { font-size: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }

/* controls */
button, input, select, textarea { font: inherit; color: inherit; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg); cursor: pointer; white-space: nowrap; transition: background .18s ease-out, border-color .18s ease-out; }
.btn:hover { background: var(--bg2); } .btn:active { background: var(--bg3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); } .btn.quiet { border-color: transparent; background: transparent; color: var(--text2); }
.btn.quiet:hover { background: var(--bg3); color: var(--text); } .btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .45; cursor: default; pointer-events: none; }
.btn.icon { width: 28px; height: 28px; padding: 0; justify-content: center; }
input[type=text], input[type=password], input[type=number], select, textarea { color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  padding: 5px 8px; min-height: 30px; width: 100%; transition: border-color .18s ease-out, box-shadow .18s ease-out; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--text2)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; line-height: 1.55; font-size: 15px; min-height: 64px; padding: 8px 10px; }
textarea.one { min-height: 34px; font-size: 13px; }
label.f { display: grid; gap: 4px; font-size: 12px; color: var(--text2); } label.f > span { font-weight: 500; }
.row { display: flex; gap: 8px; align-items: center; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1 1 auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; } .check input { width: 15px; height: 15px; accent-color: var(--accent); }

/* shell */
.shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); grid-template-rows: 48px minmax(0, 1fr); height: 100vh; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: -.01em; font-size: 15px; display: flex; align-items: center; gap: 8px; cursor: pointer; background: none; border: 0; padding: 4px; }
.brand i { display: grid; grid-template-columns: repeat(3, 5px); gap: 2px; } .brand i b { width: 5px; height: 5px; border-radius: 1px; background: var(--text); } .brand i b:nth-child(5) { background: var(--accent); }
.top .pname { font-weight: 600; border: 1px solid transparent; background: transparent; width: auto; min-width: 120px; max-width: 360px; }
.top .pname:hover { border-color: var(--line); }
.save { font-size: 12px; color: var(--text2); min-width: 86px; } .save.err { color: var(--bad); font-weight: 600; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.nav { display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 10px; border: 0; border-radius: var(--r); background: transparent; cursor: pointer; text-align: left; }
.nav:hover { background: var(--bg3); } .nav.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.nav .n { margin-left: auto; font-size: 11px; color: var(--text2); font-variant-numeric: tabular-nums; } .nav.on .n { color: var(--on-accent); }
.nav .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); margin-left: 4px; } .nav.on .dot { background: var(--on-accent); }
.side .sep { height: 1px; background: var(--line); margin: 8px 4px; } .side .cap { font-size: 11px; color: var(--text2); padding: 6px 10px 2px; font-weight: 600; }
.main { min-width: 0; min-height: 0; overflow: auto; }
.page { padding: 22px 26px 60px; max-width: 1080px; }
.head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 16px; } .head .sub { color: var(--text2); margin-top: 3px; max-width: 70ch; }

/* three panes */
.panes { display: grid; grid-template-columns: 250px minmax(0, 1fr) 340px; height: 100%; min-height: 0; }
.pane { min-height: 0; overflow: auto; padding: 14px; } .pane + .pane { border-left: 1px solid var(--line); }
.pane.list { background: var(--bg2); padding: 10px 8px; } .pane.proof { background: var(--bg2); }
.item { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 30px; padding: 4px 9px; border: 0; border-radius: var(--r); background: transparent; cursor: pointer; text-align: left; }
.item:hover { background: var(--bg3); } .item.on { background: var(--accent-soft); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.item.on .n { color: var(--text); }
.item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; } .item .n { font-size: 11px; color: var(--text2); font-weight: 400; }
.item .warn { color: var(--bad); font-size: 11px; font-weight: 700; }
.group { font-size: 11px; font-weight: 600; color: var(--text2); padding: 12px 9px 3px; }

/* chips (sorts) */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap;
  background: hsl(var(--h, 215) var(--chip-c) var(--chip-l)); color: hsl(var(--h, 215) 40% var(--chip-t)); border: 0; }
.chip.plain { background: var(--bg3); color: var(--text2); } button.chip { cursor: pointer; } button.chip:hover { filter: brightness(.96); }
.chip .x { opacity: .6; font-size: 13px; line-height: 1; } .chip.add { background: transparent; border: 1px dashed var(--line); color: var(--text2); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }

/* variants */
.variant { border: 1px solid var(--line); border-radius: var(--r2); padding: 10px; margin-bottom: 10px; background: var(--bg); }
.variant .vh { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-height: 24px; }
.variant .count { font-size: 11px; color: var(--text2); font-variant-numeric: tabular-nums; margin-left: auto; }
.variant.default { border-style: dashed; }

/* slots (forme) */
.slot { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 8px; border: 1px solid var(--line); border-radius: var(--r2); margin-bottom: 6px; background: var(--bg); }
.slot.drag { opacity: .4; } .slot.over { box-shadow: 0 -2px 0 var(--accent); }
.grip { cursor: grab; color: var(--text2); user-select: none; line-height: 30px; text-align: center; letter-spacing: -2px; }
.slot .body { display: grid; gap: 6px; min-width: 0; } .slot .opts { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 12px; color: var(--text2); }
.slot select { width: auto; max-width: 100%; min-width: 0; } .slot .body > .row > select { flex: 1 1 auto; }

/* proof */
.paper { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r2); padding: 14px 16px; font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 80px; }
.paper .ph { background: var(--bad-soft); color: var(--bad); border-radius: 3px; }
.problem { display: flex; gap: 8px; padding: 6px 9px; border-radius: var(--r); font-size: 12px; margin-top: 6px; background: var(--bad-soft); color: var(--bad); }
.problem.soft { background: var(--warn-soft); color: var(--warn); }
.okline { color: var(--ok); font-size: 12px; margin-top: 8px; font-weight: 600; }

/* flow */
.flow { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; margin: 8px 0 26px; border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; }
.station { position: relative; padding: 14px 14px 16px; background: var(--bg); border: 0; text-align: left; cursor: pointer; min-height: 132px; display: flex; flex-direction: column; gap: 4px; }
.station + .station { border-left: 1px solid var(--line); } .station:hover { background: var(--bg2); }
.station .k { font-size: 11px; color: var(--text2); font-weight: 600; } .station .big { font-size: 28px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.station .what { font-size: 12px; color: var(--text2); } .station .st { margin-top: auto; font-size: 12px; font-weight: 600; }
.station .st.bad { color: var(--bad); } .station .st.ok { color: var(--ok); } .station.next { box-shadow: inset 0 3px 0 var(--accent); }
.tbl { width: 100%; border-collapse: collapse; } .tbl th { text-align: left; font-size: 11px; color: var(--text2); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; } .tbl tr:hover td { background: var(--bg2); }
.tbl td.key { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; white-space: nowrap; }

/* popover, sheet, toast */
.pop { position: fixed; z-index: 50; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r2); box-shadow: var(--shadow); padding: 6px; min-width: 180px; max-height: 320px; overflow: auto; }
.pop .item { min-height: 28px; } .pop .cap { font-size: 11px; color: var(--text2); padding: 6px 9px 2px; font-weight: 600; }
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .32); z-index: 40; display: grid; place-items: center; padding: 16px; }
.sheet { background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); width: min(640px, 100%); max-height: 86vh; overflow: auto; padding: 20px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 10px; z-index: 60; font-weight: 500; box-shadow: var(--shadow); }
.empty { border: 1px dashed var(--line); border-radius: var(--r2); padding: 22px; color: var(--text2); text-align: center; max-width: 60ch; margin: 18px auto; }
.empty b { color: var(--text); display: block; margin-bottom: 4px; font-size: 15px; }
.card { border: 1px solid var(--line); border-radius: var(--r2); padding: 14px; margin-bottom: 12px; }
.plist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pcard { border: 1px solid var(--line); border-radius: var(--r2); padding: 14px; background: var(--bg); text-align: left; cursor: pointer; display: grid; gap: 6px; }
.pcard:hover { border-color: var(--accent); } .pcard b { font-size: 15px; }
.login { min-height: 100vh; display: grid; place-items: center; background: var(--bg2); padding: 16px; }
.login form { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 26px; width: min(340px, 100%); display: grid; gap: 12px; }
.fbimg { max-width: 100%; border: 1px solid var(--line); border-radius: var(--r); margin-top: 8px; }
kbd { font: 11px ui-monospace, Menlo, monospace; background: var(--bg3); border-radius: 4px; padding: 1px 5px; }
code { font: 12px ui-monospace, "SF Mono", Menlo, monospace; background: var(--bg3); border-radius: 4px; padding: 1px 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 1100px) { .panes { grid-template-columns: 220px minmax(0, 1fr); } .pane.proof { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); } .panes { height: auto; } .pane { overflow: visible; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: 48px auto minmax(0, 1fr); height: auto; min-height: 100vh; }
  .side { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px; } .side .sep, .side .cap { display: none; } .nav { width: auto; flex: 0 0 auto; }
  .panes { grid-template-columns: minmax(0, 1fr); } .pane + .pane { border-left: 0; border-top: 1px solid var(--line); }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); } .station:nth-child(odd) { border-left: 0; } .station:nth-child(n+3) { border-top: 1px solid var(--line); }
  .page { padding: 16px; } .top .pname { min-width: 0; max-width: 46vw; }
}

::placeholder { color: var(--text2); opacity: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
h1.ph { font-size: 12px; font-weight: 600; color: var(--text2); padding-left: 7px; letter-spacing: 0; }
.chip.sel { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent); }
.nextl { margin-left: 6px; background: var(--accent); color: var(--on-accent); border-radius: 4px; padding: 0 5px; font-size: 10px; font-weight: 700; }
.save.btn { height: 24px; padding: 0 8px; min-width: 0; } .save.err { color: var(--bad); font-weight: 700; background: var(--bad-soft); }
.pane.proof, .page { padding-right: 38px; }
.top, .side { backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px); }
@media (max-width: 860px) { .top .pname { flex: 1 1 auto; width: auto !important; } }
