:root {
  --bg: #f5f2ec;
  --panel: #ffffff;
  --panel-2: #faf8f4;
  --line: #e6e0d5;
  --line-2: #d8d0c2;
  --ink: #1d1b18;
  --ink-2: #57524a;
  --ink-3: #8c857a;
  --accent: #b4432f;
  --accent-2: #93341f;
  --accent-soft: #f6e4de;
  --ok: #2f7d5b;
  --ok-soft: #e0f0e7;
  --warn: #a86a0c;
  --warn-soft: #fbefd6;
  --bad: #b3261e;
  --bad-soft: #f9e0de;
  --info: #2d5e8c;
  --info-soft: #e1ecf6;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 14px rgba(40, 30, 10, .06);
  --shadow-lg: 0 12px 40px rgba(20, 15, 5, .18);
  --radius: 12px;
  --nav-w: 232px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --si: "Noto Sans Sinhala", "Iskoola Pota", var(--font);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15140f; --panel: #1f1d18; --panel-2: #26231d; --line: #332f27; --line-2: #443e33;
    --ink: #f1ece2; --ink-2: #bdb5a6; --ink-3: #8a8274;
    --accent: #e0765e; --accent-2: #f08e77; --accent-soft: #3a221b;
    --ok: #6cc29a; --ok-soft: #1d3228; --warn: #e3a64a; --warn-soft: #382a14;
    --bad: #ef7d74; --bad-soft: #3b1c19; --info: #7fb2e3; --info-soft: #1b2a39;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15140f; --panel: #1f1d18; --panel-2: #26231d; --line: #332f27; --line-2: #443e33;
  --ink: #f1ece2; --ink-2: #bdb5a6; --ink-3: #8a8274;
  --accent: #e0765e; --accent-2: #f08e77; --accent-soft: #3a221b;
  --ok: #6cc29a; --ok-soft: #1d3228; --warn: #e3a64a; --warn-soft: #382a14;
  --bad: #ef7d74; --bad-soft: #3b1c19; --info: #7fb2e3; --info-soft: #1b2a39;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.si { font-family: var(--si); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 22px 14px; background: var(--panel); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
/* the logo's mark is drawn on white paper, so it keeps a white tile in either theme */
.brand-mark { flex: none; width: 38px; height: 38px; border-radius: 10px; background: #fff; border: 1px solid var(--line); overflow: hidden; }
.brand-mark img { display: block; width: 100%; height: 100%; }
.brand-name { font-family: var(--serif); font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: var(--ink-3); }
.nav-links { display: flex; flex-direction: column; gap: 2px; }
.nav-links a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--ink-2); font-weight: 500; }
.nav-links a:hover { background: var(--panel-2); color: var(--ink); }
.nav-links a.active { background: var(--accent-soft); color: var(--accent); }
.nav-links .count { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.job-pill { width: 100%; font-size: 12px; padding: 9px 11px; border-radius: 9px; background: var(--info-soft); color: var(--info); display: flex; gap: 8px; align-items: center; cursor: pointer; }
.job-pill.failed { background: var(--bad-soft); color: var(--bad); }
.job-pill.done { background: var(--ok-soft); color: var(--ok); }

.main { min-width: 0; padding: 28px 36px 120px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-family: var(--serif); font-weight: 650; font-size: 30px; letter-spacing: -.02em; margin: 0; line-height: 1.15; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel); font-weight: 600; font-size: 13px; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--panel-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); }
.icon-btn:hover { background: var(--panel-2); }
.input { height: 36px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--panel); outline: none; min-width: 0; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 16px; height: 16px; }
.search .input { padding-left: 34px; width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 9px; padding: 2px; background: var(--panel); }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 11px; border-radius: 7px; display: inline-flex; gap: 6px; align-items: center; font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: var(--panel); }
.seg button svg { width: 15px; height: 15px; }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.chip svg { width: 12px; height: 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-title { font-family: var(--serif); font-size: 19px; font-weight: 650; margin: 30px 0 12px; display: flex; align-items: center; gap: 10px; }
.muted { color: var(--ink-3); }
.empty { text-align: center; padding: 60px 20px; color: var(--ink-3); }
.empty h3 { font-family: var(--serif); color: var(--ink); font-size: 20px; margin: 10px 0 6px; }
.empty svg { width: 40px; height: 40px; color: var(--line-2); }
.empty .btn svg { width: 16px; height: 16px; color: inherit; }
.empty .actions { justify-content: center; }

/* ---------- logos ---------- */
.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.logo-card { display: flex; flex-direction: column; overflow: hidden; }
.logo-tile { height: 124px; display: grid; place-items: center; padding: 0 14px; border-bottom: 1px solid var(--line);
  background: repeating-conic-gradient(var(--panel-2) 0 25%, var(--panel) 0 50%) 0 0 / 16px 16px; }
.logo-tile img { max-width: 100%; max-height: 88px; box-shadow: 3px 3px 10px rgba(0, 0, 0, .22); }
.logo-tile.none svg { width: 34px; height: 34px; color: var(--line-2); }
.logo-meta { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.logo-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: end; padding: 16px; }
.logo-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.logo-form p { grid-column: 1 / -1; margin: 0; font-size: 12.5px; }
.logo-form label.check { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }

/* ---------- overview ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { padding: 16px 18px; }
.stat .n { font-family: var(--serif); font-size: 32px; font-weight: 650; line-height: 1.1; letter-spacing: -.02em; }
.stat .l { color: var(--ink-3); font-size: 12.5px; font-weight: 500; margin-top: 2px; }
.stat.hot .n { color: var(--accent); }
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-bottom: 14px; }
.hero-card { padding: 22px 24px; display: flex; flex-direction: column; gap: 10px; }
.hero-card h2 { font-family: var(--serif); font-size: 22px; margin: 0; }
.hero-card p { margin: 0; color: var(--ink-2); }
.flow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin: 4px 0 6px; }
.flow span { background: var(--panel-2); border: 1px solid var(--line); padding: 4px 10px; border-radius: 99px; }
.flow svg { width: 14px; height: 14px; color: var(--ink-3); }
.date-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.date-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.date-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.date-card .d { font-family: var(--serif); font-size: 18px; font-weight: 650; }
.date-card .papers { display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------- add papers ---------- */
.two-col { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.drop { display: block; border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 34px 20px; text-align: center; background: var(--panel); transition: border-color .15s, background .15s; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { width: 34px; height: 34px; color: var(--accent); }
.drop h3 { font-family: var(--serif); margin: 8px 0 4px; font-size: 19px; }
.drop p { margin: 0; color: var(--ink-3); font-size: 13px; }
.staged { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.stage-row { display: grid; grid-template-columns: 34px minmax(0, 1.3fr) minmax(0, 1fr) 140px 70px 34px; gap: 8px; align-items: center; padding: 10px; }
.stage-row .fname { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-row .fname small { display: block; color: var(--ink-3); }
.stage-row .kind { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.stage-row .kind.img { background: var(--info-soft); color: var(--info); }
.stage-row .input { height: 32px; width: 100%; font-size: 13px; }
.stage-row .result { grid-column: 2 / -1; font-size: 12px; }
.stage-row.ok { border-color: var(--ok); }
.stage-row.err { border-color: var(--bad); }
.stage-hint { display: grid; grid-template-columns: 34px minmax(0, 1.3fr) minmax(0, 1fr) 140px 70px 34px; gap: 8px; font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; padding: 0 11px; }
.run-card { padding: 18px; }
.run-card h3 { margin: 0 0 4px; font-family: var(--serif); font-size: 19px; }
.run-opts { display: flex; gap: 10px; align-items: center; margin: 14px 0; flex-wrap: wrap; }
.run-opts label { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.run-opts .input { width: 64px; height: 32px; }
/* run time: the estimate, then the seven steps with a time against each */
.eta { border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 12px 14px; margin: 0 0 12px; }
.eta.done { background: var(--ok-soft); border-color: transparent; }
.eta.bad { background: var(--bad-soft); border-color: transparent; }
.eta-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.eta-big { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--ink); }
.eta-top .muted { font-size: 12.5px; }
.eta-bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 10px 0 6px; }
.eta-bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .8s ease; }
.eta-sub { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.steplist { list-style: none; margin: 14px 0 6px; padding: 0; }
.step { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: start; padding: 9px 0; position: relative; }
.step + .step { border-top: 1px dashed var(--line); }
.step-mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 600 12px var(--font); background: var(--panel-2); color: var(--ink-3); border: 1px solid var(--line-2); }
.step-mark svg { width: 14px; height: 14px; }
.step-mark .spin { width: 14px; height: 14px; }
.step.running .step-mark { background: var(--info-soft); color: var(--info); border-color: transparent; }
.step.done .step-mark { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.step.failed .step-mark { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.step.skipped { opacity: .55; }
.step-t { font-weight: 600; font-size: 13.5px; color: var(--ink); line-height: 26px; }
.step-t span { font-weight: 400; color: var(--ink-3); margin-left: 8px; font-size: 12.5px; }
.step-d { font-size: 12px; color: var(--info); margin-top: -2px; }
.step.failed .step-t { color: var(--bad); }
.step-bar { height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 6px; }
.step-bar i { display: block; height: 100%; background: var(--info); border-radius: 99px; transition: width .8s ease; }
.step-time { font-size: 12.5px; color: var(--ink-2); line-height: 26px; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.step.done .step-time b { color: var(--ok); }
.techlog { margin-top: 12px; font-size: 12.5px; }
.techlog summary { cursor: pointer; color: var(--ink-3); padding: 4px 0; }
.techlog .console { margin-top: 8px; }
.console { background: #14120e; color: #e8e2d6; font: 12px/1.55 ui-monospace, "Cascadia Code", Consolas, monospace; border-radius: 10px; padding: 12px 14px; height: 300px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.console .h { color: #f0a58f; font-weight: 700; }
.console .e { color: #ff8a80; }
.console .g { color: #9ad5b3; }
.inbox, .table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inbox th, .table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.inbox td, .table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.inbox tr:last-child td, .table tr:last-child td { border-bottom: 0; }
.inbox .nm { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.inbox .nm svg { color: var(--ink-3); }

/* ---------- library ---------- */
.lib { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 22px; align-items: start; }
.rail { position: sticky; top: 20px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; gap: 10px; }
.rail-list { overflow: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 4px; }
.rail-month { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); padding: 12px 10px 4px; }
.rail-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; }
.rail-item:hover { background: var(--panel); border-color: var(--line); }
.rail-item.on { background: var(--panel); border-color: var(--accent); box-shadow: var(--shadow); }
.rail-day { width: 40px; height: 42px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.rail-item.on .rail-day { background: var(--accent); border-color: var(--accent); color: #fff; }
.rail-day b { font-family: var(--serif); font-size: 17px; }
.rail-day small { font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; opacity: .8; }
.rail-meta { min-width: 0; flex: 1; }
.rail-meta .t { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-meta .s { font-size: 11.5px; color: var(--ink-3); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }

.paper { margin-bottom: 26px; overflow: hidden; }
.paper-head { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.paper-logo { width: 44px; height: 44px; border-radius: 10px; background: var(--ink); color: var(--panel); display: grid; place-items: center; font-family: var(--serif); font-size: 21px; font-weight: 650; flex: none; }
.paper-head h2 { font-family: var(--serif); margin: 0; font-size: 21px; letter-spacing: -.01em; }
.paper-head .sub { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.paper-head .actions { margin-left: auto; }
.page-tabs { display: flex; gap: 4px; padding: 10px 18px 0; border-bottom: 1px solid var(--line); background: var(--panel-2); overflow-x: auto; }
.page-tab { border: 1px solid transparent; border-bottom: 0; background: transparent; padding: 8px 14px 9px; border-radius: 9px 9px 0 0; font-weight: 600; font-size: 13px; color: var(--ink-2); display: flex; gap: 7px; align-items: center; margin-bottom: -1px; white-space: nowrap; }
.page-tab.on { background: var(--panel); border-color: var(--line); color: var(--ink); }
.page-tab .chip { font-size: 10.5px; padding: 0 6px; }
.page-bar { display: flex; align-items: center; gap: 10px; padding: 12px 18px; flex-wrap: wrap; }
.page-bar .actions { margin-left: auto; }
.notice { margin: 0 18px 12px; padding: 10px 14px; border-radius: 10px; display: flex; gap: 10px; align-items: center; font-size: 13px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.accent { background: var(--accent-soft); color: var(--accent); }
.notice a { font-weight: 700; text-decoration: underline; margin-left: auto; white-space: nowrap; }

.grid { columns: 4 230px; column-gap: 14px; padding: 4px 18px 18px; }
.art { break-inside: avoid; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--panel); position: relative; transition: box-shadow .15s, transform .15s, border-color .15s; }
.art:hover, .art.hl { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: var(--line-2); }
.art.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.art-img { display: block; width: 100%; background: #fff; cursor: zoom-in; border-bottom: 1px solid var(--line); min-height: 60px; }
.art-body { padding: 10px 12px 12px; }
.art-top { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; flex-wrap: wrap; }
.art-n { font-family: var(--serif); font-weight: 650; font-size: 13px; color: var(--ink-3); }
.art-h { font-family: var(--si); font-weight: 700; font-size: 14px; line-height: 1.45; margin: 0; }
.art-h.none { font-family: var(--font); font-weight: 500; color: var(--ink-3); font-style: italic; font-size: 13px; }
.art-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 5px; opacity: 0; transition: opacity .15s; }
.art:hover .art-tools, .selecting .art-tools { opacity: 1; }
.art-tools button, .art-tools a { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: rgba(20, 18, 14, .78); color: #fff; border: 0; backdrop-filter: blur(4px); }
.art-tools button:hover, .art-tools a:hover { background: var(--accent); }
.art-check { position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; border-radius: 7px; border: 2px solid #fff; background: rgba(20, 18, 14, .35); display: none; place-items: center; color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.selecting .art-check { display: grid; }
.art.sel .art-check { background: var(--accent); border-color: var(--accent); }
.art-check svg { width: 16px; height: 16px; stroke-width: 3; visibility: hidden; }
.art.sel .art-check svg { visibility: visible; }

.pagemap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; padding: 4px 18px 18px; align-items: start; }
.map-wrap { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.map-wrap img { display: block; width: 100%; }
.map-wrap svg.boxes { position: absolute; inset: 0; width: 100%; height: 100%; stroke: none; }
.boxes rect { fill: rgba(180, 67, 47, .08); stroke: var(--accent); stroke-width: 3; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill .12s; }
.boxes rect:hover, .boxes rect.hl { fill: rgba(180, 67, 47, .28); stroke-width: 4; }
.boxes text { fill: #fff; font: 700 22px var(--font); pointer-events: none; }
.boxes .tag { fill: var(--accent); stroke: none; pointer-events: none; }
.map-list { display: flex; flex-direction: column; gap: 4px; max-height: 80vh; overflow: auto; position: sticky; top: 20px; }
.map-item { display: flex; gap: 9px; padding: 8px 10px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; align-items: flex-start; }
.map-item:hover, .map-item.hl { background: var(--panel-2); border-color: var(--line); }
.map-item b { font-family: var(--serif); color: var(--accent); min-width: 20px; }
.map-item span { font-family: var(--si); font-size: 13px; line-height: 1.45; }

.results-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.results .art-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; }

/* ---------- exceptional ---------- */
.apply-banner { padding: 16px 18px; display: flex; align-items: center; gap: 14px; margin-bottom: 18px; border-color: var(--ok); background: var(--ok-soft); flex-wrap: wrap; }
.apply-banner svg { color: var(--ok); width: 24px; height: 24px; }
.apply-banner div { flex: 1; min-width: 200px; }
.apply-banner b { display: block; font-size: 14.5px; }
.exc-list { display: flex; flex-direction: column; gap: 16px; }
.exc { overflow: hidden; }
.exc-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.exc-head h3 { margin: 0; font-family: var(--si); font-size: 16px; line-height: 1.4; }
.exc-head .where { font-size: 12.5px; color: var(--ink-3); }
.exc-head .actions { margin-left: auto; }
.exc-body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, .9fr); gap: 0; }
.exc-body > div { padding: 14px 18px; border-right: 1px solid var(--line); min-width: 0; }
.exc-body > div:last-child { border-right: 0; }
.exc-body h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.exc-body img { width: 100%; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: zoom-in; display: block; }
.why { font-size: 13px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin-bottom: 10px; }
.pieces { display: grid; gap: 8px; }
.piece { font-size: 12.5px; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; }
.piece b { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.piece .flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.verdict { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel-2); align-items: center; flex-wrap: wrap; }
.verdict .state { margin-right: auto; font-size: 13px; font-weight: 600; display: flex; gap: 8px; align-items: center; }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(12, 10, 7, .82); backdrop-filter: blur(4px); }
.lb-body { position: absolute; inset: 24px; display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px 340px; gap: 12px; align-items: center; }
.lb-stage { height: 100%; display: grid; place-items: center; min-height: 0; overflow: auto; }
.lb-stage img { max-width: 100%; max-height: calc(100vh - 48px); background: #fff; border-radius: 6px; box-shadow: var(--shadow-lg); }
.lb-nav { width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; }
.lb-nav:hover { background: rgba(255,255,255,.25); }
.lb-nav:disabled { opacity: .2; }
.lb-side { background: var(--panel); border-radius: var(--radius); padding: 20px; align-self: stretch; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.lb-side .lb-where { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.lb-side h2 { font-family: var(--si); font-size: 19px; line-height: 1.5; margin: 0; }
.lb-side dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.lb-side dt { color: var(--ink-3); }
.lb-side dd { margin: 0; font-weight: 500; }
.lb-side .actions { flex-direction: column; align-items: stretch; }
.lb-side .actions .btn { justify-content: center; }
.lb-fix { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.lb-fix-t { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.lb-fix p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.lb-close { position: absolute; top: 8px; right: 8px; }
.kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--ink-2); }

/* ---------- selection bar + toasts ---------- */
.selbar { position: fixed; bottom: 22px; left: calc(50% + var(--nav-w) / 2); transform: translateX(-50%); z-index: 40; background: var(--ink); color: var(--panel); padding: 8px 8px 8px 18px; border-radius: 14px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-lg); font-weight: 600; }
.selbar .btn.ghost { color: var(--panel); }
.selbar .btn.ghost:hover { background: rgba(255,255,255,.1); }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: var(--panel); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; max-width: 380px; animation: pop .2s ease-out; }
.toast.err { background: var(--bad); color: #fff; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--panel-2), var(--line), var(--panel-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 10px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- sign-in ---------- */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; padding: 28px 28px 30px; display: flex; flex-direction: column; gap: 16px; }
.login-logo { display: block; width: 100%; max-width: 300px; height: auto; margin: -6px auto 4px; border-radius: 12px; background: #fff; }
.login-card h1 { font-family: var(--serif); font-weight: 650; font-size: 26px; letter-spacing: -.02em; margin: 0; }
.login-card p { margin: 4px 0 0; }
.login-card label, .pw-form label, .user-form label, .key-form label, .dlg-body label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.login-card .input { height: 40px; }
.login-btn { height: 42px; justify-content: center; font-size: 14px; }
.pw-field { display: flex; gap: 6px; align-items: center; }
.pw-field .input { flex: 1; }
.pw-field .icon-btn { height: 36px; width: 36px; flex: none; }
.login-card .pw-field .icon-btn { height: 40px; width: 40px; }
.form-err { background: var(--bad-soft); color: var(--bad); border-radius: 9px; padding: 9px 12px; font-size: 13px; font-weight: 500; }

/* ---------- nav: signed-in user ---------- */
.nav-group { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 16px 12px 4px; }
.nav-foot { align-items: stretch; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; border: 1px solid transparent; min-width: 0; }
.me:hover { background: var(--panel-2); }
.me.active { background: var(--accent-soft); }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.me-text b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-btns { display: flex; gap: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: var(--panel); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex: none; letter-spacing: .02em; }
.avatar.lg { width: 48px; height: 48px; font-size: 17px; }

/* ---------- account, users, API key ---------- */
.acct-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; flex-wrap: wrap; }
.pw-form, .user-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 12px; align-items: end; padding: 16px; }
.user-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.3fr) auto; }
.pw-form p, .user-form p, .pw-form .form-err { grid-column: 1 / -1; margin: 0; font-size: 12.5px; }
.table-card { overflow-x: auto; }
.table .person { display: flex; align-items: center; gap: 10px; }
.table .person b { font-size: 13.5px; }
.table .person small { display: block; font-size: 12px; }
.table tr.off .person { opacity: .55; }
.table td small { font-size: 11.5px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.table.users td:nth-child(4), .table.users td:nth-child(5) { white-space: nowrap; }
.creds { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; margin-bottom: 16px; border-color: var(--ok); background: var(--ok-soft); flex-wrap: wrap; }
.creds-ico { width: 32px; height: 32px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; flex: none; }
.creds-main { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 2px; }
.creds-main b { font-size: 14.5px; }
.creds dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 8px 0 0; font-size: 13px; }
.creds dt { color: var(--ink-3); }
.creds dd { margin: 0; font-weight: 600; word-break: break-all; }
code { font: 600 13px ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.key-card { padding: 0; overflow: hidden; }
.key-now { display: flex; align-items: center; gap: 14px; padding: 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.key-now > .actions:last-child { margin-left: auto; }
.key-ico { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.key-ico svg { width: 22px; height: 22px; }
.key-text { flex: 1; min-width: 240px; }
.key-text p { margin: 6px 0 0; font-size: 13px; }
.key-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; padding: 18px; }
.key-result { display: flex; gap: 10px; align-items: center; margin: 0 18px 18px; padding: 10px 14px; border-radius: 10px; font-size: 13px; font-weight: 500; }
.key-result.ok { background: var(--ok-soft); color: var(--ok); }
.key-result.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- activity ---------- */
.act-filter { display: flex; gap: 12px; align-items: end; padding: 14px 16px; margin-bottom: 14px; flex-wrap: wrap; }
.act-filter label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); min-width: 220px; }
.table .nowrap { white-space: nowrap; }
.table td.detail { font-size: 12.5px; color: var(--ink-2); overflow-wrap: anywhere; }
/* Fixed columns, so a long checksum in the details wraps instead of pushing
   the last column out of the card. */
.table.act { table-layout: fixed; }
.table.act th:nth-child(1) { width: 150px; }
.table.act th:nth-child(2) { width: 28%; }
.table.act th:nth-child(3) { width: 225px; }
.table.act th:nth-child(5) { width: 110px; }
.table td.key { max-width: 560px; }
.table td.key code { display: block; font-size: 12px; margin: 2px 0; word-break: break-all; background: transparent; border: 0; padding: 0; }
.table td.key small { display: block; font-size: 11.5px; }
.store-card { display: flex; gap: 12px; align-items: center; padding: 14px 16px; }
.store-card svg { width: 26px; height: 26px; color: var(--accent); }
.store-card b { display: block; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.store-card span { font-size: 12.5px; }

/* ---------- dialog ---------- */
.dlg:has(.dlg-wide) { width: min(980px, calc(100vw - 32px)); }
.dlg-wide .console { height: 60vh; }
.dlg { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
.dlg::backdrop { background: rgba(12, 10, 7, .55); backdrop-filter: blur(2px); }
.dlg-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dlg-body h3 { margin: 0; font-family: var(--serif); font-size: 19px; }
.dlg-body p { margin: -6px 0 0; font-size: 13px; }
.dlg-actions { justify-content: flex-end; }
/* page picker: thumbnails of a paper's pages, clicked to choose */
.picker { max-height: calc(100vh - 64px); }
.pick-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.pick-head p { margin: 4px 0 0; }
.pick-help { margin: -4px 0 0 !important; font-size: 12.5px !important; }
.pick-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pick-count { margin-left: auto; font-size: 13px; color: var(--ink-2); }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; overflow: auto; padding: 4px; max-height: calc(100vh - 330px); min-height: 180px; }
.pick { position: relative; border: 2px solid var(--line); border-radius: 8px; background: #fff; padding: 0; cursor: pointer; overflow: hidden; aspect-ratio: 0.62; transition: border-color .12s, transform .12s; }
.pick img { width: 100%; height: 100%; object-fit: contain; display: block; opacity: .55; transition: opacity .12s; }
.pick:hover img { opacity: .85; }
.pick.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pick.on img { opacity: 1; }
.pick-n { position: absolute; left: 6px; bottom: 6px; background: var(--ink); color: var(--panel); font: 600 11.5px var(--font); border-radius: 6px; padding: 2px 7px; }
.pick-check { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--panel); border: 1.5px solid var(--line-2); color: transparent; }
.pick-check svg { width: 13px; height: 13px; }
.pick.on .pick-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.pick.done { cursor: default; border-color: var(--ok-soft); }
.pick.done img { opacity: .4; }
.pick.done .pick-check { display: none; }
.pick-done { position: absolute; right: 6px; top: 6px; background: var(--ok); color: #fff; font: 600 11px var(--font); border-radius: 6px; padding: 2px 7px; }
.pages-btn { white-space: nowrap; }
.pages-btn.chosen { border-color: var(--accent); color: var(--accent); }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .exc-body { grid-template-columns: 1fr 1fr; }
  .exc-body > div:last-child { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .two-col, .hero { grid-template-columns: 1fr; }
  .lb-body { grid-template-columns: 48px minmax(0, 1fr) 48px; grid-template-rows: minmax(0, 1fr) auto; }
  .lb-side { grid-column: 1 / -1; max-height: 34vh; }
  .lb-stage img { max-height: calc(66vh - 60px); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: sticky; z-index: 30; height: auto; flex-direction: row; align-items: center; padding: 10px 16px; gap: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-sub, .nav-links span { display: none; }
  .nav-links { flex-direction: row; }
  .nav-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .job-pill { width: auto; }
  .main { padding: 20px 16px 120px; }
  .lib { grid-template-columns: 1fr; }
  .rail { position: static; max-height: none; }
  .rail-list { flex-direction: row; overflow-x: auto; }
  .rail-month { display: none; }
  .rail-item { flex: none; }
  .pagemap { grid-template-columns: 1fr; }
  .map-list { position: static; max-height: 40vh; }
  .exc-body { grid-template-columns: 1fr; }
  .exc-body > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .stage-row, .stage-hint { grid-template-columns: 34px 1fr 1fr; }
  .stage-hint { display: none; }
  .selbar { left: 50%; }
  .step-t span { display: block; margin-left: 0; line-height: 1.3; }
  .logo-form { grid-template-columns: 1fr; }
  .nav-links { overflow-x: auto; }
  .nav-group, .me-text { display: none; }
  .me { padding: 0; }
  .pw-form, .user-form, .key-form { grid-template-columns: 1fr; }
  .table th:nth-child(4), .table td:nth-child(4), .table th:nth-child(5), .table td:nth-child(5) { display: none; }
}

/* ------------------------------------------------------------ old papers */
.inbox-old { display: flex; gap: 8px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.inbox-old svg { width: 16px; height: 16px; color: var(--ink-3); }
.inbox-old a { margin-left: auto; font-weight: 700; color: var(--accent); }
.old-head { margin-bottom: 12px; }
.old-files { margin-bottom: 18px; }
.old-files summary { cursor: pointer; padding: 13px 16px; display: flex; gap: 10px; align-items: baseline; list-style: none; }
.old-files summary::-webkit-details-marker { display: none; }
.old-files summary::before { content: "▸"; color: var(--ink-3); }
.old-files[open] summary::before { content: "▾"; }
.old-files summary .muted { font-size: 13px; }
.old-files .inbox td .chip { margin-left: 4px; }

/* ------------------------------------------------------------------ pen */
/* Redraw an article by hand on its page (app.js, "pen"). The stage is always
   dark, like the lightbox, so the page reads as paper in both themes. */
.notice.info { background: var(--info-soft); color: var(--info); }
.pen { position: fixed; inset: 0; z-index: 55; display: grid; grid-template-columns: minmax(0, 1fr) 360px; background: #12110e; }
.pen-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pen-bar { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: #1c1a16; border-bottom: 1px solid #2c2923; color: #e9e3d8; flex-wrap: wrap; }
.pen-title { display: flex; flex-direction: column; line-height: 1.25; margin-right: 8px; min-width: 0; }
.pen-title b { font-size: 14px; }
.pen-title span { font-size: 12px; color: #a39b8c; white-space: nowrap; }
.pen-bar .seg { background: #26231d; border-color: #3a362e; }
.pen-bar .seg button { color: #cfc7b8; }
.pen-bar .seg button.on { background: #f1ece2; color: #1d1b18; }
.pen-bar .icon-btn, .pen-zoom .icon-btn { background: #26231d; border-color: #3a362e; color: #e9e3d8; }
.pen-bar .icon-btn:hover, .pen-zoom .icon-btn:hover { background: #332f27; }
.pen-bar .icon-btn:disabled { opacity: .35; cursor: default; }
.pen-bar .btn.ghost { color: #e9e3d8; }
.pen-bar .btn.ghost:hover { background: #2c2923; }
.pen-group { display: flex; gap: 4px; }
.pen-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: #cfc7b8; cursor: pointer; user-select: none; }
.pen-check.light { color: var(--ink-2); }
.pen-spacer { flex: 1; }
.pen-stage { position: relative; flex: 1; overflow: hidden; touch-action: none; cursor: crosshair; background: #12110e; }
.pen-stage.tool-edit { cursor: default; }
.pen-stage.grab { cursor: grab; }
.pen-stage.panning { cursor: grabbing; }
.pen-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.pen-canvas img { display: block; max-width: none; user-select: none; -webkit-user-drag: none; background: #fff; box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 10px 40px rgba(0, 0, 0, .5); }
.pen-canvas.px img { image-rendering: pixelated; }
.pen-canvas > svg { position: absolute; left: 0; top: 0; overflow: visible; width: auto; height: auto; fill: initial; stroke: initial; stroke-width: initial; }
.pen-dim { fill: rgba(12, 10, 7, .48); }
.pen-changes { image-rendering: pixelated; }
.pen-shape { fill: none; stroke: #2f8cff; stroke-width: 2.4; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.pen-shape.remove { stroke: #ff5a4a; stroke-dasharray: 7 5; }
.pen-draft { fill: none; stroke: #ffc928; stroke-width: 2.2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.pen-draft.remove { stroke: #ff5a4a; }
.pen-marquee { stroke-dasharray: 7 4; }
.pen-band { stroke: #ffc928; stroke-width: 1.5; stroke-dasharray: 5 5; vector-effect: non-scaling-stroke; }
.pen-first { fill: #ffc928; stroke: #1d1b18; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.pen-first.hot { fill: #2fd27a; }
.pen-handle { fill: #fff; stroke: #2f8cff; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.pen-handle.remove { stroke: #ff5a4a; }
.pen-handle.sel { fill: #2f8cff; }
.pen-other { fill: none; stroke: rgba(255, 255, 255, .75); stroke-width: 1.2; stroke-dasharray: 5 5; vector-effect: non-scaling-stroke; }
.pen-other-n { fill: #fff; stroke: rgba(0, 0, 0, .65); stroke-width: 3; paint-order: stroke; vector-effect: non-scaling-stroke; font-family: var(--font); font-weight: 700; }
.pen-hint { position: absolute; left: 12px; bottom: 12px; max-width: calc(100% - 160px); background: rgba(20, 18, 14, .88); color: #e9e3d8; padding: 7px 11px; border-radius: 8px; font-size: 12px; pointer-events: none; }
.pen-zoom { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; }
.pen-large { position: absolute; inset: 0; background: rgba(12, 10, 7, .93); display: grid; place-items: center; padding: 24px; z-index: 2; cursor: zoom-out; }
.pen-large img { max-width: 100%; max-height: calc(100vh - 120px); background: #fff; box-shadow: var(--shadow-lg); }
.pen-side { background: var(--panel); overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; border-left: 1px solid var(--line); }
.pen-head h2 { font-family: var(--serif); font-size: 20px; margin: 2px 0 0; }
.pen-head p { margin: 6px 0 0; font-size: 12.5px; }
.pen-head .lb-where { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.pen-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.pen-field .input { font-size: 14px; }
.pen-read { display: flex; gap: 8px; align-items: center; font-size: 12.5px; background: var(--info-soft); color: var(--info); padding: 8px 10px; border-radius: 9px; }
.pen-read span { flex: 1; min-width: 0; }
.pen-step { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 9px; }
.pen-step p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.pen-step-t { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.pen-step-t b { display: inline-grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; background: var(--ink); color: var(--panel); font-size: 11px; letter-spacing: 0; }
.pen-count { font-size: 12px; }
.pen-modes { display: flex; flex-direction: column; gap: 6px; }
.pen-mode { text-align: left; border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 11px; background: var(--panel); display: grid; gap: 3px; }
.pen-mode:hover:not(:disabled) { border-color: var(--ink-3); }
.pen-mode.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.pen-mode b { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.pen-mode b svg { width: 15px; height: 15px; }
.pen-mode b .chip { margin-left: auto; }
.pen-mode > span { font-size: 12px; color: var(--ink-2); line-height: 1.45; }
.pen-mode:disabled { opacity: .55; cursor: not-allowed; }
.pen-busy { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--info); background: var(--info-soft); padding: 10px 12px; border-radius: 9px; }
.pen-stale { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; background: var(--warn-soft); color: var(--warn); padding: 9px 11px; border-radius: 9px; }
.pen-stale svg { width: 15px; height: 15px; margin-top: 2px; }
.pen-tabs { align-self: flex-start; }
.pen-thumb { border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); padding: 6px; cursor: zoom-in; display: block; width: 100%; }
.pen-thumb img { display: block; width: 100%; height: 240px; object-fit: contain; background: #fff; border-radius: 5px; }
.pen-thumb.stale img { opacity: .45; }
.pen-size { font-size: 12px; }
.pen-notes { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); display: flex; flex-direction: column; gap: 3px; }
.pen-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--ink-3); }
.pen-legend span { display: inline-flex; align-items: center; gap: 5px; }
.pen-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.pen-legend i.g { background: rgba(47, 160, 100, .55); }
.pen-legend i.r { background: rgba(210, 40, 30, .8); }
.pen-legend i.k { background: rgba(120, 120, 120, .45); }
.pen-legend i.e { background: rgb(25, 150, 85); height: 3px; }
.pen-side .actions { flex-direction: column; align-items: stretch; }
.pen-side .actions .btn { justify-content: center; }
.pen-step .pen-after { font-size: 12px; color: var(--ink-3); }
.pen-keys { font-size: 11.5px; color: var(--ink-3); line-height: 2; margin-top: auto; padding-top: 8px; }
@media (max-width: 900px) {
  .pen { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .pen-side { max-height: 46vh; border-left: 0; border-top: 1px solid var(--line); }
  .pen-hint { display: none; }
}
