:root {
  color-scheme: light;
  --navy: #10182b;
  --navy-2: #17223a;
  --paper: #f4f7fb;
  --white: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #dbe2ee;
  --yellow: #ffd447;
  --yellow-dark: #5b4800;
  --blue: #4c8dff;
  --blue-soft: #e9f1ff;
  --green: #16865a;
  --green-soft: #e9f8f1;
  --danger: #c9364f;
  --shadow: 0 18px 55px rgba(20, 32, 57, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.test-page { max-width: 900px; margin: 0 auto; padding: 36px 20px; }
.test-page > p { line-height: 1.8; }
.quiz-question { margin: 24px 0; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.quiz-question legend { padding: 0 8px; font-size: 1rem; font-weight: 750; line-height: 1.7; }
.quiz-question label { display: flex; align-items: baseline; gap: 10px; padding: 14px; margin: 8px 0; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; overflow-wrap: anywhere; }
.quiz-question label:has(input:checked) { background: var(--blue-soft); border-color: var(--blue); }
.quiz-feedback { margin: 12px 0 0; line-height: 1.8; }
.quiz-feedback.correct { color: #126540; }
.quiz-feedback.incorrect { color: #a5283d; }
.test-navigation { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 24px; }
.test-navigation a { display: inline-flex; align-items: center; }
.safety-note { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; color: #52627c; font-size: .85rem; line-height: 1.7; }
.safety-note button { border: 0; padding: 0; color: #315f9d; background: transparent; text-decoration: underline; cursor: pointer; font-size: inherit; }
.test-link { display: block; margin: 5px 0 10px; padding: 8px 12px; color: #28528b; font-size: .875rem; line-height: 1.6; }
.challenge-heading { margin-top: 24px; font-size: 1.1rem; }
.challenge-check { display: flex; align-items: baseline; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: .9rem; line-height: 1.7; cursor: pointer; }
html { min-width: 320px; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(76, 141, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(76, 141, 255, .045) 1px, transparent 1px);
  background-size: 24px 24px;
}
button, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.app-shell { min-height: 100vh; min-height: 100svh; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 68px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 10px 28px;
  color: white;
  background: var(--navy);
  border-bottom: 3px solid var(--yellow);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: white;
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: .01em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--navy);
  background: var(--yellow);
  font-size: .75rem;
  letter-spacing: -.02em;
  transform: rotate(-4deg);
}
.main-nav {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .08);
}
.nav-link {
  padding: 8px 15px;
  border-radius: 9px;
  color: #bfc8dc;
  text-decoration: none;
  font-size: .875rem;
  font-weight: 700;
}
.nav-link.active { color: var(--navy); background: white; }
.progress-chip { justify-self: end; color: #c8d1e2; font-size: .8125rem; }
.progress-chip strong { color: var(--yellow); font-size: 1rem; }

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
  min-height: calc(100vh - 68px);
}
.lesson-panel {
  padding: 38px 26px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .9);
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: .75rem;
  font-weight: 850;
  letter-spacing: .18em;
}
h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.3vw, 2.2rem);
  line-height: 1.25;
  letter-spacing: -.035em;
}
.lesson-summary { margin: 14px 0 22px; color: var(--muted); line-height: 1.75; font-size: .9375rem; }
.goal-card {
  padding: 18px;
  border: 1px solid #efd56f;
  border-radius: 16px;
  background: #fff9dd;
  box-shadow: 4px 4px 0 #f1d35b;
}
.goal-label { color: var(--yellow-dark); font-size: .75rem; font-weight: 850; letter-spacing: .06em; }
.goal-card p { margin: 8px 0 0; line-height: 1.65; font-size: .9rem; }
code {
  padding: .1em .35em;
  border-radius: 5px;
  color: #2d4f8d;
  background: var(--blue-soft);
  font-family: "Cascadia Code", Consolas, monospace;
}
.hint-box { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.hint-box summary { cursor: pointer; font-size: .875rem; font-weight: 750; }
.hint-box p { margin: 12px 0 0; color: var(--muted); font-size: .875rem; line-height: 1.65; }
.provided-note { padding: 10px 12px; border-left: 3px solid #8b9fbd; color: #52627c; background: #f1f5fb; font-size: .875rem; line-height: 1.7; }
.manual-test { font-size: .875rem; color: #36557a; line-height: 1.8; }
.syntax-help { margin: 0 0 14px; }
.syntax-help pre { overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 14px; border-radius: 10px; background: #eef3fb; line-height: 1.7; }
.syntax-help pre code { padding: 0; background: transparent; }

.relation-board {
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid #b9cae8;
  border-radius: 18px;
  background: #f8fbff;
  box-shadow: 0 12px 34px rgba(38, 75, 134, .08);
}
.html-parts { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; padding: 18px; }
.html-part { flex: 1 1 140px; min-width: 0; padding: 14px; border: 1px solid #efb394; border-radius: 12px; background: #fff4ee; }
.html-part:nth-child(even) { border-color: #a9c7f3; background: #edf5ff; }
.part-number { display: block; width: 24px; height: 24px; margin-bottom: 12px; border-radius: 50%; color: white; background: #355f99; text-align: center; font-size: .875rem; line-height: 24px; }
.html-part code { display: block; padding: 0; color: #71351e; background: transparent; font-size: 1.05rem; font-weight: 750; white-space: pre-wrap; overflow-wrap: anywhere; }
.html-part p { margin: 12px 0 0; font-size: .9rem; line-height: 1.7; }
.html-tips { margin: 0; padding: 0 30px 20px 38px; color: #405375; font-size: .9rem; line-height: 1.85; }
.relation-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 18px;
  border-bottom: 1px solid #cddbf2;
  background: linear-gradient(110deg, #e9f1ff, #f8fbff 60%);
}
.relation-kicker { color: #4c70ad; font-size: .62rem; font-weight: 900; letter-spacing: .16em; }
.relation-heading h2 { margin: 3px 0 0; font-size: 1rem; line-height: 1.35; }
.relation-heading > p { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: .7rem; font-weight: 750; white-space: nowrap; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.html-dot { background: #f07a48; }
.js-dot { margin-left: 5px; background: #e3b515; }
.mapping-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 14px; }
.mapping-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr);
  align-items: center;
  padding: 13px;
  border: 1px solid #d6e1f2;
  border-radius: 14px;
  background: white;
}
.mapping-code { min-width: 0; }
.code-kind {
  display: inline-block;
  margin-bottom: 5px;
  font-size: .65rem;
  font-weight: 900;
  letter-spacing: .08em;
}
.html-kind { color: #b4491d; }
.js-kind { color: #765c00; }
.mapping-code pre {
  max-width: 100%;
  margin: 0;
  overflow-x: auto;
  min-height: 62px;
  display: flex;
  align-items: center;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 10px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .72rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.html-kind + pre { color: #7b3217; border-color: #f4b092; background: #fff2ec; }
.js-kind + pre { color: #5d4900; border-color: #efd65d; background: #fff9d9; }
.mapping-code pre code { padding: 0; color: inherit; background: transparent; }
.mapping-connector {
  position: relative;
  min-height: 70px;
  display: grid;
  place-items: center;
  color: #49658f;
  font-size: .62rem;
  font-weight: 850;
}
.connector-line {
  position: absolute;
  right: 8px;
  left: 8px;
  height: 2px;
  background: #9db4dc;
}
.connector-badge { position: relative; padding: 3px 7px; border: 1px solid #b7c8e4; border-radius: 999px; background: white; }
.connector-symbol { position: absolute; bottom: 2px; color: #6a84ac; font-size: 1rem; }
.mapping-note { grid-column: 1 / -1; display: flex; gap: 7px; margin: 11px 2px 0; padding-top: 10px; border-top: 1px dashed #d7dfeb; color: var(--muted); font-size: .76rem; line-height: 1.6; }

.step-list { display: grid; gap: 6px; max-height: 520px; overflow-y: auto; margin: 26px 0 0; padding: 0; list-style: none; }
.step-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 12px;
  color: #798397;
  text-decoration: none;
}
.step-number {
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  font-size: .75rem;
  font-weight: 800;
}
.step-copy { min-width: 0; font-size: .84rem; font-weight: 750; }
.step-copy small { display: block; overflow: hidden; margin-top: 2px; color: #929bad; font-size: .68rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.step-link.current { color: var(--ink); background: var(--blue-soft); }
.step-link.current .step-number { color: white; border-color: var(--blue); background: var(--blue); }
.step-link.complete .step-number { color: white; border-color: var(--green); background: var(--green); }
.step-link:hover { color: var(--ink); background: #f1f5fb; }

.workbench { min-width: 0; padding: 24px; }
.workbench-bar, .pane-heading, .lesson-footer { display: flex; align-items: center; justify-content: space-between; }
.workbench-bar { gap: 18px; margin-bottom: 14px; }
.file-tabs { display: flex; gap: 5px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.file-tab { border: 0; border-radius: 8px; padding: 8px 13px; color: var(--muted); background: transparent; cursor: pointer; font-size: .8125rem; font-weight: 800; }
.file-tab.active { color: white; background: var(--navy-2); }
.actions { display: flex; gap: 8px; }
.actions { flex-wrap: wrap; }
.button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
  font-size: .875rem;
  text-decoration: none;
}
.button:disabled { cursor: not-allowed; opacity: .45; }
.button.ghost { border-color: var(--line); color: var(--ink); background: white; }
.button.primary { color: var(--navy); background: var(--yellow); box-shadow: 0 4px 0 #d8ae1e; }
.button.next { color: white; background: var(--blue); }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:focus-visible, .file-tab:focus-visible, .nav-link:focus-visible, .step-link:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(76, 141, 255, .38);
  outline-offset: 2px;
}
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(320px, .92fr); gap: 14px; }
.editor-pane, .preview-pane {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  box-shadow: var(--shadow);
}
.pane-heading { min-height: 46px; padding: 0 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .75rem; font-weight: 750; }
.save-state, .preview-state { font-size: .7rem; font-weight: 600; }
#codeEditor {
  display: block;
  width: 100%;
  min-height: 510px;
  resize: vertical;
  border: 0;
  outline: 0;
  padding: 20px;
  color: #e7edf8;
  background: #111827;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: .9rem;
  line-height: 1.75;
  tab-size: 2;
}
.message-bar { min-height: 42px; padding: 12px 16px; border-top: 1px solid #2c374b; color: #b9c3d6; background: var(--navy-2); font-size: .8rem; }
.message-bar.success { color: #9be7c4; }
.message-bar.error { color: #ffb4b4; }
#previewFrame { display: block; width: 100%; min-height: 552px; border: 0; background: white; }
.lesson-footer { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.footer-spacer { flex: 1; }

.playground-page { max-width: 1500px; margin: 0 auto; padding: 28px; }
.playground-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin: 4px 0 22px;
  padding: 24px 26px;
  overflow: hidden;
  border: 1px solid #273653;
  border-radius: 20px;
  color: white;
  background:
    radial-gradient(circle at 86% 20%, rgba(255, 212, 71, .22), transparent 18rem),
    var(--navy);
  box-shadow: var(--shadow);
}
.playground-intro h1 { font-size: clamp(1.65rem, 3vw, 2.5rem); }
.playground-intro p { max-width: 580px; margin: 10px 0 0; color: #c5cee0; line-height: 1.7; }
.keyboard-note { flex: 0 0 auto; padding: 10px 14px; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; color: var(--yellow); font-size: .78rem; font-weight: 750; }
.playground-page .workspace-grid { grid-template-columns: minmax(0, 1fr) minmax(350px, 1fr); }

.mobile-view-tabs { display: none; }

@media (max-width: 1050px) {
  .topbar { grid-template-columns: 1fr auto; }
  .main-nav { order: 3; grid-column: 1 / -1; justify-self: center; }
  .lesson-layout { grid-template-columns: 1fr; }
  .lesson-panel { padding: 28px 22px; border-right: 0; border-bottom: 1px solid var(--line); }
  .step-list { grid-template-columns: repeat(4, 1fr); }
  .step-copy small { display: none; }
  .workspace-grid, .playground-page .workspace-grid { grid-template-columns: 1fr; }
  .mapping-list { grid-template-columns: 1fr; }
  #codeEditor, #previewFrame { min-height: 430px; }
}

@media (max-width: 680px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  .progress-chip { font-size: .7rem; }
  .main-nav { width: 100%; }
  .nav-link { flex: 1; text-align: center; }
  .lesson-panel, .workbench, .playground-page { padding: 20px 14px; }
  .step-list { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 4px; }
  .step-link { flex: 0 0 auto; padding: 5px; }
  .step-copy { display: none; }
  .workbench-bar { align-items: stretch; flex-direction: column; }
  .file-tabs, .actions { width: 100%; }
  .file-tab, .actions .button { flex: 1; }
  .playground-intro { align-items: flex-start; flex-direction: column; padding: 20px; }
  .relation-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .mapping-pair { grid-template-columns: 1fr; }
  .mapping-connector { min-height: 48px; }
  .connector-line { top: 4px; bottom: 4px; left: 50%; width: 2px; height: auto; }
  .connector-symbol { right: calc(50% - 26px); bottom: 14px; transform: rotate(90deg); }
  .mapping-note { grid-column: 1; }
  .keyboard-note { display: none; }
  #codeEditor { min-height: 380px; font-size: .84rem; }
  #previewFrame { min-height: 460px; }
  .save-state { display: none; }
  .lesson-footer { gap: 8px; }
  .lesson-footer .button { flex: 1; padding: 0 10px; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

