/* =========================================================================
   Library, Notes, Write, the reader, voice mode and the trust sheets.

   Same rules as style.css: glass for chrome (the list columns, the panels,
   the toolbars), solid surfaces for anything read closely (papers, cards,
   the page you write on). One accent, Penn State blue.
   ========================================================================= */

:root {
  /* Thea's face: ink on light pages, light on dark ones */
  --holo-core: #001E44;
  --holo-mid: #1E407C;
  --holo-deep: #9FB5DC;
  --hl-yellow: rgba(255, 208, 0, 0.42);
  --hl-green: rgba(46, 196, 92, 0.32);
  --hl-blue: rgba(64, 132, 230, 0.30);
  --hl-pink: rgba(255, 86, 150, 0.32);
  --page-bg: #ffffff;
  --reader-bg: rgba(0, 30, 68, 0.05);
  --read-font: var(--serif);
}

[data-theme="dark"] {
  --holo-core: #F2F9FF;
  --holo-mid: #86AEEC;
  --holo-deep: #2F63B8;
  --hl-yellow: rgba(255, 214, 10, 0.30);
  --hl-green: rgba(74, 222, 128, 0.25);
  --hl-blue: rgba(110, 165, 240, 0.30);
  --hl-pink: rgba(255, 110, 170, 0.28);
  --reader-bg: rgba(0, 0, 0, 0.22);
}

.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--text-faint); font-weight: 500; }
.mono { font-family: var(--mono); }
.break { overflow-wrap: anywhere; word-break: break-all; }

/* ------------------------------------------------------------ the spaces */

#spaceLibrary, #spaceNotes, #spaceWrite, #spaceMatrix { display: flex; flex-direction: column; }

.lib, .nts, .wr {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr);
  gap: var(--gap);
}

.wr { grid-template-columns: 268px minmax(0, 1fr); }
.wr-scrim { display: none; }
.wr.assist-on { grid-template-columns: 252px minmax(0, 1fr) 344px; }

.lib-list, .nt-list, .lib-detail, .nt-main, .wr-main, .wr-assist {
  min-width: 0;
  min-height: 0;
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lib-detail, .nt-main, .wr-main { position: relative; }

/* list column */
.lib-tools {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 8px;
  padding: 12px 12px 10px;
}

.lib-search {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.lib-search .ls-ico { position: absolute; left: 12px; display: grid; color: var(--text-faint); pointer-events: none; }
.lib-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 35px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.lib-search input:focus { border-color: var(--accent-bright); box-shadow: 0 0 0 3px var(--accent-soft); }
.lib-search input::placeholder { color: var(--text-faint); }

.lib-filter, #ntSeg { position: relative; z-index: 2; margin: 0 12px 8px; }
.nt-listhead { position: relative; z-index: 2; margin: 0 14px 6px; }
.nlh-title { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.nlh-title svg { color: var(--accent); }
.lib-filter .seg-btn, #ntSeg .seg-btn { padding: 0 8px; }

.lib-rows {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lib-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: start;
  width: 100%;
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.lib-row:hover { background: var(--surface-3); }
.lib-row.is-on { background: var(--card-hover); border-color: var(--accent-line); box-shadow: var(--shadow-sm); }
.lib-row:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: -2px; }

.lr-verdict {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-muted);
  flex-shrink: 0;
}
.lr-verdict.verified { background: var(--ok-soft); color: var(--ok-text); }
.lr-verdict.registered { background: var(--accent-soft); color: var(--accent); }
.lr-verdict.mismatch, .lr-verdict.error { background: var(--warn-soft); color: var(--warn-text); }
.lr-verdict.retracted { background: var(--bad-soft); color: var(--bad-text); }
.lr-verdict.note { background: var(--accent-soft); color: var(--accent); }
.lr-verdict .spin { width: 14px; height: 14px; }
.lr-verdict .lr-key { font-size: 10.5px; }

.lr-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lr-title {
  font-size: 13px;
  font-weight: 650;
  line-height: 1.38;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.lib-row.is-unread .lr-title::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 6px 2px 0; border-radius: 50%; background: var(--accent-bright); vertical-align: middle; }
.lr-meta { display: block; font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lr-meta .sep { opacity: 0.5; margin: 0 5px; }
.lr-meta .lr-key { margin-right: 6px; }
.lr-snip { font-size: 12px; line-height: 1.4; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lr-key { font-family: var(--mono); font-size: 11px; font-weight: 650; color: var(--accent); }
.lr-key.big { display: inline-grid; place-items: center; height: 26px; padding: 0 9px; border-radius: var(--r-sm); background: var(--accent-soft); font-size: 12px; }
.lr-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; color: var(--text-faint); font-size: 11px; padding-top: 2px; }
.lr-notes { display: inline-flex; align-items: center; gap: 3px; font-family: var(--mono); }
.lr-file { display: inline-grid; }

.lib-foot {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border-hair);
  font-size: 11.5px;
  color: var(--text-muted);
}
.lib-foot .dot { opacity: 0.5; }
.lib-foot .ok { color: var(--ok-text); font-weight: 600; }
.lib-foot .warn { color: var(--warn-text); font-weight: 600; }
.lf-local { display: inline-flex; align-items: center; gap: 4px; color: var(--text-faint); }

.lib-empty {
  margin: 18px 8px;
  padding: 22px 18px;
  border: 1px dashed var(--border-hair);
  border-radius: var(--r-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.55;
}
.lib-empty.small { padding: 16px; }
.lib-empty strong { color: var(--text); font-size: 13.5px; }
.lib-empty p { margin: 0 0 4px; }
.le-ico { width: 46px; height: 46px; border-radius: var(--r-lg); display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); margin-bottom: 2px; }

/* detail column */
.lib-detail, .nt-main, .wr-main { overflow-y: auto; }

.lib-welcome {
  position: relative;
  z-index: 2;
  margin: auto;
  width: min(620px, 100%);
  padding: 34px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: rise 0.5s var(--ease-out) both;
}
.lw-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
.lw-note { display: inline-flex; align-items: center; gap: 6px; margin-top: 22px; font-size: 12px; color: var(--text-faint); }

.pd { position: relative; z-index: 2; padding: 20px clamp(18px, 3vw, 34px) 30px; display: flex; flex-direction: column; gap: 14px; animation: rise 0.35s var(--ease-out) both; }
.pd-top { display: flex; align-items: center; gap: 8px; }
.pd-back { display: none; }
.pd-title { margin: 0; font-size: clamp(19px, 2vw, 23px); font-weight: 780; letter-spacing: -0.02em; line-height: 1.28; color: var(--text); text-wrap: balance; overflow-wrap: anywhere; }
.pd-meta { margin: -6px 0 0; font-size: 13px; line-height: 1.55; color: var(--text-muted); }
.pd-meta .sep { margin: 0 7px; opacity: 0.45; }
.pd-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.pd .source-links { margin-top: -4px; }
.icon-btn[aria-pressed="true"] { color: #e6a700; }

.card {
  padding: 15px 16px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-lg);
  background: var(--card);
}
.card-head { display: flex; align-items: flex-start; gap: 12px; }
.card-ico { width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.card-title { font-size: 14px; font-weight: 720; color: var(--text); }
.card-sub { margin-top: 2px; font-size: 12.5px; line-height: 1.5; color: var(--text-muted); }
.card-sub.verified { color: var(--ok-text); font-weight: 600; }
.card-sub.registered { color: var(--accent); font-weight: 600; }
.card-sub.mismatch, .card-sub.error { color: var(--warn-text); font-weight: 600; }
.card-sub.retracted { color: var(--bad-text); font-weight: 700; }
.card-foot { margin: 10px 0 0; font-size: 11.5px; color: var(--text-faint); }
.card .signals { margin-top: 12px; padding-left: 44px; }
.card .stage-line { margin: 12px 0 0 44px; }
.verify-card.retracted { border-color: var(--bad-line); background: color-mix(in srgb, var(--bad-soft) 60%, var(--card)); }
.verify-card.verified { border-color: var(--ok-line); }

.abstract { margin-top: 12px; padding: 11px 13px; border-radius: var(--r-md); background: var(--surface-2); font-size: 13px; line-height: 1.65; color: var(--text-2); }
.abstract .passage-label, .read-body .passage-label { display: block; margin-bottom: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }

.sum-text { margin: 12px 0 0; font-size: 14px; line-height: 1.7; color: var(--text-2); }
.sum-kv { margin: 12px 0 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; font-size: 13px; line-height: 1.55; }
.sum-kv dt { font-weight: 700; color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; padding-top: 2px; }
.sum-kv dd { margin: 0; color: var(--text-2); }
.sum-block { margin-top: 12px; }
.sum-label { font-size: 11.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.sum-block ul { margin: 6px 0 0; padding-left: 1.2em; font-size: 13px; line-height: 1.6; color: var(--text-2); }
.sum-block li { margin: 3px 0; }
.kw { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.kw-chip { padding: 3px 9px; border-radius: var(--r-sm); background: var(--surface-3); font-size: 11.5px; font-weight: 600; color: var(--text-muted); }

.ann-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ann-hit {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
  color: inherit;
  transition: background 0.15s ease;
}
.ann-hit:hover { background: var(--surface-3); }
.ann-swatch { width: 10px; min-height: 100%; border-radius: var(--r-xs); background: var(--hl-yellow); }
.ann-swatch.c-green, .sw-btn.c-green { background: var(--hl-green); }
.ann-swatch.c-blue, .sw-btn.c-blue { background: var(--hl-blue); }
.ann-swatch.c-pink, .sw-btn.c-pink { background: var(--hl-pink); }
.ann-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ann-quote { font-family: var(--read-font); font-size: 13.5px; line-height: 1.5; color: var(--text); }
.ann-comment { font-size: 12.5px; line-height: 1.5; color: var(--text-2); padding-left: 8px; border-left: 2px solid var(--accent-line); }
.ann-meta { font-size: 11px; color: var(--text-faint); }

.file-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12px; color: var(--text-faint); }
.file-line .mono { font-size: 11px; }

.primary-btn.sm { min-height: 30px; padding: 0 12px; font-size: 12px; }
.primary-btn.xs, .ghost-btn.xs { min-height: 26px; padding: 0 9px; font-size: 11.5px; gap: 5px; }
.icon-btn.sm { width: 34px; height: 34px; border-radius: var(--r-sm); }
.icon-btn.xs { width: 28px; height: 28px; border-radius: var(--r-sm); }
.icon-btn.is-on { color: var(--accent); background: var(--accent-soft); }
.icon-btn.danger-text:hover { color: var(--bad-text); background: var(--bad-soft); }
.notice.good { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-text); }

/* reference checker, cite sheet */
.mono-field { font-family: var(--mono); font-size: 12.5px; }
.ref-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ref { padding: 11px 13px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.ref.not-found, .ref.retracted { border-color: var(--bad-line); }
.ref.partial { border-color: var(--warn-line); }
.ref-badge { padding: 2px 8px; border-radius: var(--r-sm); font-size: 10.5px; font-weight: 750; letter-spacing: 0.05em; text-transform: uppercase; background: var(--ok-soft); color: var(--ok-text); }
.ref-badge.partial { background: var(--warn-soft); color: var(--warn-text); }
.ref-badge.not-found, .ref-badge.retracted { background: var(--bad-soft); color: var(--bad-text); }
.ref-in { font-size: 12.5px; line-height: 1.5; color: var(--text-2); }
.ref-match { display: flex; gap: 6px; font-size: 12.5px; color: var(--text-muted); }
.ref-match svg { flex-shrink: 0; margin-top: 3px; }
.ref-note { font-size: 12px; color: var(--warn-text); }

.cite-style { padding: 12px 14px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); }
.cite-style + .cite-style { margin-top: 8px; }
.cs-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.cs-text { margin-top: 6px; font-size: 13px; line-height: 1.6; color: var(--text); user-select: text; }

.field-row { display: flex; gap: 12px; }
.field-row > div { min-width: 0; }
.field-row > div:first-child { width: 110px; flex-shrink: 0; }
.field-row > div:not(.grow):not(:first-child) { width: 90px; flex-shrink: 0; }
.field.sm { width: 110px; padding: 6px 10px; font-size: 13px; }
.field-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }

.cite-pick { margin-top: 12px; max-height: min(46vh, 420px); overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 2px; }
.cp-row { display: grid; grid-template-columns: 18px 30px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.cp-row:hover { border-color: var(--accent-line); }
.cp-row:has(input:checked) { border-color: var(--accent-bright); background: var(--accent-soft); }
.cp-row.is-retracted { opacity: 0.6; cursor: not-allowed; }
.cp-row input { accent-color: var(--accent-bright); width: 16px; height: 16px; }
.cp-row .lr-verdict { width: 30px; height: 30px; }
.cp-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cp-title { font-size: 13px; font-weight: 650; line-height: 1.35; display: flex; gap: 7px; }
.cp-meta { font-size: 11.5px; color: var(--text-muted); }

/* ------------------------------------------------------------- the reader */

.lib.reading { grid-template-columns: minmax(0, 1fr); }
.lib.reading .lib-list { display: none; }
.lib.reading .lib-detail { overflow: hidden; }

.reader { position: relative; z-index: 2; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

.rd-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 10px;
  border-bottom: 1px solid var(--border-hair);
}
.rd-title { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
.rd-name { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.rd-tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.rd-view .seg-btn { padding: 0 10px; }
.rd-pager { display: inline-flex; align-items: center; gap: 4px; flex: none; font-size: 12.5px; color: var(--text-muted); font-family: var(--mono); white-space: nowrap; }
.rd-pagein { width: 42px; height: 28px; padding: 0 6px; border: 1px solid var(--border-hair); border-radius: var(--r-sm); background: var(--card); text-align: center; font-family: var(--mono); font-size: 12.5px; color: var(--text); outline: none; }
.rd-pagein:focus { border-color: var(--accent-bright); }
.rd-zoom { display: inline-flex; align-items: center; gap: 2px; }
.rd-zlabel { min-width: 52px; height: 28px; border: 0; border-radius: var(--r-sm); background: transparent; font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.rd-zlabel:hover { background: var(--surface-3); color: var(--text); }
.rd-zlabel.is-fit { color: var(--accent); }
.rd-sep { width: 1px; height: 20px; background: var(--border-hair); margin: 0 2px; }
.rd-hlbtn { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-muted); font-family: var(--mono); font-size: 12px; font-weight: 600; }
.rd-hlbtn:hover { background: var(--surface-3); color: var(--text); }
.reader.side-on .rd-hlbtn, .reader.side-on [data-r="find"] { color: var(--accent); }

.rd-body { flex: 1 1 auto; min-height: 0; display: flex; }
.rd-scroll {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  background: var(--reader-bg);
  border-radius: 0 0 calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px);
  outline: none;
}
.reader.side-on .rd-scroll { border-bottom-right-radius: 0; }
.rd-pages { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 22px 32px 40px; min-width: min-content; }
.reader.is-text .rd-pages { gap: 0; padding: 26px clamp(18px, 5vw, 64px) 60px; align-items: stretch; }

.pdf-page {
  --user-unit: 1;
  --total-scale-factor: calc(var(--scale-factor, 1) * var(--user-unit));
  --scale-round-x: 1px;
  --scale-round-y: 1px;
  position: relative;
  flex-shrink: 0;
  background: var(--page-bg);
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 20, 50, 0.12), 0 10px 28px rgba(0, 20, 50, 0.10);
  direction: ltr;
}
[data-theme="dark"] .pdf-page { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.45); }
.pdf-page:not(.is-rendered)::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(0, 30, 68, 0.04) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: inherit;
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.pdf-canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; }
.reader.dim-pages .pdf-page { background: #1b1f27; }
.reader.dim-pages .pdf-canvas { filter: invert(0.88) hue-rotate(180deg) contrast(0.92); }
.pg-num { position: absolute; left: 50%; bottom: -16px; transform: translateX(-50%); font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); pointer-events: none; }

.hl-layer { position: absolute; inset: 0; z-index: 1; pointer-events: none; mix-blend-mode: multiply; }
.reader.dim-pages .hl-layer { mix-blend-mode: screen; }
.hl-layer .hl { position: absolute; border-radius: 2px; background: var(--hl-yellow); }
.hl-layer .hl.c-green { background: var(--hl-green); }
.hl-layer .hl.c-blue { background: var(--hl-blue); }
.hl-layer .hl.c-pink { background: var(--hl-pink); }
.hl-layer .hl.flash { background: rgba(47, 99, 184, 0.30); animation: flash-in 4.2s ease forwards; }
.hl.pulse, mark.pulse { animation: pulse-hl 1.6s ease 2; }
@keyframes pulse-hl { 0%, 100% { box-shadow: 0 0 0 0 rgba(47, 99, 184, 0); } 40% { box-shadow: 0 0 0 4px rgba(47, 99, 184, 0.45); } }
@keyframes flash-in { 0% { opacity: 0; } 10% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }

/* pdf.js text layer: transparent, selectable text over the canvas */
.textLayer {
  position: absolute;
  text-align: initial;
  inset: 0;
  overflow: clip;
  opacity: 1;
  line-height: 1;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  caret-color: CanvasText;
  z-index: 2;
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));
}
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; user-select: text; }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) {
  z-index: 1;
  --font-height: 0;
  font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1;
  --rotate: 0deg;
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
.textLayer .markedContent { display: contents; }
.textLayer span[role="img"] { user-select: none; cursor: default; }
.textLayer ::selection { background: rgba(47, 99, 184, 0.28); color: transparent; }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer.selecting .endOfContent { top: 0; }

.mnotes { position: absolute; top: 0; bottom: 0; right: -38px; width: 30px; z-index: 3; }
.mnote {
  position: absolute;
  right: 0;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-sm) var(--r-sm) var(--r-sm) 3px;
  background: var(--surface-solid);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-4px);
  transition: transform 0.18s var(--ease-spring);
}
.mnote:hover { transform: translateY(-4px) scale(1.08); }
.mnote.c-yellow { box-shadow: var(--shadow-sm), inset 0 -3px 0 var(--hl-yellow); }
.mnote.c-green { box-shadow: var(--shadow-sm), inset 0 -3px 0 var(--hl-green); }
.mnote.c-blue { box-shadow: var(--shadow-sm), inset 0 -3px 0 var(--hl-blue); }
.mnote.c-pink { box-shadow: var(--shadow-sm), inset 0 -3px 0 var(--hl-pink); }
.mnote.inline { position: static; display: inline-grid; width: 20px; height: 20px; margin: 0 2px; vertical-align: -3px; transform: none; border-radius: var(--r-xs); }

/* text view: the paper as readable prose */
.tv-page { max-width: 720px; width: 100%; margin: 0 auto; padding: 4px 0 26px; }
.tv-head { position: sticky; top: -26px; z-index: 1; margin-bottom: 8px; padding: 6px 0; font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.tv-body { font-family: var(--read-font); font-size: 16.5px; line-height: 1.75; color: var(--text); overflow-wrap: anywhere; }
.tv-body p { margin: 0 0 0.9em; text-wrap: pretty; }
.tv-body p.tv-front { font-family: var(--sans); font-size: 14px; line-height: 1.55; color: var(--text-muted); padding-bottom: 14px; margin-bottom: 18px; border-bottom: 1px solid var(--border-hair); }
.tv-body h4 { margin: 1.4em 0 0.5em; font-family: var(--sans); font-size: 13px; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.tv-body mark.hl { color: inherit; background: var(--hl-yellow); border-radius: 2px; padding: 0.05em 0; cursor: pointer; }
.tv-body mark.hl.c-green { background: var(--hl-green); }
.tv-body mark.hl.c-blue { background: var(--hl-blue); }
.tv-body mark.hl.c-pink { background: var(--hl-pink); }
.tv-body mark.flash { color: inherit; background: rgba(47, 99, 184, 0.24); border-radius: 2px; animation: flash-in 4.2s ease forwards; }

.rd-empty, .rd-loading { margin: auto; padding: 60px 24px; max-width: 420px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text-muted); font-size: 13px; }
.rd-empty strong { color: var(--text); font-size: 14.5px; }
.rd-empty p { margin: 0; }
.rd-loading { flex-direction: row; justify-content: center; }

.rd-side {
  width: 300px;
  flex-shrink: 0;
  border-left: 1px solid var(--border-hair);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 12px 16px;
  animation: rise 0.25s var(--ease-out) both;
}
.rs-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; }
.rs-head .count { padding: 1px 8px; border-radius: var(--r-sm); background: var(--surface-3); font-family: var(--mono); font-size: 11px; color: var(--text-muted); }
.rs-empty { margin: 4px 2px; font-size: 12.5px; line-height: 1.55; color: var(--text-muted); }
.rs-find { position: relative; display: flex; align-items: center; margin-bottom: 8px; }
.rs-find .ls-ico { position: absolute; left: 11px; color: var(--text-faint); display: grid; }
.rs-find input { width: 100%; height: 34px; padding: 0 10px 0 32px; border: 1px solid var(--border-hair); border-radius: var(--r-sm); background: var(--card); color: var(--text); font-size: 13px; outline: none; }
.rs-find input:focus { border-color: var(--accent-bright); }
.rs-count { font-size: 11.5px; color: var(--text-faint); margin: 2px 2px 6px; }
.rs-results { display: flex; flex-direction: column; gap: 2px; }
.find-hit { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 6px; padding: 7px 8px; border: 0; border-radius: var(--r-sm); background: transparent; text-align: left; color: inherit; font-size: 12px; line-height: 1.45; }
.find-hit:hover { background: var(--surface-3); }
.fh-page { font-family: var(--mono); font-size: 11px; color: var(--accent); padding-top: 1px; }
.fh-text { color: var(--text-2); overflow-wrap: anywhere; }
.fh-text b { color: var(--text); background: var(--hl-yellow); border-radius: 2px; font-weight: 650; }

/* selection toolbar and highlight popover */
.rd-seltool, .rd-annpop {
  position: absolute;
  z-index: 30;
  border: 1px solid var(--border);
  background: var(--menu-fill);
  box-shadow: var(--shadow-lift), var(--glass-inset);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  animation: pop-in 0.18s var(--ease-out) both;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(4px) scale(0.97); } }
.rd-seltool { display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: var(--r-md); }
.sw-btn { width: 24px; height: 24px; border: 2px solid var(--surface-solid); border-radius: 50%; background: var(--hl-yellow); box-shadow: 0 0 0 1px var(--border-hair); transition: transform 0.15s var(--ease-spring); padding: 0; }
.sw-btn:hover { transform: scale(1.15); }
.sw-btn.is-on { box-shadow: 0 0 0 2px var(--accent-bright); }
.sw-btn.c-yellow { background: #ffd84d; }
.sw-btn.c-green { background: #7ddc95; }
.sw-btn.c-blue { background: #8db8f2; }
.sw-btn.c-pink { background: #ff9cc3; }
.st-sep { width: 1px; height: 20px; margin: 0 3px; background: var(--border-hair); }
.st-btn { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 9px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.st-btn:hover { background: var(--accent-soft); color: var(--accent); }
.st-btn.icon-only { width: 30px; padding: 0; justify-content: center; }

.rd-annpop { width: 320px; padding: 12px; border-radius: var(--r-lg); display: flex; flex-direction: column; gap: 9px; }
.ap-head { display: flex; align-items: center; gap: 8px; }
.ap-colors { display: flex; gap: 5px; flex: 1; }
.ap-page { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.ap-quote { margin: 0; padding: 2px 0 2px 10px; border-left: 3px solid var(--accent-line); font-family: var(--read-font); font-size: 13.5px; line-height: 1.5; color: var(--text-2); max-height: 120px; overflow-y: auto; }
.ap-comment { min-height: 74px; font-size: 13px; }
.ap-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.ap-foot { font-size: 11px; color: var(--text-faint); }

/* ------------------------------------------------------------------ notes */

.nt-main .lib-welcome, .wr-main .lib-welcome { margin: auto; }

.nt-editor, .wr-doc { position: relative; z-index: 2; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.nt-head, .wd-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 6px; }
.nt-title {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 21px;
  font-weight: 780;
  letter-spacing: -0.02em;
  outline: none;
}
.nt-title::placeholder { color: var(--text-faint); }
.save-state { font-size: 11.5px; font-weight: 600; color: var(--text-faint); white-space: nowrap; transition: color 0.2s ease; }
.save-state.is-dirty { color: var(--accent); }
.nt-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0 16px 8px; }
.link-chip { display: inline-flex; align-items: center; max-width: 100%; border: 1px solid var(--accent-line); border-radius: var(--r-sm); background: var(--accent-soft); overflow: hidden; }
.lc-open { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 300px; height: 26px; padding: 0 4px 0 10px; border: 0; background: transparent; color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-x { width: 24px; height: 26px; display: grid; place-items: center; border: 0; background: transparent; color: var(--accent); opacity: 0.6; }
.lc-x:hover { opacity: 1; }
.link-add { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border: 1px dashed var(--border-hair); border-radius: var(--r-sm); background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.link-add:hover { border-color: var(--accent-line); color: var(--accent); }

.ed-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 2px 12px 0;
  padding: 5px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-md);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.tb-btn { display: inline-grid; place-items: center; grid-auto-flow: column; gap: 5px; min-width: 32px; height: 32px; padding: 0 7px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-muted); font-size: 12.5px; font-weight: 650; transition: background 0.15s ease, color 0.15s ease; }
.tb-btn:hover { background: var(--surface-3); color: var(--text); }
.tb-btn.is-on { background: var(--accent-soft); color: var(--accent); }
.tb-cite { color: var(--accent); padding: 0 10px; }
.tb-mic { width: 32px; border-radius: 50%; padding: 0; }
.tb-sep { width: 1px; height: 20px; margin: 0 4px; background: var(--border-hair); }
.tb-grow { flex: 1; }
.tb-select { height: 32px; padding: 0 26px 0 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font-size: 12.5px; font-weight: 650; outline: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 13px) 55%, calc(100% - 9px) 55%; background-size: 4px 4px; background-repeat: no-repeat; cursor: pointer; }
.tb-select:hover { background-color: var(--surface-3); }
.tb-select option { color: #10141B; }

.nt-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px clamp(16px, 4vw, 44px) 40px; }
.nt-body { max-width: 760px; margin: 0 auto; min-height: 100%; }
.nt-foot, .wd-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; padding: 9px 16px 11px; border-top: 1px solid var(--border-hair); font-size: 11.5px; color: var(--text-muted); }
.nt-foot .dot, .wd-foot .dot { opacity: 0.5; }

/* highlights board */
.hl-filter { padding: 8px 10px 12px; }
.hf-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 7px; }
.hf-colors { display: flex; align-items: center; gap: 7px; }
.hf-all { height: 26px; padding: 0 10px; border: 1px solid var(--border-hair); border-radius: var(--r-sm); background: transparent; font-size: 12px; font-weight: 650; color: var(--text-muted); }
.hf-all.is-on { background: var(--accent-fill); color: var(--accent-on); border-color: transparent; }
.hl-board { position: relative; z-index: 2; padding: 18px clamp(16px, 3vw, 30px) 30px; }
.hb-head { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 16px; }
.hb-title { margin: 0; font-size: 19px; font-weight: 780; letter-spacing: -0.02em; line-height: 1.3; }
.hb-cards { columns: 2 300px; column-gap: 12px; }
.hl-card { break-inside: avoid; margin: 0 0 12px; padding: 13px 14px 10px; border: 1px solid var(--border-hair); border-left: 4px solid #ffd84d; border-radius: var(--r-md); background: var(--card); }
.hl-card.c-green { border-left-color: #7ddc95; }
.hl-card.c-blue { border-left-color: #8db8f2; }
.hl-card.c-pink { border-left-color: #ff9cc3; }
.hl-card blockquote { margin: 0; font-family: var(--read-font); font-size: 14px; line-height: 1.6; color: var(--text); }
.hc-comment { margin: 8px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--text-2); }
.hc-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 11.5px; color: var(--text-muted); }
.hc-src { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --------------------------------------------------------- rich editing */

.rich {
  outline: none;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  overflow-wrap: anywhere;
  caret-color: var(--accent-bright);
  padding-bottom: 30vh;
}
.rich.is-empty::before { content: attr(data-placeholder); position: absolute; color: var(--text-faint); pointer-events: none; }
.rich > :first-child { margin-top: 0; }
.rich p { margin: 0 0 0.9em; }
.rich h1 { margin: 1.2em 0 0.5em; font-size: 1.65em; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; }
.rich h2 { margin: 1.4em 0 0.45em; font-size: 1.28em; font-weight: 780; letter-spacing: -0.015em; line-height: 1.3; }
.rich h3 { margin: 1.2em 0 0.4em; font-size: 1.06em; font-weight: 760; line-height: 1.35; }
.rich ul, .rich ol { margin: 0 0 0.9em; padding-left: 1.5em; }
.rich li { margin: 0.2em 0; }
.rich li::marker { color: var(--text-faint); }
.rich blockquote { margin: 0 0 1em; padding: 4px 0 4px 16px; border-left: 3px solid var(--accent-line); font-family: var(--read-font); color: var(--text-2); }
.rich blockquote[data-paper] { cursor: default; border-left-color: var(--accent-bright); background: var(--accent-soft); border-radius: 0 var(--r-sm) var(--r-sm) 0; padding-right: 10px; }
.rich a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 2px; }
.rich code { font-family: var(--mono); font-size: 0.86em; padding: 0.1em 0.35em; border-radius: var(--r-xs); background: var(--surface-3); }
.rich pre { padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-3); font-family: var(--mono); font-size: 13px; white-space: pre-wrap; }
.rich hr { border: 0; border-top: 1px solid var(--border-hair); margin: 1.6em 0; }
.rich .cite, .refs .cite {
  display: inline;
  min-width: 0;
  height: auto;
  margin: 0 1px;
  padding: 0.05em 0.3em;
  border-radius: var(--r-xs);
  font-size: 0.92em;
  font-weight: 600;
  line-height: inherit;
  vertical-align: baseline;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}
.rich .cite:hover { background: var(--accent-fill); color: var(--accent-on); transform: none; }
.rich .cite.is-missing { background: var(--bad-soft); color: var(--bad-text); }
.rich .cite.is-retracted { background: var(--bad-soft); color: var(--bad-text); text-decoration: line-through; }
.rich mark.todo, .as-note mark.todo, .ac-prose mark.todo { padding: 0 0.3em; border-radius: var(--r-xs); background: var(--warn-soft); color: var(--warn-text); font-size: 0.86em; font-weight: 650; }

/* ------------------------------------------------------------------ write */

.wr-main { overflow: hidden; }
.wd-head { padding: 10px 12px 8px; flex-wrap: nowrap; }
.type-chip { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border: 1px solid var(--border-hair); border-radius: var(--r-sm); background: var(--card); color: var(--text-2); font-size: 12px; font-weight: 650; white-space: nowrap; }
.type-chip:hover { border-color: var(--accent-line); color: var(--accent); }
.wd-style .tb-select { border: 1px solid var(--border-hair); background-color: var(--card); height: 30px; border-radius: var(--r-sm); }
.wd-thea[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }

.wd-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px clamp(12px, 3vw, 36px) 30px; background: var(--reader-bg); margin-top: 10px; }
.wd-page {
  position: relative;
  max-width: 780px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) clamp(22px, 6vw, 72px) 48px;
  border-radius: var(--r-xs);
  background: var(--surface-solid);
  box-shadow: 0 1px 3px rgba(0, 20, 50, 0.08), 0 14px 40px rgba(0, 20, 50, 0.08);
  min-height: 70vh;
}
[data-theme="dark"] .wd-page { background: #111827; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 18px 46px rgba(0, 0, 0, 0.45); }
.wd-title {
  display: block;
  width: 100%;
  margin: 0 0 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--read-font);
  font-size: clamp(24px, 3vw, 31px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  resize: none;
  overflow: hidden;
  outline: none;
}
.wd-title::placeholder { color: var(--text-faint); }
.wd-body.rich { font-family: var(--read-font); font-size: 17px; padding-bottom: 40px; }
.wd-body.rich h1, .wd-body.rich h2, .wd-body.rich h3 { font-family: var(--sans); }
.wd-refs { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border-hair); }
.refs-title { margin: 0 0 10px; font-size: 16px; font-weight: 780; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.refs-note { font-size: 11.5px; font-weight: 550; color: var(--text-faint); }
.refs { margin: 0; padding-left: 1.6em; font-family: var(--read-font); font-size: 14.5px; line-height: 1.6; color: var(--text-2); }
.refs.plain { list-style: none; padding-left: 0; }
.ref-entry { position: relative; margin: 0 0 9px; padding-right: 34px; }
.refs.plain .ref-entry { padding-left: 2em; text-indent: -2em; }
.ref-text { overflow-wrap: anywhere; }
.ref-verdict { position: absolute; right: 0; top: 0; width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-muted); text-indent: 0; }
.ref-verdict.verified { background: var(--ok-soft); color: var(--ok-text); }
.ref-verdict.registered { background: var(--accent-soft); color: var(--accent); }
.ref-verdict.retracted, .ref-verdict.mismatch { background: var(--bad-soft); color: var(--bad-text); }
.ref-verdict svg { width: 14px; height: 14px; }
.ref-warn { display: block; text-indent: 0; font-family: var(--sans); font-size: 12px; font-weight: 700; color: var(--bad-text); }
.refs-empty { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-faint); }
.wd-foot .goal { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); }
.goal-bar { width: 80px; height: 5px; border-radius: var(--r-xs); background: var(--surface-3); overflow: hidden; }
.goal-bar span { display: block; height: 100%; background: var(--accent-bright); border-radius: inherit; transition: width 0.3s ease; }
.wd-foot .link-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; }

.wr-welcome { width: min(760px, 100%); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; width: 100%; margin-top: 10px; text-align: left; }
.tpl-group { width: 100%; margin: 22px 0 0; font-family: var(--sans); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); text-align: left; }
.tpl { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; gap: 2px 10px; padding: 13px 14px; border: 1px solid var(--border-hair); border-radius: var(--r-lg); background: var(--card); color: inherit; text-align: left; transition: border-color 0.18s ease, background 0.18s ease; }
.tpl:hover { border-color: var(--accent-line); background: var(--card-hover); }
.tpl-ico { grid-row: 1 / span 2; width: 34px; height: 34px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tpl-name { font-size: 13.5px; font-weight: 700; color: var(--text); }
.tpl-sub { font-size: 12px; line-height: 1.4; color: var(--text-muted); }

/* Thea's writing panel */
.as { position: relative; z-index: 2; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.as-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 10px 14px; border-bottom: 1px solid var(--border-hair); }
.as-head strong { font-size: 14px; }
.as-mark { width: 28px; height: 28px; border-radius: var(--r-sm); display: grid; place-items: center; color: #fff; background: var(--accent-fill); }
.as-seg { margin-left: auto; }
.as-seg .seg-btn { padding: 0 9px; }
.as-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 12px 18px; display: flex; flex-direction: column; gap: 10px; }
.as-target { display: flex; align-items: flex-start; gap: 7px; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface-2); font-size: 12px; line-height: 1.45; color: var(--text-muted); }
.as-target svg { flex-shrink: 0; margin-top: 2px; }
.as-target.has-sel { background: var(--accent-soft); color: var(--accent); }
.as-target b { font-weight: 700; }
.as-ask { display: flex; flex-direction: column; gap: 6px; }
.as-ask .field { min-height: 62px; font-size: 13px; padding: 9px 11px; }
.as-ask .primary-btn { align-self: flex-end; }
.as-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.as-act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 56px; padding: 7px 4px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); color: var(--text-2); font-size: 11.5px; font-weight: 650; text-align: center; line-height: 1.2; transition: border-color 0.15s ease, color 0.15s ease, transform 0.18s var(--ease-spring); }
.as-act svg { color: var(--accent); }
.as-act:hover { border-color: var(--accent-line); color: var(--accent); }
.as-act:disabled { opacity: 0.45; cursor: default; transform: none; }
.as-note { display: flex; gap: 7px; margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--text-faint); }
.as-note svg { flex-shrink: 0; margin-top: 2px; }
.as-results { display: flex; flex-direction: column; gap: 9px; }
.as-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 10px; text-align: center; color: var(--text-faint); font-size: 12px; line-height: 1.5; }
.as-empty p { margin: 0; }
.as-card { padding: 12px 12px 10px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); animation: rise 0.3s var(--ease-out) both; }
.as-card.is-used { border-color: var(--ok-line); }
.as-card.err { border-color: var(--bad-line); }
.ac-head { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.ac-meta { font-size: 11px; color: var(--text-faint); }
.ac-seal { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border: 0; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-muted); font-family: var(--mono); font-size: 10.5px; }
.ac-seal:hover { color: var(--accent); }
.as-card .chips { margin-top: 8px; }
.as-card .skeleton { margin-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.ac-prose { margin-top: 9px; font-family: var(--read-font); font-size: 14px; line-height: 1.62; max-height: 340px; overflow-y: auto; }
.ac-prose h1, .ac-prose h2, .ac-prose h3 { font-family: var(--sans); font-size: 13.5px; margin: 0.8em 0 0.3em; }
.cite-chip { display: inline; padding: 0 0.25em; border-radius: var(--r-xs); background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 0.92em; white-space: nowrap; }
.ac-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.ac-used { display: flex; align-items: center; gap: 5px; margin-top: 8px; font-size: 11.5px; font-weight: 650; color: var(--ok-text); }
.claim-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.as-card .claim { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border-hair); }
.as-card .claim.bad { border-color: var(--bad-line); }
.claim-verdict { font-size: 11.5px; font-weight: 650; }
.claim-verdict.good { color: var(--ok-text); }
.claim-verdict.warn { color: var(--warn-text); }
.claim-verdict.bad { color: var(--bad-text); }
.as-card .claim-text { font-size: 13px; line-height: 1.5; color: var(--text); }
.title-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.title-pick { width: 100%; padding: 8px 10px; border: 1px solid var(--border-hair); border-radius: var(--r-sm); background: transparent; text-align: left; font-family: var(--read-font); font-size: 14px; line-height: 1.4; color: var(--text); }
.title-pick:hover { border-color: var(--accent-line); background: var(--accent-soft); }

.as-src { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.src-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto auto; gap: 7px; align-items: center; padding: 5px 4px 5px 5px; border-radius: var(--r-md); }
.src-row:hover { background: var(--surface-3); }
.src-row .lr-verdict { width: 30px; height: 30px; border-radius: var(--r-sm); }
.src-row.is-retracted { opacity: 0.55; }
.src-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; border: 0; padding: 0; background: none; text-align: left; color: inherit; }
.src-title { display: flex; gap: 6px; font-size: 12.5px; font-weight: 650; line-height: 1.35; overflow: hidden; }
.src-meta { font-size: 11px; color: var(--text-muted); }

.hist-actions { display: flex; }
.hist-h { margin: 6px 2px 0; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.hist-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.hist-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto; gap: 7px; align-items: center; padding: 7px 6px; border-radius: var(--r-sm); }
.hist-row:hover { background: var(--surface-3); }
.hr-ico { width: 26px; height: 26px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.hr-main { min-width: 0; display: flex; flex-direction: column; }
.hr-title { font-size: 12.5px; font-weight: 650; }
.hr-meta { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-empty { margin: 0 2px; font-size: 12px; line-height: 1.5; color: var(--text-faint); }

.exp-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.exp-opt { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 13px 12px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.exp-opt input { position: absolute; opacity: 0; pointer-events: none; }
.exp-opt:has(input:checked) { border-color: var(--accent-bright); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent-bright) inset; }
.exp-opt:has(input:focus-visible) { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.eo-ico { color: var(--accent); margin-bottom: 3px; }
.eo-name { font-size: 13.5px; font-weight: 750; }
.eo-sub { font-size: 11.5px; line-height: 1.4; color: var(--text-muted); }
.checks { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent-bright); }

/* ------------------------------------------------------------ trust sheets */

.trust-seg, #stSeg { margin-bottom: 16px; }
.trust-seg .seg-btn, #stSeg .seg-btn { padding: 0 10px; }
.tr-body, .st-body { min-height: 200px; animation: fade-in 0.25s ease; }
.tr-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; font-size: 12.5px; color: var(--text-muted); }
.tr-summary .ok { color: var(--ok-text); font-weight: 650; }
.tr-summary .dot { opacity: 0.5; }
.tr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; max-height: min(52vh, 480px); overflow-y: auto; }
.tr-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto 16px; gap: 11px; align-items: center; width: 100%; padding: 10px 12px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); color: inherit; text-align: left; transition: border-color 0.15s ease; }
.tr-row:hover { border-color: var(--accent-line); }
.tr-ico { width: 34px; height: 34px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tr-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tr-title { font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-meta { font-size: 11.5px; color: var(--text-muted); }
.tr-chev { color: var(--text-faint); display: grid; }
.tr-lead { margin: 0 0 14px; font-size: 13px; line-height: 1.6; color: var(--text-2); }

.rc-checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rc-check { display: flex; gap: 10px; padding: 13px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); }
.rc-check.good { border-color: var(--ok-line); background: color-mix(in srgb, var(--ok-soft) 70%, var(--card)); }
.rc-check.bad { border-color: var(--bad-line); background: color-mix(in srgb, var(--bad-soft) 70%, var(--card)); }
.rc-check.warn { border-color: var(--warn-line); }
.rc-ico { width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-muted); }
.rc-check.good .rc-ico { background: var(--ok); color: #fff; }
.rc-check.bad .rc-ico { background: var(--bad); color: #fff; }
.rc-check.warn .rc-ico { background: var(--warn-soft); color: var(--warn-text); }
.rc-ico .spin { width: 14px; height: 14px; }
.rc-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.rc-title { font-size: 13px; font-weight: 750; }
.rc-text { font-size: 12px; line-height: 1.5; color: var(--text-2); }
.rc-facts { margin: 16px 0 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 16px; font-size: 12.5px; }
.rc-facts dt { color: var(--text-muted); font-weight: 650; }
.rc-facts dd { margin: 0; color: var(--text); }
.rc-facts .mono { font-size: 11.5px; }
.rc-note { display: flex; gap: 8px; margin: 14px 0 0; font-size: 12px; line-height: 1.55; color: var(--text-muted); }
.rc-note svg { flex-shrink: 0; margin-top: 2px; }
.rc-note code { font-family: var(--mono); font-size: 11.5px; }
.sealed-text { margin: 0; white-space: pre-wrap; font-size: 12.5px; line-height: 1.55; color: var(--text-2); max-height: 260px; overflow-y: auto; }

.drop-box { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 24px; border: 2px dashed var(--border-hair); border-radius: var(--r-lg); background: var(--surface-2); color: var(--text-muted); font-size: 13px; cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.drop-box strong { color: var(--accent); }
.drop-box:hover, .drop-box.is-over { border-color: var(--accent-bright); background: var(--accent-soft); }
.drop-box.small { margin-top: 10px; padding: 14px; }
#vOut, #sOut { margin-top: 14px; }

.how { display: flex; flex-direction: column; gap: 14px; }
.how-step { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; }
.how-n { width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--accent-fill); color: #fff; font-weight: 800; font-size: 13px; }
.how-step h4 { margin: 3px 0 3px; font-size: 14px; font-weight: 750; }
.how-step p, .how-p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--text-2); }
.how-step code { font-family: var(--mono); font-size: 12px; }
.how-h { margin: 8px 0 0; font-size: 14px; font-weight: 780; }
.how-list { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 1.55; color: var(--text-2); }

/* settings */
.st-sec { padding: 16px 0; border-top: 1px solid var(--border-hair); }
.st-sec:first-child { border-top: 0; padding-top: 0; }
.st-sec h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 14.5px; font-weight: 780; }
.st-sec h3 svg { color: var(--accent); }
.st-sec h3 .count { padding: 0 8px; border-radius: var(--r-sm); background: var(--surface-3); font-family: var(--mono); font-size: 11px; color: var(--text-muted); font-weight: 600; }
.st-sec p { margin: 0 0 10px; font-size: 13px; line-height: 1.6; color: var(--text-2); }
.st-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; padding: 10px 0; border-top: 1px dashed var(--border-hair); }
.st-label { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); }
.st-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.st-actions label { cursor: pointer; }
.st-small { font-size: 12px !important; color: var(--text-muted) !important; }
.st-list { margin: 0 0 10px; padding-left: 1.2em; display: flex; flex-direction: column; gap: 7px; font-size: 13px; line-height: 1.55; color: var(--text-2); }
.meter { display: flex; align-items: center; gap: 12px; margin: 6px 0 4px; font-size: 12px; color: var(--text-muted); font-family: var(--mono); }
.meter-bar { flex: 1; height: 7px; border-radius: var(--r-xs); background: var(--surface-3); overflow: hidden; }
.meter-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent-bright); }
.danger-zone h3 svg { color: var(--bad-text); }
.src-items { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.src-item { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); }
.si-dot { width: 8px; height: 8px; margin-top: 6px; flex-shrink: 0; border-radius: 50%; background: var(--text-faint); }
.src-item.on .si-dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.si-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.si-name { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.si-covers { font-size: 12px; line-height: 1.45; color: var(--text-muted); }
.si-key { font-size: 11.5px; color: var(--text-faint); }
.si-key code { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.si-key a { color: var(--accent); }
.kbd-list { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13px; color: var(--text-2); }
.kbd-list dt { white-space: nowrap; }
.kbd-list dd { margin: 0; }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border: 1px solid var(--border-hair); border-bottom-width: 2px; border-radius: var(--r-xs); background: var(--card); font-family: var(--mono); font-size: 11px; text-align: center; color: var(--text); }

/* -------------------------------------------------------------- dictation */

.dict-bubble {
  position: fixed;
  z-index: 75;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100vw - 16px));
  padding: 9px 9px 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--glass-fill);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-lift), var(--glass-edge);
  animation: pop-in 0.2s var(--ease-out) both;
}
.db-dot { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; background: #d6455d; box-shadow: 0 0 0 0 rgba(214, 69, 93, 0.5); animation: rec 1.4s ease infinite; }
@keyframes rec { 0% { box-shadow: 0 0 0 0 rgba(214, 69, 93, 0.5); } 70% { box-shadow: 0 0 0 8px rgba(214, 69, 93, 0); } 100% { box-shadow: 0 0 0 0 rgba(214, 69, 93, 0); } }
.db-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.db-state { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--text); }
.db-engine { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--ok-text); }
.db-interim { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-hint { font-size: 11.5px; color: var(--text-faint); }
.db-stop { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border: 0; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text); }
.db-stop:hover { background: var(--bad-soft); color: var(--bad-text); }

/* ------------------------------------------------------------- voice mode */

/* Voice occupies the space column: the header (with its Chat / Voice
   switch) and the rail stay in place, as in the tutor. Docked, it shrinks
   to a card in that column's corner so a paper stays readable. */
.voice {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: calc(var(--rail-w) + var(--gap));
  z-index: 40;
  transition: left 0.34s var(--ease-liquid);
}
.vx-scrim { display: none; }
.voice.is-docked { pointer-events: none; }
body.voice-full .spaces { visibility: hidden; }
@media (max-width: 1180px) { .voice { left: calc(54px + var(--gap)); } }
@media (max-width: 900px) { .voice { left: calc(54px + 12px); } }
@media (max-width: 640px) { .voice { left: 0; } }

.vx {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--glass-fill);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow), var(--glass-inset);
  overflow: hidden;
  animation: vx-in 0.42s var(--ease-out) both;
  transition: inset 0.5s var(--ease-liquid), border-radius 0.5s var(--ease-liquid), width 0.5s var(--ease-liquid);
}
@keyframes vx-in { from { opacity: 0; transform: scale(0.985); } to { opacity: 1; transform: none; } }
.vx-top { display: flex; align-items: center; gap: 10px; padding: 14px 14px 6px 22px; }
.vx-expand { display: none; }
.vx-expand svg { transform: rotate(180deg); }
.voice.is-docked .vx-expand { display: inline-grid; }
.vx-live { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); }
.voice[data-status="listening"] .vx-live, .voice[data-status="speaking"] .vx-live { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.voice[data-status="thinking"] .vx-live, .voice[data-status="connecting"] .vx-live, .voice[data-status="reconnecting"] .vx-live { background: var(--warn); animation: breathe-o 1s ease-in-out infinite; }
.voice[data-status="error"] .vx-live { background: var(--bad); }
.vx-privacy { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 11.5px; color: var(--text-muted); }

.vx-main { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr); gap: 18px; padding: 6px 22px 10px; }
.vx-facecol { min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.vx-face { position: relative; width: min(54vh, 100%, 540px); aspect-ratio: 1; flex-shrink: 1; }
.holo-canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.vx-status { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 13px; font-weight: 700; color: var(--text-2); }
.vs-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.voice[data-status="listening"] .vs-dot { background: var(--ok); }
.voice[data-status="speaking"] .vs-dot { background: var(--accent-bright); animation: breathe-o 0.8s ease-in-out infinite; }
.voice[data-status="thinking"] .vs-dot, .voice[data-status="connecting"] .vs-dot { background: var(--warn); animation: breathe-o 1s ease-in-out infinite; }
.voice[data-status="error"] .vs-dot { background: var(--bad); }
.voice[data-status="error"] .vx-status { color: var(--bad-text); }
.vx-caps { width: min(620px, 100%); min-height: 64px; text-align: center; }
.vx-caps p { margin: 0; transition: opacity 0.3s ease; }
.cap-you { font-size: 13px; color: var(--text-faint); font-style: italic; opacity: 0; }
.cap-you.is-on { opacity: 1; }
.cap-thea { margin-top: 5px !important; font-size: 16px; line-height: 1.5; color: var(--text); font-weight: 550; opacity: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cap-thea.is-on { opacity: 1; }

.vx-stage { min-width: 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 8px 2px 8px 0; }
.vx-hint { margin: auto 0; padding: 22px; border: 1px dashed var(--border-hair); border-radius: var(--r-lg); color: var(--text-muted); }
.vh-title { font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.vx-hint ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.vx-hint li { font-family: var(--read-font); font-size: 15px; color: var(--text-2); }
.vh-note { display: flex; align-items: center; gap: 6px; margin: 16px 0 0; font-size: 12px; color: var(--text-faint); }
.vx-card { padding: 13px 15px; border: 1px solid var(--border-hair); border-radius: var(--r-lg); background: var(--card); animation: rise 0.35s var(--ease-out) both; }
[data-theme="light"] .vx-card { background: rgba(255, 255, 255, 0.9); }
.vx-card.error { border-color: var(--warn-line); }
.vc-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.vc-kind { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.vc-title { font-size: 14.5px; font-weight: 720; line-height: 1.38; }
.vc-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 5px; font-size: 12px; color: var(--text-muted); }
.vc-text { margin: 8px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--text-2); }
.vc-quote { margin: 9px 0 0; padding: 6px 0 6px 12px; border-left: 3px solid var(--accent-bright); background: var(--accent-soft); border-radius: 0 var(--r-sm) var(--r-sm) 0; font-family: var(--read-font); font-size: 14.5px; line-height: 1.6; color: var(--text); }
.vc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.vc-results { margin: 4px 0 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 10px; }
.vr-title { font-size: 13.5px; font-weight: 650; line-height: 1.4; }
.vr-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 3px 0 5px; font-size: 11.5px; color: var(--text-muted); }
.vc-verdict { display: flex; align-items: center; gap: 8px; margin: 7px 0 4px; font-size: 13px; font-weight: 650; }
.vx-card .signals { margin-top: 8px; }
.vc-prose { font-size: 14px; }
.vc-prose h1, .vc-prose h2, .vc-prose h3 { font-size: 14px; margin: 0.6em 0 0.3em; }

.vx-controls { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 22px 20px; }
.vx-btn {
  position: relative;
  height: 52px;
  min-width: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 700;
  transition: transform 0.18s var(--ease-spring), background 0.2s ease;
}
.vx-btn:hover { background: var(--card-hover); }
.vx-btn::before { content: ""; position: absolute; inset: -4px; border-radius: inherit; border: 2px solid var(--ok); opacity: calc(var(--level, 0) * 1.6); transform: scale(calc(1 + var(--level, 0) * 0.12)); transition: transform 0.08s linear, opacity 0.08s linear; pointer-events: none; }
.vx-btn.is-off { background: var(--bad-soft); color: var(--bad-text); border-color: var(--bad-line); }
.vx-btn.is-off::before { display: none; }
.vx-btn[aria-pressed="false"][data-vx="captions"] { color: var(--text-faint); }
.vx-btn.end { background: var(--danger-fill); color: #fff; border-color: transparent; }
.vx-btn.end:hover { background: var(--danger-fill-hover); }
.vx-btn:not(.end):not(.is-off)::before { border-color: var(--accent-bright); }
.vx-type { display: flex; align-items: center; gap: 4px; flex: 0 1 380px; height: 52px; padding: 0 6px 0 16px; border: 1px solid var(--border-hair); border-radius: var(--r-sm); background: var(--card); }
.vx-type input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: var(--text); font-size: 14px; }
.vx-type:focus-within { border-color: var(--accent-bright); box-shadow: 0 0 0 3px var(--accent-soft); }

/* docked: a small card in the corner while the app stays usable */
.voice.is-docked .vx {
  pointer-events: auto;
  inset: auto 0 0 auto;
  width: 330px;
  max-height: 100%;
  border-radius: var(--r-lg);
  /* it floats over a paper being read: nearly opaque, so text never shows through */
  background: var(--menu-fill);
  box-shadow: var(--shadow-lift), var(--glass-inset);
}
.voice.is-docked .vx-top { padding: 10px 8px 0 16px; }
.voice.is-docked .vx-privacy, .voice.is-docked .vx-type, .voice.is-docked .vx-hint, .voice.is-docked [data-vx="dock"] { display: none; }
.voice.is-docked .vx-main { display: flex; flex-direction: column-reverse; gap: 6px; padding: 0 12px; }
.voice.is-docked .vx-facecol { flex-direction: row; justify-content: flex-start; gap: 10px; }
.voice.is-docked .vx-face { width: 104px; cursor: pointer; flex-shrink: 0; }
.voice.is-docked .vx-card:not(:first-child) { display: none; }
.voice.is-docked .vc-results li:nth-child(n+4) { display: none; }
.voice.is-docked .vc-results .ghost-btn { display: none; }
.voice.is-docked .vx-status { padding: 4px 10px; font-size: 12px; }
.voice.is-docked .vx-caps { display: none; }
.voice.is-docked .vx-stage { max-height: 42vh; padding: 0; }
.voice.is-docked .vx-stage:empty { display: none; }
.voice.is-docked .vx-card { padding: 10px 12px; }
.voice.is-docked .vx-controls { padding: 8px 12px 12px; gap: 6px; justify-content: flex-end; }
.voice.is-docked .vx-btn { height: 40px; min-width: 40px; padding: 0 12px; font-size: 12.5px; }

/* ------------------------------------------------------------------ print */

.print-doc { max-width: 7in; margin: 0 auto; font-family: "Times New Roman", Times, serif; font-size: 12pt; line-height: 1.5; color: #000; }
.print-doc.double { line-height: 2; }
.print-doc .pd-title { text-align: center; font-size: 17pt; margin: 0 0 18pt; font-weight: 700; }
.print-doc h1 { font-size: 15pt; } .print-doc h2 { font-size: 13.5pt; } .print-doc h3 { font-size: 12.5pt; }
.print-doc h1, .print-doc h2, .print-doc h3 { margin: 16pt 0 6pt; page-break-after: avoid; }
.print-doc p { margin: 0 0 8pt; orphans: 3; widows: 3; }
.print-doc blockquote { margin: 0 0 8pt 0.5in; font-style: italic; }
.print-doc .cite { all: unset; }
.print-doc mark { background: none; color: inherit; font-weight: 700; }
.print-refs { padding-left: 2em; }
.print-refs.plain { list-style: none; padding-left: 0; }
.print-refs.plain li { padding-left: 0.5in; text-indent: -0.5in; }
.print-refs li { margin: 0 0 6pt; page-break-inside: avoid; }

@media print {
  .voice, .dict-bubble { display: none !important; }
  @page { margin: 1in; }
}

/* -------------------------------------------------------------- responsive */

/* With Thea's panel open on a mid-size screen, the drafts list steps aside */
@media (max-width: 1320px) {
  .wr.assist-on { grid-template-columns: minmax(0, 1fr) 330px; }
  .wr.assist-on .wr-list { display: none; }
}

@media (max-width: 1240px) {
  .lib, .nts { grid-template-columns: 300px minmax(0, 1fr); }
  .rd-side { width: 260px; }
  .as-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vx-main { grid-template-columns: minmax(0, 1fr) minmax(300px, 0.9fr); }
}

/* Mid-size screens keep Thea's panel as a column beside the draft, so the
   draft's own header (Preview, Export, More) is never under it */
@media (max-width: 1080px) {
  .wr.assist-on { grid-template-columns: minmax(0, 1fr) 312px; }
  .rd-ask span { display: none; }
  .exp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rc-checks { grid-template-columns: minmax(0, 1fr); }
  .vx-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .vx-face { width: min(34vh, 100%, 360px); }
  .vx-caps { min-height: 0; }
  .vx-stage:has(.vx-hint) { display: none; }
}

@media (max-width: 900px) {
  .lib, .nts, .wr, .wr.assist-on { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  /* small screens: Thea's panel is a drawer over a scrim; the page behind waits */
  .wr-assist {
    position: fixed;
    top: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 46;
    width: min(400px, calc(100vw - 24px));
    animation: drawer-in 0.4s var(--ease-liquid) both;
    box-shadow: var(--shadow-lift), var(--glass-inset);
  }
  @keyframes drawer-in { from { transform: translateX(calc(100% + 24px)); } }
  .wr.assist-on .wr-scrim { display: block; position: fixed; inset: 0; z-index: 45; background: var(--scrim); animation: fade-in 0.3s ease; }
  /* above the phone's bottom bar, so the drawer is the only thing to act on */
  .wr-assist { z-index: 62; }
  .wr.assist-on .wr-scrim { z-index: 61; }
  .lib .lib-detail, .nts .nt-main, .wr .wr-main { display: none; }
  .lib.has-selection .lib-list, .lib.reading .lib-list, .nts.has-selection .nt-list, .wr.has-draft .wr-list { display: none; }
  .lib.has-selection .lib-detail, .lib.reading .lib-detail, .nts.has-selection .nt-main, .wr.has-draft .wr-main { display: flex; }
  /* nothing to list yet: show the welcome, which has the actions */
  .lib.is-empty .lib-list, .nts.is-empty .nt-list, .wr.is-empty:not(.has-draft) .wr-list { display: none; }
  .lib.is-empty .lib-detail, .nts.is-empty .nt-main, .wr.is-empty .wr-main { display: flex; }
  .wr-list { display: flex; }
  .pd-back { display: inline-grid; }
  .lib-welcome { padding: 24px 16px; }
  .rd-bar { flex-wrap: wrap; row-gap: 6px; }
  .rd-title { flex: 1 1 calc(100% - 60px); }
  .rd-tools { flex: 1 1 100%; justify-content: space-between; }
  .rd-pages { padding: 14px 10px 30px; }
  .mnotes { right: 4px; }
  .rd-side { position: absolute; inset: auto 0 0 0; width: auto; max-height: 55%; border-left: 0; border-top: 1px solid var(--border-hair); background: var(--surface-solid); border-radius: var(--r-lg) var(--r-lg) 0 0; z-index: 20; box-shadow: var(--shadow-lift); }
  .rd-annpop { width: min(320px, calc(100% - 16px)); }
  .wd-head .wd-style, .wd-head [data-act="export"] span, .wd-head .wd-thea span { display: none; }
  .wd-page { padding: 24px 18px 36px; border-radius: var(--r-xs); }
  .nt-scroll { padding: 10px 14px 30px; }
  .ed-toolbar { margin: 2px 8px 0; }
  .src-items { grid-template-columns: minmax(0, 1fr); }
  .vx { inset: 8px; border-radius: var(--r-lg); }
  .vx-top { padding: 12px 10px 4px 16px; }
  .vx-privacy { display: none; }
  .vx-main { padding: 4px 14px 6px; }
  .vx-controls { padding: 8px 12px 14px; gap: 6px; flex-wrap: wrap; }
  .vx-type { order: -1; flex: 1 1 100%; height: 46px; }
  .vx-btn { height: 46px; min-width: 46px; }
  /* docked on a phone or tablet: one compact bar (face, status, controls)
     under whatever Thea is showing, so the paper above stays readable */
  .voice.is-docked .vx {
    left: 8px; right: 8px; bottom: 8px; width: auto;
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "stage stage stage" "face status controls";
    align-items: center; column-gap: 8px; row-gap: 8px; padding: 8px 10px 10px;
  }
  .voice.is-docked .vx-main, .voice.is-docked .vx-facecol { display: contents; }
  .voice.is-docked .vx-stage { grid-area: stage; max-height: 26vh; }
  .voice.is-docked .vx-face { grid-area: face; width: 60px; }
  .voice.is-docked .vx-status { grid-area: status; justify-self: start; max-width: 100%; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .voice.is-docked .vx-controls { grid-area: controls; padding: 0; flex-wrap: nowrap; }
  .voice.is-docked .vx-btn { height: 40px; min-width: 40px; }
  .voice.is-docked .vx-btn.end span { display: none; }
  .voice.is-docked .vx-top { display: none; }
}

@media (max-width: 560px) {
  .tb-select { max-width: 104px; }
  .ed-toolbar .tb-btn[data-ed="underline"], .ed-toolbar .tb-btn[data-ed="redo"] { display: none; }
  .hb-cards { columns: 1; }
  .as-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .exp-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tpl-grid { grid-template-columns: minmax(0, 1fr); }
  .rd-zoom { display: none; }
  .rd-view .seg-btn { padding: 0 8px; }
  .rcpt-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .vx, .vx-card, .as-card, .pd, .lib-welcome, .rd-side, .rd-seltool, .rd-annpop, .dict-bubble { animation: none; }
  .vx { transition: none; }
  .pdf-page:not(.is-rendered)::after { animation: none; }
  .db-dot { animation: none; }
}

/* ----------------------------------------------------------------- matrix */
/* One row per paper, one column per question. The paper column and the
   header stay put while the answers scroll under them. */

.mx {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: var(--gap);
}
.mx-list, .mx-main { position: relative; min-width: 0; min-height: 0; border-radius: var(--r-lg); display: flex; flex-direction: column; overflow: hidden; }
.mx-main > .lib-welcome { margin: auto; }
.mx-welcome { width: min(820px, 100%); }
.mx-hint { display: inline-flex; align-items: center; gap: 7px; margin: 18px 0 0; font-size: 12.5px; color: var(--text-muted); }
.mx-hint .link-btn { font-size: inherit; }

/* an open matrix gets the whole space; the list is one click back */
.mx.has-matrix { grid-template-columns: minmax(0, 1fr); }
.mx.has-matrix .mx-list { display: none; }
.mx .mx-back { display: inline-grid; }

.mx-mini { display: block; width: 76px; height: 4px; margin-top: 7px; border-radius: var(--r-xs); background: var(--surface-3); overflow: hidden; }
.mx-mini span { display: block; height: 100%; border-radius: inherit; background: var(--accent-bright); }

.mx-doc { position: relative; z-index: 2; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.mx-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 6px 12px; }
.mx-title {
  flex: 1 1 auto;
  min-width: 120px;
  max-width: 560px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 18px;
  font-weight: 760;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.mx-title:hover { border-color: var(--border-hair); }
.mx-title:focus { border-color: var(--accent-bright); background: var(--card); box-shadow: 0 0 0 3px var(--accent-soft); }
.mx-title::placeholder { color: var(--text-faint); }
.mx-acts { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.mx-fill { min-width: 82px; justify-content: center; }
.mx-fill.is-done { background: var(--ok-soft); color: var(--ok-text); }
.mx-fill.is-done:hover { background: var(--ok-soft); color: var(--ok-text); filter: brightness(0.97); }
.mx-ring {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: conic-gradient(currentColor calc(var(--p, 0) * 1%), transparent 0);
  box-shadow: inset 0 0 0 1.5px currentColor;
  transition: background 0.3s ease;
}

.mx-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 6px; padding: 0 20px 10px; font-size: 12px; color: var(--text-muted); }
.mx-sub .sep { opacity: 0.45; }
.mx-key { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 650; }
.mx-key.ok { background: var(--ok-soft); color: var(--ok-text); }
.mx-key.warn { background: var(--warn-soft); color: var(--warn-text); }
.mx-key.bad { background: var(--bad-soft); color: var(--bad-text); }

.mx-scroll {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 10px 10px;
  overflow: auto;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-lg);
  background: var(--card);
  overscroll-behavior: contain;
}
.mx-table { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: 13px; }
.mx-table th, .mx-table td { padding: 0; vertical-align: top; text-align: left; border-right: 1px solid var(--border-hair); border-bottom: 1px solid var(--border-hair); }
.mx-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-solid); }
.mx-corner, .mx-paper { position: sticky; left: 0; z-index: 1; width: 264px; min-width: 264px; max-width: 264px; background: var(--surface-solid); }
.mx-table thead .mx-corner { z-index: 3; }
.mx-table tr > :last-child { border-right: 0; }

.mx-table .mx-corner { padding: 13px 12px 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.mx-count { display: inline-grid; place-items: center; min-width: 20px; height: 18px; margin-left: 6px; padding: 0 5px; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-muted); font-family: var(--mono); font-size: 10.5px; letter-spacing: 0; }
.mx-table .mx-col { width: 252px; min-width: 232px; max-width: 320px; padding: 11px 12px 10px; }
.mx-colbtn { display: inline-flex; align-items: center; gap: 5px; max-width: calc(100% + 12px); margin: -3px -6px; padding: 3px 6px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text); font-size: 12.5px; font-weight: 760; }
.mx-colbtn:hover, .mx-colbtn[aria-expanded="true"] { background: var(--surface-3); }
.mx-colbtn svg { flex-shrink: 0; color: var(--text-faint); }
.mx-collabel { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mx-colq { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 5px; font-size: 11.5px; font-weight: 500; line-height: 1.4; color: var(--text-faint); }
.mx-addcol, .mx-tdpad { width: 52px; min-width: 52px; }
.mx-table .mx-addcol { padding: 9px 0 0; text-align: center; }

.mx-table .mx-paper { padding: 10px 6px 10px 12px; }
.mx-pwrap { display: grid; grid-template-columns: 24px minmax(0, 1fr) 28px; gap: 8px; align-items: start; }
.mx-verdict { width: 24px; height: 24px; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-muted); }
.mx-verdict svg { width: 13px; height: 13px; }
.mx-verdict.verified { background: var(--ok-soft); color: var(--ok-text); }
.mx-verdict.registered { background: var(--accent-soft); color: var(--accent); }
.mx-verdict.retracted, .mx-verdict.mismatch, .mx-verdict.not-found { background: var(--bad-soft); color: var(--bad-text); }
.mx-pmain { min-width: 0; }
.mx-ptitle {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.38;
  text-align: left;
  overflow-wrap: anywhere;
}
.mx-ptitle:not(:disabled):hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.mx-pmeta { display: block; margin-top: 4px; font-size: 11.5px; line-height: 1.4; color: var(--text-muted); }
.mx-pnote { display: block; margin-top: 2px; color: var(--warn-text); font-weight: 650; }
tr.is-gone .mx-ptitle { color: var(--text-faint); text-decoration: line-through; }
tr.is-gone .mx-pnote { color: var(--text-faint); }
@media (hover: hover) {
  .mx-rowmenu { opacity: 0; transition: opacity 0.15s ease; }
  tr:hover .mx-rowmenu, .mx-rowmenu:focus-visible, .mx-rowmenu[aria-expanded="true"] { opacity: 1; }
}

.mx-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  width: 100%;
  height: 100%;
  min-height: 76px;
  padding: 10px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  transition: background 0.15s ease;
}
.mx-cell:hover { background: var(--accent-soft); }
.mx-cell:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: -2px; }
.mx-ans { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.mx-nr { color: var(--text-faint); font-style: italic; }
.mx-foot { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.mx-src { display: inline-flex; align-items: center; gap: 3px; min-height: 19px; padding: 1px 6px; border-radius: var(--r-xs); background: var(--surface-3); color: var(--text-muted); font-size: 10.5px; font-weight: 700; line-height: 1.3; }
.mx-src svg { flex-shrink: 0; }
.mx-src.ok { background: var(--ok-soft); color: var(--ok-text); }
.mx-src.warn { background: var(--warn-soft); color: var(--warn-text); }
.mx-src.bad { background: var(--bad-soft); color: var(--bad-text); }
.mx-cell.is-unverified { box-shadow: inset 3px 0 0 var(--warn-line); }
.mx-cell.is-error { box-shadow: inset 3px 0 0 var(--bad-line); }
.mx-cell.is-empty { justify-content: center; align-items: flex-start; }
.mx-fillhint { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border: 1px dashed var(--border-hair); border-radius: var(--r-sm); color: var(--text-faint); font-size: 12px; font-weight: 650; }
@media (hover: hover) {
  .mx-cell.is-empty .mx-fillhint { opacity: 0; transition: opacity 0.15s ease; }
  .mx-cell.is-empty::before { content: '—'; color: var(--text-faint); opacity: 0.6; }
  .mx-cell.is-empty:hover::before, .mx-cell.is-empty:focus-visible::before { display: none; }
  .mx-cell.is-empty:hover .mx-fillhint, .mx-cell.is-empty:focus-visible .mx-fillhint { opacity: 1; color: var(--accent); border-color: var(--accent-line); }
  .mx-cell.is-empty .mx-fillhint { position: absolute; }
  .mx-cell.is-empty { position: relative; }
}
.mx-cell.is-busy, .mx-cell.is-queued { cursor: progress; gap: 8px; justify-content: flex-start; }
.mx-skel { display: block; height: 9px; border-radius: var(--r-xs); background: linear-gradient(90deg, var(--surface-3) 0%, var(--accent-soft) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: mx-shimmer 1.3s linear infinite; }
.mx-skel.short { width: 58%; }
.mx-cell.is-queued .mx-skel { animation: none; opacity: 0.55; }
@keyframes mx-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.mx-addrow th, .mx-addrow td { border-bottom: 0; }
.mx-table .mx-addrow .mx-paper { padding: 10px 12px; }
.mx-addbtn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px dashed var(--border-hair); border-radius: var(--r-sm); background: transparent; color: var(--text-muted); font-size: 12.5px; font-weight: 650; transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease; }
.mx-addbtn:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

/* a matrix still missing its questions or papers */
.mx-empty { display: flex; flex-direction: column; gap: 12px; max-width: 760px; padding: clamp(16px, 3vw, 28px); }
.mx-step { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 16px; border: 1px solid var(--border-hair); border-radius: var(--r-lg); background: var(--surface-solid); }
.mx-stepn { width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent); font-weight: 760; }
.mx-step strong { display: block; margin-top: 4px; font-size: 14px; color: var(--text); }
.mx-step p { margin: 4px 0 12px; font-size: 12.5px; line-height: 1.5; color: var(--text-muted); }
.mx-chips, .mx-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.mx-chips .chip-btn, .mx-presets .chip-btn { min-height: 32px; padding: 5px 12px; font-size: 12.5px; }
.mx-presets .chip-btn.is-on { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok-text); opacity: 1; }
.mx-or { display: flex; align-items: center; gap: 10px; margin: 16px 0 2px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
.mx-or::before, .mx-or::after { content: ''; flex: 1; height: 1px; background: var(--border-hair); }

/* choosing papers */
.mx-pick-tools { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12.5px; color: var(--text-muted); }
.mx-all { display: inline-flex; align-items: center; gap: 7px; font-weight: 650; color: var(--text-2); cursor: pointer; }
.mx-all input, .mx-prow input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent-bright); }
.mx-pick-count { font-family: var(--mono); font-size: 11.5px; }
.mx-pick { display: flex; flex-direction: column; gap: 2px; max-height: min(52vh, 460px); margin: 0 -8px; padding: 2px 8px; overflow-y: auto; }
.mx-prow { display: grid; grid-template-columns: 16px 24px minmax(0, 1fr); gap: 10px; align-items: start; padding: 9px 10px; border-radius: var(--r-md); cursor: pointer; transition: background 0.15s ease; }
.mx-prow:hover { background: var(--surface-3); }
.mx-prow input { margin-top: 4px; }
.mx-prmain { min-width: 0; }
.mx-prtitle { display: block; font-size: 13px; font-weight: 650; line-height: 1.38; color: var(--text); overflow-wrap: anywhere; }
.mx-prmeta { display: block; margin-top: 2px; font-size: 11.5px; color: var(--text-muted); }
.mx-prow.is-dim .mx-prtitle { color: var(--text-muted); }

/* one cell, in full */
.mx-status { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-3); color: var(--text-2); font-size: 12.5px; line-height: 1.5; }
.mx-status svg { flex-shrink: 0; margin-top: 1px; }
.mx-status.ok { background: var(--ok-soft); color: var(--ok-text); }
.mx-status.warn { background: var(--warn-soft); color: var(--warn-text); }
.mx-status.bad { background: var(--bad-soft); color: var(--bad-text); }
.mx-status.accent { background: var(--accent-soft); color: var(--accent); }
.mx-cell-sheet .field-label:first-of-type { margin-top: 16px; }
.mx-quote { margin: 14px 0 0; padding: 12px 14px; border-left: 3px solid var(--accent-bright); border-radius: 0 var(--r-md) var(--r-md) 0; background: var(--accent-soft); }
.mx-quote blockquote { margin: 0; font-family: var(--read-font); font-size: 15px; line-height: 1.6; color: var(--text); overflow-wrap: anywhere; }
.mx-quote figcaption { display: flex; align-items: center; gap: 5px; margin-top: 8px; font-size: 11.5px; font-weight: 600; color: var(--text-muted); }
.mx-qacts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mx-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: 12px 0 0; font-size: 11.5px; color: var(--text-faint); }
.mx-meta .link-btn { display: inline-flex; align-items: center; gap: 4px; font-size: inherit; }

@media (min-width: 1700px) {
  .mx.has-matrix { grid-template-columns: 268px minmax(0, 1fr); }
  .mx.has-matrix .mx-list { display: flex; }
  .mx .mx-back { display: none; }
}

@media (max-width: 1080px) {
  .mx-acts [data-act="export"] span { display: none; }
}

@media (max-width: 900px) {
  .mx { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .mx .mx-main { display: none; }
  .mx.has-matrix .mx-main, .mx.is-empty .mx-main { display: flex; }
  .mx.is-empty .mx-list { display: none; }
  .mx-head { flex-wrap: wrap; row-gap: 6px; }
  .mx-head > .grow { display: none; }
  .mx-title { flex: 1 1 calc(100% - 46px); max-width: none; font-size: 16px; }
  .mx-acts { flex: 1 1 100%; justify-content: flex-end; }
  .mx-corner, .mx-paper { width: 196px; min-width: 196px; max-width: 196px; }
  .mx-table .mx-col { width: 220px; min-width: 210px; }
}

@media (max-width: 560px) {
  .mx-acts .ghost-btn span { display: none; }
  .mx-acts .ghost-btn { width: 34px; padding: 0; justify-content: center; }
  .mx-corner, .mx-paper { width: 148px; min-width: 148px; max-width: 148px; }
  .mx-pwrap { grid-template-columns: minmax(0, 1fr) 28px; }
  .mx-paper .mx-verdict { display: none; }
  .mx-table .mx-col { width: 196px; min-width: 186px; }
  .mx-scroll { margin: 0 6px 6px; border-radius: var(--r-md); }
  .mx-sub { padding: 0 12px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .mx-skel { animation: none; }
}

/* --------------------------------------------------------- command palette */

dialog.palette {
  width: min(680px, calc(100vw - 24px));
  max-height: min(600px, calc(100dvh - 120px));
  margin: max(10vh, 56px) auto auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--text);
  background: var(--menu-fill);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-lift), var(--glass-edge);
  overflow: hidden;
}
dialog.palette[open] { display: flex; animation: pl-in 0.22s var(--ease-out); }
dialog.palette::backdrop { background: var(--scrim); animation: fade-in 0.2s ease; }
@keyframes pl-in { from { opacity: 0; transform: translateY(-8px) scale(0.985); } to { opacity: 1; transform: none; } }

.pl-box { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.pl-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--border-hair); }
.pl-ico { display: grid; color: var(--text-faint); }
#plInput { flex: 1; min-width: 0; height: 34px; padding: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; outline: none; }
#plInput::placeholder { color: var(--text-faint); }
.pl-esc, .pl-foot kbd, .pl-hint {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 6px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-xs);
  background: var(--surface-3);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.pl-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 8px 8px; overscroll-behavior: contain; }
.pl-group { padding: 10px 10px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.pl-item { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 11px; align-items: center; min-height: 46px; padding: 6px 10px; border-radius: var(--r-md); cursor: pointer; }
.pl-item[aria-selected="true"] { background: var(--accent-soft); }
.pl-iico { width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-muted); }
.pl-item[aria-selected="true"] .pl-iico:not(.verdict) { color: var(--accent); }
.pl-iico.verdict svg { width: 14px; height: 14px; }
.pl-iico.verdict.verified { background: var(--ok-soft); color: var(--ok-text); }
.pl-iico.verdict.registered { background: var(--accent-soft); color: var(--accent); }
.pl-iico.verdict.retracted, .pl-iico.verdict.mismatch, .pl-iico.verdict.not-found { background: var(--bad-soft); color: var(--bad-text); }
.pl-iico.swatch { box-shadow: inset 0 -4px 0 var(--hl-yellow); }
.pl-iico.sw-green { box-shadow: inset 0 -4px 0 var(--hl-green); }
.pl-iico.sw-blue { box-shadow: inset 0 -4px 0 var(--hl-blue); }
.pl-iico.sw-pink { box-shadow: inset 0 -4px 0 var(--hl-pink); }
.pl-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pl-title, .pl-sub { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pl-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.pl-sub { font-size: 12px; color: var(--text-muted); }
.pl-item mark { padding: 0; background: transparent; color: var(--accent); font-weight: 760; }
.pl-empty { padding: 30px 16px; text-align: center; font-size: 13px; color: var(--text-faint); }
.pl-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; padding: 9px 16px; border-top: 1px solid var(--border-hair); font-size: 11.5px; color: var(--text-faint); }
.pl-foot > span { display: inline-flex; align-items: center; gap: 4px; }
.pl-local { gap: 5px !important; }

@media (max-width: 560px) {
  dialog.palette { margin-top: 10px; max-height: calc(100dvh - 20px); border-radius: var(--r-lg); }
  .pl-foot > span:not(.pl-local):not(.grow) { display: none; }
  .pl-esc { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  dialog.palette[open], dialog.palette::backdrop { animation: none; }
}

/* ------------------------------------------------- importing references */

.imp-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 16px;
  border: 1.5px dashed var(--border-hair);
  border-radius: var(--r-lg);
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 12.5px;
  text-align: center;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.imp-drop > svg { color: var(--accent); margin-bottom: 2px; }
.imp-drop strong { font-size: 14px; color: var(--text); }
.imp-drop .primary-btn { margin-top: 2px; }
.imp-drop.is-over { border-color: var(--accent-bright); background: var(--accent-soft); }
.imp-how { margin: 12px 0 0; font-size: 12.5px; color: var(--text-2); }
.imp-how summary { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; color: var(--accent); cursor: pointer; list-style: none; }
.imp-how summary::-webkit-details-marker { display: none; }
.imp-how ul { margin: 8px 0 0; padding-left: 1.2em; line-height: 1.6; }
.imp-how li { margin: 3px 0; }

/* keyboard shortcuts */
.keys-group + .keys-group { margin-top: 16px; }
.keys-group h3 { margin: 0 0 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.keys-group dl { display: grid; grid-template-columns: minmax(120px, auto) minmax(0, 1fr); gap: 7px 16px; margin: 0; align-items: center; }
.keys-group dt { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.keys-group dd { margin: 0; font-size: 13px; color: var(--text-2); }
.keys-group kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 7px; border: 1px solid var(--border-hair); border-bottom-width: 2px; border-radius: var(--r-xs); background: var(--card); color: var(--text); font-family: var(--mono); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.keys-to { font-size: 11.5px; color: var(--text-faint); padding: 0 2px; }

/* on touch screens there are no keys to hint at */
@media (pointer: coarse) {
  .pl-hint, .pl-esc, .pl-foot > span:not(.pl-local):not(.grow) { display: none; }
}

/* ------------------------------------------------------- v4: sources by index */

.srcbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 12px 0 2px; }
.srcbar-label { margin-right: 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.src-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px;
  border: 1px solid var(--border-hair); border-radius: var(--r-sm); background: var(--card);
  color: var(--text-2); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.src-chip b { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--text-muted); }
.src-chip:hover { border-color: var(--accent-line); color: var(--accent); }
.src-chip.is-on { border-color: var(--accent-fill); background: var(--accent-fill); color: #fff; }
.src-chip.is-on b { color: rgba(255, 255, 255, 0.82); }
.src-chip.failed { cursor: default; border-style: dashed; color: var(--bad-text); }
.src-chip.failed b { color: var(--bad-text); font-family: inherit; font-weight: 500; }
article.source[hidden] { display: none; }

.bd-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.bd-item { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 2px; border-bottom: 1px solid var(--border-hair); }
.bd-item:last-child { border-bottom: 0; }
.bd-item .vdot { margin-top: 6px; }
.bd-title { font-size: 13.5px; font-weight: 600; line-height: 1.4; color: var(--text); }
.bd-title a { color: inherit; text-decoration: none; }
.bd-title a:hover { color: var(--accent); text-decoration: underline; }
.bd-meta { margin-top: 2px; font-size: 12px; color: var(--text-muted); }
.bd-via { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.bd-via .prov { padding: 1px 6px; border-radius: var(--r-xs); background: var(--surface-3); font-size: 10.5px; font-weight: 600; color: var(--text-muted); }
.bd-via .prov.on { background: var(--accent-soft); color: var(--accent); }
.badge.cited-in, .badge.cited { white-space: nowrap; }
.badge.cited { background: var(--warn-soft, rgba(184, 134, 11, 0.12)); color: var(--warn-text, #8a6d1f); }
.badge.cited-in { background: var(--ok-soft); color: var(--ok-text); }
.cites-n { font-variant-numeric: tabular-nums; }

/* follow-ups: what Thea understood */
.msg-user:has(.understood) { flex-wrap: wrap; }
.understood { display: flex; align-items: baseline; flex-wrap: wrap; flex-basis: 100%; gap: 2px 8px; max-width: 100%; margin: 6px 0 0; padding: 0 4px; font-size: 12px; color: var(--text-muted); text-align: right; justify-content: flex-end; }
.understood .u-text { max-width: min(560px, 80%); }
.understood .u-label { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.understood .u-text { color: var(--text-2); font-style: italic; }
.understood .u-fresh { font-size: 12px; }

/* project memory */
.mem-list { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 8px; }
.mem-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 7px 9px; border: 1px solid var(--border-hair); border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.mem-empty { margin: 0 0 6px; font-size: 12.5px; color: var(--text-muted); }
#pMemClear { align-self: flex-start; margin-top: 2px; font-size: 12px; }

/* choosing papers to add, with their PDFs */
.pick-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pk-count { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); }
.pick-list { list-style: none; margin: 0 -8px 12px; padding: 0 8px; max-height: min(50vh, 440px); overflow-y: auto; }
.pick-row { display: grid; grid-template-columns: 16px 10px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 9px 8px; border-radius: var(--r-sm); cursor: pointer; }
.pick-row:hover { background: var(--surface-3); }
.pick-row input { margin: 3px 0 0; width: 16px; height: 16px; accent-color: var(--accent-bright); }
.pick-row .vdot { margin-top: 7px; }
.pick-row.is-have { opacity: 0.6; cursor: default; }
.pk-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pk-title { font-size: 13.5px; font-weight: 600; line-height: 1.35; color: var(--text); }
.pk-meta { font-size: 12px; color: var(--text-muted); }
.badge.oa { background: var(--ok-soft); color: var(--ok-text); white-space: nowrap; }

/* ---------------------------------------------------------- v4: writing */

/* tables in the editor */
.rich table { width: 100%; margin: 0.4em 0 1.3em; border-collapse: collapse; font-family: var(--sans); font-size: 14px; line-height: 1.45; border-top: 1.5px solid var(--text); border-bottom: 1.5px solid var(--text); }
.rich caption { caption-side: top; padding: 0 0 7px; text-align: left; font-size: 13px; color: var(--text-2); counter-increment: tbl; }
.rich caption::before { content: "Table " counter(tbl) ". "; font-weight: 750; color: var(--text); }
.rich { counter-reset: tbl fig; }
.rich caption:empty::after, .rich caption:has(> br:only-child)::after { content: attr(data-placeholder); color: var(--text-faint); }
.rich th, .rich td { padding: 6px 10px; text-align: left; vertical-align: top; border: 0; min-width: 48px; }
.rich thead th { font-weight: 750; border-bottom: 1px solid var(--text-muted); }
.rich tbody tr + tr td { border-top: 1px solid var(--border-hair); }
.rich td:focus-within, .rich th:focus-within { background: var(--accent-soft); }

/* figures in the editor */
.rich figure.fig { margin: 0.6em auto 1.4em; width: 100%; text-align: center; counter-increment: fig; user-select: none; }
.rich figure.fig[data-width="50"] { width: 50%; } .rich figure.fig[data-width="75"] { width: 75%; } .rich figure.fig[data-width="90"] { width: 90%; }
.rich figure.fig img { display: block; width: 100%; height: auto; max-height: 62vh; object-fit: contain; margin: 0 auto; border-radius: var(--r-xs); background: #fff; cursor: pointer; outline: 2px solid transparent; outline-offset: 3px; transition: outline-color 0.15s ease; }
.rich figure.fig:hover img { outline-color: var(--accent-line); }
.rich figure.fig.is-selected img { outline-color: var(--accent-bright); }
.rich figure.fig.is-missing img { min-height: 120px; background: repeating-linear-gradient(45deg, var(--surface-3), var(--surface-3) 8px, transparent 8px, transparent 16px); }
.rich figcaption { margin-top: 8px; font-family: var(--sans); font-size: 13px; line-height: 1.45; color: var(--text-2); text-align: center; user-select: text; outline: none; cursor: text; }
.rich figcaption::before { content: "Figure " counter(fig) ". "; font-weight: 750; color: var(--text); }
.rich figcaption:empty::after { content: attr(data-placeholder); color: var(--text-faint); }

/* the tools over a table or figure */
.float-tools { position: absolute; z-index: 6; display: flex; align-items: center; gap: 2px; padding: 4px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-solid); box-shadow: 0 8px 24px rgba(0, 20, 50, 0.16); font-family: var(--sans); white-space: nowrap; }
.ft-btn { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 9px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font-size: 12px; font-weight: 650; }
.ft-btn:hover { background: var(--surface-3); color: var(--text); }
.ft-btn.is-on { background: var(--accent-soft); color: var(--accent); }
.ft-btn.danger:hover { background: var(--bad-soft); color: var(--bad-text); }
.ft-sep { width: 1px; height: 18px; margin: 0 3px; background: var(--border-hair); }
.ft-label { padding: 0 6px 0 8px; font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.tbl-dims { display: grid; grid-template-columns: auto 90px auto 90px; align-items: center; gap: 8px 10px; }
.tbl-dims .field-label { margin: 0; }

/* write | preview */
.wd-view .seg-btn { display: inline-flex; align-items: center; gap: 5px; }
.wr-doc.is-preview .ed-toolbar, .wr-doc.is-preview .wd-scroll, .wr-doc.is-preview .wd-thea, .wr-doc.is-preview .wd-foot { display: none; }
.wd-preview { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin-top: 10px; background: var(--reader-bg); }
.wd-preview[hidden] { display: none; }
.pv-bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--border-hair); font-size: 12.5px; color: var(--text-muted); }
.pv-info { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.pv-notes:not(:empty) { padding: 10px 14px 0; display: flex; flex-direction: column; gap: 6px; }
.pv-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 22px 20px 40px; }
.pv-pages { display: flex; flex-direction: column; align-items: center; gap: 18px; transition: opacity 0.2s ease; }
.wd-preview.is-busy .pv-pages { opacity: 0.55; }
.pv-page { display: block; background: #fff; border-radius: 2px; box-shadow: 0 1px 2px rgba(0, 20, 50, 0.12), 0 10px 30px rgba(0, 20, 50, 0.12); }

/* format panel */
.fmt .as-head { flex-wrap: wrap; }
.fmt-sub { margin-left: auto; font-size: 11.5px; color: var(--text-faint); }
.fmt-sec { padding: 4px 2px 14px; border-bottom: 1px solid var(--border-hair); display: flex; flex-direction: column; gap: 8px; }
.fmt-sec:last-child { border-bottom: 0; }
.fmt-sec h4 { margin: 4px 0 2px; font-size: 11px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.fmt-group { display: flex; flex-direction: column; gap: 6px; }
.fmt-group + .fmt-group { margin-top: 6px; }
.fmt-glabel { font-size: 11.5px; font-weight: 650; color: var(--text-muted); }
.fmt-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.fmt-pair > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fmt-tpls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fmt-tpl { display: flex; flex-direction: column; gap: 3px; padding: 9px 10px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); text-align: left; color: inherit; }
.fmt-tpl:hover { border-color: var(--accent-line); }
.fmt-tpl[aria-pressed="true"] { border-color: var(--accent-bright); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-bright); }
.fmt-tpl .ft-name { font-size: 12.5px; font-weight: 750; color: var(--text); }
.fmt-tpl .ft-sub { font-size: 11px; line-height: 1.35; color: var(--text-muted); }
.fmt-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fmt-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.fmt-seg { display: inline-flex; padding: 2px; border-radius: var(--r-sm); background: var(--surface-3); }
.fmt-seg button { height: 26px; padding: 0 9px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-muted); font-size: 11.5px; font-weight: 650; }
.fmt-seg button[aria-pressed="true"] { background: var(--surface-solid); color: var(--text); box-shadow: 0 1px 2px rgba(0, 20, 50, 0.12); }
.fa-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 5px; padding: 6px 0; border-bottom: 1px dashed var(--border-hair); }
.fa-row .fa-mail { grid-column: 1 / span 2; }
.fa-row .icon-btn { grid-row: 1; grid-column: 3; }
.fa-row .field { height: 32px; font-size: 12.5px; }
.fmt-hint { font-size: 11.5px; color: var(--text-faint); }
#fmtAi { font-size: 12.5px; line-height: 1.5; resize: vertical; }
.fmt-exports { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.fmt-exp .fe-sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
.fmt-exp { display: grid; grid-template-columns: 30px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 9px; align-items: center; padding: 8px 10px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); color: inherit; text-align: left; }
.fmt-exp:hover { border-color: var(--accent-line); background: var(--card-hover); }
.fmt-exp .fe-ico { grid-row: 1 / span 2; width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-2); }
.fmt-exp.is-primary .fe-ico { background: var(--accent-fill); color: #fff; }
.fe-name { font-size: 13px; font-weight: 700; } .fe-sub { font-size: 11.5px; color: var(--text-muted); }
.print-doc .pt { width: 100%; border-collapse: collapse; margin: 10pt 0; font-size: 10pt; border-top: 1px solid #000; border-bottom: 1px solid #000; }
.print-doc .pt th { border-bottom: 0.5px solid #000; text-align: left; } .print-doc .pt td, .print-doc .pt th { padding: 2pt 5pt; }
.print-doc .pf { margin: 10pt auto; text-align: center; break-inside: avoid; } .print-doc .pf img { max-width: 100%; max-height: 4.5in; }
.print-doc .pd-authors { text-align: center; margin: -10pt 0 14pt; } .print-doc .pd-abstract { margin: 0 0.5in 14pt; font-size: 10.5pt; }

/* Thea writes the paper */
.as-paper { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 1px solid var(--accent-line); border-radius: var(--r-md); background: linear-gradient(180deg, var(--accent-soft), transparent 140%); color: inherit; text-align: left; }
.as-paper:hover:not(:disabled) { border-color: var(--accent-bright); }
.as-paper:disabled { opacity: 0.55; }
.ap-ico { width: 36px; height: 36px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--accent-fill); color: #fff; }
.ap-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ap-title { font-size: 13.5px; font-weight: 750; color: var(--text); }
.ap-sub { font-size: 11.5px; line-height: 1.4; color: var(--text-muted); }
.pp-step { display: flex; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 650; }
.pp-bar { height: 5px; margin: 8px 0 6px; border-radius: var(--r-xs); background: var(--surface-3); overflow: hidden; }
.pp-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent-bright); transition: width 0.4s ease; }
.ac-fig { display: flex; align-items: center; gap: 8px; margin: 8px 0; padding: 10px 12px; border: 1px dashed var(--border); border-radius: var(--r-sm); font-size: 12.5px; color: var(--text-muted); }
.paper-sheet .pp-two, .fk-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pp-plan { list-style: none; margin: 4px 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: min(52vh, 520px); overflow-y: auto; }
.pp-sec { padding: 10px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); display: flex; flex-direction: column; gap: 6px; }
.pp-row { display: flex; align-items: center; gap: 6px; }
.pp-n { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: var(--r-xs); background: var(--surface-3); font-size: 11.5px; font-weight: 750; color: var(--text-2); }
.pp-head { font-weight: 700; height: 32px; }
.pp-goal { font-size: 12.5px; line-height: 1.45; resize: vertical; }
.pp-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: 11.5px; color: var(--text-muted); }
.pp-src { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.check.sm { font-size: 12px; gap: 5px; }

/* figure sheets */
.fig-sheet { width: min(980px, calc(100vw - 32px)); }
.fk-grid { display: grid; grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.3fr); gap: 16px; align-items: start; }
.fk-form { display: flex; flex-direction: column; gap: 6px; }
.field.mono { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; white-space: pre; overflow-x: auto; }
.fk-preview { min-height: 240px; display: grid; place-items: center; padding: 10px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: #fff; }
.fk-preview svg { width: 100%; height: auto; max-height: 52vh; }
.fk-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; color: #8a94a6; font-size: 12.5px; }
.fk-problems:not(:empty) { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.tf-out:not(:empty) { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.tf-prev { padding: 8px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: #fff; }
.tf-prev img { display: block; width: 100%; height: auto; max-height: 46vh; object-fit: contain; }
.tf-cap { margin: 0; font-size: 12.5px; color: var(--text-2); }
@media (max-width: 760px) { .fk-grid { grid-template-columns: 1fr; } }

/* originality */
.orig-sheet { width: min(760px, calc(100vw - 32px)); }
.orig-top { display: flex; gap: 16px; align-items: center; padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface-3); }
.orig-top.good { background: var(--ok-soft); } .orig-top.warn { background: var(--warn-soft); } .orig-top.bad { background: var(--bad-soft); }
.orig-num { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; color: var(--text); }
.orig-num span { font-size: 20px; font-weight: 700; margin-left: 1px; }
.orig-what { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-2); }
.orig-what strong { font-size: 14px; color: var(--text); }
.orig-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.orig-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: min(48vh, 480px); overflow-y: auto; }
.orig-item { padding: 10px 12px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); }
.oi-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.oi-src { font-size: 12px; color: var(--text-muted); }
.oi-text { margin: 8px 0 6px; padding: 2px 0 2px 12px; border-left: 3px solid var(--border); font-family: var(--read-font); font-size: 14px; line-height: 1.5; color: var(--text); }
.oi-why { font-size: 12px; color: var(--text-muted); }
.oi-act { display: flex; gap: 6px; margin-top: 8px; }
.orig-foot { display: flex; gap: 8px; margin-top: 12px; font-size: 12px; line-height: 1.5; color: var(--text-muted); }
.orig-flash { animation: origflash 2.6s ease; border-radius: var(--r-xs); }
/* web check (Winston AI) */
.orig-web { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--border-hair); border-radius: var(--r-sm); background: var(--card); display: flex; flex-direction: column; gap: 8px; }
.orig-web.off { flex-direction: row; align-items: flex-start; gap: 10px; border-style: dashed; background: transparent; font-size: 12.5px; line-height: 1.5; color: var(--text-muted); }
.orig-web.off svg { flex: none; margin-top: 2px; }
.orig-web.off strong { color: var(--text-2); }
.ow-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.ow-head svg { color: var(--accent); }
.orig-list.web { max-height: min(40vh, 400px); }
.oi-link { display: inline-flex; align-items: center; gap: 4px; min-width: 0; font-size: 12.5px; font-weight: 650; color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }
.oi-link:hover { text-decoration: underline; }
/* Settings, Sources: test the keyed connections */
.st-test { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; }
.st-tests { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.st-tests:empty { display: none; }
.st-tests:not(:empty) { margin-bottom: 12px; }
.st-test-row { display: grid; grid-template-columns: 16px auto minmax(0, 1fr); align-items: start; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.45; background: var(--surface-3); }
.st-test-row svg { margin-top: 1px; }
.st-test-row.ok { background: var(--ok-soft); } .st-test-row.ok svg { color: var(--ok); }
.st-test-row.bad { background: var(--bad-soft); } .st-test-row.bad svg { color: var(--bad); }
.st-test-row span { color: var(--text-2); overflow-wrap: anywhere; }
@keyframes origflash { 0%, 60% { background: var(--warn-soft); box-shadow: 0 0 0 4px var(--warn-soft); } 100% { background: transparent; box-shadow: none; } }
.fmt-orig { align-self: flex-start; }

/* guide */
.guide-sheet { width: min(860px, calc(100vw - 32px)); }
.gd-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.gd-progress { flex: 1; height: 6px; border-radius: var(--r-xs); background: var(--surface-3); overflow: hidden; }
.gd-progress span { display: block; height: 100%; border-radius: inherit; background: var(--accent-bright); }
.gd-count { font-size: 12px; font-weight: 650; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.gd-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: min(64vh, 640px); overflow-y: auto; }
.gd-step { border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--card); }
.gd-step.is-open { border-color: var(--accent-line); box-shadow: 0 6px 20px rgba(0, 20, 50, 0.06); }
.gd-head { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; padding: 11px 14px; border: 0; background: transparent; color: inherit; text-align: left; }
.gd-head > svg { color: var(--text-faint); transition: transform 0.2s ease; }
.gd-step.is-open .gd-head > svg { transform: rotate(180deg); }
.gd-dot { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--border); font-size: 12px; font-weight: 750; color: var(--text-muted); }
.gd-step.is-done .gd-dot { border-color: transparent; background: var(--ok-text); color: #fff; }
.gd-step.is-open:not(.is-done) .gd-dot { border-color: var(--accent-bright); color: var(--accent); }
.gd-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gd-title { font-size: 14px; font-weight: 720; color: var(--text); }
.gd-step.is-done .gd-title { color: var(--text-2); }
.gd-status { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gd-body { padding: 0 16px 14px 54px; }
.gd-why { margin: 0 0 8px; font-size: 13px; line-height: 1.55; color: var(--text-2); }
.gd-tips { margin: 0 0 12px; padding-left: 18px; font-size: 13px; line-height: 1.55; color: var(--text); }
.gd-tips li { margin: 3px 0; }
.gd-tips li::marker { color: var(--accent-bright); }
.gd-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.hero-guide { display: inline-flex; align-items: center; gap: 10px; margin-top: 10px; padding: 9px 14px; border: 1px dashed var(--accent-line); border-radius: var(--r-sm); background: transparent; color: var(--text-2); font-size: 13px; }
.hero-guide:hover { border-style: solid; color: var(--accent); background: var(--accent-soft); }
.hero-guide strong { color: var(--text); font-weight: 700; }
.rich.cite-sup .cite { vertical-align: super; font-size: 0.7em; line-height: 0; padding: 0 1px; }

/* v6: records set aside by a search or a report, with their reasons */
.aside-fold .note { margin: 0 0 8px; }
.aside-reasons { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.aside-reasons li { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border: 1px solid var(--border-hair); border-radius: var(--r-pill); font-size: 12px; color: var(--text-2); background: var(--surface-2); }
.aside-reasons b { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 700; }
.aside-items { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; border-top: 1px solid var(--border-hair); }
.aside-items li { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; padding: 7px 2px; border-bottom: 1px solid var(--border-hair); font-size: 12.5px; }
.aside-title { color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }
.aside-why { flex: none; color: var(--text-muted); font-size: 11.5px; text-align: right; }
