/* 五十音 — indigo (藍) on cool white. Red is not a brand colour here: it is
   kept for meaning — the strokes a kana took from its kanji, the model
   strokes on the pad, and mistakes. */

@font-face {
  /* Klee One SemiBold, subset to the 92 basic kana and the long-vowel mark:
     textbook-style letterforms that match how kana are written by hand. */
  font-family: 'Klee Kana';
  src: url('../fonts/KleeOne-SemiBold-kana.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
  unicode-range: U+3040-30FF;
}

:root {
  color-scheme: light dark;

  --paper: #f4f6f9;
  --surface: #ffffff;
  --ink: #1a2332;
  --muted: #647189;
  --line: #dde2ea;
  --accent: #2f4d95;
  --on-accent: #ffffff;
  --accent-soft: #e3eaf8;
  --red: #d13b2e;
  --red-soft: #fbe6e2;
  --ok: #1d7a55;
  --ok-soft: #d9f0e4;
  /* Chart stages: learning (amber) → familiar (blue) → mastered (green). */
  --warn-soft: #fbedc9;
  --mid-soft: #dbe7fb;
  --shadow: 0 1px 2px rgb(20 35 70 / 0.08), 0 6px 20px rgb(20 35 70 / 0.05);

  --radius: 18px;
  --radius-sm: 12px;
  --gutter: 16px;
  --actionbar-height: 68px;
  /* Side of a source-glyph tile in the learn view. */
  --tile: clamp(58px, 18.5vw, 76px);
  --arrow: 18px;

  --font-ui:
    system-ui, -apple-system, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC',
    'Noto Sans SC', sans-serif;
  --font-kana: 'Klee Kana', 'Hiragino Sans', 'Yu Gothic', 'Noto Sans CJK JP', 'Noto Sans JP', var(--font-ui);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e131b;
    --surface: #161d28;
    --ink: #e6ebf3;
    --muted: #93a0b5;
    --line: #273142;
    --accent: #8eb0f6;
    --on-accent: #0b1426;
    --accent-soft: #1c2a47;
    --red: #ff7c68;
    --red-soft: #40211d;
    --ok: #6fd1a1;
    --ok-soft: #153527;
    --warn-soft: #3b2f13;
    --mid-soft: #1b2c4a;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  }
}

/* ── Base ─────────────────────────────────────────────────────────── */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Horizontal swipes turn pages here; they must not trigger the browser's
     own swipe-to-go-back gesture. */
  overscroll-behavior-x: none;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--font-ui);
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}

h2,
h3,
p,
ul,
ol,
figure {
  margin: 0;
}

h2 {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.4;
}

h3 {
  font-size: 14px;
  font-weight: 650;
}

a {
  color: var(--accent);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

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

[hidden] {
  display: none !important;
}

.kana {
  font-family: var(--font-kana);
  font-weight: 600;
}

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.note {
  color: var(--muted);
  font-size: 14px;
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
}

.center {
  text-align: center;
}

.noscript {
  padding: 24px;
  text-align: center;
}

/* ── Shell ────────────────────────────────────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + var(--gutter)) 8px
    calc(env(safe-area-inset-left) + var(--gutter));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: flex;
  flex: 1;
  gap: 2px;
  max-width: 440px;
  margin: 0 auto;
  padding: 3px;
  background: var(--line);
  border-radius: 999px;
}

.tabs a {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.tabs a[aria-current='page'] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.badge {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}

.icon-btn:hover {
  background: var(--line);
  color: var(--ink);
}

main {
  flex: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--gutter) calc(env(safe-area-inset-right) + var(--gutter))
    calc(env(safe-area-inset-bottom) + 28px) calc(env(safe-area-inset-left) + var(--gutter));
  outline: none;
}

/* The learn view ends above its fixed action bar. */
main[data-view='learn'] {
  padding-bottom: calc(env(safe-area-inset-bottom) + var(--actionbar-height) + 20px);
}

/* Content sits directly on the paper; sections are told apart by a hairline
   and a small label rather than by boxes. */
.sect {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.sect-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

/* ── Buttons & controls ───────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
  transition:
    transform 0.08s ease,
    background-color 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.btn-danger {
  border-color: var(--red);
  color: var(--red);
}

.btn-block {
  width: 100%;
}

.btn-round {
  flex: none;
  width: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
}

.btn-xl {
  width: 96px;
  min-height: 96px;
  font-size: 34px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn-row > .btn {
  flex: 1;
}

.btn-col {
  display: grid;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.chip[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.chip:disabled {
  opacity: 0.4;
}

.segmented {
  display: inline-flex;
  justify-self: start;
  gap: 2px;
  padding: 3px;
  background: var(--line);
  border-radius: 12px;
}

.segment {
  min-width: 52px;
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.segment .kana {
  font-size: 20px;
}

.segment[aria-pressed='true'] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  cursor: pointer;
}

.toggle-text {
  display: grid;
  font-weight: 600;
}

.toggle-text small {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  margin: 0;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transition: transform 0.15s ease;
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(20px);
}

.progress {
  flex: 1;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-thin {
  flex: none;
  height: 3px;
}

.progress > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}

.pips {
  display: inline-flex;
  gap: 3px;
}

.pips > i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line);
}

.pips > i.on {
  background: var(--ok);
}

/* ── Learn ────────────────────────────────────────────────────────── */

.learn {
  display: grid;
  gap: 14px;
}

.learn-grid,
.learn-main,
.entry,
.learn-side,
.extras {
  display: grid;
  align-content: start;
  min-width: 0;
}

.entry-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.romaji {
  color: var(--accent);
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
}

.entry-say {
  color: var(--muted);
  font-size: 13px;
}

.entry-pos {
  margin-left: auto;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.tip {
  margin: 10px 0 12px;
  padding-left: 10px;
  border-left: 2px solid var(--accent);
  font-size: 14.5px;
  line-height: 1.55;
}

/* One script per row: [label] [source tiles ›] [the kana, large]. */
.derive {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 4px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.derive-label {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.derive-label h2 {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.derive-kana {
  min-width: 1.05em;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  font-size: clamp(84px, 26vw, 112px);
  line-height: 1.12;
  text-align: center;
}

.derive-note {
  grid-column: 1 / -1;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.flow {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  /* Room for two tiles and their arrows even when a row has one tile, so
     the kana of both rows line up. */
  min-width: calc(2 * (var(--tile) + var(--arrow)));
  padding: 0;
  list-style: none;
}

.flow-step {
  width: var(--tile);
}

.flow figure {
  display: grid;
  gap: 3px;
  text-align: center;
}

.flow figcaption {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
}

.flow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--arrow);
  /* As tall as a tile, so the arrow centres on the glyph, not the caption. */
  height: var(--tile);
  color: var(--muted);
  font-size: 13px;
}

.glyph {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 7%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.glyph-ink,
.glyph-rest {
  fill: var(--ink);
}

.glyph-used {
  fill: var(--red);
}

.glyph-rest {
  transition: opacity 0.3s ease;
}

.glyph-toggle {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
}

.glyph-toggle[aria-pressed='true'] .glyph-rest {
  opacity: 0.1;
}

.words {
  display: grid;
}

.word {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  background: none;
  text-align: left;
}

.word + .word {
  border-top: 1px dashed var(--line);
}

.word-kana {
  font-size: 22px;
  line-height: 1.3;
}

.word-kana mark {
  background: none;
  color: var(--accent);
}

.word-meaning {
  color: var(--muted);
  font-size: 14px;
}

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

.lookalike {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}

.lookalike > .note {
  flex: 1 1 150px;
  font-size: 13px;
}

.lookalike-kana {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kana-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 23px;
  line-height: 1;
}

.kana-chip.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.write {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding-bottom: 14px;
}

.write-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.write-head .sect-title {
  margin-right: auto;
}

.actionbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px calc(env(safe-area-inset-right) + var(--gutter)) calc(env(safe-area-inset-bottom) + 10px)
    calc(env(safe-area-inset-left) + var(--gutter));
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.actionbar > .btn-primary {
  flex: 1;
  max-width: 300px;
}

@media (max-width: 879px) {
  /* On phones the pad lives in the bottom sheet, not in the page. */
  .learn-side {
    display: none;
  }
}

@media (min-width: 880px) {
  :root {
    --tile: 88px;
    --arrow: 24px;
  }

  .learn-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 360px);
    column-gap: 64px;
  }

  /* With room to spare, pack each row to the left under its label column. */
  .derive {
    grid-template-columns: 112px auto auto;
    justify-content: start;
    column-gap: 8px;
  }

  .derive-kana {
    font-size: 128px;
  }

  .actionbar-write {
    display: none;
  }
}

/* ── Writing pad ──────────────────────────────────────────────────── */

.pad {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}

.pad-surface {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

/* 田字格: dashed centre lines, like a kana practice sheet. */
.pad-surface::before,
.pad-surface::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

.pad-surface::before {
  top: 50%;
  right: 0;
  left: 0;
  border-top: 1px dashed var(--line);
}

.pad-surface::after {
  top: 0;
  bottom: 0;
  left: 50%;
  border-left: 1px dashed var(--line);
}

.pad-guide,
.pad-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pad-canvas {
  z-index: 1;
  color: var(--ink);
  cursor: crosshair;
  /* Finger strokes draw; they must not scroll or zoom the page. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.stroke-path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.13;
}

.stroke-number {
  fill: var(--red);
  font: 600 7px var(--font-ui);
  opacity: 0;
}

.pad-guide[data-mode='hidden'] .stroke-path {
  opacity: 0;
}

.pad-guide[data-mode='answer'] .stroke-path {
  stroke: var(--red);
  opacity: 0.6;
}

.pad-guide[data-mode='answer'] .stroke-number {
  opacity: 1;
}

/* Stroke-order demo; timing mirrors STROKE_STEP_MS in js/ui/pad.js. */
.pad-guide.is-playing .stroke-path {
  stroke: var(--red);
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 1;
  animation: stroke-draw 0.55s ease-in-out forwards;
  animation-delay: calc(var(--i) * 0.7s);
}

.pad-guide.is-playing .stroke-number {
  animation: stroke-number 0.15s ease forwards;
  animation-delay: calc(var(--i) * 0.7s);
}

@keyframes stroke-draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes stroke-number {
  to {
    opacity: 1;
  }
}

.pad-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pad-tools-gap {
  flex: 1;
}

/* ── Chart ────────────────────────────────────────────────────────── */

.chart-view {
  display: grid;
  gap: var(--gutter);
  max-width: 560px;
  margin: 0 auto;
}

.chart-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 12.5px;
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.chart {
  display: grid;
  gap: 6px;
}

.chart-row {
  display: grid;
  grid-template-columns: 40px repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.chart-head {
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.chart-row-name,
.chart-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  line-height: 1.15;
}

.chart-row-name {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
}

.chart-row-name small,
.chart-cell small {
  color: var(--muted);
  font-size: 11.5px;
}

.chart-cell {
  aspect-ratio: 1 / 0.9;
  background: var(--surface);
}

.chart-cell .kana {
  font-size: clamp(24px, 7.6vw, 36px);
}

[data-stage='new'] {
  background: var(--surface);
}

[data-stage='learning'] {
  background: var(--warn-soft);
}

[data-stage='familiar'] {
  background: var(--mid-soft);
}

[data-stage='mastered'] {
  background: var(--ok-soft);
}

/* ── Review ───────────────────────────────────────────────────────── */

.review {
  display: grid;
  gap: var(--gutter);
  max-width: 520px;
  margin: 0 auto;
}

.review-top {
  display: grid;
  gap: 14px;
  padding: 6px 0 10px;
}

.stats {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  text-align: center;
}

.stat {
  display: grid;
}

.stat b {
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat span {
  color: var(--muted);
  font-size: 12.5px;
}

.quiz-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiz-count {
  min-width: 52px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.quiz-prompt {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 14px 0 20px;
  text-align: center;
}

.quiz-prompt.is-compact {
  padding: 0;
}

.quiz-ask {
  color: var(--muted);
  font-size: 14.5px;
}

.quiz-kana {
  font-size: clamp(104px, 34vw, 148px);
  line-height: 1.15;
}

.quiz-romaji {
  color: var(--accent);
  font-size: 64px;
  font-weight: 700;
  line-height: 1.2;
}

.is-compact .quiz-romaji {
  font-size: 44px;
}

.quiz-write-target {
  display: flex;
  align-items: center;
  gap: 16px;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice {
  min-height: 72px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 24px;
  font-weight: 600;
}

.choice.kana {
  font-size: 42px;
}

.choice:disabled {
  opacity: 0.55;
}

.choice.is-correct,
.choice.is-wrong {
  opacity: 1;
}

.choice.is-correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.choice.is-wrong {
  border-color: var(--red);
  background: var(--red-soft);
}

.quiz-after {
  display: grid;
  gap: 10px;
  min-height: 48px;
}

.feedback {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
}

.feedback.is-correct {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 650;
}

.feedback.is-wrong {
  background: var(--red-soft);
}

.feedback b.kana {
  font-size: 22px;
}

.summary {
  display: grid;
  gap: 14px;
}

.summary h2 {
  font-size: 18px;
  text-align: center;
}

/* ── Dialog & toast ───────────────────────────────────────────────── */

.dialog {
  width: min(440px, calc(100vw - 28px));
  max-height: min(86vh, 720px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
}

.dialog::backdrop {
  background: rgb(10 16 28 / 0.5);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 8px 0 18px;
}

.dialog-head h2 {
  font-size: 17px;
  outline: none;
}

.dialog-body {
  display: grid;
  gap: 12px;
  padding: 8px 18px 18px;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 18px 18px;
}

.dialog-actions > .btn {
  flex: 1;
}

/* ── Writing sheet (phones) ───────────────────────────────────────── */

/* The close button only matters while the pad is shown as a sheet. */
.sheet-close {
  display: none;
}

.sheet .sheet-close {
  display: inline-flex;
}

.dialog.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 100dvh;
  margin: auto auto 0;
  padding: 8px var(--gutter) calc(env(safe-area-inset-bottom) + var(--gutter));
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
}

.dialog.sheet[open] {
  animation: sheet-up 0.2s ease-out;
}

.sheet .write {
  padding-bottom: 0;
}

.sheet .sect-title {
  outline: none;
}

@keyframes sheet-up {
  from {
    transform: translateY(32px);
    opacity: 0;
  }
}

.credits {
  display: grid;
  gap: 4px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: calc(env(safe-area-inset-bottom) + var(--actionbar-height) + 16px);
  left: 14px;
  z-index: 40;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  text-align: center;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.25);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }

  .dialog.sheet[open] {
    animation: none;
  }

  /* Show the finished strokes instead of drawing them. */
  .pad-guide.is-playing .stroke-path,
  .pad-guide.is-playing .stroke-number {
    animation: none;
    stroke-dashoffset: 0;
    opacity: 1;
  }
}
