/* Phone-first. Inside Telegram the Mini App's theme variables win, so the UI
   matches the user's Telegram theme; in a browser the fallbacks apply. */
:root {
  --bg: var(--tg-theme-bg-color, #f6f6f4);
  --card: var(--tg-theme-section-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1b1b1b);
  --muted: var(--tg-theme-hint-color, #7a7a7a);
  --accent: var(--tg-theme-button-color, #e11d48);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #c2183e);
  --line: rgba(127, 127, 127, 0.22);
  --err: #d23b3b;
  --ok: #15803d;
  --warn: #b45309;
  --plan: #1d4ed8;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-bg-color, #121212);
    --card: var(--tg-theme-section-bg-color, #1d1d1f);
    --text: var(--tg-theme-text-color, #ececec);
    --muted: var(--tg-theme-hint-color, #9a9a9a);
    --link: var(--tg-theme-link-color, #fb7190);
    --err: #f87171;
    --ok: #4ade80;
    --warn: #fbbf24;
    --plan: #93b4fd;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--link); text-decoration: none; }
h1 { font-size: 1.35rem; margin: 0.2rem 0 0.4rem; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 0.6rem; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; }
main { max-width: 720px; margin: 0 auto; padding: 12px 16px 48px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top-actions { display: flex; gap: 14px; align-items: center; }
.brand { font-weight: 700; color: var(--text); }
/* Inside Telegram the session comes from Telegram itself; signing out is moot. */
.in-telegram .logout { display: none; }

/* Bottom tab bar: six sections that never fit across a phone's header. */
:root {
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --tabbar-h: calc(58px + var(--safe-bottom));
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(6, 1fr);
  height: var(--tabbar-h); padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 0; color: var(--muted);
  font-size: 0.68rem; line-height: 1.1; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a i { font-style: normal; font-size: 1.3rem; line-height: 1; filter: grayscale(1); opacity: 0.75; }
.tabbar a.on { color: var(--link); font-weight: 600; }
.tabbar a.on i { filter: none; opacity: 1; }
body:has(.tabbar) main { padding-bottom: calc(var(--tabbar-h) + 24px); }
@media (min-width: 760px) {
  /* A desktop window has room: keep the bar but don't stretch it edge to edge. */
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: 720px; border: 1px solid var(--line); border-bottom: 0; border-radius: 14px 14px 0 0; }
}

.btn {
  display: inline-block;
  border: 0; border-radius: 10px;
  padding: 11px 16px;
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 600;
  cursor: pointer;
}
.btn.small { padding: 6px 12px; font-size: 0.9rem; }
.btn.big { display: block; width: 100%; padding: 15px 16px; font-size: 1.05rem; text-align: center; }
.record-cta p { margin: 10px 0 0; }
.card .next-step { margin-top: 6px; font-size: 0.85rem; color: var(--link); font-weight: 600; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.link { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; }
form.inline { display: inline; }

.flash {
  background: var(--card); border-left: 4px solid var(--ok);
  padding: 10px 12px; border-radius: 8px; margin-bottom: 12px;
}
.muted { color: var(--muted); }
.err { color: var(--err); white-space: pre-wrap; word-break: break-word; }
pre.err { font: 0.85rem/1.4 ui-monospace, Consolas, monospace; max-height: 14em; overflow: auto; margin: 0.6rem 0; }
.pre { white-space: pre-wrap; }

.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chip {
  flex: none; padding: 6px 12px; border-radius: 999px;
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  font-size: 0.9rem;
}
.chip span { color: var(--muted); margin-left: 2px; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.chip.on span { color: inherit; opacity: 0.8; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card {
  display: block; padding: 12px 14px;
  background: var(--card); color: var(--text);
  border-radius: var(--radius); border: 1px solid var(--line);
}
.card .row { display: flex; justify-content: space-between; gap: 8px; font-size: 0.82rem; margin-bottom: 4px; }
.card .topic { font-weight: 600; }
.card .muted, .card .err { font-size: 0.9rem; margin-top: 2px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 0.78rem; font-weight: 600;
  background: var(--line); color: var(--text);
}
.s-RECORDED, .s-PROCESSING, .s-PUBLISHING { background: rgba(180, 83, 9, 0.16); color: var(--warn); }
.s-READY { background: rgba(225, 29, 72, 0.14); color: var(--link); }
.s-UPLOADED { background: rgba(21, 128, 61, 0.15); color: var(--ok); }
.s-SCHEDULED { background: rgba(37, 99, 235, 0.14); color: var(--plan); }
.s-ERROR { background: rgba(210, 59, 59, 0.15); color: var(--err); }

.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin: 12px 0;
}
details.panel > summary { cursor: pointer; font-weight: 600; list-style: none; }
details.panel > summary::before { content: "▸ "; color: var(--muted); }
details.panel[open] > summary { margin-bottom: 10px; }
details.panel[open] > summary::before { content: "▾ "; }

label { display: block; margin: 0 0 12px; font-size: 0.92rem; }
input:not([type=checkbox]):not([type=range]):not([type=radio]):not([type=file]), textarea, select {
  display: block; width: 100%; margin-top: 4px;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; font-size: 16px; /* 16px stops iOS zooming into the field */
}
textarea { resize: vertical; }
label.check { display: flex; gap: 8px; align-items: center; }
input[type=file] { margin: 10px 0; }
progress { display: block; width: 100%; height: 8px; margin: 8px 0; accent-color: var(--accent); }

.head { margin: 4px 0 10px; }
.head .back { font-size: 0.9rem; }
.head .badge { margin-right: 6px; }

.stages { margin: 0 0 8px; padding-left: 0; list-style: none; }
.stages li { padding: 4px 0 4px 26px; position: relative; color: var(--muted); }
.stages li::before { position: absolute; left: 0; width: 20px; text-align: center; content: "○"; }
.stages .st-done { color: var(--text); }
.stages .st-done::before { content: "✓"; color: var(--ok); }
.stages .st-current { color: var(--text); font-weight: 600; }
.stages .st-current::before { content: "◌"; color: var(--warn); animation: spin 1.2s linear infinite; }
.stages .st-failed { color: var(--err); font-weight: 600; }
.stages .st-failed::before { content: "✕"; }
@keyframes spin { to { transform: rotate(360deg); } }

.player { display: block; width: 100%; max-height: 70vh; aspect-ratio: 9 / 16; background: #000; border-radius: 10px; margin-bottom: 10px; }
.pubtext { display: grid; gap: 2px 0; margin: 6px 0 12px; font-size: 0.92rem; }
.pubtext .muted { margin-top: 6px; font-size: 0.8rem; }
.cover-box { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 12px; }
.cover-thumb { width: 110px; flex: none; border-radius: 8px; background: #000; }
.cover-box p { margin: 4px 0 8px; }
.redo { display: flex; gap: 8px; align-items: center; }
.redo select { margin: 0; }

.assets { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.assets li { display: flex; align-items: center; gap: 10px; }
.thumb { flex: none; width: 48px; height: 48px; border-radius: 8px; background: var(--line) center / cover no-repeat; }
.assets code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.danger { text-align: center; margin-top: 24px; }
.danger .link { color: var(--err); }
.foot { text-align: center; font-size: 0.9rem; }

.login { max-width: 360px; margin: 12vh auto 0; }

/* teleprompter */
body.prompter { background: #000; color: #fff; }
body.prompter main { max-width: none; padding: 0; }
.pr-bar {
  position: fixed; inset: 0 0 auto 0; z-index: 2;
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  padding: 8px 14px; background: rgba(0, 0, 0, 0.75); font-size: 0.85rem;
}
.pr-bar a, .pr-bar button { color: #fff; background: none; border: 1px solid #555; border-radius: 8px; padding: 4px 10px; font: inherit; }
.pr-bar label { display: flex; gap: 6px; align-items: center; margin: 0; color: #aaa; }
.pr-text { padding: 45vh 6vw 70vh; font-size: 40px; line-height: 1.5; font-weight: 600; }
.pr-text.mirror { transform: scaleX(-1); }
.pr-hook { color: #fbbf24; }
.pr-end { color: #666; text-align: center; }

/* insert picker */
.hint { font-size: 0.88rem; margin: 0 0 4px; }
.small { font-size: 0.82rem; }
.warn { color: var(--warn); margin: 6px 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ins { scroll-margin-top: 64px; }
.ins-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.ins-n {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.8rem; font-weight: 700;
  background: var(--line);
}
.ins-phrase { font-weight: 600; }
.ins-chosen { position: relative; border-radius: 10px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.ins-chosen img, .ins-chosen video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ins-chosen .play {
  position: absolute; inset: auto 10px 10px auto; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0, 0, 0, 0.6); color: #fff; pointer-events: none;
}
.ins-chosen .small { position: absolute; left: 10px; bottom: 10px; color: #fff; text-shadow: 0 1px 2px #000; }
.frames { display: flex; gap: 4px; overflow-x: auto; margin: 8px 0 4px; scrollbar-width: thin; }
.frame { flex: none; position: relative; padding: 0; border: 0; background: none; cursor: pointer; }
.frame img { width: 64px; height: 36px; object-fit: cover; border-radius: 4px; display: block; }
.frame span { position: absolute; left: 3px; bottom: 1px; font-size: 0.65rem; color: #fff; text-shadow: 0 1px 2px #000; }
.startpick label { margin: 6px 0 0; }
.startpick input[type=range] { width: 100%; accent-color: var(--accent); }
.cands { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: thin; }
.cand {
  flex: none; position: relative; width: 112px; height: 63px; padding: 0;
  border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--line); cursor: pointer;
}
.cand img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cand.on { border-color: var(--accent); }
.cand .dur { position: absolute; right: 3px; bottom: 2px; font-size: 0.65rem; color: #fff; text-shadow: 0 1px 2px #000; }
.cand .used {
  position: absolute; left: 0; right: 0; top: 0; padding: 1px 4px;
  font-size: 0.6rem; line-height: 1.3; color: #fff; background: rgba(180, 83, 9, 0.85);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ins-more { margin-top: 8px; }
.ins-more summary { cursor: pointer; color: var(--link); font-size: 0.9rem; }
.ins-more .row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.ins-more .row input { margin: 0; }
.bottombar {
  position: sticky; bottom: var(--tabbar-h); z-index: 4;
  display: flex; justify-content: center; padding: 12px 0;
  background: linear-gradient(transparent, var(--bg) 35%);
}
.bottombar .btn { min-width: 220px; }
.stages .st-wait { color: var(--text); font-weight: 600; }
.stages .st-wait::before { content: "◆"; color: var(--link); }

/* new idea / drafts */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; }
.tab:has(input:checked) { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.tab input { display: none; }
.gen:has(input[value=niche]:checked) [data-mode=news] { display: none; }
.row2 { display: grid; grid-template-columns: 1fr 104px; gap: 10px; }
.draft-topic { font-weight: 600; margin: 0 0 10px !important; }
.hooks { border: 0; padding: 0; margin: 0 0 10px; }
.hook { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 6px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; }
.hook:has(input:checked) { border-color: var(--accent); }
.hook input { margin-top: 4px; accent-color: var(--accent); }
.hook span { flex: 1; }
.hook textarea { margin: 0; }
.draft details { margin: 8px 0 12px; }
.draft summary { cursor: pointer; font-size: 0.92rem; }
.draft details textarea { margin-top: 8px; }
.source { word-break: break-all; }
.drafts-link { display: block; margin: 0 0 10px; color: var(--link); }
.speech-total { margin: -6px 0 12px; }
.legacy pre { white-space: pre-wrap; margin: 6px 0; }
.danger-link { color: var(--err); }

/* teleprompter recording */
.pr-rec { border-color: #e11d48 !important; }
.pr-rec.on { background: #e11d48 !important; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }
.pr-overlay {
  position: fixed; inset: 0; z-index: 5; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.82); color: #fff; padding: 16px;
}
.pr-count { font-size: 120px; font-weight: 800; }
.pr-done { width: min(420px, 100%); text-align: center; }
.pr-done audio { width: 100%; margin: 12px 0; }
.pr-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.pr-done .btn.ghost { color: #fff; }
.card-form { margin-top: 8px; }
.card-form .row { margin-top: 0; }
.card-form select { width: auto; flex: 1; margin: 0; }
.card-form textarea { margin-top: 6px; }
/* An uploaded picture, screenshot or card is shown whole, as it will be fitted. */
.ins-chosen.upload img { object-fit: contain; }
.ins-chosen .small { padding: 2px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.65); text-shadow: none; }

/* publishing calendar */
.pubs { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 12px; }
.pub { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.pub:last-child { border-bottom: 0; padding-bottom: 0; }
.pub-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-bottom: 4px; }
.pub > a { display: block; font-size: 0.88rem; word-break: break-all; margin-bottom: 6px; }
.pub .actions { margin-top: 6px; }
.move summary { list-style: none; cursor: pointer; }
.move .row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.move .row input { margin: 0; }
.p-scheduled { background: rgba(37, 99, 235, 0.14); color: var(--plan); }
.p-publishing { background: rgba(180, 83, 9, 0.16); color: var(--warn); }
.p-published { background: rgba(21, 128, 61, 0.15); color: var(--ok); }
.p-failed { background: rgba(210, 59, 59, 0.15); color: var(--err); }
.platforms { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.platforms li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.platforms .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.platforms .dot.on { background: var(--ok); }
.day { margin: 18px 0 6px; font-size: 0.9rem; color: var(--muted); font-weight: 600; }
.cal { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cal-item { display: block; padding: 10px 12px; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); }
.cal-item .topic { font-weight: 600; }
.cal-item .meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 0.85rem; margin-top: 4px; }
.cal-item .err { font-size: 0.85rem; margin-top: 4px; }

/* channel */
.q-generating, .q-publishing { background: rgba(180, 83, 9, 0.16); color: var(--warn); }
.q-draft { background: rgba(225, 29, 72, 0.14); color: var(--link); }
.q-scheduled { background: rgba(37, 99, 235, 0.14); color: var(--plan); }
.q-published { background: rgba(21, 128, 61, 0.15); color: var(--ok); }
.q-failed { background: rgba(210, 59, 59, 0.15); color: var(--err); }
h2.section { font-size: 0.95rem; margin: 20px 0 8px; color: var(--muted); }
.tg-post { max-width: 420px; border-radius: 12px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.tg-post .player { margin: 0; border-radius: 0; max-height: 60vh; }
.post-preview { white-space: pre-wrap; word-break: break-word; padding: 10px 12px; font-size: 0.95rem; }
.emoji-row { display: flex; flex-wrap: wrap; gap: 4px; margin: -4px 0 10px; }
.row2 > .emoji-row { grid-column: 1 / -1; order: 3; }
.emoji-row .more { display: none; }
.emoji-row.open .more { display: inline-block; }
.emoji-row .toggle { font-size: 0.85rem; color: var(--muted); padding: 4px 10px; }
.emoji-row button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 4px 6px; font-size: 1.1rem; line-height: 1; cursor: pointer; min-width: 34px; min-height: 34px; }

/* insights */
.buckets { list-style: none; margin: 0; padding: 0; }
.buckets li { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.buckets li:first-child { border-top: 0; }
.card .metrics { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; color: var(--muted); font-variant-numeric: tabular-nums; }
.retention { position: relative; margin: 0; }
.retention svg { display: block; width: 100%; height: auto; overflow: visible; }
.retention .curve { fill: none; stroke: var(--link); stroke-width: 2; stroke-linejoin: round; }
.retention .grid { stroke: var(--line); stroke-width: 1; }
.retention .axis { stroke: var(--muted); stroke-width: 1; opacity: 0.6; }
.retention .tick { fill: var(--muted); font-size: 10px; }
.retention .drop-band { fill: var(--err); opacity: 0.12; }
.retention .drop-n { fill: var(--err); font-size: 10px; font-weight: 700; }
.retention .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.retention .dot { fill: var(--link); stroke: var(--card); stroke-width: 2; }
.chart-tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: 0.82rem; white-space: nowrap; pointer-events: none; }
.drops { margin: 0; padding-left: 1.4em; }
.drops li { padding: 6px 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
table.data td, table.data th { text-align: left; padding: 3px 0; border-top: 1px solid var(--line); }

/* channel slot grid */
.slots-set summary { cursor: pointer; }
.row-form { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 10px 0 0; }
.row-form label { display: flex; align-items: center; gap: 6px; margin: 0; }
.row-form input, .row-form select { width: auto; margin: 0; }
.row-form select { flex: 1 1 12em; min-width: 0; max-width: 100%; }
.row-form input[name=times] { min-width: 12em; }
.slot-day h3 { margin: 0 0 8px; font-size: 1rem; }
.slot-list { list-style: none; margin: 0; padding: 0; }
.slot { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); min-height: 44px; }
.slot:first-child { border-top: 0; }
.slot.past { opacity: 0.5; }
.slot.off .slot-time { color: var(--muted); font-style: italic; }
.slot-time { flex: none; width: 3.2em; font-variant-numeric: tabular-nums; font-weight: 600; }
.slot-post { flex: 1; min-width: 0; display: flex; justify-content: space-between; gap: 8px; color: var(--text); }
.slot-post > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-place { flex: 1; min-width: 0; display: flex; gap: 6px; }
.slot-place select { flex: 1; min-width: 0; margin: 0; }
.car-caption .post-preview { padding: 0; margin-bottom: 8px; }
.post-preview.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; padding: 0; margin: 0 0 10px; }
.counter { text-align: right; margin: -6px 0 10px; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--err); font-weight: 600; }
.dot-ok { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.setup { padding-left: 20px; margin: 6px 0; }
.setup li { margin: 4px 0; }

/* carousels */
.c-generating { background: rgba(180, 83, 9, 0.16); color: var(--warn); }
.c-ready { background: rgba(21, 128, 61, 0.15); color: var(--ok); }
.c-failed { background: rgba(210, 59, 59, 0.15); color: var(--err); }
.car-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.car-card { display: flex; gap: 12px; align-items: center; }
.car-card img, .car-ph { flex: none; width: 64px; aspect-ratio: 4 / 5; border-radius: 8px; object-fit: cover; background: var(--line); }
.car-card .topic { margin-top: 4px; }
.slides { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; margin: 12px 0; scrollbar-width: thin; }
.slides img { flex: none; width: min(70vw, 300px); aspect-ratio: 4 / 5; border-radius: 10px; scroll-snap-align: start; display: block; }
.slides.album { margin: 0; padding: 0; }
.slides.album img { width: min(60vw, 220px); border-radius: 0; }
.slide-edit { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 2px; margin: 0 0 12px; }
.slide-edit legend { font-size: 0.85rem; color: var(--muted); padding: 0 4px; }
.slide-edit .row2 { grid-template-columns: 1fr auto; align-items: center; margin-bottom: 6px; }
.slide-edit .row2 select { margin: 0; }
.slide-edit .check { margin: 0; }
.slide-edit input, .slide-edit textarea { margin: 0 0 8px !important; }
.car-row { display: flex; gap: 10px; align-items: center; margin: 0 0 8px; }
.car-row img { width: 40px; aspect-ratio: 4 / 5; border-radius: 6px; object-fit: cover; }
/* Five links on a phone: one line that scrolls rather than a header twice as tall. */
.top { gap: 12px; }
.top .brand { flex: none; }
.top nav { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.top nav a, .top nav button { white-space: nowrap; }
@media (max-width: 480px) {
  .top .brand { font-size: 0.9rem; }
  .top nav { gap: 10px; font-size: 0.9rem; }
}

/* by-hand platforms */
textarea.copy { font-size: 0.9rem; margin: 4px 0 8px; }
.posted { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.posted input { margin: 0 !important; }

/* sources */
.src-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.src-list li { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.src-actions { flex: none; display: flex; gap: 10px; font-size: 0.85rem; }
.item.used { opacity: 0.6; }
.item .actions { margin-top: 8px; }
.item-text summary { cursor: pointer; font-size: 0.9rem; list-style: none; }
.item-text[open] summary { display: none; }
.item-text .pre { font-size: 0.9rem; margin-top: 4px; }
.k-general { background: rgba(21, 128, 61, 0.15); color: var(--ok); }
.k-personal { background: rgba(225, 29, 72, 0.14); color: var(--link); }
.k-ad, .k-other { background: var(--line); color: var(--muted); }
.k-none { background: rgba(180, 83, 9, 0.16); color: var(--warn); }

/* funnel */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile-label { font-size: 0.82rem; color: var(--muted); }
.tile-value { font-size: 1.9rem; font-weight: 600; line-height: 1.2; margin-top: 4px; }
.tile.hero .tile-value { font-size: 3rem; }
.tile-delta { font-size: 0.85rem; color: var(--muted); }
.cols { display: flex; gap: 6px; height: 140px; margin-top: 10px; }
.cols-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 0.75rem; color: var(--muted);
  font-variant-numeric: tabular-nums; text-align: right; min-width: 1.5em; }
.cols-plot { flex: 1; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--line); }
.col { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; outline: none; }
.col i { display: block; width: 100%; max-width: 24px; min-height: 0; background: var(--plan); border-radius: 4px 4px 0 0; }
.col:hover i, .col:focus i { filter: brightness(1.15); }
.col:hover::after, .col:focus::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; background: var(--text); color: var(--bg); font-size: 0.75rem; padding: 4px 8px; border-radius: 6px;
  pointer-events: none; z-index: 2;
}
.col.l:hover::after, .col.l:focus::after { left: 0; transform: none; }
.col.r:hover::after, .col.r:focus::after { left: auto; right: 0; transform: none; }
.cols-days { display: flex; justify-content: space-between; font-size: 0.75rem; margin: 4px 0 0 calc(1.5em + 6px); }
.table-view { margin-top: 8px; }
.table-view summary { cursor: pointer; color: var(--link); }
table.nums { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin: 6px 0; }
table.nums th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.8rem; }
table.nums td, table.nums th { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.nums td:not(:first-child), table.nums th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; width: 6em; }
table.links input.copy, .magnet input.copy { margin: 4px 0 0 !important; font-size: 0.85rem; padding: 6px 8px; }
.magnet { border-bottom: 1px solid var(--line); padding: 10px 0; }
.magnet.off { opacity: 0.6; }
.magnet .row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.magnet .word { font-size: 1.05rem; letter-spacing: 0.5px; }
.magnet-form { margin-top: 14px; }
.magnet-form h3 { font-size: 0.95rem; margin: 0 0 8px; }

/* code word bonus on drafts */
.bonus { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 2px; margin: 0 0 10px; }
.bonus .row2 { grid-template-columns: 1fr auto; align-items: center; }
.bonus input, .bonus textarea { margin: 0 0 8px !important; }
.bonus-hint { margin-top: -6px; }
.codeword { font-weight: 700; letter-spacing: 0.5px; }

/* YouTube read-back */
.tiles.inline { margin: 8px 0 12px; }
.tiles.inline .tile-value { font-size: 1.5rem; }
.table-scroll { overflow-x: auto; }
table.videos td:not(:first-child), table.videos th:not(:first-child) { width: auto; white-space: nowrap; padding-left: 10px; }
table.videos td:first-child { min-width: 9em; }

/* music */
.tracks { list-style: none; margin: 0 0 12px; padding: 0; }
.tracks li { padding: 10px 0; border-top: 1px solid var(--line); }
.tracks li:first-child { border-top: 0; }
.tracks audio { width: 100%; margin: 6px 0; }
.tracks .row { display: flex; justify-content: space-between; gap: 8px; }
.tracks b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* settings */
.icon-link { font-size: 1.3rem; line-height: 1; text-decoration: none; padding: 4px; }
.settings .setting { padding: 10px 0; border-top: 1px solid var(--line); }
.settings h2 + .setting { border-top: 0; padding-top: 0; }
.setting-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-bottom: 6px; }
.setting-head label { margin: 0; }
.setting input, .setting select { margin: 0; }
.setting p { margin: 6px 0 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.badge.src-app { background: rgba(37, 99, 235, 0.14); color: var(--plan); }
.restart-note { border-left: 4px solid var(--warn); }

/* calendar: one list of videos and channel posts, clashes marked */
.cal-item { padding: 0; }
.cal-item .cal-link { display: block; padding: 10px 12px; color: var(--text); }
.cal-item .move { padding: 0 12px 10px; }
.cal-item .move .row { flex-wrap: wrap; }
.cal-item .move input[type=datetime-local] { flex: 1 1 12em; min-width: 0; }
.cal-item.clash { border-color: var(--warn); box-shadow: inset 3px 0 0 var(--warn); }
.cal-time { font-variant-numeric: tabular-nums; font-weight: 600; margin-right: 4px; }
.cal-free { padding: 6px 12px; border: 1px dashed var(--line); border-radius: var(--radius); font-size: 0.85rem; }
.clash-tag { color: var(--warn); font-size: 0.8rem; font-weight: 600; }
.clash-warn { border-color: var(--warn); }
.clash-warn h2 { margin-top: 0; }
.clash-warn h3 { font-size: 0.95rem; margin: 14px 0 6px; }
.clash-occ { margin: 4px 0 8px; padding-left: 18px; }
.clash-warn .actions .btn { white-space: normal; text-align: left; }
.clash-rest { margin-top: 14px; }

/* date + time picker for moves */
.when { display: inline-flex; gap: 6px; flex: 1 1 14em; min-width: 0; }
.when input[type=date] { flex: 1 1 9em; min-width: 0; margin: 0; }
.when select { flex: 0 0 auto; width: auto; margin: 0; }
