/* Concept Stories: thoughtfeel's look (thoughtfeel.net): indigo and gold, Literata for reading,
   Schibsted Grotesk for headings and controls, IBM Plex Mono for small labels. */

@font-face { font-family: "Literata"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url(/fonts/literata-normal-400-600.woff2) format("woff2"); }
@font-face { font-family: "Literata"; font-style: italic; font-weight: 400; font-display: swap;
  src: url(/fonts/literata-italic-400.woff2) format("woff2"); }
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 500 700; font-display: swap;
  src: url(/fonts/schibsted-grotesk-normal-500-700.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/fonts/ibm-plex-mono-normal-400.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(/fonts/ibm-plex-mono-normal-500.woff2) format("woff2"); }

:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #e6e9f0;
  --ink: #19213a;
  --ink-2: #4b5369;
  --rule: #d3d8e2;
  --indigo: #2c3f8f;
  --indigo-soft: #dfe4f5;
  --on-indigo: #ffffff;
  --weld: #b87a1c;
  --gold: #e2a84a;
  --term: #7f5210;
  --ok: #2b7451;
  --ok-soft: #dcefe4;
  --miss: #a9412e;
  --miss-soft: #f6e0db;
  --shadow: 0 1px 2px rgba(25, 33, 58, .06), 0 8px 24px rgba(25, 33, 58, .06);
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #10131b;
    --surface: #181c27;
    --surface-2: #212634;
    --ink: #e5e8ef;
    --ink-2: #a4aabb;
    --rule: #2c3243;
    --indigo: #a5b5ff;
    --indigo-soft: #232b4a;
    --on-indigo: #10131b;
    --weld: #e2a84a;
    --term: #eab964;
    --ok: #7fd1a3;
    --ok-soft: #173326;
    --miss: #f09a86;
    --miss-soft: #3a1f1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 var(--serif);
  -webkit-font-smoothing: antialiased;
  padding: 0 max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
main, .appbar, .site-foot, .elsewhere { max-width: 720px; margin-inline: auto; }
[hidden] { display: none !important; }
a { color: var(--indigo); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2.5px solid var(--indigo); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -9999px; top: 8px; }
.skip:focus { left: 16px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 10px; }

h1, h2, h3 { font-family: var(--sans); font-weight: 700; letter-spacing: -0.015em; line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(26px, 6.5vw, 34px); }
h2 { font-size: clamp(21px, 5vw, 25px); margin-bottom: 8px; }
h3 { font-size: 18px; margin-bottom: 4px; }
p { margin: 10px 0; }
.display { font-size: clamp(34px, 9vw, 52px); line-height: 1.05; letter-spacing: -0.03em; }
.eyebrow { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--term); margin: 0 0 8px; }
.lede { font-size: clamp(18px, 4.6vw, 20px); line-height: 1.55; margin: 16px 0 0; max-width: 40ch; }
.sub { color: var(--ink-2); margin: 6px 0 12px; }
.fine { font-family: var(--sans); font-size: 14px; color: var(--ink-2); margin: 14px 0 0; }
.hint { font-family: var(--sans); font-size: 14px; color: var(--ink-2); margin: 6px 0 2px; line-height: 1.45; }
.warn { font-family: var(--sans); font-size: 15px; color: var(--miss); }
.empty { color: var(--ink-2); padding: 14px 4px; margin: 0; }

/* ── The bar at the top ───────────────────────────────────────────────────── */
.appbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 0 10px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-height: 44px; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-family: var(--sans); font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }
.brand-name .feel { color: var(--weld); }
.brand-app { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); margin-top: 3px; }
.appnav { display: flex; align-items: center; gap: 4px; }
.navlink { font-family: var(--sans); font-weight: 500; font-size: 15px; text-decoration: none; color: var(--ink-2); padding: 10px 10px; border-radius: 999px; min-height: 44px; display: inline-flex; align-items: center; }
.navlink:hover { color: var(--ink); background: var(--surface-2); }
.navlink.strong { color: var(--indigo); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--indigo); color: var(--on-indigo); display: inline-grid; place-items: center;
  font-family: var(--sans); font-weight: 700; font-size: 17px; text-decoration: none; margin-left: 4px; }
@media (max-width: 380px) { .navlink#nav-help { display: none; } }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 16px/1.2 var(--sans); letter-spacing: -0.005em;
  min-height: 46px; padding: 11px 20px;
  border-radius: 999px; border: 1.5px solid var(--indigo);
  background: transparent; color: var(--indigo);
  text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .15s, filter .15s, transform .05s;
}
.btn:hover { background: var(--indigo-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--indigo); color: var(--on-indigo); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.quiet { border-color: var(--rule); color: var(--ink-2); }
.btn.danger { border-color: var(--miss); color: var(--miss); }
.btn.quiet.danger { border-color: transparent; }
.btn.wide { display: flex; width: 100%; margin-top: 12px; }
.btn.big { min-height: 56px; font-size: 18px; }
.btn:disabled, .ctl:disabled { opacity: .45; cursor: default; transform: none; }
.btn .ico { width: 20px; height: 20px; fill: currentColor; margin-left: -4px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 4px; }
button { font: inherit; color: inherit; }

/* ── Cards and sections ───────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px; margin: 14px 0; box-shadow: var(--shadow); }
.card.narrow { max-width: 440px; margin: 6vh auto 0; padding: 24px 22px; }
.card h2:first-child, .card .eyebrow:first-child { margin-top: 0; }
.block { margin: 36px 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 14px 0 8px; }
.page-head h1 { overflow-wrap: anywhere; }
.back { display: inline-block; font-family: var(--sans); font-weight: 500; font-size: 15px; text-decoration: none; padding: 8px 0; margin-bottom: 2px; }
details > summary { cursor: pointer; font-family: var(--sans); font-weight: 600; list-style-position: outside; }
details[open] > summary { margin-bottom: 8px; }

/* The weave: an indigo warp and a gold weft, from thoughtfeel's mark. */
.weave {
  height: 14px; margin: 30px 0 6px; border-radius: 999px; opacity: .9;
  background:
    repeating-linear-gradient(90deg, transparent 0 18px, var(--surface) 18px 24px),
    linear-gradient(180deg, transparent 0 4px, var(--gold) 4px 10px, transparent 10px),
    repeating-linear-gradient(90deg, var(--indigo) 0 18px, transparent 18px 24px);
}

/* ── Welcome ──────────────────────────────────────────────────────────────── */
.hero { padding: 26px 0 0; display: grid; gap: 28px; }
.hero .actions { margin-top: 22px; }
/* A still of the player, so a visitor sees what listening looks like. */
.peek { margin: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 22px; padding: 0 20px 16px; box-shadow: var(--shadow); overflow: hidden; }
.peek .track-bar { margin: 0 -20px 16px; }
.peek .track-bar span { width: 17%; }
.peek .part-text { min-height: 0; font-size: 20px; margin: 10px 0 12px; }
.peek .controls { margin: 12px 0 0; pointer-events: none; }
.peek .ctl { min-height: 52px; font-size: 14px; }
.peek figcaption { font: 500 13px/1.4 var(--sans); color: var(--ink-2); text-align: center; margin-top: 12px; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 14px 0 0; display: grid; gap: 12px; }
.steps li { counter-increment: step; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px 14px 64px; position: relative; box-shadow: var(--shadow); }
.steps li::before {
  content: counter(step); position: absolute; left: 16px; top: 16px;
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--indigo-soft); color: var(--indigo); font: 700 17px/1 var(--sans);
}
.steps p { margin: 4px 0 0; color: var(--ink-2); font-size: 16px; }
.what p { max-width: 60ch; }
.what .links { display: flex; flex-direction: column; gap: 8px; font-family: var(--sans); font-weight: 600; font-size: 16px; margin-top: 14px; }

/* ── Story lists ──────────────────────────────────────────────────────────── */
.story-list { display: grid; gap: 10px; margin: 12px 0; }
.story {
  display: flex; position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow);
}
.story-open { flex: 1; min-width: 0; text-align: left; padding: 15px 16px 16px 18px; border: 0; background: transparent; cursor: pointer; display: block; text-decoration: none; color: var(--ink); }
.story-open:hover .story-title { color: var(--indigo); }
.story-title { display: block; font: 700 17.5px/1.3 var(--sans); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.story-meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-top: 6px; font: 500 14px/1.3 var(--sans); color: var(--ink-2); }
.story-act {
  flex: none; width: 72px; padding: 8px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; border-left: 1px solid var(--rule); background: transparent; color: var(--ink-2); font: 500 12px/1.2 var(--sans);
}
.story-act:hover { color: var(--indigo); background: var(--indigo-soft); }
.story-act svg { width: 22px; height: 22px; fill: currentColor; }
.story-progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--gold); border-radius: 0 3px 3px 0; width: 0; }
.badge { font: 600 12px/1.2 var(--sans); padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.busy { background: var(--indigo-soft); color: var(--indigo); }
.badge.example { background: transparent; border: 1px solid var(--rule); }
.badge.lang { background: transparent; border: 1px solid var(--rule); }
.archived { margin: 18px 0 4px; }
.archived > summary { color: var(--ink-2); padding: 8px 2px; }
.archived .story-title { color: var(--ink-2); }
.first { border-color: var(--indigo); }
.mini-steps { padding-left: 1.3em; margin: 8px 0 14px; }
.mini-steps li { margin: 4px 0; }
.tips ul { padding-left: 1.2em; margin: 8px 0 12px; }
.tips li { margin: 6px 0; }
.tips a { font-family: var(--sans); font-weight: 600; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form label, label.field { display: block; font: 600 15px/1.3 var(--sans); margin: 16px 0 6px; }
input[type=text], input[type=password], input:not([type]), textarea, select {
  font: 17px/1.4 var(--sans); width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--rule); background: var(--bg); color: var(--ink);
}
input:focus, textarea:focus, select:focus { border-color: var(--indigo); outline: none; box-shadow: 0 0 0 3px var(--indigo-soft); }
input[readonly] { color: var(--ink-2); }
textarea { font: 15px/1.5 var(--mono); resize: vertical; margin: 12px 0 4px; }
.pw { position: relative; }
.pw input { padding-right: 76px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--indigo);
  font: 600 14px/1 var(--sans); padding: 10px; cursor: pointer; min-height: 40px; }
.form-error { font: 500 15px/1.4 var(--sans); color: var(--miss); margin: 12px 0 0; min-height: 1px; }
.form-error:empty { display: none; }
.switch { font-family: var(--sans); margin: 18px 0 0; text-align: center; color: var(--ink-2); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
label.row { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; font: 500 16px/1.3 var(--sans); margin: 12px 0; }
label.row select { width: auto; max-width: 100%; }
.preview-card .lang-pick { margin: 4px 0 10px; }
label.row input[type=range] { width: 100%; accent-color: var(--indigo); }
label.check { justify-content: flex-start; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--indigo); }

/* ── New story ────────────────────────────────────────────────────────────── */
.flow { list-style: none; padding: 0; margin: 0; }
.flow-step { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 4px 12px; }
.step-n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--indigo); color: var(--on-indigo); font: 700 17px/1 var(--sans); margin-top: 1px; }
.flow-body p { margin: 6px 0; }
.flow-body h2 { margin-top: 4px; }
.prompt-box { margin-top: 10px; }
.prompt-box > summary { color: var(--indigo); }
.prompt-box pre { white-space: pre-wrap; font: 13.5px/1.5 var(--mono); background: var(--bg); border: 1px solid var(--rule); border-radius: 12px; padding: 12px; max-height: 340px; overflow: auto; }
.preview-card { border-top: 1px solid var(--rule); margin-top: 12px; padding-top: 10px; }
.preview-card h3 { margin-top: 4px; }
.preview-parts { padding-left: 1.4em; color: var(--ink-2); font-size: 16px; }
.preview-parts li { margin: 4px 0; }

/* ── Player ───────────────────────────────────────────────────────────────── */
.stage { padding: 0 18px 18px; overflow: hidden; }
.track-bar { height: 4px; margin: 0 -18px 16px; background: var(--surface-2); }
.track-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--indigo), var(--gold)); transition: width .3s; }
.part-number { font: 500 12px/1.2 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--term); margin: 0; }
.part-text { font: 400 clamp(21px, 5.6vw, 24px)/1.5 var(--serif); margin: 12px 0 8px; min-height: 4.5em; overflow-wrap: anywhere; }
.play-state { font: 600 16px/1.3 var(--sans); color: var(--indigo); margin: 8px 0 2px; text-align: center; }
.play-state[data-state=waiting] { color: var(--weld); }
.heard { display: table; margin: 6px auto; background: var(--indigo); color: var(--on-indigo); padding: 3px 14px; border-radius: 999px; font: 600 14px/1.4 var(--sans); }
.controls { display: grid; grid-template-columns: 1fr 1fr 1.35fr; gap: 10px; margin: 16px 0 4px; }
.ctl {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 74px; border-radius: 16px; border: 1.5px solid var(--rule); background: var(--surface); color: var(--ink);
  font: 600 15px/1.2 var(--sans); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.ctl .ico { width: 26px; height: 26px; fill: currentColor; }
.ctl.big { background: var(--indigo-soft); border-color: transparent; color: var(--indigo); }
.ctl:not(:disabled):active { transform: translateY(1px); }
.voice-line { display: flex; gap: 8px; align-items: center; justify-content: center; text-align: center; font: 500 14px/1.4 var(--sans); color: var(--ink-2); margin: 14px 0 0; min-height: 1.4em; }
#voice-status[data-state=error], #voice-status[data-state=mic-off], #voice-status[data-state=muted] { color: var(--miss); }
.level {
  --level: 0; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--ok);
  opacity: calc(.3 + var(--level) * .7); transform: scale(calc(.7 + var(--level) * .8)); transition: transform .08s, opacity .08s;
}
.prep p { margin: 6px 0; }
.prep .bar { margin: 12px 0 6px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--indigo); transition: width .3s; }
.coach { border-color: var(--gold); }
.coach ol { padding-left: 1.3em; margin: 6px 0; }
.coach li { margin: 6px 0; }
.help { margin-top: 14px; color: var(--ink-2); font-size: 16px; }
.help b { color: var(--ink); }
.parts { padding-left: 1.7em; margin: 0; font-size: 16px; }
.parts li { padding: 7px 6px; border-radius: 10px; cursor: pointer; }
.parts li:hover { background: var(--surface-2); }
.parts li.current { background: var(--indigo-soft); font-weight: 600; }
.story-actions { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 0; }
.example-note { border-color: var(--indigo); }
.elsewhere { position: sticky; top: 0; z-index: 5; margin: 0 auto 10px; padding: 10px 14px; border-radius: 14px; background: var(--indigo-soft); color: var(--ink); font: 500 15px/1.4 var(--sans); }

/* ── Help ─────────────────────────────────────────────────────────────────── */
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.toc a { font: 600 14px/1 var(--sans); text-decoration: none; padding: 9px 13px; border-radius: 999px; background: var(--surface); border: 1px solid var(--rule); }
.guide section { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px; margin: 14px 0; box-shadow: var(--shadow); scroll-margin-top: 16px; }
.guide h2 { margin-bottom: 6px; }
.controls-list dt { font: 700 16px/1.3 var(--sans); margin-top: 14px; }
.controls-list dd { margin: 4px 0 0; }

/* ── Account ──────────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.stats div { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.stats dt { font: 500 12px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.stats dd { margin: 4px 0 0; font: 700 22px/1.1 var(--sans); }
.danger-zone > summary { color: var(--miss); }

/* ── Footer, toast, pocket mode ───────────────────────────────────────────── */
.site-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; align-items: center; margin-top: 40px; padding: 18px 2px 4px;
  border-top: 1px solid var(--rule); font: 500 14px/1.4 var(--sans); color: var(--ink-2); }
.site-foot p { margin: 0; display: flex; align-items: center; gap: 8px; }
.foot-links { gap: 16px !important; }
.site-foot a { color: var(--ink-2); }
body[data-screen=player] .site-foot { display: none; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: max(18px, env(safe-area-inset-bottom));
  width: max-content; max-width: calc(100% - 32px); z-index: 60;
  display: flex; align-items: center; gap: 14px;
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 14px;
  font: 500 15px/1.4 var(--sans); box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
}
.toast-action { flex: none; min-height: 36px; padding: 4px 14px; background: transparent; color: inherit; border: 1.5px solid currentColor; border-radius: 999px; font: 600 14px/1 var(--sans); cursor: pointer; }
.pocket-cover {
  position: fixed; inset: 0; z-index: 50; background: #000;
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: #3a3a3a; font: 500 18px/1.5 var(--sans);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.pocket-cover span { font-size: 14px; }

/* The welcome screen is wider on a computer: the words beside the still of the player. */
@media (min-width: 900px) {
  body[data-screen=welcome] :is(main, .appbar, .site-foot) { max-width: 1000px; }
  .hero { grid-template-columns: minmax(0, 1fr) 380px; gap: 56px; align-items: center; }
}
@media (min-width: 720px) {
  body { font-size: 18px; }
  .hero { padding-top: 48px; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .steps li { padding: 64px 18px 16px; }
  .steps li::before { top: 18px; left: 18px; }
}
