:root {
  color-scheme: light;
  --ink: #17231f;
  --muted: #59645f;
  --paper: #f8f7f1;
  --panel: #ffffff;
  --line: #d8ded9;
  --accent: #176b55;
  --accent-soft: #e0f0e9;
  --warm: #9d4f2c;
  --warm-soft: #f7e8de;
  --shadow: 0 18px 48px rgb(30 50 42 / 0.09);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Hiragino Sans",
    "Noto Sans JP",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
}

body {
  margin: 0;
}

main {
  width: min(940px, calc(100% - 32px));
  margin: 0 auto;
  padding: 64px 0 96px;
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  line-height: 1.08;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 5.2rem);
  letter-spacing: -0.045em;
}
h2 {
  margin: 0 0 18px;
  font-size: clamp(1.65rem, 4vw, 2.45rem);
}
h3 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}
p,
li {
  line-height: 1.7;
}
.lede {
  max-width: 710px;
  color: var(--muted);
  font-size: 1.18rem;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 26px 0 0;
}
.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  padding: 7px 11px;
  color: var(--muted);
  font-size: 0.83rem;
}

section {
  margin-top: 72px;
}

.principle {
  border-left: 5px solid var(--accent);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 46px);
}

.principle blockquote {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 4vw, 2.5rem);
  line-height: 1.25;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 22px;
}
.card p:last-child {
  margin-bottom: 0;
}
.number {
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 2rem;
}

.flow {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 24px 0;
}
.flow div {
  border-top: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 15px 12px;
  min-height: 98px;
}
.flow b {
  display: block;
  margin-bottom: 6px;
}
.flow span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.exercise {
  border: 1px solid #d8c2b6;
  border-radius: 16px;
  background: var(--warm-soft);
  padding: clamp(24px, 5vw, 42px);
}
.prompt {
  border-left: 3px solid var(--warm);
  padding-left: 16px;
  font-family: Georgia, serif;
  font-size: 1.25rem;
}
label {
  display: block;
  margin: 20px 0 7px;
  font-weight: 700;
}
textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid #bca99f;
  border-radius: 9px;
  background: #fffdfa;
  padding: 12px;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
}
button {
  margin-top: 20px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  padding: 11px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.feedback {
  display: none;
  margin-top: 24px;
  border-top: 1px solid #d8c2b6;
  padding-top: 20px;
}
.feedback.is-visible {
  display: block;
}
.checklist {
  padding-left: 1.15rem;
}
.checklist li {
  margin: 7px 0;
}

.source-note {
  color: var(--muted);
  font-size: 0.9rem;
}
.next {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

/* Bilingual text: Japanese shown as a quieter second line */
.ja {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 0.92em;
  font-weight: 400;
  letter-spacing: 0;
}
h1 .ja,
h2 .ja {
  font-size: 0.5em;
}

/* Figures (e.g. assets/diamond.svg) */
.figure {
  display: block;
  width: 100%;
  height: auto;
  margin: 8px 0 24px;
}

/* Quiz (assets/quiz.js) */
.quiz .q {
  border-top: 1px solid #d8c2b6;
  padding: 22px 0 6px;
}
.q-prompt {
  margin: 0 0 12px;
  font-family: Georgia, serif;
  font-size: 1.12rem;
}
.choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
button.choice {
  margin: 0;
  border: 1px solid #bca99f;
  border-radius: 9px;
  background: #fffdfa;
  color: var(--ink);
  padding: 10px 12px;
  font-weight: 600;
  text-align: left;
}
button.choice:disabled {
  cursor: default;
  opacity: 0.55;
}
button.choice.is-correct {
  border-color: var(--accent);
  background: var(--accent-soft);
  opacity: 1;
}
button.choice.is-wrong {
  border-color: var(--warm);
  text-decoration: line-through;
  opacity: 1;
}
.explain,
.quiz-score {
  display: none;
}
.explain.is-visible,
.quiz-score.is-visible {
  display: block;
}
.explain {
  margin-top: 12px;
  color: var(--muted);
}
.quiz-score {
  margin-top: 20px;
  font-family: Georgia, serif;
  font-size: 1.6rem;
}

/* Reference tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}
th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  line-height: 1.5;
}
th {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

@media (max-width: 700px) {
  main {
    padding-top: 36px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .flow {
    grid-template-columns: 1fr;
  }
  .flow div {
    min-height: auto;
  }
  .next {
    flex-direction: column;
  }
  .choices {
    grid-template-columns: 1fr 1fr;
  }
  table {
    font-size: 0.9rem;
  }
}

@media print {
  main {
    width: 100%;
    padding: 0;
  }
  button,
  textarea {
    display: none;
  }
  .explain {
    display: block;
  }
  section {
    margin-top: 38px;
    break-inside: avoid;
  }
  .card,
  .principle {
    box-shadow: none;
  }
  a {
    color: inherit;
  }
}
