:root {
  color-scheme: light;
  --bg: #fff3e6;
  --shell: #fffaf2;
  --panel: #fffdf8;
  --panel-soft: #fff1df;
  --ink: #4b3a30;
  --ink-soft: #6f5a4b;
  --muted: #9b806b;
  --line: #ecd7c2;
  --red: #ee7766;
  --red-deep: #b94d40;
  --teal: #68bca5;
  --blue: #6ba6c9;
  --green: #78b987;
  --gold: #efa75d;
  --violet: #b18ac8;
  --sakura: #f8c9cf;
  --shadow: 0 1px 2px rgba(107, 83, 65, 0.05), 0 18px 42px rgba(181, 117, 74, 0.11);
  --shadow-strong: 0 22px 60px rgba(181, 117, 74, 0.16);
  --sidebar-width: 310px;
  --header-height: 68px;
  --n5: #378d55;
  --n4: #72a84b;
  --n3: #d6851e;
  --n2: #d25749;
  --n1: #7d4ba0;
  --kanji-color: #4b3a30;
}

body.dark {
  color-scheme: dark;
  --bg: #3a3029;
  --shell: #493b31;
  --panel: #514236;
  --panel-soft: #604c3d;
  --ink: #fff4e6;
  --ink-soft: #ead6bf;
  --muted: #d5b99d;
  --line: #7a5e49;
  --red: #ff7364;
  --red-deep: #ff9a8e;
  --teal: #65c6bd;
  --blue: #7db8e5;
  --green: #82d59c;
  --gold: #edbc64;
  --violet: #c4a4eb;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.26), 0 16px 40px rgba(0, 0, 0, 0.28);
  --shadow-strong: 0 22px 62px rgba(0, 0, 0, 0.42);
  --kanji-color: #fff7ec;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #fff8ed 0, var(--bg) 360px, #fff7ec 100%);
  color: var(--ink);
  font-family: Inter, "SF Pro Text", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", "Microsoft YaHei", "PingFang SC", sans-serif;
  line-height: 1.72;
}
body.nav-open { overflow: hidden; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--red-deep); }
button,
input { font: inherit; }

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 200;
  padding: 10px 14px;
  border-radius: 6px;
  background: #7b5c45;
  color: #fffaf2;
}
.skip-link:focus { top: 16px; }

.guide-header {
  position: sticky;
  top: 0;
  z-index: 90;
  min-height: var(--header-height);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  padding: 10px 28px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
  background: color-mix(in srgb, var(--shell) 90%, transparent);
  backdrop-filter: blur(18px);
}

.guide-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.guide-brand img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(238, 119, 102, 0.18);
}
.guide-brand strong,
.guide-brand small { display: block; }
.guide-brand strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.05;
  letter-spacing: 0;
}
.guide-brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.guide-topnav {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.guide-topnav a,
.nav-toggle {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
}
.guide-topnav a:hover,
.guide-topnav a:focus-visible,
.nav-toggle:hover,
.nav-toggle:focus-visible {
  background: #fff0dc;
  color: var(--red-deep);
  outline: none;
}
.nav-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
}

.reading-progress {
  position: sticky;
  top: var(--header-height);
  z-index: 89;
  height: 3px;
  background: transparent;
}
.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--teal), var(--gold));
}

.guide-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  align-items: start;
}

.guide-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 3px);
  height: calc(100vh - var(--header-height) - 3px);
  overflow: auto;
  padding: 22px 18px 32px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--shell) 94%, transparent), color-mix(in srgb, #fff0dc 70%, var(--shell)));
}
.guide-sidebar h1 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.32;
}
.guide-sidebar .subtitle {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 12px;
}
.guide-sidebar nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.guide-sidebar nav > ul > li { margin-bottom: 3px; }
.guide-sidebar nav a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.38;
}
.guide-sidebar nav a:hover {
  background: #fff0dc;
  color: var(--red-deep);
}
.guide-sidebar nav a.active {
  background: linear-gradient(135deg, #f59a70, #f4c06e);
  color: #fffaf2;
  font-weight: 800;
}
.guide-sidebar nav ul ul { margin: 2px 0 8px 12px; }
.guide-sidebar nav ul ul a {
  padding: 5px 9px;
  color: var(--muted);
  font-size: 12.5px;
}

.guide-main {
  width: min(100%, 1180px);
  padding: 28px 44px 80px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 16px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 14%, rgba(248, 201, 207, 0.58), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(248, 214, 149, 0.52), transparent 30%),
    linear-gradient(135deg, #fffdf8 0%, #fff1df 54%, #e9f7ef 100%);
  box-shadow: var(--shadow);
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  background: #ffe3dc;
  color: var(--red-deep);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}
.hero h1 {
  margin: 18px 0 12px;
  max-width: 10ch;
  color: var(--ink);
  font-size: clamp(42px, 6vw, 72px);
  line-height: 0.98;
  letter-spacing: 0;
}
.hero p {
  margin: 0;
  max-width: 680px;
  color: var(--ink-soft);
  font-size: 16px;
}
.hero-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.hero-panel .stat {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 116px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}
.hero-panel .stat:nth-child(1) { border-top: 4px solid var(--red); }
.hero-panel .stat:nth-child(2) { border-top: 4px solid var(--teal); }
.hero-panel .stat:nth-child(3) { border-top: 4px solid var(--blue); }
.hero-panel .stat:nth-child(4) { border-top: 4px solid var(--gold); }
.hero-panel .stat:nth-child(5) {
  grid-column: 1 / -1;
  min-height: 92px;
  border-top: 4px solid var(--violet);
}
.hero-panel strong {
  color: var(--ink);
  font-size: 34px;
  line-height: 1;
}
.hero-panel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.source-note {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--gold) 42%, var(--line));
  border-radius: 8px;
  background: #fff6df;
  color: var(--ink-soft);
  font-size: 13px;
}
.source-note strong { color: var(--gold); }
.source-note span {
  flex: 1 1 240px;
  min-width: 0;
}

.guide-toolbar {
  position: sticky;
  top: calc(var(--header-height) + 14px);
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 10px 14px;
  align-items: center;
  margin: 0 0 24px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.search-field {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}
.search-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.search-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--shell);
  color: var(--ink);
  padding: 0 12px;
}
.search-field input:focus {
  outline: 2px solid color-mix(in srgb, var(--teal) 34%, transparent);
  border-color: var(--teal);
}
.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.toolbar-actions button,
.to-top,
.q-toggle {
  border: 1px solid var(--line);
  background: var(--shell);
  color: var(--ink);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}
.toolbar-actions button {
  min-height: 40px;
  padding: 0 12px;
  font-size: 13px;
}
.toolbar-actions button:hover,
.toolbar-actions button.active {
  border-color: #ef9c71;
  background: linear-gradient(135deg, #f28c70, #f5bc68);
  color: #fffaf2;
}
.search-meta {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

section.chapter {
  margin-bottom: 48px;
  scroll-margin-top: 120px;
}
section.chapter > h2 {
  margin: 0 0 16px;
  padding: 0 0 10px;
  border-bottom: 2px solid var(--line);
  color: var(--ink);
  font-size: 28px;
  line-height: 1.26;
  letter-spacing: 0;
}
section.chapter > h2::after {
  content: "";
  display: block;
  width: 88px;
  height: 3px;
  margin-top: 10px;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--teal));
}
section.chapter > h3 {
  margin: 32px 0 12px;
  padding-left: 12px;
  border-left: 4px solid var(--teal);
  color: var(--ink);
  font-size: 22px;
  line-height: 1.35;
  scroll-margin-top: 118px;
  letter-spacing: 0;
}
section.chapter > h4 {
  margin: 22px 0 8px;
  color: var(--ink);
  font-size: 17px;
}
section.chapter p { margin: 8px 0; }

.card,
.dialogue,
.confuse,
.register-card,
.quiz,
details.collapse {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(29, 37, 44, 0.03);
}
.card {
  padding: 18px 20px;
  margin: 12px 0;
}
.card:hover,
.dialogue:hover,
.confuse:hover {
  box-shadow: var(--shadow);
}
.card .title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.card .title-row h4 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
}
.card .meaning {
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
  margin-left: 6px;
}
.jlpt-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
}
.jlpt-N5 { background: var(--n5); }
.jlpt-N4 { background: var(--n4); }
.jlpt-N3 { background: var(--n3); }
.jlpt-N2 { background: var(--n2); }
.jlpt-N1 { background: var(--n1); }
.tag {
  display: inline-block;
  margin-right: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--teal) 12%, transparent);
  color: var(--teal);
  font-size: 12px;
}

.example {
  margin: 8px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--blue);
  border-radius: 0 6px 6px 0;
  background: var(--panel-soft);
  cursor: pointer;
}
.example:hover,
.dialogue .turn:hover { background: color-mix(in srgb, var(--teal) 10%, var(--panel-soft)); }
.example .jp,
.dialogue .jp {
  color: var(--ink);
  font-size: 16px;
}
.example .cn,
.dialogue .cn,
.alternatives .cn {
  color: var(--muted);
  font-size: 13px;
}
.example .cn {
  display: block;
  margin-top: 4px;
}
body.hide-cn .example .cn,
body.hide-cn .dialogue .cn,
body.hide-cn .alternatives .cn,
body.hide-cn .doc-translation { display: none; }
body.hide-cn .example.show-cn .cn { display: block; }

table.conj,
table.compare {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  overflow: hidden;
  border-radius: 8px;
}
table.conj th,
table.conj td,
.confuse table.compare th,
.confuse table.compare td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}
table.conj th,
.confuse table.compare th {
  background: linear-gradient(135deg, #f08970, #eaa95c);
  color: #fffaf2;
  font-weight: 800;
}
table.conj tr:nth-child(even) td { background: var(--panel-soft); }

ruby {
  ruby-position: over;
  color: var(--kanji-color);
}
rt {
  color: var(--muted);
  font-size: 0.55em;
  font-weight: normal;
  transition: opacity 0.2s;
}
body.no-furigana rt {
  opacity: 0;
  visibility: hidden;
}

.usecase,
.note,
.keypoints,
.doc-translation {
  border-radius: 6px;
  padding: 8px 14px;
  margin: 8px 0;
  font-size: 14px;
}
.usecase {
  border-left: 3px solid var(--blue);
  background: color-mix(in srgb, var(--blue) 8%, var(--panel-soft));
}
.usecase strong { color: var(--blue); }
.note {
  border-left: 3px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 10%, var(--panel-soft));
}
.note strong { color: var(--gold); }
.formula {
  display: inline-block;
  margin: 4px 0;
  padding: 4px 10px;
  border-radius: 6px;
  background: #7b5c45;
  color: #fffaf2;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 13px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--shell);
  padding: 4px 10px;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
}
.chip:hover {
  background: #f7d7aa;
  border-color: #efa75d;
  color: var(--ink);
}

.dialogue {
  padding: 16px 18px;
  margin: 14px 0;
}
.dialogue .scene {
  margin-bottom: 12px;
  padding: 8px 12px;
  border-left: 4px solid var(--red);
  border-radius: 4px;
  background: color-mix(in srgb, var(--red) 8%, var(--panel-soft));
  font-size: 14px;
}
.dialogue .scene strong { color: var(--red-deep); }
.dialogue .turn {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 3px solid transparent;
  border-radius: 0 6px 6px 0;
  background: var(--panel-soft);
}
.dialogue .turn.A { border-left-color: var(--blue); }
.dialogue .turn.B { border-left-color: var(--green); }
.dialogue .turn.C { border-left-color: var(--gold); }
.dialogue .speaker {
  display: inline-block;
  min-width: 64px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.dialogue .turn.A .speaker { color: var(--blue); }
.dialogue .turn.B .speaker { color: var(--green); }
.dialogue .turn.C .speaker { color: var(--gold); }
.dialogue .cn {
  display: block;
  margin-top: 3px;
  margin-left: 64px;
}
.dialogue .keypoints {
  margin-top: 12px;
  background: color-mix(in srgb, var(--teal) 8%, var(--panel-soft));
}
.dialogue .keypoints strong { color: var(--teal); }

.alternatives {
  margin: 8px 0 12px 12px;
  padding: 10px 14px;
  border: 1px dashed color-mix(in srgb, var(--gold) 70%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--gold) 7%, var(--panel));
}
.alternatives .alt-title {
  margin-bottom: 6px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
}
.alternatives .alt-item {
  margin: 6px 0;
  padding: 7px 10px;
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  background: var(--panel);
}
.alternatives .alt-label {
  display: inline-block;
  margin-bottom: 3px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--gold);
  color: #fff;
  font-size: 12px;
}
.alternatives .jp {
  font-size: 14px;
  line-height: 1.7;
}

.nat {
  display: inline-block;
  margin-left: 6px;
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 800;
  font-size: 13px;
}
.nat-best { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.nat-ok { color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, transparent); }
.nat-fml { color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, transparent); }
.nat-bad { color: var(--red-deep); background: color-mix(in srgb, var(--red) 12%, transparent); }
.nat-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--panel-soft);
  font-size: 13px;
}

.register-card {
  border-left: 4px solid var(--green);
  padding: 12px 16px;
  margin: 12px 0;
}
.register-card .reg-title {
  margin-bottom: 8px;
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
}
.register-card .reg-cn {
  margin-bottom: 8px;
  padding: 4px 10px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--green) 8%, var(--panel-soft));
  font-size: 13px;
}
.register-card .reg-row {
  margin: 6px 0;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--panel-soft);
}
.register-card .reg-label {
  display: inline-block;
  min-width: 70px;
  margin-right: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.register-card .reg-row.casual .reg-label { color: var(--blue); }
.register-card .reg-row.polite .reg-label { color: var(--red); }
.register-card .reg-row.business .reg-label { color: var(--violet); }
.register-card .reg-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.confuse {
  padding: 16px 18px;
  margin: 14px 0;
}
.confuse h4 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 17px;
}
.confuse .quick-rule {
  margin-top: 10px;
  padding: 8px 12px;
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  background: color-mix(in srgb, var(--gold) 10%, var(--panel-soft));
  font-size: 13px;
}

.quiz {
  margin: 24px 0 16px;
  padding: 18px 20px;
  border: 2px dashed color-mix(in srgb, var(--green) 70%, var(--line));
  background: color-mix(in srgb, var(--green) 7%, var(--panel));
}
.quiz h4 {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 18px;
}
.quiz .quiz-intro {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}
.quiz .q {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(29, 37, 44, 0.04);
}
.quiz .q-stem {
  margin-bottom: 8px;
  font-size: 14.5px;
}
.quiz .q-num {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  text-align: center;
  line-height: 22px;
  font-size: 12px;
  font-weight: 800;
}
.quiz .q-options {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
}
.quiz .q-options li {
  margin: 4px 0;
  padding: 7px 12px;
  border-left: 3px solid transparent;
  border-radius: 0 6px 6px 0;
  background: var(--panel-soft);
  cursor: pointer;
  font-size: 14px;
}
.quiz .q-options li:hover {
  background: color-mix(in srgb, var(--teal) 10%, var(--panel-soft));
  border-left-color: var(--teal);
}
.quiz .q-options li.correct {
  background: color-mix(in srgb, var(--green) 14%, transparent);
  border-left-color: var(--green);
  color: var(--green);
  font-weight: 800;
}
.quiz .q-options li.wrong {
  background: color-mix(in srgb, var(--red) 13%, transparent);
  border-left-color: var(--red);
  color: var(--red-deep);
  text-decoration: line-through;
}
.quiz .q-explain {
  display: none;
  margin-top: 8px;
  padding: 8px 12px;
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  background: color-mix(in srgb, var(--gold) 10%, transparent);
  font-size: 13px;
}
.quiz .q-explain.show { display: block; }
.q-toggle {
  margin-top: 8px;
  padding: 3px 10px;
  color: var(--muted);
  font-size: 12px;
}

.roadmap {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 12px;
}
.roadmap .path {
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  cursor: pointer;
}
.roadmap .path:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.roadmap .path.beginner { border-top: 4px solid var(--green); }
.roadmap .path.jlpt { border-top: 4px solid var(--blue); }
.roadmap .path.life { border-top: 4px solid var(--gold); }
.roadmap .path.work { border-top: 4px solid var(--red); }
.roadmap .path-icon {
  font-size: 27px;
  margin-bottom: 4px;
}
.roadmap .path-title {
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
}
.roadmap .path-desc {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 12px;
}
.roadmap .path-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
}
.roadmap .path-steps li { margin: 4px 0; }
.roadmap .path-steps a { color: var(--blue); }
.roadmap .step-num {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--panel-soft);
  color: var(--muted);
  text-align: center;
  line-height: 18px;
  font-size: 11px;
}

.gp-detail {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 5px 14px;
  margin: 10px 0 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--panel-soft);
  font-size: 13.5px;
}
.gp-detail .gp-label {
  color: var(--red);
  font-weight: 800;
  white-space: nowrap;
}
.gp-detail .gp-label.接续 { color: var(--blue); }
.gp-detail .gp-label.含义 { color: var(--green); }
.gp-detail .gp-label.场景 { color: var(--red); }
.gp-detail .gp-label.易错 { color: var(--gold); }
.gp-detail .gp-label.区别 { color: var(--violet); }
.gp-detail .gp-val code,
.gp-detail .gp-val .formula-mini {
  padding: 0 6px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--blue) 12%, transparent);
  color: var(--blue);
  font-family: "SF Mono", Menlo, monospace;
  font-size: 12.5px;
}

.grammar-template {
  margin: 12px 0;
  padding: 16px 18px;
  border: 1px dashed color-mix(in srgb, var(--blue) 70%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--blue) 6%, var(--panel));
}
.grammar-template .tpl-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  margin: 6px 0;
  font-size: 14px;
}
.grammar-template .tpl-label {
  color: var(--red);
  font-weight: 800;
}

.doc-template {
  margin: 12px 0;
  padding: 18px 20px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 6px;
  background: var(--shell);
  white-space: pre-wrap;
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", "PingFang SC", monospace;
  font-size: 14px;
  line-height: 1.9;
}
.doc-template .header {
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
  color: var(--red-deep);
  font-weight: 800;
}
.doc-template .placeholder {
  padding: 0 4px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--teal) 12%, transparent);
  color: var(--teal);
  font-size: 13px;
}
.doc-translation {
  margin-top: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
}

details.collapse {
  margin: 10px 0;
  padding: 4px 14px;
}
details.collapse > summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 0;
  color: var(--blue);
  font-weight: 800;
}
details.collapse > summary::before {
  content: "▶ ";
  display: inline-block;
  font-size: 10px;
}
details.collapse[open] > summary::before { transform: rotate(90deg); }

.game-arcade {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 12px;
}
.game-card {
  position: relative;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 20px;
  overflow: hidden;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--line) 82%, var(--gold));
  border-radius: 8px;
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--panel) 96%, white), color-mix(in srgb, var(--panel-soft) 78%, var(--panel))),
    var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.game-card::after {
  content: "";
  position: absolute;
  inset: auto 18px 16px 18px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--teal));
  opacity: 0.72;
}
.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--red) 48%, var(--line));
  box-shadow: var(--shadow-strong);
  outline: none;
}
.game-card .g-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: #fff0dc;
  font-size: 24px;
}
.game-card .g-title {
  color: var(--red-deep);
  font-size: 19px;
  font-weight: 900;
  line-height: 1.25;
}
.game-card .g-desc {
  flex: 1;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}
.game-card .g-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 10px;
}
.game-card .g-tag {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--teal) 14%, var(--panel));
  color: color-mix(in srgb, var(--teal) 68%, var(--ink));
  font-size: 12px;
  font-weight: 800;
}
.game-hint {
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--teal) 28%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--teal) 10%, var(--panel));
  color: var(--ink-soft);
  font-size: 14px;
}
.game-stage:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(75, 58, 48, 0.42);
  backdrop-filter: blur(10px);
}
.game-panel {
  width: min(100%, 680px);
  max-height: min(86vh, 760px);
  overflow: auto;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-strong);
}
.game-panel h3 {
  margin: 0 0 12px;
  color: var(--red-deep);
  font-size: 24px;
}
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink-soft);
  font-size: 14px;
}
.game-timer { color: var(--blue); font-weight: 900; }
.game-score { color: var(--green); font-weight: 900; }
.game-lives { color: var(--red-deep); }
.game-progress {
  height: 8px;
  margin: 10px 0 16px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 72%, transparent);
}
.game-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--red));
  transition: width 180ms ease;
}
.game-question {
  margin: 16px 0;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--gold) 26%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--gold) 10%, var(--panel));
  text-align: center;
}
.game-question .q-jp {
  font-size: 20px;
  line-height: 1.7;
}
.game-question .q-cn,
.game-question .q-scene {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}
.game-options {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}
.game-option {
  min-height: 48px;
  padding: 11px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--shell);
  color: var(--ink);
  cursor: pointer;
  font-size: 16px;
  line-height: 1.45;
}
.game-option:hover:not(:disabled),
.game-option:focus-visible:not(:disabled) {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 10%, var(--panel));
  outline: none;
}
.game-option:disabled { cursor: default; opacity: 0.88; }
.game-option.correct {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 15%, var(--panel));
  color: color-mix(in srgb, var(--green) 62%, var(--ink));
}
.game-option.wrong {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 12%, var(--panel));
  color: var(--red-deep);
}
.game-feedback {
  display: none;
  margin: 12px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  background: color-mix(in srgb, var(--gold) 12%, var(--panel));
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.6;
}
.game-feedback.show { display: block; }
.game-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.game-controls button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
}
.game-controls .primary {
  border-color: var(--red);
  background: var(--red);
  color: #fffaf2;
}
.game-result {
  padding: 18px;
  text-align: center;
}
.game-result .big-score {
  color: var(--red-deep);
  font-size: 48px;
  font-weight: 900;
  line-height: 1;
}
.game-result .grade {
  margin-top: 8px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 900;
}
.game-result .stars {
  margin: 8px 0;
  font-size: 26px;
}

.search-hidden { display: none !important; }
.to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 70;
  display: none;
  width: 44px;
  height: 44px;
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  box-shadow: var(--shadow-strong);
  font-size: 20px;
}
.to-top.show { display: block; }
mark.search-hit {
  background: #fff59d;
  color: #5b442f;
  padding: 0 2px;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 32%, transparent);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

@media (max-width: 1180px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .roadmap,
  .hero-panel,
  .game-arcade {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .guide-main {
    padding: 28px 28px 72px;
  }
}

@media (max-width: 920px) {
  .guide-header {
    grid-template-columns: auto auto;
    justify-content: space-between;
    padding: 10px 16px;
  }
  .guide-topnav { display: none; }
  .nav-toggle { display: inline-flex; }
  .guide-shell { grid-template-columns: 1fr; }
  .guide-sidebar {
    position: fixed;
    inset: var(--header-height) auto 0 0;
    z-index: 100;
    width: min(86vw, 350px);
    height: auto;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow-strong);
  }
  body.nav-open .guide-sidebar { transform: translateX(0); }
  .mobile-scrim:not([hidden]) {
    position: fixed;
    inset: var(--header-height) 0 0;
    z-index: 95;
    background: rgba(0, 0, 0, 0.36);
  }
  .guide-main {
    width: 100%;
    padding: 22px 18px 70px;
  }
  .guide-toolbar {
    position: static;
    grid-template-columns: 1fr;
  }
  .toolbar-actions { justify-content: flex-start; }
  section.chapter,
  section.chapter > h3 {
    scroll-margin-top: 92px;
  }
}

@media (max-width: 640px) {
  .guide-brand small { display: none; }
  .guide-main { padding-inline: 14px; }
  .hero {
    padding: 24px 18px;
  }
  .hero h1 {
    font-size: 38px;
  }
  .hero-panel,
  .roadmap,
  .game-arcade {
    grid-template-columns: 1fr;
  }
  .hero-panel .stat:nth-child(5) { grid-column: auto; }
  .game-panel {
    padding: 20px;
  }
  .game-stage:not([hidden]) {
    align-items: stretch;
    padding: 12px;
  }
  .search-field {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .toolbar-actions button {
    flex: 1 1 132px;
  }
  section.chapter > h2 { font-size: 24px; }
  section.chapter > h3 { font-size: 20px; }
  .gp-detail,
  .grammar-template .tpl-row { grid-template-columns: 1fr; }
  .dialogue .speaker {
    min-width: 0;
    margin-right: 6px;
  }
  .dialogue .cn { margin-left: 0; }
  .to-top {
    right: 14px;
    bottom: 14px;
  }
}
