/* Home composition: the 1440 artboard from 1180px, the 390 column below. */

.header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 24px;
  min-height: 87px;
}

.site-nav {
  display: contents;
}

.nav-sections {
  display: flex;
  grid-row: 1;
  grid-column: 2;
  gap: 36px;
}

/* The sections stay centred: switch and CTA share the right column. */
.language-switch {
  grid-row: 1;
  grid-column: 3;
  justify-self: end;
  margin-right: 144px;
}

.header-cta {
  grid-row: 1;
  grid-column: 3;
  justify-self: end;
  min-width: 120px;
}

@media (min-width: 900px) {
  .menu-toggle {
    display: none;
  }
}

.footer-top {
  display: flex;
  justify-content: space-between;
  gap: 48px;
  padding-block: 72px 56px;
}

.footer-brand .brand {
  min-height: 44px;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 360px;
}

.footer-columns {
  display: flex;
  gap: 96px;
}

.footer-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

.colophon {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding-block: 8px 36px;
}

/* Hero */
.hero {
  overflow: hidden;
  overflow: clip;
}

.hero-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  min-height: 820px;
  padding-top: 96px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  width: min(620px, 100%);
  padding-top: 24px;
}

.hero h1 {
  margin-top: 28px;
}

.hero-lede {
  max-width: 520px;
  margin-top: 28px;
}

/* The badges share one row; the QR card below takes exactly its width. */
.get-app {
  display: grid;
  justify-content: start;
  gap: 16px;
  margin-top: 44px;
}

.get-app .store-links {
  flex-wrap: nowrap;
  gap: 12px;
}

.free-note {
  margin-top: 28px;
}

.qr-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px 12px 12px;
  contain: inline-size;
}

.qr-code {
  position: relative;
  flex: 0 0 92px;
  width: 92px;
  height: 92px;
}

.qr-code svg {
  display: block;
  width: 100%;
  height: 100%;
}

.qr-code img {
  position: absolute;
  top: 33px;
  left: 33px;
  width: 26px;
  height: 26px;
}

.qr-card p {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.hero-art {
  position: relative;
  flex: 0 0 560px;
  height: 724px;
}

/* The app's tracing screen (v2c P07) in its own 390 × 844 units, scaled to
   the approved phone; Hoki stands at its foot. */
.phone-write {
  --write-scale: 0.8256;

  position: absolute;
  top: 10px;
  left: 214px;
  width: 322px;
  height: 699px;
  overflow: hidden;
}

.write-screen {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: 390px;
  height: 844px;
  transform: scale(var(--write-scale));
  transform-origin: 0 0;
}

.write-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: center;
  column-gap: 154px;
  padding: 21px 24px 19px;
}

.write-status-icons {
  display: block;
}

.write-session {
  display: flex;
  align-items: center;
  height: 48px;
  margin-top: 0;
  padding: 0 24px 0 8px;
}

.write-close {
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  height: 48px;
}

.write-close svg {
  display: block;
}

.write-count {
  flex: 1;
}

.write-spacer {
  flex: 0 0 32px;
}

.write-progress {
  height: 4px;
  margin: 4px 24px 0;
}

.write-progress span {
  display: block;
  width: 33%;
  height: 100%;
}

.write-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 12px 24px;
}

.write-help {
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  height: 48px;
}

.write-help span {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 32px;
  height: 32px;
}

.write-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0 24px;
  padding: 20px;
}

.write-cue {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.write-cue p {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.write-marks {
  display: flex;
  gap: 4px;
}

.write-marks span {
  flex: 0 0 16px;
  height: 4px;
}

.write-canvas {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  height: 302px;
  overflow: hidden;
}

.write-canvas .stroke-character {
  display: block;
  width: 300px;
  height: 300px;
}

.write-skip {
  display: grid;
  place-items: center;
  height: 52px;
  margin: 20px 24px 0;
}

.hero-hoki {
  position: absolute;
  top: 578px;
  left: 70px;
  width: 140px;
  height: 140px;
  pointer-events: none;
}

.hoki-shadow {
  position: absolute;
  top: 104px;
  left: 40px;
  width: 70px;
  height: 10px;
}

.hoki-figure,
.hoki-live {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.sheet {
  display: flex;
  flex-direction: column;
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  min-height: 45px;
  padding: 0 18px;
}

.sheet-art {
  display: flex;
  justify-content: center;
  padding: 18px 0 10px;
}

.sheet-art .stroke-character {
  width: 210px;
  height: 210px;
}

.sheet-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 18px 18px;
}

/* Chapter index */
.chapters-inner {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.chapter {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 28px 28px 30px;
}

.chapter:first-child {
  padding-left: 0;
}

.chapter:last-child {
  padding-right: 0;
}

.chapter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 01 · Pieces */
.pieces-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 48px;
  padding-block: 144px 128px;
}

.pieces-copy {
  display: flex;
  flex-direction: column;
  width: 440px;
}

.pieces-copy h2,
.memory-copy h2 {
  margin-top: 20px;
}

.pieces-copy .section-lede,
.memory-copy .section-lede,
.words-copy .section-lede {
  margin-top: 24px;
}

.stats {
  display: flex;
  gap: 32px;
  margin: 36px 0 0;
}

.stats > div {
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
}

.stats dd {
  margin: 0;
}

.access-note {
  margin-top: 20px;
}

.tree {
  position: relative;
  flex: 0 0 652px;
  height: 600px;
}

.tree-canvas {
  position: relative;
  width: 652px;
  height: 600px;
}

.tree-lines,
.tree-active {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.tree-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 132px;
  height: 152px;
  padding: 10px 0 0;
}

.tree-node .stroke-character {
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}

.tree-node > span {
  padding-top: 8px;
}

[data-node="土"] {
  top: 166px;
  left: 0;
}

[data-node="王"] {
  top: 24px;
  left: 260px;
}

[data-node="寺"] {
  top: 309px;
  left: 260px;
}

[data-node="玉"] {
  top: 24px;
  left: 520px;
}

[data-node="時"] {
  top: 214px;
  left: 520px;
}

[data-node="持"] {
  top: 404px;
  left: 520px;
}

/* Without site.js the card sits under 王, the kanji it explains, where
   site.js anchors it for the keyboard. */
.tree-cards {
  position: absolute;
  top: 188px;
  left: 260px;
  z-index: 2;
}

.tree-float .tree-cards {
  top: 0;
  left: 0;
}

.tree-card {
  flex-direction: column;
  gap: 8px;
  padding: 12px 18px;
}

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

.formula-part {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.formula-part .stroke-character {
  width: 46px;
  height: 46px;
}

.formula-sign {
  padding-bottom: 16px;
}

.tree figcaption {
  position: absolute;
  top: 572px;
  left: 0;
}

/* 02 · Library */
.library {
  display: flex;
  flex-direction: column;
  gap: 56px;
  padding-block: 128px 120px;
}

/* Two faces of one library, kanji and words, each centred in its half;
   the sentence they start closes under both. */
.library-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.library-figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
}

.library-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
}

.library-intro h2 {
  max-width: 900px;
  padding-top: 16px;
}

.library-search {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
}

/* Kanji · Words: a segmented control whose thumb slides between the two. */
.search-tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-self: center;
  width: min(256px, 100%);
  padding: 4px;
}

.search-tabs[hidden] {
  display: none;
}

.search-tabs button {
  position: relative;
  z-index: 1;
  min-height: 44px;
  padding: 0 12px;
}

.search-tabs-thumb {
  position: absolute;
  inset: 4px auto 4px 4px;
  width: calc(50% - 4px);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(600px, 100%);
  height: 64px;
  padding: 0 10px 0 22px;
}

.search-field svg {
  flex-shrink: 0;
}

/* The input fills the box so any tap on it focuses the field. */
.search-field input {
  flex: 1;
  align-self: stretch;
  min-width: 0;
  min-height: 44px;
  padding: 0;
}

.library-wall {
  position: relative;
  min-height: 600px;
  padding: 88px 0 48px;
  overflow: hidden;
  overflow: clip;
}

.wall {
  position: absolute;
  inset: 0;
}

.wall-row {
  position: absolute;
}

/* Each row drifts as one track; site.js appends an inert copy of its tiles. */
.wall-track {
  display: flex;
  gap: 12px;
  width: max-content;
}

.wall-copy {
  display: contents;
}

.wall-pause {
  position: absolute;
  right: max(24px, calc(50% - 600px));
  bottom: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
}

.wall-pause[hidden],
.wall-preview[hidden] {
  display: none;
}

.wall-preview {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: 280px;
  padding: 12px 18px 12px 14px;
}

.wall-preview > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* Kanji, words, kanji, words: each row a little off from the one above. */
.wall-row:nth-child(1) {
  top: 40px;
  left: calc(50% - 744px);
}

.wall-row:nth-child(2) {
  top: 172px;
  left: calc(50% - 780px);
}

.wall-row:nth-child(3) {
  top: 304px;
  left: calc(50% - 806px);
}

.wall-row:nth-child(4) {
  top: 436px;
  left: calc(50% - 840px);
}

.wall-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  width: 112px;
  height: 116px;
}

.wall-word {
  gap: 2px;
  width: 168px;
}

/* Both sheets share one cell; the stack eases to the open one's height. */
.sheet-stack {
  position: relative;
  display: grid;
  width: min(500px, 100%);
  margin-inline: auto;
}

.kanji-sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  grid-area: 1 / 1;
  align-self: start;
  width: 100%;
}

.kanji-sheet[hidden] {
  display: none;
}

.word-sheet .kanji-sheet-head {
  flex-wrap: wrap;
  row-gap: 12px;
}

.word-sheet-kanji ul {
  gap: 8px;
}

.word-kanji {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 56px;
  padding: 0;
}

.word-kanji-glyph {
  display: grid;
  flex: 0 0 56px;
  place-items: center;
  height: 56px;
}

.word-kanji-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kanji-sheet-head {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 28px 32px 24px;
}

.kanji-sheet-head > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.kanji-sheet-readings {
  display: flex;
  gap: 32px;
  padding: 18px 32px;
}

.kanji-sheet-readings > div {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 6px;
}

.kanji-sheet-examples {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 32px 26px;
}

.kanji-sheet-examples ul {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kanji-sheet-examples li {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.kanji-sheet-empty {
  padding: 0 32px 26px;
}

.kanji-sheet[data-state="empty"] .kanji-sheet-readings,
.kanji-sheet[data-state="empty"] .kanji-sheet-examples,
.kanji-sheet[data-state="empty"] .kanji-sheet-head {
  display: none;
}

.kanji-sheet[data-state="empty"] .kanji-sheet-empty {
  padding-top: 32px;
}

.levels {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.levels-bar {
  display: block;
  width: 100%;
  height: 14px;
}

.levels-legend {
  display: grid;
  grid-template-columns: 418px minmax(0, 1fr);
  gap: 3px;
}

.levels-legend p {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 48px;
  padding-top: 8px;
}

.feature {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 28px;
}

/* 03 · Words */
.words {
  overflow: hidden;
  overflow: clip;
}

.words-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 48px;
  padding-top: 128px;
}

.words-copy {
  display: flex;
  flex-direction: column;
  width: 700px;
  padding-bottom: 112px;
}

.words-copy h2,
.words-copy .section-lede {
  max-width: 560px;
}

.words-copy h2 {
  margin-top: 20px;
}

.progression {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  margin: 0;
  padding: 64px 0 0;
  list-style: none;
}

.progression li {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.progression li + li {
  position: relative;
  padding-left: 46px;
}

.progression li + li::before {
  position: absolute;
  bottom: 54px;
  left: 0;
}

.step-word {
  align-items: flex-start;
}

.step-word ruby {
  display: inline-flex;
  flex-direction: column-reverse;
  align-items: center;
  width: 120px;
}

.step-sentence .step-glyph {
  display: flex;
  align-items: flex-end;
  height: 96px;
  padding-bottom: 10px;
}

.themes {
  display: flex;
  flex-direction: column;
  width: min(600px, 100%);
  padding-top: 72px;
}

.themes .overline {
  padding-bottom: 14px;
}

/* The themes as tags; the free ones say so. Then the way in. */
.themes ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.theme {
  padding: 6px 11px;
}

.themes-start {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding-top: 32px;
}

.band-action {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
}

.cadence {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: min(600px, 100%);
  margin-top: 56px;
  padding: 28px 28px 26px;
}

.cadence-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.cadence-done,
.cadence-next {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
}

.cadence-gap {
  flex: 0 0 14px;
}

.words-forest {
  --forest-scale: 1;
  --forest-scroll: 600px;
  --forest-stage: calc(844px * var(--forest-scale) + 20px);

  flex: 0 0 auto;
  align-self: flex-end;
}

.forest-stage {
  display: flow-root;
}

/* With motion, the phone stays fixed while the column scrolls past it: the
   forest grows over --forest-scroll of page scroll, the whole phone in view.
   Without it the settled phone sits at the column's foot. */
.stroke-motion .words-forest {
  align-self: stretch;
  min-height: calc(var(--forest-stage) + var(--forest-scroll));
}

.stroke-motion .forest-stage {
  position: sticky;
  top: calc(50vh - var(--forest-stage) / 2);
}

.phone-forest {
  position: relative;
  width: calc(390px * var(--forest-scale));
  height: calc(844px * var(--forest-scale));
  margin: 10px;
  overflow: hidden;
}

/* The app screen in its own 390 × 844 units, scaled as a whole. */
.forest-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 390px;
  height: 844px;
  transform: scale(var(--forest-scale));
  transform-origin: 0 0;
}

/* Positions from forest.json (scripts/export_forest.py), settled state; the
   gate checks them against the export. */
.forest-content {
  position: absolute;
  inset: 0;
  transform: translateY(46.9px);
}

.forest-art {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
}

.forest-chrome {
  position: absolute;
  left: 0;
  display: block;
  width: 390px;
}

.forest-chrome-top {
  top: 0;
}

.forest-chrome-bottom {
  bottom: 0;
}

.forest-subtitle {
  position: absolute;
  top: 84px;
  left: 24px;
}

.forest-subtitle > span {
  position: absolute;
  top: 0;
  left: 0;
}

.forest-plaque {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px;
}

.forest-plaque-left {
  top: 651px;
  left: 24px;
}

.forest-plaque-right {
  top: 251px;
  right: 24px;
}

.forest-callout {
  position: absolute;
  bottom: 273px;
  left: 151px;
  padding: 8px 12px 8px 20px;
}

.forest-callout::before {
  position: absolute;
  top: calc(50% - 6px);
  left: -1px;
  width: 9px;
  height: 12px;
  clip-path: polygon(0 50%, 100% 0, 100% 100%);
  transform: translateX(-8px);
}

.forest-course {
  position: absolute;
  left: 0;
  width: 390px;
}

.forest-course-1 {
  top: 579px;
}

.forest-course-2 {
  top: 449px;
}

.forest-course-3 {
  top: 319px;
}

.forest-course-4 {
  top: 179px;
}

.forest-tile {
  position: absolute;
  top: 0;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 60px;
  height: 60px;
}

.forest-course-1 .forest-tile,
.forest-course-3 .forest-tile {
  left: 175px;
}

.forest-course-2 .forest-tile {
  left: 158px;
}

.forest-course-4 .forest-tile {
  left: 155px;
}

.forest-details {
  position: absolute;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.forest-text-end .forest-details {
  right: 24px;
}

.forest-course-1 .forest-details,
.forest-course-3 .forest-details {
  left: 251px;
}

.forest-course-2 .forest-details {
  left: 234px;
}

.forest-text-start .forest-details {
  left: 24px;
  align-items: flex-end;
}

.forest-course-4 .forest-details {
  right: 251px;
}

.forest-title {
  padding-bottom: 4px;
}

.forest-blocks,
.forest-bar,
.forest-action {
  display: none;
}

.forest-bar {
  width: 100%;
  height: 4px;
  margin-top: 8px;
}

.forest-bar span {
  display: block;
  height: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0.4);
}

.forest-action {
  align-items: center;
  gap: 4px;
  min-height: 48px;
}

[data-state="progress"] .forest-counts {
  display: none;
}

[data-state="progress"] .forest-blocks,
[data-state="progress"] .forest-bar {
  display: block;
}

[data-state="available"] .forest-start,
[data-state="progress"] .forest-continue {
  display: flex;
}

.forest-screen .forest-hoki {
  position: absolute;
  top: 146.1px;
  left: 314.6px;
  width: 70px;
  height: 70px;
  transform: scaleX(-1);
}

/* 04 · Memory */
.memory-inner {
  display: grid;
  grid-template-columns: 500px 560px;
  grid-template-rows: auto 1fr;
  justify-content: space-between;
  align-items: center;
  column-gap: 40px;
  padding-block: 144px 136px;
}

.memory-copy {
  display: flex;
  flex-direction: column;
  align-self: end;
}

.activities {
  grid-column: 1;
  grid-row: 2;
  align-self: start;
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
}

.activities li {
  display: flex;
  gap: 20px;
  padding-block: 20px;
}

.activity-glyph {
  flex: 0 0 44px;
}

.activities li > span:last-child {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.memory-cards {
  position: relative;
  grid-column: 2;
  grid-row: 1 / 3;
  width: 560px;
  height: 640px;
}

.card-back {
  position: absolute;
  top: 0;
  left: 170px;
  width: 340px;
  height: 380px;
}

.memory-card {
  position: absolute;
  top: 56px;
  left: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 400px;
}

.memory-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 220px;
}

.memory-answer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 352px;
  padding: 22px 0 26px;
}

.memory-answer .overline + .memory-meaning,
.memory-reading + .overline {
  margin-top: 0;
}

.memory-reading + .overline {
  padding-top: 12px;
}

.memory-reading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.memory-other {
  padding-top: 8px;
}

.session {
  position: absolute;
  top: 12px;
  left: 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 110px;
}

.session-bar {
  display: flex;
  width: 110px;
  height: 4px;
}

.session-bar > span {
  width: 37px;
  height: 4px;
}

.memory-answers {
  position: absolute;
  top: 492px;
  left: 40px;
  display: flex;
  gap: 14px;
  width: 400px;
}

.answer {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 56px;
}

.mastery {
  position: absolute;
  top: 580px;
  left: 40px;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 400px;
}

.mastery-meter {
  display: flex;
  flex: 1;
  gap: 4px;
}

.mastery-meter > span {
  flex: 1;
  height: 8px;
}

/* Free and Pro */
.plans-inner {
  display: flex;
  flex-direction: column;
  gap: 48px;
  padding-block: 144px 64px;
}

.plans-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 40px;
}

.plans-heading > div {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 780px;
}

.plans-heading > p {
  flex: 0 0 360px;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.plan {
  display: flex;
  flex-direction: column;
  padding: 36px 40px 40px;
}

.plan-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-top: 16px;
}

.plan-text {
  padding-top: 8px;
}

.plan-equivalent {
  padding-top: 8px;
}

.plan-options {
  margin: 24px 0 0;
}

.plan-options > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 12px;
  padding-block: 12px;
}

.plan-options dd {
  margin: 0;
}

.plan-lock {
  padding-top: 16px;
}

.plan ul {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 28px 0 0;
  padding: 28px 0 0;
}

.plan li {
  display: flex;
  gap: 12px;
}

.plan li svg {
  flex: 0 0 20px;
  margin-top: 4px;
}

/* Questions */

/* DOM follows the mobile reading order; the grid places it on desktop. */
.faq-inner {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 700px);
  grid-template-rows: auto auto auto 1fr;
  place-content: start space-between;
  column-gap: 40px;
  padding-block: 112px 120px;
}

.faq-eyebrow,
.faq-inner h2,
.faq-contact {
  grid-column: 1;
}

.faq-inner h2,
.faq-contact {
  margin-top: 20px;
}

.faq-contact {
  grid-row: 3;
}

.faq-list {
  display: flex;
  flex-direction: column;
  grid-column: 2;
  grid-row: 1 / 5;
}

.faq-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-block: 26px;
}

/* Closing. The song notes' box reaches 44 px past the art column, its ink
   29 px; where the side margin is 40 px the empty part would scroll the page. */
.closing {
  overflow: hidden;
  overflow: clip;
}

.closing-inner {
  display: grid;
  grid-template-columns: minmax(0, 580px) 500px;
  grid-template-rows: 1fr auto auto auto auto 1fr;
  justify-content: space-between;
  column-gap: 40px;
  padding-block: 112px 128px;
}

.closing-eyebrow {
  grid-row: 2;
}

.closing h2 {
  grid-row: 3;
  margin-top: 24px;
}

.closing-text {
  grid-row: 4;
  max-width: 500px;
  margin-top: 24px;
}

.closing .get-app {
  grid-row: 5;
  grid-column: 1;
  justify-self: start;
  margin-top: 40px;
}

.closing .qr-card {
  padding: 0;
}

.closing-art {
  position: relative;
  grid-column: 2;
  grid-row: 1 / 7;
  height: 560px;
}

.sheet-closing {
  position: absolute;
  top: 96px;
  left: 60px;
  width: 420px;
}

.sheet-closing .sheet-head {
  min-height: 51px;
  padding: 0 22px;
}

.sheet-closing .sheet-art {
  padding: 26px 0 14px;
}

.sheet-closing .sheet-art .stroke-character {
  width: 300px;
  height: 300px;
}

.sheet-closing .sheet-foot {
  padding: 8px 22px 22px;
}

.hoki-sing {
  position: absolute;
  top: -58px;
  left: 290px;
  width: 176px;
  height: 176px;
}

.song-notes {
  position: absolute;
  top: -92px;
  left: 448px;
  width: 96px;
  height: 120px;
}

/* Header and footer below the desktop header width */
@media (max-width: 899px) {
  .wrap {
    width: calc(100% - 48px);
  }

  .header-inner {
    grid-template-columns: minmax(0, 1fr) auto auto;
    column-gap: 4px;
    min-height: 64px;
    width: calc(100% - 40px);
    margin-right: 16px;
    margin-left: 24px;
  }

  .header-cta {
    grid-row: 1;
    grid-column: 2;
    padding-inline: 16px;
  }

  .menu-toggle {
    grid-row: 1;
    grid-column: 3;
  }

  .site-nav {
    display: flex;
    grid-row: 2;
    grid-column: 1 / -1;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0 24px;
    padding-bottom: 8px;
  }

  .nav-sections {
    flex-wrap: wrap;
    gap: 0 20px;
  }

  .menu-ready .site-nav {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    padding: 8px 24px 20px;
  }

  .menu-ready .site-nav.is-open {
    display: flex;
  }

  .menu-ready .nav-sections {
    flex-direction: column;
    gap: 0;
  }

  .language-switch {
    margin-right: 0;
  }

  .menu-ready .language-switch {
    justify-self: start;
  }

  .footer-top {
    flex-direction: column;
    gap: 32px;
    padding-block: 48px 32px;
  }

  .footer-brand {
    width: auto;
    gap: 12px;
  }

  .footer-columns {
    flex-wrap: wrap;
    gap: 32px 24px;
  }

  .footer-column {
    flex: 1 1 140px;
  }

  .footer-follow {
    flex-basis: 100%;
  }

  .colophon {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding-block: 20px 36px;
  }
}

@media (min-width: 900px) and (max-width: 1179px) {
  .wrap {
    width: calc(100% - 80px);
  }
}

/* Narrow composition: the approved 390 column, centered on tablets. */
@media (max-width: 1179px) {
  .home .wrap {
    width: min(calc(100% - 48px), 640px);
  }

  .hero-inner {
    flex-direction: column;
    gap: 32px;
    height: auto;
    padding-top: 40px;
  }

  .hero-copy {
    width: 100%;
    padding-top: 0;
  }

  .hero h1 {
    margin-top: 18px;
  }

  .hero-lede {
    margin-top: 18px;
  }

  .get-app {
    margin-top: 28px;
  }

  .get-app .store-links {
    flex-wrap: wrap;
    gap: 10px;
  }

  .qr-card {
    display: none;
  }

  .free-note {
    margin-top: 16px;
  }

  .hero-art {
    flex: none;
    align-self: center;
    width: 342px;
    max-width: none;
    height: 624px;
    overflow: hidden;
    overflow: clip;
  }

  .phone-write {
    --write-scale: 0.6564;

    top: 12px;
    left: 78px;
    width: 256px;
    height: 555px;
  }

  .sheet-head {
    min-height: 44px;
    padding: 0 14px;
  }

  .sheet-art {
    padding: 14px 0 6px;
  }

  .sheet-art .stroke-character {
    width: 158px;
    height: 158px;
  }

  .sheet-foot {
    padding: 6px 14px 14px;
  }

  .hero-hoki {
    top: 482px;
    left: 2px;
    width: 100px;
    height: 100px;
  }

  .hoki-shadow {
    top: 74px;
    left: 28px;
    width: 50px;
    height: 8px;
  }

  .chapters-inner {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home .chapters-inner {
    width: min(100%, 688px);
  }

  .chapter,
  .chapter:first-child,
  .chapter:last-child {
    gap: 6px;
    padding: 20px 16px 22px 24px;
  }

  .chapter:nth-child(even) {
    padding-right: 24px;
    padding-left: 16px;
  }

  .pieces-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-block: 72px 64px;
  }

  .pieces-copy {
    width: auto;
  }

  .pieces-copy h2,
  .memory-copy h2,
  .words-copy h2 {
    margin-top: 16px;
  }

  .pieces-copy .section-lede,
  .memory-copy .section-lede,
  .words-copy .section-lede {
    margin-top: 16px;
  }

  .stats {
    margin-top: 24px;
  }

  .access-note {
    margin-top: 12px;
  }

  .tree {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: auto;
    margin-top: 36px;
  }

  .tree-canvas {
    width: 342px;
    height: 452px;
  }

  .tree-node {
    width: 96px;
    height: 112px;
    padding-top: 8px;
  }

  .tree-node .stroke-character {
    width: 68px;
    height: 68px;
  }

  .tree-node > span {
    padding-top: 4px;
  }

  [data-node="土"] {
    top: 0;
    left: 94px;
  }

  [data-node="王"] {
    top: 170px;
    left: 9px;
  }

  [data-node="寺"] {
    top: 170px;
    left: 180px;
  }

  [data-node="玉"] {
    top: 340px;
    left: 9px;
  }

  [data-node="時"] {
    top: 340px;
    left: 123px;
  }

  [data-node="持"] {
    top: 340px;
    left: 237px;
  }

  .tree-cards {
    position: static;
    margin-top: 20px;
  }

  .tree figcaption {
    position: static;
    max-width: 342px;
    padding-top: 16px;
  }

  .library {
    gap: 0;
    padding-block: 72px 64px;
  }

  .library-intro {
    gap: 16px;
  }

  .library-figure {
    gap: 6px;
    padding-top: 4px;
  }

  .library-intro h2 {
    padding-top: 8px;
  }

  .library-search {
    align-items: stretch;
    gap: 10px;
    padding-top: 28px;
  }

  .search-field {
    width: 100%;
    min-height: 56px;
    height: auto;
    gap: 10px;
    padding: 0 8px 0 16px;
  }

  /* The sheet answers the search first; the rows drift whole below it, in
     the flow, so a taller sheet pushes them down instead of covering them. */
  .library-wall {
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-top: 28px;
    padding: 0 0 15px;
  }

  .wall {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
  }

  .wall-row {
    position: relative;
  }

  .wall-row:nth-child(1) {
    top: auto;
    left: calc(50% - 217px);
  }

  .wall-row:nth-child(2) {
    top: auto;
    left: calc(50% - 262px);
  }

  .wall-row:nth-child(3),
  .wall-row:nth-child(4) {
    display: none;
  }

  .wall-track {
    gap: 8px;
  }

  .wall-pause {
    position: relative;
    right: auto;
    bottom: auto;
    align-self: flex-end;
    margin: 12px 24px 0 0;
  }

  .wall-tile {
    width: 60px;
    height: 60px;
  }

  .wall-tile small,
  .wall-word-reading {
    display: none;
  }

  .wall-word {
    width: 96px;
  }

  .sheet-stack {
    order: -1;
    width: min(342px, calc(100% - 48px));
  }

  .kanji-sheet-head {
    gap: 20px;
    padding: 22px 22px 18px;
  }

  .kanji-sheet-readings {
    padding: 18px 22px;
  }

  .kanji-sheet-examples {
    padding: 18px 22px 26px;
  }

  .kanji-sheet-empty {
    padding: 0 22px 26px;
  }

  .levels {
    padding-top: 36px;
  }

  .levels-bar {
    height: 12px;
  }

  .levels-legend {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .levels-legend p {
    gap: 3px;
  }

  .features {
    grid-template-columns: 1fr;
    gap: 0;
    margin-top: 32px;
    padding-top: 0;
  }

  .feature {
    gap: 4px;
    padding-block: 18px;
  }

  .words-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-block: 72px 64px;
  }

  .words-copy {
    display: contents;
  }

  .progression {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-top: 36px;
    padding: 0;
  }

  .progression li,
  .progression li + li {
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 4px 0 18px 18px;
  }

  .progression li:last-child {
    align-items: flex-end;
    padding-bottom: 4px;
  }

  .step-label {
    flex: 0 0 76px;
  }

  .step-word ruby {
    width: auto;
  }

  .step-sentence .step-glyph {
    height: auto;
    padding-bottom: 0;
  }

  .step-sentence {
    flex-wrap: wrap;
  }

  .step-sentence .step-label {
    padding-bottom: 8px;
  }

  .words-forest {
    --forest-scale: 0.7436;
  }

  .words-forest,
  .stroke-motion .words-forest {
    order: 1;
    align-self: center;
    min-height: 0;
    margin-top: 44px;
  }

  .stroke-motion .forest-stage {
    position: static;
  }

  .phone-forest {
    margin: 0;
  }

  .themes {
    order: 2;
    width: 100%;
    padding-top: 44px;
  }

  .themes .overline {
    padding-bottom: 12px;
  }

  .themes-start {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding-top: 24px;
  }

  .cadence {
    order: 3;
    width: 100%;
    gap: 16px;
    margin-top: 32px;
    padding: 22px 20px 20px;
  }

  .cadence-line {
    gap: 4px;
  }

  .cadence-done,
  .cadence-next {
    flex-basis: 12px;
    width: 12px;
    height: 12px;
  }

  .cadence-gap {
    flex-basis: 8px;
  }

  .memory-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding-block: 72px 64px;
  }

  .memory-cards {
    order: 1;
    align-self: center;
    width: 342px;
    height: 548px;
    margin-top: 32px;
  }

  .activities {
    order: 2;
    margin-top: 28px;
  }

  .card-back {
    top: 22px;
    left: 66px;
    width: 256px;
    height: 300px;
  }

  .memory-card {
    top: 52px;
    left: 20px;
    width: 290px;
  }

  .memory-glyph {
    height: 176px;
  }

  .memory-answer {
    width: 250px;
    padding: 18px 0 20px;
  }

  .session {
    top: 0;
    left: 20px;
  }

  .memory-answers {
    top: 430px;
    left: 20px;
    gap: 10px;
    width: 290px;
  }

  .answer {
    height: 50px;
  }

  .mastery {
    top: 502px;
    left: 20px;
    gap: 10px;
    width: 290px;
  }

  .plans-inner {
    gap: 20px;
    padding-block: 72px 56px;
  }

  .plans-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding-bottom: 8px;
  }

  .plans-heading > div {
    gap: 14px;
  }

  .plans-heading > p {
    flex: none;
  }

  .plan-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .plan {
    padding: 26px 24px 28px;
  }

  .faq-inner {
    display: flex;
    flex-direction: column;
    padding-block: 64px 56px;
  }

  .faq-inner h2 {
    margin-top: 14px;
  }

  .faq-contact {
    margin-top: 0;
    padding-top: 24px;
  }

  .faq-list {
    width: 100%;
    margin-top: 28px;
  }

  .faq-item {
    padding-block: 20px;
  }

  .closing-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-block: 64px 72px;
  }

  .closing h2 {
    margin-top: 24px;
  }

  .closing-text {
    margin-top: 16px;
  }

  .closing-art {
    flex: none;
    align-self: center;
    width: 342px;
    height: 470px;
    margin-top: 24px;
  }

  .closing .get-app {
    margin-top: 28px;
  }

  .sheet-closing {
    top: 96px;
    left: 21px;
    width: 300px;
  }

  .sheet-closing .sheet-head {
    min-height: 51px;
    padding: 0 18px;
  }

  .sheet-closing .sheet-art {
    padding: 18px 0 10px;
  }

  .sheet-closing .sheet-art .stroke-character {
    width: 226px;
    height: 226px;
  }

  .sheet-closing .sheet-foot {
    padding: 8px 18px 18px;
  }

  .hoki-sing {
    top: -6px;
    left: 170px;
    width: 132px;
    height: 132px;
  }

  .song-notes {
    top: -14px;
    left: 272px;
    width: 72px;
    height: 90px;
  }
}

@media (max-width: 899px) {
  .footer-socials {
    flex-flow: row wrap;
    gap: 8px;
  }
}

/* Short desktop viewports scale the fixed phone so it stays whole. */
@media (min-width: 1180px) and (max-height: 911px) {
  .stroke-motion .words-forest {
    --forest-scale: 0.9;
  }
}

@media (min-width: 1180px) and (max-height: 822px) {
  .stroke-motion .words-forest {
    --forest-scale: 0.8;
  }
}

@media (min-width: 1180px) and (max-height: 733px) {
  .stroke-motion .words-forest {
    --forest-scale: 0.7;
  }
}

/* Below the 390 artboard the fixed 342 px compositions scale as a whole. */
@media (max-width: 389px) {
  .hero-art,
  .tree-canvas,
  .memory-cards,
  .closing-art {
    zoom: 0.95;
  }
}

@media (max-width: 372px) {
  .hero-art,
  .tree-canvas,
  .memory-cards,
  .closing-art {
    zoom: 0.9;
  }
}

@media (max-width: 355px) {
  .words-forest {
    --forest-scale: 0.7;
  }

  .hero-art,
  .tree-canvas,
  .memory-cards,
  .closing-art {
    zoom: 0.78;
  }
}
