:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #62666d;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --line: #ded8cd;
  --accent: #2f6f73;
  --accent-2: #a34d36;
  --gold: #b78a2f;
  --soft: #eef5f3;
  --shadow: 0 18px 45px rgba(34, 31, 26, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "YuGothic", "Noto Sans JP", sans-serif;
  line-height: 1.75;
}

button {
  font: inherit;
}

.app-header {
  background:
    linear-gradient(115deg, rgba(32, 33, 36, 0.82), rgba(47, 111, 115, 0.68)),
    radial-gradient(circle at 72% 20%, rgba(183, 138, 47, 0.45), transparent 30%),
    linear-gradient(135deg, #293233, #795442 56%, #d9c18e);
  color: #fff;
  min-height: 520px;
  padding: 20px clamp(18px, 4vw, 56px) 46px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1220px;
}

.brand {
  align-items: center;
  display: flex;
  font-weight: 700;
  gap: 12px;
}

.brand-mark {
  align-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  display: inline-flex;
  font-family: serif;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  align-items: center;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-size: 20px;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.hero {
  align-items: end;
  display: grid;
  gap: 36px;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  margin: 110px auto 0;
  max-width: 1220px;
}

.hero-copy {
  max-width: 760px;
}

.eyebrow {
  color: #f5d993;
  font-weight: 700;
  margin: 0 0 10px;
}

h1 {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  font-size: clamp(2.45rem, 5vw, 5.2rem);
  line-height: 1.14;
  margin: 0 0 22px;
}

.hero-copy p:last-child {
  font-size: 1.06rem;
  margin: 0;
  max-width: 680px;
}

.hero-panel {
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  padding: 22px;
}

.hero-character {
  filter: drop-shadow(0 16px 18px rgba(18, 20, 20, 0.24));
  height: 178px;
  justify-self: center;
  margin: -62px 0 4px;
  object-fit: contain;
  width: 178px;
}

.flow-step {
  align-items: center;
  display: flex;
  gap: 14px;
}

.flow-step span {
  align-items: center;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.86rem;
  font-weight: 700;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.flow-step strong {
  font-size: 1.05rem;
}

.flow-line {
  background: rgba(255, 255, 255, 0.3);
  height: 30px;
  margin-left: 21px;
  width: 2px;
}

.layout {
  display: grid;
  gap: 28px;
  grid-template-columns: 340px minmax(0, 1fr);
  margin: -34px auto 60px;
  max-width: 1220px;
  padding: 0 clamp(18px, 4vw, 56px);
}

.course-panel,
.lesson {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.course-panel {
  align-self: start;
  overflow: hidden;
  position: sticky;
  top: 16px;
}

.progress-box {
  background: #f4efe6;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

#progressLabel {
  display: block;
  font-weight: 800;
  margin-bottom: 10px;
}

.progress-track {
  background: #ddd4c7;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.progress-fill {
  background: linear-gradient(90deg, var(--accent), var(--gold));
  height: 100%;
  width: 0;
}

#unlockText {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 10px 0 0;
}

.utility-link {
  align-items: center;
  background: #fff;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  display: inline-flex;
  font-size: 0.92rem;
  font-weight: 800;
  justify-content: center;
  margin-top: 14px;
  min-height: 40px;
  padding: 8px 12px;
  text-decoration: none;
  width: 100%;
}

.lesson-list {
  display: grid;
  max-height: calc(100vh - 190px);
  overflow: auto;
}

.lesson-button {
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 2px;
  padding: 14px 18px;
  text-align: left;
}

.lesson-button:hover,
.lesson-button.selected {
  background: var(--soft);
}

.lesson-button.locked {
  color: #9a9288;
  cursor: not-allowed;
}

.lesson-button small {
  color: var(--muted);
  font-weight: 700;
}

.lesson-button:not(.locked) small {
  color: var(--accent);
}

.lesson {
  min-height: 760px;
  padding: clamp(22px, 4vw, 54px);
}

.lesson-header {
  border-bottom: 1px solid var(--line);
  margin-bottom: 30px;
  padding-bottom: 24px;
}

.lesson-kicker {
  color: var(--accent-2);
  font-weight: 800;
  margin: 0 0 8px;
}

.lesson h2 {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  font-size: clamp(1.9rem, 3vw, 3rem);
  line-height: 1.28;
  margin: 0 0 14px;
}

.lesson h3 {
  font-size: 1.32rem;
  line-height: 1.45;
  margin: 34px 0 12px;
}

.lead {
  color: var(--muted);
  font-size: 1.06rem;
  margin: 0;
}

.callout {
  background: #f7f3eb;
  border-left: 5px solid var(--gold);
  border-radius: 8px;
  margin: 24px 0;
  padding: 18px 20px;
}

.lesson-guide {
  align-items: center;
  background: #f4efe6;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 18px;
  grid-template-columns: 128px minmax(0, 1fr);
  margin: 0 0 28px;
  padding: 16px 18px;
}

.lesson-guide-image {
  filter: drop-shadow(0 10px 14px rgba(34, 31, 26, 0.12));
  height: 126px;
  object-fit: contain;
  width: 126px;
}

.lesson-guide figcaption {
  color: var(--muted);
}

.lesson-guide strong {
  color: var(--accent);
  display: block;
  font-size: 1.1rem;
}

.original-text {
  background: #292622;
  border: 1px solid #403a32;
  border-radius: 8px;
  color: #f7f3eb;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  line-height: 1.9;
  margin: 18px 0 28px;
  max-height: 360px;
  overflow: auto;
  padding: 18px 20px;
}

.original-text p {
  margin: 0 0 0.65rem;
  overflow-wrap: anywhere;
}

.deep-reading {
  background: #fffdfa;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  margin: 16px 0 28px;
  padding: 18px 20px;
}

.deep-reading p {
  margin: 0 0 0.85rem;
}

.deep-reading p:last-child {
  margin-bottom: 0;
}

.key-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 22px 0;
}

.key-card {
  background: var(--soft);
  border: 1px solid #d4e6e2;
  border-radius: 8px;
  padding: 16px;
}

.key-card strong {
  color: var(--accent);
  display: block;
  margin-bottom: 6px;
}

.diagram {
  background: #fbfaf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 24px 0;
  overflow: hidden;
  padding: 22px;
  position: relative;
}

.cause-flow {
  align-items: stretch;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
}

.cause-card,
.person-card,
.reading-block,
.tariki-side,
.tariki-center {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.cause-card span,
.person-card span,
.reading-block span,
.tariki-side span,
.tariki-center span {
  color: var(--muted);
  display: block;
  font-size: 0.84rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.cause-card strong,
.person-card strong,
.reading-block strong,
.tariki-side strong,
.tariki-center strong {
  color: var(--accent);
  display: block;
  font-size: 1.12rem;
  line-height: 1.35;
  margin-bottom: 8px;
}

.cause-card p,
.person-card p,
.reading-block p,
.tariki-side p,
.tariki-center p {
  margin: 0;
}

.cause-card.warning strong,
.response-side strong,
.tariki-side.self strong {
  color: var(--accent-2);
}

.cause-card.result strong,
.quote-side strong,
.tariki-side.trust strong {
  color: var(--gold);
}

.flow-arrow {
  align-items: center;
  color: var(--gold);
  display: flex;
  font-size: 1.5rem;
  font-weight: 800;
  justify-content: center;
  min-width: 22px;
}

.structure {
  display: grid;
  gap: 12px;
  grid-template-columns: 0.9fr 1.4fr 1.4fr 0.9fr;
}

.structure-part {
  border: 2px solid var(--accent);
  border-radius: 8px;
  min-height: 120px;
  padding: 14px;
}

.structure-part:nth-child(2) {
  border-color: var(--gold);
}

.structure-part:nth-child(3) {
  border-color: var(--accent-2);
}

.structure-part strong {
  display: block;
  margin-bottom: 8px;
}

.map-row {
  align-items: stretch;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.map-node {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 96px;
  padding: 12px;
}

.map-node span {
  color: var(--accent-2);
  display: block;
  font-weight: 800;
}

.relationship {
  align-items: stretch;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 88px minmax(0, 1fr) 88px minmax(0, 1fr);
}

.relay {
  align-content: center;
  display: grid;
  gap: 8px;
}

.relay span {
  background: #f4efe6;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-2);
  font-size: 0.84rem;
  font-weight: 800;
  padding: 5px 8px;
  text-align: center;
}

.person-card.teacher {
  border-top: 5px solid var(--accent);
}

.person-card.writer {
  border-top: 5px solid var(--gold);
}

.person-card.reader {
  border-top: 5px solid var(--accent-2);
}

.two-column-diagram {
  align-items: stretch;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) 110px minmax(0, 1fr);
}

.reading-bridge {
  align-items: center;
  display: flex;
  justify-content: center;
}

.reading-bridge span {
  background: var(--accent);
  border-radius: 999px;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 800;
  padding: 8px 12px;
  text-align: center;
}

.tariki-diagram {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr);
}

.tariki-center {
  background: #eef5f3;
  border: 2px solid var(--accent);
}

.quiz {
  border-top: 1px solid var(--line);
  margin-top: 36px;
  padding-top: 26px;
}

.question {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 16px 0;
  padding: 18px;
}

.question p {
  font-weight: 800;
  margin: 0 0 12px;
}

.choices {
  display: grid;
  gap: 8px;
}

.choice {
  align-items: center;
  background: #f8f8f6;
  border: 1px solid #e5e1d9;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
}

.choice.correct {
  background: #e8f4ee;
  border-color: #6aa17b;
}

.choice.wrong {
  background: #faebe7;
  border-color: #c87663;
}

.quiz-result {
  color: var(--accent);
  font-weight: 800;
  min-height: 30px;
}

.primary-button {
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  padding: 12px 18px;
}

.secondary-button,
.primary-link-button {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  line-height: 1.35;
  min-height: 46px;
  padding: 12px 16px;
  text-decoration: none;
}

.secondary-button {
  background: #fff;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.primary-link-button {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  margin-top: 8px;
}

.completion-resources {
  background: #f4efe6;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 30px;
  padding: 22px;
}

.completion-resources h3 {
  margin-top: 0;
}

.resource-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

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

.glossary-card {
  background: #fffdfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.glossary-card h3 {
  color: var(--accent);
  font-size: 1.08rem;
  margin: 0 0 8px;
}

.glossary-card p {
  margin: 0;
}

.newsletter-panel {
  align-items: start;
  background: #fffdfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 22px;
  grid-template-columns: 150px minmax(0, 1fr);
  margin: 20px 0 26px;
  padding: 22px;
}

.newsletter-panel h3 {
  margin-top: 0;
}

.newsletter-character {
  filter: drop-shadow(0 10px 14px rgba(34, 31, 26, 0.12));
  height: 140px;
  object-fit: contain;
  width: 140px;
}

.locked-view {
  align-content: center;
  display: grid;
  min-height: 520px;
  text-align: center;
}

.locked-view .lock {
  color: var(--gold);
  font-size: 3rem;
}

.site-footer {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0 clamp(18px, 4vw, 56px) 32px;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 920px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  .hero {
    margin-top: 72px;
  }

  .course-panel {
    position: static;
  }

  .lesson-list {
    max-height: 360px;
  }

  .key-grid,
  .glossary-grid,
  .structure,
  .map-row,
  .cause-flow,
  .relationship,
  .two-column-diagram,
  .tariki-diagram {
    grid-template-columns: 1fr;
  }

  .flow-arrow {
    min-height: 22px;
    transform: rotate(90deg);
  }

  .relay {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .reading-bridge {
    min-height: 48px;
  }

  .newsletter-panel {
    grid-template-columns: 1fr;
  }

  .newsletter-character {
    justify-self: center;
  }
}

@media (max-width: 560px) {
  .app-header {
    min-height: auto;
  }

  .hero-character {
    height: 142px;
    margin-top: -36px;
    width: 142px;
  }

  .brand span:last-child {
    font-size: 0.92rem;
  }

  h1 {
    font-size: 2.25rem;
  }

  .lesson {
    padding: 22px 18px;
  }

  .lesson-guide {
    grid-template-columns: 86px minmax(0, 1fr);
    padding: 12px;
  }

  .lesson-guide-image {
    height: 86px;
    width: 86px;
  }

  .diagram {
    padding: 18px;
  }

  .diagram.diagram-illustrated {
    padding: 18px;
  }

}
