/* Signal Export Viewer: a quiet reading room for private chats. Cool slate paper, ink-blue accent, chat bubbles on
   screen (yours on the right, like the app), a plain transcript with names and times on every line on paper. */
:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #18202b;
  --muted: #4f5b6a;
  --line: #d5dce5;
  --line-strong: #8794a4;
  --accent: #2b5b88;
  --accent-ink: #ffffff;
  --accent-soft: #e2eaf3;
  --mine: #d9e6f4;
  --theirs: #ffffff;
  --event: #e4e9ef;
  --mark: #ffe9a8;
  --err: #a2301c;
  --warn-bg: #fdf3dc;
  --c0: #2b5b88; --c1: #9a4a1d; --c2: #3c6e2e; --c3: #8a3166; --c4: #6b4fa0; --c5: #7a5a10; --c6: #1d6f73; --c7: #a0352f;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-bubble: 16px;
  --r: 8px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151b; --surface: #171e26; --ink: #e5ebf2; --muted: #9eabba; --line: #2a3441; --line-strong: #657385;
    --accent: #8db8e3; --accent-ink: #0d1a27; --accent-soft: #1d2b3a; --mine: #233b54; --theirs: #1d252f; --event: #1e2630;
    --mark: #6a5714; --err: #ff9f8a; --warn-bg: #3a3220;
    --c0: #8db8e3; --c1: #f0a77a; --c2: #9fd28c; --c3: #ee9bd0; --c4: #bfa8f2; --c5: #e2c36f; --c6: #7fd3d6; --c7: #ff9f98;
  }
  :root .avatar { color: #10151b; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 var(--sans); }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 5; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 1.02rem; letter-spacing: -0.01em; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; }
.hero { padding: 26px 0 6px; max-width: 46rem; }
.hero h1 { font-size: clamp(1.75rem, 4.8vw, 2.6rem); font-weight: 700; margin: 0 0 10px; }
.lead { margin: 0; font-size: 1.08rem; color: var(--muted); max-width: 62ch; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 8px 18px; border: 1.5px solid var(--line-strong);
  border-radius: 999px; background: var(--surface); color: var(--ink); font: 600 1rem var(--sans); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { min-height: 44px; padding: 6px 14px; font-size: .95rem; }
.link-btn { background: none; border: 0; padding: 8px 0; min-height: 44px; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
input[type=file].vh:focus-visible + .btn, .btn:has(+ input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }

/* picker */
.tool { margin: 20px 0 44px; }
.drop { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px 22px; border-left: 5px solid var(--accent); }
.drop.over { background: var(--accent-soft); border-color: var(--accent); }
.drop-title { font-weight: 700; font-size: 1.2rem; margin: 0 0 14px; }
.pick-row { display: flex; flex-wrap: wrap; gap: 10px; }
.drop-hint { margin: 14px 0 0; color: var(--muted); font-size: .98rem; }
.trust { display: flex; align-items: center; gap: 8px; margin: 14px 2px 0; font-weight: 600; }
.trust svg { color: var(--accent); flex: none; }
.sample-line { margin: 8px 2px 0; color: var(--muted); }

.status { margin: 16px 0; padding: 14px 16px; border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 var(--r) var(--r) 0; }
.status p { margin: 0 0 6px; }
.status.error { border-color: var(--err); }
.status.error p:first-child { font-weight: 650; }
.status progress { width: 100%; height: 10px; accent-color: var(--accent); }
.small { font-size: .95rem; color: var(--muted); }

/* loaded */
.loaded-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 16px; }
.loaded-name { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.about { margin: 2px 0 14px; }
.about summary { cursor: pointer; color: var(--accent); min-height: 44px; display: flex; align-items: center; }
.about-body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; max-width: 44rem; }
.about-body ul { margin: 6px 0; padding-left: 1.2em; }
.about-body p { margin: 6px 0; }
.damage { margin: 4px 0 12px; padding: 10px 14px; background: var(--warn-bg); border-left: 4px solid var(--err); border-radius: 0 var(--r) var(--r) 0; max-width: 52rem; }
.resume { margin: 0 0 10px; padding: 8px 12px; background: var(--accent-soft); border-radius: var(--r); }

.layout { display: grid; grid-template-columns: 1fr; gap: 18px; }
.chat-items { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.chat-items li + li { border-top: 1px solid var(--line); }
.chat-item { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 0 12px; width: 100%; text-align: left; background: none; border: 0; padding: 11px 14px; cursor: pointer; color: var(--ink); font: inherit; align-items: center; }
.chat-item:hover { background: var(--accent-soft); }
.chat-item[aria-current=true] { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.avatar { grid-row: span 2; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 1rem; color: #fff; background: var(--c0); }
.ci-name { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-meta { display: block; color: var(--muted); font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-empty { padding: 10px 14px; color: var(--muted); font-size: .95rem; }

.chat-pane { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px 22px; }
.back { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; color: var(--accent); font: 600 1rem var(--sans); padding: 6px 0; min-height: 44px; cursor: pointer; }
.chat-title { margin: 2px 0 0; font-size: 1.45rem; overflow-wrap: anywhere; }
.chat-title:focus { outline: none; }
.chat-meta { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }
.chat-people { margin: 2px 0 0; color: var(--muted); font-size: .95rem; overflow-wrap: anywhere; }
.chat-people .link-btn { min-height: 0; padding: 0; }
.chat-head { padding-bottom: 10px; border-bottom: 1px solid var(--line); }

/* phone: list first, then the chat */
.layout.show-chat .chat-list { display: none; }
.layout:not(.show-chat) .chat-pane { display: none; }
@media (min-width: 880px) {
  .layout { grid-template-columns: 290px minmax(0, 1fr); gap: 24px; align-items: start; }
  .layout .chat-list, .layout .chat-pane { display: block !important; }
  .chat-list { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
  .back { display: none; }
}

.chat-tools { padding: 12px 0 2px; display: grid; gap: 8px; }
.search { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.search input[type=search] { flex: 1 1 220px; min-width: 0; min-height: 46px; font-size: 16px; padding: 8px 14px; border: 1.5px solid var(--line-strong); border-radius: 999px; background: var(--bg); color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.more-btn { justify-self: start; background: none; border: 0; padding: 6px 0; min-height: 44px; color: var(--accent); font: 600 1rem var(--sans); cursor: pointer; }
.more-btn::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-3px) rotate(45deg); }
.more-btn[aria-expanded=true]::after { transform: translateY(1px) rotate(-135deg); }
.more { display: grid; gap: 10px; padding: 4px 0 6px; }
.tool-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.mini { display: inline-flex; flex-direction: column; font-size: .92rem; color: var(--muted); gap: 2px; }
.mini select, .mini input { min-height: 44px; font-size: 16px; padding: 6px 8px; border: 1.5px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--ink); max-width: 15rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.print-panel { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 12px 14px; background: var(--accent-soft); border-radius: var(--r); }
.p-summary { flex-basis: 100%; margin: 0; font-weight: 600; }
.p-note { flex-basis: 100%; margin: 0; font-size: .95rem; }
.p-note:empty { display: none; }
@media (min-width: 880px) { .more-btn { display: none; } .more { display: grid !important; } }

/* transcript */
.transcript { margin-top: 6px; }
.day { text-align: center; font-size: .9rem; font-weight: 600; color: var(--muted); margin: 22px 0 10px; }
.day span { display: inline-block; padding: 3px 12px; background: var(--event); border-radius: 999px; }
.msg { display: flex; flex-direction: column; align-items: flex-start; margin: 3px 0; }
.msg.out { align-items: flex-end; }
.msg.cont { margin-top: 1px; }
.who { margin: 8px 12px 2px; font-weight: 650; font-size: .92rem; overflow-wrap: anywhere; }
.c0 { color: var(--c0); } .c1 { color: var(--c1); } .c2 { color: var(--c2); } .c3 { color: var(--c3); } .c4 { color: var(--c4); } .c5 { color: var(--c5); } .c6 { color: var(--c6); } .c7 { color: var(--c7); }
.bubble { max-width: min(88%, 36rem); background: var(--theirs); border: 1px solid var(--line); border-radius: var(--r-bubble); padding: 8px 12px 6px; overflow-wrap: anywhere; }
.msg.out .bubble { background: var(--mine); border-color: transparent; }
.bubble:has(img.photo) { max-width: min(88%, 326px); }
.msg.flash .bubble { background: var(--mark); }
.text { white-space: pre-wrap; margin: 0; }
.text .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
.spoiler { background: var(--ink); color: transparent; border-radius: 3px; cursor: pointer; }
.spoiler.shown { background: var(--accent-soft); color: inherit; cursor: auto; }
.mention { font-weight: 650; color: var(--accent); }
.meta { margin: 2px 0 0; font-size: .82rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.msg.out .meta { color: var(--muted); }
.edited-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; min-height: 24px; }
.prev { margin: 6px 0 2px; padding: 6px 10px; border-left: 3px solid var(--line-strong); font-size: .92rem; color: var(--muted); }
.prev p { margin: 2px 0; white-space: pre-wrap; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin: -4px 10px 2px; }
.react { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; font-size: .9rem; }
.quote { display: block; width: 100%; text-align: left; margin: 2px 0 6px; padding: 5px 9px; border: 0; border-left: 3px solid var(--accent); border-radius: 6px; background: var(--accent-soft); font: inherit; font-size: .93rem; color: var(--ink); cursor: pointer; }
.quote.missing { cursor: default; }
.q-who { display: block; font-weight: 650; color: var(--accent); }
.q-text { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-note { display: block; color: var(--muted); font-size: .85rem; font-style: italic; }
.event { text-align: center; margin: 12px 0; color: var(--muted); font-size: .93rem; }
.event span { display: inline-block; padding: 4px 12px; background: var(--event); border-radius: 12px; max-width: 92%; overflow-wrap: anywhere; }
.event .t { font-size: .82rem; margin-left: 6px; }
.event.unknown span { background: var(--warn-bg); color: var(--ink); }
.event .timer-note { display: block; background: none; padding: 2px 12px 0; font-size: .88rem; }
.note { margin: 0; font-style: italic; color: var(--muted); }
.story-tag { margin: 0 0 2px; font-size: .88rem; color: var(--muted); }
.tag { display: inline-block; font-size: .8rem; color: var(--muted); margin-left: 6px; }
.links { margin: 6px 0 2px; padding: 6px 10px; border-left: 3px solid var(--line-strong); font-size: .93rem; }
.links b { display: block; }
.links span { display: block; color: var(--muted); }

.media { margin: 4px 0; display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-start; }
.media img.photo { display: block; max-width: min(100%, 300px); max-height: 320px; width: auto; height: auto; border-radius: 10px; background: var(--event); }
.media img.sticker { width: 120px; height: 120px; object-fit: contain; }
.sticker-emoji { font-size: 2.6rem; margin: 0; line-height: 1.2; }
.chip { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin: 2px 0; padding: 5px 10px; border: 1px dashed var(--line-strong); border-radius: 8px; font-size: .93rem; overflow-wrap: anywhere; }
.chip.have { border-style: solid; }
.chip .why { color: var(--muted); }
.player-a { display: block; width: min(100%, 300px); }
.player-v { display: block; max-width: min(100%, 300px); max-height: 320px; border-radius: 10px; background: #000; }
.poll-q { font-weight: 650; margin: 0 0 4px; }
.poll-a { list-style: none; padding: 0; margin: 0; min-width: min(16rem, 70vw); }
.poll-a li { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 3px 8px; margin: 3px 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.pa-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); z-index: 0; }
.pa-text, .pa-n { position: relative; z-index: 1; }
.poll-meta { margin: 2px 0 0; font-size: .88rem; color: var(--muted); }
.card p { margin: 0; }
.card .card-name { font-weight: 650; }
.pager { margin: 12px 0; }
.range-note { color: var(--muted); font-size: .95rem; margin: 14px 0 6px; text-align: center; }
.empty { color: var(--muted); }

/* search results */
.results-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 16px; margin: 6px 0; }
.results-head p { margin: 0; font-weight: 650; }
.hits { list-style: none; margin: 0; padding: 0; }
.hit { display: block; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 10px 4px; cursor: pointer; font: inherit; color: var(--ink); }
.hit:hover { background: var(--accent-soft); }
.hit-top { display: block; font-size: .9rem; color: var(--muted); }
.hit-text { display: block; overflow-wrap: anywhere; }
mark { background: var(--mark); color: inherit; border-radius: 2px; }

/* content */
.explain, .faq { max-width: 46rem; margin: 0 0 34px; }
.explain h2, .faq h2 { font-size: 1.4rem; margin: 34px 0 10px; }
.steps { padding-left: 1.4em; }
.steps li { margin: 6px 0; }
.faq details { border-top: 1px solid var(--line); }
.faq details:last-of-type { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 12px 0; font-weight: 650; min-height: 44px; }
.faq details p { margin: 0 0 14px; }
.note-small { color: var(--muted); font-size: .95rem; margin-top: 16px; }

footer { border-top: 1px solid var(--line); padding: 22px 0 34px; color: var(--muted); font-size: .95rem; background: var(--surface); }
.sb-footer p { margin: 6px 0; }

@media (max-width: 520px) {
  .wrap { padding: 0 14px; }
  .chat-pane { padding: 10px 10px 16px; border-radius: 10px; margin: 0 -4px; }
  .bubble { max-width: 92%; }
  .drop { padding: 18px 14px; }
  .pick-row .btn { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: no-preference) { .msg.flash .bubble { transition: background 1.5s; } }

.print-root { display: none; }

/* ---------------- print ---------------- */
@page { size: auto; margin: 16mm 15mm 17mm; @bottom-right { content: "Page " counter(page) " of " counter(pages); font: 9pt system-ui, sans-serif; color: #444; } @top-left { font: 9pt system-ui, sans-serif; color: #444; } }
@media print {
  :root { --ink: #111; --muted: #444; --line: #bbb; --accent: #1f4a73; --surface: #fff; --bg: #fff;
    --c0: #1f4a73; --c1: #7d3a14; --c2: #2c5622; --c3: #6e2551; --c4: #533d82; --c5: #5e450b; --c6: #155558; --c7: #7f2722; }
  body { background: #fff; color: #111; font-size: 10.5pt; line-height: 1.4; }
  body.has-print > *:not(.print-root) { display: none !important; }
  body.has-print .print-root { display: block; }
  .topbar, footer, .skip, .tool, .faq details:not([open]) p { display: none; }
  .pr-head { border-bottom: 1.5pt solid #111; padding-bottom: 6pt; margin-bottom: 6pt; }
  .pr-title { font-size: 17pt; font-weight: 700; margin: 0 0 4pt; }
  .pr-meta { margin: 2pt 0; font-size: 10pt; }
  .pr-meta b { font-weight: 650; }
  .pr-missing { margin: 6pt 0 2pt; padding: 5pt 8pt; border: .75pt solid #888; font-size: 9.5pt; break-inside: avoid; }
  .pr-missing p { margin: 0 0 2pt; font-weight: 650; }
  .pr-missing ul { margin: 0; padding-left: 12pt; }
  .pr-day { font-size: 10.5pt; font-weight: 700; margin: 12pt 0 4pt; padding-bottom: 2pt; border-bottom: .75pt solid #999; break-after: avoid; page-break-after: avoid; }
  .pr-msg { display: grid; grid-template-columns: 17mm minmax(0, 1fr); gap: 0 3mm; padding: 2.5pt 0; break-inside: avoid; page-break-inside: avoid; }
  .pr-msg.long { break-inside: auto; page-break-inside: auto; }
  .pr-t { font-size: 8.5pt; color: #444; line-height: 1.75; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .pr-who { font-weight: 700; margin: 0; }
  .pr-who .tag { font-weight: 400; color: #444; font-size: 9pt; margin-left: 4pt; }
  .pr-body .text { white-space: pre-wrap; overflow-wrap: anywhere; }
  .pr-event { color: #333; font-style: italic; }
  .pr-event.unknown { font-style: normal; font-weight: 650; }
  .pr-event .timer-note { display: block; font-style: normal; font-size: 9pt; color: #333; }
  .quote { border: 0; border-left: 1.5pt solid #777; border-radius: 0; background: none; padding: 0 0 0 6pt; margin: 1pt 0 3pt; font-size: 9.5pt; }
  .q-who { color: #222; }
  .q-text { white-space: normal; color: #444; }
  .q-note { color: #444; }
  .media img.photo { max-width: 62mm; max-height: 52mm; border-radius: 0; border: .5pt solid #bbb; background: none; }
  .media img.sticker { width: 18mm; height: 18mm; }
  .chip { border: .75pt solid #777; border-radius: 0; font-size: 9.5pt; padding: 1pt 5pt; }
  .chip.gone { border-style: dashed; }
  .spoiler { background: none; color: inherit; border-bottom: 1pt dotted #555; }
  .mention { color: inherit; }
  .reacts-p, .edit-p, .pin-p { margin: 1pt 0 0; font-size: 9pt; color: #333; }
  .prev { border-left: 1pt solid #999; padding: 1pt 0 1pt 6pt; margin: 2pt 0; font-size: 9.5pt; color: #333; }
  .links { border-left: 1pt solid #999; padding: 1pt 0 1pt 6pt; font-size: 9.5pt; }
  .poll-a { max-width: 110mm; }
  .poll-a li { border: .5pt solid #999; }
  .pa-bar { background: #e2e2e2; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .pr-body .small { font-size: 9.5pt; color: #444; margin: 1pt 0; }
  .pr-end { margin-top: 10pt; padding-top: 4pt; border-top: .75pt solid #999; font-size: 9pt; color: #444; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* touch screens: zip first (app.js), hint about zipping instead of dropping */
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: inline; } .no-touch { display: none; } }

/* phone: slim bar with the chat name once the chat's heading and search have scrolled away (fixed: no layout jump) */
.mini-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; gap: 12px; min-height: 48px;
  padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.mini-bar .back { flex: none; }
.mini-title { font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 880px) { .mini-bar { display: none !important; } }

@media print {
  .mini-bar { display: none !important; }
  /* date above the time on every message, so any page can be tied to its day */
  .pr-msg { grid-template-columns: 19mm minmax(0, 1fr); }
  .pr-t { line-height: 1.3; padding-top: 1pt; }
  .pr-date, .pr-time { display: block; }
  /* "Large photos" print option (keepsakes); the default stays small */
  .print-root.large-photos .media img.photo { max-width: 120mm; max-height: 150mm; }
}
