:root {
  color-scheme: light;
  --paper: #f8f5ed;
  --card: #fffdf7;
  --ink: #272922;
  --soft: #645f51;
  --rule: #e5dcc9;
  --red: #a33b2e;
  --red-dark: #8a3026;
  --red-pale: #f8e9df;
  --olive: #4a6146;
  --serif: "Songti SC", "Noto Serif CJK SC", "SimSun", serif;
  --japanese: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif CJK JP", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans", "Microsoft YaHei", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 280px;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
}

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

button:disabled { cursor: default; opacity: .45; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--red); outline-offset: 4px; }
canvas { display: block; }
h1, h2, h3, p { margin: 0; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--rule);
}

.topbar-inner {
  width: min(100% - 64px, 1272px);
  min-height: 62px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.brand {
  color:inherit;
  text-decoration:none;
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 750;
  font-size: 14px;
  letter-spacing: .09em;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  background: var(--red);
  color: #fff9ee;
  border-radius: 6px;
  font: 700 20px/1 var(--japanese);
}

.modes { display: flex; align-self: stretch; gap: 24px; }

.mode {
  padding: 0 9px;
  position: relative;
  background: transparent;
  color: var(--soft);
  white-space: nowrap;
  font-weight: 600;
}

.mode::after {
  content: "";
  position: absolute;
  height: 2px;
  inset: auto 8px -1px;
  background: transparent;
}

.mode:hover, .mode[aria-pressed="true"] { color: var(--red); }
.mode[aria-pressed="true"]::after { background: var(--red); }

.completion { justify-self: end; width: 126px; }
.completion-label { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--soft); }
#progress-text { font-weight: 750; font-variant-numeric: tabular-nums; }

progress {
  width: 100%;
  height: 5px;
  display: block;
  margin-top: 5px;
  border: 0;
  border-radius: 99px;
  appearance: none;
  background: var(--rule);
  color: var(--red);
}

progress::-webkit-progress-bar { border-radius: 99px; background: var(--rule); }
progress::-webkit-progress-value { border-radius: 99px; background: var(--red); }
progress::-moz-progress-bar { border-radius: 99px; background: var(--red); }

.page { width: min(100% - 64px, 1272px); margin-inline: auto; }

.page-heading {
  padding: 17px 0 10px;
}

h1 {
  font: 800 clamp(33px, 4.3vw, 51px)/1.14 var(--serif);
  letter-spacing: -.035em;
}

h1 span { color: var(--red-dark); }
.page-heading p { color: var(--soft); margin-top: 9px; font-size: 14px; }

.map-counts {
  padding: 0 0 3px;
  color: var(--soft);
  font-size: 13px;
  white-space: nowrap;
  letter-spacing: .025em;
}

.count-number { color: var(--ink); font-weight: 750; font-variant-numeric: tabular-nums; }

.learning-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(342px, 1fr);
  align-items: start;
  gap: 22px;
}

.panel {
  border: 1px solid var(--rule);
  background: var(--card);
  border-radius: 13px;
  box-shadow: 0 3px 12px #4c382007;
}

.map-panel { overflow: hidden; }

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 17px 10px;
}

.panel-heading h2 { font-size: 17px; font-weight: 750; }
.map-breadcrumb {
  display: flex;
  align-items: center;
  min-block-size: 28px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  margin-top: 2px;
  color: var(--soft);
  font-size: 12px;
  line-height: 1.4;
}
.crumb { background: transparent; padding: 3px 0; color: var(--red-dark); }
.crumb:hover { text-decoration: underline; text-underline-offset: 2px; }
.map-breadcrumb > :not(:first-child)::before { content: "›"; display: inline-block; margin: 0 5px; color: #8a8171; }
.crumb-current { font-weight: 650; }
.map-breadcrumb::-webkit-scrollbar { display: none; }
.map-breadcrumb > * { flex: none; white-space: nowrap; }
.map-breadcrumb .crumb { min-block-size: 28px; }
.map-breadcrumb .crumb:focus-visible { outline-offset: -2px; }
.zoom-level {
  padding: 4px 10px;
  border-radius: 16px;
  background: #eee8d9;
  color: var(--soft);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.map-surface {
  position: relative;
  height: clamp(225px, 54svh, 468px);
  background: #f1ebda;
  border-block: 1px solid #ddcfb4;
  overflow: hidden;
  isolation: isolate;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
.map-surface.is-dragging, .map-surface.is-dragging .station { cursor: grabbing; }
.map-surface:focus-visible { outline: 2px solid var(--red); outline-offset: -3px; }
.map-canvas, .station-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.station-layer { pointer-events: none; }

.map-tools { position: absolute; z-index: 4; right: 12px; bottom: 12px; display: flex; gap: 7px; }
.zoom-controls { display: flex; }
.zoom-button, .locate-word {
  width: 36px;
  height: 36px;
  padding: 0;
  background: #fffbf1;
  color: var(--red-dark);
  border: 1px solid #d2c3a8;
  font-size: 21px;
  line-height: 1;
  box-shadow: 0 1px 3px #4c382021;
}
.locate-word { border-radius: 7px; font-size: 23px; }
.zoom-button:first-child { border-radius: 7px 0 0 7px; }
.zoom-button:last-child { border-radius: 0 7px 7px 0; border-left: 0; }
.zoom-button:not(:disabled):hover, .locate-word:hover { background: #f8e8d9; }
.zoom-button:disabled { color: #8d8270; opacity: 1; }

.compass {
  position: absolute;
  z-index: 1;
  top: 14px;
  right: 15px;
  display: grid;
  justify-items: center;
  gap: 3px;
  color: #655441;
  font: bold 11px/1 var(--serif);
  pointer-events: none;
}
.compass i {
  width: 28px;
  height: 28px;
  background: conic-gradient(#94816a 0 45deg, #ba9b79 45deg 90deg, #7b6953 90deg 180deg, #b7a185 180deg 270deg, #786450 270deg);
  clip-path: polygon(50% 0, 58% 42%, 100% 50%, 58% 58%, 50% 100%, 42% 58%, 0 50%, 42% 42%);
}
.map-legend {
  position: absolute;
  bottom: 13px;
  left: 13px;
  z-index: 3;
  max-width: calc(100% - 140px);
  padding: 4px 6px;
  border-radius: 4px;
  background: #fff9eddd;
  color: #655441;
  font-size: 10px;
  pointer-events: none;
}
.detail-family i { width: 6px; height: 6px; border-radius: 50%; background: var(--red); }

.station {
  position: absolute;
  z-index: 2;
  left: 0;
  top: 0;
  display: grid;
  align-content: center;
  gap: 3px;
  width: 98px;
  min-height: 44px;
  padding: 5px 5px 5px 8px;
  border: 1px solid #a79574;
  border-left: 3px solid var(--station-ink);
  border-radius: 6px;
  background: #fbf5e8;
  box-shadow: 0 2px 5px #59472a25;
  color: #353227;
  text-align: center;
  pointer-events: auto;
  transition: background .16s, border-color .16s, box-shadow .16s;
}
.station[inert] { pointer-events: none; }
.station:hover { background: #fffaf0; border-color: var(--station-ink); }
.station[aria-current] { background: var(--station-ink); color: #fff9ef; border-color: var(--station-ink); box-shadow: 0 3px 0 #3e302a60, 0 5px 12px #3e302a33; }
.station:focus-visible { outline-color: #2b3328; outline-offset: 3px; z-index: 3; }
.station-title { display: block; font: 750 16px/1.15 var(--japanese); letter-spacing: -.025em; overflow-wrap: anywhere; }
.station-gloss { display: block; font-size: 10px; font-weight: 650; line-height: 1.2; }
.station[data-depth="0"] { width: 121px; min-height: 52px; }
.station[data-depth="0"] .station-title { font: 750 15px/1.15 var(--sans); }
.station[data-depth="1"] { width: 103px; }
.station[data-depth="1"] .station-title { font-size: 18px; }
.station[data-depth="2"] .station-title { font-size: 15px; }
.map-surface[data-map-compact] .station[data-depth="0"] { width: 108px; }
.map-surface[data-map-small] .station[data-depth="0"] { width: 102px; }

.station-check {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 17px;
  height: 17px;
  border: 1px solid var(--card);
  border-radius: 50%;
  background: var(--olive);
  color: white;
  font: 11px/15px var(--sans);
}

.route { padding: 14px 18px 17px; }
.route-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 9px; }
.route-heading h3 { font: 800 19px/1.25 var(--japanese); }
.route-meaning { margin-left: 6px; color: var(--soft); font: 600 12px var(--sans); }
.route-count { color: var(--soft); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.route > p { margin: 5px 0 12px; font-size: 12px; color: var(--soft); }

.word-list { display: flex; flex-wrap: wrap; gap: 7px; }

.word-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  justify-content: center;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #f9f5eb;
  font: 700 14px var(--japanese);
  white-space: nowrap;
}

.word-chip:hover { border-color: #c09687; }
.word-chip[aria-pressed="true"] { background: var(--red-pale); border-color: #d5a393; color: var(--red-dark); }
.chip-check { color: var(--olive); font: 750 11px var(--sans); }

.detail-panel {
  --reader-padding: clamp(14px, 1.5vw, 22px);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
#card-reader {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-anchor: none;
  padding: 16px var(--reader-padding);
  scroll-padding-block: 12px;
}
#card-reader:focus-visible { outline: 2px solid var(--red); outline-offset: -3px; }
.detail-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.detail-family { display: inline-flex; align-items: center; gap: 7px; color: var(--red-dark); font-size: 12px; font-weight: 700; }
.word-position { color: var(--soft); font-size: 12px; font-variant-numeric: tabular-nums; }

.word-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px 13px;
  flex-wrap: wrap;
  margin: 10px 0 16px;
}

.word-title { font: 800 clamp(31px, 3.25vw, 44px)/1.21 var(--japanese); letter-spacing: -.045em; }
.word-title .root-part { color: var(--red-dark); }
.reading-line { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 9px; margin-top: 4px; }
.word-reading { color: var(--soft); font-size: 14px; }
.pronunciation {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 3px 8px;
  border: 1px solid #dfc8b1;
  border-radius: 5px;
  background: #f8f0e4;
  color: var(--red-dark);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.pronunciation:hover, .pronunciation[data-playing] { background: var(--red-pale); border-color: #d5a393; }
.speaker-icon { position: relative; display: block; width: 15px; height: 14px; }
.speaker-icon::before {
  content: "";
  position: absolute;
  inset: 1px 6px 1px 0;
  background: currentColor;
  clip-path: polygon(0 34%, 35% 34%, 100% 0, 100% 100%, 35% 66%, 0 66%);
}
.speaker-icon::after {
  content: "";
  position: absolute;
  inset: 2px 1px 2px 8px;
  border-right: 1.5px solid currentColor;
  border-radius: 0 100% 100% 0;
}
.audio-error { margin: -10px 0 10px; color: var(--red-dark); font-size: 12px; }
.word-meaning { color: var(--ink); font-weight: 700; font-size: 14px; align-self: center; max-width: 100%; }

.motion-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.motion-heading h3 { font-size: 13px; font-weight: 750; }

.motion-scene {
  overflow: hidden;
  border: 1px solid #e0d7c5;
  border-radius: 8px;
  background: #f8f5e9;
}
.scene-drawing {
  display: block;
  width: 100%;
  max-height: 200px;
  aspect-ratio: 320 / 142;
  font-family: var(--sans);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.answer-space { padding-top: 11px; }
.example { margin-top: 10px; padding: 9px 10px 8px; border-left: 2px solid #caa78c; background: #f8f3e8; border-radius: 0 5px 5px 0; }
.example h3 { color: #795747; font-size: 11px; margin-bottom: 3px; }
.ja-example { font-size: 16px; line-height: 1.95; color: var(--ink); }
.ja-example ruby { ruby-position: over; }
.ja-example rt { font-size: .5em; color: #857e73; line-height: 1; }
.ja-example mark {
  background: linear-gradient(transparent 55%, #edd6c7 55%);
  background-repeat: no-repeat;
  color: var(--red-dark);
  font-weight: 750;
  white-space: nowrap;
}
.ja-example mark rt { color: #987867; }
@media (prefers-reduced-motion: no-preference) {
  .ja-example mark { animation: example-highlight .35s ease-out both; }
  @keyframes example-highlight {
    from { background-size: 0 100%; }
    to { background-size: 100% 100%; }
  }
}
#translation { margin-top: 3px; color: var(--soft); font-size: 12px; }
.word-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) fit-content(48%) minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 9px var(--reader-padding);
  border-top: 1px solid var(--rule);
  background: var(--card);
}
.word-actions button {
  min-width: 0;
  min-height: 37px;
  border-radius: 6px;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 700;
}
.step { padding: 5px 3px; background: transparent; color: var(--soft); }
.step:not(:disabled):hover { color: var(--red-dark); background: #f8f3e8; }
.step span { margin-inline: 3px; }
.master { padding: 5px 13px; background: var(--red); color: #fff9f0; }
.master:hover { background: var(--red-dark); }
.master[aria-pressed="true"] { background: #e9eee2; color: #3d573a; }
.master[aria-pressed="true"]:hover { background: #dde7d4; }

.noscript { margin: 20px 32px; color: var(--red-dark); }

.sr-only {
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media screen and (min-width: 761px) {
  /* The header takes its natural height, including wrapped navigation in other languages.
     The learning view uses the remaining viewport; the footer follows in document flow. */
  body:has(> .page > #atlas-page:not([hidden])) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100svh;
  }
  .page:has(> #atlas-page:not([hidden])) { flex: 1 0 0; min-height: 0; }
  #atlas-page {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding-bottom: 12px;
  }
  .learning-layout { flex: 1 0 auto; align-items: stretch; }
  .learning-layout #card-reader { contain: size; }
  .map-panel {
    display: grid;
    grid-template: "heading" auto "surface" minmax(280px, 1fr) "directory" auto / minmax(0, 1fr);
  }
  .map-panel .panel-heading { grid-area: heading; }
  .map-panel .map-surface { grid-area: surface; height: auto; }
  .map-panel .city-directory { grid-area: directory; }
}

@media (max-width: 900px) {
  .topbar-inner, .page { width: calc(100% - 38px); }
  .learning-layout { grid-template-columns: minmax(0, 1.2fr) minmax(305px, 1fr); gap: 13px; }
  .route { padding-inline: 13px; }
  .word-chip { padding-inline: 9px; }
}

@media (max-width: 760px) {
  .learning-layout { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .page-heading { padding-block: 12px 8px; }
  .panel-heading { padding-inline: 15px; }
  .word-title { font-size: 36px; }
}

@media (max-width: 495px) {
  .topbar-inner, .page { width: calc(100% - 24px); }
  .topbar-inner { min-height: 57px; }
  .brand { font-size: 11px; gap: 5px; letter-spacing: .055em; }
  .brand-mark { width: 25px; height: 26px; font-size: 15px; }
  .modes { gap: 2px; }
  .mode { font-size: 12px; padding-inline: 5px; }
  .mode::after { inset-inline: 4px; }
  .completion { width: 47px; }
  .completion-label { display: block; text-align: right; font-size: 10px; line-height: 1.3; }
  .completion-label span { display: block; }
  progress { height: 4px; margin-top: 3px; }
  .page-heading { display: block; }
  .page-heading p { margin-top: 6px; font-size: 13px; }
  .map-counts { margin-top: 5px; padding: 0; font-size: 11px; }
  .zoom-button, .locate-word { width: 32px; height: 33px; }
  .station-gloss { font-size: 10px; }
  .compass { right: 10px; top: 10px; }
  .compass i { width: 23px; height: 23px; }
}

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

/* Word cards and atlas index */
.atlas-tools { display: flex; gap: 6px 14px; align-items: center; justify-content: space-between; }
.atlas-tools .map-counts { padding:0; }
.catalog-open, .mobile-current {
  display:inline-flex; align-items:center; justify-content:center; gap:9px; min-height:36px; padding:5px 12px;
  border:1px solid #d8cbb7; border-radius:7px; background:var(--card); color:#594838; font-weight:650;
}
.catalog-open:hover,.mobile-current:hover { border-color:#a88668; background:#fff9ee; }
.search-icon { position:relative; display:inline-block; width:15px; height:15px; color:#79674e; flex:none; }
.search-icon::before { content:""; position:absolute; width:8px; height:8px; border:1.6px solid; border-radius:50%; left:0; top:0; }
.search-icon::after { content:""; position:absolute; width:6px; height:1.6px; background:currentColor; transform:rotate(45deg); left:9px; top:11px; }
.word-heading { margin-bottom:8px; }
.word-pos { display:flex; flex-wrap:wrap; gap:4px; margin:0 0 12px; }
.pos-label { color:#3f6056; background:#eaf0e7; padding:2px 7px; font-weight:600; font-size:12px; border-radius:4px; }
.detail-tools { display:flex; gap:9px; align-items:center; }
.detail-family {color:var(--topic-color,var(--red-dark));}
.detail-family i {background:var(--topic-color,var(--red));}
.bookmark { display:inline-flex;align-items:center;gap:4px;min-height:29px;padding:2px 6px;border-radius:5px;background:transparent;color:#706457;font-size:12px; }
.bookmark span:first-child {font:18px/1 system-ui,sans-serif;}
.bookmark:hover,.bookmark[aria-pressed="true"] {background:#f6edce;color:#805617;}
.other-meaning {color:var(--soft);font-size:12px;margin:-6px 0 10px;}
.other-meaning summary {cursor:pointer;width:fit-content;}
.other-meaning p {padding:4px 0;}
.example h3 {display:flex;gap:8px;align-items:baseline;flex-wrap:wrap;}
#example-role {font-size:11px;color:var(--soft);font-weight:500;}
.sense-area {margin:15px 0 12px;padding:13px 0 0;border-top:1px solid var(--rule);}
.sense-heading {display:flex;align-items:baseline;justify-content:space-between;gap:.75rem;margin-bottom:8px;}
.sense-heading h3 {font-size:15px;}
.sense-heading > span {color:var(--soft);font-size:12px;}
.sense-options {display:flex;flex-wrap:wrap;gap:6px;}
.sense-options button {display:inline-flex;align-items:baseline;gap:6px;max-width:100%;text-align:start;white-space:normal;background:#fffdf7;color:var(--ink);border:1px solid var(--rule);padding:5px 9px;border-radius:6px;font-size:13px;line-height:1.5;}
.sense-options button:hover {border-color:#ba9b7f;}
.sense-options button[aria-pressed="true"] {border-color:#a55b47;background:#f6e9dc;color:#792e22;}
.sense-number {font-size:11px;font-weight:700;font-variant-numeric:tabular-nums;opacity:.8;}
.sense-area .example {padding:10px 12px;}
.usage-line {display:flex;align-items:baseline;flex-wrap:wrap;gap:4px 9px;margin-top:8px;}
.usage-line > span {font-size:12px;color:var(--soft);}
.usage-line strong {font:600 15px/1.6 var(--japanese);}
.word-families {display:flex;flex-wrap:wrap;gap:4px 8px;}
.family-link {padding:3px 0;background:transparent;color:var(--red-dark);font-size:12px;text-decoration:underline;text-underline-offset:3px;}
.word-families:not(:empty) {margin-top:5px;}
.mobile-current {display:none;}
dialog {color:var(--ink);font-family:var(--sans);}
dialog::backdrop {background:#242a2480;}
.catalog {
  width:min(620px,calc(100% - 24px)); max-height:min(82dvh,740px); padding:18px 20px 0;
  border:1px solid #cfbea6; border-radius:14px; box-shadow:0 18px 80px #2921174a;
  background:var(--card); overflow:hidden;
}
.catalog[open] {display:flex;flex-direction:column;}
.catalog-header {display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;}
.catalog-header h2 {font:750 25px var(--serif);}
.catalog-header button,.sheet-bar button {color:var(--red-dark);border-radius:5px;background:transparent;font-size:13px;padding:6px 8px;}
.catalog-header button:hover,.sheet-bar button:hover {background:var(--red-pale);}
.catalog-search {display:flex;align-items:center;gap:8px;border:1px solid #bdab91;border-radius:7px;background:white;padding:0 10px;}
.catalog-search:focus-within {outline:2px solid #9e7d60;outline-offset:1px;}
.catalog-search input {width:100%;min-width:0;height:39px;border:0;outline:0;font:16px var(--sans);background:transparent;color:var(--ink);}
.catalog-count {font-size:12px;margin:1px 0 7px;color:var(--soft);}
.catalog-results {overflow-y:auto;overscroll-behavior:contain;min-height:0;scrollbar-gutter:stable;}
.catalog-word {display:grid;grid-template-columns:1fr 1fr;gap:2px 12px;text-align:left;width:100%;border-top:1px solid var(--rule);background:transparent;padding:8px 6px 9px 10px;position:relative;}
.catalog-more { display:block; width:100%; min-height:42px; border-top:1px solid var(--rule); background:#f5f0e4; color:var(--ink); font-weight:650; }
.catalog-word:hover,.catalog-word:focus-visible {background:#f5f0e4;}
.catalog-word strong {font:700 17px var(--japanese);}
.catalog-word span {align-self:center;font-size:14px;}
.catalog-word small {font-size:12px;color:var(--soft);}
.catalog-word::before {content:"";position:absolute;left:0;top:12px;width:3px;height:18px;border-radius:4px;background:var(--region-color);}
.catalog-family button {background:#efe7d7;padding:2px 9px;color:#615338;border-radius:4px;margin:2px 0;font-size:13px;}
.mobile-sheet {border:0;padding:0;border-radius:15px 15px 0 0;background:var(--card);max-width:none;max-height:none;width:100%;margin:auto 0 0;}
@media (min-width:761px) { .mobile-sheet {display:none;} }
@media (max-width:760px) {
  .modes {gap:5px;}
  .mode {padding-inline:7px;}
  .mobile-current {display:inline-flex;margin-top:10px;font-size:13px;}
  #atlas-page #word-card {display:none;}
  .mobile-sheet[open] {display:flex;flex-direction:column;height:min(72dvh,670px);transition:height .16s ease-out;}
  .mobile-sheet[open][data-expanded] {height:94dvh;}
  .sheet-bar {display:flex;align-items:center;justify-content:space-between;gap:6px;position:relative;padding:5px 10px 2px;touch-action:none;border-bottom:1px solid var(--rule);flex:none;}
  .sheet-grip {position:absolute;left:calc(50% - 23px);top:12px;width:46px;height:4px;background:#c8baaa;border-radius:6px;}
  .sheet-home {display:grid;place-items:center;width:40px;min-height:40px;}
  #sheet-expand {margin-inline-end:auto;}
  #sheet-content {display:flex; flex-direction:column; flex:1; min-height:0; padding-bottom:env(safe-area-inset-bottom);}
  #sheet-content .detail-panel {flex:1; border:0; border-radius:0; box-shadow:none;}
  #sheet-content #card-reader {overscroll-behavior:contain; padding-top:10px;}
}
@media (max-width:540px) {
  .page-heading {display:block;}
  .atlas-tools .map-counts {margin:0;}
  .catalog-open {min-height:32px;font-size:13px;}
  .modes {gap:2px;}
  .mode {padding-inline:5px;font-size:12px;}
  .catalog {padding:13px 12px 0;}
}
@media (max-width:359px) {
  .brand {font-size:0;gap:0;}
  .topbar-inner {grid-template-columns:auto 1fr auto;}
  .modes {justify-self:center;}
}

.card-links {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 12px;
}
.card-links :is(button,a) {
  padding: 5px 0;
  background: transparent;
  color: var(--red-dark);
  font-size: 13px;
  font-weight: 650;
  text-align: start;
  text-underline-offset: 4px;
}
.card-links :is(button,a):hover { text-decoration: underline; }
.book-header {
  max-width: 1080px;
  margin: clamp(22px, 3.4vw, 40px) auto 20px;
}
.book-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.book-heading h1 { font: 700 clamp(28px, 3.3vw, 42px)/1.25 var(--serif); }
.book-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 18px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--rule);
}
.book-nav button {
  min-height: 38px;
  padding: 5px 14px;
  border-radius: 6px;
  background: transparent;
  color: var(--soft);
  font-size: 14px;
  font-weight: 650;
}
.book-nav button[aria-pressed="true"] { color: var(--red-dark); background: var(--red-pale); }
.book-nav button:hover { color: var(--red-dark); }
.book-contrast-misses { margin-top: 16px; }
.book-contrast-misses p { margin: 5px 0 12px; overflow-wrap: anywhere; }
#book-header[hidden] + #study-page:not([hidden]) { margin-top: clamp(20px, 3vw, 36px); }

@media (max-width: 590px) {
  .topbar-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand progress" "modes modes";
    row-gap: 0;
    padding-top: 8px;
  }
  .brand { grid-area: brand; font-size: 12px; }
  .brand-mark { width: 24px; height: 25px; font-size: 15px; }
  .completion { grid-area: progress; width: 88px; }
  .completion-label { display: flex; align-items: baseline; font-size: 10px; }
  .topbar-inner .modes { grid-area: modes; width: 100%; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 0; }
  .modes .mode { min-height: 44px; padding: 4px 0; font-size: 13px; }
  .mode::after { inset-inline: 12%; }
  .book-nav button { min-height: 42px; }
  .book-header { margin-bottom: 14px; }
}


