/* =====================================================================
   Metro Wayfinding — theme for "Nihongo Side Station"
   Each JLPT level is a line; each lesson is a numbered station.
   Shared source: books/shared/extra.css (copied into each book).
   ===================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  /* line colours (one per level). */
  --line-start: #7354D6;   /* Part 0: violet */
  --line-n5:    #EE8A12;   /* N5: orange    */
  --line-n4:    #1F9D57;
  --line-n3:    #1E78D2;
  --line-n2:    #D6385A;
  --line-n1:    #3B4252;
  --line-facility: #5B6B82;

  /* enamel-sign neutrals */
  --ground:  #F2F5F8;
  --panel:   #FFFFFF;
  --ink:     #14213D;
  --ink-2:   #46536A;
  --ink-3:   #6B778C;
  --rule:    #DCE2EA;
  --rule-2:  #C5CEDA;
  --tint:    #EEF2F7;

  --ok:      #17713D;
  --caution: #8F5600;

  --line: var(--line-n5);
  --line-ink: #8A4B00;      /* line colour darkened for text on white (AA) */
  --line-wash: #FDF1E2;     /* line colour washed for fills */

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
  --shadow-1: 0 1px 2px rgba(20, 33, 61, .06), 0 2px 8px rgba(20, 33, 61, .05);
  --shadow-2: 0 2px 4px rgba(20, 33, 61, .06), 0 10px 28px rgba(20, 33, 61, .09);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  --font-sign: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  --font-body: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
}

html[data-line="start"]    { --line: var(--line-start); --line-ink: #5A3CC0; --line-wash: #F1EDFC; }
html[data-line="n5"]       { --line: var(--line-n5);    --line-ink: #8A4B00; --line-wash: #FDF1E2; }
html[data-line="facility"] { --line: var(--line-facility); --line-ink: #46536A; --line-wash: #EEF2F7; }
html[data-line="home"]     { --line: var(--ink);        --line-ink: var(--ink); --line-wash: var(--tint); }

[data-md-color-scheme="slate"] {
  --ground:  #0E1420;
  --panel:   #161E2C;
  --ink:     #E9EEF6;
  --ink-2:   #B3BDCD;
  --ink-3:   #8A96AA;
  --rule:    #263247;
  --rule-2:  #34425B;
  --tint:    #1C2637;
  --ok:      #4CC283;
  --caution: #F0A63A;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .35), 0 12px 30px rgba(0, 0, 0, .35);
}
[data-md-color-scheme="slate"] { --line-ink: var(--line); --line-wash: color-mix(in srgb, var(--line) 16%, var(--panel)); }
html[data-line="home"] [data-md-color-scheme="slate"] { --line-ink: var(--ink); --line-wash: var(--tint); }

/* map tokens onto Material */
[data-md-color-scheme] {
  --md-default-bg-color: var(--ground);
  --md-default-fg-color: var(--ink);
  --md-default-fg-color--light: var(--ink-2);
  --md-default-fg-color--lighter: var(--ink-3);
  --md-default-fg-color--lightest: var(--rule);
  --md-primary-fg-color: var(--panel);
  --md-primary-bg-color: var(--ink);
  --md-accent-fg-color: var(--line-ink);
  --md-typeset-color: var(--ink);
  --md-typeset-a-color: var(--line-ink);
  --md-code-bg-color: var(--tint);
  --md-code-fg-color: var(--ink);
  --md-footer-bg-color: var(--panel);
  --md-footer-bg-color--dark: var(--ground);
  --md-footer-fg-color: var(--ink);
  --md-footer-fg-color--light: var(--ink-2);
  --md-footer-fg-color--lighter: var(--ink-3);
  --md-text-font-family: var(--font-body);
}

/* ---------- 2. Browser surfaces ---------- */
body { font-family: var(--font-body); -webkit-font-smoothing: antialiased; background: var(--ground); }
::selection { background: color-mix(in srgb, var(--line) 28%, transparent); color: var(--ink); }
:focus-visible { outline: 3px solid var(--line); outline-offset: 2px; border-radius: 4px; }
html { scrollbar-color: var(--rule-2) transparent; accent-color: var(--line); }
.md-typeset a { text-underline-offset: .18em; text-decoration-thickness: 1px; }
.md-typeset a:hover { text-decoration: underline; }
.md-typeset table, .md-typeset .route__count, .roundel { font-variant-numeric: tabular-nums; }

/* ---------- 3. Header: a white enamel bar with the line stripe ---------- */
.md-header {
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  color: var(--ink);
  box-shadow: 0 1px 0 var(--rule);
  border-top: 4px solid var(--line);
}
.md-header--shadow { box-shadow: 0 1px 0 var(--rule), 0 6px 18px rgba(20, 33, 61, .06); }
.md-header__title { font-family: var(--font-sign); font-weight: 700; letter-spacing: -.01em; }
.md-header__button { color: var(--ink); }
.md-search__form { background: var(--tint); border-radius: 999px; }
.md-search__input { color: var(--ink); }
.md-search__input::placeholder { color: var(--ink-3); }
.md-search__icon { color: var(--ink-2); }
@media (prefers-reduced-transparency: reduce) {
  .md-header { background: var(--panel); backdrop-filter: none; }
}

/* ---------- 4. Navigation: the sidebar reads like a line diagram ---------- */
.md-nav { font-size: .74rem; }
.md-nav__title { font-family: var(--font-sign); color: var(--ink); }
.md-nav--primary > .md-nav__list > .md-nav__item--section > .md-nav__link,
.md-nav--primary > .md-nav__list > .md-nav__item--section > label.md-nav__link {
  font-family: var(--font-sign); font-weight: 700; color: var(--ink); letter-spacing: .01em;
}
.md-nav__link { color: var(--ink-2); border-radius: var(--radius-sm); transition: color 150ms ease, background-color 150ms ease; }
@media (hover: hover) and (pointer: fine) {
  .md-nav__link:hover { color: var(--ink); }
}
.md-nav__link--active, .md-nav__item--active > .md-nav__link {
  color: var(--ink) !important; font-weight: 700;
}
@media screen and (min-width: 76.25em) {
  .md-sidebar--primary .md-nav__item--section > .md-nav > .md-nav__list {
    border-left: 2px solid var(--rule); margin-left: .45rem; padding-left: .2rem;
  }
  .md-sidebar--primary .md-nav__item--section .md-nav__link--active {
    position: relative;
  }
  .md-sidebar--primary .md-nav__item--section .md-nav__link--active::before {
    content: ""; position: absolute; left: -.62rem; top: 50%; width: .62rem; height: .62rem;
    transform: translate(-50%, -50%); border-radius: 50%;
    background: var(--panel); border: 3px solid var(--line);
  }
}

/* ---------- 5. Reading leaf ---------- */
.md-main__inner { margin-top: 1.2rem; }
.md-content__inner {
  padding: 1rem 1.2rem 1.8rem;
  margin: 0 .6rem 1.2rem;
}
.md-content__inner::before { display: none; }
@media screen and (max-width: 44.9375em) {
  .md-main__inner { margin-top: .6rem; }
  .md-content__inner { margin: 0 .4rem .8rem; padding: .6rem .5rem 1.3rem; }
}

.md-typeset { font-size: .86rem; line-height: 1.85; color: var(--ink); }
.md-typeset p, .md-typeset li, .md-typeset td { line-height: 1.9; }
@media screen and (max-width: 44.9375em) { .md-typeset { font-size: .84rem; } }

/* furigana */
.md-typeset ruby { ruby-position: over; }
.md-typeset rt { font-size: .58em; color: var(--ink-3); font-weight: 500; letter-spacing: .02em; }

/* headings: signage type, Japanese stays the hero */
.md-typeset h1, .md-typeset h2, .md-typeset h3, .md-typeset h4 { font-family: var(--font-sign); color: var(--ink); text-wrap: balance; }
.md-typeset h1 { font-weight: 900; font-size: clamp(1.55rem, 1.1rem + 2.2vw, 2.25rem); line-height: 1.35; letter-spacing: -.02em; margin: 0 0 .4em; }
.md-typeset h2 {
  font-weight: 700; font-size: 1.32rem; line-height: 1.4; letter-spacing: -.01em;
  margin: 2.2em 0 .7em; padding-top: 1.2em; border-top: 1px solid var(--rule);
  display: flex; align-items: center; gap: .55em;
}
.md-typeset h2::before {               /* a stop on the line */
  content: ""; flex: none; width: .62em; height: .62em; border-radius: 50%;
  background: var(--panel); box-shadow: 0 0 0 .2em var(--line);
}
.md-typeset h3 { font-weight: 700; font-size: 1.05rem; margin: 1.8em 0 .5em; }
.md-typeset h4 { font-weight: 700; font-size: .95rem; }
.md-typeset .headerlink { color: var(--ink-3); }
.md-typeset hr { border-bottom: 1px solid var(--rule); }


/* ---------- 6. Station sign + roundel ---------- */
.roundel {
  --c: var(--line);
  display: inline-grid; place-items: center; align-content: center;
  width: 3rem; height: 3rem; flex: none;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: inset 0 0 0 .3rem var(--c);
  color: var(--ink);
  font-family: var(--font-sign);
  line-height: 1;
}
.roundel[data-line="start"]    { --c: var(--line-start); }
.roundel[data-line="n5"], .roundel[data-line="n5-hub"] { --c: var(--line-n5); }
.roundel[data-line="facility"] { --c: var(--line-facility); }
.roundel__line { font-size: .6rem; font-weight: 700; letter-spacing: .04em; }
.roundel__num  { font-size: 1rem; font-weight: 900; letter-spacing: -.02em; }
.roundel__line:empty { display: none; }
.roundel--lg { width: 3.9rem; height: 3.9rem; box-shadow: inset 0 0 0 .38rem var(--c); }
.roundel--lg .roundel__line { font-size: .64rem; }
.roundel--lg .roundel__num { font-size: 1.3rem; }

.md-typeset .station { margin: -.2rem 0 1.4rem; }
.md-typeset .station__sign { display: flex; align-items: center; gap: .95rem; }
.md-typeset .station__sign h1 { margin: 0; }
@media screen and (max-width: 44.9375em) {
  .md-typeset .station__sign { align-items: flex-start; gap: .75rem; }
  .roundel--lg { width: 3.3rem; height: 3.3rem; margin-top: .35rem; }
  .roundel--lg .roundel__num { font-size: 1.1rem; }
}

/* route strip: every station on this line */
.md-typeset .route { margin-top: 1.1rem; }
.md-typeset .route__track {
  list-style: none; margin: 0; padding: 0;
  display: flex; justify-content: space-between; align-items: center;
  position: relative;
}
.md-typeset .route__track::before {   /* the line itself */
  content: ""; position: absolute; left: .5rem; right: .5rem; top: 50%; height: 4px;
  transform: translateY(-50%); border-radius: 2px; background: var(--line);
}
.md-typeset .route__stop { margin: 0; padding: 0; position: relative; z-index: 1; list-style: none; }
.md-typeset .route__stop a {
  display: grid; place-items: center; width: 1.6rem; height: 2.2rem; text-decoration: none; color: var(--ink-3);
}
.md-typeset .route__dot {
  width: .62rem; height: .62rem; border-radius: 50%;
  background: var(--panel); box-shadow: 0 0 0 3px var(--line);
  transition: transform 160ms var(--ease-out);
}
.md-typeset .route__label { display: none; }
/* stations ahead of you: the line is not travelled yet */
.md-typeset .route__stop.is-current ~ .route__stop .route__dot { box-shadow: 0 0 0 3px var(--rule-2); }
.md-typeset .route__stop.is-seen:not(.is-current) .route__dot { background: var(--line); }
.md-typeset .route__stop.is-current .route__dot {
  width: 1.05rem; height: 1.05rem; background: var(--ink); box-shadow: 0 0 0 3px var(--panel), 0 0 0 6px var(--line);
}
@media (hover: hover) and (pointer: fine) {
  .md-typeset .route__stop a:hover .route__dot { transform: scale(1.35); }
}
.md-typeset .route__stop a:active .route__dot { transform: scale(.9); }
.md-typeset .route__count {
  margin: .25rem 0 0; font-family: var(--font-sign); font-size: .72rem; font-weight: 700; color: var(--ink-3); text-align: right;
}

/* ---------- 7. Home: route map ---------- */
.md-typeset .routemap { margin: 1.2rem 0 2rem; }
.md-typeset .continue {
  display: flex; align-items: center; gap: 1rem;
  padding: .9rem 1.1rem; border-radius: var(--radius);
  background: var(--ink); color: var(--panel); text-decoration: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .08), 0 10px 24px rgba(0, 0, 0, .12);
  transition: transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
[data-md-color-scheme="slate"] .md-typeset .continue { background: #F2F5FA; color: #0E1420; }
.md-typeset .continue:active { transform: scale(.98); }
@media (hover: hover) and (pointer: fine) {
  .md-typeset .continue:hover { text-decoration: none; transform: translateY(-1px); }
  .md-typeset .continue:hover .continue__arrow { transform: translateX(3px); }
}
.md-typeset .continue .roundel { color: var(--ink); }
[data-md-color-scheme="slate"] .md-typeset .continue .roundel { background: #fff; color: #14213D; }
.md-typeset .continue__text { display: grid; flex: 1; min-width: 0; }
.md-typeset .continue__label { font-size: .72rem; font-weight: 700; letter-spacing: .04em; opacity: .75; }
.md-typeset .continue__title { font-family: var(--font-sign); font-size: 1.05rem; font-weight: 700; line-height: 1.4; }
.md-typeset .continue__arrow { width: 1.4rem; height: 1.4rem; flex: none; transition: transform 160ms var(--ease-out); }

.md-typeset .lines { display: grid; gap: 1rem; margin-top: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(16.5rem, 1fr)); align-items: start; }
.md-typeset .line { --c: var(--line-facility); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel); padding: .9rem 1rem .6rem; }
.md-typeset .line[data-line="start"] { --c: var(--line-start); }
.md-typeset .line[data-line="n5"]    { --c: var(--line-n5); }
.md-typeset .line__head { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; }
.md-typeset .line__badge {
  display: inline-grid; place-items: center; min-width: 2.2rem; height: 2.2rem; padding: 0 .45rem; border-radius: .6rem;
  background: var(--c); color: #fff; font-family: var(--font-sign); font-weight: 900; font-size: .9rem;
}
.md-typeset .line__badge[data-line="n5"] { color: #14213D; }
.md-typeset .line__badge[data-line="soon"] { background: var(--rule-2); color: var(--ink-2); }
.md-typeset .line__name { margin: 0; padding: 0; border: 0; font-size: 1rem; display: block; }
.md-typeset .line__name::before { display: none; }
.md-typeset .line__stops { list-style: none; margin: 0; padding: 0; position: relative; }
.md-typeset .line__stops::before {
  content: ""; position: absolute; left: .62rem; top: .9rem; bottom: .9rem; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--c);
}
.md-typeset .line__stop { margin: 0; list-style: none; }
.md-typeset .line__stop a {
  position: relative; display: grid; grid-template-columns: 1.25rem auto 1fr auto; align-items: center; gap: .6rem;
  min-height: 2.75rem; padding: .25rem .4rem .25rem 0; border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none; line-height: 1.35;
}
@media (hover: hover) and (pointer: fine) {
  .md-typeset .line__stop a:hover { background: var(--tint); text-decoration: none; }
  .md-typeset .line__stop a:hover .line__dot { transform: scale(1.25); }
}
.md-typeset .line__stop a:active { background: var(--tint); }
.md-typeset .line__dot {
  justify-self: center; width: .75rem; height: .75rem; border-radius: 50%;
  background: var(--panel); box-shadow: 0 0 0 3px var(--c); transition: transform 160ms var(--ease-out);
}
.md-typeset .line__code { font-family: var(--font-sign); font-weight: 900; font-size: .72rem; color: var(--ink-3); min-width: 2.6rem; }
.md-typeset .line__title { font-size: .8rem; font-weight: 500; }
.md-typeset .line__seen { font-size: .62rem; font-weight: 700; color: var(--ok); letter-spacing: .03em; visibility: hidden; }
.md-typeset .line__stop.is-seen .line__dot { background: var(--c); }
.md-typeset .line__stop.is-seen .line__seen { visibility: visible; }
.md-typeset .line__stop.is-last .line__dot { width: 1rem; height: 1rem; background: var(--ink); box-shadow: 0 0 0 3px var(--panel), 0 0 0 6px var(--c); }
.md-typeset .line--soon { border-style: dashed; background: transparent; }
.md-typeset .line__soon { margin: 0 0 .4rem; color: var(--ink-3); font-weight: 700; font-size: .8rem; }

/* ---------- 8. Dialogue: a script, one row per line ---------- */
.md-typeset .dialogue {
  margin: 1rem 0 1.2rem; padding: .3rem .2rem; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--rule-2);
  display: grid; gap: 0;
}
.md-typeset .dl {
  margin: 0; display: grid; grid-template-columns: 6.2rem 1fr; gap: .8rem; align-items: start;
  padding: .55rem .8rem; border-radius: 0; background: transparent;
  font-size: 1.02em; line-height: 2;
}
.md-typeset .dl + .dl { border-top: 1px solid var(--rule); }
.md-typeset .dl__who {
  justify-self: start; margin-top: .55em;
  font-family: var(--font-sign); font-weight: 700; font-size: .78rem; line-height: 1.5;
  padding: .12em .65em .18em; border-radius: 999px;
  background: var(--who-bg, var(--tint)); color: var(--who-ink, var(--ink-2));
}
.md-typeset .dl__who rt { color: inherit; opacity: .7; }
.md-typeset .dl[data-who="rina"]   { --who-hue: #8A4B00; --who-bg: #FDEBD6; --who-ink: #8A4B00; }
.md-typeset .dl[data-who="yuki"]   { --who-hue: #A3203F; --who-bg: #FCE4EA; --who-ink: #A3203F; }
.md-typeset .dl[data-who="mike"]   { --who-hue: #1B6B3E; --who-bg: #DFF3E7; --who-ink: #1B6B3E; }
.md-typeset .dl[data-who="yamada"] { --who-hue: #1C4E9A; --who-bg: #E6EEFB; --who-ink: #1C4E9A; }
[data-md-color-scheme="slate"] .md-typeset .dl[data-who] .dl__who { background: color-mix(in srgb, var(--who-hue, #5B6B82) 62%, var(--panel)); color: #FFFFFF; }
.md-typeset .dl--direction { display: block; background: transparent; padding: .2rem .8rem; font-size: .8rem; font-style: italic; color: var(--ink-2); line-height: 1.6; }
@media screen and (max-width: 44.9375em) {
  .md-typeset .dl { grid-template-columns: 1fr; gap: 0; padding: .5rem .7rem .55rem; }
  .md-typeset .dl__who { margin: 0 0 .1rem; }
}

/* ---------- 9. Grammar pattern: the platform sign ---------- */
.md-typeset .grammar {
  margin: 1rem 0; padding: .9rem 1.2rem; border-radius: var(--radius);
  background: var(--ink); color: #F5F7FB;
  font-family: var(--font-sign); font-size: 1.12em; font-weight: 700; line-height: 1.9;
  box-shadow: var(--shadow-1);
}
[data-md-color-scheme="slate"] .md-typeset .grammar { background: #E9EEF6; color: #0E1420; }
.md-typeset .grammar p { margin: .1rem 0; }
.md-typeset .grammar strong { font-weight: 900; }
.md-typeset .grammar rt { color: inherit; opacity: .72; }

/* ---------- 10. Callouts as sign plates ---------- */
.md-typeset .admonition, .md-typeset details {
  --a: var(--ink-2);
  border: 1px solid var(--rule); border-left-width: 1px;
  border-radius: var(--radius); background: var(--panel); box-shadow: none;
  font-size: .82rem; padding: 0 1rem; margin: 1.3em 0;
}
.md-typeset .admonition > .admonition-title, .md-typeset details > summary {
  font-family: var(--font-sign); font-weight: 700; font-size: .8rem;
  background: transparent; border: 0; margin: 0 -1rem; padding: .7rem 1rem .5rem 2.7rem;
  color: var(--a);
}
.md-typeset .admonition > .admonition-title::before, .md-typeset details > summary::before {
  background-color: var(--a); left: 1rem; top: .78rem; width: 1.05rem; height: 1.05rem;
}
.md-typeset details > summary { min-height: 2.75rem; display: flex; align-items: center; padding-top: .55rem; cursor: pointer; }
.md-typeset details > summary::after { color: var(--ink-3); top: .8rem; }
.md-typeset details[open] > summary { border-bottom: 1px solid var(--rule); margin-bottom: .6rem; padding-bottom: .55rem; }
.md-typeset .admonition.tip, .md-typeset details.tip           { --a: var(--ok); background: color-mix(in srgb, var(--ok) 6%, var(--panel)); border-color: color-mix(in srgb, var(--ok) 28%, var(--rule)); }
.md-typeset .admonition.warning, .md-typeset details.warning   { --a: var(--caution); background: color-mix(in srgb, var(--caution) 7%, var(--panel)); border-color: color-mix(in srgb, var(--caution) 30%, var(--rule)); }
.md-typeset .admonition.note, .md-typeset .admonition.info,
.md-typeset details.info, .md-typeset details.note             { --a: #1E66C2; background: color-mix(in srgb, #1E78D2 6%, var(--panel)); border-color: color-mix(in srgb, #1E78D2 26%, var(--rule)); }
[data-md-color-scheme="slate"] .md-typeset .admonition.note, [data-md-color-scheme="slate"] .md-typeset .admonition.info,
[data-md-color-scheme="slate"] .md-typeset details.info { --a: #7DB6F2; }
.md-typeset details.success { --a: var(--line-ink); background: var(--line-wash); border-color: color-mix(in srgb, var(--line) 35%, var(--rule)); }
.md-typeset .admonition :is(p, li), .md-typeset details :is(p, li) { line-height: 1.85; }

/* ---------- 11. Tables ---------- */
.md-typeset table:not([class]) {
  border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden;
  font-size: .8rem; box-shadow: none; background: var(--panel);
}
.md-typeset table:not([class]) th {
  background: var(--tint); color: var(--ink-2); font-family: var(--font-sign); font-weight: 700; font-size: .74rem;
  border-bottom: 1px solid var(--rule); padding: .6em 1em;
}
.md-typeset table:not([class]) td { border-top: 1px solid var(--rule); padding: .55em 1em; vertical-align: middle; }
.md-typeset table:not([class]) tr:first-child td { border-top: 0; }
@media (hover: hover) and (pointer: fine) {
  .md-typeset table:not([class]) tbody tr:hover { background: color-mix(in srgb, var(--line) 5%, transparent); }
}
.md-typeset .kana table td { font-size: 1.12em; text-align: center; white-space: nowrap; }
@media screen and (max-width: 44.9375em) {
  .md-typeset table:not([class]) { font-size: .76rem; }
  .md-typeset table:not([class]) th, .md-typeset table:not([class]) td { padding: .45em .6em; }
}
.md-typeset .exc {
  display: inline-grid; place-items: center; width: 1.15em; height: 1.15em; border-radius: 50%;
  background: var(--caution); color: #fff; font-family: var(--font-sign); font-weight: 900; font-size: .8em; vertical-align: .08em;
}

/* ---------- 12. Kanji cards (generated) ---------- */
.md-typeset .kanji-card {
  display: grid; grid-template-columns: 8.5rem 1fr; gap: 1.2rem; align-items: start;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel);
  padding: 1rem 1.1rem; margin: 1rem 0;
}
.md-typeset .kanji-card > p:first-child { margin: 0; }
.md-typeset .kanji-card img.kanji-svg {
  width: 8.5rem; height: 8.5rem; display: block; border-radius: var(--radius-sm);
  background:
    linear-gradient(var(--rule) 1px, transparent 1px) center / 100% 50% no-repeat,
    linear-gradient(90deg, var(--rule) 1px, transparent 1px) center / 50% 100% no-repeat,
    #fff;
  border: 1px solid var(--rule);
}
.md-typeset .kanji-big { display: inline-block; font-family: var(--font-sign); font-weight: 900; font-size: 3.2rem; line-height: 1; color: var(--ink); margin-bottom: .2rem; }
.md-typeset .kanji-info p { margin: .25rem 0; font-size: .8rem; line-height: 1.85; }
.md-typeset .kanji-info strong { color: var(--ink-2); font-weight: 700; }
@media screen and (max-width: 44.9375em) {
  .md-typeset .kanji-card { grid-template-columns: 6.2rem 1fr; gap: .9rem; padding: .85rem; }
  .md-typeset .kanji-card img.kanji-svg { width: 6.2rem; height: 6.2rem; }
  .md-typeset .kanji-big { font-size: 2.5rem; }
}

/* ---------- 13. Buttons, blockquotes, code, lists ---------- */
.md-typeset .md-button {
  display: inline-flex; align-items: center; gap: .4em; min-height: 2.75rem; margin: .25rem .3rem .25rem 0;
  padding: .55em 1.15em; border-radius: 999px; border: 1px solid var(--rule-2);
  background: var(--panel); color: var(--ink); font-family: var(--font-sign); font-weight: 700; font-size: .8rem;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease;
}
.md-typeset .md-button:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) {
  .md-typeset .md-button:hover { background: var(--tint); border-color: var(--line); color: var(--ink); }
}
.md-typeset .md-button--primary { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.md-typeset blockquote { border-left: 0; padding: .7rem 1rem; margin: 1rem 0; border-radius: var(--radius); background: var(--tint); color: var(--ink); font-size: 1.05em; }
.md-typeset code { border-radius: 6px; padding: .1em .35em; }
.md-typeset pre > code { border-radius: var(--radius); }
.md-typeset ul li::marker { color: var(--line); }
.md-typeset ol li::marker { color: var(--ink-2); font-weight: 700; }
.md-typeset .task-list-control .task-list-indicator::before { background-color: var(--rule-2); }

.jp-big { font-family: var(--font-sign); font-size: 2.2em; font-weight: 700; line-height: 1.5; }

/* ---------- 14. Footer: next/previous station signs ---------- */
.md-footer { background: transparent; color: var(--ink); }
.md-footer__inner { padding: .4rem .6rem 1rem; gap: .8rem; display: flex; }
.md-footer__link {
  flex: 1 1 0; display: flex; align-items: center; gap: .6rem; min-height: 3.6rem; padding: .7rem 1rem;
  background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); color: var(--ink);
  transition: transform 160ms var(--ease-out), border-color 150ms ease;
  opacity: 1;
}
.md-footer__link:active { transform: scale(.98); }
@media (hover: hover) and (pointer: fine) { .md-footer__link:hover { border-color: var(--line); opacity: 1; } }
.md-footer__link--next { justify-content: flex-end; text-align: right; }
.md-footer__title { font-family: var(--font-sign); font-weight: 700; font-size: .9rem; line-height: 1.35; padding: 0; flex: initial; }
.md-footer__direction { color: var(--ink-3); font-size: .64rem; font-weight: 700; letter-spacing: .05em; position: static; opacity: 1; margin-bottom: .1rem; }
.md-footer__button { color: var(--line-ink); margin: 0; padding: 0; }
.md-footer-meta { background: transparent; }
.md-footer-meta__inner { color: var(--ink-3); }
@media screen and (max-width: 44.9375em) {
  .md-footer__link--prev .md-footer__title { display: block; font-size: .78rem; }
  .md-footer__link--prev { flex: 0 1 38%; }
}

/* ---------- 15. Motion & accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
@media (prefers-contrast: more) {
  :root { --rule: #8A96AA; --ink-2: #26324A; --ink-3: #3A465C; }
}

/* ---------- 16. Beat Material's list defaults for wayfinding lists ---------- */
[dir] .md-typeset ol.route__track { display: flex; margin: 0; padding: 0; }
[dir] .md-typeset ol.route__track > li.route__stop,
[dir] .md-typeset ol.line__stops > li.line__stop { margin: 0; padding: 0; list-style: none; }
[dir] .md-typeset ol.line__stops { margin: 0; padding: 0; display: block; }

/* ---------- 17. Fit-to-width fixes (phone) ---------- */
[dir] .md-typeset ol.route__track > li.route__stop { flex: 1 1 0; min-width: 0; display: flex; justify-content: center; }
.md-typeset .route__stop a { width: 100%; max-width: 1.6rem; }
.md-typeset .route__track::before { left: .3rem; right: .3rem; }
@media screen and (max-width: 44.9375em) {
  .md-typeset .route__dot { width: .5rem; height: .5rem; box-shadow: 0 0 0 2.5px var(--line); }
  .md-typeset .route__stop.is-current ~ .route__stop .route__dot { box-shadow: 0 0 0 2.5px var(--rule-2); }
  .md-typeset .route__stop.is-current .route__dot { width: .85rem; height: .85rem; box-shadow: 0 0 0 2.5px var(--panel), 0 0 0 5px var(--line); }
  .md-typeset h1 { font-size: 1.42rem; line-height: 1.45; }
}
/* visited mark: a drawn check, the words stay for screen readers */
.md-typeset .line__stop a { grid-template-columns: 1.25rem auto minmax(0, 1fr) 1.1rem; }
.md-typeset .line__seen {
  position: relative; width: 1.1rem; height: 1.1rem; font-size: 0; color: transparent; overflow: hidden;
}
.md-typeset .line__seen::before {
  content: ""; position: absolute; left: .32rem; top: .12rem; width: .32rem; height: .62rem;
  border: solid var(--ok); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}

/* ---------- 18. Minimum sizes for Material's small print ---------- */
.md-skip { font-size: .75rem; }
.md-footer__direction { font-size: .7rem; }
.md-footer-meta, .md-copyright { font-size: .72rem; }
.md-search-result__meta { font-size: .72rem; }
.md-typeset .line__code { font-size: .74rem; }
.md-typeset .route__count { font-size: .74rem; }

/* ---------- 19. Finish-review fixes ---------- */
/* station sign = a white enamel plate with the line along its foot */
.md-typeset .station {
  background: var(--panel); border: 1px solid var(--rule); border-bottom: 6px solid var(--line);
  border-radius: var(--radius-lg); padding: 1.15rem 1.25rem .95rem; box-shadow: var(--shadow-1);
  margin: 0 0 1.6rem;
}
/* three-part title: small prefix, large Japanese, small gloss */
.md-typeset h1 .t-pre, .md-typeset h1 .t-gloss {
  display: block; font-size: .95rem; font-weight: 700; letter-spacing: 0; color: var(--ink-2); line-height: 1.5;
}
.md-typeset h1 .t-jp {
  display: block; font-size: clamp(2rem, 1.35rem + 2.6vw, 3rem); font-weight: 900; line-height: 1.45;
  word-break: keep-all; line-break: strict; overflow-wrap: anywhere; letter-spacing: -.01em; margin: .1rem 0 .15rem;
}
.md-typeset h1 .t-jp rt { font-size: .42em; font-weight: 500; }
/* previous / next stations under the strip */
.md-typeset .route__ends { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .8rem; }
.md-typeset .route__end {
  display: flex; align-items: center; gap: .65rem; min-height: 2.75rem; padding: .55rem .8rem;
  background: var(--ground); border: 1px solid var(--rule); border-radius: var(--radius);
  color: var(--ink); text-decoration: none; transition: transform 160ms var(--ease-out), border-color 150ms ease;
}
.md-typeset .route__end--none { visibility: hidden; }
.md-typeset .route__end--next { flex-direction: row-reverse; text-align: right; }
.md-typeset .route__end:active { transform: scale(.98); }
@media (hover: hover) and (pointer: fine) {
  .md-typeset .route__end:hover { border-color: var(--line); text-decoration: none; }
}
.md-typeset .route__end .roundel { width: 2.3rem; height: 2.3rem; box-shadow: inset 0 0 0 .22rem var(--c); }
.md-typeset .route__end .roundel__line { font-size: .5rem; }
.md-typeset .route__end .roundel__num { font-size: .8rem; }
.md-typeset .route__end-text { display: grid; min-width: 0; }
.md-typeset .route__end-dir { font-size: .7rem; font-weight: 700; color: var(--ink-3); line-height: 1.3; }
.md-typeset .route__end-title { font-family: var(--font-sign); font-weight: 700; font-size: .82rem; line-height: 1.35; }
/* goals heading, sentence case, no eyebrow */
.md-typeset .goals-title { font-family: var(--font-sign); font-size: 1.05rem; font-weight: 700; color: var(--ink); margin: 0 0 .2rem; }
/* Japanese is the largest text in rows and tables */
.md-typeset .dl__say { font-size: 1.15em; }
.md-typeset td > span[lang="ja"] { font-size: 1.14em; }
/* stop Material's stock callout colours from winning */
.md-typeset :is(.admonition, details):is(.note, .info, .tip, .success, .warning, .abstract, .question, .example, .quote, .danger, .failure, .bug) > :is(.admonition-title, summary) {
  background-color: transparent; border: 0;
}
.md-typeset :is(.admonition, details):is(.note, .info, .tip, .success, .warning, .abstract, .question, .example, .quote, .danger, .failure, .bug) > :is(.admonition-title, summary)::before {
  background-color: var(--a);
}
.md-typeset :is(.admonition, details):is(.note, .info, .tip, .success, .warning, .abstract, .question, .example, .quote, .danger, .failure, .bug) > summary::after {
  color: var(--ink-3);
}
.md-typeset details[open]:is(.note, .info, .tip, .success, .warning) > summary { border-bottom: 1px solid var(--rule); }
/* footer titles may wrap instead of truncating */
.md-footer__title .md-ellipsis { white-space: normal; }
@media screen and (max-width: 44.9375em) {
  .md-footer__link--prev { flex: 1 1 0; }
  .md-typeset .station { padding: .95rem .9rem .85rem; margin: 0 -.1rem 1.3rem; }
  /* phone route strip: scrollable, full-size tap targets, station numbers shown */
  [dir] .md-typeset ol.route__track { overflow-x: auto; scroll-snap-type: x proximity; justify-content: flex-start; scrollbar-width: none; padding-bottom: .1rem; }
  .md-typeset .route__track::before { display: none; }
  [dir] .md-typeset ol.route__track > li.route__stop { flex: 0 0 2.75rem; scroll-snap-align: center; }
  .md-typeset .route__stop::before {
    content: ""; position: absolute; left: 0; right: 0; top: 1.05rem; height: 4px; background: var(--line); z-index: -1;
  }
  .md-typeset .route__stop:first-child::before { left: 50%; }
  .md-typeset .route__stop:last-child::before { right: 50%; }
  .md-typeset .route__stop a { max-width: none; width: 2.75rem; height: 3.1rem; grid-template-rows: 2.1rem 1fr; place-items: center; }
  .md-typeset .route__label { display: block; font-family: var(--font-sign); font-size: .7rem; font-weight: 700; color: var(--ink-3); line-height: 1; }
  .md-typeset .route__stop.is-current .route__label { color: var(--ink); }
  .md-typeset .route__ends { grid-template-columns: 1fr 1fr; gap: .45rem; }
  .md-typeset .route__end { padding: .5rem .6rem; gap: .45rem; }
  .md-typeset .route__end .roundel { display: none; }
}
.md-typeset .station h1 .headerlink { display: none; }
.md-typeset .station h1 { margin: 0; }
@media screen and (max-width: 44.9375em) {
  .md-typeset h1 .t-jp { font-size: clamp(1.5rem, 1.05rem + 2.8vw, 2rem); }
}

/* ---------- 20. Lines for N4, N3, N2 and N1 ---------- */
html[data-line="n4"] { --line: var(--line-n4); --line-ink: #146C3B; --line-wash: #E6F4EC; }
html[data-line="n3"] { --line: var(--line-n3); --line-ink: #155A9E; --line-wash: #E5EFFA; }
html[data-line="n2"] { --line: var(--line-n2); --line-ink: #A8213F; --line-wash: #FBE9ED; }
html[data-line="n1"] { --line: var(--line-n1); --line-ink: #2B303B; --line-wash: #ECEEF2; }
.roundel[data-line="n4"], .roundel[data-line="n4-hub"] { --c: var(--line-n4); }
.roundel[data-line="n3"], .roundel[data-line="n3-hub"] { --c: var(--line-n3); }
.roundel[data-line="n2"], .roundel[data-line="n2-hub"] { --c: var(--line-n2); }
.roundel[data-line="n1"], .roundel[data-line="n1-hub"] { --c: var(--line-n1); }
.md-typeset .line[data-line="n4"] { --c: var(--line-n4); }
.md-typeset .line[data-line="n3"] { --c: var(--line-n3); }
.md-typeset .line[data-line="n2"] { --c: var(--line-n2); }
.md-typeset .line[data-line="n1"] { --c: var(--line-n1); }
.md-typeset .line__badge[data-line="n4"] { background: #146C3B; }
.md-typeset .line__badge[data-line="n3"] { background: #155A9E; }
.md-typeset .line__badge[data-line="n2"] { background: #A8213F; }
.md-typeset .line__badge[data-line="n1"] { background: #3B4252; }
/* appendices hang off each line as small facility signs */
[dir] .md-typeset ul.line__facs { list-style: none; margin: .6rem 0 .3rem; padding: .6rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; border-top: 1px solid var(--rule); }
[dir] .md-typeset ul.line__facs > li { margin: 0; }
.md-typeset .line__facs a {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 2.75rem; padding: .3rem .75rem .3rem .35rem;
  border: 1px solid var(--rule); border-radius: 999px; color: var(--ink); text-decoration: none; font-size: .78rem; font-weight: 500;
}
@media (hover: hover) and (pointer: fine) { .md-typeset .line__facs a:hover { border-color: var(--c); text-decoration: none; } }
.md-typeset .line__fac-code {
  display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--tint); color: var(--ink-2); font-family: var(--font-sign); font-weight: 900; font-size: .72rem;
}
