/*
 * Opitan on the open web: shared story pages, profiles, the waitlist and the embed player.
 * The app's "stage directions" language (public/styles.css): ink on dusk-coloured paper (night in dark mode), one warm
 * accent — the marigold lamp — for what you can play, and emotion as the only other colour: the scrubber's ribbon
 * shows the narrator's moods across the whole story, faint ahead of you and full where you have listened.
 */

:root {
  color-scheme: light dark;

  --bg: #f4eff3;
  --bg-raised: #fcfafc;
  --bg-sunk: #ebe4ea;
  --hover: rgb(34 27 58 / 0.06);
  --ink: #221b3a;
  --ink-2: #4b4463;
  --ink-3: #625b7a;
  --line: #e0d7df;
  --line-strong: #c7bdc9;
  --lamp: #e8962a;
  --lamp-ink: #8a5000;
  --lamp-wash: rgb(232 150 42 / 0.13);
  --lamp-glow: rgb(232 150 42 / 0.36);
  --on-lamp: #221b3a;
  --focus: #5847d6;
  --danger: #b03a2e;
  --mood-joy: #e8962a;
  --mood-tender: #d4607a;
  --mood-grave: #4b6fc2;
  --mood-tension: #8053cc;
  --mood-neutral: #9a93ae;
  --brand-tile: #241d45;
  --brand-wave: #f1ecf8;
  --veil: rgb(252 250 252 / 0.5);
  --veil-strong: rgb(252 250 252 / 0.6);
  --dock-bg: rgb(252 250 252 / 0.9);
  --shadow-lift: 0 1px 0 var(--line), 0 22px 48px -30px rgb(34 27 58 / 0.32);

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: 16px;
  --measure: 1080px;
  --column: 760px;
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 22px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16132b;
    --bg-raised: #1f1b3a;
    --bg-sunk: #100e22;
    --hover: rgb(241 237 248 / 0.07);
    --ink: #f1edf8;
    --ink-2: #c6bfda;
    --ink-3: #9d95b8;
    --line: #2f2a4f;
    --line-strong: #463f6b;
    --lamp: #f4ac45;
    --lamp-ink: #f6b75c;
    --lamp-wash: rgb(244 172 69 / 0.12);
    --lamp-glow: rgb(244 172 69 / 0.3);
    --on-lamp: #1a1530;
    --focus: #b5a8ff;
    --danger: #ff8f80;
    --mood-joy: #f4ac45;
    --mood-tender: #f08aa1;
    --mood-grave: #7d9cf0;
    --mood-tension: #b08cf5;
    --mood-neutral: #8c85a8;
    --brand-tile: #2c2656;
    --brand-wave: #f1edf8;
    --veil: rgb(31 27 58 / 0.5);
    --veil-strong: rgb(31 27 58 / 0.56);
    --dock-bg: rgb(31 27 58 / 0.9);
    --shadow-lift: 0 1px 0 var(--line), 0 22px 48px -28px rgb(0 0 0 / 0.6);
  }
}

/* An embed can be told which theme to use (?theme=light|dark), whatever the visitor's system says. */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16132b;
  --bg-raised: #1f1b3a;
  --bg-sunk: #100e22;
  --hover: rgb(241 237 248 / 0.07);
  --ink: #f1edf8;
  --ink-2: #c6bfda;
  --ink-3: #9d95b8;
  --line: #2f2a4f;
  --line-strong: #463f6b;
  --lamp: #f4ac45;
  --lamp-ink: #f6b75c;
  --lamp-wash: rgb(244 172 69 / 0.12);
  --lamp-glow: rgb(244 172 69 / 0.3);
  --on-lamp: #1a1530;
  --focus: #b5a8ff;
  --danger: #ff8f80;
  --mood-joy: #f4ac45;
  --mood-tender: #f08aa1;
  --mood-grave: #7d9cf0;
  --mood-tension: #b08cf5;
  --mood-neutral: #8c85a8;
  --brand-tile: #2c2656;
  --brand-wave: #f1edf8;
  --veil: rgb(31 27 58 / 0.5);
  --veil-strong: rgb(31 27 58 / 0.56);
  --dock-bg: rgb(31 27 58 / 0.9);
  --shadow-lift: 0 1px 0 var(--line), 0 22px 48px -28px rgb(0 0 0 / 0.6);
}

@media (min-width: 720px) {
  :root {
    --gutter: 28px;
  }
}

/* ───────────── Base ───────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body.site {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in oklab, currentColor 35%, transparent);
}

a:hover {
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 12px;
  top: -80px;
  z-index: 100;
  padding: 12px 16px;
  border-radius: var(--r-s);
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
}

.skip:focus {
  top: 12px;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ───────────── Header and brand ───────────── */

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) var(--gutter) 6px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding-right: 6px;
  border-radius: var(--r-s);
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
}

.mark-tile {
  fill: var(--brand-tile);
}

.mark-lamp {
  fill: var(--lamp);
}

.mark-wave {
  fill: none;
  stroke: var(--brand-wave);
  stroke-width: 4.6;
  stroke-linecap: round;
}

.mark-wave-far {
  opacity: 0.55;
}

.brand-name {
  font: 600 1.375rem/1 var(--serif);
  font-variation-settings: "opsz" 36;
  letter-spacing: -0.01em;
}

.site-nav {
  display: flex;
  gap: 8px;
}

/* ───────────── Buttons ───────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 600 1rem/1 var(--sans);
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: progress;
  opacity: 0.7;
}

.btn.is-busy .spinner {
  display: inline-block;
}

.btn-primary {
  background: var(--lamp);
  color: var(--on-lamp);
}

.btn-primary:hover:not(:disabled) {
  background: color-mix(in oklab, var(--lamp) 86%, var(--ink));
}

.btn-quiet {
  border-color: var(--line-strong);
}

.btn-quiet:hover {
  background: var(--hover);
  border-color: var(--ink-3);
}

.btn-sm {
  min-height: 40px;
  padding: 0 16px;
  font-size: 0.9375rem;
}

.btn-sm .icon {
  width: 18px;
  height: 18px;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 2px;
  border: 0;
  background: none;
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  text-decoration-color: color-mix(in oklab, currentColor 35%, transparent);
}

.btn-link:hover {
  text-decoration-color: currentColor;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}

.icon-btn:hover {
  background: var(--hover);
}

.icon-btn .icon {
  width: 26px;
  height: 26px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* ───────────── Pages ───────────── */

.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 12px var(--gutter) 56px;
  outline: none;
}

.section-title {
  margin: 0 0 14px;
  font: 500 1.375rem/1.2 var(--serif);
  font-variation-settings: "opsz" 30;
  letter-spacing: -0.01em;
}

.owner-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  max-width: var(--column);
  margin: 4px auto 22px;
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-m);
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.owner-bar p {
  margin: 0;
}

.owner-bar .btn-link {
  color: var(--ink);
}

/* An older version of a revised piece: a warm pointer to the newest, above the story it replaces. */
.version-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  max-width: var(--column);
  margin: 4px auto 22px;
  padding: 12px 16px;
  border-radius: var(--r-m);
  background: var(--lamp-wash);
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.version-note p {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.version-note strong {
  color: var(--ink);
  font-weight: 600;
}

.version-note .btn-link {
  color: var(--lamp-ink);
}

/* ───────────── Story: title ───────────── */

.story {
  max-width: var(--column);
  margin: 0 auto;
}

.story-hero {
  display: grid;
  gap: 20px;
  padding-top: 8px;
}

.cover {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--bg-sunk);
}

.cover > .art,
.cover > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-cover {
  width: 100%;
  aspect-ratio: 21 / 9;
  border-radius: var(--r-l);
}

.story-title {
  margin: 0;
  font: 500 clamp(2rem, 1.35rem + 2.7vw, 3.35rem) / 1.04 var(--serif);
  font-variation-settings: "opsz" 72;
  letter-spacing: -0.022em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.story-byline {
  margin: 12px 0 0;
  color: var(--ink-2);
  font-size: 1.0625rem;
  overflow-wrap: anywhere;
}

.story-byline a,
.story-byline .byline-name {
  color: var(--ink);
  font-weight: 600;
}

@media (min-width: 720px) {
  .story-hero {
    grid-template-columns: 208px minmax(0, 1fr);
    align-items: end;
    gap: 32px;
    padding-top: 28px;
  }

  .story-cover {
    width: 208px;
    aspect-ratio: 1;
  }
}

/* ───────────── Player ───────────── */

.player-card {
  margin-top: 28px;
  padding: 18px 18px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: var(--bg-raised);
  box-shadow: var(--shadow-lift);
}

/* Without JavaScript the browser's own controls play the story. */
.player-audio {
  display: block;
  width: 100%;
}

.player-card .player-ui {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "play main"
    "tools tools";
  align-items: center;
  gap: 4px 16px;
}

.player-card .player-ui > .play {
  grid-area: play;
}

.player-main {
  grid-area: main;
  min-width: 0;
}

.player-tools {
  grid-area: tools;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

@media (min-width: 620px) {
  .player-card .player-ui {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "play main tools";
    gap: 0 20px;
  }
}

/* The lamp: what you press to listen. Its sound rings ripple while the story plays. */
.play {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--lamp);
  color: var(--on-lamp);
  box-shadow: 0 10px 24px -10px var(--lamp-glow);
  transition:
    background-color 0.15s ease,
    transform 0.1s ease;
}

.play:hover {
  background: color-mix(in oklab, var(--lamp) 88%, var(--ink));
}

.play:active {
  transform: scale(0.97);
}

.play > * {
  grid-area: 1 / 1;
}

.play .icon {
  width: 28px;
  height: 28px;
}

.play .i-play {
  margin-left: 3px;
}

.play .i-pause,
.play.is-playing .i-play {
  display: none;
}

.play.is-playing .i-pause {
  display: block;
}

.play .spinner {
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  border-color: var(--lamp);
  border-right-color: transparent;
}

.play.is-waiting .spinner {
  display: block;
}

.play::before,
.play::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 2px solid var(--lamp);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .play.is-playing::before,
  .play.is-playing::after {
    animation: ring 2.6s cubic-bezier(0.2, 0.6, 0.4, 1) infinite;
  }

  .play.is-playing::after {
    animation-delay: 1.3s;
  }
}

@keyframes ring {
  0% {
    opacity: 0.5;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.55);
  }
}

/* Scrubber: the whole story's moods, faint ahead and full where you have listened. */
.scrub {
  --played: 0%;
  --buffered: 0%;
  position: relative;
  height: 36px;
  min-width: 0;
}

.scrub-track {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 10px;
  margin-top: -5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-sunk);
}

.scrub-ribbon {
  position: absolute;
  inset: 0;
  background: var(--lamp);
}

.scrub-veil {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: var(--played);
  background: var(--veil-strong);
}

.scrub-ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tick {
  position: absolute;
  top: 50%;
  width: 3px;
  height: 12px;
  margin: -6px 0 0 -1.5px;
  background: var(--bg-raised);
}

.scrub-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.scrub-input:focus-visible {
  outline: none;
}

.scrub:has(.scrub-input:focus-visible) .scrub-track {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.scrub-input::-webkit-slider-runnable-track {
  height: 36px;
  background: transparent;
}

.scrub-input::-webkit-slider-thumb {
  box-sizing: border-box;
  width: 22px;
  height: 22px;
  margin-top: 7px;
  border: 3px solid var(--bg-raised);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 1px 6px rgb(0 0 0 / 0.25);
  -webkit-appearance: none;
  appearance: none;
}

.scrub-input::-moz-range-track {
  height: 36px;
  background: transparent;
}

.scrub-input::-moz-range-thumb {
  box-sizing: border-box;
  width: 22px;
  height: 22px;
  border: 3px solid var(--bg-raised);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 1px 6px rgb(0 0 0 / 0.25);
}

.player-times {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 12px;
  margin-top: -2px;
}

.time {
  color: var(--ink-2);
  font: 500 0.8125rem/1.2 var(--sans);
  font-variant-numeric: tabular-nums;
}

.player-chapter {
  overflow: hidden;
  color: var(--ink-3);
  font-size: 0.8125rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mood-legend {
  margin: 10px 0 0;
  color: var(--ink-3);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.mood-key {
  white-space: nowrap;
}

.mood-key::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin: 0 5px 1px 2px;
  border-radius: 50%;
  background: var(--mood-neutral);
  vertical-align: middle;
}

.mood-key[data-mood="joy"]::before {
  background: var(--mood-joy);
}

.mood-key[data-mood="tender"]::before {
  background: var(--mood-tender);
}

.mood-key[data-mood="grave"]::before {
  background: var(--mood-grave);
}

.mood-key[data-mood="tension"]::before {
  background: var(--mood-tension);
}

.speed {
  min-width: 56px;
  min-height: 40px;
  margin-left: 4px;
  padding: 0 10px;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  font: 600 0.875rem/1 var(--sans);
  font-variant-numeric: tabular-nums;
}

.speed:hover {
  border-color: var(--ink);
}

.player-resume,
.player-error {
  margin: 10px 0 0;
  font-size: 0.875rem;
}

.player-resume {
  color: var(--ink-2);
}

.player-resume strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.player-error {
  color: var(--danger);
  font-weight: 500;
}

.story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* ───────────── Chapters ───────────── */

.chapters {
  margin-top: 44px;
}

.chapter-list {
  display: grid;
  gap: 2px;
  margin: 0 -12px;
  padding: 0;
  list-style: none;
}

.chapter {
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  border: 0;
  border-radius: var(--r-m);
  background: transparent;
  text-align: left;
}

.chapter:hover {
  background: var(--hover);
}

.chapter[aria-current="true"] {
  background: var(--lamp-wash);
}

.chapter-num {
  color: var(--ink-3);
  font: 600 0.875rem/1.4 var(--sans);
  font-variant-numeric: tabular-nums;
}

.chapter[aria-current="true"] .chapter-num {
  color: var(--lamp-ink);
}

.chapter-title {
  font: 500 1.0625rem/1.35 var(--serif);
  overflow-wrap: anywhere;
}

.chapter[aria-current="true"] .chapter-title {
  font-weight: 600;
}

.chapter-time {
  color: var(--ink-3);
  font: 500 0.8125rem/1.4 var(--sans);
  font-variant-numeric: tabular-nums;
}

/* ───────────── About an imported story ───────────── */

.story-about {
  margin-top: 44px;
}

.story-excerpt {
  margin: 0;
  padding: 2px 0 2px 20px;
  border-left: 3px solid var(--line-strong);
}

.story-excerpt p {
  margin: 0;
  color: var(--ink-2);
  font: italic 400 1.25rem/1.55 var(--serif);
  overflow-wrap: anywhere;
}

.source-note {
  margin: 18px 0 0;
  color: var(--ink-3);
  font-size: 0.9375rem;
  max-width: 36em;
}

.source-note a {
  color: var(--ink);
  font-weight: 600;
}

/* ───────────── An authored story's text ───────────── */

.prose {
  max-width: 34em;
  margin-top: 48px;
  font: 400 1.1875rem/1.7 var(--serif);
  font-variation-settings: "opsz" 16;
  overflow-wrap: break-word;
}

.prose > :first-child {
  margin-top: 0;
}

.prose p {
  margin: 0 0 1.05em;
}

.prose h2 {
  margin: 2em 0 0.6em;
  font: 600 1.55rem/1.2 var(--serif);
  font-variation-settings: "opsz" 36;
  letter-spacing: -0.012em;
}

.prose h3 {
  margin: 1.7em 0 0.5em;
  font: 600 1.25rem/1.3 var(--serif);
}

.prose ul {
  margin: 0 0 1.05em;
  padding-left: 1.3em;
}

.prose li {
  margin: 0.3em 0;
  padding-left: 0.2em;
}

.prose li::marker {
  color: var(--ink-3);
}

.prose blockquote {
  margin: 1.4em 0;
  padding: 0 0 0 1em;
  border-left: 3px solid var(--line-strong);
  color: var(--ink-2);
  font-style: italic;
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose .caption {
  color: var(--ink-3);
  font: 400 0.9375rem/1.5 var(--sans);
}

.prose pre {
  margin: 1.2em 0;
  padding: 14px 16px;
  overflow-x: auto;
  border-radius: var(--r-m);
  background: var(--bg-sunk);
  font: 0.875rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* A scene break: a quiet dinkus, never a rule across the page. */
.scene-break {
  width: 52px;
  height: 6px;
  margin: 2.2em auto;
  border: 0;
  background: radial-gradient(circle, var(--ink-3) 0 2.5px, transparent 3px) 0 0 / 20px 6px repeat-x;
}

.notes {
  margin-top: 2.6em;
  padding-top: 1.2em;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font: 400 0.9375rem/1.6 var(--sans);
}

.notes h2 {
  margin: 0 0 0.6em;
  font: 600 1rem/1.4 var(--sans);
  letter-spacing: 0;
}

.notes ol {
  margin: 0;
  padding-left: 1.4em;
}

.notes li::marker {
  font-variant-numeric: proportional-nums;
}

/* ───────────── Who shared it ───────────── */

.author-card {
  margin-top: 52px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

/* A link to the profile once it is open to everyone; until then the same block, unlinked. */
.author-link,
.author-id {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  border-radius: var(--r-m);
  text-decoration: none;
}

.author-text {
  display: grid;
}

.author-label {
  color: var(--ink-3);
  font-size: 0.8125rem;
}

.author-name {
  font: 600 1.125rem/1.3 var(--serif);
  overflow-wrap: anywhere;
}

.author-link:hover .author-name {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.author-handle {
  color: var(--ink-3);
  font-size: 0.875rem;
}

.author-bio {
  max-width: 36em;
  margin: 12px 0 0;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.avatar {
  display: grid;
  flex: none;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--brand-tile);
  color: var(--brand-wave);
  font-family: var(--serif);
  font-weight: 600;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-md {
  width: 52px;
  height: 52px;
  font-size: 1.25rem;
}

.avatar-lg {
  width: 96px;
  height: 96px;
  font-size: 2.25rem;
}

/* ───────────── Story lists ───────────── */

.more {
  max-width: var(--column);
  margin: 56px auto 0;
}

.card-list {
  display: grid;
  gap: 4px;
  margin: 0 -12px;
  padding: 0;
  list-style: none;
}

.card-link {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border-radius: var(--r-m);
  text-decoration: none;
}

.card-link:hover {
  background: var(--hover);
}

.card-art {
  width: 72px;
  height: 72px;
  flex: none;
  border-radius: var(--r-m);
}

.card-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.card-title {
  font: 500 1.1875rem/1.25 var(--serif);
  overflow-wrap: anywhere;
}

.card-link:hover .card-title {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  color: var(--ink-3);
  font-size: 0.875rem;
}

.card-site {
  color: var(--ink-2);
  font-weight: 500;
}

.card-length {
  font-variant-numeric: tabular-nums;
}

/* ───────────── Mini player (story pages, once the main player scrolls away) ───────────── */

.mini {
  --played: 0%;
  position: fixed;
  z-index: 30;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 18px 8px 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--dock-bg);
  box-shadow: var(--shadow-lift);
  -webkit-backdrop-filter: saturate(1.3) blur(16px);
  backdrop-filter: saturate(1.3) blur(16px);
}

.mini-play {
  width: 46px;
  height: 46px;
  flex: none;
  box-shadow: none;
}

.mini-play .icon {
  width: 22px;
  height: 22px;
}

.mini-play::before,
.mini-play::after {
  display: none;
}

.mini-text {
  display: grid;
  min-width: 0;
}

.mini-title {
  overflow: hidden;
  font: 500 1rem/1.25 var(--serif);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-time {
  color: var(--ink-3);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.mini-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--lamp) var(--played), transparent var(--played));
}

body.has-mini {
  padding-bottom: 84px;
}

/* ───────────── Profile ───────────── */

.profile-head {
  display: grid;
  gap: 18px;
  max-width: var(--column);
  margin: 0 auto;
  padding-top: 20px;
}

@media (min-width: 640px) {
  .profile-head {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 28px;
    padding-top: 36px;
  }
}

.profile-name {
  margin: 0;
  font: 500 clamp(2rem, 1.5rem + 2vw, 3rem) / 1.06 var(--serif);
  font-variation-settings: "opsz" 60;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.profile-handle {
  margin: 6px 0 0;
  color: var(--ink-3);
}

.profile-bio {
  max-width: 34em;
  margin: 14px 0 0;
  color: var(--ink-2);
  font: 400 1.125rem/1.55 var(--serif);
  overflow-wrap: anywhere;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.profile-stories {
  max-width: var(--column);
  margin: 48px auto 0;
}

.count {
  display: inline-grid;
  place-items: center;
  min-width: 1.7em;
  height: 1.7em;
  margin-left: 6px;
  padding: 0 0.45em;
  border-radius: 999px;
  background: var(--bg-sunk);
  color: var(--ink-2);
  font: 600 0.8125rem/1 var(--sans);
  vertical-align: 0.2em;
}

.empty {
  margin: 0;
  color: var(--ink-3);
}

/* ───────────── Join ───────────── */

.join-page {
  display: grid;
  gap: 40px;
  padding-top: 28px;
}

@media (min-width: 900px) {
  .join-page {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    align-items: start;
    gap: 64px;
    padding-top: 56px;
  }
}

.join-title {
  margin: 0;
  font: 500 clamp(2.3rem, 1.5rem + 3.2vw, 3.8rem) / 1.02 var(--serif);
  font-variation-settings: "opsz" 72;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.join-lede {
  max-width: 32em;
  margin: 18px 0 0;
  color: var(--ink-2);
  font: 400 1.1875rem/1.55 var(--serif);
}

.join-already {
  margin: 18px 0 0;
  font-weight: 500;
}

.join-already a {
  font-weight: 600;
}

.join-form {
  display: grid;
  max-width: 460px;
  margin-top: 30px;
}

.field-label {
  display: block;
  margin: 16px 0 8px;
  font: 600 0.9375rem/1.3 var(--sans);
}

.field-label:first-child {
  margin-top: 0;
}

.optional {
  color: var(--ink-3);
  font-weight: 400;
}

.field-input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-m);
  background: var(--bg-raised);
  font-size: 1rem;
  transition: border-color 0.15s ease;
}

.field-input:hover {
  border-color: var(--ink-3);
}

.field-input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

textarea.field-input {
  min-height: 96px;
  resize: vertical;
}

.join-form .btn {
  justify-self: start;
  margin-top: 22px;
  min-width: 190px;
}

.join-form.is-done .field-input {
  color: var(--ink-3);
}

.form-status {
  min-height: 1.5em;
  margin: 14px 0 0;
  color: var(--ink-2);
  font-weight: 500;
}

.join-points {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.join-points li {
  padding: 18px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
}

.join-points li:last-child {
  border-bottom: 1px solid var(--line);
}

.join-points strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font: 600 1.125rem/1.3 var(--serif);
}

/* ───────────── Not found ───────────── */

.notice {
  display: grid;
  gap: 14px;
  justify-items: start;
  max-width: 560px;
  padding-top: 10vh;
}

.notice-title {
  margin: 0;
  font: 500 clamp(2rem, 1.4rem + 2vw, 2.8rem) / 1.08 var(--serif);
  letter-spacing: -0.015em;
}

.notice-text {
  margin: 0 0 8px;
  color: var(--ink-2);
  font-size: 1.0625rem;
}

/* ───────────── Footer ───────────── */

.site-foot {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter) max(24px, env(safe-area-inset-bottom));
}

.foot-card {
  display: grid;
  justify-items: start;
  gap: 14px;
  padding: 28px;
  border-radius: 26px;
  background: var(--brand-tile);
  color: var(--brand-wave);
}

.foot-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font: 600 1rem/1 var(--sans);
}

.foot-brand .brand-mark {
  width: 26px;
  height: 26px;
}

.foot-brand .mark-tile {
  fill: color-mix(in oklab, var(--brand-tile) 70%, var(--brand-wave));
}

.foot-line {
  max-width: 28em;
  margin: 0;
  font: 400 clamp(1.3rem, 1.1rem + 0.8vw, 1.6rem) / 1.3 var(--serif);
  letter-spacing: -0.01em;
}

.foot-card .btn {
  margin-top: 6px;
}

.foot-card :focus-visible {
  outline-color: var(--brand-wave);
}

.foot-small {
  margin: 16px 0 0;
  color: var(--ink-3);
  font-size: 0.875rem;
  text-align: center;
}

.foot-small a {
  color: var(--ink-2);
  font-weight: 600;
}

/* ───────────── Embed player (inside other sites' iframes) ───────────── */

.embed-body {
  height: 100%;
  overflow: hidden;
  background: transparent;
}

html:has(.embed-body) {
  height: 100%;
}

.embed {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  padding: 12px 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-raised);
}

.embed-player {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.embed-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.embed-art {
  width: 56px;
  height: 56px;
  border-radius: 12px;
}

.embed-text {
  min-width: 0;
}

.embed-title {
  margin: 0;
  overflow: hidden;
  font: 600 1.0625rem/1.25 var(--serif);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.embed-sub {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--ink-3);
  font-size: 0.8125rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.embed .play {
  width: 52px;
  height: 52px;
  box-shadow: 0 8px 18px -10px var(--lamp-glow);
}

.embed .play .icon {
  width: 24px;
  height: 24px;
}

.embed-timeline {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.embed-timeline .scrub {
  height: 26px;
}

.embed-timeline .scrub-track {
  height: 8px;
  margin-top: -4px;
}

.embed-timeline .scrub-input::-webkit-slider-runnable-track {
  height: 26px;
}

.embed-timeline .scrub-input::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: 4px;
}

.embed-timeline .scrub-input::-moz-range-track {
  height: 26px;
}

.embed-timeline .scrub-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
}

.embed-timeline .tick {
  height: 10px;
  margin-top: -5px;
}

.embed-timeline .time {
  font-size: 0.75rem;
}

.embed-extra {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.embed .speed {
  min-height: 30px;
  min-width: 48px;
  margin: 0;
  font-size: 0.8125rem;
}

.chapter-select {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 240px;
  height: 30px;
  padding: 0 28px 0 12px;
  overflow: hidden;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%239a93ae' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 16px;
  font-size: 0.8125rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.chapter-select:hover {
  border-color: var(--ink-3);
}

.chapter-select option {
  background: var(--bg-raised);
  color: var(--ink);
}

.embed-brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 4px 2px;
  border-radius: 8px;
  color: var(--ink-3);
  font-size: 0.75rem;
  text-decoration: none;
  white-space: nowrap;
}

.embed-brand b {
  color: var(--ink);
  font-weight: 600;
}

.embed-brand .brand-mark {
  width: 18px;
  height: 18px;
}

.embed-brand:hover b {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.embed .player-resume,
.embed .player-error {
  margin: 0;
  font-size: 0.75rem;
}

/* Without JavaScript: title, cover and the browser's controls. */
.embed .player-audio {
  height: 36px;
}

/* Wide embeds: the cover spans the player's height. */
@media (min-width: 540px) {
  .embed-player {
    grid-template-columns: 96px minmax(0, 1fr) auto;
    grid-template-areas:
      "art text play"
      "art timeline timeline"
      "art extra extra"
      "art notes notes";
    column-gap: 16px;
    row-gap: 4px;
    align-items: center;
  }

  .embed-top {
    display: contents;
  }

  .embed-art {
    grid-area: art;
    width: 96px;
    height: 96px;
    align-self: start;
    border-radius: 14px;
  }

  .embed-text {
    grid-area: text;
  }

  .embed-top > .player-ui {
    grid-area: play;
  }

  .embed-player > .player-audio,
  .embed-timeline {
    grid-area: timeline;
  }

  .embed-extra {
    grid-area: extra;
  }

  .embed-player > .player-resume,
  .embed-player > .player-error {
    grid-area: notes;
  }
}

/* Short embeds keep the essentials: what it is, play and the scrubber (resume still happens, quietly). */
@media (max-height: 174px) {
  .embed .player-resume {
    display: none;
  }
}

@media (max-height: 139px) {
  .embed-extra {
    display: none;
  }
}

.embed-missing {
  gap: 4px;
  text-align: center;
}

.embed-missing .embed-title {
  white-space: normal;
}

/* ───────────── Forced colours (Windows High Contrast) ───────────── */

@media (forced-colors: active) {
  .scrub-track {
    border: 1px solid CanvasText;
  }

  .scrub-ribbon {
    background: Highlight !important;
  }

  .scrub-veil {
    background: Canvas;
  }

  .tick {
    background: CanvasText;
  }

  .chapter[aria-current="true"] {
    forced-color-adjust: none;
    background: Highlight;
    color: HighlightText;
  }

  .chapter[aria-current="true"] :is(.chapter-num, .chapter-title, .chapter-time) {
    color: HighlightText;
  }

  .play,
  .btn-primary {
    border: 2px solid ButtonText;
  }
}

/* ───────────── Motion preferences ───────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
