:root {
  --bg: #0f1115;
  --card: #15181e;
  --text: #f2efe9;
  --muted: #a7a39b;
  --faint: #6f6c66;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #f0b35a;
  --like: #ff5d73;
  --save: #f0b35a;
  --paper: #1d1913;
  --paper-text: #efe4cf;
  --night-a: #141633;
  --night-b: #2a1f4d;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Literata", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font-family: var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- feed ---------- */
#feed {
  height: 100dvh;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
#feed::-webkit-scrollbar { display: none; }

.card {
  --tint: var(--accent);
  position: relative;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: var(--card);
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  transition: opacity .35s ease, transform .35s ease;
}
.card.rejected { opacity: 0; transform: translateX(-30%); }

.card-media { position: absolute; inset: 0 0 auto 0; height: 48%; }
.card-media img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  mask-image: linear-gradient(to bottom, #000 45%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent);
  opacity: .85;
}
.card:not(.has-media) .card-media {
  background: radial-gradient(120% 70% at 20% 0%, color-mix(in srgb, var(--tint) 22%, transparent), transparent 70%);
}

.card-inner {
  position: relative;
  padding: calc(64px + var(--safe-top)) 84px calc(28px + var(--safe-bottom)) 22px;
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
  max-width: 720px;
}
.card-inner::-webkit-scrollbar { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--tint) 18%, transparent);
  color: color-mix(in srgb, var(--tint) 75%, white);
}
.chip.quiet { background: rgba(255,255,255,.07); color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 500; }
.has-media .chip { background: rgba(12,14,18,.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.has-media .chip.quiet { color: #d6d2ca; }

.hook {
  font-size: clamp(24px, 6.6vw, 34px);
  line-height: 1.15;
  font-weight: 750;
  letter-spacing: -0.015em;
  margin: 0 0 12px;
  text-wrap: balance;
}
.title { font-size: 17px; font-weight: 600; margin: 0 0 12px; color: color-mix(in srgb, var(--tint) 60%, var(--text)); }
.body { font-size: 16.5px; line-height: 1.5; margin: 0 0 14px; color: #dcd8d0; text-wrap: pretty; }
.why { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.why::before { content: "✦ "; color: var(--tint); }
.next-step {
  font-size: 14.5px; margin: 0 0 16px; padding: 10px 14px;
  border-left: 3px solid var(--tint); background: rgba(255,255,255,.04); border-radius: 0 10px 10px 0;
}
.why:empty, .next-step:empty, .title:empty, .body:empty { display: none; }

.links { display: flex; flex-wrap: wrap; gap: 10px; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 999px; text-decoration: none;
  font-size: 15px; font-weight: 600;
  background: var(--text); color: var(--bg);
}
.link-btn.secondary { background: rgba(255,255,255,.1); color: var(--text); }

/* ---------- rail ---------- */
.rail {
  position: absolute; right: 14px; bottom: calc(36px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.act {
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center;
  background: rgba(0,0,0,.35); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: transform .15s ease, background .2s ease;
}
.act:active { transform: scale(.88); }
.act svg { width: 26px; height: 26px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.act.like[aria-pressed="true"] svg { fill: var(--like); stroke: var(--like); }
.act.save[aria-pressed="true"] svg { fill: var(--save); stroke: var(--save); }
.act.reject svg { stroke: var(--muted); width: 22px; height: 22px; }
.act.note svg { stroke: var(--muted); width: 22px; height: 22px; }
.act.pop { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.25); } }

/* ---------- clip ---------- */
.clip-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9; margin: 4px 0 14px;
  border-radius: 14px; overflow: hidden; background: #000; cursor: pointer; border: 0; padding: 0;
  display: block;
}
.clip-frame img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .9; }
.clip-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.clip-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: linear-gradient(to top, rgba(0,0,0,.55), transparent 60%);
}
.clip-play span {
  width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.92);
}
.clip-play svg { width: 28px; height: 28px; fill: #111; margin-left: 4px; }
.clip-len { position: absolute; right: 10px; bottom: 10px; font-size: 13px; font-weight: 600; background: rgba(0,0,0,.7); padding: 3px 8px; border-radius: 6px; }
.clip-frame.playing .clip-play, .clip-frame.playing .clip-len { display: none; }
.yt-host, .clip-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.clip-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.18); pointer-events: none; }
.clip-progress span { display: block; height: 100%; width: 0; background: var(--tint); transition: width .25s linear; }
.clip-end {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(10,11,14,.82); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.clip-end strong { font-size: 20px; }
.clip-end-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.clip-end .link-btn { border: 0; cursor: pointer; }
.clip-span { font-size: 14px; color: var(--muted); margin: -8px 0 8px; font-variant-numeric: tabular-nums; }
.clip-span.live { color: color-mix(in srgb, var(--tint) 70%, var(--text)); }

/* ---------- passage ---------- */
.card.passage { background: var(--paper); }
.card.passage .card-media { display: none; }
.card.passage .hook { font-size: clamp(20px, 5.4vw, 26px); }
.quote {
  font-family: var(--serif); font-size: clamp(17px, 4.6vw, 20px); line-height: 1.62;
  color: var(--paper-text); margin: 6px 0 18px; padding: 0; white-space: pre-line;
  hyphens: auto; text-wrap: pretty;
}
.quote::first-letter { font-size: 2.6em; float: left; line-height: .9; padding: 4px 8px 0 0; color: var(--tint); }
.source-line { font-family: var(--serif); font-style: italic; color: var(--muted); margin: 0 0 14px; font-size: 15px; }

/* ---------- bedtime ---------- */
.card.bedtime { background: linear-gradient(170deg, var(--night-a), var(--night-b)); }
.card.bedtime .card-media { display: none; }
.card.bedtime .hook { font-weight: 650; }
.card.bedtime .stars {
  position: absolute; inset: 0; pointer-events: none; opacity: .55;
  background-image:
    radial-gradient(1.5px 1.5px at 20% 18%, #fff, transparent),
    radial-gradient(1px 1px at 70% 12%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 85% 30%, #fff, transparent),
    radial-gradient(1px 1px at 40% 8%, #fff, transparent),
    radial-gradient(1px 1px at 55% 25%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 12% 35%, #fff, transparent);
}
.moon { font-size: 44px; line-height: 1; margin-bottom: 10px; display: block; }

/* ---------- empty / end ---------- */
.card.notice .hook { font-size: 26px; }
.card.notice code { background: rgba(255,255,255,.08); padding: 2px 6px; border-radius: 5px; }

/* ---------- menu ---------- */
.menu-btn, .icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: rgba(0,0,0,.35);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.menu-btn { position: fixed; top: calc(12px + var(--safe-top)); right: 14px; z-index: 5; }
.menu-btn svg, .icon-btn svg { width: 22px; height: 22px; stroke: var(--text); stroke-width: 1.8; fill: none; stroke-linecap: round; }

.menu {
  position: fixed; inset: 0; z-index: 10; background: rgba(12,13,17,.97);
  display: flex; flex-direction: column; padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
}
.menu[hidden] { display: none; }
.menu-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.menu-head h2 { margin: 0; font-size: 22px; }
.saved-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.saved-list li { padding: 14px 4px; border-bottom: 1px solid var(--line); }
.saved-list a { text-decoration: none; display: block; }
.saved-list .s-title { font-weight: 600; display: block; }
.saved-list .s-meta { font-size: 13px; color: var(--muted); }
.saved-list .empty { color: var(--muted); border: 0; }
.menu-foot { padding-top: 12px; border-top: 1px solid var(--line); }
.stats { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.text-btn { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px; cursor: pointer; color: var(--muted); }

/* ---------- comment sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto;
  background: #1a1d24; border-radius: 18px 18px 0 0; padding: 14px 16px calc(16px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet-about { margin: 0; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.note-tag {
  border: 1px solid var(--line); background: rgba(255,255,255,.05); border-radius: 999px;
  padding: 8px 12px; font-size: 14px; cursor: pointer;
}
.note-tag[aria-pressed="true"] { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
.sheet textarea {
  width: 100%; resize: vertical; min-height: 96px; font: inherit; font-size: 16px; color: var(--text);
  background: #0f1115; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-foot .link-btn { border: 0; cursor: pointer; }
.sheet-status { color: var(--muted); font-size: 14px; }
.menu-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (min-width: 900px) {
  .card { align-items: center; }
  .card-inner { width: 720px; padding-right: 22px; }
  .rail { right: calc(50% - 440px); }
}
@media (prefers-reduced-motion: reduce) {
  .card, .act { transition: none; }
  .act.pop { animation: none; }
}
.has-media .hook, .has-media .title { text-shadow: 0 1px 14px rgba(0,0,0,.7); }
