/*
 * kanafox.com: the one stylesheet. Tokens follow docs/design.md section 4; every class is documented, with
 * the markup to copy, in docs/markup.md and shown in every state at /_fixtures/components.
 * Order: tokens, fonts, reset, base, layout, components, utilities. Components use tokens, never a raw
 * colour, so the dark theme is one token block. Pages compose these classes: a missing piece is reported
 * to the stylesheet's owner, never patched here or in a style attribute.
 */

/* ---------------------------------------------------------------------------------------------------- */
/* Tokens                                                                                               */
/* ---------------------------------------------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  /* Brand constants, the same in both themes. */
  --brand-vermilion: #e8562a;
  --brand-cream: #fff3e3;
  --brand-indigo: #1e2a5e;
  --gradient-plus: linear-gradient(135deg, #1e2a5e, #7a2c22);

  /* "Paper", the light theme (the default). */
  --bg: #fbf6ee;
  --surface: #fff;
  --surface-2: #f3ece0;
  --border: #e6ddcf;
  --field-border: #858a94;
  --text: #16181d;
  --muted: #5f646e;
  --ink: #1f2340;
  --accent: #e0501f;
  --link: #b83e12;
  --button: #c9461a;
  --button-hover: #b23d15;
  --on-button: #fff;
  --focus: #1f2340;
  --gold: #c98a12;
  --on-gold: #1f2340;
  --info: #1f2340;
  --info-bg: #edeff6;
  --success: #1a7a47;
  --success-bg: #e6f3ea;
  --warning: #a86b00;
  --warning-bg: #fbf0d6;
  --danger: #b3261e;
  --danger-bg: #fbe8e6;
  --danger-fill: #b3261e;
  --shadow: 0 1px 2px rgb(31 35 64 / 0.06), 0 4px 16px rgb(31 35 64 / 0.06);

  /* The transcript card is dark in both themes, as the app's player is. */
  --player-bg: #1b1e25;
  --player-text: #f7f2ea;
  --player-muted: #a3a8b3;
  --player-ruby: #f3b79e;
  --player-gloss: #f27a52;
  --player-highlight: #c9461a;

  /* Type: Nunito for Latin; Japanese and Korean use the system's fonts (each named, so that no browser falls
     back to a Chinese face and its glyph forms: Apple's, then Windows', then Android's and Linux's). */
  --font: Nunito, "Nunito Fallback", system-ui, sans-serif;
  --font-ja:
    "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", YuGothic, "Noto Sans JP", "Noto Sans CJK JP",
    Meiryo, sans-serif;
  --font-ko: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR", sans-serif;
  --text-sm: 0.875rem;
  --text-md: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: clamp(2rem, 1.6rem + 2vw, 2.75rem);

  /* Space: steps of 4, 8, 12, 16, 24, 32, 48 and 72 px; 20 px page padding. */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --gutter: 1.25rem;
  --page: 70rem;
  --measure: 56ch; /* about 70 characters of Nunito: its "0" is wider than the average letter */
  --tap: 2.75rem;

  /* Shape and motion. */
  --radius: 14px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --fast: 150ms;
  --slow: 200ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* "Ink", the dark theme. */
    --bg: #111318;
    --surface: #1b1e25;
    --surface-2: #252932;
    --border: #2c3039;
    --field-border: #737985;
    --text: #f7f2ea;
    --muted: #a3a8b3;
    --ink: #fff3e3;
    --accent: #e8562a;
    --link: #f27a52;
    /* The app lightens its button on hover; white on that is 4.0:1, so the web darkens it in both themes. */
    --button-hover: #b23d15;
    --focus: #f27a52;
    --gold: #f4b63f;
    --info: #a9b3e0;
    --info-bg: #1d2233;
    --success: #3dbe7a;
    --success-bg: #15261d;
    --warning: #f4b63f;
    --warning-bg: #2b2414;
    --danger: #f28b82;
    --danger-bg: #2e1a1b;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
  }
}

/* ---------------------------------------------------------------------------------------------------- */
/* Fonts: Nunito (SIL Open Font License, /assets/fonts/OFL-Nunito.*.txt), and Arial resized to Nunito's  */
/* metrics so that the swap moves nothing.                                                               */
/* ---------------------------------------------------------------------------------------------------- */

@font-face {
  font-family: Nunito;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/nunito-400.e4bdc1e6d0.woff2") format("woff2");
}

@font-face {
  font-family: Nunito;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/nunito-700.d514676104.woff2") format("woff2");
}

@font-face {
  font-family: Nunito;
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/assets/fonts/nunito-800.e17a019a15.woff2") format("woff2");
}

/* Overrides computed from the font files: the letter-frequency-weighted advance width against Arial's,
   and Nunito's ascent (1011) and descent (353) per 1000 units divided by that size. */
@font-face {
  font-family: "Nunito Fallback";
  font-weight: 400;
  src: local("Arial"), local("ArialMT");
  size-adjust: 101.91%;
  ascent-override: 99.2%;
  descent-override: 34.64%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Nunito Fallback";
  font-weight: 700;
  src: local("Arial Bold"), local("Arial-BoldMT");
  size-adjust: 97.85%;
  ascent-override: 103.32%;
  descent-override: 36.07%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Nunito Fallback";
  font-weight: 800;
  src: local("Arial Bold"), local("Arial-BoldMT");
  size-adjust: 100.11%;
  ascent-override: 100.99%;
  descent-override: 35.26%;
  line-gap-override: 0%;
}

/* ---------------------------------------------------------------------------------------------------- */
/* Reset                                                                                                */
/* ---------------------------------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* A faint vermilion flash on tap instead of the browser's grey box. */
  -webkit-tap-highlight-color: rgb(232 86 42 / 0.15);
}

img,
svg {
  display: block;
  max-inline-size: 100%;
  block-size: auto;
}

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

button {
  cursor: pointer;
}

/* The flows show and hide steps with the hidden attribute; no class may override it. */
[hidden] {
  /* biome-ignore lint/complexity/noImportantStyles: a component's display must never reveal a hidden step */
  display: none !important;
}

/* ---------------------------------------------------------------------------------------------------- */
/* Base                                                                                                 */
/* ---------------------------------------------------------------------------------------------------- */

html {
  scroll-padding-block-start: var(--space-5);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  display: flex;
  flex-direction: column;
  min-block-size: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

h1,
h2,
h3 {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.2;
  text-wrap: balance;
}

h1 {
  font-size: var(--text-3xl);
  letter-spacing: -0.01em;
}

h2 {
  font-size: var(--text-2xl);
}

h3 {
  font-size: var(--text-xl);
}

p,
li,
dd {
  text-wrap: pretty;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

strong,
b {
  font-weight: 800;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/*
 * Japanese and Korean, a whole page (<html lang="ja">) or a span in an English one (the home page's line of
 * dialogue): the system's faces, Latin letters and digits included (Nunito's round, wide Latin beside kana or
 * hangul read as pasted in on a trial page, docs/design.md 4), the line rules of each script, and no faked
 * italic (neither script has one). Japanese breaks between any two characters except before closing
 * punctuation and small kana (strict), and keeps phrases whole where the browser can find them. Korean breaks
 * at spaces, as its words are written; a word too long for its line (an address) still breaks.
 */
:lang(ja) {
  font-family: var(--font-ja);
  font-synthesis: weight;
  line-break: strict;
  word-break: normal;
}

:lang(ko) {
  font-family: var(--font-ko);
  font-synthesis: weight;
  line-break: strict;
  word-break: keep-all;
  overflow-wrap: break-word;
}

@supports (word-break: auto-phrase) {
  :lang(ja) {
    word-break: auto-phrase;
  }
}

/*
 * A whole page in Japanese or Korean. Full-width characters are 1em wide and fill the line's height, so the
 * reading measure is counted in them (36 to a line, where English has about 70 letters), lines get more air,
 * and the display sizes are a step smaller than Latin at the same weight, which would look heavy. Headings
 * keep their tracking (a negative one crowds the characters) and take Japanese's proportional punctuation.
 */
:root:is(:lang(ja), :lang(ko)) {
  --measure: 36em;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: clamp(1.625rem, 1.4rem + 1.2vw, 2.25rem);
}

:root:lang(ja) body {
  line-height: 1.8;
}

:root:lang(ko) body {
  line-height: 1.75;
}

:root:is(:lang(ja), :lang(ko)) :is(h1, h2, h3) {
  line-height: 1.4;
  letter-spacing: normal;
}

:root:lang(ja) :is(h1, h2, h3) {
  font-feature-settings: "palt";
}

/* ---------------------------------------------------------------------------------------------------- */
/* Layout                                                                                               */
/* ---------------------------------------------------------------------------------------------------- */

.wrap {
  inline-size: 100%;
  max-inline-size: calc(var(--page) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* The plain layout and other reading pages: one column at a comfortable measure. */
.wrap--narrow {
  max-inline-size: calc(46rem + 2 * var(--gutter));
}

main {
  flex: 1;
}

.section {
  padding-block: clamp(var(--space-7), 2rem + 4vw, var(--space-8));
}

/* Consecutive sections are spaced by the bottom padding alone, so the rhythm is the same after the hero. */
:is(.section, .hero) + .section {
  padding-block-start: 0;
}

/* A section's heading and lead, kept to a readable measure. */
.section-head {
  display: grid;
  gap: var(--space-3);
  max-inline-size: 40rem;
  margin-block-end: var(--space-6);
}

.lead {
  color: var(--muted);
  font-size: var(--text-lg);
}

.prose {
  max-inline-size: var(--measure);
}

.prose > * + * {
  margin-block-start: var(--space-4);
}

.prose > * + :is(h2, h3) {
  margin-block-start: var(--space-6);
}

.prose h3 {
  font-size: var(--text-lg);
}

.stack {
  display: grid;
  gap: var(--space-4);
}

/* A section's heading beside its content on wide screens, above it on phones. */
.split {
  display: grid;
  gap: var(--space-5);
}

.split > .section-head {
  margin-block-end: 0;
}

@media (width >= 56rem) {
  .split {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    align-items: start;
    column-gap: var(--space-7);
  }
}

/* The blocks of a plain page or a flow, one under another. A grid gap, not margins, because the gap skips
   what takes no room: the live region (positioned) and every hidden step, notice or banner. */
.flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  row-gap: var(--space-7);
}

/* ---------------------------------------------------------------------------------------------------- */
/* Components: shared (buttons, lists, small text), before the sections that adjust them                 */
/* ---------------------------------------------------------------------------------------------------- */

/* Buttons: pills, 48 px tall. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-block-size: 3rem;
  padding: var(--space-2) var(--space-5);
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--button);
  color: var(--on-button);
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  transition:
    background-color var(--fast) var(--ease),
    border-color var(--fast) var(--ease);
}

.button:hover {
  background: var(--button-hover);
}

.button--secondary {
  border-color: var(--link);
  background: transparent;
  color: var(--link);
}

.button--secondary:hover {
  background: var(--surface-2);
}

/* A quiet button reads as a link and lines up with the text around it. */
.button--quiet {
  min-block-size: var(--tap);
  padding-inline: 0;
  border-width: 0;
  background: transparent;
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.button--quiet:hover {
  background: transparent;
  text-decoration-thickness: 2px;
}

.button--danger {
  background: var(--danger-fill);
}

.button--danger:hover {
  background: var(--danger-fill);
  border-color: var(--text);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button:disabled:hover {
  background: var(--button);
}

.button--secondary:disabled:hover,
.button--quiet:disabled:hover {
  background: transparent;
}

.button--danger:disabled:hover {
  background: var(--danger-fill);
  border-color: transparent;
}

/* Busy: the script sets aria-busy="true" and disabled, and changes the label ("Sending..."). */
.button[aria-busy="true"] {
  cursor: progress;
  opacity: 1;
}

.button[aria-busy="true"]::before,
.spinner {
  content: "";
  flex: none;
  inline-size: 1em;
  block-size: 1em;
  border: 2.5px solid currentcolor;
  border-inline-end-color: transparent;
  border-radius: 50%;
}

@media (prefers-reduced-motion: no-preference) {
  .button[aria-busy="true"]::before,
  .spinner {
    animation: spin 0.8s linear infinite;
  }
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

@media (width < 30rem) {
  .actions > .button:not(.button--quiet) {
    flex: 1 1 100%;
  }
}

.badge {
  display: inline-block;
  padding: 0.125rem var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--gold);
  color: var(--on-gold);
  font-size: var(--text-sm);
  font-weight: 800;
}

/* A list whose items carry a small tick drawn in CSS: "what Plus includes". */
.ticks {
  display: grid;
  gap: var(--space-2);
  padding: 0;
  list-style: none;
}

.ticks li {
  position: relative;
  padding-inline-start: var(--space-6);
}

.ticks li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0.35rem;
  inset-block-start: 0.4em;
  inline-size: 0.45rem;
  block-size: 0.8rem;
  border-block-end: 2.5px solid var(--success);
  border-inline-end: 2.5px solid var(--success);
  transform: rotate(45deg);
}

.fine {
  color: var(--muted);
  font-size: var(--text-md);
}

/* Waiting for an answer: a spinner and a sentence; the live region announces the sentence. */
.loading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-block-size: var(--tap);
  color: var(--muted);
}

.loading .spinner {
  color: var(--link);
}

/* ---------------------------------------------------------------------------------------------------- */
/* Components: page chrome                                                                              */
/* ---------------------------------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-2);
  z-index: 10;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--link);
  font-weight: 700;
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: none;
}

/* The wordmark is set in Nunito in every language, as in the app. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-block-size: var(--tap);
  color: inherit;
  font-family: var(--font);
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand img {
  inline-size: 2rem;
}

/* The marketing header is the stand's noren: an indigo curtain split into flaps along its hem. */
.noren {
  --focus: var(--brand-cream);
  --hem: 1.25rem;
  position: relative;
  padding-block: var(--space-2) calc(var(--hem) + var(--space-2));
  background: var(--brand-indigo);
  color: var(--brand-cream);
}

.noren::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  block-size: var(--hem);
  background:
    linear-gradient(var(--bg) 0 0) 25% 0 / 4px 100% no-repeat,
    linear-gradient(var(--bg) 0 0) 50% 0 / 4px 100% no-repeat,
    linear-gradient(var(--bg) 0 0) 75% 0 / 4px 100% no-repeat;
}

.noren-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: var(--space-5);
}

.noren-nav ul {
  display: flex;
  flex-wrap: wrap;
  margin-inline-start: calc(-1 * var(--space-3));
  padding: 0;
  list-style: none;
}

.noren-nav a {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--tap);
  padding-inline: var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--brand-cream);
  font-weight: 700;
  text-decoration: none;
}

.noren-nav a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

/* The plain header: the logo, not a link, and nothing else (docs/design.md section 3). */
.plain-header {
  padding-block: var(--space-3);
  border-block-end: 1px solid var(--border);
  color: var(--ink);
}

.site-footer {
  padding-block: var(--space-7) var(--space-6);
  background: var(--surface-2);
  color: var(--text);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: var(--space-6) var(--space-5);
}

.footer-title {
  margin-block-end: var(--space-2);
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 800;
}

.footer-links {
  padding: 0;
  list-style: none;
}

/* In a list of links the list says "these are links", so they go without an underline until hovered. */
.footer-links a {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--tap);
  color: var(--ink);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--link);
  text-decoration: underline;
}

.footer-company {
  display: grid;
  gap: var(--space-2);
  margin-block-start: var(--space-6);
  padding-block-start: var(--space-5);
  border-block-start: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--text-md);
  max-inline-size: var(--measure);
}

/* The plain footer links only to the other plain pages. */
.plain-footer {
  margin-block-start: var(--space-8);
  padding-block: var(--space-6);
  border-block-start: 1px solid var(--border);
}

.plain-footer .footer-links {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--space-5);
}

.plain-footer .footer-company {
  margin-block-start: var(--space-3);
  padding-block-start: 0;
  border: 0;
}

/* The region switcher (priced pages) and the language switcher (plain pages), first in the footer: plain
   links as pills, each named in its own language, never a flag. The current one is filled and ticked, so it
   is told by more than colour. */
.switcher {
  margin-block-end: var(--space-6);
  padding-block-end: var(--space-5);
  border-block-end: 1px solid var(--border);
}

.switcher-title {
  margin-block-end: var(--space-3);
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 800;
}

.switcher-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0;
  list-style: none;
}

.switcher-list a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-block-size: var(--tap);
  padding-inline: var(--space-4);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-pill);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.switcher-list a:hover {
  border-color: var(--link);
  color: var(--link);
}

.switcher-list a[aria-current="page"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

/* The tick of .ticks, drawn in the text's colour. */
.switcher-list a[aria-current="page"]::before {
  content: "";
  inline-size: 0.35em;
  block-size: 0.7em;
  margin-block-start: -0.2em;
  border: solid currentcolor;
  border-width: 0 0.15em 0.15em 0;
  transform: rotate(45deg);
}

.plain-footer .switcher {
  margin-block-end: var(--space-4);
  padding-block-end: var(--space-4);
}

/* ---------------------------------------------------------------------------------------------------- */
/* Components: home                                                                                     */
/* ---------------------------------------------------------------------------------------------------- */

.hero {
  display: grid;
  gap: var(--space-5);
  padding-block: var(--space-6) var(--space-7);
}

.hero-text {
  display: grid;
  gap: var(--space-4);
  max-inline-size: 36rem;
}

.hero-text .lead {
  color: var(--text);
}

/* The fox mark on a round crest, like the mark dyed on a shop's noren. */
.hero-mark {
  --size: clamp(7.5rem, 26vw, 18rem);
  inline-size: var(--size);
  padding: calc(var(--size) * 0.12);
  border-radius: 50%;
  background: var(--surface-2);
}

.hero-actions {
  display: grid;
  gap: var(--space-3);
  margin-block-start: var(--space-2);
}

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

@media (width >= 30rem) {
  .hero-actions {
    display: flex;
    flex-wrap: wrap;
  }
}

@media (width >= 44rem) {
  .hero {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    align-items: center;
    padding-block: var(--space-8);
  }

  .hero-mark {
    order: 2;
    justify-self: center;
  }
}

/* A line of dialogue as the app's transcript shows it: furigana, romaji and the meaning under each word. */
.scene {
  --focus: var(--player-gloss);
  display: grid;
  gap: var(--space-4);
  max-inline-size: 40rem;
  padding: var(--space-5) var(--space-4);
  border-radius: var(--radius);
  background: var(--player-bg);
  color: var(--player-text);
  box-shadow: var(--shadow);
}

.scene-meta {
  color: var(--player-muted);
  font-size: var(--text-md);
}

.scene-speaker {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
}

.scene-speaker::before {
  content: "";
  inline-size: 0.75rem;
  block-size: 0.75rem;
  border-radius: 50%;
  background: var(--brand-vermilion);
}

.scene-words {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-3) var(--space-2);
  padding: 0;
  list-style: none;
}

/* Each word is a button that opens its sheet. Where the Popover API is missing it would do nothing, so it
   looks like plain text until the @supports rule below makes it a chip. */
.word {
  display: grid;
  justify-items: center;
  min-inline-size: 3rem;
  max-inline-size: 9rem;
  padding: var(--space-1) var(--space-2) var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  text-align: center;
  cursor: default;
}

/* Every word's Japanese line is the same height, with room for furigana, so the rows line up. A step
   smaller on the narrowest phones, with a narrower gap between words, so two words share a row there in
   WebKit too (at 320 px its first two words miss the row by a pixel with the usual gap). */
.word-ja {
  font-size: 1.5rem;
  line-height: 2.3;
}

@media (width < 24rem) {
  .scene-words {
    column-gap: var(--space-1);
  }

  .word-ja {
    font-size: 1.375rem;
  }
}

:is(.word-ja, .sheet-word) rt {
  color: var(--player-ruby);
  font-size: 0.5em;
}

.word-roman {
  margin-block-start: -0.35rem;
  color: var(--player-muted);
  font-size: var(--text-md);
}

.word-gloss {
  color: var(--player-gloss);
  text-wrap: balance;
  font-size: var(--text-md);
  font-weight: 700;
  line-height: 1.3;
}

.scene-translation {
  padding-block-start: var(--space-3);
  border-block-start: 1px solid color-mix(in srgb, var(--player-text) 12%, transparent);
  font-size: var(--text-lg);
}

@media (width >= 30rem) {
  .scene {
    padding: var(--space-6);
  }
}

/* The word sheet, as the app shows it: a popover in the top layer, so it opens on a tap or Enter and closes on
   Done, Escape or a tap outside with no script. Dark in both themes, like the card. A bottom sheet on phones,
   a card in the middle of the screen from 40rem. */
.sheet {
  --focus: var(--player-gloss);
  inset: auto 0 0;
  inline-size: auto;
  max-block-size: 85dvh;
  margin: 0;
  overscroll-behavior: contain;
  padding: var(--space-5) var(--gutter);
  border: 0;
  border-block-start: 1px solid color-mix(in srgb, var(--player-text) 12%, transparent);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--player-bg);
  color: var(--player-text);
}

/* The popover's own display rule only hides it when closed, so the layout applies to the open state alone. */
.sheet:popover-open {
  display: grid;
  gap: var(--space-3);
}

/* The sheet takes focus when it opens (autofocus), so a screen reader reads it; Done carries the ring. */
.sheet:focus-visible {
  outline: none;
}

.sheet::backdrop {
  background: color-mix(in srgb, var(--brand-indigo) 45%, transparent);
}

.sheet-word {
  color: var(--player-text);
  font-size: 2rem;
  line-height: 1.6;
}

.sheet-reading {
  margin-block-start: calc(-1 * var(--space-3));
  color: var(--player-muted);
}

/* The part of speech, as the app's small vermilion chip. */
.sheet-pos {
  justify-self: start;
  padding-inline: var(--space-3);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--player-highlight) 25%, transparent);
  color: var(--player-gloss);
  font-size: var(--text-sm);
  font-weight: 700;
}

.sheet-meaning {
  font-size: var(--text-xl);
  font-weight: 800;
  line-height: 1.3;
}

.sheet-note {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--player-text) 7%, transparent);
}

/* The app's (i) before a note: drawn here, and silent to screen readers (the empty alternative text). */
.sheet-note::before {
  content: "i" / "";
  display: grid;
  place-items: center;
  inline-size: 1.25rem;
  block-size: 1.25rem;
  margin-block-start: 0.2rem;
  border: 2px solid var(--player-gloss);
  border-radius: 50%;
  color: var(--player-gloss);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1;
}

.sheet-done {
  justify-self: end;
  min-block-size: var(--tap);
  padding-inline: var(--space-5);
  border: 0;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--player-text) 10%, transparent);
  font-weight: 800;
}

.sheet-done:hover {
  background: color-mix(in srgb, var(--player-text) 18%, transparent);
}

@media (width >= 40rem) {
  .sheet {
    inset: 0;
    inline-size: 24rem;
    max-inline-size: calc(100% - 2 * var(--gutter));
    block-size: fit-content;
    margin: auto;
    padding: var(--space-5);
    border: 0;
    border-radius: var(--radius);
  }
}

/* With the Popover API the words are chips that say "tap me", and the word whose sheet is open is lit as
   the app lights the word being said. Without it the sheets stay hidden and the words stay plain text. */
@supports selector(:popover-open) {
  .word {
    background: color-mix(in srgb, var(--player-text) 8%, transparent);
    cursor: pointer;
    transition: background-color var(--fast) var(--ease);
  }

  li:has(> .sheet:popover-open) > .word {
    background: var(--player-highlight);
  }

  li:has(> .sheet:popover-open) > .word :is(.word-ja, .word-roman, .word-gloss, rt) {
    color: var(--on-button);
  }
}

@media (hover: hover) {
  @supports selector(:popover-open) {
    .word:hover {
      background: color-mix(in srgb, var(--player-text) 16%, transparent);
    }
  }
}

@supports not selector(:popover-open) {
  .sheet {
    display: none;
  }
}

/* The sheet rises a little as it fades in, and leaves the same way; nothing moves under reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  .sheet {
    transition:
      opacity var(--slow) var(--ease),
      translate var(--slow) var(--ease),
      display var(--slow) allow-discrete,
      overlay var(--slow) allow-discrete;
  }

  .sheet:not(:popover-open) {
    opacity: 0;
    translate: 0 1rem;
  }

  @starting-style {
    .sheet:popover-open {
      opacity: 0;
      translate: 0 1rem;
    }
  }
}

/* Your languages: each by its own name in its own script (never a flag), the others' English names after. */
.languages {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) clamp(var(--space-4), 4vw, var(--space-6));
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.languages li {
  display: grid;
}

/* Sized with the screen, so the three names share one row on a 320 px phone. */
.language-name {
  color: var(--ink);
  font-size: clamp(1.5rem, 1rem + 2.5vw, 2.75rem);
  font-weight: 800;
  line-height: 1.2;
}

/* The closing band: episode 1's callback, then the hero's first button again. */
.closing {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  text-align: center;
}

.closing img {
  inline-size: 4.5rem;
}

.closing h2 {
  font-size: var(--text-3xl);
}

.closing .lead {
  max-inline-size: 32rem;
  text-wrap: balance;
}

/* How it works: three steps, each a real screen of the app (no device frame). */
.steps {
  display: grid;
  gap: var(--space-7);
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.step-card {
  display: grid;
  gap: var(--space-3);
  align-content: start;
  counter-increment: step;
}

.step-card h3::before {
  content: counter(step);
  display: inline-grid;
  place-items: center;
  inline-size: 2rem;
  block-size: 2rem;
  margin-inline-end: var(--space-3);
  border-radius: 50%;
  background: var(--button);
  color: var(--on-button);
  font-size: var(--text-md);
  vertical-align: 0.15em;
}

.step-card p {
  max-inline-size: 30rem;
}

.step-card img {
  inline-size: min(15rem, 70%);
  margin-block-start: var(--space-3);
  filter: drop-shadow(0 6px 18px rgb(31 35 64 / 0.18));
}

@media (width >= 48rem) {
  .steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-6);
  }

  .step-card {
    grid-template-rows: auto 1fr auto;
  }

  .step-card img {
    inline-size: min(15rem, 100%);
  }
}

/* The town: cast portraits with their blurbs, then series covers. */
.cast {
  display: grid;
  gap: var(--space-5);
  padding: 0;
  list-style: none;
}

.cast-member {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: var(--space-4);
  align-items: center;
}

.cast-member img {
  inline-size: 5rem;
  border-radius: 50%;
}

.cast-member h3 {
  font-size: var(--text-lg);
}

.cast-member p {
  color: var(--muted);
}

@media (width >= 40rem) {
  .cast {
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  }
}

@media (width >= 64rem) {
  .cast {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .cast-member {
    grid-template-columns: 1fr;
    align-content: start;
    justify-items: start;
  }

  .cast-member img {
    inline-size: 6rem;
  }
}

.series-list {
  display: grid;
  gap: var(--space-5);
  margin-block-start: var(--space-7);
  padding: 0;
  list-style: none;
}

.series {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.series img {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.series h3 {
  margin-block-start: var(--space-2);
  font-size: var(--text-lg);
}

.series p {
  margin-block-start: var(--space-2);
}

@media (width >= 40rem) {
  .series {
    grid-template-columns: 10rem minmax(0, 1fr);
    gap: var(--space-5);
  }
}

@media (width >= 64rem) {
  .series-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-6);
  }
}

.series-list + .fine {
  margin-block-start: var(--space-6);
  max-inline-size: var(--measure);
}

/* Follow Kanafox: one large labelled link per account; one looks complete, three stack neatly. */

.social {
  display: grid;
  gap: var(--space-3);
  padding: 0;
  list-style: none;
}

.social-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--space-4);
  min-block-size: 4.5rem;
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: border-color var(--fast) var(--ease);
}

.social-link:hover {
  border-color: var(--accent);
}

.social-name {
  color: var(--ink);
  font-size: var(--text-xl);
  font-weight: 800;
}

.social-handle {
  grid-column: 1;
  color: var(--muted);
}

.social-link svg {
  grid-row: 1 / span 2;
  grid-column: 2;
  inline-size: 1.5rem;
  color: var(--link);
}

/* Pricing: the Plus band with the region's plans, then the notes. */
.pricing > * + * {
  margin-block-start: var(--space-6);
}

/* The Plus band: the app paywall's gradient. */
.plus-band {
  --focus: var(--brand-cream);
  display: grid;
  gap: var(--space-5);
  padding: var(--space-6) var(--space-4);
  border-radius: var(--radius);
  background: var(--gradient-plus);
  color: var(--brand-cream);
}

.plus-band h2 {
  color: var(--brand-cream);
  font-size: var(--text-3xl);
}

.plus-tagline {
  font-size: var(--text-lg);
  font-weight: 700;
}

.plus-band .ticks li::before {
  border-color: var(--brand-cream);
}

/* Where the prices apply, and the way to the region switcher: cream on the band, the link underlined. */
.plus-band a {
  color: var(--brand-cream);
}

.price-region {
  font-weight: 700;
}

@media (width >= 30rem) {
  .plus-band {
    padding: var(--space-7) var(--space-6);
  }
}

@media (width >= 56rem) {
  .plus-band {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    align-items: start;
    column-gap: var(--space-7);
  }
}

/* Download: one line per store until a store is live (no official badges before then). */
.stores {
  display: grid;
  gap: var(--space-3);
  padding: 0;
  list-style: none;
}

.store {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-5);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}

.store-name {
  color: var(--ink);
  font-size: var(--text-xl);
  font-weight: 800;
}

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

@media (width >= 40rem) {
  .stores {
    grid-template-columns: repeat(2, minmax(0, 18rem));
  }
}

/* Questions: native disclosure, no script. */
.faq {
  max-inline-size: 46rem;
  border-block-start: 1px solid var(--border);
}

.faq details {
  border-block-end: 1px solid var(--border);
}

.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-block-size: var(--tap);
  padding-block: var(--space-4);
  color: var(--ink);
  font-weight: 800;
  list-style: none;
  cursor: pointer;
}

.faq summary::-webkit-details-marker {
  display: none;
}

/* A chevron drawn with two borders, turned up when open. */
.faq summary::after {
  content: "";
  flex: none;
  inline-size: 0.6rem;
  block-size: 0.6rem;
  margin-inline-end: var(--space-2);
  border-block-end: 2.5px solid var(--link);
  border-inline-end: 2.5px solid var(--link);
  transform: translateY(-25%) rotate(45deg);
}

.faq details[open] summary::after {
  transform: translateY(25%) rotate(-135deg);
}

.faq details > :not(summary) {
  padding-block-end: var(--space-5);
  max-inline-size: var(--measure);
}

@media (prefers-reduced-motion: no-preference) {
  .faq summary::after {
    transition: transform var(--slow) var(--ease);
  }
}

/* ---------------------------------------------------------------------------------------------------- */
/* Components: plans and prices (home and /plus)                                                        */
/* ---------------------------------------------------------------------------------------------------- */

.plans {
  display: grid;
  gap: var(--space-4);
  padding: 0;
  list-style: none;
}

.plan {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-5);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* The plan the visitor chose, on the confirmation step and in the sign-in step. */
.plan[data-selected] {
  border-color: var(--button);
}

.plan-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-block-end: var(--space-2);
}

.plan-name {
  color: var(--ink);
  font-size: var(--text-xl);
}

.plan-price {
  color: var(--ink);
  font-weight: 700;
}

/* The amount billed per period is the largest figure on the card (docs/design.md section 7). */
.plan-amount {
  font-size: 2.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.plan-per-month,
.plan-tax {
  color: var(--muted);
}

.plan-trial {
  margin-block-start: var(--space-2);
  font-weight: 700;
}

/* The card's action sits at its foot, so cards side by side line their buttons up. The auto margin takes
   the spare height; the margin before it keeps the gap when there is none. */
.plan > .button {
  margin-block-start: auto;
}

.plan > :has(+ .button) {
  margin-block-end: var(--space-4);
}

@media (width >= 36rem) {
  .plans {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Rows of a label and a value: the order on /plus, identity lists, what is deleted and what is kept. */
.rows {
  display: grid;
  border-block-start: 1px solid var(--border);
}

.rows > div {
  display: grid;
  gap: var(--space-1);
  padding-block: var(--space-3);
  border-block-end: 1px solid var(--border);
}

.rows dt {
  color: var(--muted);
  font-weight: 700;
}

.rows dd {
  max-inline-size: var(--measure);
}

/* Stacked rows name an item (what is kept, a purchase record): the name is the heading of its row. */
.rows--stacked dt {
  color: var(--ink);
}

@media (width >= 36rem) {
  .rows:not(.rows--stacked) > div {
    grid-template-columns: 11rem minmax(0, 1fr);
    gap: var(--space-4);
  }
}

/* ---------------------------------------------------------------------------------------------------- */
/* Components: flows (/plus, /plus/thanks, /cancel, /delete-account)                                    */
/* ---------------------------------------------------------------------------------------------------- */

/* A card groups one part of a page; the accent card is the one to act in. */
.card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  padding: var(--space-5) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.card--accent {
  border-block-start: 4px solid var(--button);
}

@media (width >= 30rem) {
  .card {
    padding: var(--space-6);
  }
}

/* A flow step: shown or hidden with the hidden attribute; its title takes focus when it appears. */
.step {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

/* Inside a card or a step, a heading (or a step) that follows other content starts a new part: twice the
   usual gap above it ("What Plus includes" under the plans, "Without signing in" under the sign-in). */
:is(.card, .step) > :is(h2, h3, .step):not(:first-child) {
  margin-block-start: var(--space-4);
}

.step-title:focus {
  outline: none;
}

.step-title:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Form fields: a visible label, an optional hint, the control, and its error once there is one. */
.form {
  display: grid;
  gap: var(--space-5);
}

.field {
  display: grid;
  gap: var(--space-2);
  max-inline-size: 28rem;
}

.field-label {
  color: var(--ink);
  font-weight: 700;
}

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

.input {
  inline-size: 100%;
  min-block-size: 3rem;
  padding: var(--space-2) var(--space-4);
  border: 2px solid var(--field-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 1.0625rem;
}

.input:hover {
  border-color: var(--text);
}

.input:focus-visible {
  border-color: var(--focus);
  outline-offset: 2px;
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

/* The 6-digit code: large, spaced digits that a phone fills from the email. */
.input--code {
  inline-size: 11ch;
  max-inline-size: 100%;
  padding-inline: var(--space-3);
  font-size: 1.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.3em;
}

/* One inline run of text, so a sentence with a link wraps as a sentence. */
.field-error {
  position: relative;
  padding-inline-start: 1.6em;
  color: var(--danger);
  font-weight: 700;
}

/* A small cross before the error, so it is never told by colour alone; centred on the first line. */
.field-error::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: 0.25em;
  inline-size: 1.1em;
  block-size: 1.1em;
  border-radius: 50%;
  background:
    linear-gradient(45deg, transparent 44%, var(--surface) 44% 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, var(--surface) 44% 56%, transparent 56%), var(--danger);
  background-size:
    70% 70%,
    70% 70%,
    auto;
  background-position: center;
  background-repeat: no-repeat;
}

/* A checkbox and its label, as one 44 px target. */
.check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-block-size: var(--tap);
  padding-block: var(--space-2);
  cursor: pointer;
  max-inline-size: var(--measure);
}

.check input {
  flex: none;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  margin-block-start: 0.05rem;
  accent-color: var(--button);
  cursor: pointer;
}

/* Notices: a tinted panel with a coloured edge; the words say what kind it is. */
.notice {
  --tone: var(--info);
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border-inline-start: 4px solid var(--tone);
  border-radius: var(--radius-sm);
  background: var(--info-bg);
  color: var(--text);
}

.notice--success {
  --tone: var(--success);
  background: var(--success-bg);
}

.notice--warning {
  --tone: var(--warning);
  background: var(--warning-bg);
}

.notice--error {
  --tone: var(--danger);
  background: var(--danger-bg);
}

/* Test mode: Paddle's sandbox. Never shown on kanafox.com's live checkout. */
.test-banner {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--gold);
  color: var(--on-gold);
  font-weight: 700;
}

/* "Signed in as ..." with its way out, which wraps under it on a phone. */
.account-line strong {
  overflow-wrap: anywhere;
}

/* An email address or other backend value can be longer than a phone is wide: "anywhere", not "break-word",
   so it also lowers the min-content width that sizes the auto grid columns around it. */
.field-hint strong,
.notice,
.rows dd {
  overflow-wrap: anywhere;
}

/* Between the blocks of a page, the line belongs to the step under it: half the usual gap below. */
.flow > .account-line {
  margin-block-end: calc(var(--space-5) - var(--space-7));
}

/* Web subscriptions on /cancel: plan, date lines, id, and the button. */
.subs {
  display: grid;
  gap: var(--space-3);
  padding: 0;
  list-style: none;
}

.sub {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.sub-name {
  color: var(--ink);
  font-size: var(--text-lg);
  font-weight: 800;
}

.sub-id {
  color: var(--muted);
  font-size: var(--text-md);
  overflow-wrap: anywhere;
}

.sub .button {
  justify-self: start;
  margin-block-start: var(--space-2);
}

/* "Where did you subscribe?": links to the sections of a page. */
.jump ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-block-start: var(--space-2);
  padding: 0;
  list-style: none;
}

.jump a {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--tap);
  padding-inline: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-weight: 700;
  text-decoration: none;
}

.jump a:hover {
  border-color: var(--link);
}

/* Running text that sits outside .prose: the /legal jump note, a plain page's paragraphs in a .stack and the
   text of a notice (the box keeps its width). */
.notice > p,
.jump > p,
.flow > .stack > p {
  max-inline-size: var(--measure);
}

/* A plain bulleted list, for facts that are neither steps nor ticks. */
.bullets {
  display: grid;
  gap: var(--space-2);
  padding-inline-start: var(--space-5);
}

.bullets li::marker {
  color: var(--muted);
}

/* Numbered instructions (steps in the App Store or Google Play). */
.numbered {
  display: grid;
  gap: var(--space-2);
  padding-inline-start: var(--space-5);
}

.numbered li::marker {
  color: var(--link);
  font-weight: 800;
}

/* Links that go to another site or another part of this one, each on its own 44 px line. */
.link-list {
  padding: 0;
  list-style: none;
}

.link-list a {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--tap);
}

/* ---------------------------------------------------------------------------------------------------- */
/* Utilities                                                                                            */
/* ---------------------------------------------------------------------------------------------------- */

/* Read by screen readers, not shown: the live region and extra words such as "(opens in a new tab)". */
.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
