/* Self-hosted (not Google Fonts CDN, which is unreliable from some networks
   e.g. Russia — the whole reason this app exists talks to Yandex APIs
   directly rather than relying on external services where avoidable).
   Variable font with all 3 axes this family actually has: weight (300-900),
   width (75%-150%), optical size (12-36 — pair with font-optical-sizing:auto
   so the browser adjusts it to rendered text size automatically). Google's
   default CSS2 request only ships wght; these were re-fetched with opsz+wdth
   explicitly requested too. No slnt axis exists for this family at all. */
@font-face {
  font-family: "TikTok Sans";
  font-style: normal;
  font-weight: 300 900;
  font-stretch: 75% 150%;
  font-display: swap;
  src: url("/fonts/tiktoksans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "TikTok Sans";
  font-style: normal;
  font-weight: 300 900;
  font-stretch: 75% 150%;
  font-display: swap;
  src: url("/fonts/tiktoksans-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* Real drawn arrow glyphs (←↑→↓↗) confirmed present in TikTok Sans — the
   latin subset above only carries ↑/↓, so ←/↗ used in the UI (back/share
   icons) were silently falling back to the system font, looking visibly
   inconsistent. This tiny extra subset (fetched via Google's text= param)
   covers just the icons this app actually uses. No "black arrow" (⬇⬅) or
   copy-square (⧉) glyphs exist in this font at all — don't use those chars. */
@font-face {
  font-family: "TikTok Sans";
  font-style: normal;
  font-weight: 300 900;
  font-stretch: 75% 150%;
  font-display: swap;
  src: url("/fonts/tiktoksans-icons.woff2") format("woff2");
  unicode-range: U+2190-2193, U+2197;
}

:root {
  --bg: #0b0b0d;
  --surface: #131316;
  --surface-2: #191920;
  --border: #26262d;
  --text: #f4f1ea;
  --muted: #8b8b86;
  --muted-2: #5f5f5b;
  --gold: #eae1a9;
  --gold-strong: #d0c485;
  --gold-contrast: #1a1408;
  --danger: #e5794f;
  --success: #7bb98f;
  --radius: 16px;
  --radius-sm: 11px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Several elements below (.detail, .gate, .user, .active-rec) set their own
   `display` for when they're shown. Without this, that same-specificity
   author rule beats the browser's default `[hidden] { display: none }`,
   so a `hidden` element renders anyway. Force it, unconditionally. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "TikTok Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  /* Explicit 100% (not the `normal` keyword) so this inherited value matches
     the @font-face's `font-stretch: 75% 150%` range everywhere. Some engines
     (incl. Telegram's WebView) fail to match the default `normal` keyword
     against a percentage range and silently fall back to the system font —
     which is why elements WITHOUT an explicit font-stretch were showing the
     wrong font, while ones that set it (e.g. .seg-speaker) rendered fine. */
  font-stretch: 100%;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1100px 500px at 50% -12%, rgba(234, 225, 169, 0.07), transparent 70%),
    var(--bg);
  min-height: 100vh;
}

#app { max-width: 640px; margin: 0 auto; padding: 0 16px 40px; }

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 2px 20px;
}
.wordmark {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.wordmark .dot { color: var(--gold); }
.wordmark.big { font-size: 40px; margin-bottom: 18px; }

.user { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.user-name { font-size: 13px; color: var(--muted); font-weight: 600; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(140deg, var(--gold), var(--gold-strong));
  color: var(--gold-contrast);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
  background-size: cover; background-position: center;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.capture-head { display: flex; align-items: center; justify-content: space-between; }
.capture h2 { margin: 0; font-size: 17px; font-weight: 700; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 14px; }

.tag {
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--gold);
  background: rgba(234, 225, 169, 0.10);
  border: 1px solid rgba(234, 225, 169, 0.22);
  padding: 4px 9px; border-radius: 999px;
}

.capture-row { display: flex; gap: 9px; }
.input {
  flex: 1; min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--gold-strong); }
.input::placeholder { color: var(--muted-2); }

.btn {
  border: none; cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: inherit; font-weight: 700; font-size: 14px;
  padding: 12px 18px;
  transition: transform 0.08s, opacity 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold-strong)); color: var(--gold-contrast); }
.btn-stop { background: transparent; color: var(--danger); border: 1px solid rgba(229, 121, 79, 0.4); }

.error-line { color: var(--danger); font-size: 13px; margin-top: 10px; }

.capture-alt { margin-top: 11px; }
.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-family: inherit; font-size: 13px;
  padding: 2px 0; transition: color 0.15s;
}
.link-btn:hover { color: var(--gold-strong); }
.link-btn:disabled { opacity: 0.6; cursor: default; }

/* ── Active recording ── */
.active-row { display: flex; align-items: center; justify-content: space-between; }
.active-left { display: flex; align-items: center; gap: 12px; }
.active-title { font-weight: 700; font-size: 15px; }
.active-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.pulse {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(229, 121, 79, 0.6);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(229, 121, 79, 0.55); }
  70% { box-shadow: 0 0 0 12px rgba(229, 121, 79, 0); }
  100% { box-shadow: 0 0 0 0 rgba(229, 121, 79, 0); }
}

.meeting-link {
  display: inline-block; color: var(--gold); font-size: 12.5px; font-weight: 700;
  text-decoration: none; margin-top: 10px;
}
.meeting-link:hover { text-decoration: underline; }

/* ── List ── */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 2px 12px;
}
.section-head h3 { margin: 0; font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--muted); border-radius: 10px;
  width: 34px; height: 34px; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { transform: scale(0.94); }

.pill-btn {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--muted); border-radius: 10px; height: 34px; padding: 0 12px;
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.pill-btn:active { transform: scale(0.96); }

.download-wrap { position: relative; }
.download-menu {
  position: absolute; top: 40px; right: 0; z-index: 10;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px; display: flex; flex-direction: column;
  min-width: 110px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.download-menu button {
  background: none; border: none; color: var(--text); text-align: left;
  font-family: inherit; font-size: 13px; padding: 8px 10px; border-radius: 7px;
  cursor: pointer;
}
.download-menu button:active { background: rgba(234,225,169,0.12); }

.list { display: flex; flex-direction: column; gap: 10px; }
.rec {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.rec:active { background: var(--surface-2); }
.rec-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rec-title { font-weight: 700; font-size: 15px; }
.rec-bottom { display: flex; align-items: center; gap: 10px; margin-top: 7px; }
.rec-meta { color: var(--muted); font-size: 12.5px; }
.src { font-size: 11px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 3px 8px; border-radius: 999px; margin-left: auto; }

.badge { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.badge.recording { color: var(--danger); background: rgba(229,121,79,0.12); }
.badge.transcribing { color: var(--gold); background: rgba(234,225,169,0.12); }
.badge.done { color: var(--success); background: rgba(123,185,143,0.12); }
.badge.error { color: #ff8a8a; background: rgba(255,138,138,0.12); }

/* ── Empty / loading ── */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty-glyph { font-size: 34px; color: var(--muted-2); margin-bottom: 10px; }
.empty p { font-size: 13.5px; line-height: 1.6; }
.spinner {
  width: 26px; height: 26px; margin: 0 auto;
  border: 2.5px solid var(--border); border-top-color: var(--gold);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Gate ── */
.gate {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 30px; background: var(--bg);
}
.gate p { color: var(--muted); max-width: 300px; }
.gate-widget { margin-top: 18px; }

/* ── Detail ── */
.detail {
  position: fixed; inset: 0; background: var(--bg);
  z-index: 20; display: flex; flex-direction: column;
  max-width: 640px; margin: 0 auto;
}
.detail-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.detail-title { flex: 1; font-weight: 700; font-size: 15px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-meta { padding: 12px 18px; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--border); }
/* Docked as a footer bar: it's the LAST child of .detail's flex column (after
   .detail-body, which is the flex:1 scrolling area) — that alone keeps it
   pinned at the bottom of the fixed-fullscreen .detail panel without ever
   scrolling away, no position:fixed/z-index juggling needed. */
.player {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.player-wave { position: relative; height: 36px; margin-bottom: 8px; }
.player-wave-bars { position: absolute; inset: 0; display: flex; align-items: center; gap: 2px; }
.player-wave-bars .bar { flex: 1; min-width: 1px; border-radius: 1px; min-height: 3px; opacity: 0.45; transition: opacity 0.15s ease; }
.player-wave-bars .bar.is-past { opacity: 1; }
.player-wave-playhead {
  position: absolute; top: 0; bottom: 0; width: 2px; left: 0;
  background: var(--gold); pointer-events: none;
  box-shadow: 0 0 4px rgba(234, 225, 169, 0.6);
}
/* Invisible — the waveform bars are the visual, this is purely the
   interaction surface (native click-to-jump + drag-to-scrub + keyboard). */
.player-seek {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  -webkit-appearance: none; appearance: none; background: transparent; opacity: 0; cursor: pointer;
}
.player-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 2px; height: 100%; }
.player-seek::-moz-range-thumb { width: 2px; height: 100%; border: none; background: transparent; }
.player-seek::-moz-range-track { height: 100%; background: transparent; }
.player-row { display: flex; align-items: center; gap: 10px; }
.player-play {
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--gold), var(--gold-strong));
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.player-play:active { transform: scale(0.94); }
/* Drawn in CSS, not a ▶/⏸ glyph — those two characters aren't in our
   self-hosted font's icon subset, so they fell back to the OS symbol font,
   whose baseline/metrics don't match TikTok Sans and sat visibly off-center. */
.player-play-icon {
  width: 0; height: 0; margin-left: 2px;
  border-style: solid; border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent var(--gold-contrast);
}
.player-play.is-playing .player-play-icon {
  width: 3px; height: 12px; margin-left: 0;
  border-style: none; background: var(--gold-contrast);
  box-shadow: 5px 0 0 var(--gold-contrast);
}
.player-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; font-stretch: 100%; flex-shrink: 0; }
.player-time-sep { color: var(--muted-2); font-size: 12px; }
.player-spacer { flex: 1; }
.player-rate {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); border-radius: 8px;
  font-family: inherit; font-size: 12px; font-weight: 700; padding: 5px 8px; cursor: pointer; flex-shrink: 0;
}
.player-rate:active { transform: scale(0.94); }
#shareBtn.shared { color: var(--gold); border-color: var(--gold); }
.detail-body {
  flex: 1; overflow-y: auto; padding: 16px 18px 40px;
  white-space: pre-wrap; word-wrap: break-word;
  font-size: 14.5px; line-height: 1.6;
}
.detail-body .status-note { color: var(--muted); text-align: center; padding: 40px 10px; }
.detail-body .spk { color: var(--gold); font-weight: 700; }

.participants-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 8px;
}
.participants { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.participant {
  border: none; padding: 3px 11px 3px 3px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.participant:active { transform: scale(0.96); }
.pt-avatar {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; background-size: cover; background-position: center;
}
.pt-avatar.has-photo { box-shadow: 0 0 0 1.5px currentColor; }

.drive-link {
  display: inline-block; margin-bottom: 14px;
  color: var(--gold); font-size: 13px; font-weight: 700;
  text-decoration: none;
}
.drive-link:hover { text-decoration: underline; }

.summary-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px;
}
.summary-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--gold); margin-bottom: 6px;
}
.summary-text { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; line-height: 1.55; }

.structure-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px;
}
.structure-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--gold); margin-bottom: 6px;
}
.structure-hint { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }

.chapter-list { display: flex; flex-direction: column; gap: 2px; }
.chapter-row {
  display: flex; align-items: baseline; gap: 10px; padding: 6px 4px; border-radius: 8px;
  cursor: pointer; font-size: 13.5px; background: none; border: none; text-align: left;
  color: var(--text); font-family: inherit; width: 100%;
}
.chapter-row:active { background: var(--surface-2); }
.chapter-time {
  color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0;
  min-width: 42px; font-size: 12px;
}

.marker-list { display: flex; flex-direction: column; gap: 6px; }
.marker-row {
  display: flex; align-items: flex-start; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px;
  cursor: pointer; text-align: left; font-family: inherit; width: 100%;
}
.marker-row:active { border-color: var(--gold-strong); }
.marker-icon { width: 11px; height: 11px; flex-shrink: 0; margin-top: 4px; box-sizing: border-box; }
.marker-icon.type-decision { background: var(--gold); border-radius: 3px; transform: rotate(45deg); }
.marker-icon.type-agreement { background: var(--success); border-radius: 50%; }
.marker-icon.type-task { background: #8fb8e0; border-radius: 3px; }
.marker-icon.type-question { background: #d9a8c9; border-radius: 50% 50% 50% 0; }
.marker-time {
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
  flex-shrink: 0; min-width: 38px; padding-top: 1px;
}
.marker-body { flex: 1; font-size: 12.5px; color: var(--text); }
.marker-meta { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.marker-meta .agree { color: var(--success); }

.seg { transition: background 0.25s ease; border-radius: var(--radius-sm); margin: 0 -10px 16px; padding: 8px 10px; }
/* column-reverse: DOM order stays [speaker, time] (unchanged, so desktop's
   position:absolute pull-out further down still works the same way), but
   visually the time renders above the speaker chip instead of beside it. */
.seg-head { display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 2px; margin-bottom: 3px; }
.seg-speaker {
  background: none; border: none; padding: 2px 4px; margin: -2px -4px;
  color: var(--gold); font-weight: 500; font-size: 0.75rem; font-stretch: 115%;
  text-transform: uppercase; letter-spacing: 0.1em;
  font-family: inherit; cursor: pointer; border-radius: 6px;
}
.seg-speaker:hover { background: rgba(234, 225, 169, 0.10); }
.seg-time { color: var(--muted-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.seg-text { margin: 0; white-space: pre-wrap; word-wrap: break-word; }

/* The timestamp hangs in the left margin outside the text block instead of
   living in its own grid column — the speaker+text block keeps its normal
   width/position entirely unchanged; only the time is pulled out of flow
   via absolute positioning. .detail-body gets extra left padding so there's
   room for it to sit in without being clipped or forcing a scrollbar.
   Applies at every viewport width now, not just desktop. */
.detail-body { padding-left: 90px; }
.seg { position: relative; }
.seg-time {
  position: absolute;
  top: 8px;
  right: 100%;
  margin-right: 6px;
  width: 60px;
  text-align: right;
  font-stretch: 75%;
}
.seg.is-active { background: rgba(234, 225, 169, 0.08); }
.seg.is-active .seg-time { color: var(--gold); }
.seg.is-active .seg-text { color: var(--text); }
.seg-text p { margin: 0 0 8px; }
.seg-text p:last-child { margin-bottom: 0; }
.seg-chapter {
  display: flex; align-items: baseline; gap: 10px; cursor: pointer;
  margin: 22px 0 12px; padding-top: 14px; border-top: 1px solid var(--border);
}
.seg-chapter-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.seg-chapter-title { font-size: 15px; font-weight: 700; color: var(--gold); }
.seg-badges { display: inline-flex; flex-wrap: wrap; gap: 5px; margin-left: 8px; }
.seg-badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em; color: var(--mk);
  background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 999px; padding: 2px 7px;
}
.seg-badge-glyph { width: 7px; height: 7px; background: var(--mk); }
.seg-badge-glyph.shape-diamond { border-radius: 1px; transform: rotate(45deg); }
.seg-badge-glyph.shape-square { border-radius: 1px; }
.seg-badge-glyph.shape-circle { border-radius: 50%; }
.seg-speaker-input {
  background: var(--surface-2); border: 1px solid var(--gold-strong);
  color: var(--gold); font-weight: 700; font-size: 14.5px;
  font-family: inherit; border-radius: 6px; padding: 1px 5px;
  width: 12ch; outline: none;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); padding: 11px 18px; border-radius: 12px;
  font-size: 13px; z-index: 40; box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
