:root {
  --bg: #f6f2ea;
  --bg-card: #fffdf8;
  --ink: #241f1a;
  --ink-soft: #6b6157;
  --line: #e2d9c9;
  --accent: #9a3b3b;
  --accent-soft: #f0e2e2;
  --wave-bar: #e2d9c9;
  --shadow: 0 1px 2px rgba(36, 31, 26, .05), 0 8px 24px rgba(36, 31, 26, .06);
  --reader-size: 19px;
}

:root[data-theme="dark"] {
  --bg: #14120f;
  --bg-card: #1c1917;
  --ink: #ece5da;
  --ink-soft: #a1968a;
  --line: #322c26;
  --accent: #e08a8a;
  --accent-soft: #2a1e1e;
  --wave-bar: #3d352d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ---------- progress bar ---------- */
#progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0;
  background: var(--accent);
  z-index: 50;
  transition: width .1s linear;
}

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .02em;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}

.brand span { color: var(--accent); }

.spacer { flex: 1; }

.tools { display: flex; gap: 8px; }

button.tool {
  font: inherit;
  font-size: 14px;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  transition: .15s;
}

button.tool:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
}

/* ---------- layout ---------- */
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px 96px;
}

.hero {
  padding: 72px 0 40px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 40px;
}

.hero h1 {
  font-size: clamp(34px, 6vw, 52px);
  line-height: 1.12;
  margin: 0 0 14px;
  letter-spacing: -.02em;
}

.hero p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 18px;
  max-width: 52ch;
}

/* ---------- story card ---------- */
.card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 26px;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0,0,0,.06), 0 14px 34px rgba(0,0,0,.10);
}

.card h2 {
  margin: 0 0 6px;
  font-size: 25px;
  letter-spacing: -.01em;
}

.byline {
  font-family: ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin: 0 0 14px;
}

.summary { margin: 0 0 18px; color: var(--ink-soft); }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }

.tag {
  font-family: ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  font-size: 12.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 11px;
}

.meta {
  font-family: ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

/* ---------- reader ---------- */
.story-head {
  padding: 64px 0 30px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  margin-bottom: 44px;
}

.story-head h1 {
  font-size: clamp(30px, 5.4vw, 44px);
  line-height: 1.15;
  margin: 0 0 12px;
  letter-spacing: -.02em;
}

.story-head .byline { margin-bottom: 18px; }

.story-head .tags { justify-content: center; }

article {
  font-size: var(--reader-size);
  line-height: 1.82;
}

article p { margin: 0 0 1.35em; }

article p.first::first-letter {
  float: left;
  font-size: 3.3em;
  line-height: .82;
  padding: .06em .09em 0 0;
  color: var(--accent);
}

article .break {
  text-align: center;
  color: var(--ink-soft);
  letter-spacing: .8em;
  margin: 2.2em 0;
}

article em { font-style: italic; }

.end {
  margin-top: 56px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--ink-soft);
}

.end a { text-decoration: none; }

/* ---------- voice messages ---------- */
.voices {
  margin: 2.4em 0;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px 8px;
  box-shadow: var(--shadow);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
}

.voices-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.voices-avatar {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 600;
}

.voices-title { font-size: 15.5px; font-weight: 600; }
.voices-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 1px; }
.voices-all { margin-left: auto; flex: none; }

.vm {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.vm:last-child { border-bottom: 0; }

.vm-play {
  width: 42px;
  height: 42px;
  flex: none;
  margin-top: 2px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  position: relative;
  transition: transform .12s ease, filter .12s ease;
}

.vm-play:hover { filter: brightness(1.1); }
.vm-play:active { transform: scale(.94); }

/* play triangle */
.vm-play::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0; height: 0;
  margin-left: 16px;
  border-left: 12px solid #fff;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

/* pause bars */
.vm.playing .vm-play::before {
  width: 12px;
  height: 14px;
  margin-left: auto;
  border: 0;
  background: linear-gradient(to right, #fff 0 4px, transparent 4px 8px, #fff 8px 12px);
}

.vm-body { flex: 1; min-width: 0; }

.vm-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 14.5px;
  margin-bottom: 7px;
}

.vm-time { color: var(--ink-soft); font-size: 12.5px; }

.vm.unheard .vm-top b::after {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-left: 7px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}

.vm-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 30px;
  cursor: pointer;
}

.vm-wave i {
  flex: 1;
  min-width: 2px;
  max-width: 4px;
  border-radius: 2px;
  /* Themed via a variable, NOT via a `:root[data-theme] .vm-wave i` override —
     that selector outranked `.vm-wave i.on` and repainted played bars in the
     unplayed colour, making progress invisible in dark mode. */
  background: var(--wave-bar);
  transition: background .12s linear;
}

.vm-wave i.on { background: var(--accent); }

.vm-tx {
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-soft);
  background: none;
  border: 0;
  padding: 8px 0 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.vm-tx:hover { color: var(--accent); }

.vm-transcript {
  display: none;
  margin: 8px 0 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  border-left: 2px solid var(--line);
  padding-left: 12px;
}

.vm-transcript.open { display: block; }

.vm-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 0 5px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  font-style: italic;
  color: var(--ink-soft);
}

.vm-typing .dots { display: inline-flex; gap: 3px; }

.vm-typing .dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: vm-blink 1.4s infinite;
}

.vm-typing .dots i:nth-child(2) { animation-delay: .2s; }
.vm-typing .dots i:nth-child(3) { animation-delay: .4s; }

@keyframes vm-blink {
  0%, 60%, 100% { opacity: .22; }
  30% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .vm-typing .dots i { animation: none; opacity: .5; }
}

@media (max-width: 560px) {
  .voices { padding: 16px 14px 6px; }
  .voices-all { padding: 5px 9px; font-size: 12px; }
}

.note {
  margin-top: 34px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 16px 20px;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.note b { color: var(--ink); }

@media (max-width: 560px) {
  .wrap { padding: 0 18px 72px; }
  .site-header { padding: 12px 16px; gap: 10px; }
  .brand { font-size: 15px; }
  button.tool { padding: 5px 10px; font-size: 13px; }
}
