/* Layout: one calm conversation column, composer docked at the bottom (Claude-style), emblem gold + sea blue. */
:root {
  /* ===== BRAND COLORS - Kuwait Navy Force emblem ===== */
  --gold: #B8860B;          /* accent fills: send button, active mode */
  --gold-soft: #F3E3B5;     /* highlight behind matched words */
  --on-gold: #FFFFFF;       /* text/icons on gold */
  --sea: #2B6CB0;           /* links, citation chips */
  --sea-soft: #E3EDF8;

  /* neutrals (cool, slightly blue - the sea side of the emblem) */
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #EDF0F4;
  --ink: #141A22;
  --ink-2: #3A4452;
  --muted: #687384;
  --line: #DCE1E8;
  --danger: #B42318;
  --shadow: 0 1px 2px rgba(20, 26, 34, .06), 0 8px 24px rgba(20, 26, 34, .07);

  /* San Francisco (SF Arabic + SF Pro) on iPhone, iPad and Mac via the system font.
     Apple doesn't allow SF to be embedded, so other devices use their own system font:
     Noto Sans Arabic / Roboto on Android, Segoe UI on Windows. */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Arabic", "SF Pro Text", "SF Pro Display", system-ui,
             "Segoe UI", "Noto Sans Arabic", Roboto, Tahoma, sans-serif;
  --font-greet-ar: -apple-system, BlinkMacSystemFont, "SF Arabic", "SF Pro Display", system-ui, "Segoe UI", "Noto Sans Arabic", sans-serif;
  --font-greet-en: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Segoe UI", Roboto, sans-serif;

  --col: 46rem;
  --r: 1.25rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gold: #E2B240; --gold-soft: rgba(226, 178, 64, .22); --on-gold: #1A1404;
    --sea: #7CB2EE; --sea-soft: rgba(124, 178, 238, .14);
    --bg: #0C121A; --surface: #141C27; --surface-2: #1B2532;
    --ink: #E8ECF1; --ink-2: #C3CBD6; --muted: #8E99A8; --line: #253142;
    --danger: #F97066; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --gold: #E2B240; --gold-soft: rgba(226, 178, 64, .22); --on-gold: #1A1404;
  --sea: #7CB2EE; --sea-soft: rgba(124, 178, 238, .14);
  --bg: #0C121A; --surface: #141C27; --surface-2: #1B2532;
  --ink: #E8ECF1; --ink-2: #C3CBD6; --muted: #8E99A8; --line: #253142;
  --danger: #F97066; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.7 var(--font-ui);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- unlock ---------- */
.lock {
  min-height: 100%; display: grid; place-items: center;
  padding-block: 2rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.lock-card { width: min(100%, 22rem); display: flex; flex-direction: column; align-items: stretch; gap: .7rem; text-align: center; }
.lock-emblem { width: 7.5rem; height: auto; align-self: center; margin-bottom: .5rem; }
.lock-title { margin: 0; font: 700 1.9rem/1.3 var(--font-greet-ar); }
:root[lang="en"] .lock-title { font-family: var(--font-greet-en); letter-spacing: -.01em; }
.lock-org { margin: -.4rem 0 1.2rem; color: var(--muted); font-size: .95rem; }
.field-label { text-align: start; font-size: .85rem; color: var(--ink-2); font-weight: 500; }
.passcode {
  width: 100%; padding: .85rem 1rem; border-radius: .9rem;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 1.15rem; letter-spacing: .2em; text-align: center;
}
.passcode:focus { outline: none; border-color: var(--sea); box-shadow: 0 0 0 3px var(--sea-soft); }
.check { display: flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--ink-2); text-align: start; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--gold); }
.lock-error { margin: 0; color: var(--danger); font-size: .9rem; }
.btn-primary {
  border: 0; border-radius: .9rem; padding: .85rem 1rem; margin-top: .3rem;
  background: var(--gold); color: var(--on-gold); font-weight: 600; font-size: 1rem;
}
.btn-primary:disabled { opacity: .55; cursor: progress; }
.btn-secondary {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: .9rem; padding: .75rem 1rem; font-weight: 500;
}
.link-btn { border: 0; background: none; color: var(--sea); font-size: .9rem; padding: .4rem; }

/* ---------- main shell ---------- */
.main { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding-block: .6rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.brand { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.brand-mark { width: 2.4rem; height: auto; }
.brand-name { font-weight: 600; font-size: 1.02rem; }
.top-actions { display: flex; align-items: center; gap: .25rem; position: relative; }
.icon-btn {
  width: 2.5rem; height: 2.5rem; display: grid; place-items: center;
  border: 0; border-radius: .8rem; background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); }
.menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + .35rem); z-index: 20;
  min-width: 14rem; padding: .35rem; border-radius: 1rem;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.menu-item { text-align: start; border: 0; background: none; padding: .65rem .8rem; border-radius: .7rem; font-size: .95rem; }
.menu-item:hover { background: var(--surface-2); }
.menu-meta { margin: .3rem .8rem .4rem; font-size: .78rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: .55rem; }

.scroller { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.welcome, .thread, .dock > * {
  width: min(100%, var(--col)); margin-inline: auto;
}
.welcome {
  padding-block: 12vh 1rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  text-align: center;
}
.greeting {
  margin: 0 0 .5rem; font: 700 clamp(1.8rem, 6vw, 2.5rem)/1.3 var(--font-greet-ar);
  text-wrap: balance;
}
:root[lang="en"] .greeting { font-family: var(--font-greet-en); letter-spacing: -.02em; }
.greeting .spark { color: var(--gold); }
.welcome-sub { margin: 0; color: var(--muted); }
.welcome-meta { margin: .75rem 0 0; font-size: .78rem; color: var(--muted); opacity: .7; }
.main.chatting .welcome { display: none; }

.thread {
  display: flex; flex-direction: column; gap: 1.6rem;
  padding-block: 1rem 2rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.msg-user {
  align-self: flex-end; max-width: 85%;
  background: var(--surface-2); padding: .6rem 1rem; border-radius: 1.2rem;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-bot { display: flex; flex-direction: column; gap: .8rem; min-width: 0; }
.bot-head { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .85rem; }
.bot-head img { width: 1.6rem; height: auto; }
.answer { overflow-wrap: anywhere; }
.answer p { margin: 0 0 .7em; }
.answer p:last-child { margin-bottom: 0; }
.answer ul, .answer ol { margin: 0 0 .7em; padding-inline-start: 1.3em; }
.cite {
  display: inline-grid; place-items: center; min-width: 1.4em; height: 1.4em; padding: 0 .3em;
  margin-inline: .12em; vertical-align: .12em;
  border: 0; border-radius: .45em; background: var(--sea-soft); color: var(--sea);
  font-size: .72em; font-weight: 600; font-variant-numeric: tabular-nums;
}
.note { color: var(--muted); font-size: .92rem; margin: 0; }
.caret::after { content: "▍"; color: var(--gold); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* sources */
.sources { display: flex; flex-direction: column; gap: .6rem; }
.sources-label { font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.src {
  border: 1px solid var(--line); background: var(--surface); border-radius: 1rem;
  padding: .75rem .9rem; display: flex; flex-direction: column; gap: .35rem; text-align: start;
  transition: border-color .15s;
}
.src.flash { border-color: var(--sea); box-shadow: 0 0 0 3px var(--sea-soft); }
.src-top { display: flex; align-items: baseline; gap: .55rem; min-width: 0; }
.src-n {
  flex: none; display: grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: .45rem;
  background: var(--sea-soft); color: var(--sea); font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.src-title { font-weight: 600; font-size: .92rem; min-width: 0; overflow-wrap: anywhere; }
.src-loc { color: var(--muted); font-size: .8rem; white-space: nowrap; margin-inline-start: auto; }
.src-q { font-size: .9rem; color: var(--ink-2); font-weight: 500; }
.src-text { font-size: .93rem; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.src mark { background: var(--gold-soft); color: inherit; border-radius: .2em; padding: 0 .1em; }
.src-more { align-self: flex-start; border: 0; background: none; color: var(--sea); font-size: .82rem; padding: 0; font-weight: 500; }

/* ---------- composer dock ---------- */
.dock {
  padding-block: .4rem calc(.6rem + env(safe-area-inset-bottom, 0px));
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.composer {
  display: flex; flex-direction: column; gap: .35rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: .75rem .75rem .6rem; box-shadow: var(--shadow);
}
.composer:focus-within { border-color: color-mix(in srgb, var(--sea) 45%, var(--line)); }
#q {
  width: 100%; border: 0; outline: none; resize: none; background: transparent;
  font-size: 1rem; line-height: 1.55; max-height: 9.5rem; padding: .1rem .35rem;
}
#q::placeholder { color: var(--muted); }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.mode { display: flex; gap: .25rem; background: var(--surface-2); padding: .2rem; border-radius: .85rem; min-width: 0; }
.mode-opt {
  display: flex; align-items: center; gap: .35rem; border: 0; background: transparent;
  padding: .35rem .7rem; border-radius: .7rem; font-size: .86rem; color: var(--ink-2); white-space: nowrap;
}
.mode-opt svg { width: 16px; height: 16px; }
.mode-opt[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.mode-opt[data-mode="ai"][aria-checked="true"] svg { color: var(--gold); }
.send {
  flex: none; width: 2.35rem; height: 2.35rem; border-radius: .8rem; border: 0;
  display: grid; place-items: center; background: var(--gold); color: var(--on-gold);
}
.send:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
.send.stop svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; padding-top: .7rem; }
.main.chatting .suggestions { display: none; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: .4rem .85rem; font-size: .86rem; color: var(--ink-2); text-align: start;
}
.chip:hover { border-color: var(--gold); }
.disclaimer { margin: .45rem auto 0; text-align: center; font-size: .74rem; color: var(--muted); }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; display: grid; align-items: end; justify-items: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 12, 18, .45); }
.sheet-panel {
  position: relative; width: min(100%, 34rem); max-height: 85%; overflow-y: auto;
  background: var(--surface); border-radius: 1.4rem 1.4rem 0 0;
  padding-block: 1rem calc(1.4rem + env(safe-area-inset-bottom, 0px));
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
}
@media (min-width: 640px) { .sheet { align-items: center; } .sheet-panel { border-radius: 1.4rem; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.sheet-head h3 { margin: 0; font-size: 1.1rem; }
.sheet-body { display: flex; flex-direction: column; gap: .8rem; font-size: .95rem; color: var(--ink-2); }
.sheet-body p { margin: 0; }
.doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.doc-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.doc-list li:last-child { border-bottom: 0; }
.doc-list .count { color: var(--muted); font-size: .85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.progress { height: .45rem; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .3s; }
.progress-text { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.sheet-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.sheet-actions > * { flex: 1 1 10rem; }
.steps { margin: 0; padding-inline-start: 1.3em; display: flex; flex-direction: column; gap: .4rem; }
.sheet-actions .btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; margin-top: 0; }

/* ---------- answers: tables, badge, actions ---------- */
.answer h4 { margin: .2em 0 .4em; font-size: 1rem; }
.table-wrap { overflow-x: auto; margin: .2em 0 .9em; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.table-wrap th, .table-wrap td { padding: .55rem .75rem; text-align: start; vertical-align: top; border-bottom: 1px solid var(--line); }
.table-wrap th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td + td, .table-wrap th + th { border-inline-start: 1px solid var(--line); }
.badge { font-size: .72rem; font-weight: 600; color: var(--gold); border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); padding: .05rem .5rem; border-radius: 999px; }
.actions { display: flex; align-items: center; gap: .25rem; margin-top: -.2rem; }
.act {
  display: inline-flex; align-items: center; gap: .35rem; height: 2.1rem; min-width: 2.1rem; justify-content: center;
  border: 0; background: transparent; color: var(--muted); border-radius: .65rem; padding: 0 .45rem; font-size: .85rem;
}
.act svg { width: 18px; height: 18px; }
.act:hover { background: var(--surface-2); color: var(--ink); }
.act-share { color: var(--ink-2); border: 1px solid var(--line); padding: 0 .7rem; }

/* ---------- share sheet ---------- */
.fmt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; }
.fmt {
  display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center;
  border: 1px solid var(--line); background: var(--surface); border-radius: 1rem; padding: .85rem .4rem .75rem; min-width: 0;
}
.fmt:hover { border-color: var(--gold); }
.fmt-name { font-weight: 600; font-size: .92rem; color: var(--ink); }
.fmt-hint { font-size: .72rem; color: var(--muted); line-height: 1.35; }
.fmt-tile {
  flex: none; display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: .7rem;
  color: #fff; font: 700 .8rem/1 system-ui, sans-serif; letter-spacing: .02em;
}
/* file-type colors people recognize from their apps */
.fmt-pdf { background: #C5352B; } .fmt-docx { background: #2B5797; } .fmt-xlsx { background: #1E7145; }
.fmt-pptx { background: #C8501F; } .fmt-png { background: #6B4FA0; } .fmt-txt { background: #56606E; }
.file-card { display: flex; align-items: center; gap: .8rem; padding: .8rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--bg); }
.file-meta { display: flex; flex-direction: column; gap: .3rem; min-width: 0; flex: 1; }
.file-meta b { overflow-wrap: anywhere; color: var(--ink); font-size: .92rem; }
.file-meta span { color: var(--muted); font-size: .82rem; }
.file-meta .progress { display: block; }
.file-meta .progress > i { animation: grow 1.6s ease-in-out infinite alternate; }
@keyframes grow { from { width: 20%; } to { width: 85%; } }
@media (max-width: 360px) { .fmt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- export card (rendered off-screen into PDF / image; always light) ---------- */
.print-holder { position: fixed; top: 0; left: -10000px; pointer-events: none; }
.print-card {
  width: 794px; padding: 48px 56px 40px; background: #ffffff; color: #141A22;
  font: 400 15px/1.75 var(--font-ui);
}
.pc-head { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-bottom: 14px; margin-bottom: 4px; position: relative; }
.pc-head img { width: 38px; height: auto; }
.pc-head span { color: #5B6472; font-size: 12px; letter-spacing: .04em; }
.pc-head::after { content: ""; width: 72px; height: 1px; background: #C9A646; margin-top: 6px; }
.pc-q { font-size: 21px; line-height: 1.5; margin: 20px 0 12px; font-weight: 700; letter-spacing: -.005em; }
.pc-a p { margin: 0 0 10px; }
.pc-a ul, .pc-a ol { margin: 0 0 10px; padding-inline-start: 22px; }
.pc-a .table-wrap { border-color: #DCE1E8; background: #fff; overflow: visible; }
.pc-a .table-wrap th { background: #F3E3B5; color: #141A22; }
.pc-a .table-wrap th, .pc-a .table-wrap td { border-color: #DCE1E8; white-space: normal; }
.pc-cite { color: #2B6CB0; font-size: 11px; }
.pc-h { font-size: 12px; margin: 26px 0 10px; color: #8A94A3; font-weight: 600; letter-spacing: .06em; }
.pc-src { border-inline-start: 2px solid #C9A646; padding: 4px 14px; margin-bottom: 12px; font-size: 13px; }
.pc-src span { color: #687384; }
.pc-src p { margin: 4px 0 0; color: #3A4452; white-space: pre-wrap; }
.pc-src .pc-sh { font-weight: 600; }
.pc-foot { margin-top: 26px; padding-top: 10px; border-top: 1px solid #ECEFF3; color: #8A94A3; font-size: 11.5px; display: flex; justify-content: space-between; gap: 12px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* full reference line under each source title */
.src-type { flex: none; font-size: .7rem; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: .4rem; padding: 0 .4rem; line-height: 1.6; margin-inline-start: auto; }
.src-meta { display: flex; flex-wrap: wrap; gap: .15rem .5rem; font-size: .8rem; color: var(--muted); }
.src-meta span + span::before { content: "·"; margin-inline-end: .5rem; }

/* ---------- classification marking ---------- */
.marking {
  --mark: #2E7D4F;
  background: var(--mark); color: #fff; text-align: center;
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; line-height: 1.9;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.marking-bottom { padding-bottom: env(safe-area-inset-bottom, 0px); }
.main:has(.marking-bottom:not([hidden])) .dock { padding-bottom: .5rem; }
.cls-chip {
  --mark: #2E7D4F;
  font-size: .68rem; font-weight: 700; color: var(--mark); white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--mark) 55%, transparent); border-radius: .35rem; padding: 0 .4rem; line-height: 1.6;
}
.bot-head .cls-chip { margin-inline-start: auto; }

/* ---------- source footer ---------- */
.src-foot { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.src-orig {
  display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--line); background: var(--surface);
  color: var(--sea); border-radius: .6rem; padding: .25rem .6rem; font-size: .8rem; font-weight: 500; margin-inline-start: auto;
}
.src-orig svg { width: 16px; height: 16px; }

/* ---------- references list ---------- */
.doc-list li { align-items: flex-start; }
.doc-main { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.doc-main b { color: var(--ink); font-size: .93rem; }
.doc-main span { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.doc-main .sup-note { color: var(--danger); }
.doc-side { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; flex: none; }
.status { font-size: .72rem; font-weight: 600; }
.status.on { color: var(--muted); }
.status.off { color: var(--danger); }
.doc-list li.sup .doc-main b { text-decoration: line-through; color: var(--muted); }

/* ---------- original page viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: var(--bg); }
body.viewing { overflow: hidden; }
.v-head, .v-foot {
  display: flex; align-items: center; gap: .5rem; background: var(--surface); border-color: var(--line);
  padding-left: max(10px, env(safe-area-inset-left, 0px)); padding-right: max(10px, env(safe-area-inset-right, 0px));
}
.v-head { border-bottom: 1px solid var(--line); padding-block: calc(.4rem + env(safe-area-inset-top, 0px)) .4rem; }
.v-foot { border-top: 1px solid var(--line); justify-content: center; padding-block: .4rem calc(.4rem + env(safe-area-inset-bottom, 0px)); }
.v-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: center; line-height: 1.35; }
.v-titles b { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-titles span { font-size: .78rem; color: var(--muted); }
.v-stage { flex: 1; overflow: auto; display: flex; justify-content: center; align-items: flex-start; padding: 1rem; -webkit-overflow-scrolling: touch; }
.v-stage canvas { background: #fff; box-shadow: var(--shadow); border-radius: .3rem; flex: none; }
.v-msg { margin-top: 3rem; }
.v-page { min-width: 7.5rem; text-align: center; font-size: .85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.icon-btn:disabled { opacity: .35; cursor: default; }
[dir="rtl"] .v-dir svg { transform: scaleX(-1); }
.pc-mark { margin: -48px -56px 22px; padding: 5px; text-align: center; color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .08em; }
.pc-foot + .pc-mark { margin: 20px -56px -40px; }

/* ---------- highlight / underline / bold ---------- */
mark.u-hl, .src mark.u-hl { background: #FFE066; color: #141A22; border-radius: .15em; padding: 0 .08em; }
.u-ul { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .22em; text-decoration-color: var(--sea); }
.u-b { font-weight: 700; }
.fmt-bar {
  position: fixed; z-index: 70; display: flex; align-items: center; gap: .15rem; padding: .3rem;
  background: var(--ink); color: var(--bg); border-radius: .9rem; box-shadow: var(--shadow);
}
.fmt-bar button { width: 2.5rem; height: 2.5rem; display: grid; place-items: center; border: 0; background: transparent; color: inherit; border-radius: .65rem; }
.fmt-bar button:hover, .fmt-bar button:focus-visible { background: color-mix(in srgb, var(--bg) 16%, transparent); }
.fmt-bar .hl-line { stroke: #FFE066; stroke-width: 3; }
.fmt-sep { width: 1px; height: 1.4rem; background: color-mix(in srgb, var(--bg) 30%, transparent); margin-inline: .15rem; }
.pc-a mark.u-hl, .pc-src mark.u-hl { background: #FFE066; }
.pc-a .u-ul, .pc-src .u-ul { text-decoration-color: #2B6CB0; }
/* tables keep whole words and scroll sideways on narrow phones */
.table-wrap td, .table-wrap th { overflow-wrap: normal; word-break: normal; min-width: 6.5em; }

/* ---------- Google Authenticator code field ---------- */
.lock-hint { margin: -.2rem 0 0; font-size: .8rem; color: var(--muted); text-align: start; line-height: 1.5; }
.passcode.otp { text-align: center; font-size: 1.6rem; letter-spacing: .5em; padding-inline-start: .5em; font-variant-numeric: tabular-nums; }

/* ---------- recent searches ---------- */
.recent { margin: 2rem auto 0; max-width: 30rem; text-align: start; }
.recent-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-inline: .2rem; margin-bottom: .35rem; }
.recent-head span { font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.recent-head .link-btn { font-size: .78rem; padding: .2rem 0; }
.recent-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); overflow: hidden; }
.recent-list li { display: flex; align-items: center; min-width: 0; }
.recent-list li + li { border-top: 1px solid var(--line); }
.recent-q {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: .6rem; padding: .65rem .8rem;
  border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: .92rem; text-align: start; cursor: pointer;
}
.recent-q span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.recent-q svg { width: 17px; height: 17px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; }
.recent-q:hover { background: var(--surface-2); color: var(--ink); }
.recent-x { flex: none; width: 2.4rem; height: 2.4rem; border: 0; background: transparent; color: var(--muted); border-radius: .6rem; cursor: pointer; display: grid; place-items: center; }
.recent-x svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.recent-x:hover { color: var(--danger); }

/* ---------- copy / rating ---------- */
.act.done { color: var(--gold); }
.act-fb[aria-pressed="true"] { color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, transparent); }
.act-fb[aria-pressed="true"] svg { fill: color-mix(in srgb, var(--gold) 25%, transparent); }
.act-note { font-size: .78rem; color: var(--muted); min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.actions .act-share { margin-inline-start: auto; }
.fb-h { margin: .4rem 0 0; font-size: .9rem; color: var(--ink); }
.fb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.fb-list li { display: flex; flex-direction: column; gap: .15rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.fb-list li:last-child { border-bottom: 0; }
.fb-list b { font-weight: 500; color: var(--ink); overflow-wrap: anywhere; }
.fb-list span { font-size: .78rem; color: var(--muted); }

/* ---------- document browser ---------- */
.doc-list li.doc-item { display: block; padding: 0; }
.doc-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: .7rem 0; width: 100%; }
.doc-toggle { border: 0; background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer; border-radius: .6rem; }
.doc-toggle .chev { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-top: .15rem; transition: transform .2s; }
.doc-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.doc-toggle .doc-main { flex: 1; min-width: 0; }
.doc-list .toc { list-style: none; margin: 0 0 .7rem; padding: .3rem; display: flex; flex-direction: column; gap: 1px; background: var(--surface-2); border-radius: .9rem; }
.doc-list .toc li { display: block; padding: 0; border: 0; }
.toc-item {
  width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: .8rem;
  border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: .9rem; text-align: start;
  padding: .55rem .7rem; border-radius: .65rem; cursor: pointer;
}
.toc-item span { min-width: 0; overflow-wrap: anywhere; }
.toc-item small { color: var(--muted); white-space: nowrap; font-size: .76rem; }
.toc-item:hover { background: var(--surface); color: var(--ink); }
.toc-all { color: var(--sea); font-weight: 600; }

/* ---------- update available ---------- */
.update-bar {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%);
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); width: min(calc(100% - 32px), 30rem);
  display: flex; align-items: center; gap: .6rem; padding: .55rem .55rem .55rem .9rem;
  background: var(--ink); color: var(--bg); border-radius: 1rem; box-shadow: var(--shadow); font-size: .88rem;
}
.update-bar span { flex: 1; min-width: 0; }
.update-go { border: 0; background: var(--gold); color: var(--on-gold); font: inherit; font-weight: 600; padding: .45rem .8rem; border-radius: .7rem; cursor: pointer; white-space: nowrap; }
.update-bar .update-x { color: inherit; opacity: .7; width: 2rem; height: 2rem; }
.update-bar .update-x:hover { background: transparent; opacity: 1; }
