/*
 * Commenter. Dark only, same family as the household's other apps: depth from lighter surfaces, not shadows;
 * one warm accent (marigold) reserved for actions and the chosen draft; red only for "unread".
 * Mukta for the interface (Latin + Devanagari); Martel only for comment drafts, so they read as "the words you'll post".
 */

:root {
  color-scheme: dark;

  --bg: #141017;
  --surface: #1d1720;
  --surface-2: #271f2b;
  --surface-3: #332937;
  --line: #2f2633;
  --line-strong: #4a3d4f;

  --text: #f3edf2;
  --muted: #b3a6b2;
  --faint: #7d6f7e;

  --accent: #f2b544;
  --on-accent: #2b1a00;
  --accent-soft: rgb(242 181 68 / 0.14);
  --plum: #d5a3c8;
  --plum-soft: rgb(213 163 200 / 0.12);
  --unread: #ff5a5f;
  --ok: #7fcf96;
  --ok-soft: rgb(127 207 150 / 0.13);
  --warn: #f0a35e;
  --warn-soft: rgb(240 163 94 / 0.13);

  --r-pane: 24px;
  --r-group: 18px;
  --r-field: 14px;
  --r-pill: 999px;

  --appbar: 60px;
  --bottomnav: 72px;
  --font: "Mukta", "Noto Sans Devanagari", system-ui, sans-serif;
  --font-draft: "Martel", "Noto Serif Devanagari", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
img { display: block; max-width: 100%; }
a { color: var(--plum); text-underline-offset: 3px; }
::selection { background: rgb(242 181 68 / 0.38); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

.loading { padding: 40px 20px; color: var(--muted); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ---- App bar + navigation --------------------------------------------------
   Phone: brand bar on top, navigation pinned to the bottom (thumb reach).
   Wide: one top bar with the navigation on the right. */
.appbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--appbar);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.12rem; letter-spacing: -0.01em; }
.brand img { border-radius: 8px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--bottomnav) + env(safe-area-inset-bottom));
  padding: 8px 8px env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.nav a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 0.82rem; font-weight: 600;
}
.nav a svg { width: 56px; height: 30px; padding: 4px 17px; border-radius: var(--r-pill); transition: background 0.15s; }
.nav a[aria-current="page"] { color: var(--text); }
.nav a[aria-current="page"] svg { background: var(--accent-soft); color: var(--accent); }
.nav-count {
  position: absolute; top: 0; left: calc(50% + 6px);
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--unread); color: #fff; font-size: 0.75rem; font-weight: 700; line-height: 20px; text-align: center;
}

main { padding: 20px 16px calc(var(--bottomnav) + 32px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
main:focus { outline: none; }
body.signed-out main { padding-bottom: 40px; }

@media (min-width: 900px) {
  .appbar { padding: 0 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); }
  .nav {
    position: static; height: auto; margin-left: auto; padding: 0; background: none; border: 0;
    display: flex; gap: 4px;
  }
  .nav a { flex-direction: row; gap: 8px; padding: 8px 16px; border-radius: var(--r-pill); font-size: 0.95rem; }
  .nav a svg { width: 20px; height: 20px; padding: 0; background: none !important; }
  .nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
  .nav-count { position: static; margin-left: 2px; }
  main { padding: 28px 24px 48px; }
  main.wide { max-width: none; padding: 0; }
}

/* ---- Page headings ---------------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-title { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.section { margin-top: 32px; }
.section-title { font-size: 0.95rem; font-weight: 700; color: var(--muted); margin: 0 4px 10px; }
.section-note { color: var(--muted); font-size: 0.95rem; margin: -4px 4px 12px; max-width: 60ch; }

/* ---- Grouped lists (Android settings style) -------------------------------- */
.group { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r-group); overflow: hidden; }
.group > li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 64px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; line-height: 1.3; }
.row-sub { color: var(--muted); font-size: 0.9rem; line-height: 1.35; margin-top: 2px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--surface-3); object-fit: cover; flex: none; }

/* ---- Buttons (pill) --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); background: transparent; color: var(--text);
  font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 19px; height: 19px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: #f6c460; }
.btn-tonal { background: var(--surface-3); border-color: transparent; }
.btn-tonal:hover { background: #3d3242; }
.btn-text { border-color: transparent; padding: 0 12px; color: var(--plum); }
.btn-text:hover { background: var(--plum-soft); }
.btn-big { min-height: 54px; font-size: 1.05rem; padding: 0 26px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---- Fields ----------------------------------------------------------------- */
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; }
.field small { color: var(--muted); font-size: 0.88rem; line-height: 1.4; }
.field input, .field textarea, .field select, .input {
  width: 100%; min-height: 50px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-field);
  color: var(--text);
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus, .input:focus { outline: none; border-color: var(--accent); background: var(--surface-3); }
::placeholder { color: var(--faint); }
.form { display: grid; gap: 20px; }
.error { color: #ff8a80; font-size: 0.95rem; }

/* ---- Chips / tags ----------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--muted); font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.plum { background: var(--plum-soft); color: var(--plum); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.pending::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* ---- Segmented control ------------------------------------------------------ */
.segmented { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface); border-radius: var(--r-pill); }
.segmented a, .segmented button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 16px; border-radius: var(--r-pill);
  border: 0; background: none; color: var(--muted); font-weight: 600; text-decoration: none;
}
.segmented [aria-current="page"], .segmented [aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.segmented .n { font-size: 0.82rem; color: var(--accent); }

/* ---- Video list ------------------------------------------------------------- */
.feed-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.videos { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.vid {
  display: grid; grid-template-columns: 132px 1fr; gap: 14px; padding: 10px;
  border-radius: var(--r-group); background: var(--surface); color: var(--text); text-decoration: none;
  position: relative; transition: background 0.12s;
}
.vid:hover { background: var(--surface-2); }
.vid[aria-current="true"] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.vid-thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--surface-3); }
.vid-thumb img { width: 100%; height: 100%; object-fit: cover; }
.vid-thumb .dur { position: absolute; right: 5px; bottom: 5px; padding: 0 5px; border-radius: 5px; background: rgb(0 0 0 / 0.75); font-size: 0.75rem; font-weight: 600; }
.vid-body { min-width: 0; display: grid; gap: 4px; align-content: start; }
.vid-title { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vid-meta { color: var(--muted); font-size: 0.86rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vid .chips { margin-top: 2px; }
.vid.unread .vid-title::before { content: ""; display: inline-block; width: 9px; height: 9px; margin: 0 7px 1px 0; border-radius: 50%; background: var(--unread); vertical-align: middle; }
@media (max-width: 420px) { .vid { grid-template-columns: 112px 1fr; gap: 12px; } }

.empty { padding: 36px 24px; text-align: center; background: var(--surface); border-radius: var(--r-group); }
.empty svg { width: 40px; height: 40px; color: var(--faint); margin: 0 auto 12px; }
.empty h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 42ch; margin: 0 auto; }
.empty .btn { margin-top: 18px; }

/* ---- Split view (wide screens) ---------------------------------------------- */
.split { display: grid; grid-template-columns: minmax(340px, 420px) 1fr; height: calc(100dvh - var(--appbar)); }
.split-list { overflow-y: auto; padding: 20px 16px 32px 20px; border-right: 1px solid var(--line); }
.split-detail { overflow-y: auto; position: relative; }
.split-detail > .detail { max-width: 760px; margin: 0 auto; padding: 28px 32px 0; }
.split-empty { height: 100%; display: grid; place-content: center; text-align: center; color: var(--muted); gap: 8px; padding: 24px; }
.split-empty svg { width: 48px; height: 48px; margin: 0 auto; color: var(--faint); }
.split-empty strong { color: var(--text); font-size: 1.1rem; }
.split .vid { grid-template-columns: 112px 1fr; }

/* ---- Video detail ----------------------------------------------------------- */
.back { display: inline-flex; align-items: center; gap: 4px; margin: -6px 0 12px -10px; }
.hero { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: var(--r-pane); overflow: hidden; background: var(--surface-2); }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgb(0 0 0 / 0.55), transparent 45%); }
.hero .play {
  position: absolute; z-index: 1; left: 16px; bottom: 14px;
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 10px; border-radius: var(--r-pill);
  background: rgb(0 0 0 / 0.6); color: #fff; font-weight: 600; font-size: 0.9rem; backdrop-filter: blur(6px);
}
.hero .play svg { width: 18px; height: 18px; }
.detail-title { font-size: 1.45rem; font-weight: 800; line-height: 1.25; letter-spacing: -0.015em; margin-top: 18px; }
@media (min-width: 900px) {
  .detail-head { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
  .detail-head .hero { border-radius: var(--r-group); }
  .detail-head .detail-title { margin-top: 0; font-size: 1.35rem; }
  .detail-head .play { left: 10px; bottom: 10px; }
}
.stats { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; color: var(--muted); font-size: 0.92rem; }
.stats strong { color: var(--text); font-weight: 600; }
.detail .chips { margin-top: 12px; }

.callout { display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; padding: 14px 16px; border-radius: var(--r-group); background: var(--plum-soft); color: var(--text); }
.callout svg { color: var(--plum); margin-top: 1px; }
.callout.warn { background: var(--warn-soft); }
.callout.warn svg { color: var(--warn); }
.callout p + p { margin-top: 4px; }
.callout .muted { font-size: 0.93rem; }

details.about { margin-top: 12px; }
details.about summary { cursor: pointer; color: var(--muted); font-weight: 600; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.about summary::-webkit-details-marker { display: none; }
details.about summary::after { content: "›"; transition: transform 0.15s; }
details.about[open] summary::after { transform: rotate(90deg); }
details.about p { margin-top: 8px; color: var(--muted); max-width: 62ch; }

/* The drafts: the one loud thing. Each is a choice; the chosen one is outlined in marigold and editable. */
.pick-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 30px 0 12px; }
.pick-head h2 { font-size: 1.15rem; font-weight: 700; }
.drafts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.draft {
  display: grid; grid-template-columns: 24px 1fr; gap: 12px; align-items: start;
  padding: 16px 16px 16px 14px; border-radius: var(--r-group);
  background: var(--surface); border: 2px solid transparent; cursor: pointer; transition: border-color 0.12s, background 0.12s;
}
.draft:hover { background: var(--surface-2); }
.draft .radio { width: 22px; height: 22px; margin-top: 6px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; }
.draft[aria-checked="true"] { border-color: var(--accent); background: var(--surface-2); }
.draft[aria-checked="true"] .radio { border-color: var(--accent); }
.draft[aria-checked="true"] .radio::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.draft textarea {
  width: 100%; padding: 0; border: 0; background: transparent; resize: none; overflow: hidden;
  font: 400 1.15rem/1.75 var(--font-draft); color: var(--text);
}
.draft textarea:focus { outline: none; }
.draft .edit-hint { grid-column: 2; font-size: 0.82rem; color: var(--faint); margin-top: -2px; }
.draft[aria-checked="false"] .edit-hint { display: none; }

.quote { margin: 0 0 12px; padding: 14px 16px; border-radius: var(--r-group); background: var(--surface); border-left: 3px solid var(--plum); }
.quote .who { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.quote p { font-family: var(--font-draft); line-height: 1.7; margin-top: 4px; }

.more { margin-top: 28px; display: grid; gap: 10px; padding-bottom: 8px; }
.more .row { min-height: 56px; }
.more button.row { width: 100%; border: 0; background: none; text-align: left; color: var(--text); }
.more button.row:hover { background: var(--surface-2); }
.more .row svg { color: var(--muted); }

/* Sticky action bar: always within thumb reach, above the bottom navigation on phones. */
.actionbar {
  position: sticky; bottom: calc(var(--bottomnav) + env(safe-area-inset-bottom)); z-index: 10;
  margin: 20px -16px 0; padding: 12px 16px 14px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  display: flex; gap: 10px; align-items: center;
}
.actionbar .btn-primary { flex: 1; }
.actionbar .ask { flex: 1; font-weight: 600; }
@media (min-width: 900px) {
  .actionbar { bottom: 0; margin: 24px -32px 0; padding: 16px 32px 20px; }
  .actionbar .btn-primary { flex: 0 1 auto; }
}

.status-panel { margin-top: 28px; padding: 22px; border-radius: var(--r-group); background: var(--surface); display: flex; gap: 14px; align-items: center; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Channels -------------------------------------------------------------- */
.add-row { display: flex; gap: 10px; padding: 12px; }
.add-row .input { flex: 1; min-width: 0; }
@media (max-width: 520px) { .add-row { flex-direction: column; } }
.row .actions { display: flex; gap: 4px; align-items: center; }

/* ---- Setup steps (a real sequence, so numbered) ----------------------------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding: 14px 16px; background: var(--surface); border-radius: var(--r-group); }
.steps li::before { content: counter(step); width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; }
.steps code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; }

.card-pad { background: var(--surface); border-radius: var(--r-group); padding: 20px; }

/* ---- Sign in ---------------------------------------------------------------- */
.signin { max-width: 420px; margin: 8vh auto 0; }
.signin img { border-radius: 16px; margin-bottom: 20px; }
.signin h1 { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.02em; }
.signin > p { color: var(--muted); margin: 6px 0 24px; }

/* ---- Snackbar (top, so it never covers the keyboard or the action bar) ------- */
.snackbar {
  position: fixed; z-index: 50; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%);
  max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 14px;
  background: #ece6ee; color: #1d1720; font-weight: 600; box-shadow: 0 8px 28px rgb(0 0 0 / 0.4);
  animation: drop 0.18s ease-out;
}
@keyframes drop { from { transform: translate(-50%, -8px); opacity: 0; } }
