/* Layout: drafting table — cool blue-grey desk, white sheets, ink-blue accent, highlighter yellow for marks.
   Chrome is three thin bands (top bar, tabs, contextual tools) over a 3-column workspace. */
:root {
  --desk: #e6e9f0; --desk-2: #dde1ea;
  --chrome: #f7f8fb; --chrome-2: #eef0f5;
  --line: #d3d8e3; --line-2: #c3c9d6;
  --ink: #151b2c; --muted: #5b6479; --faint: #8a92a5;
  --accent: #2a46c8; --accent-ink: #ffffff; --accent-soft: #e2e7fb; --accent-line: #b8c3f2;
  --mark: #ffd23f; --paper: #ffffff;
  --ok: #1f8a5b; --warn: #b8740f; --danger: #c62f3a;
  --shadow: 0 1px 2px rgba(20, 27, 44, .08), 0 6px 18px rgba(20, 27, 44, .08);
  --ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --r: 7px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #12151d; --desk-2: #0e1118; --chrome: #1a1e28; --chrome-2: #212634; --line: #2b3142; --line-2: #3a4256;
    --ink: #e6e9f2; --muted: #a0a8bc; --faint: #737c92; --accent: #8fa3ff; --accent-ink: #0d1124; --accent-soft: #232b4d; --accent-line: #3c4a8a;
    --mark: #ffd23f; --paper: #ffffff; --ok: #4cc38a; --warn: #e2a14a; --danger: #ff6b76;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --desk: #12151d; --desk-2: #0e1118; --chrome: #1a1e28; --chrome-2: #212634; --line: #2b3142; --line-2: #3a4256;
  --ink: #e6e9f2; --muted: #a0a8bc; --faint: #737c92; --accent: #8fa3ff; --accent-ink: #0d1124; --accent-soft: #232b4d; --accent-line: #3c4a8a;
  --mark: #ffd23f; --paper: #ffffff; --ok: #4cc38a; --warn: #e2a14a; --danger: #ff6b76;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: var(--desk); color: var(--ink); font: 13.5px/1.45 var(--ui); overflow: hidden; -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--chrome); }
#app { height: 100%; display: grid; grid-template-rows: auto auto auto 1fr auto; min-height: 0; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .sm { font-size: 12px; } .pad { padding: 8px 12px; }
.danger-t { color: var(--danger); } .ok-t { color: var(--ok); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input, select, textarea { font: inherit; color: var(--ink); }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; gap: 10px; background: var(--chrome); border-bottom: 1px solid var(--line); padding-block: 8px; padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); min-width: 0; }
.brand { display: flex; align-items: center; gap: 7px; font: 800 19px/1 var(--display); letter-spacing: -.02em; }
.logo { width: 26px; height: 26px; }
.fileid { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 0 1 260px; }
.fileid input { width: 100%; min-width: 60px; border: 1px solid transparent; background: none; border-radius: 6px; padding: 5px 7px; font-weight: 500; text-overflow: ellipsis; }
.fileid input:hover, .fileid input:focus { border-color: var(--line); background: var(--paper); color: #151b2c; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }
.tgroup { display: flex; align-items: center; gap: 2px; flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--chrome); border-radius: var(--r); padding: 6px 11px; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover:not(:disabled) { background: var(--chrome-2); border-color: var(--faint); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.wide { width: 100%; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.iconbtn { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; background: none; border-radius: 6px; color: var(--ink); }
.iconbtn:hover:not(:disabled) { background: var(--chrome-2); }
.iconbtn.sm { width: 26px; height: 26px; } .iconbtn.sm .ic { width: 15px; height: 15px; }
.danger-h:hover { color: var(--danger); }
.pagebox { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); }
.pagebox input { width: 40px; text-align: center; border: 1px solid var(--line); border-radius: 5px; padding: 3px 2px; background: var(--paper); color: #151b2c; font-family: var(--mono); }
.zoomval { border: 0; background: none; min-width: 52px; font-size: 12.5px; border-radius: 5px; padding: 5px 2px; }
.zoomval:hover { background: var(--chrome-2); }
.find { display: flex; align-items: center; gap: 2px; margin-left: auto; border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 0 4px 0 8px; min-width: 0; flex: 0 1 290px; color: #151b2c; }
.find .fic { color: #6b7389; display: grid; } .find .ic { width: 16px; height: 16px; }
.find input { border: 0; outline: 0; background: none; padding: 6px 4px; min-width: 40px; flex: 1; color: #151b2c; }
#findCount { font-size: 11.5px; color: #6b7389; white-space: nowrap; }
.find .iconbtn { color: #151b2c; } .find .iconbtn:hover { background: #eef0f5; }

/* ---------- tabs & toolbar ---------- */
.tabs { display: flex; gap: 2px; background: var(--chrome); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; padding-left: max(10px, env(safe-area-inset-left, 0px)); padding-right: max(10px, env(safe-area-inset-right, 0px)); }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 9px 12px 8px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tab .ic { width: 16px; height: 16px; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.tab.on .ic { color: var(--accent); }
.toolbar { display: flex; align-items: center; gap: 2px; background: var(--chrome-2); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; min-height: 52px; padding-block: 5px; padding-left: max(10px, env(safe-area-inset-left, 0px)); padding-right: max(10px, env(safe-area-inset-right, 0px)); }
.tb { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1px solid transparent; background: none; border-radius: 7px; padding: 4px 9px 3px; min-width: 58px; font-size: 11px; color: var(--ink); white-space: nowrap; }
.tb .ic { width: 19px; height: 19px; }
.tb:hover { background: var(--chrome); border-color: var(--line); }
.tb.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.tsep { width: 1px; align-self: stretch; background: var(--line); margin: 4px 6px; flex: none; }
.thint { margin-left: 12px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ---------- workspace ---------- */
.work { display: grid; grid-template-columns: 168px minmax(0, 1fr) 312px; min-height: 0; position: relative; }
body.hide-left .work { grid-template-columns: 0 minmax(0, 1fr) 312px; }
body.hide-right .work { grid-template-columns: 168px minmax(0, 1fr) 0; }
body.hide-left.hide-right .work { grid-template-columns: 0 minmax(0, 1fr) 0; }
.left, .right { background: var(--chrome); min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.left { border-right: 1px solid var(--line); }
.right { border-left: 1px solid var(--line); }
.lt { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.lt button { flex: 1; border: 0; background: none; padding: 8px 2px; font-size: 11.5px; white-space: nowrap; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; }
.lt button.on { color: var(--ink); border-bottom-color: var(--accent); }
.thumbs { overflow-y: auto; padding: 12px 0 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; flex: 1; }
.thumb { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; border-radius: 6px; padding: 4px; }
.thumb span { font: 11px var(--mono); color: var(--muted); }
.tcv, .gcv { position: relative; background: #fff; box-shadow: 0 0 0 1px var(--line-2); border-radius: 2px; overflow: hidden; }
.tcv canvas, .tcv svg, .gcv canvas, .gcv svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.thumb.cur .tcv { box-shadow: 0 0 0 2px var(--accent); }
.thumb.cur span { color: var(--accent); font-weight: 600; }
.thumb.sel { background: var(--accent-soft); }
.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.drop-after { box-shadow: 0 3px 0 var(--accent); }
.gcard.drop-before { box-shadow: -4px 0 0 var(--accent); } .gcard.drop-after { box-shadow: 4px 0 0 var(--accent); }
.bookmarks { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.bm { display: flex; align-items: center; padding-left: calc(var(--lv) * 10px); }
.bmgo { flex: 1; min-width: 0; display: flex; gap: 6px; justify-content: space-between; border: 0; background: none; text-align: left; padding: 5px 6px; border-radius: 5px; font-size: 12.5px; }
.bmgo span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bmgo:hover { background: var(--chrome-2); }
.bm .iconbtn { opacity: 0; } .bm:hover .iconbtn, .bm:focus-within .iconbtn { opacity: 1; }
.bookmarks .btn { margin-top: 8px; }

.viewer { overflow: auto; position: relative; background: var(--desk); min-height: 0; overscroll-behavior: contain; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 20px 28px 80px; width: max-content; min-width: 100%; box-sizing: border-box; }
.pg { position: relative; background: #fff; box-shadow: var(--shadow); flex: none; touch-action: pan-x pan-y; }
.pg canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pg.inverted canvas { filter: invert(.92) hue-rotate(180deg); }
.pg svg.ov { position: absolute; inset: 0; overflow: visible; }
.pg .pgno { position: absolute; left: -26px; top: 2px; font: 11px var(--mono); color: var(--faint); }
.viewer[data-tool="hand"] .pg { cursor: grab; }
.viewer:not([data-tool="select"]):not([data-tool="hand"]) .pg { cursor: crosshair; touch-action: none; }
.viewer[data-tool="textsel"] .pg, .viewer[data-tool="hl-text"] .pg, .viewer[data-tool="ul-text"] .pg, .viewer[data-tool="st-text"] .pg, .viewer[data-tool="edittext"] .pg { cursor: text; }
.viewer.placing .pg { cursor: copy; touch-action: none; }
.pg g.ann > g { cursor: pointer; }
.viewer[data-tool="select"] .pg g.ann > g:hover { filter: drop-shadow(0 0 1.5px rgba(42, 70, 200, .7)); }
.pg .hd { cursor: nwse-resize; }
.pg .tx { white-space: pre; }
.halo { paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.hit { fill: var(--mark); opacity: .5; mix-blend-mode: multiply; }
.hit.cur { fill: #ff8a1f; opacity: .55; }
.cmp-add { fill: #3fbf7f; opacity: .35; mix-blend-mode: multiply; }
.forms { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.ff { position: absolute; pointer-events: auto; box-sizing: border-box; border: 1px solid rgba(42, 70, 200, .35); background: rgba(226, 233, 255, .72); color: #111; border-radius: 2px; padding: 0 3px; font-family: PaftaSans, sans-serif; margin: 0; }
.ff:hover { border-color: #2a46c8; }
.ff:focus { outline: 2px solid #2a46c8; background: #fff; }
textarea.ff { resize: none; padding-top: 2px; }
.ff-check, .ff-radio { accent-color: #2a46c8; background: none; border: 0; }
.ted { position: absolute; z-index: 5; border: 1.5px solid #2a46c8; border-radius: 2px; padding: 0 3px; margin: -1px 0 0 -2px; resize: none; overflow: hidden; outline: none; box-shadow: 0 2px 10px rgba(42, 70, 200, .25); white-space: pre; }
.selbar { position: absolute; z-index: 6; display: flex; gap: 2px; background: #151b2c; color: #fff; padding: 4px; border-radius: 9px; box-shadow: var(--shadow); }
.selbar button { display: flex; align-items: center; gap: 5px; border: 0; background: none; color: #fff; padding: 6px 9px; border-radius: 6px; font-size: 12px; white-space: nowrap; }
.selbar button .ic { width: 15px; height: 15px; }
.selbar button:hover { background: rgba(255, 255, 255, .14); }

.pages.spread { flex-direction: row; flex-wrap: wrap; justify-content: center; align-content: flex-start; width: 100%; max-width: none; }
.pages.spread .pg .pgno { display: none; }
.sigbanner { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 10px; padding: 8px max(16px, env(safe-area-inset-left, 0px)); font-size: 12.5px; border-bottom: 1px solid var(--line); background: var(--chrome); }
.sigbanner .ic { width: 17px; height: 17px; flex: none; }
.sigbanner span { flex: 1; min-width: 0; }
.sigbanner.good { background: color-mix(in srgb, var(--ok) 12%, var(--chrome)); } .sigbanner.good .ic { color: var(--ok); }
.sigbanner.warn { background: color-mix(in srgb, var(--warn) 14%, var(--chrome)); } .sigbanner.warn .ic { color: var(--warn); }
.sigbanner.bad { background: color-mix(in srgb, var(--danger) 12%, var(--chrome)); } .sigbanner.bad .ic { color: var(--danger); }
.sigrow { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 7px; border-left: 3px solid var(--line-2); background: var(--chrome-2); font-size: 12.5px; }
.sigrow.good { border-left-color: var(--ok); } .sigrow.warn { border-left-color: var(--warn); } .sigrow.bad { border-left-color: var(--danger); }
.sigrow small { font-size: 11.5px; }
.idrow, .att { display: flex; align-items: center; gap: 4px; padding: 6px 4px; border-bottom: 1px dashed var(--line); }
.idrow .cbody, .att .cbody { font-size: 12.5px; }
.att.new b { color: var(--accent); }
.ff-sig { background: rgba(255, 244, 200, .8); border: 1.5px dashed #b8740f; color: #6b4300; font: 600 12px PaftaSans, sans-serif; cursor: pointer; display: grid; place-items: center; }
.ff-sig:hover { background: #fff1c2; }
/* page organizer */
.pages.grid { flex-direction: row; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 22px; width: auto; padding: 24px 20px 80px; }
.gcard { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 10px; border: 1px solid transparent; cursor: grab; }
.gcard:hover { background: var(--chrome); border-color: var(--line); }
.gcard.sel { background: var(--accent-soft); border-color: var(--accent-line); }
.gcard.sel .gcv { box-shadow: 0 0 0 2px var(--accent); }
.gpick { position: absolute; top: 6px; left: 6px; z-index: 2; background: rgba(255, 255, 255, .9); border-radius: 4px; padding: 2px; display: grid; }
.gpick input { width: 16px; height: 16px; margin: 0; accent-color: #2a46c8; }
.gbar { display: flex; align-items: center; gap: 0; }
.gbar .mono { font-size: 12px; color: var(--muted); margin-right: auto; padding-left: 2px; }
.gadd { width: 168px; height: 237px; margin: 8px; border: 1.5px dashed var(--line-2); border-radius: 8px; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 12.5px; text-align: center; }
.gadd:hover { border-color: var(--accent); color: var(--accent); background: var(--chrome); }
.gadd .ic { width: 26px; height: 26px; }

/* ---------- side panel ---------- */
.panel { overflow-y: auto; padding: 16px 16px 40px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.ph h3 { margin: 0; font: 700 16px/1.25 var(--display); letter-spacing: -.01em; text-wrap: balance; overflow-wrap: anywhere; }
.ph p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.pgrp { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.pgrp h4 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.count { font: 600 10.5px var(--mono); background: var(--chrome-2); border: 1px solid var(--line); border-radius: 10px; padding: 0 6px; color: var(--ink); letter-spacing: 0; }
.prow { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 8px; }
.pl { font-size: 12px; color: var(--muted); }
.fld { display: flex; flex-direction: column; gap: 4px; }
.fld span { font-size: 12px; color: var(--muted); }
.fld input, .fld textarea, .fld select, .inp { border: 1px solid var(--line-2); background: var(--paper); color: #151b2c; border-radius: 6px; padding: 6px 8px; min-width: 0; width: 100%; box-sizing: border-box; }
.fld textarea { resize: vertical; }
.fld input[type="color"], .inp[type="color"] { padding: 2px; height: 32px; }
.chk { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; }
.chk input { margin-top: 2px; accent-color: var(--accent); }
.rng { display: flex; align-items: center; gap: 8px; } .rng input { flex: 1; min-width: 0; accent-color: var(--accent); } .rng output { font-size: 11.5px; min-width: 34px; text-align: right; }
.sw { display: flex; flex-wrap: wrap; gap: 5px; }
.swb { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .18); background: var(--c); padding: 0; position: relative; display: grid; place-items: center; }
.swb.on { box-shadow: 0 0 0 2px var(--chrome), 0 0 0 4px var(--accent); }
.swb.none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45% 55%, transparent 55%), var(--paper); }
.swb.custom { background: conic-gradient(#f43, #fd3, #3c6, #39f, #a3f, #f43); overflow: hidden; cursor: pointer; }
.swb.custom input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; background: var(--chrome); }
.seg.full { display: flex; } .seg.full button { flex: 1; }
.seg button { border: 0; background: none; padding: 6px 10px; font-size: 12px; white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pacts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.pacts .btn { padding: 6px 8px; font-size: 12.5px; } .pacts .ic { width: 16px; height: 16px; }
.row2 { display: flex; gap: 6px; flex-wrap: wrap; } .row2 > .btn { flex: 1; } .row2.between { justify-content: space-between; align-items: center; }
.actlist { display: flex; flex-direction: column; gap: 4px; }
.arow { display: flex; gap: 10px; align-items: flex-start; text-align: left; border: 1px solid var(--line); background: var(--paper); color: #151b2c; border-radius: 8px; padding: 9px 10px; }
.arow:hover { border-color: var(--accent-line); background: color-mix(in srgb, var(--accent-soft) 40%, var(--paper)); }
.arow .ic { color: #2a46c8; margin-top: 1px; }
.arow span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.arow small { color: #5b6479; font-size: 11.5px; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: 12.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.keys { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
kbd { font: 11px var(--mono); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--chrome); margin-right: 2px; }
.clist, .flist { display: flex; flex-direction: column; gap: 2px; max-height: 46vh; overflow-y: auto; }
.crow, .hunk { display: flex; gap: 8px; align-items: flex-start; text-align: left; border: 0; background: none; padding: 7px 6px; border-radius: 6px; font-size: 12.5px; }
.crow:hover, .hunk:hover { background: var(--chrome-2); }
.cdot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); margin-top: 5px; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.cbody { display: flex; flex-direction: column; min-width: 0; flex: 1; } .cbody span { color: var(--muted); overflow-wrap: anywhere; }
.crow .mono { font-size: 11px; }
.frow { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr); gap: 6px; align-items: center; font-size: 12px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.flink { border: 0; background: none; color: var(--accent); font-size: 11px; padding: 0; text-align: left; }
.fname { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .fval { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote { margin: 0; border-left: 3px solid var(--mark); padding: 4px 8px; font-size: 12.5px; color: var(--muted); }
.stamps { display: flex; flex-wrap: wrap; gap: 6px; }
.stampb { border: 1.8px solid var(--c); color: var(--c); background: var(--paper); border-radius: 4px; padding: 3px 7px; font: 700 10.5px var(--ui); letter-spacing: .04em; }
.stampb.on { box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 3px var(--accent); }
.selinfo { margin: 0; font-size: 12.5px; color: var(--muted); }
.okmsg { display: flex; gap: 6px; align-items: flex-start; margin: 0; padding: 8px 10px; background: color-mix(in srgb, var(--ok) 12%, transparent); border-radius: 7px; font-size: 12.5px; }
.okmsg .ic { color: var(--ok); width: 16px; height: 16px; }
.cmpres { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; padding: 8px 10px; background: var(--chrome-2); border-radius: 7px; }
.cmpres .btn { margin-left: auto; }
.cmpsum { display: flex; gap: 10px; font: 600 13px var(--mono); }
.ins, ins { color: var(--ok); text-decoration: none; background: color-mix(in srgb, var(--ok) 14%, transparent); border-radius: 3px; padding: 0 2px; }
.del, del { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); border-radius: 3px; padding: 0 2px; }
.hunk .mono { font-size: 11px; flex: none; padding-top: 1px; }
.sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sigc { position: relative; } .sigc .iconbtn { position: absolute; top: 2px; right: 2px; background: var(--chrome); }
.sigb { width: 100%; height: 64px; border: 1px solid var(--line); border-radius: 7px; background: #fff; display: grid; place-items: center; padding: 6px; }
.sigb:hover { border-color: var(--accent); } .sigb img { max-height: 100%; max-width: 100%; }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; }
.chat:empty { display: none; }
.msg { padding: 8px 11px; border-radius: 10px; font-size: 13px; max-width: 100%; overflow-wrap: anywhere; }
.msg.u { background: var(--accent); color: var(--accent-ink); align-self: flex-end; border-bottom-right-radius: 3px; }
.msg.a { background: var(--chrome-2); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg p, .msg ul { margin: 0 0 6px; } .msg ul { padding-left: 18px; } .msg h5 { margin: 6px 0 4px; font-size: 13px; }
.msg > :last-child { margin-bottom: 0; }
.pref { border: 0; background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 4px; font: 500 11.5px var(--mono); }
.dots::after { content: "…"; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.ask { display: flex; flex-direction: column; gap: 6px; }
.ask textarea { border: 1px solid var(--line-2); background: var(--paper); color: #151b2c; border-radius: 8px; padding: 8px; resize: vertical; }
.ask .btn { align-self: flex-end; }
code { font: 11.5px var(--mono); background: var(--chrome-2); padding: 0 3px; border-radius: 3px; }

/* ---------- status ---------- */
.status { display: flex; gap: 16px; align-items: center; background: var(--chrome); border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); padding-block: 4px; padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); white-space: nowrap; overflow: hidden; }
.status .grow { flex: 1; }

/* ---------- overlays ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(12, 16, 28, .45); display: grid; place-items: center; z-index: 80; padding: 16px; }
.modal { background: var(--chrome); color: var(--ink); border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); width: min(460px, 100%); max-height: calc(100% - 32px); display: flex; flex-direction: column; border: 1px solid var(--line); }
.modal.wide { width: min(640px, 100%); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px 18px; }
.modal-h h2 { margin: 0; font: 700 17px var(--display); }
.modal-b { padding: 6px 18px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-b p { margin: 0; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
details summary { cursor: pointer; font-size: 12.5px; font-weight: 500; padding: 4px 0; }
details > .fld, details > .chk, details > .grid3 { margin-top: 8px; }
.copyarea { width: 100%; min-height: 200px; border: 1px solid var(--line-2); border-radius: 6px; padding: 8px; font: 12px var(--mono); box-sizing: border-box; background: var(--paper); color: #151b2c; }
.sigpad { width: 100%; aspect-ratio: 2.8; background: #fff; border: 1px dashed var(--line-2); border-radius: 8px; touch-action: none; cursor: crosshair; max-width: 100%; display: block; background-image: linear-gradient(transparent calc(100% - 28%), #dfe3ec calc(100% - 28%), #dfe3ec calc(100% - 27.5%), transparent calc(100% - 27.5%)); }
#sgName { width: 100%; box-sizing: border-box; border: 1px solid var(--line-2); border-radius: 6px; padding: 8px; background: var(--paper); color: #151b2c; }
.sgfonts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.sgf { height: 64px; font-size: 26px; border: 1px solid var(--line); background: #fff; color: #14182b; border-radius: 8px; overflow: hidden; white-space: nowrap; }
.sgf.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.drop.small { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px; border: 1.5px dashed var(--line-2); border-radius: 8px; text-align: center; color: var(--muted); cursor: pointer; font-size: 12.5px; }
.drop.small input { display: none; }
#sgPrev { max-height: 120px; margin-top: 8px; background: #fff; border-radius: 6px; padding: 6px; align-self: center; }
.dropzone { position: fixed; inset: 0; z-index: 40; background: rgba(12, 16, 28, .55); display: flex; gap: 18px; align-items: center; justify-content: center; padding: 24px; flex-wrap: wrap; }
.dz { width: min(300px, 100%); height: 180px; border: 2px dashed rgba(255, 255, 255, .7); border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #fff; font-size: 15px; }
.dz .ic { width: 34px; height: 34px; } .dz.hot { background: rgba(42, 70, 200, .5); border-color: #fff; }
.busy { position: fixed; inset: 0; z-index: 60; background: rgba(12, 16, 28, .32); display: grid; place-items: center; }
.busyc { background: var(--chrome); border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; width: min(320px, calc(100% - 32px)); display: flex; flex-direction: column; align-items: center; gap: 10px; box-shadow: var(--shadow); }
.busyc p { margin: 0; text-align: center; font-size: 13px; }
.spin { width: 26px; height: 26px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { width: 100%; height: 4px; background: var(--chrome-2); border-radius: 2px; overflow: hidden; } .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.toasts { position: fixed; bottom: calc(36px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(520px, calc(100% - 32px)); pointer-events: none; }
.toast { background: #151b2c; color: #f3f5fa; padding: 9px 14px; border-radius: 9px; font-size: 13px; box-shadow: var(--shadow); border-left: 4px solid #8fa3ff; transition: opacity .3s, transform .3s; max-width: 100%; }
.toast.ok { border-left-color: #4cc38a; } .toast.warn { border-left-color: #e2a14a; } .toast.err { border-left-color: #ff6b76; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- narrow screens ---------- */
@media (max-width: 979px) {
  .work, body.hide-left .work, body.hide-right .work { grid-template-columns: minmax(0, 1fr); }
  .left, .right { position: absolute; top: 0; bottom: 0; z-index: 20; box-shadow: var(--shadow); transition: transform .2s ease; }
  .left { left: 0; width: 176px; transform: translateX(-102%); }
  .right { right: 0; width: min(340px, 92%); transform: translateX(102%); }
  body.show-left .left, body.show-right .right { transform: none; }
  .pages { padding: 14px 10px 80px; gap: 12px; }
  .pg .pgno { display: none; }
  .thint { display: none; }
  .tgroup.zoom .iconbtn, .tgroup.nav .iconbtn { display: none; }
  .fileid { display: none; }
  .find { flex: 1 1 120px; }
}
@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 6px; }
  .brand b { display: none; }
  .btn span { display: none; } .btn { padding: 6px 9px; }
  .find { order: 10; flex: 1 1 100%; margin-left: 0; }
  .tgroup.zoom { display: none; }
  .tgroup.panes { margin-left: auto; }
  .tab { padding: 8px 10px 7px; } .tab span { font-size: 12.5px; }
  .tb { min-width: 52px; padding: 4px 6px 3px; }
  .status span:not(#stPage) { display: none; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- server features ---------- */
.envs { display: grid; grid-template-columns: 10px minmax(0, 1fr) minmax(0, 1.3fr); gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.envs .btn, .envs .iconbtn { grid-column: 2 / -1; justify-self: start; }
.envs .iconbtn { grid-column: 3; justify-self: end; margin-top: -32px; }
.dotc { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.srow2 { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 6px; font-size: 12.5px; padding: 4px 0; }
.envbanner { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px max(16px, env(safe-area-inset-left, 0px)); background: color-mix(in srgb, var(--mark) 26%, var(--chrome)); border-bottom: 1px solid var(--line); font-size: 13px; }
.envbanner span { flex: 1 1 260px; min-width: 0; }
.envbanner small { color: var(--muted); }
.envscreen { position: fixed; inset: 0; z-index: 75; background: var(--desk); display: grid; place-items: center; padding: 16px; }
.envscreen .card { background: var(--chrome); border: 1px solid var(--line); border-radius: 14px; padding: 26px; max-width: 460px; width: 100%; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.envscreen .brand { margin-bottom: 6px; } .envscreen h2 { margin: 0; font: 800 22px var(--display); } .envscreen p { margin: 0; color: var(--muted); }
body.signmode .ff-sig:not(.ff-other) { animation: pulse 1.6s ease-in-out infinite; }
.ff-other { background: rgba(140, 146, 165, .14); border: 1px dashed #8a92a5; color: #6b7389; cursor: not-allowed; font: 500 11px PaftaSans, sans-serif; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(255, 210, 63, .5); } }
