:root {
  --bg: #f6f4f1;
  --card: #ffffff;
  --text: #1c1a22;
  --muted: #6b6775;
  --line: #e2ded8;
  --accent: #d6336c;
  --warm: #c2560c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121019;
    --card: #1d1a27;
    --text: #f1eef7;
    --muted: #a39db3;
    --line: #2e2a3c;
    --accent: #ff6b9d;
    --warm: #ffa94d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  padding: 0 16px 48px;
  max-width: 1200px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.material-symbols-outlined { font-size: 18px; vertical-align: -4px; }

/* The menu bar at the top of every page (templates/_nav.html): the logo, the categories of
   entertainment, and the support button. A category opens a panel under it showing one level
   of the hierarchy at a time; on narrow screens a menu button opens the same panel. */
.site-nav {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px 16px;
  padding: 20px 0 14px;
  border-bottom: 1px solid var(--line);
}
/* The logo shrinks to share a phone's width with the menu button. */
.brand { flex: 0 1 auto; min-width: 0; margin-right: 12px; }
.brand img { display: block; width: 354px; max-width: 100%; height: auto; }
.site-nav .support { flex-shrink: 0; white-space: nowrap; }
.menu { display: flex; align-items: center; gap: 4px; flex: 1; margin: 0; padding: 0; list-style: none; }
.menu-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.menu-link:hover, .menu-link[aria-expanded="true"] { background: var(--card); }
.menu-link.current { color: var(--accent); }
.menu-link[aria-expanded="true"] .material-symbols-outlined { transform: rotate(180deg); }
.menu-toggle {
  display: none;
  flex-shrink: 0;
  align-items: center;
  margin-left: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.menu-toggle .material-symbols-outlined { vertical-align: 0; }
.browse {
  position: absolute;
  top: 100%;
  left: 0;
  width: 340px;
  max-width: 100%;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.25);
}
.browse[hidden], .root[hidden] { display: none; }
.browse ul { margin: 0; padding: 0; list-style: none; }
/* Each level beneath another is indented, with a guide line down its left. */
.browse ul ul { margin: 2px 0 4px 14px; padding-left: 8px; border-left: 1px solid var(--line); }
.root-title { margin: 6px 12px; font-size: 1.0625rem; font-weight: 700; }
/* Under its name (the phone menu, or with several categories), a category's entries are
   indented like every other level; opened from the bar, the name is in the bar already. */
.root > ul { margin: 2px 0 4px 14px; padding-left: 8px; border-left: 1px solid var(--line); }
.browse.single .root-title { display: none; }
.browse.single .root > ul { margin: 0; padding-left: 0; border-left: 0; }
.root + .root { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.browse a, .browse summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  list-style: none;   /* a summary's disclosure triangle */
}
.browse summary::-webkit-details-marker { display: none; }
.browse a:hover, .browse summary:hover { background: var(--bg); color: var(--accent); }
.browse details[open] > summary { font-weight: 700; }
.browse summary .material-symbols-outlined { transition: transform 0.15s; }
.browse details[open] > summary .material-symbols-outlined { transform: rotate(180deg); }
.browse .level-all { color: var(--accent); font-weight: 600; }
.browse a[aria-current] { color: var(--accent); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .browse summary .material-symbols-outlined { transition: none; } }
/* Below this the categories give way to the menu button, whose panel is full width. With more
   categories in the bar, raise it so the bar still fits on one line above it (Games and Music
   need about 860). */
@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; }
  .menu { display: none; }
  .browse { right: 0; width: auto; }
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  padding: 20px 0 16px;
}
header > div:not(.status) { flex: 1 1 20em; min-width: 0; }
h1 { margin: 0; font-size: 1.5rem; line-height: 1.25; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; align-items: center; margin: 0 0 8px; padding: 0; list-style: none; color: var(--muted); font-size: 0.875rem; }
.breadcrumbs li { display: inline-flex; align-items: center; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs [aria-current] { color: var(--text); }
.breadcrumbs .material-symbols-outlined { margin: 0 2px; font-size: 16px; vertical-align: 0; }
.tagline { max-width: 70ch; margin: 4px 0 0; color: var(--muted); }
/* A section page's next level down (Games: GTA; GTA: each game), under its heading. */
.subnav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.subnav a {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}
.subnav a:hover { border-color: var(--accent); color: var(--accent); }
.subnav .material-symbols-outlined { font-size: 18px; vertical-align: 0; }
.status { text-align: right; color: var(--muted); font-size: 0.875rem; }
.status p { margin: 0; }
.live { color: var(--accent); font-weight: 600; }
.support { color: var(--accent); font-weight: 600; text-decoration: none; }
.support:hover { text-decoration: underline; }
.support.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--card);   /* white in light mode, near-black in dark: both pass contrast */
  font-size: 0.9375rem;
}
.support.button .material-symbols-outlined { vertical-align: 0; }
.support.button:hover { filter: brightness(1.1); text-decoration: none; }

nav.filters {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.chip {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

main {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  grid-auto-flow: dense;   /* small cards fill the gaps the wide ones leave */
  gap: 16px;
  padding-top: 16px;
}

.card {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.card[hidden] { display: none; }
.card h2 a { color: inherit; text-decoration: none; }
.card h2 a:hover { color: var(--accent); }
.thumb { display: block; }
.card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
/* Album artwork is square: shown whole on the card's colour rather than cropped. */
.card img.square { object-fit: contain; background: var(--line); }
.body { padding: 12px 14px 14px; }
.card h2 { margin: 0 0 6px; font-size: 1rem; line-height: 1.35; }
.meta { margin: 0; color: var(--muted); font-size: 0.8125rem; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
/* A story's pulse and level (stories.level); tapping it filters the feed to that level. */
.pulse {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px 2px 5px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: none;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.pulse:hover { filter: brightness(1.2); }
.pulse .level { margin-left: 3px; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.04em; }
.pulse small { font-size: 0.6875rem; font-weight: 600; opacity: 0.8; }
.pulse-flatlining { color: var(--muted); border-style: dashed; }
.pulse-low, .pulse-resting { color: var(--muted); }
.pulse-pumping { color: var(--text); }
.pulse-racing { color: var(--warm); }
.pulse-elevated { color: var(--accent); }
.pulse.pulse-svt { color: #fff; background: var(--accent); border-color: var(--accent); }
.card.hero .pulse { font-size: 1rem; }

/* Heart-rate tags beside the pulse. */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  cursor: help;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-spiking { color: var(--warm); border: 1px solid var(--warm); background: none; font-family: inherit; cursor: pointer; }
/* The filter bar's chip for the level being shown, and the line when nothing is at it. */
.chip.level-filter { display: inline-flex; align-items: center; gap: 4px; }
.chip.level-filter[hidden], .no-match[hidden] { display: none; }

/* Each story's own ECG. */
.tile-ecg { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.tile-ecg svg { flex: 1; min-width: 0; height: 22px; }
.tile-ecg path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.25;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.tile-ecg.flat path { stroke: var(--muted); stroke-dasharray: 3 3; }
.tile-ecg span { color: var(--muted); font-size: 0.6875rem; white-space: nowrap; }
.card.hero .tile-ecg svg { height: 32px; }
.growth { color: var(--accent); font-weight: 600; white-space: nowrap; }

.also, .wiki { margin: 8px 0 0; color: var(--muted); font-size: 0.8125rem; }
.wiki a { color: var(--text); text-underline-offset: 3px; text-decoration-color: var(--line); }
.also a {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-right: 8px;
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

/* Bigger cards for the stories with the most activity. Only on screens with room for them. */
.card.hero h2 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -0.01em; }
.card.wide h2 { font-size: 1.25rem; line-height: 1.25; }
@media (min-width: 600px) {
  .card.hero { grid-column: 1 / -1; }
  .card.wide { grid-column: span 2; }
  /* minmax(0, ...) so a wide tile ECG cannot stretch the text column and squeeze the
     picture's column to nothing (a 24-hour trace is 1,440 units wide). */
  .card.hero:has(.thumb) { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: center; }
  .card.hero img { height: 100%; max-height: 380px; }
  .card.hero .body { padding: 24px; }
  .card.hero h2 { margin-bottom: 12px; }
  .card.wide img { max-height: 260px; }
}

/* A spoiler card is blurred until its button, or the page toggle, reveals it. */
.card.spoiler :is(.thumb, h2, .badge) { filter: blur(14px); pointer-events: none; }
.card.spoiler.revealed :is(.thumb, h2, .badge),
body.show-spoilers .card.spoiler :is(.thumb, h2, .badge) { filter: none; pointer-events: auto; }
.reveal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.card.revealed .reveal, body.show-spoilers .reveal { display: none; }

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


/* A branch of the hierarchy (templates/_tree.html), in the footer site map and on section
   pages: sections and topics in bold, a topic's questions on one line per group. */
.tree ul, ul.tree { margin: 0; padding: 0; list-style: none; }
.tree li li { margin-top: 6px; }
.tree li > ul { padding-left: 16px; }
.tree a { color: var(--muted); text-decoration: none; }
.tree a:hover { color: var(--accent); }
.tree .section > a, .tree .topic > a { color: var(--text); font-weight: 700; }
.tree ul:has(> .question), ul.tree:has(> .question) { display: flex; flex-wrap: wrap; gap: 2px 12px; }
/* A topic's groups as two columns: the group's name, then its questions. Stacked on phones. */
.tree ul:has(> .group), ul.tree:has(> .group) { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; }
.tree .group { display: contents; }
.tree .group > span { color: var(--text); }
.tree .group > ul { padding-left: 0; }
.tree .question { margin-top: 0; }
@media (max-width: 600px) {
  .tree ul:has(> .group), ul.tree:has(> .group) { grid-template-columns: 1fr; gap: 2px; }
  .tree .group > ul { margin-bottom: 8px; }
}
.sitemap { padding-bottom: 8px; }
.sitemap > ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px 32px; }


footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8125rem;
}

/* The global ECG: always at the bottom of the screen, always dark like a heart monitor. */
body { padding-bottom: 104px; }
.ecg {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 max(16px, calc((100vw - 1200px) / 2));
  background-color: #0d0b13;
  background-image:
    linear-gradient(rgba(255, 107, 157, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 107, 157, 0.07) 1px, transparent 1px);
  background-size: 12px 12px;
  border-top: 1px solid #2e2a3c;
  color: #f1eef7;
}
.ecg-label { display: flex; align-items: center; gap: 4px; margin: 0; color: #a39db3; font-size: 0.75rem; white-space: nowrap; }
.ecg-label small { opacity: 0.8; }
.ecg-trace { flex: 1; min-width: 0; height: 40px; }
.ecg-trace path {
  fill: none;
  stroke: #ff6b9d;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.ecg-now { display: flex; align-items: center; gap: 5px; margin: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ecg-now strong { font-size: 1.25rem; }
.ecg-now small { color: #a39db3; font-size: 0.6875rem; font-weight: 600; }
.ecg .badge-spiking { color: #ffa94d; border-color: #ffa94d; }
.ecg .ecg-level { color: #f1eef7; border: 1px solid #2e2a3c; cursor: help; }
/* A pulse's small ECG (templates/_beat.html), on the strip and on every story's pulse, drawn
   like a heart monitor: a tip sweeps left to right along the trace drawing it ("new"), over the
   previous sweep's dimmer line ("old"), which is wiped just ahead of the tip. Two beats a
   sweep, at that pulse (--sweep) and as bright as it is high (--lit); static/app.js sets both.
   The trace is the #beat symbol in index.html, its length counted as 100 (pathLength), so the
   dash offsets below are shares of it; the tip's path must match its shape. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.beat { position: relative; display: inline-block; flex-shrink: 0; width: 32px; height: 12px; opacity: var(--lit, 1); }
.beat svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
.beat .new { stroke-dasharray: 100 100; animation: beat-draw var(--sweep, 2s) linear infinite; }
.beat .old { stroke-dasharray: 100 100; opacity: 0.4; animation: beat-wipe var(--sweep, 2s) linear infinite; }
.beat .tip {
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 3px currentColor;
  offset-path: path("M0 8 H3 Q4 6.6 5 8 H6 L6.8 9 L7.9 1 L9 11 L9.8 8 H11.5 Q12.75 6 14 8 H19 Q20 6.6 21 8 H22 L22.8 9 L23.9 1 L25 11 L25.8 8 H27.5 Q28.75 6 30 8 H32");
  offset-rotate: 0deg;
  animation: beat-tip var(--sweep, 2s) linear infinite;
}
.pulse .beat { margin: 0 3px 0 1px; }
.ecg-dot { color: #ff6b9d; }
@keyframes beat-draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes beat-wipe { from { stroke-dashoffset: -6; } to { stroke-dashoffset: -106; } }
@keyframes beat-tip { from { offset-distance: 0%; } to { offset-distance: 100%; } }
/* Without motion: the trace drawn whole and still. */
@media (prefers-reduced-motion: reduce) {
  .beat .new { animation: none; stroke-dashoffset: 0; }
  .beat .old, .beat .tip { display: none; }
}
.ecg-label .ecg-recent, .ecg-trace.ecg-recent { display: none; }
/* On phones the header's support button scrolls away at once, so it moves into the strip,
   which is always on screen. The strip is always dark, hence fixed colours. */
.support.ecg-support {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #ff6b9d;
  color: #0d0b13;
  font-size: 0.8125rem;
  white-space: nowrap;
}
.support.ecg-support .material-symbols-outlined { vertical-align: 0; }
.support.ecg-support:hover { filter: brightness(1.1); text-decoration: none; }
@media (max-width: 600px) {
  .site-nav .support { display: none; }   /* the strip at the bottom has it */
  .status { text-align: left; }
  .support.ecg-support { display: inline-flex; }
  .ecg .ecg-level { display: none; }   /* no room beside the support button */
  .ecg { gap: 8px; height: 48px; }
  .ecg-label { flex-direction: column; align-items: flex-start; gap: 0; }
  .ecg-label .material-symbols-outlined, .ecg-label .ecg-day, .ecg-trace.ecg-day { display: none; }
  .ecg-label .ecg-recent { display: inline; }
  .ecg-trace.ecg-recent { display: block; }
}

/* Time before the first reading: nothing to show, so a faint dotted line that can never be
   mistaken for a flatline (which is a dashed or solid flat stretch of the trace itself). */
.ecg-trace .nodata, .tile-ecg .nodata {
  stroke: currentColor;
  stroke-width: 1;
  stroke-dasharray: 1 5;
  stroke-linecap: round;
  opacity: 0.35;
  vector-effect: non-scaling-stroke;
}
.ecg-trace { color: #a39db3; }
.tile-ecg svg { color: var(--muted); }

/* The dark strip across the top of feed pages: the stories' language and the view options
   (minimal view, spoilers), kept out of the filter bar. Dark in both themes, like the pulse
   strip at the bottom. Its background runs the window's full width without widening the page. */
.top-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 4px 0;
  background: #0d0b13;
  color: #c9c3d6;
  font-size: 0.8125rem;
  box-shadow: 0 0 0 100vmax #0d0b13;
  clip-path: inset(0 -100vmax);
}
.language-picker { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.language-picker select {
  min-width: 0;
  max-width: 100%;
  padding: 3px 6px;
  border: 1px solid #2e2a3c;
  border-radius: 999px;
  background: #1d1a27;
  color: #f1eef7;
  font: inherit;
}
.view-options { display: flex; flex-shrink: 0; gap: 16px; margin-left: auto; }
/* The view options as small switches. */
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.switch input {
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 28px;
  height: 16px;
  margin: 0;
  border-radius: 999px;
  background: #2e2a3c;
  cursor: pointer;
  transition: background 0.15s;
}
.switch input::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f1eef7;
  transition: transform 0.15s;
}
.switch input:checked { background: #ff6b9d; }
.switch input:checked::before { transform: translateX(12px); }
.switch input:focus-visible { outline: 2px solid #ff6b9d; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .switch input, .switch input::before { transition: none; } }
/* On the narrowest phones the language box keeps room for its words. */
@media (max-width: 400px) {
  .top-strip { gap: 8px; }
  .language-picker .material-symbols-outlined { display: none; }
  .view-options { gap: 10px; }
}
/* On phones the filter bar is one row of chips to swipe along. */
@media (max-width: 600px) {
  nav.filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  nav.filters .chip { flex-shrink: 0; white-space: nowrap; }
}

/* Minimal view (the filter bar's switch, static/prefs.js): one line per story with its pulse,
   level, tags, title and trace, and no pictures; on phones the trace takes a second line. */
.minimal main#feed { display: flex; flex-direction: column; gap: 6px; }
.minimal .card .thumb, .minimal .card .meta, .minimal .card .wiki, .minimal .card .also,
.minimal .card .tile-ecg span { display: none; }
.minimal .card.hero:has(.thumb) { display: block; }
.minimal .card .body, .minimal .card.hero .body {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) minmax(100px, 28%);
  align-items: center;
  gap: 4px 12px;
  padding: 8px 12px;
}
.minimal .card .tags { margin: 0; flex-wrap: nowrap; }
.minimal .card h2, .minimal .card.hero h2, .minimal .card.wide h2 {
  margin: 0;
  overflow: hidden;
  font-size: 0.9375rem;
  line-height: 1.4;
  letter-spacing: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.minimal .card .tile-ecg { margin: 0; }
.minimal .card .tile-ecg svg, .minimal .card.hero .tile-ecg svg { height: 20px; }
@media (max-width: 600px) {
  .minimal .card .body, .minimal .card.hero .body { grid-template-columns: max-content minmax(0, 1fr); }
  .minimal .card .tile-ecg { grid-column: 1 / -1; }
}
