/* Layout: a reviewer's desk in three panes. Papers rail, the submission on a lit desk,
   and an inspector for marks, the assistant, research and the review form. */
:root {
  --bg: #E8ECF0; --surface: #FFFFFF; --surface-2: #F2F5F8; --line: #D2D9E1; --line-strong: #A7B2BF;
  --fg: #16202B; --muted: #586677; --accent: #2B4F87; --accent-ink: #FFFFFF; --accent-soft: #E1E9F5;
  --desk: #D3DAE2; --page-bg: #FFFFFF; --page-filter: none; --hl-blend: multiply; --danger: #B42318; --ok: #2F7A4C;
  --shadow: 0 1px 2px rgba(18,28,40,.08), 0 10px 28px rgba(18,28,40,.10);
  --backdrop: rgba(14,22,32,.42);
  --c-contrib: #2D5DB0; --c-strength: #2F7A4C; --c-weakness: #B42318; --c-question: #6A44B2; --c-presentation: #8A6100; --c-related: #0E7480; --c-limits: #AD5218;
  --hl-contrib: rgba(70,130,255,.30); --hl-strength: rgba(50,170,95,.32); --hl-weakness: rgba(235,70,55,.30); --hl-question: rgba(150,95,240,.28);
  --hl-presentation: rgba(255,205,0,.48); --hl-related: rgba(0,175,185,.30); --hl-limits: rgba(255,135,40,.36);
  --find: rgba(255,170,0,.42); --find-current: rgba(255,120,0,.62);
  --font-display: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1217; --surface: #141B23; --surface-2: #1A232D; --line: #283341; --line-strong: #3E4C5D;
    --fg: #E1E7EE; --muted: #93A2B3; --accent: #8EB0E8; --accent-ink: #0D1217; --accent-soft: #1C2A3D;
    --desk: #080C10; --page-filter: brightness(.88); --danger: #F28B80; --ok: #7FC99B;
    --shadow: 0 1px 2px rgba(0,0,0,.45), 0 10px 28px rgba(0,0,0,.4); --backdrop: rgba(0,0,0,.6);
    --c-contrib: #8EB0E8; --c-strength: #7FC99B; --c-weakness: #F28B80; --c-question: #B9A1EE; --c-presentation: #E1B85C; --c-related: #62C6CD; --c-limits: #EFA06B;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1217; --surface: #141B23; --surface-2: #1A232D; --line: #283341; --line-strong: #3E4C5D;
  --fg: #E1E7EE; --muted: #93A2B3; --accent: #8EB0E8; --accent-ink: #0D1217; --accent-soft: #1C2A3D;
  --desk: #080C10; --page-filter: brightness(.88); --danger: #F28B80; --ok: #7FC99B;
  --shadow: 0 1px 2px rgba(0,0,0,.45), 0 10px 28px rgba(0,0,0,.4); --backdrop: rgba(0,0,0,.6);
  --c-contrib: #8EB0E8; --c-strength: #7FC99B; --c-weakness: #F28B80; --c-question: #B9A1EE; --c-presentation: #E1B85C; --c-related: #62C6CD; --c-limits: #EFA06B;
  color-scheme: dark;
}
/* Page look overrides (Settings → Appearance). These come after the theme blocks so they win. */
:root[data-pages="original"] { --page-filter: none; }
:root[data-pages="night"] {
  --page-filter: invert(.9) hue-rotate(180deg); --page-bg: #1B1E22; --hl-blend: screen;
  --hl-contrib: rgba(70,130,255,.45); --hl-strength: rgba(50,170,95,.45); --hl-weakness: rgba(235,70,55,.45); --hl-question: rgba(150,95,240,.45);
  --hl-presentation: rgba(255,205,0,.40); --hl-related: rgba(0,175,185,.45); --hl-limits: rgba(255,135,40,.45);
  --find: rgba(255,170,0,.40); --find-current: rgba(255,140,0,.6);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font-ui);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 0;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent); }
kbd { font: 500 11px/1.4 var(--font-mono); color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--surface-2); white-space: nowrap; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .sm { font-size: 12px; } .grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; } .row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; } .row.end { justify-content: flex-end; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

#app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 10px; padding-block: max(10px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-bottom, 0px)); }

/* top bar */
.top { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font: 600 16px/1 var(--font-display); white-space: nowrap; }
.brand svg { flex: none; }
.docbar { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 12px; padding-left: 12px; border-left: 1px solid var(--line); }
.doctitle { font: 400 15px/1.3 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pageind { font: 500 12px var(--font-mono); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tools { display: flex; align-items: center; gap: 2px; }
.zoom { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); margin-right: 4px; }
.zoom button { appearance: none; border: 0; background: transparent; padding: 5px 10px; cursor: pointer; font: 500 13px var(--font-mono); font-variant-numeric: tabular-nums; }
.zoom button:hover { background: var(--surface-2); }
.zoom .zoomval { min-width: 58px; border-inline: 1px solid var(--line); }
.savestate { font-size: 12px; color: var(--muted); white-space: nowrap; }
.savestate.bad { color: var(--danger); }
.viewswitch { display: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.viewswitch button { appearance: none; border: 0; background: transparent; padding: 6px 10px; font-size: 13px; cursor: pointer; color: var(--muted); }
.viewswitch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--fg); font-weight: 500; }

/* buttons, inputs */
.btn { appearance: none; font: 500 13px/1.2 var(--font-ui); border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 7px; padding: 7px 11px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn.icon { padding: 6px; }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.libtoggle { display: none; }
.linkbtn { appearance: none; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 12px; }
.input, .select { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 7px 9px; min-width: 0; }
.select.sm { padding: 4px 6px; font-size: 12px; }
.input { flex: 1; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; cursor: pointer; }
.check input { accent-color: var(--accent); }

/* shell */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr) minmax(340px, 410px); gap: 10px; min-height: 0; }
.library, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.reader { min-height: 0; min-width: 0; position: relative; background: var(--desk); border-radius: 12px; overflow: hidden; display: flex; }

/* library */
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 8px; }
.lib-head h2, .lbl { font: 600 11px/1.2 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lib-list { overflow: auto; flex: 1; padding: 2px 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.pitem { position: relative; border-radius: 9px; border: 1px solid transparent; }
.pitem[aria-current="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.pitem:hover:not([aria-current="true"]) { background: var(--surface-2); }
.pi-open { appearance: none; border: 0; background: transparent; text-align: left; width: 100%; padding: 10px; display: grid; gap: 6px; cursor: pointer; border-radius: 9px; }
.pi-title { font: 400 14px/1.3 var(--font-display); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; padding-right: 44px; overflow-wrap: anywhere; }
.pi-meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 4px 8px; flex-wrap: wrap; align-items: center; font-variant-numeric: tabular-nums; }
.pi-bar { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.pi-bar > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.pi-bar.big { height: 5px; width: 160px; margin-top: 5px; }
.pi-actions { position: absolute; top: 6px; right: 6px; display: flex; opacity: 0; transition: opacity .15s; }
.pitem:hover .pi-actions, .pitem:focus-within .pi-actions, .pitem[aria-current="true"] .pi-actions { opacity: 1; }
@media (pointer: coarse) { .pi-actions { opacity: 1; } #keysBtn { display: none; } }
.pi-confirm { padding: 0 10px 10px; display: grid; gap: 8px; font-size: 12.5px; }
.pi-rename { width: 100%; font: 400 14px var(--font-display); }
.pill { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 500; border: 1px solid var(--line); color: var(--muted); background: var(--surface); }
.pill.s-drafting { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.pill.s-ready { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.pill.s-submitted { color: var(--surface); background: var(--ok); border-color: var(--ok); }
.pill.practice { border-style: dashed; }
.lib-empty { padding: 10px 8px; display: grid; gap: 6px; font-size: 13px; }
.lib-foot { padding: 10px 12px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); display: grid; gap: 4px; }
.note.warn { font-size: 12px; color: var(--danger); padding: 6px 8px; }

/* viewer */
.viewer { flex: 1; overflow: auto; position: relative; padding: 18px 0 48px; outline: none; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 0 16px; width: max-content; min-width: 100%; }
.page { position: relative; background: var(--page-bg); box-shadow: var(--shadow); flex: none; }
.page canvas { position: absolute; inset: 0; width: 100%; height: 100%; filter: var(--page-filter); z-index: 0; }
.hlLayer, .findLayer { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.hl { position: absolute; background: var(--hl); mix-blend-mode: var(--hl-blend); border-radius: 2px; }
.hl.on { box-shadow: 0 0 0 1.5px var(--c); }
.hl.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--c); } 100% { box-shadow: 0 0 0 0 transparent; } }
.hlnote { position: absolute; left: calc(100% + 5px); width: 6px; height: 14px; border-radius: 2px; background: var(--c); opacity: .85; }
.fh { position: absolute; background: var(--find); mix-blend-mode: var(--hl-blend); border-radius: 2px; }
.fh.cur { background: var(--find-current); box-shadow: 0 0 0 1.5px var(--find-current); }
/* pdf.js text layer (from pdf.js 3.11 viewer CSS) */
.textLayer { position: absolute; text-align: initial; inset: 0; overflow: hidden; line-height: 1; -webkit-text-size-adjust: none; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; z-index: 2; }
.textLayer span, .textLayer br { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer span.markedContent { top: 0; height: 0; }
.textLayer ::selection { background: rgba(43,79,135,.30); }
.textLayer br::selection { background: transparent; }
/* Keeps drag-selection from jumping across columns in two-column papers. */
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0 0; z-index: -1; cursor: default; user-select: none; }
.textLayer .endOfContent.active { top: 0; }
.overlay-state { position: absolute; inset: 0; overflow: auto; background: var(--desk); z-index: 5; }
.vstate { display: grid; place-items: center; padding: 24px; }
.vs-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; max-width: 440px; display: grid; gap: 12px; justify-items: start; }
.vs-card h2 { font: 600 20px/1.25 var(--font-display); }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* find bar */
.findbar { position: absolute; top: 10px; right: 22px; z-index: 6; display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 5px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.findbar input { border: 0; background: transparent; padding: 4px 6px; width: 220px; min-width: 0; outline: none; }
.findbar .pageind { min-width: 54px; text-align: right; padding-right: 4px; }

/* welcome */
.welcome { padding: 28px 20px 40px; display: flex; justify-content: center; }
.welcome-inner { max-width: 740px; width: 100%; display: grid; gap: 26px; align-content: start; }
.eyebrow { font: 600 11px var(--font-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.welcome h1 { font: 600 clamp(23px, 2.6vw, 31px)/1.18 var(--font-display); text-wrap: balance; margin-top: 6px; max-width: 30ch; }
.welcome h2 { font: 600 17px/1.3 var(--font-display); margin-bottom: 6px; }
.welcome p { max-width: 65ch; }
.drop { border: 1.5px dashed var(--line-strong); border-radius: 14px; padding: 20px; display: grid; gap: 14px; background: var(--surface); }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.mapping { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 13px; }
.mapping th { font: 600 11px var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.mapping td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.mapping tr:last-child td { border-bottom: 0; }
.mapping td:first-child { width: 46px; }
.mk { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; display: inline-block; }
.field-name { font-family: var(--font-display); }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.steps h3 { font: 600 14px var(--font-ui); margin-bottom: 4px; }
.steps p { font-size: 13px; color: var(--muted); }
.fine { font-size: 12px; color: var(--muted); }

/* panel */
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 6px; flex: none; overflow-x: auto; }
.tab { appearance: none; background: none; border: 0; padding: 12px 10px 10px; font: 500 13px var(--font-ui); color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.tab .count { font: 500 11px var(--font-mono); color: var(--muted); margin-left: 4px; }
.pane { flex: 1; overflow: auto; min-height: 0; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.pane.chat { padding: 0; gap: 0; }
.empty { color: var(--muted); font-size: 13px; padding: 24px 6px; text-align: center; }
.sec { display: grid; gap: 8px; }

/* marks */
.note-input { width: 100%; border: 1px solid transparent; background: var(--surface-2); border-radius: 7px; padding: 7px 9px; font: 13px/1.45 var(--font-ui); color: var(--fg); resize: none; min-height: 34px; overflow: hidden; }
.note-input.big { min-height: 64px; }
.note-input:focus { border-color: var(--accent); outline: none; background: var(--surface); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { appearance: none; display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; background: var(--surface); cursor: pointer; color: var(--fg); text-decoration: none; font-variant-numeric: tabular-nums; }
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--surface)); }
.chip.dim { opacity: .55; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { appearance: none; border: 0; background: transparent; padding: 3px 8px; font-size: 12px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--fg); }
.hint { font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.cards { display: grid; gap: 8px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px 10px; display: grid; gap: 7px; background: var(--surface); }
.card.on { border-color: color-mix(in srgb, var(--c) 60%, var(--line)); }
.card.flashc { animation: cardflash 1.4s ease-out; }
@keyframes cardflash { 0%, 40% { box-shadow: 0 0 0 2px var(--c); } 100% { box-shadow: 0 0 0 0 transparent; } }
.card-head { display: flex; align-items: center; gap: 6px; font-size: 12px; min-width: 0; }
.catsel { appearance: none; border: 0; background: transparent; font: 600 12px var(--font-ui); color: var(--c); cursor: pointer; padding: 2px; border-radius: 4px; }
.catsel:hover { background: var(--surface-2); }
.catsel option { color: var(--fg); background: var(--surface); }
.loc { appearance: none; border: 0; background: transparent; font: 500 11.5px var(--font-mono); color: var(--muted); cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.loc:hover:not([disabled]) { color: var(--accent); background: var(--surface-2); }
.loc[disabled] { cursor: default; }
.quote { font: 400 13.5px/1.5 var(--font-display); cursor: pointer; overflow-wrap: anywhere; }
.quote span { background: color-mix(in srgb, var(--c) 20%, transparent); -webkit-box-decoration-break: clone; box-decoration-break: clone; padding: 1px 2px; border-radius: 2px; }
.quote.loose { cursor: default; }
.quote.loose span { background: none; padding: 0; }
.addnote { flex-wrap: wrap; padding-top: 4px; }

/* assistant */
.chat-ctx { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.chat-ctx .btn { margin-left: auto; }
.ctxline { font-size: 12px; color: var(--muted); padding: 8px 14px 0; }
.msgs { flex: 1; overflow: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.msg .body { font-size: 13.5px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 88%; }
.msg.user .body { background: var(--accent-soft); border-radius: 10px 10px 2px 10px; padding: 8px 11px; white-space: pre-wrap; }
.msg.asst { max-width: 100%; }
.md p + p, .md p + ul, .md p + ol, .md ul + p, .md ol + p, .md h4 + p { margin-top: 8px; }
.md ul, .md ol { margin: 6px 0; padding-left: 20px; }
.md li + li { margin-top: 3px; }
.md h4 { font: 600 13.5px var(--font-ui); margin-top: 10px; }
.md code { font: 12px var(--font-mono); background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.md pre { background: var(--surface-2); padding: 8px; border-radius: 7px; overflow-x: auto; font: 12px var(--font-mono); }
.msg-actions { display: flex; gap: 2px; margin-top: 4px; }
.thinking { color: var(--muted); font-style: italic; }
.err { color: var(--danger); font-size: 12.5px; }
.okmsg { color: var(--ok); font-size: 12.5px; }
.composer { border-top: 1px solid var(--line); padding: 10px 14px 12px; display: grid; gap: 8px; }
.chat-in { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; resize: none; min-height: 56px; max-height: 220px; background: var(--surface); font: 13.5px/1.45 var(--font-ui); overflow: auto; }
.chat-in:focus { outline: none; border-color: var(--accent); }
.starters { display: grid; gap: 6px; }
.starter { appearance: none; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 8px 10px; font-size: 13px; cursor: pointer; color: var(--fg); }
.starter:hover { background: var(--surface-2); border-color: var(--line-strong); }
.setup { padding: 18px 16px; display: grid; gap: 12px; align-content: start; }
.setup h3 { font: 600 17px/1.3 var(--font-display); }
.setup ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; }

/* research */
.callout { font-size: 12.5px; background: color-mix(in srgb, var(--c-presentation) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c-presentation) 35%, var(--line)); border-radius: 8px; padding: 9px 11px; }
.links, .qchips { display: flex; flex-wrap: wrap; gap: 6px; }
.results { display: grid; gap: 12px; }
.result { display: grid; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.rtitle { font: 600 14px/1.35 var(--font-display); text-decoration: none; color: var(--fg); }
.rtitle:hover { color: var(--accent); text-decoration: underline; }
.rmeta { font-size: 12px; color: var(--muted); }
.abs { font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.abs.open { display: block; }

/* review */
.rv-head { display: grid; gap: 10px; padding-bottom: 4px; }
.rv-progress { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.rv-form { display: grid; }
.field { display: grid; gap: 7px; padding: 14px 0; border-top: 1px solid var(--line); }
.fl { font-weight: 600; font-size: 13.5px; }
.opt { font-weight: 400; color: var(--muted); font-size: 12px; }
.help { font-size: 12px; color: var(--muted); }
.rv-ta { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font: 15px/1.55 var(--font-display); background: var(--surface); color: var(--fg); resize: vertical; min-height: 90px; overflow: hidden; }
.rv-ta:focus { outline: none; border-color: var(--accent); }
.field-foot { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; color: var(--muted); }
.wc { font: 11.5px var(--font-mono); font-variant-numeric: tabular-nums; }
.scale { display: flex; flex-wrap: wrap; gap: 4px; position: relative; }
.scale input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.scale label { min-width: 40px; text-align: center; padding: 6px 0; border: 1px solid var(--line); border-radius: 6px; font: 500 12px var(--font-mono); cursor: pointer; background: var(--surface); font-variant-numeric: tabular-nums; }
.scale label:hover { border-color: var(--line-strong); }
.scale input:checked + label { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.scale input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.scale-label { font-size: 12.5px; }
.polish, .check-out { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: var(--surface-2); display: grid; gap: 8px; }
.pol-text { white-space: pre-wrap; font: 14px/1.55 var(--font-display); }
.issue { display: grid; gap: 3px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.issue:first-of-type { border-top: 0; }
.sev { font: 600 10.5px var(--font-ui); letter-spacing: .06em; text-transform: uppercase; }
.sev.high { color: var(--danger); } .sev.medium { color: var(--c-presentation); } .sev.low { color: var(--muted); }

/* popover, toast, drop */
.pop { position: fixed; z-index: 50; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 10px 30px rgba(10,20,35,.24); padding: 8px; width: min(340px, calc(100vw - 32px)); display: grid; gap: 8px; }
.pop-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.pop-cat { appearance: none; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; border: 0; background: transparent; font-size: 13px; cursor: pointer; text-align: left; }
.pop-cat:hover, .pop-cat:focus-visible { background: var(--surface-2); }
.pop-cat kbd { margin-left: auto; }
.pop-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 8px; }
.pop-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.pop-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.pop-chips .chip { font-size: 11.5px; padding: 3px 8px; }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 14px; border-radius: 9px; font-size: 13px; z-index: 90; display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 32px); box-shadow: var(--shadow); }
.toast-act { appearance: none; border: 0; background: none; color: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; padding: 0; }
.dropover { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 16%, transparent); font: 600 18px var(--font-ui); pointer-events: none; }
.dropover span { background: var(--surface); border: 2px dashed var(--accent); border-radius: 14px; padding: 22px 28px; color: var(--fg); }

/* dialogs */
dialog.modal { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--fg); width: min(660px, calc(100vw - 32px)); max-height: min(88vh, 920px); box-shadow: 0 24px 60px rgba(0,0,0,.3); }
dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal::backdrop { background: var(--backdrop); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex: none; }
.dlg-head h2 { font: 600 19px/1.2 var(--font-display); }
.dlg-body { overflow: auto; min-height: 0; }
.set-sec { display: grid; gap: 12px; padding: 16px 18px 18px; border-top: 1px solid var(--line); }
.set-sec:first-child { border-top: 0; }
.set-sec h3 { font: 600 11px/1.2 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.set-row { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 6px 14px; align-items: start; }
.set-row > label, .set-row > .set-label { padding-top: 7px; font-weight: 500; font-size: 13px; }
.set-row .help { margin-top: 4px; }
.set-ctl { display: grid; gap: 4px; min-width: 0; }
.set-ctl .input, .set-ctl .select { width: 100%; }
.radios { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; width: max-content; max-width: 100%; flex-wrap: wrap; }
.radios label { padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.radios input { position: absolute; opacity: 0; pointer-events: none; }
.radios label:has(input:checked) { background: var(--accent-soft); color: var(--fg); font-weight: 500; }
.radios label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.set-note { font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 9px 11px; }
.keys { width: 100%; border-collapse: collapse; font-size: 13px; }
.keys td { padding: 8px 18px; border-top: 1px solid var(--line); vertical-align: top; }
.keys tr:first-child td { border-top: 0; }
.keys td:first-child { width: 190px; white-space: nowrap; }

/* responsive */
@media (max-width: 1199px) {
  .shell { grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); }
  .library { position: fixed; left: max(16px, env(safe-area-inset-left, 0px)); top: calc(62px + env(safe-area-inset-top, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: 290px; z-index: 40; box-shadow: var(--shadow); display: none; }
  .shell[data-lib-open="true"] .library { display: flex; }
  .btn.libtoggle { display: inline-flex; }
}
@media (max-width: 859px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .shell:not([data-view="library"]) .library,
  .shell:not([data-view="reader"]) .reader,
  .shell:not([data-view="panel"]) .panel { display: none; }
  .shell[data-view="library"] .library { display: flex; position: static; width: auto; box-shadow: none; }
  .viewswitch { display: flex; }
  .btn.libtoggle { display: none; }
  .brand span { display: none; }
  .docbar { order: 5; flex-basis: 100%; border-left: 0; padding-left: 0; }
  .zoom { display: none; }
  .set-row { grid-template-columns: minmax(0, 1fr); }
  .set-row > label, .set-row > .set-label { padding-top: 0; }
  .findbar input { width: 130px; }
}
