/* Telegram Export Viewer: an archive reader. Paper-white transcript, slate ink, one teal accent,
   DM Mono for headings and timestamps (like a printed log), system sans for reading. */
@font-face { font-family: "DM Mono"; src: url("fonts/dm-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --bg: #f6f7f5;
  --paper: #ffffff;
  --ink: #17201f;
  --muted: #4e5b59;
  --line: #d9dfdd;
  --line-strong: #7f8c8a;
  --accent: #0b6b68;
  --accent-ink: #ffffff;
  --accent-soft: #e1efed;
  --mark: #ffe27a;
  --err: #a32a17;
  --c0: #0b6b68; --c1: #a2461c; --c2: #2456a6; --c3: #8a2e69; --c4: #586a10; --c5: #7a5220;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 6px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101615; --paper: #161e1d; --ink: #e6eeec; --muted: #a5b4b1; --line: #2b3735; --line-strong: #6f807d;
    --accent: #5cc6c0; --accent-ink: #082524; --accent-soft: #173533; --mark: #6b5a12; --err: #ff9b85;
    --c0: #5cc6c0; --c1: #f0a272; --c2: #8fb5ff; --c3: #eb94cf; --c4: #b9cf6a; --c5: #dcb07c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); }
.wrap { max-width: 1120px; 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(--paper); padding: 8px 12px; z-index: 5; }
.skip:focus { left: 8px; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

.topbar { border-bottom: 1px solid var(--line); background: var(--paper); }
.topbar-in { display: flex; align-items: center; min-height: 54px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 500 1rem var(--mono); }

h1, h2, h3 { font-family: var(--mono); font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; }
.hero { padding: 28px 0 8px; max-width: 760px; }
.hero h1 { font-size: clamp(1.7rem, 4.6vw, 2.5rem); 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; min-height: 44px; padding: 8px 16px; border: 1.5px solid var(--line-strong);
  border-radius: var(--r); background: var(--paper); 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: 40px; padding: 6px 12px; 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: 18px 0 40px; }
.drop { border: 2px dashed var(--line-strong); border-radius: 10px; padding: 26px 22px; background: var(--paper); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-title { font: 500 1.15rem var(--mono); 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; }
.sample-line { margin: 12px 2px 0; }

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

/* loaded app */
.loaded-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; }
.loaded-name { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 18px; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; min-height: 44px; font: 500 1rem var(--mono); color: var(--muted); cursor: pointer; }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); }

.chats-layout { display: grid; grid-template-columns: 1fr; gap: 18px; }
.chat-select { width: 100%; min-height: 44px; font-size: 16px; padding: 8px; border: 1.5px solid var(--line-strong); border-radius: var(--r); background: var(--paper); color: var(--ink); }
.chat-items { display: none; list-style: none; margin: 0; padding: 0; }
@media (min-width: 880px) {
  .chats-layout { grid-template-columns: 250px minmax(0, 1fr); gap: 28px; }
  .chat-select { display: none; }
  .chat-items { display: block; }
}
.chat-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-left: 3px solid transparent; padding: 9px 10px; cursor: pointer; color: var(--ink); font: inherit; }
.chat-item:hover { background: var(--accent-soft); }
.chat-item[aria-current=true] { border-left-color: var(--accent); background: var(--paper); }
.ci-name { display: block; font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.ci-meta { display: block; color: var(--muted); font-size: .9rem; }

.chat-pane { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 18px 18px 22px; }
.chat-head { border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.chat-title { margin: 0; font-size: 1.45rem; overflow-wrap: anywhere; }
.chat-meta { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }
.chat-tools { padding: 12px 0 4px; display: grid; gap: 10px; }
.search { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.search input[type=search] { flex: 1 1 220px; min-width: 0; min-height: 44px; font-size: 16px; padding: 8px 12px; border: 1.5px solid var(--line-strong); border-radius: var(--r); 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); }
.tool-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.mini { display: inline-flex; flex-direction: column; font-size: .9rem; color: var(--muted); gap: 2px; }
.mini select, .mini input { min-height: 40px; font-size: 16px; padding: 6px 8px; border: 1.5px solid var(--line-strong); border-radius: var(--r); background: var(--paper); color: var(--ink); max-width: 13rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.print-panel { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; padding: 12px; background: var(--accent-soft); border-radius: var(--r); }
.p-note { flex-basis: 100%; margin: 0; font-size: .95rem; }
.p-note:empty { display: none; }

/* transcript */
.transcript { margin-top: 8px; }
.day { font: 500 .98rem var(--mono); color: var(--muted); margin: 22px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); letter-spacing: 0; }
.msg, .svc { display: grid; grid-template-columns: 4.6rem minmax(0, 1fr); gap: 0 10px; padding: 5px 4px; border-radius: 4px; }
.msg.cont { padding-top: 0; }
.t { font: 500 .85rem/1.9 var(--mono); color: var(--muted); white-space: nowrap; }
.who { margin: 0; font-weight: 700; 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); }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.text code, .text pre { font-family: var(--mono); font-size: .9em; background: var(--bg); border-radius: 3px; padding: 0 3px; }
.text pre { padding: 8px; white-space: pre-wrap; margin: 4px 0; }
.text blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid var(--line-strong); }
.tag { color: var(--accent); }
.spoiler { background: var(--ink); color: transparent; border-radius: 3px; cursor: pointer; }
.spoiler.shown { background: var(--accent-soft); color: inherit; cursor: auto; }
.fwd { margin: 0; font-size: .92rem; color: var(--muted); font-style: italic; }
.quote { display: block; width: 100%; max-width: 34rem; text-align: left; margin: 2px 0 4px; padding: 3px 0 3px 10px; border: 0; border-left: 3px solid var(--accent); background: none; font: inherit; font-size: .93rem; color: var(--ink); cursor: pointer; }
button.quote:hover { background: var(--accent-soft); }
.quote.missing { color: var(--muted); font-style: italic; cursor: default; }
.q-who { display: block; font-weight: 600; color: var(--accent); }
.q-text { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tail { margin: 2px 0 0; font-size: .9rem; color: var(--muted); }
.svc { color: var(--muted); font-style: italic; }
.svc-text { overflow-wrap: anywhere; }
.flash { background: var(--mark); transition: background 2s; }
@media (prefers-reduced-motion: reduce) { .flash { transition: none; } }

.media { margin: 4px 0; }
.media .photo { display: block; max-width: min(100%, 340px); height: auto; max-height: 340px; width: auto; border-radius: 4px; border: 1px solid var(--line); }
.sticker { width: 128px; height: 128px; object-fit: contain; display: block; }
.sticker-emoji { font-size: 2.6rem; margin: 0; line-height: 1.2; }
.chip { display: inline-block; margin: 2px 0; padding: 4px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); font-size: .95rem; overflow-wrap: anywhere; }
.save { font-weight: 600; margin-left: 4px; }
.player-v { display: block; max-width: min(100%, 340px); max-height: 340px; width: auto; height: auto; border-radius: 4px; background: #000; margin-bottom: 4px; }
.player-v.round { border-radius: 50%; width: 220px; height: 220px; object-fit: cover; }
.player-a { display: block; width: min(100%, 340px); margin-bottom: 4px; }
.todo { margin: 0; padding-left: 1.3em; }
.poll-q { font-weight: 600; margin: 0 0 4px; }
.poll-a { list-style: none; padding: 0; margin: 0; max-width: 26rem; }
.poll-a li { position: relative; display: flex; justify-content: space-between; gap: 10px; padding: 3px 8px; margin: 3px 0; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.pa-text, .pa-n { position: relative; z-index: 1; }
.pa-n { font-family: var(--mono); }
.pa-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); z-index: 0; }
.poll-meta { margin: 2px 0 0; font-size: .9rem; color: var(--muted); }
.range-note { color: var(--muted); font-size: .95rem; margin: 14px 0 6px; }
.pager { margin: 10px 0; }
.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: 600; }
.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; }

/* contacts */
.contacts { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.contacts-count { margin: 0 0 12px; font-weight: 600; }
.dl-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
.ctable { border-collapse: collapse; width: 100%; font-size: .98rem; }
.ctable th, .ctable td { text-align: left; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.ctable th { font: 500 .9rem var(--mono); color: var(--muted); }
.ctable .ph { font-family: var(--mono); font-size: .92rem; white-space: nowrap; }
.ctable th { white-space: nowrap; }
.ctable td:nth-child(2) { min-width: 6.5em; overflow-wrap: break-word; }
@media (max-width: 400px) { .ctable { font-size: .92rem; } .ctable th { white-space: normal; } .ctable .ph { font-size: .82rem; } .ctable td:nth-child(2) { min-width: 4.5em; } }
.split-cell { color: var(--accent); }

/* content */
.explain, .faq { max-width: 720px; margin: 0 0 36px; }
.explain h2, .faq h2 { font-size: 1.35rem; 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: 600; min-height: 44px; }
.faq details p { margin: 0 0 14px; }

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

@media (max-width: 520px) {
  .wrap { padding: 0 14px; }
  .chat-pane, .contacts { padding: 14px 12px 18px; border-radius: 8px; }
  .msg, .svc { grid-template-columns: 4.1rem minmax(0, 1fr); gap: 0 6px; padding-left: 0; padding-right: 0; }
  .t { font-size: .8rem; }
  .actions { margin-left: 0; }
  .drop { padding: 20px 14px; }
}

.print-root { display: none; }

/* ---------------- print ---------------- */
@page { margin: 16mm 14mm 17mm; @bottom-right { content: counter(page) " of " counter(pages); font: 9pt system-ui, sans-serif; color: #555; } @top-left { font: 9pt system-ui, sans-serif; color: #555; } }
@media print {
  :root { --ink: #111; --muted: #555; --line: #ccc; --accent: #0b6b68; --paper: #fff; --bg: #fff;
    --c0: #0b5c59; --c1: #8f3b15; --c2: #1f4b91; --c3: #7a2659; --c4: #4b5a0c; --c5: #6a461a; }
  body { background: #fff; color: #111; font-size: 10.5pt; line-height: 1.4; }
  .topbar, .hero, footer, .explain, .faq, .picker, .status, .loaded-bar, .tabs, .chat-list, .chat-tools, .results, .pager, .range-note, .skip, #panel-contacts { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .tool { margin: 0; }
  .chat-pane { border: 0; padding: 0; }
  .chats-layout { display: block; }
  /* With a prepared print view, print only that. Without (Ctrl+P), print the messages on screen. */
  body.has-print main { display: none; }
  body.has-print .print-root { display: block; }
  .pr-head { border-bottom: 1.5pt solid #111; padding-bottom: 6pt; margin-bottom: 4pt; }
  .pr-title { font: 500 17pt/1.2 var(--mono); margin: 0; }
  .pr-meta { margin: 3pt 0 0; color: #444; font-size: 9.5pt; }
  .day { font-size: 10.5pt; color: #111; margin: 12pt 0 4pt; padding-bottom: 2pt; border-bottom: .75pt solid #999; break-after: avoid; page-break-after: avoid; }
  .msg, .svc { grid-template-columns: 17mm minmax(0, 1fr); gap: 0 3mm; padding: 2pt 0; break-inside: avoid; page-break-inside: avoid; }
  /* Keep a quick follow-up with the message above it, so a page never starts with a message that has no name. */
  .msg.cont { padding-top: 0; break-before: avoid; page-break-before: avoid; }
  .msg.long { break-inside: auto; page-break-inside: auto; }
  .t { font-size: 8.5pt; line-height: 1.75; color: #555; }
  .who { font-size: 10.5pt; }
  .quote { border-left: 1.5pt solid #888; padding: 0 0 0 6pt; font-size: 9.5pt; }
  .q-who { color: #333; }
  .q-text { white-space: normal; color: #555; }
  .media .photo { max-width: 70mm; max-height: 55mm; border: .5pt solid #bbb; }
  .sticker { width: 22mm; height: 22mm; }
  .sticker-emoji { font-size: 18pt; }
  .chip { background: none; border: .5pt solid #999; font-size: 9.5pt; padding: 1pt 5pt; }
  .poll-a li { border: .5pt solid #999; }
  .pa-bar { background: #e6e6e6; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .spoiler { background: none; color: inherit; border-bottom: 1pt dotted #777; }
  .text code, .text pre { background: none; border: .5pt solid #ccc; }
  .flash { background: none; }
  a { color: inherit; text-decoration: none; }
  .tail { font-size: 9pt; }
  .player-v, .player-a { display: none; }
}
