/*
 * Stories — monochrome UI refresh
 * Clean-room visual direction inspired by restrained enterprise web design:
 * high contrast, precise spacing, quiet surfaces, strong hierarchy.
 * No LiquidUI assets, colors, typography, or proprietary visual elements are copied.
 */

:root {
  color-scheme: dark;

  --bg: #090909;
  --panel: #111111;
  --panel-raised: #171717;
  --input: #151515;
  --line: #292929;
  --line-strong: #3a3a3a;
  --text: #f5f5f2;
  --muted: #999994;
  --accent: #f5f5f2;
  --accent-contrast: #0a0a0a;
  --soft: #1d1d1d;
  --shadow: #00000066;

  --font-ui: "Avenir Next", "Segoe UI Variable Text", "Inter", -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Avenir Next", "Segoe UI Variable Display", "Inter",
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-reading: "Iowan Old Style", "Palatino Linotype", "Book Antiqua",
    Palatino, Georgia, serif;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -20%, #ffffff08 0, transparent 34rem),
    var(--bg);
  color: var(--text);
  font: 15.5px/1.62 var(--font-ui);
  letter-spacing: -0.008em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.light {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --panel-raised: #ffffff;
  --input: #f1f1ed;
  --line: #deded8;
  --line-strong: #c9c9c2;
  --text: #121212;
  --muted: #6f6f69;
  --accent: #111111;
  --accent-contrast: #ffffff;
  --soft: #ecece7;
  --shadow: #00000014;
}

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

button,
.button {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  padding: 10px 16px;
  font-weight: 560;
}

button:hover,
.button:hover {
  border-color: var(--line-strong);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

button:disabled {
  opacity: 0.38;
  cursor: default;
}

.primary {
  background: var(--text);
  color: var(--accent-contrast);
  border-color: var(--text);
  font-weight: 700;
  box-shadow: 0 8px 26px var(--shadow);
}

.primary:hover {
  background: color-mix(in srgb, var(--text) 90%, var(--bg));
  border-color: color-mix(in srgb, var(--text) 90%, var(--bg));
}

.quiet {
  background: transparent;
}

.small {
  font-size: 13px;
}

.muted {
  color: var(--muted);
}

a {
  color: var(--text);
  text-underline-offset: 3px;
}

header {
  max-width: 1100px;
  height: 78px;
  margin: auto;
  padding: 0 32px;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  font: 720 23px/1 var(--font-display);
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.brand span {
  color: var(--text);
  margin-right: 9px;
}

nav {
  display: flex;
  flex: 1;
  justify-content: flex-end;
  gap: 4px;
}

nav button {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
}

nav button.active {
  background: none;
  color: var(--text);
}

header #theme {
  border: 0;
  background: none;
  padding: 8px;
}

main {
  max-width: 1190px;
  margin: 8px auto 40px;
  padding: 0 28px 120px;
}

.eyebrow {
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 760;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  color: var(--text);
}

h1 {
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.08;
  letter-spacing: -0.045em;
  font-weight: 650;
  margin: 12px 0;
}

h2 {
  font-size: 28px;
  line-height: 1.18;
  letter-spacing: -0.035em;
  font-weight: 640;
  margin: 8px 0 18px;
}

h3 {
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: -0.015em;
  font-weight: 680;
  margin: 0 0 8px;
}

p {
  margin: 10px 0 20px;
}

.intro {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.pill {
  font-size: 11px;
  border: 1px solid var(--line);
  padding: 6px 11px;
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  letter-spacing: 0.02em;
}

.grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 28px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: 0 18px 50px var(--shadow);
}

.world {
  height: 250px;
  background:
    linear-gradient(0deg, #000000c7 0%, #0000002a 58%, transparent 100%),
    url('assets/story-world.png') center 48% / cover;
  border-radius: var(--radius-md);
  display: flex;
  align-items: end;
  padding: 24px;
  color: #ffffff;
  margin-bottom: 24px;
  overflow: hidden;
}

.world h2 {
  color: #ffffff;
  font-size: 30px;
  margin: 4px 0;
}

.memory {
  border-left: 2px solid var(--line-strong);
  padding-left: 17px;
  margin: 22px 0;
  color: var(--muted);
}

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

.between {
  justify-content: space-between;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 680;
  margin: 16px 0 7px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 0 #ffffff05;
}

input::placeholder,
textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 82%, transparent);
}

textarea {
  resize: vertical;
  min-height: 85px;
}

.chips button {
  padding: 8px 14px;
  font-size: 13px;
}

.chips button.selected {
  border-color: var(--text);
  background: var(--text);
  color: var(--accent-contrast);
}

.full {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.wide {
  width: 100%;
  margin-top: 22px;
}

.chapter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.chapter button {
  text-align: left;
}

.number {
  color: var(--muted);
  font: 500 24px/1 var(--font-display);
  min-width: 30px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.book-grid .world {
  height: 230px;
}

.read {
  max-width: 760px;
  margin: auto;
}

.prose {
  font: 20px/1.9 var(--font-reading);
  letter-spacing: 0;
  white-space: pre-wrap;
  min-height: 260px;
  outline-color: var(--text);
}

.actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.player {
  max-width: 680px;
  margin: 30px auto;
  text-align: center;
}

.player .world {
  height: 270px;
  text-align: left;
}

.play {
  border-radius: 50%;
  width: 76px;
  height: 76px;
  background: var(--text);
  color: var(--accent-contrast);
  border-color: var(--text);
  font-size: 26px;
}

.progress {
  height: 4px;
  background: var(--line);
  border-radius: 999px;
  margin: 30px 0 12px;
  overflow: hidden;
}

.progress i {
  display: block;
  background: var(--text);
  height: 100%;
  width: 0;
}

.notice {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--muted);
  margin: 20px 0;
  background: color-mix(in srgb, var(--panel) 72%, transparent);
}

.hidden {
  display: none !important;
}

footer {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  opacity: 0.75;
  max-width: 540px;
  margin: auto;
  padding: 24px 20px;
}

#toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--accent-contrast);
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  z-index: 100;
  max-width: 90vw;
  box-shadow: 0 12px 40px var(--shadow);
}

body.dim header,
body.dim footer {
  opacity: 0.22;
}

body.dim {
  --bg: #050505;
  --panel: #0d0d0d;
  --panel-raised: #111111;
  --input: #101010;
  --text: #c9c9c5;
  --muted: #777772;
}

/* Tonight / creation */
.tonight {
  max-width: 540px;
  margin: 42px auto 0;
}

.current-book {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0;
  background: none;
  border: 0;
  text-align: left;
  margin-bottom: 48px;
  color: var(--text);
}

.current-book img {
  width: 52px;
  height: 68px;
  object-fit: cover;
  border-radius: 7px;
  filter: saturate(0.9) contrast(1.02);
}

.current-book span span {
  display: block;
  margin-top: 3px;
}

.current-book strong {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.tonight h1 {
  font-size: 40px;
  letter-spacing: -0.05em;
  margin-bottom: 14px;
}

.tonight > p {
  margin-bottom: 28px;
}

.tonight textarea {
  min-height: 118px;
  padding: 18px;
  line-height: 1.65;
  background: var(--panel);
  border-color: var(--line);
}

.tonight .primary {
  padding: 16px;
  font-size: 15px;
  margin-top: 18px;
}

.tonight details {
  margin-top: 22px;
}

.tonight summary {
  font-size: 13px;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.tonight summary::after {
  content: '＋';
  color: var(--muted);
}

.tonight details[open] summary::after {
  content: '−';
}

.tonight summary > span {
  margin-left: auto;
  font-size: 12px;
}

.ingredients-content {
  padding: 4px 0 22px;
  border-bottom: 1px solid var(--line);
}

.last-chapter {
  display: block;
  margin: 32px auto 0;
  border: 0;
  background: none;
  font-size: 13px;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.change-menu {
  align-self: center;
}

.change-menu summary {
  cursor: pointer;
  padding: 10px;
}

.change-menu button {
  display: block;
  margin: 8px;
}

.read .card {
  background: none;
  border: 0;
  padding: 16px 0;
  box-shadow: none;
}

.read {
  max-width: 660px;
}

.read h1 {
  font-size: 38px;
}

.read .eyebrow {
  font-size: 10px;
  letter-spacing: 0.12em;
}

.player {
  max-width: 460px;
}

.player .world {
  height: 190px;
}

.player > .notice {
  display: none;
}

/* Editor and listening options */
#editor,
.story-editor {
  min-height: 50vh;
  font: 19px/1.82 var(--font-reading);
  letter-spacing: 0;
  margin-top: 14px;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  margin-top: 36px;
  padding-top: 20px;
  text-align: left;
}

.chapter-nav button {
  font-size: 13px;
}

.chapter-nav small {
  display: block;
  color: var(--muted);
}

.listening-options {
  max-width: 380px;
  margin: 0 auto 24px;
  text-align: left;
}

.listening-options label {
  font-weight: 450;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.listening-options input {
  width: 18px;
  height: 18px;
  accent-color: var(--text);
}

.listening-options select {
  width: auto;
  padding: 7px 10px;
  font-size: 13px;
}

.listening-options .row {
  justify-content: space-between;
}

.listening-options .row label {
  margin: 0;
}

.player.hybrid {
  max-width: 660px;
}

.player.hybrid .world {
  height: 125px;
}

.player #along {
  text-align: left;
  margin-top: 30px;
}

.word.active-word {
  background: var(--text);
  color: var(--accent-contrast);
  border-radius: 3px;
  box-shadow: 0 0 0 3px var(--text);
}

.prose .word {
  transition: background 0.12s, color 0.12s;
}

.player #along .prose {
  min-height: 0;
}

/* Reader chrome */
.back-link {
  display: block;
  background: none;
  border: 0;
  color: var(--muted);
  padding: 8px 0;
  margin-bottom: 24px;
  font-size: 13px;
}

.chapter-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.chapter-banner img {
  width: 64px;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.chapter-banner > div {
  min-width: 0;
}

.read .chapter-banner h1 {
  font-size: 29px;
  margin: 8px 0 10px;
}

.reader-tools {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: 0 12px 30px var(--shadow);
  backdrop-filter: blur(18px);
}

.reader-tools > button {
  padding: 9px 14px;
  font-size: 13px;
}

.reader-tools > .quiet {
  border-color: transparent;
}

.reader-tools .change-menu {
  margin-left: auto;
  font-size: 13px;
  position: relative;
}

.reader-tools .change-menu summary {
  list-style: none;
  padding: 10px;
  white-space: nowrap;
  border-radius: 8px;
}

.reader-tools .change-menu summary:focus-visible {
  outline: 2px solid var(--text);
}

.menu-panel {
  position: absolute;
  right: 0;
  top: 100%;
  min-width: 235px;
  max-width: 80vw;
  padding: 8px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 50px var(--shadow);
  z-index: 6;
}

.change-menu .menu-panel button {
  width: 100%;
  background: none;
  border: 0;
  text-align: left;
  margin: 0;
  font-size: 13px;
  padding: 12px;
}

.change-menu .menu-panel button:hover {
  background: var(--soft);
}

.tool-note {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}

.draft-note {
  margin-top: 20px;
}

.read .prose {
  padding-top: 12px;
}

.playback-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  overflow: hidden;
  margin-bottom: 24px;
}

.player .playback-card .world {
  margin: 0;
  height: 165px;
  border-radius: 0;
  padding: 22px;
}

.playback-controls {
  padding: 18px 24px 20px;
}

.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.transport .quiet {
  border: 0;
  min-width: 62px;
  padding: 10px;
  font-size: 13px;
}

.transport #restart {
  font-size: 24px;
}

.transport .play {
  width: 62px;
  height: 62px;
  font-size: 23px;
}

.playback-controls .progress {
  margin: 20px 0 10px;
}

.player.hybrid .playback-card {
  position: sticky;
  top: 0;
  z-index: 3;
  box-shadow: 0 12px 30px var(--shadow);
}

.player.hybrid .playback-card .world {
  height: 102px;
  padding: 16px 22px;
}

.player.hybrid .playback-card h2 {
  font-size: 23px;
  margin-bottom: 0;
}

.player.hybrid .playback-controls {
  padding: 12px 22px;
}

.player.hybrid .playback-controls .progress {
  margin-top: 12px;
}

.player.hybrid .play {
  width: 48px;
  height: 48px;
}

.player #along .word {
  scroll-margin-top: 270px;
}

/* Persistent mini player */
body.has-player {
  padding-bottom: 195px;
}

body {
  padding-bottom: 110px;
}

#mini,
.mini-player {
  position: fixed;
  bottom: calc(86px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 12px 44px var(--shadow);
  z-index: 17;
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.mini-row {
  display: flex;
  align-items: center;
  padding: 10px;
  gap: 12px;
}

.mini-open {
  border: 0;
  background: none;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  flex: 1;
  min-width: 0;
  padding: 0;
}

.mini-open img,
.mini-art {
  width: 45px;
  height: 52px;
  object-fit: cover;
  border-radius: 7px;
}

.mini-open > span {
  min-width: 0;
}

.mini-open strong {
  font-size: 13px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-open small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.mini-toggle {
  border: 0;
  border-radius: 50%;
  background: var(--text);
  color: var(--accent-contrast);
  width: 44px;
  height: 44px;
  padding: 0;
}

.mini-close {
  border: 0;
  background: none;
  font-size: 18px;
  padding: 8px;
}

.mini-line {
  height: 2px;
  background: var(--line);
}

.mini-line i {
  display: block;
  background: var(--text);
  height: 100%;
  width: 0;
}

/* Full player / dialog */
#player {
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 24px;
  width: min(600px, calc(100% - 32px));
  max-height: 92dvh;
  padding: 0;
  overscroll-behavior: contain;
}

#player::backdrop,
.full-player::backdrop {
  background: #000000a8;
  backdrop-filter: blur(8px);
}

.np-inner {
  padding: 24px 32px 32px;
}

.np-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.np-header button {
  border: 0;
  background: none;
}

.np-header span {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.np-art {
  width: 100%;
  height: 260px;
  object-fit: cover;
  border-radius: 16px;
  display: block;
  margin-bottom: 24px;
}

.np-title {
  font: 650 28px/1.18 var(--font-display);
  letter-spacing: -0.035em;
  margin: 6px 0 10px;
}

.np-book {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 18px;
}

.np-transport {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  margin: 22px 0;
}

.np-transport button {
  border: 0;
  background: none;
  font-size: 23px;
}

.np-transport .play {
  background: var(--text);
  color: var(--accent-contrast);
  width: 64px;
  height: 64px;
}

.np-tabs {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.np-tabs button {
  flex: 1;
  background: none;
  border: 0;
  font-size: 13px;
  padding: 10px 6px;
}

.np-tabs button.on {
  background: var(--soft);
  color: var(--text);
}

#player .progress {
  margin: 14px 0 10px;
}

#player .prose {
  font-size: 21px;
  line-height: 1.9;
  min-height: 0;
}

#player.reading .np-art {
  height: 90px;
  margin-bottom: 18px;
}

#player.reading .np-title {
  font-size: 24px;
}

.np-panel {
  margin-top: 22px;
}

.queue-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 16px 0;
}

.queue-row small {
  display: block;
  color: var(--muted);
}

.queue-row.current {
  color: var(--text);
  font-weight: 680;
}

.np-panel label {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 450;
}

.np-panel input {
  width: 18px;
  height: 18px;
  accent-color: var(--text);
}

.np-panel .listening-options {
  max-width: none;
}

.np-status {
  min-height: 22px;
}

.np-sleep select {
  width: 100%;
  margin-top: 10px;
}

#player.night {
  --bg: #050505;
  --panel: #0d0d0d;
  --panel-raised: #121212;
  --input: #101010;
  --text: #d7d7d2;
  --muted: #81817c;
  --accent: #d7d7d2;
}

.np-sync {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 18px;
}

/* Bottom navigation */
#nav,
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 16;
  display: flex;
  justify-content: center;
  gap: 0;
  flex: initial;
  height: calc(78px + env(safe-area-inset-bottom));
  padding: 7px 16px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(20px);
}

#nav button,
.bottom-nav a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3px;
  width: min(190px, 33%);
  flex: initial;
  font-size: 11px;
  color: var(--muted);
  border: 0;
  background: none;
  padding: 4px;
  min-height: 54px;
  text-decoration: none;
}

#nav button span,
.bottom-nav a > span:first-child {
  font-size: 25px;
  line-height: 1.1;
}

#nav button.active,
#nav button[aria-expanded="true"],
.bottom-nav a.active {
  color: var(--text);
}

#toast {
  bottom: calc(176px + env(safe-area-inset-bottom));
}

/* Create sheet */
#sheet {
  position: fixed;
  inset: auto 0 calc(85px + env(safe-area-inset-bottom));
  margin: 0 auto;
  width: min(600px, calc(100% - 24px));
  max-height: 70dvh;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel-raised);
  color: var(--text);
  box-shadow: 0 18px 60px var(--shadow);
}

#sheet::backdrop {
  background: #00000070;
  backdrop-filter: blur(4px);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.sheet-head h2 {
  font-size: 26px;
  margin: 0;
}

.sheet-head button {
  border: 0;
  background: none;
}

.new-world {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  background: none;
  border: 0;
  padding: 16px 0;
  text-align: left;
}

.new-world > span:first-child {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--soft);
  font-size: 27px;
  color: var(--text);
}

.new-world strong {
  display: block;
}

.new-world small {
  display: block;
  color: var(--muted);
}

.sheet-book {
  border-top: 1px solid var(--line);
  padding: 15px 0;
}

.sheet-book summary {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.sheet-book summary::after {
  content: '⌄';
  margin-left: auto;
  color: var(--muted);
}

.sheet-book summary img,
.sheet-art {
  width: 36px;
  height: 48px;
  object-fit: cover;
  border-radius: 5px;
}

.sheet-book summary small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.sheet-chapters {
  padding: 8px 0 0 48px;
}

.sheet-chapters button {
  display: block;
  text-align: left;
  width: 100%;
  border: 0;
  background: none;
  padding: 11px 0;
  font-size: 13px;
}

.sheet-chapters button.add-chapter {
  color: var(--text);
  font-weight: 700;
}

.sheet-chapters .index {
  color: var(--muted);
  margin-right: 10px;
}

/* Lyrics / reading screen */
#player.reading {
  width: min(820px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  border-radius: 0;
  background: #111111;
  --text: #f5f5f2;
  --muted: #8b8b86;
  --accent: #ffffff;
  color: var(--text);
  overflow: hidden;
}

#player.reading.night {
  background: #050505;
}

.lyrics-screen {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.lyrics-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 26px 16px;
  border-bottom: 1px solid #ffffff14;
}

.lyrics-top > div {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.lyrics-top strong {
  display: block;
  font-size: 15px;
}

.lyrics-top small {
  color: var(--muted);
  font-size: 11px;
}

.lyrics-top button {
  border: 0;
  background: none;
  padding: 8px;
  font-size: 22px;
}

.lyrics-scroll {
  overflow-y: auto;
  padding: 30px 30px 100px;
  scrollbar-width: thin;
  overscroll-behavior: contain;
  mask-image: linear-gradient(
    to bottom,
    transparent,
    black 18px,
    black calc(100% - 35px),
    transparent
  );
}

.lyric-line {
  font: 680 clamp(25px, 3.8vw, 37px) / 1.5 var(--font-display);
  letter-spacing: -0.035em;
  color: #777772;
  margin-bottom: 30px;
  transition: color 0.2s;
}

.lyric-line.current-line {
  color: #ffffff;
}

.lyric-line.past-line {
  color: #adada7;
}

.lyric-line .word.active-word {
  background: none;
  box-shadow: none;
  color: #ffffff;
  text-decoration: underline;
  text-decoration-color: #ffffff70;
  text-underline-offset: 7px;
}

.lyrics-bottom {
  padding: 12px 30px calc(18px + env(safe-area-inset-bottom));
  background: inherit;
  border-top: 1px solid #ffffff14;
}

.lyrics-bottom .progress {
  margin: 4px 0 8px !important;
}

.lyrics-bottom .np-transport {
  margin: 12px 0 0;
}

.lyrics-bottom .np-status {
  font-size: 11px;
  min-height: 18px;
}

.lyrics-follow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  margin-bottom: 14px;
  gap: 12px;
}

.lyrics-follow button {
  background: none;
  border: 1px solid #ffffff2d;
  color: inherit;
  font-size: 11px;
  padding: 6px 10px;
}

.lyrics-follow #sync-note {
  color: var(--muted);
  font-size: 11px;
}

.lyrics-bottom .np-transport button {
  color: var(--text);
}

.lyrics-bottom .np-transport .play {
  background: #ffffff;
  color: #0a0a0a;
}

.lyrics-bottom .np-transport button:disabled {
  opacity: 0.4;
}

/* Unified player */
#player.unified {
  width: min(700px, 100%);
  height: 94dvh;
  max-height: 94dvh;
  margin: auto;
  border-radius: 22px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

#player.unified.reading {
  background: var(--bg);
}

.unified-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.unified-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.unified-header > div {
  flex: 1;
  text-align: center;
  min-width: 0;
}

.unified-header strong {
  display: block;
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: -0.015em;
}

.unified-header small {
  font-size: 11px;
  color: var(--muted);
}

.unified-header button {
  border: 0;
  background: none;
  font-size: 22px;
  padding: 10px;
  flex-shrink: 0;
}

.unified-content {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: 24px 28px;
  scroll-behavior: auto;
}

.unified-content.art-view {
  display: flex;
  align-items: center;
  justify-content: center;
}

.unified-art {
  width: 100%;
  height: 100%;
  max-height: 430px;
  object-fit: cover;
  border-radius: 18px;
}

.unified-content .np-panel {
  margin-top: 0;
}

.unified-content h2 {
  margin: 4px 0 20px;
  font-size: 28px;
}

.unified-content .lyric-line {
  font-size: clamp(24px, 3.7vw, 34px);
  margin-bottom: 28px;
}

.unified-footer {
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  padding: 10px 24px calc(14px + env(safe-area-inset-bottom));
  backdrop-filter: blur(16px);
}

.unified-footer .np-tabs {
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  gap: 8px;
}

.unified-footer .np-tabs button {
  padding: 10px 5px;
  font-size: 13px;
}

.unified-footer .progress {
  margin: 10px 0 8px !important;
}

.unified-footer .np-transport {
  margin: 8px 0 0;
  gap: 10px;
  justify-content: space-evenly;
}

.unified-footer .np-transport .play {
  width: 54px;
  height: 54px;
  font-size: 22px;
}

.unified-footer .np-transport button {
  padding: 8px;
  min-width: 44px;
  color: var(--text);
}

.unified-footer .np-transport .play {
  color: var(--accent-contrast);
}

.unified-footer .np-status {
  font-size: 11px;
  min-height: 18px;
  margin-top: 4px;
  text-align: center;
}

.unified-follow {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 18px;
}

.unified-follow #sync-note {
  font-size: 11px;
  color: var(--muted);
}

.unified-follow button {
  font-size: 11px;
  white-space: nowrap;
  padding: 6px 9px;
}

.transport-icon {
  width: 22px;
  height: 22px;
  display: block;
  fill: currentColor;
}

.unified-content .np-sleep label {
  font-size: 15px;
}

.unified-content .np-sleep select {
  padding: 14px;
}

.unified-content .queue-row {
  font-size: 14px;
}

.unified-content .np-panel label {
  margin-top: 8px;
}

#player.unified,
#player.unified.reading {
  --bg: #090909;
  --panel: #111111;
  --panel-raised: #171717;
  --input: #151515;
  --line: #292929;
  --text: #f5f5f2;
  --muted: #90908b;
  --accent: #f5f5f2;
  --accent-contrast: #090909;
}

body.light #player.unified {
  --bg: #f7f7f4;
  --panel: #ffffff;
  --panel-raised: #ffffff;
  --input: #f1f1ed;
  --line: #deded8;
  --text: #121212;
  --muted: #6f6f69;
  --accent: #111111;
  --accent-contrast: #ffffff;
}

#player.unified.night,
body.light #player.unified.night {
  --bg: #050505;
  --panel: #0d0d0d;
  --panel-raised: #111111;
  --input: #101010;
  --text: #d4d4cf;
  --muted: #81817c;
  --accent: #d4d4cf;
  --accent-contrast: #050505;
}

.unified-content .lyric-line {
  color: var(--muted);
}

.unified-content .lyric-line.current-line {
  color: var(--text);
}

.unified-content .lyric-line.past-line {
  color: color-mix(in srgb, var(--muted) 84%, var(--text));
}

.unified-content .lyric-line .word.active-word {
  color: var(--text);
  text-decoration-color: color-mix(in srgb, var(--text) 55%, transparent);
}

/* Shelf / book detail */
.shelf-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.shelf-heading h1 {
  font-size: 34px;
  margin: 0;
}

.book-tile {
  text-align: left;
  padding: 18px;
  display: block;
  width: 100%;
}

.book-tile .world {
  margin-bottom: 14px;
  height: 210px;
}

.book-title {
  display: block;
  font: 650 25px/1.18 var(--font-display);
  letter-spacing: -0.035em;
  margin-top: 8px;
}

.tile-caption {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
}

.tile-caption > span:last-child {
  color: var(--muted);
  font-size: 24px;
}

.book-detail {
  max-width: 760px;
  margin: auto;
}

.book-heading {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 0 0 24px;
}

.book-heading img,
.book-heading-art {
  width: 64px;
  height: 86px;
  object-fit: cover;
  border-radius: 8px;
}

.book-heading h1 {
  font-size: 32px;
  margin: 0 0 8px;
}

.book-heading p {
  margin: 0;
}

.chapter-list {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 4px 20px;
  background: var(--panel);
}

.chapter-link {
  display: flex;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: none;
  padding: 20px 0;
  gap: 16px;
}

.chapter-link:last-child {
  border-bottom: 0;
}

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

.chapter-info {
  display: block;
  flex: 1;
  min-width: 0;
}

.chapter-info strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}

.chapter-info .small {
  display: block;
  font-size: 12px;
}

.chapter-chevron {
  color: var(--muted);
  font-size: 24px;
}

.empty-book {
  padding: 18px 0;
}

.book-crumb {
  padding: 0 !important;
  border: 0;
  background: none !important;
  text-align: left;
  color: var(--muted);
  font: 760 10px/1.5 var(--font-ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.book-crumb:hover {
  color: var(--text);
  text-decoration: underline;
}

.chapter-kicker {
  display: block;
  font-size: 11px;
  margin-top: 4px;
}

.chapter-end {
  align-self: center;
  padding: 10px 0;
}

.contextual-create {
  border-bottom: 1px solid var(--line);
  padding-top: 6px;
}

.contextual-create strong {
  color: var(--text);
}

#nav button .nav-label {
  font-size: 11px;
  line-height: 1.4;
}

.list-end-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  width: 100%;
  margin: 22px 0 0;
  border-radius: 14px;
  font-weight: 680;
}

.list-end-action:not(.primary) {
  background: var(--panel);
  color: var(--text);
  border: 1px dashed var(--line-strong);
}

.list-end-action:not(.primary):hover {
  border-color: var(--text);
}

.list-end-action > span {
  font-size: 20px;
}

/* Application adapter: prototype visuals with authenticated, persisted data. */
.app-header {
  max-width: 1100px;
  margin: auto;
  border: 0;
  height: 78px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.app-header .brand {
  color: var(--text);
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header #logout {
  font-size: 13px;
}

.app-header #theme {
  font-size: 18px;
}

#notice {
  max-width: 700px;
  margin: auto;
  padding: 0 28px;
  color: var(--muted);
}

#notice button {
  margin-left: 10px;
}

.current-book,
.book-tile,
.chapter-link,
.back-link {
  text-decoration: none;
}

.current-book-art {
  width: 52px;
  height: 68px;
  object-fit: cover;
  border-radius: 7px;
}

.chapter-art {
  width: 64px;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.tonight .button.primary {
  display: block;
  text-align: center;
  padding: 16px;
  font-size: 15px;
  margin-top: 18px;
}

.last-chapter {
  text-align: center;
  text-decoration: none;
}

.book-tile,
.chapter-link {
  color: var(--text);
  text-decoration: none;
}

.reading-nav a {
  text-decoration: none;
}

.full-player.unified {
  padding: 0;
  border: 0;
}

.unified-footer input[type='range'] {
  display: block;
  width: 100%;
  height: 24px;
  margin: 2px 0;
  padding: 0;
  background: transparent;
  accent-color: var(--text);
  cursor: pointer;
}

#sheet button {
  margin: 5px;
}

.auth {
  max-width: 440px;
  margin: 3rem auto;
}

.check {
  display: flex;
  gap: 10px;
}

.check input {
  width: auto;
}

.ingredient-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}

.ingredient-actions .button {
  margin: 0;
}

.recipe-world {
  height: 340px;
}

.recipe .wide + .wide {
  margin-top: 12px;
}

.speed-control {
  position: relative;
}

.speed-glyph {
  display: grid;
  place-items: center;
  min-width: 42px;
}

.speed-glyph svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.speed-glyph circle {
  transform: rotate(-90deg);
  transform-origin: 14px 14px;
  stroke-dasharray: 62.832;
}

.speed-track {
  opacity: 0.2;
}

.speed-fill {
  stroke: var(--text);
  transition: stroke-dashoffset 0.2s;
}

.speed-glyph small {
  font-size: 10px;
  line-height: 1;
  color: inherit;
  margin-top: 2px;
}

.timed-story .word {
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}

.timed-story .active-word {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 10%, transparent);
  text-decoration: underline;
  text-underline-offset: 5px;
}

.timed-story .current-line {
  color: var(--text);
}

.unified-follow > span:last-child {
  display: flex;
  gap: 6px;
}

.unified-header .transport-icon,
.mini-player .transport-icon {
  width: 22px;
  height: 22px;
}

.quick-modifiers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 2px;
}

.quick-modifiers label {
  margin: 0;
}

.quick-modifiers select {
  min-height: 44px;
  background: var(--panel);
  font-weight: 650;
}

.reading-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  border-top: 1px solid var(--line);
  margin-top: 38px;
  padding-top: 22px;
}

.reader-direction {
  min-width: 0;
}

.reader-direction.next {
  text-align: right;
}

.reader-direction a {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  padding: 12px;
  border-radius: 12px;
}

.reader-direction.next a {
  justify-content: flex-end;
}

.reader-direction small,
.reader-direction strong {
  display: block;
}

.reader-direction small {
  color: var(--muted);
  font-size: 11px;
}

.reader-direction strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-end {
  display: block;
  color: var(--muted);
  padding: 12px;
  font-size: 12px;
}

.nav-icon {
  width: 27px;
  height: 27px;
}

.mini-toggle,
.np-transport .play {
  display: grid;
  place-items: center;
}

.mini-toggle .transport-icon,
.np-transport .play .transport-icon {
  margin: auto;
}

.button,
button,
a.chapter-link,
a.book-tile,
.reader-direction a,
.np-tabs button,
.bottom-nav a {
  transition:
    background-color 0.15s,
    color 0.15s,
    border-color 0.15s,
    transform 0.08s,
    box-shadow 0.15s;
}

.button:hover,
button:not(:disabled):hover,
.reader-direction a:hover,
.bottom-nav a:hover {
  background-color: color-mix(in srgb, var(--text) 7%, transparent);
}

.primary:hover,
.play:hover,
.mini-toggle:hover,
.np-transport .play:hover {
  background-color: color-mix(in srgb, var(--text) 88%, var(--bg));
}

.button:active,
button:not(:disabled):active,
a.chapter-link:active,
a.book-tile:active,
.reader-direction a:active,
.bottom-nav a:active {
  transform: translateY(1px) scale(0.99);
}

.np-tabs button.on,
.bottom-nav .active,
.chips .selected {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 28%, transparent);
}

/* Responsive */
@media (max-width: 760px) {
  header {
    padding: 0 20px;
    height: 80px;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .brand {
    font-size: 21px;
    flex: initial;
  }

  nav {
    order: initial;
    flex-basis: auto;
    width: auto;
    gap: 0;
  }

  nav button {
    flex: initial;
    padding: 8px;
  }

  main {
    margin-top: 26px;
    padding: 0 18px 60px;
  }

  .grid,
  .book-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 22px;
  }

  .intro {
    align-items: start;
    gap: 12px;
  }

  .intro .pill {
    display: none;
  }

  .world {
    height: 205px;
  }

  .full {
    grid-template-columns: 1fr;
  }

  .prose {
    font-size: 19px;
  }

  .tonight {
    margin-top: 24px;
  }

  .tonight h1 {
    font-size: 33px;
  }

  .current-book {
    margin-bottom: 36px;
  }

  .tonight summary > span {
    font-size: 11px;
  }

  .read h1 {
    font-size: 32px;
  }
}

@media (max-width: 600px) {
  #player {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    max-width: 100%;
    border: 0;
    border-radius: 0;
    margin: 0;
  }

  .np-inner {
    padding: 20px 24px calc(28px + env(safe-area-inset-bottom));
  }

  .np-art {
    height: min(34dvh, 310px);
  }

  .mini-open strong {
    max-width: 230px;
  }

  .np-header {
    margin-bottom: 18px;
  }

  #player.unified {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
  }

  .unified-header {
    padding: 16px 16px 12px;
  }

  .unified-header strong {
    font-size: 15px;
  }

  .unified-content {
    padding: 22px 24px;
  }

  .unified-footer {
    padding: 8px 24px calc(12px + env(safe-area-inset-bottom));
  }

  header,
  .app-header {
    height: 68px;
  }

  .app-header {
    padding: 0 20px;
  }

  .shelf-heading h1 {
    font-size: 30px;
  }

  .book-heading {
    gap: 15px;
    margin-bottom: 22px;
  }

  .book-heading h1 {
    font-size: 27px;
  }

  .book-heading img,
  .book-heading-art {
    width: 52px;
    height: 70px;
  }

  .book-tile .world {
    height: 180px;
  }

  .book-grid {
    gap: 18px;
  }

  .book-tile {
    padding: 14px;
  }

  .chapter-list {
    padding: 4px 16px;
  }

  .chapter-link {
    gap: 12px;
  }

  .chapter-link .number {
    font-size: 23px;
  }

  .read .chapter-banner {
    margin-top: 0;
  }
}

@media (max-width: 480px) {
  #sheet {
    padding: 20px;
  }

  .lyrics-top {
    padding: 18px 18px 12px;
  }

  .lyrics-scroll {
    padding: 22px 24px 70px;
  }

  .lyrics-bottom {
    padding-left: 24px;
    padding-right: 24px;
  }

  .lyrics-follow {
    align-items: flex-start;
  }

  .lyrics-follow #sync-note {
    max-width: 65%;
  }

  .chapter-banner {
    padding: 18px 16px;
    gap: 14px;
  }

  .chapter-banner img,
  .chapter-art {
    width: 45px;
    height: 64px;
  }

  .read .chapter-banner h1 {
    font-size: 24px;
  }

  .chapter-banner .eyebrow {
    font-size: 9px;
  }

  .chapter-banner #duration {
    font-size: 11px;
  }

  .reader-tools {
    padding: 10px;
    gap: 2px;
    scroll-margin-top: 0;
  }

  .reader-tools > button {
    padding: 10px 12px;
  }

  .reader-tools .change-menu summary {
    padding: 10px 8px;
  }

  .tool-note {
    display: none;
  }

  .playback-controls {
    padding: 16px;
  }

  .ingredient-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .ingredient-actions > * {
    width: 100%;
    text-align: center;
  }

  .reading-nav {
    gap: 8px;
  }

  .reader-direction a {
    padding: 10px 6px;
  }

  .reader-direction strong {
    font-size: 13px;
  }
}

@media (max-width: 380px) {
  .unified-footer {
    padding-left: 12px;
    padding-right: 12px;
  }

  .unified-footer .np-transport {
    gap: 2px;
  }

  .unified-footer .np-transport button {
    min-width: 40px;
    padding: 5px;
  }

  .speed-glyph svg {
    width: 30px;
    height: 30px;
  }
}

@media (max-height: 560px) {
  .unified-header {
    padding: 6px 12px;
  }

  .unified-header small {
    display: none;
  }

  .unified-footer {
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .unified-footer .np-tabs {
    margin-bottom: 0;
  }

  .unified-footer .np-tabs button {
    padding: 4px;
  }

  .unified-footer .np-transport {
    margin: 0;
  }

  .unified-footer .np-transport .play {
    width: 38px;
    height: 38px;
  }

  .unified-footer .np-status {
    display: none;
  }

  .unified-content {
    padding: 12px 20px;
  }
}

@media (max-height: 550px) {
  .player.hybrid .playback-card {
    position: static;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  .button,
  button,
  a {
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .button:active,
  button:not(:disabled):active,
  a:active {
    transform: none !important;
  }
}

/* ========================================================================== 
   PERSONAL STORY APP PASS
   Warm monochrome, softer hierarchy, friendlier navigation and reading UI.
   This layer intentionally keeps the existing markup and behavior intact.
   ========================================================================== */

:root {
  --bg: #171614;
  --panel: #1f1d1a;
  --panel-raised: #26231f;
  --input: #24211d;
  --line: #37332d;
  --line-strong: #4a443c;
  --text: #f5f1e9;
  --muted: #aaa39a;
  --accent: #f5f1e9;
  --accent-contrast: #171614;
  --soft: #2c2924;
  --shadow: #00000052;

  --font-ui: "Avenir Next", "SF Pro Rounded", "Segoe UI Variable Text",
    "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: "Avenir Next", "SF Pro Rounded", "Segoe UI Variable Display",
    "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-reading: Charter, "Iowan Old Style", "Palatino Linotype", Palatino,
    Georgia, serif;

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
}

body.light {
  --bg: #f8f5ef;
  --panel: #fffdfa;
  --panel-raised: #ffffff;
  --input: #f1ede6;
  --line: #e4ded4;
  --line-strong: #d5cdc1;
  --text: #1b1a18;
  --muted: #777168;
  --accent: #1b1a18;
  --accent-contrast: #fffdfa;
  --soft: #f0ebe3;
  --shadow: #3d35280f;
}

html,
body {
  background-color: var(--bg);
}

body {
  background:
    radial-gradient(circle at 18% -8%, color-mix(in srgb, var(--panel) 90%, transparent) 0, transparent 29rem),
    radial-gradient(circle at 82% 2%, color-mix(in srgb, var(--soft) 65%, transparent) 0, transparent 25rem),
    var(--bg);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.006em;
  padding-bottom: 118px;
}

body.has-player {
  padding-bottom: 218px;
}

/* Softer, more human typography. */
h1 {
  font-weight: 680;
  letter-spacing: -0.045em;
}

h2 {
  font-weight: 650;
}

h3,
.chapter-info strong,
.mini-open strong {
  font-weight: 650;
}

.eyebrow {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
}

p,
.small,
.muted {
  color: var(--muted);
}

/* Header: less account-console, more personal app. */
header,
.app-header {
  max-width: 1040px;
  height: 82px;
  padding: 0 24px;
}

.brand,
.app-header .brand {
  font-size: 24px;
  font-weight: 720;
  letter-spacing: -0.045em;
}

.header-actions {
  gap: 6px;
}

.app-header #theme {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.app-header #theme:hover {
  background: var(--soft);
}

.app-header #logout {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 999px;
}

.app-header #logout:hover {
  color: var(--text);
  background: var(--soft);
}

main {
  max-width: 1080px;
  margin-top: 12px;
  padding-bottom: 150px;
}

/* Notices should read as reassuring status, not an alert banner. */
#notice {
  max-width: 820px;
  padding: 0 24px;
  margin: 8px auto 14px;
  color: var(--muted);
  font-size: 14px;
}

#notice:empty {
  display: none;
}

.notice {
  border: 0;
  background: var(--soft);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
}

/* Buttons: rounded and tactile without looking like enterprise controls. */
button,
.button {
  border-radius: 14px;
  font-weight: 600;
}

.primary {
  background: var(--text);
  color: var(--accent-contrast);
  border-color: var(--text);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--shadow) 80%, transparent);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--text) 72%, transparent);
  outline-offset: 3px;
}

/* General cards: paper-like rather than dashboard-like. */
.card {
  border-color: color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 24px;
  box-shadow:
    0 1px 2px color-mix(in srgb, var(--shadow) 24%, transparent),
    0 16px 48px color-mix(in srgb, var(--shadow) 48%, transparent);
}

/* Book detail: let the book feel like the center of the page. */
.book-detail {
  max-width: 820px;
  padding-top: 10px;
}

.book-heading {
  gap: 24px;
  margin: 8px 0 30px;
  align-items: center;
}

.book-heading img,
.book-heading-art {
  width: 82px;
  height: 110px;
  border-radius: 14px;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--shadow) 46%, transparent);
}

.book-heading h1 {
  font-size: clamp(34px, 5vw, 46px);
  line-height: 1.02;
  margin: 4px 0 10px;
  font-weight: 700;
}

.book-heading p {
  font-size: 15px;
  color: var(--muted);
}

.book-crumb {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.1em;
}

/* Chapters: reading list, not data table. */
.chapter-list {
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 24px;
  background: var(--panel);
  box-shadow:
    0 1px 2px color-mix(in srgb, var(--shadow) 20%, transparent),
    0 14px 42px color-mix(in srgb, var(--shadow) 35%, transparent);
}

.chapter-link {
  align-items: center;
  gap: 16px;
  padding: 15px 14px;
  margin: 2px 0;
  border: 0;
  border-radius: 17px;
}

.chapter-link:last-child {
  border: 0;
}

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

.number,
.chapter-link .number {
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--muted);
  font: 650 15px/1 var(--font-display);
  letter-spacing: -0.02em;
}

.chapter-info strong {
  font-size: 16px;
  line-height: 1.35;
  margin-bottom: 5px;
}

.chapter-info .small {
  font-size: 12.5px;
  color: var(--muted);
}

.chapter-chevron {
  font-size: 20px;
  opacity: 0.72;
  padding-right: 4px;
}

/* The create action should invite, not dominate the whole screen. */
.list-end-action {
  width: fit-content;
  min-width: 330px;
  min-height: 58px;
  margin: 26px auto 0;
  padding: 0 28px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
}

.list-end-action > span {
  font-size: 21px;
  line-height: 1;
}

.list-end-action.primary {
  box-shadow: 0 12px 34px color-mix(in srgb, var(--shadow) 58%, transparent);
}

.list-end-action:not(.primary) {
  border-style: solid;
  background: var(--panel);
}

/* Shelf tiles get a softer, personal-library feel. */
.book-grid {
  gap: 20px;
}

.book-tile {
  border-radius: 22px;
  border: 1px solid transparent;
  background: transparent;
  padding: 12px;
}

.book-tile:hover {
  background: var(--panel);
  border-color: var(--line);
}

.book-title {
  font-size: 23px;
  font-weight: 680;
}

.shelf-heading {
  margin-bottom: 28px;
}

/* Inputs: warm paper fields instead of admin forms. */
input,
select,
textarea {
  border-radius: 14px;
  border-color: var(--line);
  background: var(--input);
  box-shadow: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--line-strong);
}

.chips button {
  border-radius: 999px;
}

.chips button.selected {
  background: var(--text);
  color: var(--accent-contrast);
}

/* Mini player: a compact floating companion. */
#mini,
.mini-player {
  bottom: calc(104px + env(safe-area-inset-bottom));
  width: min(700px, calc(100% - 32px));
  border-radius: 22px;
  border-color: color-mix(in srgb, var(--line) 78%, transparent);
  background: color-mix(in srgb, var(--panel-raised) 94%, transparent);
  box-shadow:
    0 2px 5px color-mix(in srgb, var(--shadow) 25%, transparent),
    0 18px 54px color-mix(in srgb, var(--shadow) 50%, transparent);
}

.mini-row {
  padding: 10px 12px;
  gap: 12px;
}

.mini-open {
  gap: 12px;
}

.mini-open img,
.mini-art {
  width: 52px;
  height: 52px;
  border-radius: 12px;
}

.mini-open strong {
  font-size: 14px;
}

.mini-open small {
  margin-top: 2px;
  font-size: 11.5px;
}

.mini-toggle {
  width: 48px;
  height: 48px;
  background: var(--text);
  color: var(--accent-contrast);
  box-shadow: none;
}

.mini-close {
  color: var(--muted);
}

.mini-close:hover {
  color: var(--text);
  background: transparent !important;
}

/* Desktop navigation becomes a light floating dock instead of an app console bar. */
#nav,
.bottom-nav {
  left: 50%;
  right: auto;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  height: 72px;
  padding: 7px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 22px;
  background: color-mix(in srgb, var(--panel-raised) 93%, transparent);
  box-shadow:
    0 2px 4px color-mix(in srgb, var(--shadow) 22%, transparent),
    0 16px 46px color-mix(in srgb, var(--shadow) 45%, transparent);
  backdrop-filter: blur(18px);
}

#nav button,
.bottom-nav a {
  width: 33.333%;
  min-height: 56px;
  border-radius: 16px;
  gap: 2px;
  font-size: 11px;
}

#nav button span,
.bottom-nav a > span:first-child {
  font-size: 23px;
}

#nav button.active,
#nav button[aria-expanded="true"],
.bottom-nav a.active {
  color: var(--text);
  background: var(--soft);
  box-shadow: none;
}

#nav button:hover,
.bottom-nav a:hover {
  background: color-mix(in srgb, var(--soft) 72%, transparent);
}

#nav button .nav-label {
  font-size: 11px;
}

#toast {
  bottom: calc(190px + env(safe-area-inset-bottom));
}

/* Create sheet now visually belongs to the floating dock. */
#sheet {
  inset: auto 0 calc(104px + env(safe-area-inset-bottom));
  border-radius: 26px;
  background: var(--panel-raised);
  box-shadow: 0 24px 70px color-mix(in srgb, var(--shadow) 62%, transparent);
}

/* Full player and reading mode use the same warmer monochrome system. */
#player.unified,
#player.unified.reading {
  --bg: #171614;
  --panel: #1f1d1a;
  --panel-raised: #26231f;
  --input: #24211d;
  --line: #37332d;
  --text: #f5f1e9;
  --muted: #aaa39a;
  --accent: #f5f1e9;
  --accent-contrast: #171614;
}

body.light #player.unified {
  --bg: #f8f5ef;
  --panel: #fffdfa;
  --panel-raised: #ffffff;
  --input: #f1ede6;
  --line: #e4ded4;
  --text: #1b1a18;
  --muted: #777168;
  --accent: #1b1a18;
  --accent-contrast: #fffdfa;
}

#player.night,
#player.unified.night,
body.light #player.unified.night {
  --bg: #11100f;
  --panel: #191816;
  --panel-raised: #201e1b;
  --input: #1d1b18;
  --line: #302d28;
  --text: #ded9cf;
  --muted: #938d84;
  --accent: #ded9cf;
  --accent-contrast: #11100f;
}

#player,
#player.unified {
  border-radius: 28px;
  border-color: var(--line);
  box-shadow: 0 28px 90px #00000042;
}

.np-tabs button,
.unified-footer .np-tabs button {
  border-radius: 12px;
}

.np-tabs button.on,
.unified-footer .np-tabs button.on {
  background: var(--soft);
  box-shadow: none;
}

.prose,
.story-editor,
#editor {
  font-family: var(--font-reading);
}

/* Keep interactions subtle; this is a bedtime product, not a control panel. */
.button:hover,
button:not(:disabled):hover,
.reader-direction a:hover,
.bottom-nav a:hover {
  background-color: color-mix(in srgb, var(--soft) 74%, transparent);
}

.primary:hover,
.play:hover,
.mini-toggle:hover,
.np-transport .play:hover {
  background-color: color-mix(in srgb, var(--text) 88%, var(--bg));
}

/* Mobile keeps the familiar edge-to-edge navigation while retaining the softer styling. */
@media (max-width: 600px) {
  body {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  body.has-player {
    padding-bottom: calc(184px + env(safe-area-inset-bottom));
  }

  header,
  .app-header {
    height: 68px;
    padding-left: 18px;
    padding-right: 18px;
  }

  .brand,
  .app-header .brand {
    font-size: 21px;
  }

  main {
    padding-left: 18px;
    padding-right: 18px;
    padding-bottom: 110px;
  }

  #notice {
    padding: 0 18px;
  }

  .book-detail {
    padding-top: 0;
  }

  .book-heading {
    gap: 16px;
    margin: 4px 0 24px;
  }

  .book-heading img,
  .book-heading-art {
    width: 62px;
    height: 84px;
    border-radius: 11px;
  }

  .book-heading h1 {
    font-size: 30px;
    margin-bottom: 7px;
  }

  .chapter-list {
    padding: 6px;
    border-radius: 20px;
  }

  .chapter-link {
    padding: 14px 10px;
    gap: 12px;
  }

  .number,
  .chapter-link .number {
    flex-basis: 42px;
    width: 42px;
    height: 42px;
    min-width: 42px;
    font-size: 14px;
  }

  .chapter-info strong {
    font-size: 15px;
  }

  .list-end-action {
    width: 100%;
    min-width: 0;
    min-height: 56px;
    margin-top: 20px;
  }

  #nav,
  .bottom-nav {
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    height: calc(76px + env(safe-area-inset-bottom));
    padding: 6px 10px calc(7px + env(safe-area-inset-bottom));
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    box-shadow: 0 -8px 30px color-mix(in srgb, var(--shadow) 30%, transparent);
  }

  #nav button,
  .bottom-nav a {
    min-height: 56px;
    border-radius: 14px;
  }

  #mini,
  .mini-player {
    bottom: calc(84px + env(safe-area-inset-bottom));
    width: calc(100% - 20px);
    border-radius: 18px;
  }

  .mini-open img,
  .mini-art {
    width: 46px;
    height: 46px;
    border-radius: 10px;
  }

  .mini-toggle {
    width: 44px;
    height: 44px;
  }

  #sheet {
    inset: auto 10px calc(84px + env(safe-area-inset-bottom));
    width: auto;
    border-radius: 24px;
  }

  #toast {
    bottom: calc(166px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 380px) {
  .chapter-link {
    padding-left: 8px;
    padding-right: 8px;
  }

  .chapter-chevron {
    padding-right: 0;
  }

  .app-header #logout {
    padding-left: 8px;
    padding-right: 8px;
  }
}

/* ========================================================================== 
   BEDTIME POLISH PASS
   Quieter hierarchy, reliable high-contrast actions, and a warmer atmospheric
   background. Keeps the existing markup and behavior unchanged.
   ========================================================================== */

:root {
  --bg: #11110f;
  --panel: #1a1916;
  --panel-raised: #211f1b;
  --input: #211f1b;
  --line: rgba(245, 241, 233, 0.105);
  --line-strong: rgba(245, 241, 233, 0.18);
  --text: #f3efe7;
  --text-strong: #faf7f0;
  --muted: #a8a299;
  --faint: #777168;
  --accent: #f3efe7;
  --accent-contrast: #171614;
  --soft: #26231f;
  --shadow: #0000005c;
  --primary: #f3efe7;
  --primary-hover: #fffaf1;
  --primary-text: #171614;
}

body.light {
  --bg: #f7f3ec;
  --panel: #fffdf9;
  --panel-raised: #ffffff;
  --input: #f0ece4;
  --line: rgba(27, 26, 24, 0.105);
  --line-strong: rgba(27, 26, 24, 0.18);
  --text: #1a1917;
  --text-strong: #11110f;
  --muted: #716b62;
  --faint: #999187;
  --accent: #1a1917;
  --accent-contrast: #fffdf9;
  --soft: #eee9e1;
  --shadow: #332d2414;
  --primary: #1a1917;
  --primary-hover: #090908;
  --primary-text: #fffdf9;
}

html {
  background: var(--bg);
}

body {
  color: var(--text);
  font-weight: 450;
  background:
    radial-gradient(
      900px 520px at 15% 7%,
      rgba(255, 244, 222, 0.052),
      transparent 62%
    ),
    radial-gradient(
      720px 520px at 87% 76%,
      rgba(255, 255, 255, 0.018),
      transparent 66%
    ),
    linear-gradient(180deg, #151411 0%, #11110f 52%, #0f0f0d 100%);
  background-attachment: fixed;
}

body.light {
  background:
    radial-gradient(
      900px 520px at 15% 7%,
      rgba(255, 255, 255, 0.82),
      transparent 62%
    ),
    radial-gradient(
      760px 540px at 88% 78%,
      rgba(231, 220, 201, 0.32),
      transparent 68%
    ),
    linear-gradient(180deg, #fbf8f2 0%, #f7f3ec 55%, #f3eee6 100%);
  background-attachment: fixed;
}

/* Let the story lead; utility copy should stay quiet. */
p,
.small,
.muted,
#notice,
.book-heading p,
.chapter-info .small,
.mini-open small,
.bottom-nav a,
#nav button {
  font-weight: 450;
}

.eyebrow,
.book-crumb {
  font-weight: 700;
}

/* Reduce the wall of bold text. */
h1 {
  font-weight: 650;
  letter-spacing: -0.036em;
}

h2 {
  font-weight: 620;
  letter-spacing: -0.026em;
}

h3 {
  font-weight: 600;
}

.brand,
.app-header .brand {
  font-weight: 680;
}

.book-heading h1 {
  font-size: clamp(32px, 4.2vw, 42px);
  line-height: 1.04;
  font-weight: 650;
  letter-spacing: -0.035em;
}

.chapter-info strong {
  font-size: 16px;
  font-weight: 590;
  letter-spacing: -0.012em;
}

.book-title {
  font-weight: 620;
}

.mini-open strong {
  font-weight: 590;
  letter-spacing: -0.01em;
}

.list-end-action {
  font-weight: 600;
}

#nav button,
.bottom-nav a {
  font-weight: 450;
}

#nav button.active,
#nav button[aria-expanded="true"],
.bottom-nav a.active {
  font-weight: 550;
}

/* The chapter card should feel like a soft reading surface, not a data panel. */
.chapter-list {
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  border: 1px solid var(--line);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.018),
    0 22px 64px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body.light .chapter-list {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 20px 55px rgba(65, 53, 36, 0.055);
}

.chapter-link {
  transition:
    background-color 0.16s ease,
    transform 0.08s ease;
}

.chapter-link:hover {
  background: color-mix(in srgb, var(--soft) 70%, transparent);
}

.number,
.chapter-link .number {
  background: color-mix(in srgb, var(--soft) 84%, transparent);
  color: color-mix(in srgb, var(--text) 70%, var(--muted));
  font-weight: 600;
}

/* A single deterministic primary-action treatment prevents dark-on-dark states. */
.primary,
.button.primary,
.list-end-action.primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.primary *,
.button.primary *,
.list-end-action.primary * {
  color: inherit;
}

.primary:hover,
.button.primary:hover,
.list-end-action.primary:hover {
  background: var(--primary-hover);
  color: var(--primary-text);
  border-color: transparent;
}

.primary:focus-visible,
.button.primary:focus-visible,
.list-end-action.primary:focus-visible {
  outline-color: color-mix(in srgb, var(--primary) 78%, transparent);
}

/* Disabled actions stay legible rather than collapsing into dark-on-dark. */
.primary:disabled,
.button.primary:disabled,
.list-end-action.primary:disabled {
  opacity: 1;
  cursor: default;
  background: color-mix(in srgb, var(--primary) 24%, var(--panel));
  color: color-mix(in srgb, var(--text) 55%, var(--muted));
  border: 1px solid var(--line);
  box-shadow: none;
}

body.light .primary:disabled,
body.light .button.primary:disabled,
body.light .list-end-action.primary:disabled {
  background: color-mix(in srgb, var(--primary) 10%, var(--panel));
  color: var(--muted);
}

/* Player transport receives the same contrast discipline. */
.mini-toggle,
.np-transport .play,
.unified-footer .np-transport .play {
  background: var(--primary);
  color: var(--primary-text);
  border-color: transparent;
}

.mini-toggle:hover,
.np-transport .play:hover,
.unified-footer .np-transport .play:hover {
  background: var(--primary-hover);
  color: var(--primary-text);
}

.mini-toggle:disabled,
.np-transport .play:disabled,
.unified-footer .np-transport .play:disabled {
  opacity: 1;
  background: var(--soft);
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: none;
}

/* Make floating chrome quieter than the story itself. */
#mini,
.mini-player,
#nav,
.bottom-nav {
  background: color-mix(in srgb, var(--panel-raised) 87%, transparent);
  border-color: var(--line);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

#mini,
.mini-player {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.018),
    0 18px 52px rgba(0, 0, 0, 0.26);
}

#nav,
.bottom-nav {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.018),
    0 14px 42px rgba(0, 0, 0, 0.22);
}

#nav button.active,
#nav button[aria-expanded="true"],
.bottom-nav a.active {
  background: color-mix(in srgb, var(--soft) 74%, transparent);
}

/* Keep the central CTA inviting without making it feel like a banner ad. */
.list-end-action {
  min-width: 310px;
  min-height: 56px;
  padding-inline: 26px;
}

/* Smaller visual gap between cover and title, slightly calmer cover shadow. */
.book-heading {
  gap: 22px;
}

.book-heading img,
.book-heading-art {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

body.light .book-heading img,
body.light .book-heading-art {
  box-shadow: 0 10px 28px rgba(74, 59, 38, 0.1);
}

@media (max-width: 600px) {
  .book-heading h1 {
    font-size: 29px;
    letter-spacing: -0.03em;
  }

  .chapter-info strong {
    font-size: 15px;
    font-weight: 590;
  }

  .list-end-action {
    min-width: 0;
    width: 100%;
    font-weight: 600;
  }

  #nav,
  .bottom-nav {
    background: color-mix(in srgb, var(--panel-raised) 94%, transparent);
  }
}

/* ========================================================================== 
   IMAGINATION & LIGHT-MODE UPGRADE
   Personal, warm, story-first polish. CSS-only: no decorative image assets.
   ========================================================================== */

:root {
  --warm-glow: rgba(245, 232, 205, 0.075);
  --sparkle: rgba(255, 250, 238, 0.10);
  --paper-highlight: rgba(255, 255, 255, 0.035);
}

body.light {
  --bg: #f7f2e9;
  --panel: #fffdf8;
  --panel-raised: #fffdfa;
  --input: #f2ede4;
  --line: rgba(45, 39, 31, 0.11);
  --line-strong: rgba(45, 39, 31, 0.20);
  --text: #201e1b;
  --text-strong: #151412;
  --muted: #746d64;
  --faint: #9a9288;
  --soft: #eee8de;
  --shadow: rgba(63, 52, 38, 0.09);
  --primary: #1d1b18;
  --primary-hover: #0f0e0d;
  --primary-text: #fffaf2;
  --warm-glow: rgba(222, 195, 150, 0.15);
  --sparkle: rgba(68, 56, 41, 0.055);
  --paper-highlight: rgba(255, 255, 255, 0.74);
}

/*
 * Keep the page canvas in the selected theme. Without this, a short light-mode
 * page can reveal the root dark background below its content, producing the
 * hard black band visible behind the fixed player/navigation.
 */
html,
body {
  min-height: 100%;
}

body {
  min-height: 100dvh;
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(circle at 9% 16%, var(--sparkle) 0 1px, transparent 1.45px),
    radial-gradient(circle at 88% 13%, var(--sparkle) 0 1px, transparent 1.45px),
    radial-gradient(circle at 73% 39%, color-mix(in srgb, var(--sparkle) 70%, transparent) 0 1px, transparent 1.4px),
    radial-gradient(circle at 23% 71%, color-mix(in srgb, var(--sparkle) 65%, transparent) 0 1px, transparent 1.35px),
    radial-gradient(780px 500px at 9% -2%, var(--warm-glow), transparent 68%),
    radial-gradient(620px 480px at 92% 72%, rgba(255, 255, 255, 0.018), transparent 72%),
    linear-gradient(180deg, #151411 0%, #11110f 54%, #0f0f0d 100%);
  background-attachment: fixed;
}

body.light {
  background:
    radial-gradient(circle at 9% 16%, var(--sparkle) 0 1px, transparent 1.45px),
    radial-gradient(circle at 88% 13%, var(--sparkle) 0 1px, transparent 1.45px),
    radial-gradient(circle at 73% 39%, color-mix(in srgb, var(--sparkle) 72%, transparent) 0 1px, transparent 1.4px),
    radial-gradient(circle at 23% 71%, color-mix(in srgb, var(--sparkle) 62%, transparent) 0 1px, transparent 1.35px),
    radial-gradient(880px 540px at 8% -5%, rgba(255, 255, 255, 0.92), transparent 66%),
    radial-gradient(760px 520px at 93% 73%, var(--warm-glow), transparent 72%),
    linear-gradient(180deg, #fbf8f2 0%, #f7f2e9 58%, #f3ede3 100%);
  background-attachment: fixed;
}

/* Modern browsers can also paint the root canvas correctly during theme swaps. */
html:has(body.light) {
  background: #f7f2e9;
}

/* Friendlier type: rounded display shapes, quieter weight, story serif only
   where it adds emotion rather than throughout the interface. */
:root {
  --font-ui: "Avenir Next", "Segoe UI Variable Text", Inter, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: ui-rounded, "Avenir Next", "SF Pro Rounded",
    "Segoe UI Variable Display", Inter, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-reading: Charter, "Iowan Old Style", "Palatino Linotype", Palatino,
    Georgia, serif;
}

.brand,
.app-header .brand {
  font-weight: 680;
  letter-spacing: -0.038em;
}

.brand span,
.app-header .brand span {
  text-shadow: 0 0 18px color-mix(in srgb, var(--text) 14%, transparent);
}

/* Keep keyboard focus obvious without the harsh rectangular browser frame. */
.brand:focus-visible,
.app-header .brand:focus-visible {
  outline: none;
  border-radius: 10px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 22%, transparent);
}

h1 {
  font-weight: 620;
  letter-spacing: -0.038em;
}

h2 {
  font-weight: 600;
}

h3 {
  font-weight: 580;
}

.book-heading h1 {
  font-weight: 620;
  letter-spacing: -0.034em;
}

.shelf-heading h1 {
  font-weight: 620;
  letter-spacing: -0.035em;
}

.chapter-info strong,
.mini-open strong,
.book-title {
  font-weight: 580;
}

/* Header stays useful but visually gets out of the story's way. */
.app-header #theme {
  transition: background-color 0.16s ease, transform 0.16s ease;
}

.app-header #theme:hover {
  background: color-mix(in srgb, var(--soft) 78%, transparent);
  transform: rotate(-5deg);
}

.app-header #logout {
  font-weight: 520;
  color: var(--muted);
}

.app-header #logout:hover {
  color: var(--text);
}

/* Reassuring status text should read like narration, not system telemetry. */
#notice {
  color: color-mix(in srgb, var(--muted) 90%, var(--text));
  letter-spacing: -0.01em;
}

/* Book detail: the cover is the emotional anchor; title supports it. */
.book-heading img,
.book-heading-art,
.current-book img,
.current-book-art {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 14px 34px color-mix(in srgb, var(--shadow) 62%, transparent);
}

body.light .book-heading img,
body.light .book-heading-art,
body.light .current-book img,
body.light .current-book-art {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 14px 34px rgba(77, 59, 36, 0.12);
}

/* Reading-list card: lighter borders, paper depth, less dashboard geometry. */
.chapter-list {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--panel) 96%, transparent),
      color-mix(in srgb, var(--panel) 90%, transparent));
  border-color: color-mix(in srgb, var(--line) 85%, transparent);
  box-shadow:
    inset 0 1px 0 var(--paper-highlight),
    0 18px 54px color-mix(in srgb, var(--shadow) 52%, transparent);
}

body.light .chapter-list {
  background:
    linear-gradient(180deg, rgba(255, 254, 251, 0.96), rgba(255, 252, 247, 0.91));
  border-color: rgba(63, 52, 38, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 18px 44px rgba(82, 62, 38, 0.075);
}

.chapter-link {
  border-radius: 18px;
}

.chapter-link:hover {
  background: color-mix(in srgb, var(--soft) 62%, transparent);
}

.chapter-link .number,
.number {
  font-weight: 560;
  background: color-mix(in srgb, var(--soft) 86%, transparent);
}

body.light .chapter-link .number,
body.light .number {
  background: #f1ece4;
  color: #45403a;
}

/* CTA: still decisive, but warmer than a pure black advertising slab. */
.primary,
.button.primary,
.list-end-action.primary {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--primary) 94%, white),
    var(--primary));
  color: var(--primary-text);
  border-color: transparent;
  font-weight: 590;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.09) inset,
    0 14px 34px color-mix(in srgb, var(--shadow) 60%, transparent);
}

body.light .primary,
body.light .button.primary,
body.light .list-end-action.primary {
  background: linear-gradient(180deg, #25221e, #181715);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.10) inset,
    0 14px 32px rgba(57, 45, 31, 0.14);
}

.primary:hover,
.button.primary:hover,
.list-end-action.primary:hover {
  transform: translateY(-1px);
}

/* Library: let each book feel collectible rather than like a dashboard tile. */
.book-tile {
  border-radius: 26px;
  transition:
    transform 0.18s ease,
    background-color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.book-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 46px color-mix(in srgb, var(--shadow) 42%, transparent);
}

.book-tile .world {
  border-radius: 20px;
  box-shadow: 0 16px 38px color-mix(in srgb, var(--shadow) 42%, transparent);
}

body.light .book-tile {
  background: color-mix(in srgb, var(--panel) 48%, transparent);
  border-color: rgba(63, 52, 38, 0.06);
}

body.light .book-tile:hover {
  background: rgba(255, 253, 248, 0.94);
  border-color: rgba(63, 52, 38, 0.11);
  box-shadow: 0 20px 46px rgba(82, 62, 38, 0.085);
}

.shelf-heading > :last-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

/* Tonight: this should feel like a prompt from a storyteller, not a form. */
.tonight h1 {
  font-weight: 610;
  letter-spacing: -0.04em;
}

.tonight > p {
  font-size: 16px;
  line-height: 1.55;
  color: var(--muted);
}

.current-book strong {
  font-weight: 590;
}

.tonight textarea {
  border-color: color-mix(in srgb, var(--line) 90%, transparent);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--input) 94%, transparent),
      color-mix(in srgb, var(--input) 86%, transparent));
  box-shadow: inset 0 1px 0 var(--paper-highlight);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background-color 0.16s ease;
}

body.light .tonight textarea {
  background: rgba(255, 253, 248, 0.72);
}

.tonight textarea:focus {
  border-color: color-mix(in srgb, var(--text) 28%, var(--line));
  box-shadow:
    inset 0 1px 0 var(--paper-highlight),
    0 0 0 4px color-mix(in srgb, var(--text) 5%, transparent);
}

.tonight textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 86%, transparent);
  font-family: var(--font-reading);
  font-style: italic;
  letter-spacing: 0;
}

.quick-modifiers select {
  font-weight: 540;
  background: color-mix(in srgb, var(--input) 90%, transparent);
}

.tonight summary,
.last-chapter {
  font-weight: 500;
}

/* Mini player: warm paper in light mode instead of cool gray, night companion
   in dark mode. */
#mini,
.mini-player {
  background: color-mix(in srgb, var(--panel-raised) 94%, transparent);
  border-color: color-mix(in srgb, var(--line) 88%, transparent);
}

body.light #mini,
body.light .mini-player {
  background: rgba(255, 253, 249, 0.96);
  border-color: rgba(62, 51, 37, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 16px 42px rgba(64, 49, 31, 0.12);
}

.mini-toggle,
.np-transport .play,
.unified-footer .np-transport .play {
  box-shadow: 0 7px 20px color-mix(in srgb, var(--shadow) 42%, transparent);
}

/* Navigation: softer floating glass/paper rather than a utility bar. */
#nav,
.bottom-nav {
  border-color: color-mix(in srgb, var(--line) 84%, transparent);
}

body.light #nav,
body.light .bottom-nav {
  background: rgba(255, 252, 247, 0.94);
  border-color: rgba(61, 51, 38, 0.11);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 14px 42px rgba(62, 49, 31, 0.09);
}

#nav button.active,
#nav button[aria-expanded="true"],
.bottom-nav a.active {
  background: color-mix(in srgb, var(--soft) 72%, transparent);
}

body.light #nav button.active,
body.light #nav button[aria-expanded="true"],
body.light .bottom-nav a.active {
  background: rgba(238, 232, 222, 0.78);
}

/* Sheets and dialogs should feel like pages laid above the story, not admin
   modals. */
#sheet {
  border-color: color-mix(in srgb, var(--line) 90%, transparent);
}

body.light #sheet {
  background: #fffdf8;
  border-color: rgba(61, 51, 38, 0.11);
  box-shadow: 0 28px 70px rgba(58, 44, 29, 0.15);
}

/* Keep the full reader immersive but restrained. */
#player,
#player.unified {
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.30);
}

body.light #player,
body.light #player.unified {
  box-shadow: 0 28px 80px rgba(64, 48, 31, 0.18);
}

.prose,
.story-editor,
#editor {
  font-kerning: normal;
  text-wrap: pretty;
}

/* Mobile tuning for the screens shown in the review. */
@media (max-width: 600px) {
  body,
  body.light {
    min-height: 100dvh;
  }

  .app-header {
    padding-left: 20px;
    padding-right: 20px;
  }

  .brand,
  .app-header .brand {
    font-size: 21px;
    font-weight: 660;
  }

  #notice {
    margin-top: 16px;
    margin-bottom: 20px;
    font-size: 13.5px;
  }

  .book-heading {
    margin-top: 6px;
    margin-bottom: 30px;
  }

  .book-heading h1 {
    font-size: 29px;
    font-weight: 610;
  }

  .chapter-list {
    border-radius: 22px;
  }

  .chapter-link {
    min-height: 88px;
  }

  .chapter-info strong {
    font-size: 15px;
    font-weight: 570;
  }

  .list-end-action {
    min-height: 58px;
    border-radius: 999px;
    font-weight: 580;
  }

  .shelf-heading {
    align-items: center;
    margin-bottom: 24px;
  }

  .shelf-heading h1 {
    font-size: 31px;
    font-weight: 610;
  }

  .book-tile {
    padding: 10px;
    border-radius: 24px;
  }

  .book-tile .world {
    border-radius: 18px;
  }

  .tonight {
    margin-top: 26px;
  }

  .tonight h1 {
    font-size: 32px;
    line-height: 1.1;
    font-weight: 600;
  }

  .tonight > p {
    font-size: 16px;
    margin-bottom: 28px;
  }

  .tonight textarea {
    min-height: 138px;
  }

  #nav,
  .bottom-nav {
    background: color-mix(in srgb, var(--panel-raised) 96%, transparent);
    backdrop-filter: blur(22px) saturate(110%);
    -webkit-backdrop-filter: blur(22px) saturate(110%);
  }

  body.light #nav,
  body.light .bottom-nav {
    background: rgba(255, 252, 247, 0.965);
  }

  body.light #mini,
  body.light .mini-player {
    background: rgba(255, 253, 249, 0.975);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-header #theme:hover,
  .book-tile:hover,
  .primary:hover,
  .button.primary:hover,
  .list-end-action.primary:hover {
    transform: none;
  }
}

/* ========================================================================== 
   DUAL MAGIC + PILL INTERACTION PASS
   Dark mode uses Red Light Neon #FF0055 as the small electric spark.
   Light mode uses Honeysuckle #E7FF86 as the warm imaginative highlight.
   The interface itself stays warm cream/charcoal; accents are intentionally sparse.
   ========================================================================== */

:root {
  --magic: #FF0055;
  --magic-ink: #15070c;
  --magic-text: #FF4A85;
  --magic-soft: color-mix(in srgb, var(--magic) 9%, transparent);
  --magic-soft-strong: color-mix(in srgb, var(--magic) 16%, transparent);
  --magic-line: color-mix(in srgb, var(--magic) 40%, transparent);
  --magic-ring: color-mix(in srgb, var(--magic) 25%, transparent);
  --magic-glow: color-mix(in srgb, var(--magic) 16%, transparent);
  --pill-radius: 999px;
}

body.light {
  --magic: #E7FF86;
  --magic-ink: #15170d;
  --magic-text: #5F7000;
  --magic-soft: color-mix(in srgb, var(--magic) 11%, transparent);
  --magic-soft-strong: color-mix(in srgb, var(--magic) 20%, transparent);
  --magic-line: color-mix(in srgb, var(--magic) 54%, #6f7d1a);
  --magic-ring: color-mix(in srgb, var(--magic) 32%, transparent);
  --magic-glow: color-mix(in srgb, var(--magic) 18%, transparent);
}

/* --------------------------------------------------------------------------
   Atmosphere: Honeysuckle is a glint, not a page wash.
   -------------------------------------------------------------------------- */
body {
  background:
    radial-gradient(500px 320px at 86% 4%, var(--magic-soft), transparent 76%),
    radial-gradient(circle at 9% 16%, var(--sparkle) 0 1px, transparent 1.45px),
    radial-gradient(circle at 88% 13%, var(--sparkle) 0 1px, transparent 1.45px),
    radial-gradient(circle at 73% 39%, color-mix(in srgb, var(--sparkle) 70%, transparent) 0 1px, transparent 1.4px),
    radial-gradient(circle at 23% 71%, color-mix(in srgb, var(--sparkle) 65%, transparent) 0 1px, transparent 1.35px),
    radial-gradient(780px 500px at 9% -2%, var(--warm-glow), transparent 68%),
    radial-gradient(620px 480px at 92% 72%, rgba(255, 255, 255, 0.018), transparent 72%),
    linear-gradient(180deg, #151411 0%, #11110f 54%, #0f0f0d 100%);
  background-attachment: fixed;
}

body.light {
  background:
    radial-gradient(540px 360px at 89% 4%, var(--magic-soft), transparent 77%),
    radial-gradient(circle at 9% 16%, var(--sparkle) 0 1px, transparent 1.45px),
    radial-gradient(circle at 88% 13%, var(--sparkle) 0 1px, transparent 1.45px),
    radial-gradient(circle at 73% 39%, color-mix(in srgb, var(--sparkle) 72%, transparent) 0 1px, transparent 1.4px),
    radial-gradient(circle at 23% 71%, color-mix(in srgb, var(--sparkle) 62%, transparent) 0 1px, transparent 1.35px),
    radial-gradient(880px 540px at 8% -5%, rgba(255, 255, 255, 0.92), transparent 66%),
    radial-gradient(760px 520px at 93% 73%, var(--warm-glow), transparent 72%),
    linear-gradient(180deg, #fbf8f2 0%, #f7f2e9 58%, #f3ede3 100%);
  background-attachment: fixed;
}

/* --------------------------------------------------------------------------
   App header: a real floating capsule, not loose controls on the canvas.
   -------------------------------------------------------------------------- */
.app-header {
  width: min(1040px, calc(100% - 32px));
  max-width: 1040px;
  height: 62px;
  min-height: 62px;
  margin: 14px auto 0;
  padding: 7px 9px 7px 18px;
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: var(--pill-radius);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, white 5%, transparent),
    0 14px 38px color-mix(in srgb, var(--shadow) 32%, transparent);
  backdrop-filter: blur(18px) saturate(115%);
  -webkit-backdrop-filter: blur(18px) saturate(115%);
}

body.light .app-header {
  background: rgba(255, 253, 248, 0.86);
  border-color: rgba(63, 52, 39, 0.11);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 13px 34px rgba(66, 51, 32, 0.08);
}

.app-header .brand {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 5px;
  border-radius: var(--pill-radius);
}

.brand span,
.app-header .brand span {
  color: var(--magic);
  text-shadow: 0 0 20px var(--magic-glow);
}

body.light .brand span,
body.light .app-header .brand span {
  color: var(--magic);
  text-shadow: 0 0 18px var(--magic-glow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.app-header #theme {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.app-header #theme:hover {
  color: var(--magic-text);
  background: var(--magic-soft-strong);
}

.app-header #logout {
  min-height: 42px;
  padding: 0 15px;
  border: 0;
  border-radius: var(--pill-radius);
  background: transparent;
  color: var(--muted);
  font-weight: 540;
}

.app-header #logout:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--soft) 82%, transparent);
}

/* --------------------------------------------------------------------------
   Click/focus behavior: rounded feedback only. Pointer clicks never flash a
   square; keyboard focus remains visible and follows each control's geometry.
   -------------------------------------------------------------------------- */
button,
.button,
a,
summary,
select,
[role='button'] {
  -webkit-tap-highlight-color: transparent;
}

button:focus:not(:focus-visible),
.button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
summary:focus:not(:focus-visible),
[role='button']:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

button:focus-visible,
.button:focus-visible,
a:focus-visible,
summary:focus-visible,
[role='button']:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--magic-ring);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 0;
}

.brand:focus-visible,
.app-header .brand:focus-visible {
  outline: 0;
  border-radius: var(--pill-radius);
  box-shadow: 0 0 0 3px var(--magic-ring);
}

/* --------------------------------------------------------------------------
   Selects: unmistakable pills with a theme-aware magic arrow button.
   The open OS menu itself remains native for a real <select>.
   -------------------------------------------------------------------------- */
select {
  -webkit-appearance: none;
  appearance: none;
  min-height: 54px;
  padding: 11px 58px 11px 21px;
  border: 1px solid color-mix(in srgb, var(--line) 92%, transparent);
  border-radius: var(--pill-radius);
  color: var(--text);
  font-weight: 570;
  background-color: color-mix(in srgb, var(--input) 90%, transparent);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9' fill='none'%3E%3Cpath d='M2 2L7 7L12 2' stroke='%2315170d' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
    radial-gradient(circle, var(--magic) 0 67%, transparent 69%);
  background-repeat: no-repeat, no-repeat;
  background-position: right 19px center, right 8px center;
  background-size: 14px 9px, 36px 36px;
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--paper-highlight) 88%, transparent),
    0 5px 16px color-mix(in srgb, var(--shadow) 18%, transparent);
  transition:
    border-color .16s ease,
    background-color .16s ease,
    box-shadow .16s ease,
    transform .08s ease;
}

body.light select {
  background-color: rgba(255, 253, 248, 0.9);
  border-color: rgba(65, 54, 41, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 6px 18px rgba(70, 54, 35, 0.045);
}

select:hover:not(:disabled),
select:focus {
  border-color: var(--magic-line);
}

select:focus-visible {
  border-color: var(--magic-line);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--paper-highlight) 90%, transparent),
    0 0 0 3px var(--magic-ring),
    0 9px 24px color-mix(in srgb, var(--shadow) 21%, transparent);
}

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

select:disabled {
  opacity: .48;
  cursor: default;
}

select option {
  background: var(--panel-raised);
  color: var(--text);
  font-weight: 520;
}

body.light select option {
  background: #fffdf8;
  color: #201e1b;
}

.quick-modifiers {
  gap: 12px;
  margin-top: 18px;
}

.quick-modifiers label {
  margin: 0;
  border-radius: var(--pill-radius);
}

.quick-modifiers select {
  min-height: 60px;
  padding-left: 23px;
  padding-right: 60px;
  border-radius: var(--pill-radius);
  font-weight: 600;
}

.listening-options select,
.np-sleep select,
.unified-content .np-sleep select {
  border-radius: var(--pill-radius);
  padding-left: 18px;
}

/* --------------------------------------------------------------------------
   Pill vocabulary: capsules for actions, chips, navigation, and the player.
   -------------------------------------------------------------------------- */
.button.primary,
button.primary,
.list-end-action,
.pill,
.chips button,
.reader-tools > button,
.unified-follow button,
.lyrics-follow button,
.change-menu summary {
  border-radius: var(--pill-radius);
}

.tonight .primary,
.tonight .button.primary,
.list-end-action.primary {
  min-height: 58px;
  border-radius: var(--pill-radius);
  padding-inline: 27px;
}

/* The theme accent is strongest on tiny moments, not whole screens. */
.list-end-action > span:first-child,
.new-world > span:first-child {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  color: var(--magic-ink);
  background: var(--magic);
  box-shadow: 0 7px 20px var(--magic-glow);
}

.sheet-chapters button.add-chapter,
.book-crumb,
.read .eyebrow,
.chapter-kicker {
  color: var(--magic-text);
}

/* Player surfaces become unmistakable capsules. */
#mini,
.mini-player {
  border-radius: var(--pill-radius);
  overflow: hidden;
}

.mini-toggle,
.np-transport .play,
.unified-footer .np-transport .play {
  border-radius: 50%;
}

/* Reader/listening selection can carry a full theme-accent fill. */
.reader-tools > .primary,
.reader-tools > button.primary,
.playback-controls .primary,
.np-tabs button.on {
  background: var(--magic);
  border-color: transparent;
  color: var(--magic-ink);
  box-shadow: 0 8px 24px var(--magic-glow);
}

.reader-tools > .primary:hover,
.reader-tools > button.primary:hover,
.playback-controls .primary:hover,
.np-tabs button.on:hover {
  background: color-mix(in srgb, var(--magic) 88%, white);
  color: var(--magic-ink);
}

/* --------------------------------------------------------------------------
   Create sheet: remove the chunky square focus language and turn choices into
   friendly rounded rows. This specifically fixes the dialog shown in review.
   -------------------------------------------------------------------------- */
#sheet {
  border-radius: 30px;
  border-color: color-mix(in srgb, var(--line) 90%, transparent);
}

.sheet-head {
  align-items: flex-start;
}

.sheet-head h2 {
  font-weight: 620;
  letter-spacing: -0.035em;
}

.sheet-head button {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--soft) 82%, transparent);
  color: var(--text);
  box-shadow: none;
}

.sheet-head button:hover {
  border-color: var(--magic-line);
  background: var(--magic-soft-strong);
}

.sheet-head button:focus-visible {
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--magic-ring);
}

.new-world {
  gap: 16px;
  margin: 5px 0;
  padding: 13px 14px;
  border: 1px solid transparent;
  border-radius: 24px;
  background: transparent;
  transition: background-color .16s ease, border-color .16s ease, transform .08s ease;
}

.new-world:hover:not(:disabled) {
  background: var(--magic-soft);
  border-color: color-mix(in srgb, var(--magic-line) 70%, transparent);
}

.new-world:active:not(:disabled) {
  transform: translateY(1px);
}

.new-world strong {
  font-weight: 620;
}

.new-world small {
  margin-top: 2px;
}

.sheet-book summary {
  min-height: 62px;
  padding: 9px 12px;
  margin: 3px -12px;
  border-radius: 20px;
}

.sheet-book summary:hover {
  background: color-mix(in srgb, var(--soft) 70%, transparent);
}

.sheet-chapters button {
  border-radius: var(--pill-radius);
  padding-inline: 13px;
}

.sheet-chapters button:hover {
  background: var(--magic-soft);
}

body.light #sheet {
  background: rgba(255, 253, 248, 0.98);
}

/* --------------------------------------------------------------------------
   Bottom navigation: a floating dock pill; selected destinations glow rather
   than sitting inside a rounded square.
   -------------------------------------------------------------------------- */
#nav,
.bottom-nav {
  left: 50%;
  right: auto;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(700px, calc(100% - 24px));
  height: 72px;
  padding: 6px;
  border: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
  border-radius: var(--pill-radius);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, white 4%, transparent),
    0 18px 46px color-mix(in srgb, var(--shadow) 46%, transparent);
  backdrop-filter: blur(18px) saturate(110%);
  -webkit-backdrop-filter: blur(18px) saturate(110%);
}

body.light #nav,
body.light .bottom-nav {
  background: rgba(255, 253, 248, 0.92);
  border-color: rgba(61, 51, 38, 0.11);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.94),
    0 16px 40px rgba(62, 49, 31, 0.11);
}

#nav button,
.bottom-nav a {
  height: 58px;
  min-height: 58px;
  border-radius: var(--pill-radius);
  overflow: hidden;
  isolation: isolate;
}

#nav button.active,
#nav button[aria-expanded='true'],
.bottom-nav a.active {
  color: var(--magic-text);
  background: var(--magic-soft-strong);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--magic) 13%, transparent);
}

#nav button.active > span:first-child,
#nav button[aria-expanded='true'] > span:first-child,
.bottom-nav a.active > span:first-child {
  color: var(--magic-text);
  filter: drop-shadow(0 3px 9px var(--magic-glow));
}

#nav button:hover,
.bottom-nav a:hover {
  background: var(--magic-soft);
}

body.light #nav button.active,
body.light #nav button[aria-expanded='true'],
body.light .bottom-nav a.active {
  color: var(--magic-text);
  background: color-mix(in srgb, var(--magic) 10%, #fffaf2);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--magic) 18%, transparent);
}

body.light #nav button.active > span:first-child,
body.light #nav button[aria-expanded='true'] > span:first-child,
body.light .bottom-nav a.active > span:first-child {
  color: var(--magic);
  filter: drop-shadow(0 3px 8px var(--magic-glow));
}

/* Mini-player sits cleanly above the dock. */
#mini,
.mini-player {
  bottom: calc(94px + env(safe-area-inset-bottom));
}

body.has-player {
  padding-bottom: 190px;
}

/* Selected chips are one of the few filled accent pills. */
.chips button.selected {
  background: var(--magic);
  border-color: transparent;
  color: var(--magic-ink);
  box-shadow: 0 6px 18px var(--magic-glow);
}

/* Focus follows pill/circle geometry. */
.primary:focus-visible,
.button.primary:focus-visible,
.list-end-action:focus-visible,
.chips button:focus-visible,
.reader-tools > button:focus-visible,
.bottom-nav a:focus-visible,
#nav button:focus-visible,
.mini-toggle:focus-visible,
.np-transport button:focus-visible,
.change-menu summary:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--magic-ring);
}

.quick-modifiers select:focus-visible,
.listening-options select:focus-visible,
.np-sleep select:focus-visible,
.unified-content .np-sleep select:focus-visible {
  outline: 0;
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--paper-highlight) 90%, transparent),
    0 0 0 3px var(--magic-ring),
    0 9px 24px color-mix(in srgb, var(--shadow) 21%, transparent);
}

.tonight textarea:focus,
.tonight textarea:focus-visible {
  outline: 0;
  border-color: var(--magic-line);
  box-shadow:
    inset 0 1px 0 var(--paper-highlight),
    0 0 0 3px var(--magic-ring);
}

/* Functional magic: progress/read-along may use the accent more directly. */
.word.active-word,
.timed-story .active-word,
.unified-content .lyric-line .word.active-word {
  color: var(--magic-text);
  background: var(--magic-soft-strong);
  text-decoration-color: color-mix(in srgb, var(--magic) 62%, transparent);
  box-shadow: none;
}

body.light .word.active-word,
body.light .timed-story .active-word,
body.light .unified-content .lyric-line .word.active-word {
  color: var(--magic-text);
}

.progress i,
.mini-line i {
  background: var(--magic);
}

.speed-fill {
  stroke: var(--magic);
}

.tonight summary::after {
  color: var(--magic-text);
}

body.light .tonight summary::after {
  color: var(--magic-text);
}

/* Light-mode story controls stay warm and tactile. */
body.light .quick-modifiers select {
  background-color: rgba(255, 252, 246, .94);
}

body.light .tonight textarea {
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 254, 250, .94), rgba(255, 251, 244, .84));
}

/* Mobile: keep the header and dock visibly pill-shaped rather than allowing
   either to collapse back into full-width bars. */
@media (max-width: 600px) {
  .app-header {
    width: calc(100% - 24px);
    height: 58px;
    min-height: 58px;
    margin-top: 10px;
    padding: 6px 7px 6px 15px;
  }

  .app-header .brand {
    min-height: 40px;
    font-size: 20px;
  }

  .app-header #theme {
    width: 40px;
    height: 40px;
  }

  .app-header #logout {
    min-height: 40px;
    padding-inline: 12px;
  }

  .quick-modifiers {
    gap: 10px;
  }

  .quick-modifiers select {
    min-height: 60px;
    padding-left: 22px;
    padding-right: 58px;
  }

  .tonight textarea {
    border-radius: 26px;
  }

  #sheet {
    border-radius: 30px 30px 26px 26px;
  }

  .new-world {
    border-radius: 22px;
  }

  #nav,
  .bottom-nav {
    width: calc(100% - 20px);
    height: 70px;
    bottom: max(8px, env(safe-area-inset-bottom));
    padding: 5px;
  }

  #nav button,
  .bottom-nav a {
    height: 58px;
    min-height: 58px;
  }

  #mini,
  .mini-player {
    width: calc(100% - 28px);
    bottom: calc(90px + env(safe-area-inset-bottom));
  }

  body.has-player {
    padding-bottom: 186px;
  }
}

@media (prefers-reduced-motion: reduce) {
  select,
  .new-world,
  .reader-tools > .primary,
  .bottom-nav a,
  #nav button,
  .app-header #theme {
    transition: none;
  }
}


/* ==========================================================================
   FINAL THEME + INTERACTION CORRECTIONS
   Dark: Red Light Neon #FF0055
   Light: Honeysuckle #E7FF86
   ========================================================================== */

/*
 * The app header is the first block on many pages. Its top margin used to
 * collapse through body, exposing the html canvas and producing a thin band
 * of a different color above the header. A body block-formatting context
 * keeps that breathing room inside the actual page canvas.
 */
html {
  min-height: 100%;
  margin: 0;
  padding: 0;
  background: #151411;
}

html:has(body.light) {
  background: #fbf8f2;
}

body {
  min-height: 100dvh;
  margin: 0;
  display: flow-root;
}

/* Authoritative accent assignment. */
:root {
  --magic: #FF0055;
  --magic-ink: #15070c;
  --magic-text: #FF4A85;
  --magic-soft: color-mix(in srgb, var(--magic) 9%, transparent);
  --magic-soft-strong: color-mix(in srgb, var(--magic) 16%, transparent);
  --magic-line: color-mix(in srgb, var(--magic) 40%, transparent);
  --magic-ring: color-mix(in srgb, var(--magic) 25%, transparent);
  --magic-glow: color-mix(in srgb, var(--magic) 16%, transparent);
}

body.light {
  --magic: #E7FF86;
  --magic-ink: #15170d;
  /* Honeysuckle itself is intentionally reserved for fills and symbols.
     This deeper olive keeps small accent text accessible on cream. */
  --magic-text: #5F7000;
  --magic-soft: color-mix(in srgb, var(--magic) 11%, transparent);
  --magic-soft-strong: color-mix(in srgb, var(--magic) 20%, transparent);
  --magic-line: color-mix(in srgb, var(--magic) 54%, #6f7d1a);
  --magic-ring: color-mix(in srgb, var(--magic) 32%, transparent);
  --magic-glow: color-mix(in srgb, var(--magic) 18%, transparent);
}

/* Keep the top-of-page atmosphere continuous with the floating header. */
body {
  background:
    radial-gradient(520px 330px at 86% 1%, var(--magic-soft), transparent 76%),
    radial-gradient(circle at 9% 16%, var(--sparkle) 0 1px, transparent 1.45px),
    radial-gradient(circle at 88% 13%, var(--sparkle) 0 1px, transparent 1.45px),
    radial-gradient(780px 500px at 9% -2%, var(--warm-glow), transparent 68%),
    linear-gradient(180deg, #151411 0%, #11110f 54%, #0f0f0d 100%);
  background-attachment: fixed;
}

body.light {
  background:
    radial-gradient(560px 350px at 88% 1%, var(--magic-soft), transparent 78%),
    radial-gradient(circle at 9% 16%, var(--sparkle) 0 1px, transparent 1.45px),
    radial-gradient(circle at 88% 13%, var(--sparkle) 0 1px, transparent 1.45px),
    radial-gradient(880px 540px at 8% -5%, rgba(255,255,255,.92), transparent 66%),
    radial-gradient(760px 520px at 93% 73%, var(--warm-glow), transparent 72%),
    linear-gradient(180deg, #fbf8f2 0%, #f7f2e9 58%, #f3ede3 100%);
  background-attachment: fixed;
}

/* Brand sparkle: literal theme accent, deliberately small. */
.brand span,
.app-header .brand span {
  color: var(--magic);
  text-shadow: 0 0 18px var(--magic-glow);
}

/* Header remains a floating pill; no separate strip above it. */
.app-header {
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  border-color: color-mix(in srgb, var(--line) 88%, transparent);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, white 5%, transparent),
    0 14px 38px color-mix(in srgb, var(--shadow) 32%, transparent);
}

body.light .app-header {
  background: rgba(255, 253, 248, .90);
  border-color: rgba(63, 52, 39, .11);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.96),
    0 13px 34px rgba(66,51,32,.08);
}

/* Theme button gets a restrained accent halo rather than a square click state. */
.app-header #theme:hover {
  background: var(--magic-soft);
  color: var(--text);
}

.app-header #theme:focus-visible,
.app-header .brand:focus-visible,
.app-header #logout:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--magic-ring);
}

/* --------------------------------------------------------------------------
   PLAYBACK — the play action is an accent object in both themes.
   Earlier primary-button rules intentionally cannot override this block.
   -------------------------------------------------------------------------- */
.play,
.mini-toggle,
.np-transport .play,
.unified-footer .np-transport .play {
  background: var(--magic);
  color: var(--magic-ink);
  border-color: transparent;
  box-shadow:
    0 10px 28px var(--magic-glow),
    inset 0 1px 0 color-mix(in srgb, white 24%, transparent);
}

.play:hover,
.mini-toggle:hover,
.np-transport .play:hover,
.unified-footer .np-transport .play:hover {
  background: color-mix(in srgb, var(--magic) 90%, white);
  color: var(--magic-ink);
  border-color: transparent;
  transform: translateY(-1px);
}

.play:active,
.mini-toggle:active,
.np-transport .play:active,
.unified-footer .np-transport .play:active {
  background: var(--magic);
  color: var(--magic-ink);
  transform: translateY(0) scale(.98);
}

/* Preparing narration can disable play. Keep its accent identity while making
   the disabled state visibly quieter instead of reverting to black/gray. */
.play:disabled,
.mini-toggle:disabled,
.np-transport .play:disabled,
.unified-footer .np-transport .play:disabled {
  opacity: 1;
  cursor: default;
  background: color-mix(in srgb, var(--magic) 68%, var(--panel));
  color: color-mix(in srgb, var(--magic-ink) 78%, var(--muted));
  border: 1px solid var(--magic-line);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--magic) 9%, transparent);
  transform: none;
}

.play:focus-visible,
.mini-toggle:focus-visible,
.np-transport .play:focus-visible,
.unified-footer .np-transport .play:focus-visible {
  outline: 0;
  box-shadow:
    0 0 0 4px var(--magic-ring),
    0 10px 28px var(--magic-glow);
}

/* Progress and native range widgets follow the same accent language. */
.progress i,
.mini-line i {
  background: var(--magic);
}

input[type='range'],
.unified-footer input[type='range'] {
  accent-color: var(--magic);
}

/* --------------------------------------------------------------------------
   SELECTED PILLS — selection remains selected through hover/click/focus.
   -------------------------------------------------------------------------- */
#player .np-tabs button.on,
#player .np-tabs button.on:hover,
#player .np-tabs button.on:active,
#player .np-tabs button.on:focus,
#player .np-tabs button.on:focus-visible,
#player.unified .np-tabs button.on,
#player.unified .np-tabs button.on:hover,
#player.unified .np-tabs button.on:active,
#player.unified .np-tabs button.on:focus,
#player.unified .np-tabs button.on:focus-visible,
.unified-footer .np-tabs button.on,
.unified-footer .np-tabs button.on:hover,
.unified-footer .np-tabs button.on:active,
.unified-footer .np-tabs button.on:focus,
.unified-footer .np-tabs button.on:focus-visible {
  background: var(--magic);
  color: var(--magic-ink);
  border-color: transparent;
  opacity: 1;
  box-shadow: 0 8px 24px var(--magic-glow);
}

#player .np-tabs button.on:hover,
#player.unified .np-tabs button.on:hover,
.unified-footer .np-tabs button.on:hover {
  background: color-mix(in srgb, var(--magic) 92%, white);
  color: var(--magic-ink);
  transform: translateY(-1px);
}

#player .np-tabs button.on:active,
#player.unified .np-tabs button.on:active,
.unified-footer .np-tabs button.on:active {
  transform: translateY(0);
}

#player .np-tabs button.on *,
#player.unified .np-tabs button.on *,
.unified-footer .np-tabs button.on * {
  color: inherit;
}

#player .np-tabs button:not(.on):hover,
#player.unified .np-tabs button:not(.on):hover,
.unified-footer .np-tabs button:not(.on):hover {
  background: var(--magic-soft);
  color: var(--text);
}

/* Bottom dock: keep the capsule obvious, but reserve the full accent fill for
   high-confidence state such as Read along and Play. */
#nav button.active,
#nav button[aria-expanded='true'],
.bottom-nav a.active {
  color: var(--magic-text);
  background: color-mix(in srgb, var(--magic) 14%, var(--panel));
  box-shadow: inset 0 0 0 1px var(--magic-line);
}

body.light #nav button.active,
body.light #nav button[aria-expanded='true'],
body.light .bottom-nav a.active {
  color: #3f4900;
  background: color-mix(in srgb, var(--magic) 28%, #fffaf2);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #697800 28%, transparent);
}

#nav button.active > span:first-child,
#nav button[aria-expanded='true'] > span:first-child,
.bottom-nav a.active > span:first-child {
  color: var(--magic);
  filter: drop-shadow(0 3px 8px var(--magic-glow));
}

#nav button:hover,
.bottom-nav a:hover {
  background: var(--magic-soft);
}

/* Small accent text: readable derivative in light mode, neon in dark. */
.sheet-chapters button.add-chapter,
.book-crumb,
.read .eyebrow,
.chapter-kicker,
.word.active-word,
.timed-story .active-word,
.unified-content .lyric-line .word.active-word,
.tonight summary::after {
  color: var(--magic-text);
}

/* Selected chips and creation micro-actions may carry the literal fill. */
.chips button.selected,
.reader-tools > .primary,
.reader-tools > button.primary,
.playback-controls .primary {
  background: var(--magic);
  color: var(--magic-ink);
  border-color: transparent;
  box-shadow: 0 8px 24px var(--magic-glow);
}

.chips button.selected:hover,
.reader-tools > .primary:hover,
.reader-tools > button.primary:hover,
.playback-controls .primary:hover {
  background: color-mix(in srgb, var(--magic) 91%, white);
  color: var(--magic-ink);
}

/* Honeysuckle is too bright for tiny text on cream; keep light-mode text
   accessible while its actual fills, icons, and sparks remain #E7FF86. */
body.light .sheet-chapters button.add-chapter,
body.light .book-crumb,
body.light .read .eyebrow,
body.light .chapter-kicker,
body.light .word.active-word,
body.light .timed-story .active-word,
body.light .unified-content .lyric-line .word.active-word,
body.light .tonight summary::after {
  color: var(--magic-text);
}

/* The browser-native open select menu is OS-controlled, but the closed
   control, chevron, and focus treatment remain fully on-theme. */
select:focus,
select:focus-visible {
  border-color: var(--magic-line);
  box-shadow: 0 0 0 4px var(--magic-ring);
}

/* Remove the rectangular mobile tap flash while retaining keyboard focus. */
button,
a,
summary,
select {
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 600px) {
  /* Flow-root prevents margin collapse at every size; retain the intended
     compact mobile gap without exposing the root canvas. */
  .app-header {
    margin-top: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .play,
  .mini-toggle,
  .np-transport .play,
  .unified-footer .np-transport .play,
  .np-tabs button,
  #nav button,
  .bottom-nav a {
    transition: none !important;
  }
}

/* ========================================================================== 
   REDUCED-LIGHT READER FIX
   When a light-theme user turns on the reader's reduced-light/night mode,
   the reader becomes a dark surface. It should therefore use the dark-theme
   Red Light Neon accent instead of inheriting light-theme Honeysuckle.
   ========================================================================== */

#player.night,
#player.unified.night,
body.light #player.night,
body.light #player.unified.night {
  color-scheme: dark;

  --magic: #FF0055;
  --magic-ink: #15070c;
  --magic-text: #FF4A85;
  --magic-soft: color-mix(in srgb, var(--magic) 9%, transparent);
  --magic-soft-strong: color-mix(in srgb, var(--magic) 16%, transparent);
  --magic-line: color-mix(in srgb, var(--magic) 40%, transparent);
  --magic-ring: color-mix(in srgb, var(--magic) 25%, transparent);
  --magic-glow: color-mix(in srgb, var(--magic) 16%, transparent);
}

/* A light body previously forced cream select surfaces even after the reader
   had switched itself to reduced-light mode. Keep reader controls dark too. */
body.light #player.night select,
body.light #player.unified.night select {
  color: var(--text);
  background-color: color-mix(in srgb, var(--input) 94%, transparent);
  border-color: color-mix(in srgb, var(--line) 94%, transparent);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.035),
    0 6px 18px rgba(0,0,0,.14);
}

body.light #player.night select option,
body.light #player.unified.night select option {
  color: var(--text);
  background: var(--panel-raised);
}

body.light #player.night select:disabled,
body.light #player.unified.night select:disabled {
  opacity: .70;
  color: var(--muted);
}

/* The reduced-light toggle/header controls should not become pale square
   buttons. Keep them quiet circles and let the accent appear only on hover or
   keyboard focus. */
#player.night .unified-header button,
#player.unified.night .unified-header button {
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
}

#player.night .unified-header button:hover,
#player.unified.night .unified-header button:hover {
  color: var(--text);
  background: var(--magic-soft);
  box-shadow: none;
}

#player.night .unified-header button:focus-visible,
#player.unified.night .unified-header button:focus-visible {
  outline: 0;
  background: var(--magic-soft);
  box-shadow: 0 0 0 3px var(--magic-ring);
}

/* ========================================================================== 
   GRADIENT HIGHLIGHT EXPERIMENT
   Same reader fix as Variant 1, with gradients restricted to high-confidence
   interaction highlights. Surfaces, typography, and navigation stay calm.
   ========================================================================== */

:root {
  --magic-highlight: linear-gradient(135deg, #FF0055 0%, #FF2C72 52%, #FF5A91 100%);
  --magic-highlight-hover: linear-gradient(135deg, #FF1764 0%, #FF3D7D 52%, #FF70A0 100%);
  --magic-progress: linear-gradient(90deg, #FF0055 0%, #FF5A91 100%);
}

body.light {
  --magic-highlight: linear-gradient(135deg, #E7FF86 0%, #D8FF6F 52%, #F2FFAE 100%);
  --magic-highlight-hover: linear-gradient(135deg, #EDFF9A 0%, #DEFF7C 52%, #F7FFC2 100%);
  --magic-progress: linear-gradient(90deg, #D8FF6F 0%, #E7FF86 50%, #F2FFAE 100%);
}

/* Reduced-light mode is a dark reader even when the outer site is light. */
#player.night,
#player.unified.night,
body.light #player.night,
body.light #player.unified.night {
  --magic-highlight: linear-gradient(135deg, #FF0055 0%, #FF2C72 52%, #FF5A91 100%);
  --magic-highlight-hover: linear-gradient(135deg, #FF1764 0%, #FF3D7D 52%, #FF70A0 100%);
  --magic-progress: linear-gradient(90deg, #FF0055 0%, #FF5A91 100%);
}

/* Main interaction jewels: play and selected reader tabs. */
.play:not(:disabled),
.mini-toggle:not(:disabled),
.np-transport .play:not(:disabled),
.unified-footer .np-transport .play:not(:disabled),
#player .np-tabs button.on,
#player.unified .np-tabs button.on,
.unified-footer .np-tabs button.on,
.chips button.selected,
.reader-tools > .primary,
.reader-tools > button.primary,
.playback-controls .primary {
  background: var(--magic-highlight);
  color: var(--magic-ink);
}

.play:not(:disabled):hover,
.mini-toggle:not(:disabled):hover,
.np-transport .play:not(:disabled):hover,
.unified-footer .np-transport .play:not(:disabled):hover,
#player .np-tabs button.on:hover,
#player.unified .np-tabs button.on:hover,
.unified-footer .np-tabs button.on:hover,
.chips button.selected:hover,
.reader-tools > .primary:hover,
.reader-tools > button.primary:hover,
.playback-controls .primary:hover {
  background: var(--magic-highlight-hover);
  color: var(--magic-ink);
}

/* Progress is the safest place for a little extra motion/energy visually. */
.progress i,
.mini-line i {
  background: var(--magic-progress);
}

/* Small circular creation cues can participate without turning cards into
   gradient surfaces. */
.list-end-action > span:first-child,
.new-world > span:first-child {
  background: var(--magic-highlight);
  color: var(--magic-ink);
}

/* ========================================================================== 
   FINAL POLISH PASS
   1) Reduced-light reader uses a deliberately subdued sleep accent instead
      of Red Light Neon.
   2) Fixed player/navigation chrome gets a safe visual + scroll zone so page
      content never peeks awkwardly between the two floating capsules.
   3) Active dock pills get a restrained gradient treatment to match the
      successful gradient-highlight experiment without turning the dock loud.
   ========================================================================== */

/* --------------------------------------------------------------------------
   LOW-LIGHT / SLEEP READER
   The reader is intentionally calmer than the site's normal dark theme.
   This is a desaturated, low-luminance moon-moss highlight: enough state
   visibility without the stimulating neon red used elsewhere in dark mode.
   -------------------------------------------------------------------------- */
#player.night,
#player.unified.night,
body.light #player.night,
body.light #player.unified.night {
  --magic: #909477;
  --magic-ink: #10110d;
  --magic-text: #b7baa0;
  --magic-soft: color-mix(in srgb, var(--magic) 8%, transparent);
  --magic-soft-strong: color-mix(in srgb, var(--magic) 14%, transparent);
  --magic-line: color-mix(in srgb, var(--magic) 30%, transparent);
  --magic-ring: color-mix(in srgb, var(--magic) 20%, transparent);
  --magic-glow: color-mix(in srgb, var(--magic) 7%, transparent);

  --magic-highlight: linear-gradient(
    135deg,
    #777a62 0%,
    #8d9074 52%,
    #a3a688 100%
  );
  --magic-highlight-hover: linear-gradient(
    135deg,
    #7f8268 0%,
    #96997c 52%,
    #abad90 100%
  );
  --magic-progress: linear-gradient(
    90deg,
    #71745d 0%,
    #8a8d71 52%,
    #9ea184 100%
  );
}

/* Keep the selected sleep/read-along capsule calm: no luminous neon halo. */
#player.night .np-tabs button.on,
#player.unified.night .np-tabs button.on,
body.light #player.night .np-tabs button.on,
body.light #player.unified.night .np-tabs button.on {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .045),
    0 7px 20px rgba(0, 0, 0, .16);
}

#player.night .np-tabs button.on:hover,
#player.unified.night .np-tabs button.on:hover,
body.light #player.night .np-tabs button.on:hover,
body.light #player.unified.night .np-tabs button.on:hover {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .05),
    0 7px 20px rgba(0, 0, 0, .18);
}

/* Sleep mode should also quiet the play jewel and timer glyph. */
#player.night .play:not(:disabled),
#player.unified.night .play:not(:disabled),
body.light #player.night .play:not(:disabled),
body.light #player.unified.night .play:not(:disabled),
#player.night .np-transport .play:not(:disabled),
#player.unified.night .np-transport .play:not(:disabled) {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.05),
    0 8px 22px rgba(0,0,0,.16);
}

/* --------------------------------------------------------------------------
   FLOATING PLAYER + DOCK SAFE ZONE
   A soft fixed scrim hides page copy beneath the chrome while extra scroll
   space guarantees the final page actions can still be brought fully above it.
   -------------------------------------------------------------------------- */
body.has-player {
  padding-bottom: calc(250px + env(safe-area-inset-bottom));
  scroll-padding-bottom: calc(225px + env(safe-area-inset-bottom));
}

body.has-player main {
  padding-bottom: 190px;
}

body.has-player::after {
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(205px + env(safe-area-inset-bottom));
  z-index: 14;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    color-mix(in srgb, var(--bg) 36%, transparent) 17%,
    color-mix(in srgb, var(--bg) 82%, transparent) 40%,
    var(--bg) 70%,
    var(--bg) 100%
  );
}

#mini,
.mini-player {
  z-index: 17;
}

#nav,
.bottom-nav {
  z-index: 16;
}

/* Keep the gap between the player and dock deliberate rather than allowing
   underlying labels (such as Change ingredients) to read through it. */
body.light.has-player::after {
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(248,245,239,.20) 16%,
    rgba(248,245,239,.78) 40%,
    rgba(248,245,239,.98) 69%,
    #f8f5ef 100%
  );
}

/* --------------------------------------------------------------------------
   ACTIVE DOCK GRADIENT
   Related to the brighter gradient jewels, but intentionally lower-energy.
   -------------------------------------------------------------------------- */
#nav button.active,
#nav button[aria-expanded='true'],
.bottom-nav a.active {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--magic) 24%, var(--panel)) 0%,
    color-mix(in srgb, var(--magic) 13%, var(--panel)) 58%,
    color-mix(in srgb, var(--magic) 7%, var(--panel)) 100%
  );
  border-color: color-mix(in srgb, var(--magic) 35%, transparent);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--magic) 24%, transparent),
    inset 0 1px 0 color-mix(in srgb, white 4%, transparent);
}

body.light #nav button.active,
body.light #nav button[aria-expanded='true'],
body.light .bottom-nav a.active {
  color: #3f4900;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--magic) 42%, #fffaf2) 0%,
    color-mix(in srgb, var(--magic) 28%, #fffaf2) 55%,
    color-mix(in srgb, var(--magic) 13%, #fffaf2) 100%
  );
  border-color: color-mix(in srgb, #697800 22%, transparent);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, #697800 18%, transparent),
    inset 0 1px 0 rgba(255,255,255,.78);
}

/* The active dock should remain stable on hover instead of switching back to
   the generic hover surface. */
#nav button.active:hover,
#nav button[aria-expanded='true']:hover,
.bottom-nav a.active:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--magic) 28%, var(--panel)) 0%,
    color-mix(in srgb, var(--magic) 16%, var(--panel)) 58%,
    color-mix(in srgb, var(--magic) 9%, var(--panel)) 100%
  );
}

body.light #nav button.active:hover,
body.light #nav button[aria-expanded='true']:hover,
body.light .bottom-nav a.active:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--magic) 47%, #fffaf2) 0%,
    color-mix(in srgb, var(--magic) 32%, #fffaf2) 55%,
    color-mix(in srgb, var(--magic) 16%, #fffaf2) 100%
  );
}

/* Mobile has less vertical room, but still needs enough reserve for both
   floating capsules plus the safe-area inset. */
@media (max-width: 600px) {
  body.has-player {
    padding-bottom: calc(235px + env(safe-area-inset-bottom));
    scroll-padding-bottom: calc(215px + env(safe-area-inset-bottom));
  }

  body.has-player main {
    padding-bottom: 170px;
  }

  body.has-player::after {
    height: calc(195px + env(safe-area-inset-bottom));
  }
}

/* ========================================================================== 
   FINAL CTA + LIGHT DOCK ICON FIX
   - "Make tonight's story" now belongs to each theme instead of looking like
     a white advertising slab in dark mode or a generic white control in light.
   - Light-mode dock glyphs inherit the dock state color so Tonight no longer
     flashes literal Honeysuckle while its label uses the readable olive tone.
   ========================================================================== */

:root {
  --story-cta-bg: linear-gradient(
    135deg,
    color-mix(in srgb, var(--panel) 97%, #000) 0%,
    color-mix(in srgb, var(--magic) 7%, var(--panel)) 62%,
    color-mix(in srgb, var(--magic) 12%, var(--panel)) 100%
  );
  --story-cta-bg-hover: linear-gradient(
    135deg,
    color-mix(in srgb, var(--panel) 96%, #000) 0%,
    color-mix(in srgb, var(--magic) 10%, var(--panel)) 58%,
    color-mix(in srgb, var(--magic) 17%, var(--panel)) 100%
  );
  --story-cta-text: var(--text);
  --story-cta-border: color-mix(in srgb, var(--magic) 20%, var(--line));
}

body.light {
  --story-cta-bg: linear-gradient(
    135deg,
    rgba(255, 253, 248, .98) 0%,
    color-mix(in srgb, var(--magic) 8%, #fffaf2) 62%,
    color-mix(in srgb, var(--magic) 15%, #fffaf2) 100%
  );
  --story-cta-bg-hover: linear-gradient(
    135deg,
    #fffdf8 0%,
    color-mix(in srgb, var(--magic) 12%, #fffaf2) 58%,
    color-mix(in srgb, var(--magic) 21%, #fffaf2) 100%
  );
  --story-cta-text: #201e1b;
  --story-cta-border: color-mix(in srgb, #667500 20%, var(--line));
}

/* This is the book/detail CTA used for "Make tonight's story". */
.list-end-action.primary {
  background: var(--story-cta-bg);
  color: var(--story-cta-text);
  border: 1px solid var(--story-cta-border);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, white 5%, transparent),
    0 16px 38px color-mix(in srgb, var(--shadow) 44%, transparent);
}

.list-end-action.primary:hover {
  background: var(--story-cta-bg-hover);
  color: var(--story-cta-text);
  border-color: color-mix(in srgb, var(--magic) 30%, var(--line));
  transform: translateY(-1px);
}

body.light .list-end-action.primary {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.9),
    0 15px 34px rgba(70,54,35,.09);
}

/* Keep the small + as the jewel; the whole CTA no longer needs to shout. */
.list-end-action.primary > span:first-child {
  background: var(--magic-highlight);
  color: var(--magic-ink);
  box-shadow: 0 7px 20px var(--magic-glow);
}

/* Light mode: all dock glyphs follow the readable label color.  This
   specifically fixes the selected Tonight moon, which was being forced to the
   literal Honeysuckle fill by a late generic active-icon rule. */
body.light #nav button > span:first-child,
body.light .bottom-nav a > span:first-child,
body.light #nav button .nav-icon,
body.light .bottom-nav a .nav-icon {
  color: currentColor;
  filter: none;
  text-shadow: none;
}

body.light #nav button.active > span:first-child,
body.light #nav button[aria-expanded='true'] > span:first-child,
body.light .bottom-nav a.active > span:first-child,
body.light #nav button.active .nav-icon,
body.light #nav button[aria-expanded='true'] .nav-icon,
body.light .bottom-nav a.active .nav-icon {
  color: currentColor;
  filter: none;
  text-shadow: none;
}

body.light #nav button:not(.active):not([aria-expanded='true']) > span:first-child,
body.light .bottom-nav a:not(.active) > span:first-child {
  color: currentColor;
  opacity: .92;
}

/* ========================================================================== 
   STEEPER GRADIENT EXPERIMENT
   Same fixes as the production candidate above, with deliberately stronger
   highlight separation. Geometry and theme logic stay unchanged.
   ========================================================================== */

:root {
  --magic-highlight: linear-gradient(
    132deg,
    #FF0055 0%,
    #FF0055 28%,
    #FF3D7D 61%,
    #FF96B7 100%
  );
  --magic-highlight-hover: linear-gradient(
    132deg,
    #FF1764 0%,
    #FF1764 26%,
    #FF548B 60%,
    #FFADC6 100%
  );
  --magic-progress: linear-gradient(
    90deg,
    #FF0055 0%,
    #FF0055 38%,
    #FF4B84 72%,
    #FF96B7 100%
  );
}

body.light {
  --magic-highlight: linear-gradient(
    132deg,
    #E7FF86 0%,
    #E7FF86 27%,
    #C9F34F 61%,
    #F7FFC7 100%
  );
  --magic-highlight-hover: linear-gradient(
    132deg,
    #EDFF9A 0%,
    #EDFF9A 25%,
    #D5F76A 59%,
    #FBFFD8 100%
  );
  --magic-progress: linear-gradient(
    90deg,
    #D8FA62 0%,
    #E7FF86 39%,
    #C9F34F 72%,
    #F7FFC7 100%
  );
}

/* Stronger but still theme-integrated CTA sweep. */
:root {
  --story-cta-bg: linear-gradient(
    132deg,
    color-mix(in srgb, var(--panel) 98%, #000) 0%,
    color-mix(in srgb, var(--panel) 97%, #000) 34%,
    color-mix(in srgb, var(--magic) 13%, var(--panel)) 70%,
    color-mix(in srgb, var(--magic) 22%, var(--panel)) 100%
  );
  --story-cta-bg-hover: linear-gradient(
    132deg,
    color-mix(in srgb, var(--panel) 97%, #000) 0%,
    color-mix(in srgb, var(--panel) 95%, #000) 31%,
    color-mix(in srgb, var(--magic) 18%, var(--panel)) 68%,
    color-mix(in srgb, var(--magic) 29%, var(--panel)) 100%
  );
}

body.light {
  --story-cta-bg: linear-gradient(
    132deg,
    #fffdf8 0%,
    #fffdf8 33%,
    color-mix(in srgb, var(--magic) 16%, #fffaf2) 69%,
    color-mix(in srgb, var(--magic) 30%, #fffaf2) 100%
  );
  --story-cta-bg-hover: linear-gradient(
    132deg,
    #fffdf8 0%,
    #fffdf8 30%,
    color-mix(in srgb, var(--magic) 22%, #fffaf2) 67%,
    color-mix(in srgb, var(--magic) 38%, #fffaf2) 100%
  );
}

/* Make the selected dock gradient visibly steeper without turning the whole
   dock into an accent block. */
#nav button.active,
#nav button[aria-expanded='true'],
.bottom-nav a.active {
  background: linear-gradient(
    132deg,
    color-mix(in srgb, var(--magic) 33%, var(--panel)) 0%,
    color-mix(in srgb, var(--magic) 26%, var(--panel)) 34%,
    color-mix(in srgb, var(--magic) 13%, var(--panel)) 70%,
    color-mix(in srgb, var(--magic) 7%, var(--panel)) 100%
  );
}

#nav button.active:hover,
#nav button[aria-expanded='true']:hover,
.bottom-nav a.active:hover {
  background: linear-gradient(
    132deg,
    color-mix(in srgb, var(--magic) 38%, var(--panel)) 0%,
    color-mix(in srgb, var(--magic) 30%, var(--panel)) 32%,
    color-mix(in srgb, var(--magic) 16%, var(--panel)) 69%,
    color-mix(in srgb, var(--magic) 9%, var(--panel)) 100%
  );
}

body.light #nav button.active,
body.light #nav button[aria-expanded='true'],
body.light .bottom-nav a.active {
  background: linear-gradient(
    132deg,
    color-mix(in srgb, var(--magic) 58%, #fffaf2) 0%,
    color-mix(in srgb, var(--magic) 45%, #fffaf2) 35%,
    color-mix(in srgb, var(--magic) 24%, #fffaf2) 70%,
    color-mix(in srgb, var(--magic) 11%, #fffaf2) 100%
  );
}

body.light #nav button.active:hover,
body.light #nav button[aria-expanded='true']:hover,
body.light .bottom-nav a.active:hover {
  background: linear-gradient(
    132deg,
    color-mix(in srgb, var(--magic) 64%, #fffaf2) 0%,
    color-mix(in srgb, var(--magic) 50%, #fffaf2) 33%,
    color-mix(in srgb, var(--magic) 28%, #fffaf2) 69%,
    color-mix(in srgb, var(--magic) 14%, #fffaf2) 100%
  );
}

/* ========================================================================== 
   FINAL LIGHT-MODE STORY CTA CASCADE FIX
   A stronger earlier body.light .primary rule was still winning on the
   "Make tonight's story" control. Keep the steeper Honeysuckle gradient and
   readable dark label authoritative in light mode.
   ========================================================================== */
body.light .list-end-action.primary {
  background: var(--story-cta-bg);
  color: var(--story-cta-text);
  border-color: var(--story-cta-border);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.94),
    0 15px 34px rgba(70,54,35,.09);
}

body.light .list-end-action.primary:hover {
  background: var(--story-cta-bg-hover);
  color: var(--story-cta-text);
  border-color: color-mix(in srgb, var(--magic) 34%, var(--line));
}

body.light .list-end-action.primary:active {
  background: var(--story-cta-bg-hover);
  color: var(--story-cta-text);
}

body.light .list-end-action.primary > span,
body.light .list-end-action.primary > strong {
  color: inherit;
}

body.light .list-end-action.primary > span:first-child {
  color: var(--magic-ink);
}

/* ==========================================================================
   FOUNDER PHONE FIXES 2026-09-22
   Mini-player seek, restrained bottom-nav active state, and conventional
   Restart / Speed glyphs. Kept last so earlier cascade layers cannot win.
   ========================================================================== */
.mini-seek {
  display: block;
  /* Track spans the title column only: art (13px inset + 46px + 12px gap) to just before play/close. */
  width: calc(100% - 71px - 119px);
  height: 16px;
  margin: -12px 119px 6px 71px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  min-height: 0;
  accent-color: var(--magic);
  touch-action: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.mini-seek::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--text) 18%, transparent);
}

.mini-seek::-moz-range-track {
  height: 3px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--text) 18%, transparent);
}

.mini-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border: 0;
  border-radius: 50%;
  background: var(--magic);
}

.mini-seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--magic);
}

.mini-seek:disabled {
  opacity: 0.4;
  cursor: default;
}

.mini-seek:focus-visible {
  outline: 2px solid var(--magic);
  outline-offset: 2px;
}

#nav a.active,
#nav a.active:hover,
#nav button.active,
#nav button.active:hover,
body.light #nav a.active,
body.light #nav a.active:hover,
body.light #nav button.active,
body.light #nav button.active:hover {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  outline: none;
  color: var(--magic-text, var(--text));
}

#nav a.active .nav-label {
  font-weight: 700;
}

#nav a.active > span:first-child,
#nav a.active .nav-icon {
  color: var(--magic-text, var(--text));
  background: transparent;
  box-shadow: none;
}

#nav a:focus-visible,
#nav button:focus-visible {
  outline: 2px solid var(--magic);
  outline-offset: 2px;
}

.transport-icon .stroke-glyph,
.speed-glyph svg path,
.speed-glyph svg circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.speed-glyph svg {
  width: 26px;
  height: 26px;
}

.speed-glyph .speed-dial {
  opacity: 0.55;
}

.speed-glyph .speed-hub {
  fill: currentColor;
  stroke: none;
}

.speed-glyph circle {
  transform: none;
  stroke-dasharray: none;
}

.np-transport button,
.speed-control {
  min-width: 44px;
  min-height: 44px;
}

body.light .mini-seek::-webkit-slider-thumb {
  background: var(--magic-text, var(--text));
}

body.light .mini-seek::-moz-range-thumb {
  background: var(--magic-text, var(--text));
}

/* The dock's display rule must not override the hidden attribute on signed-out screens. */
#nav[hidden],
#mini[hidden] {
  display: none;
}

/* Founder direction 2026-09-23: actions are flat; important titles carry the gradient. */
button.primary,
button.primary:hover,
button.primary:active,
.list-end-action.primary,
.list-end-action.primary:hover,
.list-end-action.primary:active,
body.light button.primary,
body.light button.primary:hover,
body.light .list-end-action.primary,
body.light .list-end-action.primary:hover {
  background-image: none;
  box-shadow: none;
}

/* One primary style everywhere: flat primary fill, ink label. */
button.primary,
button.primary:hover,
button.primary:active,
body.light button.primary,
body.light button.primary:hover,
body.light button.primary:active,
.list-end-action.primary,
.list-end-action.primary:hover,
.list-end-action.primary:active,
body.light .list-end-action.primary,
body.light .list-end-action.primary:hover,
body.light .list-end-action.primary:active {
  background-color: var(--magic);
  border-color: transparent;
  color: var(--magic-ink);
}

.list-end-action.primary > span,
.list-end-action.primary > strong,
body.light .list-end-action.primary > span,
body.light .list-end-action.primary > strong {
  color: inherit;
}

/* Uniform button system (founder direction 2026-09-23).
   Primary: flat primary fill, ink label, pill. Secondary: outline, text label, pill.
   Menu rows, choice chips, transport icons and the dock keep their own components. */
button.primary,
a.button.primary,
.list-end-action.primary,
button[data-action="register"],
button[data-action="signin"],
button.quiet,
a.button.quiet,
.list-end-action,
form > button:not(.primary),
.actions > button:not(.primary) {
  min-height: 48px;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 650;
  line-height: 1.2;
}

main button.primary.wide,
body.light main button.primary.wide {
  height: auto;
  min-height: 48px;
  padding-block: 10px;
}

button.primary[data-action],
body.light button.primary[data-action],
.reader-tools > button.primary,
.unified-footer .np-transport .play:not(:disabled),
.mini-player .mini-toggle:not(:disabled),
body.light .unified-footer .np-transport .play:not(:disabled),
body.light .mini-player .mini-toggle:not(:disabled) {
  background-image: none;
  background-color: var(--magic);
  color: var(--magic-ink);
  border-color: transparent;
  box-shadow: none;
}

button.quiet,
a.button.quiet,
.list-end-action:not(.primary),
form > button:not(.primary),
.actions > button:not(.primary),
body.light button.quiet,
body.light a.button.quiet,
body.light .list-end-action:not(.primary),
body.light form > button:not(.primary),
body.light .actions > button:not(.primary),
.reader-tools > button.quiet,
body.light .reader-tools > button.quiet,
button[data-action="register"],
button[data-action="signin"],
body.light button[data-action="register"],
body.light button[data-action="signin"] {
  background-image: none;
  background-color: var(--secondary-bg);
  border: 1px solid var(--secondary-border);
  color: var(--secondary-text);
  box-shadow: none;
}

button.quiet.small,
a.button.quiet.small {
  min-height: 40px;
  padding: 8px 16px;
}

button.quiet:hover,
a.button.quiet:hover,
.list-end-action:not(.primary):hover,
form > button:not(.primary):hover,
.actions > button:not(.primary):hover,
.reader-tools > button.quiet:hover {
  background-color: var(--secondary-bg-hover);
}

button.primary:hover,
button.primary[data-action]:hover,
.list-end-action.primary:hover,
body.light button.primary:hover,
body.light .list-end-action.primary:hover {
  background-color: var(--primary-fill-hover);
}

.list-end-action > span:first-child,
.list-end-action.primary > span:first-child,
body.light .list-end-action > span:first-child,
body.light .list-end-action.primary > span:first-child {
  display: inline-grid;
  place-items: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  aspect-ratio: 1;
  border-radius: 50%;
  background-image: none;
  box-shadow: none;
  font-size: 16px;
}

.list-end-action:not(.primary) > span:first-child,
body.light .list-end-action:not(.primary) > span:first-child {
  background-color: var(--magic);
  color: var(--magic-ink);
}

.list-end-action.primary > span:first-child,
body.light .list-end-action.primary > span:first-child {
  background: transparent;
  box-shadow: none;
  color: inherit;
}

main h1,
.unified-header strong {
  background-image: var(--title-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  color: transparent;
}

@media (forced-colors: active) {
  main h1,
  .unified-header strong {
    background-image: none;
    color: CanvasText;
  }
}

/* Selected player view and the spoken word use the same restrained accent as the dock: text only, no box. */
#player .np-tabs button.on,
#player .np-tabs button.on:hover,
#player .np-tabs button.on:active,
#player .np-tabs button.on:focus,
#player.unified .unified-footer .np-tabs button.on,
#player.unified .unified-footer .np-tabs button.on:hover,
#player.unified .unified-footer .np-tabs button.on:active,
#player.unified .unified-footer .np-tabs button.on:focus,
body.light #player.unified .unified-footer .np-tabs button.on {
  background: transparent;
  background-image: none;
  border-color: transparent;
  box-shadow: none;
  color: var(--magic-text, var(--magic));
  font-weight: 700;
}

#player .np-tabs button:focus-visible {
  outline: 2px solid var(--magic);
  outline-offset: 2px;
}

.word.active-word,
.timed-story .active-word,
.unified-content .lyric-line .word.active-word,
body.light .word.active-word,
body.light .timed-story .active-word,
body.light .unified-content .lyric-line .word.active-word {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  color: var(--magic-text, var(--magic));
  text-decoration-line: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 6px;
  text-decoration-color: currentColor;
}

/* iOS zooms into any focused field under 16px and keeps the zoom after sign-in. Keep every text control at 16px or larger. */
form input[name="email"],
form input[name="password"],
#quick-mood,
#quick-duration,
body.light form input[name="email"],
body.light form input[name="password"],
body.light #quick-mood,
body.light #quick-duration {
  font-size: 16px;
}

/* Player header: minimize on the left, Follow (Read Along only) on the right. */
.unified-header .header-spacer {
  display: block;
  width: 44px;
  height: 44px;
}

.unified-header .follow-toggle {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.unified-header .follow-toggle.on {
  color: var(--magic-text, var(--magic));
}

.unified-header .follow-toggle:focus-visible {
  outline: 2px solid var(--magic);
  outline-offset: 2px;
}


/* ==========================================================================
   PALETTE v2 (founder direction 2026-09-24)
   Light "day" palette after tesla.com: white paper, ink #171A20, one flat blue action.
   Dark "bedtime" palette after mystorybot.com: indigo night #06040D, lavender and violet.
   Flat buttons only; gradients live on titles. Every text pair is WCAG AA (4.5:1 or better).
   ========================================================================== */
:root,
body,
#player.unified,
#player.unified.reading,
#player.night,
#player.unified.night {
  --bg: #06040D;
  --panel: #14102A;
  --panel-raised: #1A1A2E;
  --input: #1A1633;
  --soft: #1E1838;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #F5F3FF;
  --text-strong: #FFFFFF;
  --muted: #B9B3CC;
  --faint: #8A83A3;
  --accent: #F5F3FF;
  --accent-contrast: #06040D;
  --shadow: rgba(0, 0, 0, 0.45);
  --warm-glow: rgba(168, 85, 247, 0.08);
  --sparkle: rgba(216, 180, 254, 0.10);
  --paper-highlight: rgba(255, 255, 255, 0.03);
  --magic: #9333EA;
  --magic-ink: #FFFFFF;
  --magic-text: #D8B4FE;
  --magic-soft: rgba(168, 85, 247, 0.12);
  --magic-soft-strong: rgba(168, 85, 247, 0.20);
  --magic-line: rgba(216, 180, 254, 0.40);
  --magic-ring: rgba(216, 180, 254, 0.55);
  --magic-glow: rgba(168, 85, 247, 0.18);
  --magic-highlight: #9333EA;
  --magic-highlight-hover: #7E22CE;
  --magic-progress: #A855F7;
  --primary: #9333EA;
  --primary-hover: #7E22CE;
  --primary-text: #FFFFFF;
  --primary-fill-hover: #7E22CE;
  --secondary-bg: rgba(255, 255, 255, 0.05);
  --secondary-bg-hover: rgba(255, 255, 255, 0.10);
  --secondary-border: rgba(255, 255, 255, 0.16);
  --secondary-text: #F5F3FF;
  --story-cta-bg: #9333EA;
  --story-cta-bg-hover: #7E22CE;
  --story-cta-text: #FFFFFF;
  --story-cta-border: transparent;
  --title-gradient: linear-gradient(100deg, #C4B5FD 0%, #D8B4FE 50%, #F0ABFC 100%);
}

body.light,
body.light #player.unified,
body.light #player.unified.reading,
body.light #player.night,
body.light #player.unified.night {
  --bg: #FFFFFF;
  --panel: #FFFFFF;
  --panel-raised: #FFFFFF;
  --input: #F4F4F4;
  --soft: #F4F4F4;
  --line: #E2E3E5;
  --line-strong: #D0D1D2;
  --text: #171A20;
  --text-strong: #171A20;
  --muted: #5C5E62;
  --faint: #8E8E8E;
  --accent: #171A20;
  --accent-contrast: #FFFFFF;
  --shadow: rgba(23, 26, 32, 0.08);
  --warm-glow: transparent;
  --sparkle: rgba(62, 106, 225, 0.05);
  --paper-highlight: rgba(255, 255, 255, 0.9);
  --magic: #3E6AE1;
  --magic-ink: #FFFFFF;
  --magic-text: #3E6AE1;
  --magic-soft: rgba(62, 106, 225, 0.08);
  --magic-soft-strong: rgba(62, 106, 225, 0.14);
  --magic-line: rgba(62, 106, 225, 0.45);
  --magic-ring: rgba(62, 106, 225, 0.45);
  --magic-glow: rgba(62, 106, 225, 0.14);
  --magic-highlight: #3E6AE1;
  --magic-highlight-hover: #3457C7;
  --magic-progress: #3E6AE1;
  --primary: #3E6AE1;
  --primary-hover: #3457C7;
  --primary-text: #FFFFFF;
  --primary-fill-hover: #3457C7;
  --secondary-bg: #F4F4F4;
  --secondary-bg-hover: #EAEAEA;
  --secondary-border: transparent;
  --secondary-text: #393C41;
  --story-cta-bg: #3E6AE1;
  --story-cta-bg-hover: #3457C7;
  --story-cta-text: #FFFFFF;
  --story-cta-border: transparent;
  --title-gradient: linear-gradient(100deg, #3E6AE1 0%, #6D5BF5 50%, #9333EA 100%);
}

body {
  background: var(--bg);
}

/* Button rigor: one shape, one height, one weight; flat fills; visible focus; clear pressed and disabled states. */
button.primary,
a.button.primary,
.list-end-action,
.list-end-action.primary,
button.quiet,
a.button.quiet,
form > button,
.actions > button,
.reader-tools > button.quiet {
  font-weight: 600;
  letter-spacing: 0;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

button.primary:active:not(:disabled),
.list-end-action:active:not(:disabled),
button.quiet:active:not(:disabled),
form > button:active:not(:disabled),
.actions > button:active:not(:disabled) {
  transform: translateY(1px);
}

button.primary:focus-visible,
a.button.primary:focus-visible,
.list-end-action:focus-visible,
button.quiet:focus-visible,
a.button.quiet:focus-visible,
form > button:focus-visible,
.actions > button:focus-visible {
  outline: 3px solid var(--magic-ring);
  outline-offset: 2px;
}

button.primary:disabled,
.list-end-action:disabled,
button.quiet:disabled,
form > button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Palette v2 surfaces: page, chrome and fields read the palette instead of legacy cream or warm-dark literals. */
html,
body,
body.light {
  background: var(--bg);
}

html:has(body.light) {
  background: #FFFFFF;
}

.app-header,
#nav,
#mini,
body.light .app-header,
body.light #nav,
body.light #mini {
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border-color: var(--line);
}

#app textarea,
#app input:not([type="range"]):not([type="checkbox"]):not([type="radio"]),
body.light #app textarea,
body.light #app input:not([type="range"]):not([type="checkbox"]):not([type="radio"]) {
  background: var(--input);
  border-color: var(--line);
  color: var(--text);
}

/* Selects keep their drawn arrow (a background image); only the fill changes. */
#app select,
body.light #app select {
  background-color: var(--input);
  border-color: var(--line);
  color: var(--text);
}

body.light #app textarea,
body.light #app input:not([type="range"]):not([type="checkbox"]):not([type="radio"]),
body.light #app select {
  border-color: transparent;
}

.chapter-list,
body.light .chapter-list {
  background: var(--panel);
  border-color: var(--line);
}

.chapter-list .number,
body.light .chapter-list .number {
  background: var(--soft);
  color: var(--text);
}

#sheet,
body.light #sheet {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
}

/* ==========================================================================
   DOCK: mini-player and bottom navigation form one composite unit.
   #dock owns position, width, surface and shape; its children are plain rows.
   ========================================================================== */
#dock {
  position: fixed;
  left: 50%;
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 17;
  width: min(700px, calc(100% - 20px));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 30px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  backdrop-filter: blur(18px) saturate(1.1);
  box-shadow: 0 12px 32px var(--shadow);
}

#dock:has(> #mini[hidden]):has(> #nav[hidden]) {
  display: none;
}

#dock #mini,
#dock #nav,
body.light #dock #mini,
body.light #dock #nav {
  position: static;
  inset: auto;
  transform: none;
  width: auto;
  max-width: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

#dock #mini:not([hidden]),
body.light #dock #mini:not([hidden]) {
  border-bottom: 1px solid var(--line);
}
/* "Something got stuck" popup (app.mjs blockerPopup). */
dialog.blocker { max-width: min(440px, calc(100vw - 32px)); border: 1px solid var(--line, rgba(127,127,127,.3)); border-radius: 18px; padding: 22px; background: var(--panel, #14102A); color: var(--text, inherit); box-shadow: 0 24px 60px rgba(0,0,0,.35); }
dialog.blocker::backdrop { background: rgba(6, 4, 13, .55); }
dialog.blocker h2 { margin: 0 0 8px; font-size: 22px; }
dialog.blocker p { margin: 0 0 12px; line-height: 1.45; }
dialog.blocker label { display: grid; gap: 6px; font-weight: 600; }
dialog.blocker textarea { width: 100%; font: inherit; border-radius: 12px; padding: 10px; border: 1px solid var(--line, rgba(127,127,127,.3)); background: var(--input, transparent); color: inherit; }
.blocker-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
/* The b mark goes to www.bhaashi.com; the product name stays the Stories home. */
.brand-group { display: inline-flex; align-items: center; gap: 10px; }
.bhaashi-mark img { display: block; width: 28px; height: 28px; border-radius: 8px; }
