/* Shared UI. Laboratory drawings have their own stylesheet. */
:root {
  --ink: #172c37;
  --muted: #516672;
  --paper: #fff;
  --bg: #edf3f7;
  --line: #cbd9e0;
  --teal: #087780;
  --teal-soft: #e7f5f5;
  --orange: #b54713;
  --orange-soft: #fff0e5;
  --purple: #6845a0;
  --success: #216b42;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.6;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
a {
  font: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: default;
  opacity: 0.6;
}
button,
a,
input,
select,
summary {
  touch-action: manipulation;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 4px;
}
[hidden] {
  display: none !important;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 1.3rem;
}
h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1.35;
  letter-spacing: -0.025em;
}
h3 {
  font-size: 1.15rem;
}
a {
  color: var(--teal);
}
.skip {
  position: absolute;
  left: 16px;
  top: -80px;
  background: white;
  padding: 10px;
  z-index: 10;
}
.skip:focus {
  top: 8px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
}
header {
  background: white;
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1200px;
  margin: auto;
  padding: 20px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}
.brand-mark {
  font-size: 2.5rem;
  color: var(--teal);
  line-height: 1;
}
.header-small {
  color: var(--muted);
  font-size: 0.85rem;
}
.course-label {
  font-size: 0.8rem;
  color: var(--teal);
}
.container {
  max-width: 1200px;
  margin: auto;
  padding: 0 28px;
}
.main-nav {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin: 22px 0 10px;
}
.main-nav .button {
  flex: 1;
  min-width: 110px;
}
.main-nav [aria-current="page"] {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
}
.status-bar {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}
.status-bar span {
  max-width: 48%;
}
main {
  min-width: 0;
  min-height: 400px;
  padding-bottom: 24px;
}
main > * + * {
  margin-top: 20px;
}
.page-title {
  font-size: clamp(1.8rem, 4vw, 2.45rem);
  letter-spacing: -0.035em;
}
.task {
  color: var(--muted);
  max-width: 80ch;
  margin-top: 10px;
  margin-bottom: 18px;
}
.stage {
  padding: 28px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  min-width: 0;
  box-shadow: 0 8px 36px #1c526008;
}
.welcome {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: center;
}
.welcome h3 {
  font-size: 1.5rem;
}
.welcome .illustration {
  margin: 0;
}
.section-title {
  margin-top: 28px;
  margin-bottom: 14px;
}
.path-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding: 20px 4px;
}
.path-steps > div {
  padding-left: 42px;
  position: relative;
}
.path-steps p {
  color: var(--muted);
  font-size: 0.9rem;
}
.step-number {
  position: absolute;
  left: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 700;
}
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  min-height: 46px;
  padding: 10px 16px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}
.button:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}
.button.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}
.button.primary:hover {
  background: #075e65;
}
.button[aria-pressed="true"] {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal);
}
.chapter-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 20px;
  min-height: 135px;
}
.chapter-card small {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85rem;
}
.eyebrow {
  font-size: 0.8rem;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  margin-bottom: 6px;
}
.actions,
.word-pool,
.lab-navigation {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.word-pool {
  margin-bottom: 20px;
}
.bottom-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
}
.small-note,
.source-line {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 12px;
}
.source-line {
  padding-top: 14px;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.illustration {
  background: #f4f8fa;
  border: 1px solid #d9e5e9;
  border-radius: 12px;
  padding: 16px;
  min-width: 0;
}
.illustration svg {
  display: block;
  width: 100%;
  height: auto;
}
.diagram-caption {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--muted);
  margin-top: 12px;
}
.scene {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.scene-item {
  padding: 12px 4px;
  text-align: center;
  border: 2px solid transparent;
  border-radius: 10px;
  font-size: 0.8rem;
}
.scene-symbol {
  display: block;
  font-size: 1.6rem;
  color: var(--teal);
  margin-bottom: 10px;
}
.highlighted {
  border: 2px solid var(--orange) !important;
  background: var(--orange-soft);
}
.device-chain {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.device {
  padding: 12px;
  background: white;
  border: 2px solid var(--line);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.device small {
  font-size: 0.75rem;
  color: var(--muted);
}
.device strong {
  font-size: 0.9rem;
}
.device-step {
  font-size: 0.7rem;
  color: var(--muted);
}
.conversion {
  display: flex;
  justify-content: space-around;
  gap: 10px;
  align-items: center;
  padding: 48px 10px;
}
.conversion strong {
  font-size: 1.05rem;
}
.conversion span {
  font-size: 2rem;
  color: var(--orange);
}
.lesson-layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 30px;
  align-items: start;
}
.term-title {
  font-size: 1.6rem;
  margin-bottom: 14px;
}
.definition {
  font-size: 1.1rem;
  line-height: 1.65;
  margin: 12px 0;
}
.example {
  background: var(--bg);
  padding: 16px;
  border-radius: 10px;
  margin-top: 18px;
}
.example strong {
  display: block;
  margin-bottom: 5px;
  font-size: 0.9rem;
}
.memory {
  background: var(--teal-soft);
  border-left: 4px solid var(--teal);
  padding: 14px 18px;
  border-radius: 4px;
  font-weight: 600;
  margin-top: 20px;
}
.exercise-help {
  margin-top: 20px;
}
.exercise-help summary,
.glossary-word summary,
.words-help summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--teal);
  padding: 12px 0;
  min-height: 46px;
}
.exercise-help > p {
  margin: 12px 0;
}
.help-panel {
  padding: 18px;
  background: var(--teal-soft);
  border-radius: 12px;
}
.help-panel .button {
  margin: 10px 8px 10px 0;
}
.help-panel details p {
  margin-top: 12px;
}
.clue {
  margin-top: 10px;
  border-left: 3px solid var(--teal);
  padding-left: 12px;
}
.answer-block {
  white-space: pre-line;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin: 12px 0;
}
.feedback {
  margin-top: 18px;
  padding: 13px 16px;
  border-radius: 10px;
  background: var(--bg);
  min-height: 52px;
}
.feedback.good {
  background: #edf8ef;
  color: var(--success);
}
.feedback.try {
  background: var(--orange-soft);
  color: #8a3510;
}
.exercise-title {
  font-size: 1.45rem;
  margin: 14px 0 24px;
  max-width: 70ch;
}
.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.picture-choice {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  min-width: 0;
  padding: 14px;
}
.picture-choice > .illustration {
  margin-top: 8px;
  width: 100%;
  background: white;
  border: 0;
  padding: 4px;
}
.picture-choice .diagram-caption {
  font-weight: 400;
}
.matching {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 24px;
}
.matching-words,
.matching-clues {
  display: grid;
  gap: 12px;
}
.matching .button {
  text-align: left;
  justify-content: flex-start;
  min-height: 76px;
}
.matched {
  background: var(--teal-soft);
  border-color: var(--teal);
  opacity: 0.75 !important;
}
.order-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0;
  list-style: none;
}
.order-slots li {
  background: var(--bg);
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.order-slots li.filled {
  background: var(--teal-soft);
  border-style: solid;
  border-color: var(--teal);
}
.session-header {
  margin-bottom: 10px;
}
.exercise-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}
.exercise-menu .button {
  justify-content: flex-start;
  text-align: left;
  min-height: 70px;
}
.word-card {
  background: var(--teal-soft);
  border: 1px solid #a9cccf;
  border-radius: 16px;
  padding: 28px;
  min-height: 240px;
}
.card-kicker {
  color: var(--muted);
  font-size: 0.9rem;
}
.card-word {
  font-size: 2.1rem;
  margin-top: 16px;
}
.card-answer {
  margin-top: 20px;
}
.card-answer .illustration {
  background: white;
  max-width: 620px;
}
.glossary-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.glossary-filters label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}
input[type="search"],
select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  min-height: 46px;
}
.glossary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}
.glossary-word {
  padding: 10px 20px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.glossary-word > .illustration {
  margin-top: 12px;
}
.lab-navigation .button {
  flex: 1;
  min-width: 130px;
}
.laboratory .chart {
  width: 100%;
}
footer {
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
  padding: 20px 28px 28px;
  max-width: 1200px;
  margin: auto;
}
@media (max-width: 850px) {
  .welcome,
  .lesson-layout {
    grid-template-columns: 1fr;
  }
  .chapter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .welcome .illustration {
    max-width: 600px;
  }
  .status-bar {
    display: block;
  }
  .status-bar span {
    max-width: none;
    display: block;
  }
  .status-bar span + span {
    margin-top: 5px;
  }
  .glossary-grid {
    grid-template-columns: 1fr;
  }
  .lesson-layout {
    gap: 18px;
  }
}
@media (max-width: 560px) {
  .container {
    padding: 0 14px;
  }
  .header-inner {
    padding: 18px 16px;
  }
  .header-inner > .header-small {
    display: none;
  }
  .main-nav {
    gap: 6px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .main-nav .button {
    min-width: 0;
    font-size: 0.82rem;
    padding: 10px 6px;
  }
  .stage {
    padding: 20px 16px;
  }
  .chapter-card {
    padding: 14px;
    min-height: 155px;
  }
  .chapter-card strong {
    font-size: 0.95rem;
  }
  .path-steps {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .compare-grid {
    grid-template-columns: 1fr;
  }
  .glossary-filters {
    grid-template-columns: 1fr;
  }
  .matching {
    grid-template-columns: 1fr 1.4fr;
    gap: 10px;
  }
  .matching .button {
    padding: 10px;
    font-size: 0.85rem;
    min-height: 94px;
  }
  .device-chain {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .scene-item {
    padding: 10px 2px;
    font-size: 0.75rem;
  }
  .illustration {
    padding: 12px;
  }
  .word-card {
    padding: 20px 16px;
  }
  .card-word {
    font-size: 1.7rem;
  }
  .exercise-menu {
    grid-template-columns: 1fr;
  }
  .bottom-nav .button {
    font-size: 0.85rem;
    padding: 10px;
  }
  .conversion {
    padding: 30px 0;
  }
  .conversion strong {
    font-size: 0.9rem;
  }
  .chapter-grid {
    gap: 8px;
  }
  .laboratory .stage-heading {
    display: block;
  }
  .laboratory .stage-heading .help {
    margin-top: 12px;
  }
  .source-line {
    font-size: 0.8rem;
  }
  footer {
    padding: 20px 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

.reader-menu {
  max-width: 600px;
}
.reader-menu label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}
.reader-point {
  margin-top: 12px;
}
.original-page {
  margin-top: 24px;
}
.original-page > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 12px 0;
  min-height: 46px;
}
.document-viewport {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-top: 14px;
  max-height: 1000px;
  background: #e1e8ec;
}
.document-viewport img {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
}
.original-text {
  white-space: pre-wrap;
  font: inherit;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  padding: 16px;
  background: var(--bg);
  border-radius: 10px;
}
.reader-point {
  max-width: 80ch;
}

.conversion strong {
  min-width: 0;
  max-width: 43%;
  overflow-wrap: anywhere;
}
.conversion span {
  flex: none;
}
