: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 {
  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-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 button {
  padding: 5px 0;
  background: transparent;
  color: var(--red-dark);
  font-size: 13px;
  font-weight: 650;
  text-align: start;
  text-underline-offset: 4px;
}
.card-links button: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; }
}



.map-panel .panel-heading { padding: 13px 17px 12px; }
.map-panel .zoom-level { color: #4e6252; background: #e7ecdc; }
.map-surface { background: #f3eddb; }
.map-surface .station {
  border: none;
  padding: 3px 5px;
  background: transparent;
  color: #393d32;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}
.map-surface .station[data-depth="0"],
.map-surface[data-map-compact] .station[data-depth="0"],
.map-surface[data-map-small] .station[data-depth="0"] {
  width: 112px;
  min-height: 40px;
  border: 1px solid #ab9f817b;
  border-radius: 17px 17px 13px 13px / 7px;
  background: #fff9e9f5;
  box-shadow: inset 0 -2px #e0d4b46b, 0 1px 3px #55472c30;
  gap: 2px;
}
.map-surface[data-map-compact] .station[data-depth="0"] { width: 99px; }
.map-surface[data-map-small] .station[data-depth="0"] { width: 86px; }
.map-surface .station[data-depth="0"] .station-title {
  color: var(--station-ink);
  font: 800 15px/1.18 var(--serif);
  letter-spacing: .045em;
}
.map-surface .station[data-depth="0"] .station-gloss { font-size: 10px; }
.map-surface .station[data-depth="1"] {
  width: 102px;
  min-height: 43px;
  padding: 4px 6px;
  gap: 2px;
  border: 1px solid #a59c82;
  border-bottom: 2px solid var(--station-ink);
  background: #fffaeaf5;
  border-radius: 10px 3px;
  box-shadow: 0 1px 3px #554a3420;
}
.map-surface .station[data-depth="1"] .station-title {
  color: #43453a;
  font: 680 12px/1.18 var(--sans);
  letter-spacing: 0;
}
.map-surface .station[data-depth="1"] .station-gloss { color: var(--station-ink); font-size: 9px; }
.map-surface .station[data-depth="2"] {
  width: 101px;
  min-height: 40px;
  gap: 2px;
  border-radius: 4px;
  background: #fffaf0ed;
  border: 1px solid #c1b49a;
  box-shadow: 0 1px 2px #594a3120;
}
.map-surface[data-narrow-street] .station[data-depth="2"] { width: 82px; }
.map-surface .station[data-depth="2"] .station-title { font: 750 15px/1.18 var(--japanese); }
.map-surface .station-gloss { color: #635e4c; font-weight: 550; line-height: 1.2; }
.map-surface .station:not([aria-current]):hover {
  color: #383e33;
  border-color: var(--station-ink);
  background: #fffdf6;
  box-shadow: 0 2px 6px #66573a40;
}
.map-surface .station[data-depth][aria-current] { border-color: var(--station-ink); box-shadow: 0 0 0 1px var(--station-ink), 0 2px 5px #5e523634; }
.map-surface .station[data-depth="2"][aria-current] { background: var(--station-ink); }
.map-surface .station[data-depth="2"][aria-current] :is(.station-title,.station-gloss) { color: #fffbee; }
.map-surface .station:focus-visible { outline: 2px solid #293e35; outline-offset: 3px; }
.map-surface .compass { color: #5b6455; }
.map-surface .compass i {
  background: conic-gradient(#405e57 0 45deg,#869589 45deg 90deg,#f5edda 90deg 180deg,#a39c87 180deg 270deg,#596f64 270deg);
  filter: drop-shadow(0 1px 1px #65563644);
}
.map-surface .map-legend { color: #5e604f; padding: 4px 7px; border: 1px solid #cfc4aabf; background: #fff9e8eb; }
.map-surface .locate-word, .map-surface .zoom-button {
  background: #fffaf0; color: #425347; border-color: #bdb69e; box-shadow: 0 2px 4px #69573624;
}
.map-surface .locate-word:not(:disabled):hover, .map-surface .zoom-button:not(:disabled):hover { background: #f2e8d6; }
.map-surface .zoom-button:disabled { color: #a09a88; }
.city-directory { border-bottom: 1px solid #e0d7c2; background: #faf7ed; }
:root[data-theme="city"] .city-directory { display:none; }
.city-directory summary {
  align-items: center; display: flex; justify-content: space-between;
  color: #525b49; padding: 10px 17px; font-size: 12px; font-weight: 650; cursor: pointer; list-style: none;
}
.city-directory summary::-webkit-details-marker { display: none; }
.directory-chevron { font-size: 16px; font-weight: 500; line-height: 1; }
.city-directory[open] .directory-chevron { transform: rotate(180deg); }
.directory-links { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 15px 12px; }
.directory-links button {
  padding: 5px 9px; border: 1px solid #d8ceba; background: #fffdf4; color: #536048; border-radius: 5px;
  font-size: 12px; line-height: 1.4;
}
.directory-links button:hover { border-color: #7f8b70; background: #f1f1e3; }
@media (pointer: coarse) {
  .map-surface .zoom-button, .map-surface .locate-word { width: 40px; height: 40px; }
  .directory-links button { min-height: 39px; }
}
.map-surface[data-portrait-city] .compass { transform: rotate(90deg); }
.map-surface[data-portrait-city] .compass span { transform: rotate(-90deg); }

/* Keep the symbol and label in the same keyboard and touch target. */
.map-surface .station[data-depth] {
  display: grid;
  grid-template-columns: 29px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  align-items: center;
  justify-items: start;
  column-gap: 5px;
  row-gap: 2px;
  min-height: 46px;
  padding: 5px 6px;
  text-align: left;
  border-radius: 8px;
}
.map-surface .station[hidden] { display: none; }
.map-surface .station[data-depth="0"] { min-height: 51px; }
.map-surface .station[data-depth="0"] .station-title { font-size: 13px; letter-spacing: 0; }
.map-surface .station-title, .map-surface .station-gloss { grid-column: 2; min-width: 0; }
.map-surface .station-gloss { overflow-wrap: anywhere; }
.map-surface .meaning-icon {
  grid-area: 1 / 1 / 3 / 2;
  align-self: center;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 29px;
  height: 30px;
  border-radius: 9px;
  background: #f0e9d8;
  background: color-mix(in srgb, var(--station-ink) 13%, #fff9e9);
  font: 21px/1 "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif;
  letter-spacing: -1px;
}
.map-surface .meaning-icon small {
  position: absolute;
  right: -1px;
  bottom: -2px;
  min-width: 13px;
  height: 13px;
  padding: 0 2px;
  border: 1px solid #fff9ed;
  border-radius: 7px;
  background: var(--station-ink);
  color: white;
  font: 700 9px/11px var(--sans);
  text-align: center;
  letter-spacing: 0;
}
.map-surface .station[data-depth="2"] { min-height: 48px; }
.map-surface .station[data-depth="2"] .station-title { font-size: 14px; }
.map-surface .station[data-depth="2"]:is([aria-current],:focus-visible) .meaning-icon { background: #fff5df; }
.map-surface[data-map-small] .station[data-depth="0"],
.map-surface[data-narrow-street] .station[data-depth="2"] {
  grid-template-columns: 23px minmax(0,1fr);
  padding: 4px;
  column-gap: 4px;
}
.map-surface[data-map-small] .station[data-depth="0"] .meaning-icon,
.map-surface[data-narrow-street] .station[data-depth="2"] .meaning-icon {
  width: 23px;
  height: 26px;
  font-size: 17px;
}

.map-surface .meaning-icon.meaning-icon-pair { font-size: 14px; letter-spacing: -2px; }

/* A vocabulary marker reads vertically like a map pin. The complete width
   remains available for the Japanese spelling and its reading below. */
.map-surface .station[data-depth="2"],
.map-surface .station[data-depth="2"]:is([aria-current],:hover),
.map-surface[data-narrow-street] .station[data-depth="2"] {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 1px;
  min-height: 65px;
  padding: 0 3px 3px;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
  isolation: isolate;
}
.map-surface .station[data-depth="2"][hidden] { display: none; }
.map-surface .station[data-depth="2"]::before {
  content: "";
  position: absolute;
  inset: 25px 0 0;
  z-index: -1;
  border-radius: 8px;
  border: 1px solid #baac94;
  background: #fffaf0f7;
  box-shadow: 0 2px 4px #58472b20;
}
.map-surface .station[data-depth="2"][aria-current]::before {
  background: var(--station-ink);
  border-color: var(--station-ink);
}
.map-surface .station[data-depth="2"]:hover::before { border-color: var(--station-ink); }
.map-surface .station[data-depth="2"] .meaning-icon {
  align-self: center;
  width: 33px;
  height: 32px;
  border: 1px solid #bea98f;
  border-radius: 50%;
  background: #fff7e8;
  box-shadow: 0 1px 3px #58472b22;
  font-size: 23px;
}
.map-surface .station[data-depth="2"] .meaning-icon-pair { width: 39px; font-size: 16px; }
.map-surface .station[data-depth="2"] .meaning-icon small { right: -3px; bottom: -1px; }
.map-surface .station[data-depth="2"] .station-title,
.map-surface .station[data-depth="2"] .station-gloss { width: 100%; }

#overview-map { position: absolute; inset: 0; }
.map-panel .panel-heading > div { min-width: 0; }
.map-panel .map-breadcrumb { row-gap: 4px; }
.map-panel .zoom-level { flex: none; }
.map-panel .task-progress { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:8px; }
.map-panel .task-progress .mobile-current { margin:0; }
@media (min-width:761px) {
  .map-panel .task-progress:has(.route-count[hidden]) { display:none; }
  /* Keep the canvas the same size when entering a task or opening its directory. */
  .map-panel .route.task-progress {
    grid-area:surface;
    align-self:end;
    justify-self:start;
    z-index:2;
    margin:0 0 12px 12px;
    padding:4px 8px;
    border:1px solid var(--rule);
    border-radius:5px;
    background:var(--card);
    pointer-events:none;
  }
  .city-directory { position:relative; z-index:3; }
  .city-directory[open] .directory-links {
    position:absolute;
    inset:auto 0 100%;
    max-height:min(30vh, 15rem);
    padding-top:12px;
    background:inherit;
    border-block:1px solid var(--rule);
  }
}
.directory-links { max-height: min(45vh, 24rem); overflow-y: auto; overscroll-behavior: contain; }
.directory-links button[aria-current="location"] { font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }

.map-surface { overflow: clip; }
#map-geography, #atlas-detail, #atlas-names {
  position:absolute; inset:0; width:100%; height:100%; pointer-events:none;
}
#map-geography { overflow:hidden; isolation:isolate; }
#atlas-detail { z-index:2; }
#atlas-names { z-index:3; }
#overview-map[aria-hidden="true"] { pointer-events:none; }
#overview-map[aria-hidden="true"] .compass { visibility:hidden; }
#overview-map [data-station] { opacity:var(--topic-visibility,1) !important; }
.map-surface[data-map-theme="city"][data-map-compact] #overview-map .station {
  grid-template: "title title" auto "icon count" auto / auto auto;
  justify-content:center; align-content:center; column-gap:3px; min-height:43px; text-align:center;
}
.map-surface[data-map-theme="city"][data-map-compact] #overview-map .station-title { grid-area:title; }
.map-surface[data-map-theme="city"][data-map-compact] #overview-map .station-gloss { grid-area:count; }
.map-surface[data-map-theme="city"][data-map-compact] #overview-map .meaning-icon {
  grid-area:icon; justify-self:end; width:16px; height:16px; font-size:14px; background:transparent;
}
#atlas-names .atlas-place-name {
  position:absolute; left:0; top:0; width:max-content; box-sizing:border-box;
  display:flex; flex-direction:column; align-items:center; text-align:center; pointer-events:none;
  padding:2px 3px; gap:2px; color:#352e24; line-height:1.18; text-wrap:balance;
  overflow-wrap:anywhere; text-shadow:0 1px 2px #fff8dc,1px 0 2px #fff8dc,-1px 0 2px #fff8dc;
}
.atlas-place-name b { font-size:var(--place-size); font-weight:750; }
.atlas-place-name small { font-size:11px; font-weight:550; line-height:1.22; overflow:hidden; }
.atlas-place-name.sense b { font-family:var(--jp-serif,var(--serif,serif)); }
[data-map-theme="space"] #atlas-names .atlas-place-name {
  color:#f0f3ff; text-shadow:0 1px 3px #020912,1px 0 3px #061122,-1px 0 3px #061122;
}
[data-map-theme="space"] .atlas-place-name small { color:#cbdae9; }
/* Buttons keep their generous hit areas. Pointer and keyboard feedback
   follow the projected label as it scales with the map. */
#semantic-map.semantic-camera .semantic-pin > * { visibility:hidden; }
#semantic-map.semantic-camera .semantic-pin:is(:hover,.is-hovered,[aria-current],:focus-visible) {
  border-color:transparent; background:transparent; outline:none;
}
#overview-map .compass { pointer-events:none; }

/* The warm paper shows through the geography. Landmarks and word icons live
   on a separate layer and keep their original contrast at every zoom level. */
[data-map-theme="city"] #map-geography { background:#fffaf0; }
[data-map-theme="city"] #map-canvas { opacity:.58; }
[data-map-theme="city"] #atlas-names .atlas-place-name {
  background:#fffaf0e6;
  border-radius:5px;
  color:#332b24;
  text-shadow:none;
  box-shadow:0 1px 2px #6e58391c;
}
[data-map-theme="city"] #atlas-names .atlas-place-name.sense {
  background:#fffdf7f5;
  box-shadow:0 0 0 1px #a78e676b, 0 2px 4px #5e493322;
}
[data-map-theme="city"] #atlas-names .atlas-place-name small { color:#534b40; }
[data-map-theme="city"] #atlas-names .atlas-place-name.current {
  box-shadow:0 0 0 1.5px #996142, 0 2px 4px #5e493322;
}
[data-map-theme="city"] #atlas-names .atlas-place-name.hovered { background:#ffedce; }
[data-map-theme="space"] #atlas-names .atlas-place-name:is(.hovered,.current) {
  background:#101e32e8; border-radius:5px; box-shadow:0 0 0 1px #87b7d6;
}
#atlas-names .atlas-place-name.keyboard-focus { outline:2px solid currentColor; outline-offset:2px; }
@media (forced-colors:active) {
  #semantic-map.semantic-camera .semantic-pin { forced-color-adjust:none; }
  #atlas-names .atlas-place-name.keyboard-focus { outline-color:Highlight; }
}

.study-root {
  width: min(100%, 1080px);
  margin: 0 auto 32px;
  color: var(--ink);
}
.study-root .study-heading { margin: 8px 0 22px; }
.study-root h2 { font: 700 clamp(25px, 3vw, 37px)/1.25 var(--serif); }
.study-root h3 { font-size: 18px; line-height: 1.45; }
.study-heading p, .study-help, .study-caption, .study-translation { color: var(--soft); }
.study-heading p { margin-top: 7px; }
.study-caption { font-size: 13px; line-height: 1.6; }
.study-help { font-size: 15px; line-height: 1.7; }
.study-panel {
  padding: clamp(17px, 3vw, 30px);
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 2px 8px #4b463009;
}
.study-home-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(265px, .86fr); gap: 18px; }
.study-metrics { display: flex; flex-wrap: wrap; gap: 16px 28px; margin: 21px 0; }
.study-metric { display: flex; flex-direction: column; gap: 1px; }
.study-metric strong { color: var(--red-dark); font: 700 36px/1.22 var(--serif); font-variant-numeric: tabular-nums; }
.study-metric span { color: var(--soft); font-size: 13px; }
.study-btn { min-height: 40px; padding: 8px 15px; border: 1px solid #cfc3af; border-radius: 7px; color: var(--ink); background: #fffdf8; font-weight: 620; line-height: 1.4; }
.study-btn:not(:disabled):hover { border-color: var(--red); background: #faf0e6; color: var(--red-dark); }
.study-btn.primary,.study-btn.study-play { border-color: var(--red-dark); background: var(--red-dark); color: white; }
.study-btn.primary:not(:disabled):hover,.study-btn.study-play:not(:disabled):hover { background: #6f281f; color: white; }
.study-btn.subtle { min-height: 34px; padding: 5px 6px; border-color: transparent; background: transparent; color: var(--red-dark); font-size: 13px; }
.study-daily > .study-btn { margin-top: 17px; }
.study-settings-fields, .study-filters { display:flex;align-items:end;flex-wrap:wrap;gap:12px; }
.study-settings-fields { margin: 16px 0 11px; }
.study-field { display:grid; gap:5px; color: var(--soft); font-size: 13px; }
.study-root :is(input:not([type=checkbox]):not([type=file]),select) {
  max-width:100%; min-width:0; min-height:40px; padding:7px 10px;
  font: inherit; font-size: 15px; color:var(--ink); border:1px solid #cabfa9; border-radius:6px; background:#fffcf4;
}
.study-root input[type=number] { width: 108px; }
.study-root input:focus-visible,.study-root select:focus-visible,.study-root summary:focus-visible { outline:2px solid var(--red);outline-offset:2px; }
.study-toggle { display:flex;align-items:center;gap:6px;font-size:13px;color:var(--soft); }
.study-toggle input { accent-color:var(--red-dark); }
.study-toolbar,.study-book-tools,.study-bartabs,.study-entry-title,.study-meta { display:flex;align-items:center;justify-content:space-between;gap:12px; }
.study-toolbar,.study-bartabs { margin: 6px 0 16px; }
.study-practice { max-width: 740px; margin: 0 auto; display: grid; gap: 15px; justify-items: start; }
.study-practice .study-meta,.study-practice .study-progress,.study-practice .study-options,.study-practice .study-hints,.study-practice .study-example,.study-practice .study-explain { width: 100%; }
.study-meta span { color: var(--soft); font-weight: 650; }
.study-meta span:first-child { color: var(--red-dark); }
.study-root .study-progress { height:5px;accent-color:var(--red-dark); }
.study-instruction { margin-top:5px; }
.study-root .study-prompt-word { font: 650 clamp(31px,5vw,47px)/1.45 var(--japanese); color:var(--ink); word-break:break-word; }
.study-kana { display:flex;flex-wrap:wrap;gap:9px; }
.study-kana input { width:min(290px,100%); }
.study-options { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px; }
.study-options .option { padding:12px 15px; text-align:left; min-height:46px; }
.study-options .option[lang=ja] { font: 600 20px/1.45 var(--japanese); }
.study-root .study-sentence { padding: 7px 0; font: 500 clamp(17px, 2.1vw, 22px)/2.15 var(--japanese); overflow-wrap:anywhere; }
.study-root .study-sentence rt { color:#978d7d;font-size:.44em;font-weight:400; }
.study-root .study-sentence mark { background:#f6e3d7;color:#8a3928;border-radius:3px;padding:1px 2px; }
.study-gap { display:inline-block;min-width:3.4em;border-bottom:2px solid var(--red-dark);line-height:1; }
.study-hints { border-top:1px solid var(--rule); padding-top:9px; }
.study-hint-figure { margin:0; }
.study-hint-figure figcaption { margin-bottom:4px; }
.study-picture { max-width:360px; border-radius:8px;overflow:hidden;background:#f9f4e8; }
.study-picture svg { display:block;width:100%;height:auto; }
.study-clue { margin-top:8px; font: 600 16px/1.7 var(--japanese); }
.study-controls,.study-answer-head,.study-audio { display:flex;align-items:center;gap:8px;flex-wrap:wrap; }
.study-answer-head { gap:8px 14px; }
.study-pron { font: 500 15px/1.65 var(--japanese);color:var(--soft); }
.study-answer-meaning { font-size:19px;font-weight:650; }
.study-example,.study-explain { border-top:1px solid var(--rule);padding-top:11px; }
.study-explain summary { cursor:pointer;font-size:14px;font-weight:600;color:var(--red-dark); }
.study-explain .motion-scene { margin-top:11px;max-width:450px; }
.study-explain .study-caption {margin-top:7px;}
.study-sense {padding:12px 0 5px;}
.study-sense + .study-sense {margin-top:6px;border-top:1px solid var(--rule);}
.study-sense-title {font-size:14px;color:var(--red-dark);}
.study-verdict { padding: 3px 9px; border-radius:5px;background:#e8eedc;color:#405b38; font-weight:700; }
.study-verdict.wrong { background:var(--red-pale);color:var(--red-dark); }
.study-verdict.aided { background:#f1e9d4;color:#69562e; }
.study-bartabs { justify-content:flex-start; gap:20px; }
.study-bartabs strong {font-size:17px;}
.study-filters { padding-bottom:14px; border-bottom:1px solid var(--rule); }
.study-book-tools { justify-content:flex-start; flex-wrap:wrap; margin:15px 0; }
.study-entry { padding:14px 0; border-top:1px solid var(--rule); }
.study-entry-title { justify-content:flex-start;flex-wrap:wrap;gap:5px 14px; }
.study-entry-title strong {font:650 21px/1.45 var(--japanese);}
.study-entry-title button {margin-left:auto;}
.study-entry-detail {margin-top:4px; color:var(--soft);font-size:13px;overflow-wrap:anywhere;}
.study-state {display:inline-block;margin-left:8px;color:var(--olive);}
.study-empty,.study-notice {padding:14px;background:#f5efdf;border-radius:6px;color:var(--soft);}
.study-notice,.study-backup {margin:15px 0;}
.study-backup .study-help {margin:6px 0 12px;}
.study-import {border-left:3px solid var(--red-dark);padding:10px 13px;margin-top:13px;background:#fbf2e7;}
.study-import h4 {margin:0 0 4px;}
.study-import .study-controls {margin-top:10px;}
@media(max-width:720px) {
  .study-home-grid {grid-template-columns:minmax(0,1fr);}
  .study-panel {border-radius:11px;}
  .study-filters > label:first-child {flex-basis:100%;}
}
@media(max-width:420px) {
  .study-options {grid-template-columns:minmax(0,1fr);}
  .study-toolbar {gap:5px;}
  .study-kana {display:grid; width:100%;}
  .study-kana input {width:100%;}
}
.study-context { border-left:2px solid #c9bea6; padding-left:10px; color:var(--soft); font-size:14px; }

.learning-editor {
  width: min(510px, calc(100vw - 28px));
  max-height: min(86vh, 700px);
  max-height: min(86dvh, 700px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 16px 60px #30251933;
}
.learning-editor::backdrop { background: #2e291b52; }
.learning-note-form { display: grid; gap: 12px; padding: clamp(18px,4vw,29px); }
.learning-note-form h2 { font: 700 25px/1.25 var(--serif); }
.learning-note-word, .learning-note-actions, .learning-note-footer, .learning-note-tools { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; }
.learning-note-word strong { color: var(--ink); font: 650 23px/1.5 var(--japanese); }
.learning-note-word span, .learning-note-footer small { font-size: 13px; color: var(--soft); }
.learning-note-word span[lang=ja] { font-family: var(--japanese); }
.learning-note-label { margin-top: 4px; font-size: 14px; font-weight: 650; }
.learning-textarea {
  width: 100%; min-width: 0; min-height: 100px; padding: 10px 12px; resize: vertical;
  font: inherit; font-size: 16px; line-height: 1.65; color: var(--ink);
  background: #fffcf5; border: 1px solid #c7baa5; border-radius: 7px;
}
.learning-textarea:focus-visible, .learning-day:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.learning-note-actions { justify-content: flex-end; }
.learning-note-actions .study-caption { margin-right: auto; white-space: nowrap; }
.learning-note-status { color: var(--red-dark); font-size: 13px; }
.learning-note-status:empty { display: none; }
.learning-note-tools { justify-content: space-between; gap: 8px 16px; }
.learning-note-search { width: min(100%, 310px); }
.learning-note-search input { width: 100%; }
.learning-note-count { margin-top: 14px; margin-bottom: 8px; }
.learning-note-entry { padding: 15px 0; border-top: 1px solid var(--rule); }
.learning-note-text { margin: 7px 0 5px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.learning-note-footer small { margin-right: auto; }
.learning-note-footer .study-btn { font-size: 13px; }
.learning-stats-metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; max-width: 690px; margin: 21px 0; }
.learning-trend, .learning-breakdown { margin-top: 24px; }
.learning-trend h4, .learning-breakdown h4 { margin: 0 0 9px; font-size: 16px; line-height: 1.5; }
.learning-legend { display: flex; flex-wrap: wrap; gap: 5px 16px; color: var(--soft); font-size: 13px; }
.learning-legend span { display: inline-flex; align-items: center; gap: 5px; }
.learning-legend span::before { content: ""; width: 9px; height: 9px; border-radius: 2px; }
.learning-bar-good, .learning-legend-good::before { background: #526c52; }
.learning-bar-aided,.learning-legend-aided::before { background: #bb9452; }
.learning-bar-wrong,.learning-legend-wrong::before { background: #a25645; }
.learning-chart { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: clamp(2px,.65vw,9px); margin-top: 12px; }
.learning-day {
  display: grid; grid-template-rows: 20px 76px auto; justify-items: center;
  min-width: 0; gap: 4px; padding: 6px 0; border-radius: 6px; border: 1px solid transparent;
  color: var(--soft); background: transparent; cursor: pointer; font: inherit;
}
.learning-day:hover { background: #f7f1e5; }
.learning-day[aria-pressed=true] { background: #f1ebde; border-color: #d4c9b4; color: var(--ink); }
.learning-day-count, .learning-day-label { font-size: 13px; font-variant-numeric: tabular-nums; }
.learning-day-count { font-weight: 650; }
.learning-bar-track { display: flex; flex-direction: column; justify-content: flex-end; width: min(34px,70%); height: 100%; border-bottom: 1px solid #bdb19c; }
.learning-bar-stack { display: flex; flex-direction: column-reverse; flex-shrink: 0; overflow: hidden; border-radius: 4px 4px 0 0; }
.learning-bar-stack span { flex-basis: 0; }
.learning-day-detail { margin-top: 7px; color: var(--soft); font-size: 13px; line-height: 1.65; }
.learning-breakdown table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.learning-breakdown td, .learning-breakdown th { padding: 8px 6px; border-bottom: 1px solid var(--rule); line-height: 1.5; text-align: right; }
.learning-breakdown th:first-child { text-align: left; padding-left: 0; }
.learning-breakdown thead th { color: var(--soft); font-size: 13px; font-weight: 600; }
.learning-method { margin-top: 13px; }
@media (max-width: 600px) {
  .learning-stats-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .learning-note-search { width: 100%; }
  .learning-day-label { font-size: 11px; }
}
@media (max-width: 360px) {
  .learning-breakdown td,.learning-breakdown th { padding-inline: 2px; }
  .learning-note-actions { gap: 4px; }
  .learning-note-actions .study-btn { padding-inline: 8px; }
}

.contrast-root {
  max-width: 1080px;
  margin: 0 auto 36px;
  color: var(--ink);
}
.contrast-root :is(h2,h3,h4,p) { margin: 0; }
.contrast-root button:focus-visible,.contrast-root input:focus-visible,.contrast-root summary:focus-visible {
  outline: 2px solid var(--red-dark); outline-offset: 3px;
}
.contrast-title { font: 700 clamp(25px,3vw,36px)/1.35 var(--serif); }
.contrast-title:focus,.contrast-verdict:focus { outline: none; }
.contrast-intro,.contrast-filterbar,.contrast-meter-label,.contrast-card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.contrast-intro { flex-wrap: wrap; margin: 12px 0 20px; }
.contrast-intro .contrast-muted { margin-top: 6px; }
.contrast-muted,.contrast-count,.contrast-translation { color:var(--soft);line-height:1.65; }
.contrast-actions,.contrast-filters { display:flex;flex-wrap:wrap;align-items:center;gap:8px; }
.contrast-root .study-btn,.contrast-link { cursor:pointer; }
.contrast-filterbar { flex-wrap:wrap; justify-content:flex-start; gap:12px 18px; }
.contrast-search {
  box-sizing:border-box; height:43px; width:min(235px,100%); padding:8px 13px;
  border:1px solid #cbbfa9; border-radius:7px; background:#fffcf5; color:var(--ink);
  font:inherit; font-size:15px;
}
.contrast-filters { gap:4px; }
.contrast-filter,.contrast-link {
  min-height:36px; padding:5px 9px; border:1px solid transparent; border-radius:6px;
  background:transparent; color:var(--soft); font:inherit; font-size:14px;
}
.contrast-filter { cursor:pointer; }
.contrast-filter[aria-pressed=true] { color:var(--red-dark);background:#f4e8d9;font-weight:700; }
.contrast-root .contrast-count { margin:11px 0; font-size:13px; }
.contrast-category { margin:20px 0 26px; }
.contrast-category h3 { margin-bottom:9px; font-size:17px; line-height:1.45; }
.contrast-cards,.contrast-meanings { display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,255px),1fr));gap:10px; }
.contrast-card,.contrast-definition,.contrast-drill {
  color:var(--ink);background:var(--card);border:1px solid var(--rule);border-radius:11px;
}
.contrast-card {
  display:flex;flex-direction:column;align-items:stretch;gap:6px;padding:12px 15px;
  text-align:left;font:inherit;cursor:pointer;
}
.contrast-card:hover,.contrast-choice:not(:disabled):hover { border-color:#ab8e72;background:#faf4e8; }
.contrast-card-head { gap:8px; }
.contrast-card-head strong { font-size:16px;line-height:1.5; }
.contrast-card-arrow { color:#806f56;font-size:20px;line-height:1; }
.contrast-card-words { font:500 14px/1.6 var(--japanese); color:var(--soft); }
.contrast-done { color:var(--olive);font-size:12px; }
.contrast-link { color:var(--red-dark);font-weight:650;text-align:left; }
.contrast-link:hover,.contrast-example-toggle summary:hover { text-decoration:underline; }
.contrast-toolbar { margin:0 0 10px; }
.contrast-toolbar .contrast-link { padding-left:0; }
.contrast-definition { display:flex; flex-direction:column; align-items:flex-start; gap:13px; padding:20px; }
.contrast-definition > .contrast-link { margin-top:auto; padding-left:0; }
.contrast-word-face { display:flex;flex-direction:column;align-items:flex-start;gap:1px; }
.contrast-word-face strong { font:650 clamp(20px,2.4vw,26px)/1.5 var(--japanese); }
.contrast-word-face small { color:var(--soft);font:500 13px/1.6 var(--japanese); }
.contrast-note,.contrast-other,.contrast-prompt { line-height:1.85;overflow-wrap:anywhere; }
.contrast-note { font-size:15px; }
.contrast-phrase { font-family:var(--japanese); }
.contrast-root :is(.contrast-phrase,.contrast-example) rt { font-size:.43em;color:#8b8376;font-weight:400; }
.contrast-example-toggle { width:100%;font-size:14px; }
.contrast-example-toggle summary { width:fit-content;cursor:pointer;color:var(--red-dark);font-weight:650; }
.contrast-sample { padding:10px 12px;border-left:2px solid #b4a58c;background:#f7f2e8; }
.contrast-example-toggle .contrast-sample { margin-top:11px; }
.contrast-example { font:500 18px/2.1 var(--japanese); overflow-wrap:anywhere; }
.contrast-example mark { color:var(--red-dark);background:#f1decc; border-radius:3px; }
.contrast-translation { margin-top:4px !important;font-size:14px; }
.contrast-drill { max-width:760px;margin:0 auto;padding:clamp(18px,3vw,32px); }
.contrast-drill h3 { font-size:clamp(20px,3vw,27px); }
.contrast-meter-label { font-weight:650;color:var(--soft);font-size:14px; }
.contrast-meter { display:block;width:100%;height:5px;margin:10px 0 23px; accent-color:var(--red-dark); }
.contrast-root .contrast-prompt { margin:10px 0 17px;font-size:clamp(16px,2vw,19px); }
.contrast-choices { display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,138px),1fr));gap:8px; }
.contrast-choice {
  padding:10px 14px; min-width:0;border:1px solid #c7b9a4;border-radius:8px;background:#fffcf6;
  color:var(--ink);text-align:left;cursor:pointer;
}
.contrast-choice strong { font-size:21px; }
.contrast-choice:disabled { cursor:default;opacity:1; }
.contrast-choice.is-answer { background:#edf2e7;border-color:#69815b; }
.contrast-choice.is-miss { background:#f9ebe4;border-color:#af6958; }
.contrast-feedback { margin-top:18px;padding-top:16px;border-top:1px solid var(--rule);display:grid;gap:9px; }
.contrast-verdict { color:#405a36;font-size:17px; }
.contrast-verdict.is-miss { color:var(--red-dark); }
.contrast-other { color:var(--soft);font-size:14px; }
.contrast-feedback .contrast-actions { margin-top:7px; }
.contrast-score { color:var(--olive);font:650 22px/1.5 var(--serif);padding:12px 0 16px; }
.contrast-summary-item { padding:12px 0;border-top:1px solid var(--rule); }
.contrast-drill > .contrast-actions { margin-top:10px; }
@media(max-width:600px) {
  .contrast-card,.contrast-definition { padding:13px; }
  .contrast-search { width:100%; }
  .contrast-filters { gap:0; }
  .contrast-filter { padding-inline:8px; }
}
@media(max-width:380px) {
  .contrast-choices { grid-template-columns:minmax(0,1fr); }
  .contrast-definition { gap:8px; }
}

/* The native select still opens the platform picker. Reserve a separate
   gutter for its visible chevron in every view of the offline app. */
:root select:not([multiple]):not([size]) {
  -webkit-appearance: none;
  appearance: none;
  min-inline-size: 0;
  max-inline-size: 100%;
  min-block-size: 44px;
  margin: 0;
  padding: .5em 2.45em .5em .8em;
  border: 1px solid #bdb29f;
  border-radius: 7px;
  color: var(--ink);
  background-color: #fffcf5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath d='m2.5 5 4.5 4.5L11.5 5' fill='none' stroke='%23675d4d' stroke-width='1.65' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8em center;
  background-size: 14px 14px;
  font: 400 15px/1.4 var(--sans);
  cursor: pointer;
}

.study-filters {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  padding-bottom: 18px;
}

.study-settings-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.25rem), 1fr));
  gap: 12px;
}

.study-field {
  min-inline-size: 0;
  gap: 6px;
}

.study-field > :is(input, select) {
  width: 100%;
}

.study-root .study-field > input:not([type=checkbox]):not([type=file]) {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding-inline: .8em;
  border-color: #bdb29f;
  border-radius: 7px;
  background-color: #fffcf5;
}

.catalog-search {
  min-height: 44px;
  padding-inline: 12px;
}

.catalog-filters {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 8px;
  margin: 12px 0 5px;
  align-items: end;
}
.catalog { block-size: min(82dvh,740px); }
.catalog-results { flex: 1; }
.catalog-multi {
  --picker-bg: #fffcf5;
  --picker-line: #bdb29f;
  position: relative;
  min-width: 0;
}
[data-theme="space"] .catalog-multi { --picker-bg: #142136; --picker-line: #3d4f68; }
.catalog-multi summary {
  display: flex; align-items: center; gap: 5px;
  min-height: 44px; padding: .5em .75em;
  border: 1px solid var(--picker-line); border-radius: 7px;
  background: var(--picker-bg); color: var(--ink);
  font: 400 15px/1.4 var(--sans); list-style: none; cursor: pointer;
}
.catalog-multi summary::-webkit-details-marker { display: none; }
.catalog-multi summary::after {
  content: ""; flex: none; width: 7px; height: 7px; margin: -3px 2px 0 auto;
  border: solid var(--soft); border-width: 0 1.6px 1.6px 0; transform: rotate(45deg);
}
.catalog-multi[open] summary::after { transform: rotate(225deg); margin-top: 3px; }
.catalog-multi summary > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catalog-multi[data-active] summary { color: var(--red-dark); border-color: var(--red-dark); }
.catalog-selection-count { flex: none; font-size: .8em; font-weight: 660; }
.catalog-options {
  position: absolute; z-index: 4; top: calc(100% + 4px);
  width: max-content; min-width: 100%; max-width: min(18rem,calc(100vw - 42px)); max-height: 45dvh;
  padding: 4px; border: 1px solid var(--picker-line); border-radius: 9px;
  overflow-y: auto; overscroll-behavior: contain;
  color: var(--ink); background: var(--card); box-shadow: 0 7px 24px #151c252d;
}
.catalog-options.opens-above { top: auto; bottom: calc(100% + 4px); }
.catalog-options > :is(button,label) {
  display: flex; align-items: center; gap: 9px; min-height: 36px;
  margin: 0; padding: 5px 8px; border-radius: 5px; font: 400 14px/1.35 var(--sans);
  cursor: pointer; overflow-wrap: anywhere; text-align: start;
}
.catalog-options > button { width: 100%; color: var(--soft); background: transparent; }
.catalog-options > button[aria-pressed="true"] { color: var(--red-dark); font-weight: 650; }
.catalog-options > button[aria-pressed="true"]::after { content: "✓"; margin-inline-start: auto; }
.catalog-options > label:has(input:checked) { color: var(--red-dark); }
.catalog-options > :is(button,label):hover { background: var(--red-pale); }
.catalog-options input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--red-dark); }
.catalog-multi summary:focus-visible { outline: 2px solid var(--red-dark); outline-offset: 2px; }
.catalog-options > button:focus-visible { outline-offset: -2px; }
@media (pointer: coarse) {
  .catalog-options > :is(button,label) { min-height: 44px; }
}

:root select:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

@media (hover: hover) {
  :root select:not([multiple]):not([size]):enabled:hover {
    border-color: #907c62;
  }
}

@media (max-width: 720px) {
  .study-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .study-filters > label:first-child { grid-column: 1 / -1; }

  /* Keep mobile input focus at the current zoom level. */
  :root select:not([multiple]):not([size]),
  .study-root input:not([type=checkbox]):not([type=file]),
  .catalog-search input {
    font-size: 16px;
  }
}

@media (max-width: 348px) {
  .study-filters { grid-template-columns: minmax(0, 1fr); }
}

@media (forced-colors: active) {
  :root select:not([multiple]):not([size]) {
    -webkit-appearance: auto;
    appearance: auto;
    padding-inline-end: .8em;
    background-image: none;
    border-color: ButtonText;
  }

  :root select:focus-visible { outline-color: Highlight; }
}

.atlas-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: -3px 0 16px;
  color: var(--soft);
  font-size: 13px;
}
.level-switch {
  display: inline-flex;
  padding: 3px;
  gap: 1px;
  border-radius: 9px;
  background: #ece6d9;
}
.level-switch button {
  min-width: 40px;
  padding: 6px 10px;
  line-height: 1.4;
  color: #5c5c4f;
  background: transparent;
  border-radius: 6px;
  font-weight: 620;
}
.level-switch button[aria-pressed="true"] { color: #fffaf0; background: #754135; }
.level-switch button:not([aria-pressed="true"]):hover { background: #fcf9f0; }
:root #map-pos {
  min-height: 36px;
  min-block-size: 36px;
  max-width: 12em;
  padding-block: 4px;
  font-size: 14px;
}
.filter-clear {
  min-height: 36px;
  padding: 4px 7px;
  background: transparent;
  color: var(--red-dark);
  font: 600 13px var(--sans);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.map-empty { padding: 42px 16px; text-align: center; border: 1px solid var(--rule); border-radius: 13px; background: var(--card); }
.map-empty h2 { font: 700 20px var(--serif); }
.map-empty p { margin: 7px 0 14px; color: var(--soft); }
.level-badge, .catalog-word .level-badge {
  display: inline-block;
  flex: none;
  padding: 2px 6px;
  border-radius: 4px;
  color: #704536;
  background: #f2e4d8;
  font: 680 12px/1.5 var(--sans);
  letter-spacing: .02em;
}
.level-badge[data-level="N5"] { color: #38563b; background: #e2ecde; }
.level-badge[data-level="N4"] { color: #345963; background: #e1ebec; }
.level-badge[data-level="N3"] { color: #635071; background: #ece5ef; }
.level-badge[data-level="N1"] { color: #883b2e; background: #f3ddd5; }
.catalog-word .result-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.catalog-status { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 28px; }
.catalog-count { margin: 0; }
.catalog-status .filter-clear { min-height: 28px; flex: none; }
@media (max-width: 570px) {
  .catalog-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 510px) {
  .atlas-filters { column-gap: 12px; margin-top: 0; }
  .level-switch button { min-width: 36px; padding-inline: 8px; }
}
@media (pointer: coarse) {
  .level-switch button { min-height: 38px; }
  :root #map-pos { min-block-size: 44px; font-size: 16px; }
}
@media (max-width: 350px) {
  .catalog-filters { column-gap: 7px; }
  :root .catalog-filters select:not([multiple]):not([size]) { padding-inline: 6px 20px; background-position: right 4px center; }
}

.word-aliases { margin: -6px 0 12px; color: var(--soft); font-size: 12px; line-height: 1.65; }
.word-aliases .variant-audio { display: block; margin-top: 4px; }

/* The identity and theme selector are shared by both atlases. */
.topbar-inner {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  column-gap: clamp(14px, 2.2vw, 34px);
  min-height: 68px;
}
.topbar-inner .modes { justify-self: center; }
.brand { gap: 9px; }
.brand-mark {
  position: relative;
  width: 37px;
  height: 37px;
  overflow: hidden;
  border: 1px solid #63809e;
  border-radius: 11px;
  background: radial-gradient(circle at 64% 23%, #344b64, transparent 76%), #172235;
  box-shadow: inset 0 0 13px #15213540;
}
.brand-mark::before {
  content: "";
  position: absolute;
  width: 30px;
  height: 11px;
  border: 1px solid #cbe5eb8a;
  border-radius: 50%;
  transform: rotate(-35deg);
}
.brand-mark i, .brand-mark::after {
  display: block;
  background: #ffe1aa;
  clip-path: polygon(50% 0,60% 36%,100% 48%,63% 60%,50% 100%,39% 61%,0 50%,37% 37%);
}
.brand-mark i { position: relative; width: 22px; height: 25px; }
.brand-mark::after { content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; background: #c8faff; }
.brand-lockup { display: grid; gap: 3px; letter-spacing: 0; }
.brand-lockup strong { font: 750 18px/1.18 var(--sans); letter-spacing: .06em; }
.brand-lockup small { color: var(--soft); font: 500 10px/1.1 var(--sans); letter-spacing: .06em; }
.theme-switch {
  display: inline-flex;
  justify-self: end;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--rule);
  border-radius: 20px;
  background: var(--paper);
}
.theme-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 31px;
  padding: 4px 10px;
  border-radius: 16px;
  background: transparent;
  color: var(--soft);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
}
.theme-switch button[aria-pressed="true"] { color: var(--red-dark); background: var(--card); box-shadow: 0 1px 4px #382e1e24; }
.theme-switch button:focus-visible { outline-offset: 1px; }
.theme-space-icon, .theme-city-icon { position: relative; display: inline-block; width: 13px; height: 13px; flex: none; }
.theme-space-icon::before { content: ""; position: absolute; inset: 2px; border-radius: 50%; background: currentColor; }
.theme-space-icon::after { content: ""; position: absolute; inset: 4px -1px; border: 1px solid currentColor; border-radius: 50%; transform: rotate(-28deg); }
.theme-city-icon {
  background: currentColor;
  clip-path: polygon(0 99%,0 45%,26% 45%,26% 26%,46% 26%,46% 4%,69% 4%,69% 52%,80% 52%,80% 32%,100% 32%,100% 99%);
}

:root[data-theme="space"] {
  color-scheme: dark;
  --paper: #080d1d;
  --card: #101a2c;
  --ink: #edf3fd;
  --soft: #afbdd3;
  --rule: #2b3951;
  --red: #8ce3db;
  --red-dark: #a5eddf;
  --red-pale: #1a343c;
  --olive: #a1e1bb;
  --edge: #41506d;
  --raised: #19253a;
  --ice: #8ce3db;
  --lilac: #bebafa;
  --sand: #f5c98a;
}
:root[data-theme="space"] body {
  background:
    radial-gradient(ellipse at 14% -15%, #1f2845 0, transparent 46rem),
    radial-gradient(ellipse at 99% 45%, #151a32 0, transparent 47rem),
    var(--paper);
}
:root[data-theme="space"] .topbar { background: #0d1424; border-color: #25324a; }
:root[data-theme="space"] .brand-mark { border-color: #51627b; box-shadow: inset 0 0 14px #65798a22, 0 0 14px #6ab1e511; }
:root[data-theme="space"] .brand-lockup small { color: #a0b1c9; }
:root[data-theme="space"] .theme-switch { background: #080e1c; border-color: #34415b; }
:root[data-theme="space"] .theme-switch button[aria-pressed="true"] { color: #e0e4ff; background: #303550; box-shadow: inset 0 0 0 1px #636c9566; }
:root[data-theme="space"] .mode { color: #abb8ce; }
:root[data-theme="space"] .mode:hover, :root[data-theme="space"] .mode[aria-pressed="true"] { color: #e3fcf6; }
:root[data-theme="space"] .mode[aria-pressed="true"]::after { height: 2px; background: var(--ice); box-shadow: 0 -2px 10px #9deae84d; }
:root[data-theme="space"] .completion { width: 119px; }
:root[data-theme="space"] #progress-text { color: #d0dfef; }
:root[data-theme="space"] progress { background: #2c384e; height: 4px; }
:root[data-theme="space"] progress::-webkit-progress-value { background: linear-gradient(90deg,#84bbf3,var(--ice)); }

:root[data-theme="space"] .map-counts { font-size: 13px; letter-spacing: .025em; margin: 0; }
:root[data-theme="space"] .count-number { color: #e4e9f8; font-family: ui-monospace,"SFMono-Regular",Consolas,monospace; }
:root[data-theme="space"] .atlas-filters { margin: 0 0 13px; gap: 6px 17px; }

:root[data-theme="space"] .panel, :root[data-theme="space"] .study-panel {
  border-color: #2c3a52;
  background: linear-gradient(125deg,#142035 0%,#10192b 63%);
  box-shadow: inset 0 1px #9db7d00c, 0 8px 24px #02071336;
}
:root[data-theme="space"] .panel { border-radius: 13px; }
:root[data-theme="space"] .map-panel .panel-heading { padding: 12px 17px; }
:root[data-theme="space"] .panel-heading h2 { font-size: 18px; }
:root[data-theme="space"] .map-breadcrumb { color: #9aadc6; }
:root[data-theme="space"] .map-breadcrumb > :not(:first-child)::before { color: #6d829d; }
:root[data-theme="space"] .map-panel .zoom-level {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 4px 9px; border: 1px solid #3a4b62; border-radius: 5px;
  color: #bdd9e4; background: #17273a; letter-spacing: .04em;
}
:root[data-theme="space"] .zoom-level::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--ice); box-shadow: 0 0 7px #99e9e896; }
:root[data-theme="space"] .map-surface { border-block-color: #34405a; background: #080d20; }
:root[data-theme="space"] .map-surface .compass { display: none; }
:root[data-theme="space"] .map-surface .map-legend {
  color: #c0cee2; background: #0c1426e6; border-color: #344561; border-radius: 5px;
  padding: 4px 8px; letter-spacing: .03em;
}
:root[data-theme="space"] .map-surface :is(.locate-word,.zoom-button) {
  color: #e0eefb; background: #121e32ed; border-color: #496078; box-shadow: 0 3px 12px #0106127a;
}
:root[data-theme="space"] .map-surface :is(.locate-word,.zoom-button):not(:disabled):hover { color: #cafff2; background: #26394d; }
:root[data-theme="space"] .map-surface .zoom-button:disabled { color: #8293a9; background: #172235; }
:root[data-theme="space"] .city-directory { background: #0b1526; border-color: #27374e; }
:root[data-theme="space"] .city-directory summary { color: #afcde0; }
:root[data-theme="space"] .directory-links button { color: #c0cee1; background: #18243a; border-color: var(--rule); }
:root[data-theme="space"] .directory-links button:hover { color: #d8fff5; border-color: #639594; }
:root[data-theme="space"] .route { padding: 16px 18px 19px; }
:root[data-theme="space"] #route-root { color: #e0eaf7; }
:root[data-theme="space"] .word-chip { background: #172337; color: #ccd8e8; border-color: #34425a; }
:root[data-theme="space"] .word-chip:hover { border-color: #7187a2; }
:root[data-theme="space"] .word-chip[aria-pressed="true"] { background: #20383f; border-color: #5b9a9a; color: #cafff1; }

.map-surface[data-map-theme="space"] .station[data-depth],
.map-surface[data-map-theme="space"][data-map-small] .station[data-depth],
.map-surface[data-map-theme="space"][data-narrow-street] .station[data-depth] {
  width: 98px; min-height: 34px; padding: 2px 3px;
  gap: 1px; display: flex; flex-direction: column; justify-content: center; align-items: center;
  border: 1px solid transparent; border-radius: 6px; isolation: auto;
  background: radial-gradient(ellipse at center,#080e20c9 22%,#0b122859 66%,transparent 80%);
  box-shadow: none; color: #ecf4ff; text-align: center;
  text-shadow: 0 1px 3px #040815, 0 0 6px #05091a;
}
.map-surface[data-map-theme="space"] .station[data-depth]::before,
.map-surface[data-map-theme="space"] .station .meaning-icon { display: none; }
.map-surface[data-map-theme="space"] .station[data-depth] .station-title {
  color: #f3f5ff; width: 100%; line-height: 1.2; font-size: 13px; font-weight: 690; letter-spacing: .015em;
}
.map-surface[data-map-theme="space"] .station[data-depth="2"] .station-title { font-size: 14px; }
.map-surface[data-map-theme="space"] .station[data-depth] .station-gloss { color: #c0ccdf; font-size: 10px; font-weight: 500; line-height: 1.2; }
.map-surface[data-map-theme="space"] .station[data-depth][aria-current],
.map-surface[data-map-theme="space"] .station[data-depth]:hover,
.map-surface[data-map-theme="space"][data-map-small] .station[data-depth]:is(:hover,[aria-current]),
.map-surface[data-map-theme="space"][data-narrow-street] .station[data-depth]:is(:hover,[aria-current]) {
  border-color: color-mix(in srgb,var(--station-ink) 52%,#273d57);
  background: #101b2fe8; box-shadow: 0 0 11px color-mix(in srgb,var(--station-ink) 17%,transparent);
}
.map-surface[data-map-theme="space"] .station[data-depth][aria-current] .station-title { color: #fff; }
.map-surface[data-map-theme="space"] .station[data-depth]:focus-visible { outline: 2px solid #bcf7eb; outline-offset: 2px; }
.map-surface[data-map-theme="space"] .station .station-check { top: -5px; right: -3px; background: #a2e7c8; color: #153432; }
.map-surface[data-map-theme="space"][data-map-small] .station[data-depth="0"] { width: 85px; }
.map-surface[data-map-theme="space"][data-narrow-street] .station[data-depth="2"] { width: 82px; }

:root[data-theme="space"] .detail-panel {
  border-top-color: #6a6279;
  background: radial-gradient(ellipse at top right, #30304888, transparent 16rem), var(--card);
}
:root[data-theme="space"] .detail-family { color: #cfdbec; color: color-mix(in srgb,var(--topic-color,#72aaa4) 37%,#eeefff); }
:root[data-theme="space"] .detail-family i { background: currentColor; box-shadow: 0 0 7px currentColor; }
:root[data-theme="space"] .word-heading { margin-top: 12px; }
:root[data-theme="space"] .word-title .root-part { color: #fad3a3; }
:root[data-theme="space"] .word-reading { color: #b8c6dd; }
:root[data-theme="space"] .word-meaning { color: #e7ebf8; }
:root[data-theme="space"] .pos-label { background: #1b2d3c; color: #b1d4df; }
:root[data-theme="space"] .level-badge { background: #3c2e25; color: #f2cf99; }
:root[data-theme="space"] .level-badge[data-level="N5"] { background: #213b33; color: #b6e5bd; }
:root[data-theme="space"] .level-badge[data-level="N4"] { background: #1c3641; color: #aae1ea; }
:root[data-theme="space"] .level-badge[data-level="N3"] { background: #332e48; color: #dcc9f5; }
:root[data-theme="space"] .level-badge[data-level="N1"] { background: #422c37; color: #f6c1bb; }
:root[data-theme="space"] .pronunciation { background: #1c3041; border-color: #39576b; color: #b8e9ee; }
:root[data-theme="space"] .pronunciation:hover, :root[data-theme="space"] .pronunciation[data-playing] { background: #284657; border-color: #669caa; }
:root[data-theme="space"] .bookmark { color: #c0c8dc; }
:root[data-theme="space"] .bookmark:hover, :root[data-theme="space"] .bookmark[aria-pressed="true"] { background: #3e352a; color: #f3d89f; }
:root[data-theme="space"] .sense-options button { background: #172236; border-color: var(--rule); }
:root[data-theme="space"] .sense-options button:hover { border-color: #566a87; }
:root[data-theme="space"] .sense-options button[aria-pressed="true"] { color: #f8d6aa; background: #302d31; border-color: #7c6751; }
:root[data-theme="space"] .motion-scene { background: #dadfda; border-color: #455368; color-scheme: light; }
:root[data-theme="space"] .example, :root[data-theme="space"] .contrast-sample {
  background: #1a2538; border-left-color: #b4937c;
}
:root[data-theme="space"] .example h3 { color: #e3c9a9; }
:root[data-theme="space"] .ja-example rt,
:root[data-theme="space"] .study-sentence rt,
:root[data-theme="space"] :is(.contrast-phrase,.contrast-example) rt { color: #97a6bf; font-size: .45em; font-weight: 450; }
:root[data-theme="space"] :is(.ja-example,.study-sentence,.contrast-example) mark {
  color: #ffdaa6; background: linear-gradient(transparent 57%,#77604675 57%); font-weight: 710;
}
:root[data-theme="space"] .ja-example mark rt { color: #b9aa96; }
:root[data-theme="space"] .step:not(:disabled):hover { background: var(--raised); color: var(--ice); }
:root[data-theme="space"] :is(.master,.study-btn.primary,.study-btn.study-play) {
  color: #102b32; background: #a0e2d9; border-color: #a0e2d9;
}
:root[data-theme="space"] :is(.master,.study-btn.primary,.study-btn.study-play):not(:disabled):hover { color: #09262b; background: #baf3e4; border-color: #baf3e4; }
:root[data-theme="space"] .master[aria-pressed="true"] { color: #beedcd; background: #25453c; }
:root[data-theme="space"] .master[aria-pressed="true"]:hover { color: #cef2d8; background: #2b5546; }
:root[data-theme="space"] :is(.catalog-open,.mobile-current) { border-color: #4c656e; background: #1a303c; color: #c2f2e7; }
:root[data-theme="space"] :is(.catalog-open,.mobile-current):hover { color: #e1fff5; background: #26414d; border-color: #719b9e; }
:root[data-theme="space"] .search-icon { color: currentColor; }
:root[data-theme="space"] .level-switch { background: #101a2a; border: 1px solid var(--rule); }
:root[data-theme="space"] .level-switch button { color: #abbad0; }
:root[data-theme="space"] .level-switch button[aria-pressed="true"] { background: #28464b; color: #cdfff2; box-shadow: inset 0 0 0 1px #527f8080; }
:root[data-theme="space"] .level-switch button:not([aria-pressed="true"]):hover { background: #26364a; color: #e5efff; }
:root[data-theme="space"] select:not([multiple]):not([size]) {
  background-color: #142136; border-color: #3d4f68; color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath d='m2.5 5 4.5 4.5L11.5 5' fill='none' stroke='%23bbcde2' stroke-width='1.65' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
:root[data-theme="space"] select:not([multiple]):not([size]):enabled:hover { border-color: #7991ab; }
:root[data-theme="space"] .catalog, :root[data-theme="space"] .learning-editor { border-color: #48607b; background: #101a2c; box-shadow: 0 20px 75px #020611a6; }
:root[data-theme="space"] dialog::backdrop { background: #030611a8; }
:root[data-theme="space"] .catalog-search { background: #172236; border-color: #4b5e78; color: #bbcce2; }
:root[data-theme="space"] .catalog-search:focus-within { outline-color: var(--ice); }
:root[data-theme="space"] :is(.catalog-more,.catalog-family button) { background: #203047; color: var(--ink); }
:root[data-theme="space"] .catalog-word:hover, :root[data-theme="space"] .catalog-word:focus-visible { background: #1d2c41; }
:root[data-theme="space"] .sheet-grip { background: #596c86; }
:root[data-theme="space"] :is(.learning-textarea,.contrast-search),
:root[data-theme="space"] .study-root input:not([type=checkbox]):not([type=file]),
:root[data-theme="space"] .study-root .study-field > input:not([type=checkbox]):not([type=file]) { background: #152238; border-color: #43546e; }
:root[data-theme="space"] input::placeholder, :root[data-theme="space"] textarea::placeholder { color: #98a8c0; opacity: 1; }
:root[data-theme="space"] .study-btn:not(.primary):not(.study-play):not(.subtle),
:root[data-theme="space"] .contrast-choice { color: var(--ink); background: #19273c; border-color: #3d4e68; }
:root[data-theme="space"] .study-btn:not(.primary):not(.study-play):not(.subtle):not(:disabled):hover,
:root[data-theme="space"] :is(.contrast-choice,.contrast-card):not(:disabled):hover { background: #22374a; border-color: #66868e; }
:root[data-theme="space"] .study-btn.subtle:not(:disabled):hover { background: var(--red-pale); color: var(--ice); }
:root[data-theme="space"] :is(.study-empty,.study-notice,.study-import) { background: #1a273c; }
:root[data-theme="space"] :is(.study-verdict,.contrast-choice.is-answer) { color: #c1edcb; background: #244237; border-color: #53836b; }
:root[data-theme="space"] :is(.study-verdict.wrong,.contrast-choice.is-miss) { color: #ffc8be; background: #432c37; border-color: #a86c75; }
:root[data-theme="space"] .study-verdict.aided { color: #f3d7a7; background: #403727; }
:root[data-theme="space"] .contrast-verdict { color: #a8e2bf; }
:root[data-theme="space"] .contrast-verdict.is-miss { color: #ffb8b0; }
:root[data-theme="space"] .contrast-filter[aria-pressed="true"] { background: var(--red-pale); color: var(--ice); }
:root[data-theme="space"] .contrast-card-arrow { color: #a7b7d3; }
:root[data-theme="space"] .learning-day:hover { background: #192a3d; }
:root[data-theme="space"] .learning-day[aria-pressed="true"] { background: #223249; border-color: #4c627d; }
:root[data-theme="space"] .learning-bar-track { border-color: #486077; }
:root[data-theme="space"] .learning-bar-good, :root[data-theme="space"] .learning-legend-good::before { background-color: #85c9a6; }
:root[data-theme="space"] .learning-bar-aided, :root[data-theme="space"] .learning-legend-aided::before { background-color: #dfb574; }
:root[data-theme="space"] .learning-bar-wrong, :root[data-theme="space"] .learning-legend-wrong::before { background-color: #e19499; }

@media (max-width: 850px) {
  .topbar-inner {
    grid-template-areas: "brand progress switch" "modes modes modes";
    grid-template-columns: minmax(0,1fr) auto auto;
    gap: 0 14px; min-height: auto; padding-top: 9px;
  }
  .brand { grid-area: brand; }
  .completion { grid-area: progress; }
  .theme-switch { grid-area: switch; }
  .topbar-inner .modes {
    grid-area: modes; display: grid; width: 100%; justify-self: stretch;
    grid-template-columns: repeat(4,minmax(0,1fr)); gap: 0;
  }
  .topbar-inner .mode { min-height: 39px; }
  .topbar-inner .mode::after { inset-inline: 14%; }
}
@media (max-width: 590px) {
  .topbar-inner { gap: 0 10px; padding-top: 7px; }
  .brand-mark { width: 31px; height: 31px; border-radius: 9px; }
  .brand-lockup strong { font-size: 15px; }
  .brand-lockup small { font-size: 9px; letter-spacing: .015em; }
  .brand { gap: 7px; }
  .theme-switch button { min-height: 32px; padding: 4px 8px; }
  :root[data-theme="space"] .completion { width: 78px; }
  :root[data-theme="space"] .atlas-tools .map-counts { font-size: 12px; }
  :root[data-theme="space"] .atlas-tools .catalog-open { flex: none; }
  :root[data-theme="space"] .level-switch button { min-width: 33px; padding-inline: 7px; }
  :root[data-theme="space"] .atlas-filters { margin-bottom: 10px; gap: 6px 13px; }
}
@media (max-width: 365px) {
  .topbar-inner { gap: 0 6px; }
  .brand { gap: 5px; }
  .brand-mark { width: 26px; height: 28px; }
  .theme-switch button { padding: 4px 6px; gap: 3px; }
  .topbar-inner .completion, :root[data-theme="space"] .completion { width: 58px; }
  .completion-label { justify-content: flex-end; flex-wrap: wrap; gap: 0 3px; }
  .brand-lockup small { font-size: 8px; }
  :root[data-theme="space"] .atlas-tools .map-counts { font-size: 11px; }
  :root[data-theme="space"] .atlas-tools { gap: 7px; }
  :root[data-theme="space"] .atlas-tools .catalog-open { padding-inline: 8px; gap: 5px; }
}
@media (forced-colors: active) {
  .brand-mark i, .brand-mark::after, .theme-space-icon::before, .theme-city-icon { background: ButtonText; }
  :root[data-theme="space"] select:not([multiple]):not([size]) { background-image: none; border-color: ButtonText; }
  .map-surface[data-map-theme="space"] .station[data-depth][aria-current] { border: 2px solid Highlight; }
  .theme-switch button[aria-pressed="true"] { outline: 1px solid Highlight; }
}

.map-surface[data-map-theme="space"] .station[data-depth] :is(.station-title,.station-gloss) {
  display: block; width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

@media (max-width: 590px) {
  .topbar-inner .completion-label {
    display: grid; justify-content: end; gap: 0;
    font-size: 10px; line-height: 1.2; text-align: right;
  }
  .topbar-inner .completion-label span { display: block; white-space: nowrap; }
  .atlas-tools {display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;}
  .atlas-tools .map-counts {line-height:1.5;}
}

.semantic-map { position:absolute; inset:0; z-index:2; overflow:hidden; cursor:default; touch-action:none; container-type:inline-size; }
.semantic-map.semantic-camera { overflow:clip; cursor:grab; }
.semantic-map.semantic-over-node { cursor:pointer; }
.map-surface.is-dragging .semantic-camera, .map-surface.is-dragging .semantic-camera .semantic-pin { cursor:grabbing; }
.semantic-map[hidden] { display:none; }
.semantic-map:focus-visible { outline:2px solid var(--red); outline-offset:-3px; }
.semantic-plane, .semantic-chart, .semantic-pins { position:absolute; inset:0; width:100%; height:100%; }
.semantic-chart[hidden] { display:none; }
.semantic-plane { overflow:visible; }
.semantic-pins { pointer-events:none; }
.semantic-pin { position:absolute; transform-origin:50% 38%; transform:translate(-50%,-38%) scale(var(--atlas-label-scale,1)); display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:2px; pointer-events:auto; min-height:36px;
  padding:4px 3px; color:#382f24; border:1px solid transparent; border-radius:7px;
  background:transparent; box-shadow:none; text-align:center; cursor:pointer; line-height:1.18; }
.semantic-name { font-size:clamp(13px,1.25vw,17px); font-weight:750; text-wrap:balance; overflow-wrap:anywhere; }
.semantic-detail { font-size:11px; line-height:1.3; font-weight:570; text-wrap:balance; overflow-wrap:anywhere; }
.semantic-map[data-theme=city] .semantic-pin { text-shadow:0 1px 2px #fffaed,1px 0 2px #fffaed,-1px 0 2px #fffaed; }
.semantic-map[data-theme=city] .semantic-detail { color:#534736; }
.semantic-map[data-theme=space] .semantic-pin { color:#f0f3ff; text-shadow:0 1px 4px #020810,0 0 7px #000b19; }
.semantic-map[data-theme=space] .semantic-detail { color:#c8d6e4; }
.semantic-map[data-kind=regions] .semantic-pin { width:max-content; max-width:var(--atlas-name-width); padding-inline:8px; }
.semantic-plane[data-world][data-wide-view] .semantic-pin { min-height:20px; max-width:var(--atlas-wide-width); padding:2px 3px; }
.semantic-plane[data-world][data-wide-view] .semantic-name { font-size:clamp(13px,2.1cqw,17px); line-height:1.18; letter-spacing:0; }
.semantic-plane[data-world][data-wide-view] .semantic-detail { display:none; }
.semantic-map[data-kind=regions] .semantic-name { letter-spacing:.035em; }
.semantic-map[data-theme=city][data-kind=regions] .semantic-name {
  text-shadow:0 1px 2px #fff7dc, 1px 0 2px #fff7dc, -1px 0 2px #fff7dc, 0 -1px 2px #fff7dc;
}
.semantic-map[data-theme=space][data-kind=regions] .semantic-name {
  color:#f1f4ff; text-shadow:0 1px 2px #061122, 1px 0 3px #061122, -1px 0 3px #061122;
}
.semantic-pin:hover, .semantic-pin.is-hovered, .semantic-pin[aria-current], .semantic-pin:focus-visible {
  border-color:#9b7f5b; background:#fff5e5e8; outline:0; }
.semantic-map[data-theme=space] .semantic-pin:is(:hover,.is-hovered,[aria-current],:focus-visible) {
  border-color:#87b7d6; background:#101e32e8; }
.semantic-map[data-kind=senses] .semantic-pin { transform-origin:50% 0; transform:translate(-50%,var(--word-caption-offset,12px)) scale(var(--atlas-label-scale,1)); padding:3px; min-height:32px; }
.semantic-map[data-kind=senses] .semantic-name { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; }
.semantic-map[data-kind=senses] .semantic-name { font-family:var(--jp-serif,var(--serif,serif)); font-size:clamp(14px,1.35vw,18px); }
@media(max-width:460px) {
  .semantic-detail { font-size:10px; }
}

/* Reserve the illustration's space while its SVG is being lazy-loaded. */
#motion-scene:empty, #motion-scene[aria-busy="true"] {
  box-sizing: content-box;
  aspect-ratio: 320 / 164;
  max-height: 244px;
}
.word-stage-art {
  --stage-sky: #fbf7e9;
  --stage-distant: #e3e6d7;
  --stage-field: #d4dfcc;
  --stage-sun: #f2d99b;
  --stage-floor: #f0e7d5;
  --stage-line: #d4caba;
  --stage-water: #d4e5e3;
  --stage-shadow: #c6bba480;
  --stage-light: #f9f0db;
  --stage-plinth: #e7d8bd;
  display: block;
  width: 100%;
  height: auto;
  max-height: 244px;
  margin: 0 auto;
  background: var(--stage-sky);
  color-scheme: light;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: hidden;
}
.word-stage-glyph { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.word-stage-art .word-stage-night {
  --stage-sky: #a6b3c9;
  --stage-distant: #8496af;
  --stage-field: #8d9da9;
  --stage-floor: #b9bfca;
  --stage-line: #8a98aa;
  --stage-water: #8fa5b7;
}
:root[data-theme="space"] .word-stage-art {
  --stage-sky: #e9eaf4;
  --stage-distant: #d2d9e8;
  --stage-field: #c4d3d9;
  --stage-sun: #f7deab;
  --stage-floor: #dedbe5;
  --stage-line: #bdc2d3;
  --stage-water: #cadce8;
  --stage-shadow: #a7a5bf80;
  --stage-light: #efecf3;
  --stage-plinth: #d1cbdc;
}

/* Focus controls follow the atlas palette. The clock face is a small dial by
   daylight and a luminous orbit in the space theme. */
:root {
  --focus-edge:#d7c6b1;
  --focus-wash:#f5eee1;
  --focus-action:#8e4235;
  --focus-on-action:#fffaf0;
  --focus-rim:#e2d4bd;
  --focus-dial:#fffcf5;
  --focus-rest:#5c7962;
  --focus-shade:0 15px 55px #594a3930;
}
:root[data-theme="space"] {
  --focus-edge:#3a4e69;
  --focus-wash:#19263a;
  --focus-action:#92dfd5;
  --focus-on-action:#102a30;
  --focus-rim:#364a63;
  --focus-dial:#152035;
  --focus-rest:#b5c0f2;
  --focus-shade:0 20px 70px #02081581;
}
.topbar-inner:has(#focus-mini) {grid-template-columns:auto minmax(0,1fr) auto auto auto;gap:0 clamp(9px,1.5vw,23px)}
#focus-mini {min-inline-size:0;min-block-size:36px;position:relative;justify-self:end}
.focus-btn {
  display:inline-flex;align-items:center;justify-content:center;gap:.38em;min-height:36px;
  padding:6px 13px;max-width:100%;border:1px solid var(--focus-edge);border-radius:8px;
  background:var(--card);color:var(--ink);font:600 14px/1.45 var(--sans);cursor:pointer;
}
.focus-btn:focus-visible,.focus-dialog :is(input,select):focus-visible {outline:2px solid var(--red);outline-offset:2px}
.focus-btn:enabled:hover {border-color:var(--focus-action);color:var(--focus-action)}
.focus-btn:disabled {opacity:.5;cursor:default}
.focus-primary {background:var(--focus-action);border-color:var(--focus-action);color:var(--focus-on-action)}
.focus-primary:enabled:hover {background:var(--red-dark);color:var(--focus-on-action)}
.focus-soft {background:var(--focus-wash);color:var(--red-dark)}
.focus-text {background:transparent;border-color:transparent;color:var(--red-dark);padding-inline:6px}
.focus-mini {min-width:82px;padding:5px 10px;border-radius:100px;background:var(--focus-wash);color:var(--red-dark);gap:7px;letter-spacing:.01em;font-size:13px;white-space:nowrap}
.focus-mini-value {font-variant-numeric:tabular-nums}
.focus-clock-icon {display:inline-block;position:relative;width:15px;height:15px;flex:none;border-radius:50%;border:1.5px solid currentColor;}
.focus-clock-icon::before {content:"";position:absolute;left:6px;top:2px;height:5px;border-left:1.5px solid currentColor}
.focus-clock-icon::after {content:"";position:absolute;left:6px;top:6px;height:4px;border-left:1.5px solid currentColor;transform:rotate(-50deg);transform-origin:top}
.focus-mini[data-phase="short"],.focus-mini[data-phase="long"] {color:var(--focus-rest)}
.focus-mini[data-status="due"] {box-shadow:0 0 0 3px color-mix(in srgb,var(--focus-action) 25%,transparent);color:var(--red-dark)}
#focus-mini.focus-detached:not(.sheet-bar #focus-mini) > .focus-mini {position:fixed;z-index:6;inset:auto max(12px,env(safe-area-inset-right)) max(14px,env(safe-area-inset-bottom)) auto;box-shadow:var(--focus-shade)}
.sheet-bar #focus-mini {justify-self:auto;min-block-size:30px;margin-right:auto}
.sheet-bar #focus-mini .focus-mini {position:static;min-width:62px;min-height:30px;padding:3px 8px;border:1px solid var(--focus-edge);border-radius:100px;font-size:12px;background:var(--focus-wash)}
.focus-board {margin-block:15px;padding:clamp(16px,2.5vw,26px);border:1px solid var(--focus-edge);border-radius:14px;background:var(--card);position:relative}
:root[data-theme="space"] .focus-board {background:linear-gradient(112deg,#132335,#101a2c 62%,#182039)}
.focus-row-head {display:flex;align-items:center;justify-content:space-between;gap:8px 15px;flex-wrap:wrap}
.focus-row-head :is(h3,h4),.focus-body :is(h3,h4) {margin:0;line-height:1.4}
.focus-board h3,.focus-body h3 {font:700 19px/1.4 var(--serif)}
.focus-board h4,.focus-body h4 {font:650 15px/1.4 var(--sans)}
.focus-description,.focus-empty,.focus-next {color:var(--soft);font-size:13px;line-height:1.6;margin:0;overflow-wrap:anywhere}
.focus-empty {padding-block:10px}
.focus-board-metrics,.focus-result-metrics {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;max-width:620px;margin:16px 0 19px}
.focus-metric {min-width:0;display:grid;align-content:start;gap:4px;border-left:2px solid var(--focus-rim);padding-left:12px}
.focus-metric strong {font-size:clamp(16px,2.1vw,24px);font-weight:700;line-height:1.15;color:var(--ink);font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.focus-metric span,.focus-task-copy small,.focus-history-entry small,.focus-week-col small {color:var(--soft);font-size:12px}
.focus-subhead {border-top:1px solid var(--rule);padding-top:12px}
.focus-task {display:flex;align-items:center;gap:6px 12px;justify-content:space-between;padding-block:11px;border-bottom:1px solid var(--rule)}
.focus-task-copy {display:grid;gap:2px;min-width:0}
.focus-task-copy strong,.focus-history-entry strong,.focus-current-task {overflow-wrap:anywhere}
.focus-task-actions,.focus-actions,.focus-board-footer {display:flex;align-items:center;flex-wrap:wrap;gap:7px}
.focus-task-actions {flex-shrink:0;gap:3px}
.focus-task-actions .focus-btn {font-size:13px;min-height:31px;padding:4px 8px}
.focus-task-done {font-size:13px;white-space:nowrap;color:var(--olive)}
.focus-board-footer {border-top:1px solid var(--rule);padding-top:9px;justify-content:flex-end}
.focus-task-list:has(.focus-task:last-child) + .focus-board-footer {border-top:0}
.focus-dialog {
  padding:0;width:min(460px,calc(100% - 24px));max-height:min(88vh,760px);max-height:min(88dvh,760px);
  box-sizing:border-box;border:1px solid var(--focus-edge);border-radius:17px;
  background:var(--card);color:var(--ink);box-shadow:var(--focus-shade);overflow:auto;overscroll-behavior:contain;
}
.focus-dialog::backdrop {background:#1c202b75}
:root[data-theme="space"] .focus-dialog {background:linear-gradient(150deg,#142037,#101a2c 52%,#121d32)}
:root[data-theme="space"] .focus-dialog::backdrop {background:#0308179c}
.focus-dialog-head {display:flex;align-items:center;justify-content:space-between;gap:12px;padding:15px 19px 8px}
.focus-dialog-head h2 {font:700 23px/1.3 var(--serif);margin:0}
.focus-tabs {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;margin:6px 19px 0;padding:3px;border:1px solid var(--rule);border-radius:10px;background:var(--focus-wash)}
.focus-tab {border-color:transparent;border-radius:7px;min-width:0;min-height:32px;padding:4px 0;background:transparent;font-size:13px;color:var(--soft)}
.focus-tab[aria-pressed="true"] {color:var(--red-dark);background:var(--card);border-color:var(--focus-edge)}
.focus-body {padding:19px;min-height:120px}
.focus-status {color:var(--soft);font-size:13px;padding:0 19px 13px;line-height:1.5}
.focus-status:empty {padding:0;display:none}
.focus-timer {display:grid;gap:13px}
.focus-dial-wrap {
  --face-dot:#c8a879;
  display:grid;place-items:center;min-height:183px;border:1px solid var(--rule);border-radius:12px;
  background:radial-gradient(ellipse at center,var(--focus-dial) 27%,var(--focus-wash) 100%);position:relative;isolation:isolate;overflow:hidden;
}
:root[data-theme="space"] .focus-dial-wrap {
  background:radial-gradient(ellipse at 47% 45%,#234651,#14223a 52%,#111a2f 82%);border-color:#344663;
}
:root[data-theme="space"] .focus-dial-wrap::before {
  content:"";position:absolute;z-index:-1;inset:0;opacity:.9;
  background:radial-gradient(circle at 7% 67%,#c5c9fa 0 1px,transparent 1.7px),radial-gradient(circle at 16% 25%,#cde7ff 0 1.2px,transparent 2px),radial-gradient(circle at 26% 75%,#92b6d8 0 1px,transparent 1.6px),radial-gradient(circle at 79% 33%,#edd0aa 0 1.3px,transparent 2px),radial-gradient(circle at 90% 70%,#b8dcf0 0 1px,transparent 2px),radial-gradient(circle at 65% 16%,#adc2e6 0 .8px,transparent 1.6px);
}
.focus-face {--sweep:0deg;--dial-hand:var(--focus-action);height:155px;width:155px;position:relative;display:grid;place-items:center;isolation:isolate;border-radius:100%;background:conic-gradient(var(--dial-hand) var(--sweep),var(--focus-rim) 0);box-shadow:0 0 0 5px var(--focus-dial),0 0 0 6px var(--focus-rim)}
.focus-face[data-phase="short"],.focus-face[data-phase="long"] {--dial-hand:var(--focus-rest)}
.focus-face::before,.focus-face::after {content:"";position:absolute;border-radius:50%;pointer-events:none}
.focus-face::before {inset:4px;z-index:-1;background:repeating-conic-gradient(from 0deg,var(--focus-edge) 0deg 1deg,transparent 1deg 10deg),var(--focus-dial)}
.focus-face::after {inset:10px;z-index:-1;background:var(--focus-dial)}
:root[data-theme="space"] .focus-face {box-shadow:0 0 0 5px #111e32,0 0 0 6px #59748a,0 0 33px #7ddad222}
.focus-clock-face {display:grid;justify-items:center;gap:3px}
.focus-phase {font-size:12px;color:var(--red-dark);font-weight:650;letter-spacing:.08em}
.focus-time {font:650 32px/1.2 ui-monospace,"SFMono-Regular",Consolas,monospace;letter-spacing:-.055em;font-variant-numeric:tabular-nums;color:var(--ink)}
.focus-current-task,.focus-next,.focus-center {text-align:center;justify-content:center}
.focus-center .focus-btn {min-height:41px}
.focus-form,.focus-tasks-pane,.focus-history {display:grid;gap:13px}
.focus-form-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.focus-field {display:grid;align-content:start;gap:5px;color:var(--soft);font-size:13px;min-width:0}
.focus-field input,.focus-field select {width:100%;min-width:0;min-height:40px;padding:7px 10px;border:1px solid var(--focus-edge);border-radius:7px;background:var(--card);font:inherit;font-size:16px;color:var(--ink)}
.focus-new-task {background:var(--focus-wash);padding:14px;border:1px solid var(--rule);border-radius:9px}
.focus-form > .focus-primary {justify-self:start}
.focus-check {display:inline-flex;align-items:center;gap:8px;font-size:14px}
.focus-check input {width:17px;height:17px;accent-color:var(--focus-action)}
.focus-result {border-top:1px solid var(--rule);padding-top:13px}
.focus-result:first-child,.focus-history>.focus-result {border-top:0;padding-top:0}
.focus-result .focus-result-metrics {margin-block:14px}
.focus-chip {padding:2px 6px;border-radius:5px;color:var(--red-dark);font-size:12px;background:var(--focus-wash)}
.focus-review-list {display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.focus-sense {text-align:left;justify-content:flex-start;overflow-wrap:anywhere;font-size:13px;white-space:normal;height:auto}
.focus-week {display:grid;grid-template-columns:repeat(7,minmax(0,1fr));align-items:stretch;gap:4px;padding:11px 5px 7px;background:var(--focus-wash);border-radius:9px}
.focus-week-col {display:grid;justify-items:center;gap:3px;min-width:0}
.focus-week-bar {width:60%;height:42px;display:block;border-radius:4px 4px 0 0;border-bottom:1px solid var(--focus-edge);background:linear-gradient(to top,var(--focus-action) var(--fill),transparent var(--fill))}
.focus-week-value,.focus-week-col small {font-size:10px;color:var(--soft);font-variant-numeric:tabular-nums}
.focus-dist-row,.focus-history-entry {display:flex;align-items:center;justify-content:space-between;gap:8px;border-bottom:1px solid var(--rule);padding-block:7px;overflow-wrap:anywhere}
.focus-dist-row strong,.focus-history-entry>span:last-child {white-space:nowrap;font-size:13px;font-weight:600}
.focus-history-entry {border-width:0 0 1px;border-radius:0;text-align:left;background:transparent;padding:4px 0 9px;width:100%}
.focus-history-entry span:first-child {display:grid}
@media(max-width:1020px) {
  .topbar-inner:has(#focus-mini) {grid-template-columns:minmax(0,1fr) auto auto auto;grid-template-areas:"brand timer progress switch" "modes modes modes modes";padding-top:6px;gap:0 12px}
  .topbar-inner:has(#focus-mini) .brand {grid-area:brand}
  .topbar-inner:has(#focus-mini) .completion {grid-area:progress}
  .topbar-inner:has(#focus-mini) .theme-switch {grid-area:switch}
  .topbar-inner:has(#focus-mini) #focus-mini {grid-area:timer}
  .topbar-inner:has(#focus-mini) .modes {grid-area:modes;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));width:100%;justify-self:stretch}
  .topbar-inner:has(#focus-mini) .mode {min-height:39px}
}
@media(max-width:595px) {
  .topbar-inner:has(#focus-mini) {grid-template-columns:minmax(0,1fr) auto auto;grid-template-areas:"brand timer switch" "modes modes progress";gap:3px 6px}
  .topbar-inner:has(#focus-mini) .completion {width:60px;justify-self:end}
  .topbar-inner:has(#focus-mini) .mode {font-size:12px;padding-inline:0}
  .topbar-inner:has(#focus-mini) .modes {gap:0}
  .focus-mini {min-width:65px;min-height:32px;padding:4px 7px;font-size:12px;gap:5px}
  #focus-mini {min-block-size:32px}
  .focus-dialog:modal {width:min(460px,calc(100% - 16px));max-height:92dvh}
  .focus-body {padding:14px}
  .focus-dialog-head {padding:12px 14px 6px}
  .focus-tabs {margin-inline:14px}
}
@media(max-width:370px) {
  .focus-board {padding:13px}
  .focus-metric {padding-left:6px}
  .focus-task {align-items:flex-start;flex-wrap:wrap}
  .focus-task-actions {margin-left:auto}
  .focus-btn {font-size:13px}
  .focus-time {font-size:29px}
  .focus-mini {font-size:11px}
}
.focus-time-detail {margin:0 0 8px}
.focus-mini[data-status="paused"] .focus-clock-icon {border:0;border-radius:0}
.focus-mini[data-status="paused"] .focus-clock-icon::before,.focus-mini[data-status="paused"] .focus-clock-icon::after {width:2px;height:10px;top:2.5px;transform:none;border:0;background:currentColor}
.focus-mini[data-status="paused"] .focus-clock-icon::before {left:4px}
.focus-mini[data-status="paused"] .focus-clock-icon::after {left:9px}

/* The small station and night sky are vector scenery; the dial always remains the foreground. */
.focus-dial-art {position:absolute;inset:0;width:100%;height:100%;z-index:-1;pointer-events:none}
.focus-space-art,:root[data-theme="space"] .focus-city-art {display:none}
:root[data-theme="space"] .focus-space-art {display:inline}
.focus-tram {transform:translateX(39px)}
.focus-orbit-turn {transform:rotate(-23deg)}
:root[data-theme="space"] .focus-dial-wrap:is([data-phase="short"],[data-phase="long"]) {
  background:radial-gradient(ellipse at 45% 42%,#373954,#202840 56%,#141c32 86%);
}
.focus-review-list {display:grid;gap:9px}
.focus-review-word {display:flex;flex-wrap:wrap;align-items:center;gap:5px 8px}
.focus-review-word > strong {font:650 17px/1.5 var(--serif);color:var(--ink)}
.focus-moment {
  position:fixed;inset:auto max(14px,env(safe-area-inset-right)) max(70px,calc(env(safe-area-inset-bottom) + 58px)) auto;
  margin:0;padding:5px 13px 5px 4px;max-width:calc(100vw - 24px);width:max-content;box-sizing:border-box;
  border:1px solid var(--focus-edge);border-radius:12px;background:var(--card);color:var(--ink);
  box-shadow:var(--focus-shade);z-index:18;pointer-events:none;
}
.focus-moment:popover-open,.focus-moment:not([popover]) {display:flex;align-items:center;gap:7px}
@supports not selector(:popover-open) {.focus-moment {display:flex;align-items:center;gap:7px}}
.focus-moment svg {width:76px;height:44px;flex:none}
.focus-moment-copy {display:grid;gap:2px;line-height:1.4;min-width:0}
.focus-moment-copy strong {font:700 16px/1.4 var(--serif)}
.focus-moment-copy small {font-size:12px;color:var(--soft)}
:root[data-theme="space"] .focus-moment {background:linear-gradient(120deg,#1e3045,#141e31)}
@media (prefers-reduced-motion:no-preference) {
  /* Only the open clock and the active miniature clock move. All motion uses opacity or transforms. */
  .focus-dial-wrap[data-status="running"] .focus-tram {animation:focus-tram-cross 16s linear -3s infinite}
  .focus-dial-wrap[data-status="running"] .focus-tree {transform-origin:0 49px;animation:focus-branches 5s ease-in-out infinite alternate}
  .focus-dial-wrap[data-status="running"] .focus-orbit-turn {animation:focus-orbit 24s linear infinite}
  .focus-dial-wrap[data-status="running"] .focus-moon {animation:focus-moonrise 7s ease-in-out infinite alternate}
  .focus-dial-wrap[data-status="running"] .focus-starlight {animation:focus-twinkle 4.5s ease-in-out infinite alternate}
  .focus-mini[data-status="running"] .focus-clock-icon::before {transform-origin:50% 100%;animation:focus-minute-hand 60s linear infinite}
  :root[data-theme="space"] .focus-mini[data-status="running"] .focus-clock-icon {
    border-color:color-mix(in srgb,currentColor 55%,transparent);animation:focus-orbit 15s linear infinite;
  }
  :root[data-theme="space"] .focus-mini[data-status="running"] .focus-clock-icon::before {
    animation:none;top:-2px;left:5px;width:4px;height:4px;border:0;border-radius:50%;background:currentColor;
  }
  :root[data-theme="space"] .focus-mini[data-status="running"] .focus-clock-icon::after {
    border:0;width:3px;height:3px;left:5px;top:5px;border-radius:50%;background:currentColor;
  }
  .focus-moment {animation:focus-moment-in .28s ease-out both}
  .focus-arrive {animation:focus-tram-arrive 1.55s cubic-bezier(.16,.72,.24,1) both}
  .focus-sunrise {animation:focus-daybreak 1.5s ease-out both}
  .focus-constellation {stroke-dasharray:110;animation:focus-connect 1.15s ease-out both}
  .focus-spark {transform-origin:63px 10px;animation:focus-light-star .75s .58s ease-out both}
  .focus-comet {animation:focus-comet-rise 1.4s cubic-bezier(.2,.7,.27,1) both}
}
@keyframes focus-tram-cross {0%{transform:translateX(-39px)}100%{transform:translateX(400px)}}
@keyframes focus-branches {from{transform:rotate(-2deg)}to{transform:rotate(3deg)}}
@keyframes focus-orbit {from{transform:rotate(-23deg)}to{transform:rotate(337deg)}}
@keyframes focus-moonrise {to{transform:translate(1px,-4px)}}
@keyframes focus-twinkle {from{opacity:.45}to{opacity:1}}
@keyframes focus-minute-hand {to{transform:rotate(360deg)}}
@keyframes focus-moment-in {from{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}
@keyframes focus-tram-arrive {from{transform:translateX(-58px)}to{transform:translateX(0)}}
@keyframes focus-daybreak {from{opacity:.35;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
@keyframes focus-connect {from{stroke-dashoffset:110}to{stroke-dashoffset:0}}
@keyframes focus-light-star {from{opacity:.3;transform:scale(.45)}to{opacity:1;transform:scale(1)}}
@keyframes focus-comet-rise {from{opacity:.3;transform:translate(-27px,16px)}to{opacity:1;transform:translate(0)}}

#share-dialog {
  box-sizing:border-box; width:min(39rem,calc(100% - 24px)); max-height:90vh; max-height:90dvh;
  padding:clamp(15px,3vw,24px); border:1px solid var(--rule); border-radius:18px;
  color:var(--ink); background:var(--card); box-shadow:0 20px 72px #080c172e;
  overflow:auto; overscroll-behavior:contain;
}
#share-dialog::backdrop {background:#16162280}
.share-heading {display:flex; align-items:center; justify-content:space-between; gap:1rem; margin:0 0 14px}
.share-heading h2 {margin:0; font:700 1.35rem/1.35 var(--serif)}
#share-close {padding:7px; background:transparent; color:var(--red-dark); font:650 .85rem var(--sans)}
.share-layout {display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:clamp(16px,3vw,26px); align-items:center}
.share-figure {margin:0; overflow:hidden; border-radius:10px; box-shadow:0 3px 14px #060c181f}
.share-figure :is(canvas,img) {display:block; width:100%; height:auto; aspect-ratio:3/4}
#share-dialog[data-format="story"] .share-figure :is(canvas,img) {aspect-ratio:9/16}
#share-dialog [hidden] {display:none!important}
.share-details {min-width:0}
.share-kind {display:flex; flex-wrap:wrap; gap:4px; padding:4px; border-radius:10px; background:var(--paper); border:1px solid var(--rule)}
.share-kind button {flex:1; min-height:36px; border-radius:6px; padding:3px; color:var(--soft); background:transparent; font:650 .85rem var(--sans)}
.share-kind button[aria-pressed="true"] {color:var(--red-dark); background:var(--card); box-shadow:0 1px 4px #1815242b}
#share-summary {margin:15px 0; color:var(--ink); font-size:.94rem; line-height:1.65; overflow-wrap:anywhere}
.share-actions {display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px}
.share-actions :is(a,button) {display:grid; place-items:center; box-sizing:border-box; min-height:42px; padding:6px 3px; border:1px solid var(--rule); border-radius:8px; color:var(--ink); background:var(--paper); text-decoration:none; font:650 .82rem/1.4 var(--sans); cursor:pointer}
#share-save {color:var(--card); background:var(--red-dark); border-color:var(--red-dark)}
.share-actions button:disabled {opacity:.55; cursor:wait}
#share-help,#share-status {color:var(--soft); margin:12px 0; font-size:.81rem; line-height:1.65}
#share-status:empty {margin:0}
#share-visit {color:var(--red-dark); font-size:.83rem; text-underline-offset:3px}
#share-instagram[aria-expanded="true"] {border-color:var(--red-dark)}
#share-instagram-guide {
  margin:9px 0 0; padding:11px 13px; border-inline-start:2px solid var(--red-dark);
  border-radius:4px; color:var(--ink); background:var(--paper); font-size:.85rem; line-height:1.55
}
#share-instagram-guide p {margin:0 0 6px}
#share-instagram-guide :is(a,button) {
  display:inline-block; padding:5px 0; color:var(--red-dark); background:none;
  font:650 .83rem/1.5 var(--sans); text-decoration:underline; text-underline-offset:3px; cursor:pointer
}
#share-instagram-send {margin-inline-end:10px}
#share-url {display:block; width:100%; margin:6px 0; padding:8px; color:var(--ink); background:var(--paper); border:1px solid var(--rule); border-radius:5px}
.share-load-error {font-size:.84rem; color:var(--soft)}
@media(max-width:540px) {
  .share-layout {grid-template-columns:minmax(0,1fr); gap:12px}
  .share-figure {width:min(58vw,24vh,195px); width:min(58vw,28dvh,195px); justify-self:center}
  #share-dialog[data-format="story"] .share-figure {width:min(48vw,23dvh,160px)}
  #share-summary {margin:8px 0}
  #share-help,#share-status {margin:7px 0}
}

:root:not(:lang(zh)) .brand-lockup {min-width:0;letter-spacing:normal}
:root:not(:lang(zh)) .brand-lockup strong {letter-spacing:0;line-height:1.15}
:root:not(:lang(zh)) .brand-lockup small {letter-spacing:0;white-space:normal}
:root:not(:lang(zh)) .mode {white-space:normal;line-height:1.2}
@media(max-width:600px) {
  .page-heading .atlas-tools {display:flex; flex-wrap:wrap; justify-content:flex-end; align-items:center;gap:5px 8px}
  .atlas-tools .map-counts {margin-inline-end:auto}
  :root:not(:lang(zh)) .brand-lockup strong {font-size:14px}
  :root:not(:lang(zh)) .brand-lockup small {font-size:9px}
}

:root:not(:lang(zh)) .map-surface .station[data-depth="0"] .station-title {
  display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2;
  white-space:normal; overflow:hidden; text-wrap:balance; line-height:1.12;
}
.course-locale-status {margin:.5rem auto;padding:.5rem 1rem;max-width:80rem;color:var(--ink);font-size:.9rem}
.course-locale-status button {margin-inline-start:.6rem;color:inherit;text-decoration:underline;cursor:pointer}

/* Keep global actions available while the learning mode changes. */
.topbar .topbar-inner:has(#focus-mini, > .site-tools) {
  grid-template-columns:auto minmax(0,1fr) auto auto auto auto;
  grid-template-areas:"brand modes timer progress switch tools";
  column-gap:clamp(8px,1.1vw,18px);
}
.topbar-inner > .brand {grid-area:brand}
.topbar-inner > .modes {grid-area:modes}
.topbar-inner > #focus-mini {grid-area:timer}
.topbar-inner > .completion {grid-area:progress}
.topbar-inner > .theme-switch {grid-area:switch}
.topbar-inner > .site-tools {grid-area:tools}
@media(max-width:1180px) {
  .topbar .topbar-inner:has(#focus-mini, > .site-tools) {
    grid-template-columns:minmax(0,1fr) auto auto auto auto;
    grid-template-areas:"brand timer progress switch tools" "modes modes modes modes modes";
    padding-top:5px;
  }
  .topbar-inner:has(#focus-mini, > .site-tools) .modes {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));width:100%}
  .topbar-inner:has(#focus-mini, > .site-tools) .mode {min-height:39px}
}
@media(max-width:650px) {
  .topbar .topbar-inner:has(#focus-mini, > .site-tools) {
    grid-template-columns:auto minmax(0,1fr) auto;
    grid-template-areas:"brand brand tools" "timer progress switch" "modes modes modes";
    gap:2px 10px;
  }
  .topbar-inner:has(#focus-mini, > .site-tools) #focus-mini {justify-self:start}
  .topbar-inner:has(#focus-mini, > .site-tools) .completion {width:100%;min-width:0;max-width:140px;justify-self:center}
  .topbar-inner:has(#focus-mini, > .site-tools) .completion-label {gap:2px;font-size:10px;flex-wrap:wrap}
  .topbar-inner:has(#focus-mini, > .site-tools) .mode {min-width:0;min-height:40px;overflow-wrap:anywhere;padding:3px}
  .topbar-inner:has(#focus-mini, > .site-tools) .brand {min-width:0}
  .topbar-inner:has(#focus-mini, > .site-tools) .brand-lockup {white-space:normal}
  .topbar-inner:has(#focus-mini, > .site-tools) .theme-switch {justify-self:end}
}

/* Shared by the learning map, public introduction and static word lists. */
.site-tools {
  --utility-ink:#4e483e; --utility-border:#d6cbbb; --utility-surface:#fffcf6;
  --utility-hover:#f2ece0; --utility-active:#883d30; --utility-shadow:#37261525;
  display:inline-flex; align-items:center; justify-self:end; flex:none;
  gap:2px; color:var(--utility-ink);
}
:root[data-theme="space"] .site-tools {
  --utility-ink:#c4d3e9; --utility-border:#34435c; --utility-surface:#172235;
  --utility-hover:#223149; --utility-active:#a5eddf; --utility-shadow:#0007;
}
.site-tools .utility-share, .site-tools .language-menu > summary {
  box-sizing:border-box; width:42px; height:42px; display:grid; place-items:center;
  margin:0; padding:0; border:0; border-radius:9px; background:transparent;
  color:inherit; text-decoration:none; cursor:pointer; list-style:none; touch-action:manipulation;
}
.site-tools .language-menu > summary::-webkit-details-marker { display:none; }
.site-tools .language-menu > summary::after { content:none; }
.site-tools > a:hover, .site-tools .language-menu > summary:hover, .site-tools details[open] > summary {
  background:var(--utility-hover); color:var(--utility-active);
}
.site-tools :is(a,button,summary):focus-visible { outline:2px solid var(--utility-active); outline-offset:2px; }
.site-tools svg { display:block; width:20px; height:20px; }
.site-tools .language-menu { position:relative; flex:none; margin:0; padding:0; border:0; background:transparent; }
.site-tools [hidden] { display:none!important; }
.site-tools .language-options {
  box-sizing:border-box; position:absolute; z-index:20; inset-block-start:calc(100% + 4px); inset-inline-end:0;
  width:max-content; min-width:10.5rem; max-width:min(19rem,90vw); padding:5px; border-radius:12px;
  border:1px solid var(--utility-border); background:var(--utility-surface); box-shadow:0 8px 26px var(--utility-shadow);
}
.site-tools .language-links { display:grid; grid-template-columns:1fr; gap:0; margin:0; }
.site-tools .language-options :is(button,a) {
  box-sizing:border-box; display:flex; align-items:center; justify-content:space-between; gap:16px;
  width:100%; min-height:38px; margin:0; padding:6px 11px; border:0; border-radius:7px;
  color:var(--utility-ink); background:transparent; text-decoration:none; text-align:start;
  font:500 .9rem/1.35 system-ui,sans-serif; cursor:pointer;
}
.site-tools .language-options [data-language-auto] { margin-block-end:3px; }
.site-tools .language-options :is(a,button):hover,
.site-tools .language-options :is(a,button):focus-visible { background:var(--utility-hover); }
.site-tools [data-language-auto][aria-pressed="true"]::after,
.site-tools .language-menu:not([data-automatic="true"]) .language-links :is([aria-current="page"],[aria-pressed="true"])::after {
  content:""; width:7px; height:4px; border-left:2px solid var(--utility-active); border-bottom:2px solid var(--utility-active); transform:rotate(-45deg);
}
@media (pointer:coarse) {
  .site-tools .utility-share, .site-tools .language-menu > summary { width:44px; height:44px; }
  .site-tools .language-options :is(button,a) { min-height:44px; }
}
@media(forced-colors:active) {
  .site-tools { --utility-active:Highlight; --utility-border:ButtonText; }
  .site-tools .language-options { border-color:CanvasText; }
}

.site-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 24px;
  margin: 20px 0 24px;
  padding: 10px 0 0;
  border-top: 1px solid var(--rule, var(--line));
  color: var(--soft);
  font-size: .8rem;
}
.site-footer a { color: inherit; text-decoration: none; text-underline-offset: .22em; }
.site-footer a:hover { text-decoration: underline; }
.community-links, .level-index, .footer-credits {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.site-footer .community-links {
  gap: 0 clamp(14px, 2vw, 27px);
  margin-inline-end: auto;
  color: var(--red-dark, var(--accent));
  font-size: .92rem;
  font-weight: 650;
}
.community-links a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.community-links svg {
  flex: none; fill: none; stroke: currentColor; stroke-width: 1.65;
  stroke-linecap: round; stroke-linejoin: round;
}
.site-footer .level-index { gap: 0 12px; }
.site-footer .level-index a { display: inline-flex; align-items: center; min-height: 38px; }
.footer-credits { gap: 0 14px; color: var(--quiet, var(--soft)); font-size: .75rem; }
.footer-credits a { display: inline-block; padding-block: 6px; }
.level-index + .footer-credits { flex-basis: 100%; }
@media (max-width: 680px) {
  .site-footer { align-items: flex-start; flex-direction: column; }
  .site-footer .community-links { column-gap: 15px; }
  .site-footer .level-index { gap: 0 15px; }
}
