/* Tokens first. The shell's slot is the one that must survive every redesign:
   inside the Second Draft shell a 48px round button floats in the bottom-right
   corner, 16px in from each edge, above everything. Nothing tappable goes
   there. Applied everywhere, shell or not, so one stylesheet stays right. */
:root {
  --shell-switcher-size: 48px;
  --shell-switcher-inset: 16px;
  --shell-switcher-gap: 16px;
  --shell-slot: 80px; /* inset + size + gap: the corner the shell owns */

  /* Read in a dark room with no lamp on: nothing here is bright. The page is
     near-black and the ink is a warm, dimmed ivory — low light off the screen,
     but 12:1 against the background, so the letters are still easy. No pure
     white anywhere, and no large pale area to flare in the dark. */
  --paper: #0a0910;
  --ink: #d9c9a8;
  --quiet: #8b8073;
  --card: #12101a;
  --line: #221e2c;
  --accent: #b99a5e;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --reading: Georgia, 'Iowan Old Style', 'Palatino Linotype', Palatino, serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; background: var(--paper); }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--font); }
body { min-height: 100dvh; -webkit-text-size-adjust: 100%; }
::selection { background: #2c2540; color: var(--ink); }

.page {
  max-width: 34rem;
  margin: 0 auto;
  padding: 20px 22px calc(env(safe-area-inset-bottom, 0px) + var(--shell-slot));
}
.page-heading { font-family: var(--reading); font-size: 1.55rem; font-weight: 600; line-height: 1.3; margin: 0 0 6px; letter-spacing: 0.01em; }
.quiet { color: var(--quiet); margin: 0; }

/* The thin line of links at the top. Nothing lives at the bottom of this app,
   so the shell's corner stays empty by construction. */
.ribbon { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.ribbon nav { display: flex; gap: 16px; }
.dateline { color: var(--quiet); font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; margin: 0; }
a { color: var(--accent); text-decoration: none; border-bottom: 1px solid #4a3d28; padding-bottom: 1px; }
a:active { color: var(--ink); }

.meta { color: var(--quiet); font-size: 0.88rem; margin: 0 0 20px; }

/* The story. Long line height, roomy paragraphs, one column, nothing to press
   in the middle of it. */
.story { font-family: var(--reading); font-size: 1.18rem; line-height: 1.85; letter-spacing: 0.005em; }
.story p { margin: 0 0 1.25em; }
.story p.said { font-style: italic; color: #cdbb9c; margin-left: 1.1em; }
.story p:last-child { margin-bottom: 0; }
.the-end { color: var(--quiet); font-family: var(--reading); font-style: italic; margin: 28px 0 0; }

button, input, select, textarea { font: inherit; }
.button {
  appearance: none; border: 1px solid var(--line); border-radius: 12px; padding: 11px 16px;
  background: var(--card); color: var(--ink); cursor: pointer; min-height: 44px;
}
.button:active { background: #1a1726; }
/* Even the "on" state stays dim: a lit block of brass is the brightest thing
   in a dark room, and this app is read in one. */
.button[aria-pressed="true"] { background: #241d12; color: var(--accent); border-color: #5a4826; }
.button--wide { width: 100%; }
/* The ways to take tonight, on one line above the words: read or listen, and
   the story or the animal facts. Wrapping if the words in them are long. */
.ways { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 24px; }
.listen, .choice { margin: 0; display: flex; gap: 10px; align-items: center; }

.field { display: block; margin: 0 0 18px; }
.field > span { display: block; color: var(--quiet); font-size: 0.88rem; margin-bottom: 8px; }
select, input[type="search"] {
  appearance: none; width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
}
.times { display: flex; gap: 8px; align-items: center; }
.times .colon { color: var(--quiet); }
.times select { width: auto; flex: 1; }

/* The shelf of past nights. */
.shelf { list-style: none; padding: 0; margin: 18px 0 0; }
.shelf li { border-top: 1px solid var(--line); }
.shelf a { display: block; padding: 14px 0; border: 0; color: var(--ink); }
.shelf .when { display: block; color: var(--quiet); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 3px; }
/* What that night was: the story, or the facts. Every night says which. */
.shelf .kind { color: var(--accent); }
.shelf .kind::before { content: '·'; color: var(--quiet); margin: 0 0.5em; }
.shelf .what { font-family: var(--reading); font-size: 1.05rem; }
.shelf .peek { display: block; color: var(--quiet); font-size: 0.86rem; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.notice { color: var(--quiet); font-size: 0.88rem; border-left: 2px solid var(--line); padding-left: 12px; margin: 0 0 20px; }

/* Messages that are not the page: keep out of the shell's 80×80 corner. */
#toast {
  position: fixed; left: 16px; right: var(--shell-slot);
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--shell-switcher-inset));
  pointer-events: none;
}
#toast:empty { display: none; }
#toast > * { background: #1c1828; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font-size: 0.92rem; }
