:root {
  --green: #22c670;
  --green-dark: #119655;
  --green-deep: #087044;
  --night: #071a14;
  --ink: #122033;
  --muted: #587065;
  --cream: #f4fbf7;
  --paper: #fdfffe;
  --mint: #e3f7ec;
  --mint-strong: #caefdb;
  --line: #d4e9dd;
  --cyan: #63e5ff;
  --violet: #8b5cf6;
  --gold: #ffc15a;
  --coral: #ff6b74;
  --shadow: 0 20px 54px rgba(5, 50, 27, .11);
  --shadow-soft: 0 8px 22px rgba(34, 198, 112, .14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; min-height: 100%; background: var(--cream); -webkit-text-size-adjust: 100%; }
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(900px 390px at 52% -180px, #dff7ea 0%, rgba(223, 247, 234, 0) 72%),
    var(--cream);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}
button, input, output { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--green-dark);
  outline-offset: 3px;
}
.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  transform: translateY(-150%);
  padding: 9px 13px;
  border-radius: 9px;
  color: var(--night);
  background: var(--green);
  font-weight: 850;
}
.skip-link:focus { transform: none; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.site-header {
  width: min(1540px, calc(100% - 28px));
  min-height: 64px;
  margin: 10px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(253, 255, 254, .9);
  box-shadow: 0 6px 20px rgba(5, 50, 27, .06);
  backdrop-filter: blur(12px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--night); text-decoration: none; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: var(--mint);
}
.brand-mark img { display: block; width: 39px; height: 39px; object-fit: contain; }
.brand > span:last-child { display: grid; line-height: 1.1; }
.brand strong { font-size: 1rem; font-weight: 900; letter-spacing: -.02em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: .62rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.level-pill {
  padding: 8px 12px;
  border: 1px solid var(--mint-strong);
  border-radius: 999px;
  color: var(--green-deep);
  background: var(--mint);
  font-size: .69rem;
  font-weight: 900;
  letter-spacing: .045em;
  text-transform: uppercase;
}

main { width: min(1540px, calc(100% - 28px)); margin: 0 auto; padding: 18px 0 26px; }
.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 470px);
  align-items: end;
  gap: 28px;
  margin-bottom: 16px;
}
.eyebrow, .step-label {
  display: block;
  color: var(--green-dark);
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .105em;
  text-transform: uppercase;
}
.intro h1 { margin: 3px 0 4px; color: var(--night); font-size: clamp(1.72rem, 3vw, 2.45rem); line-height: 1.08; letter-spacing: -.04em; }
.intro > div > p { margin: 0; color: var(--muted); font-size: clamp(.92rem, 1.3vw, 1.04rem); }
.learning-goal {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  border: 1px solid var(--mint-strong);
  border-radius: 15px;
  background: rgba(227, 247, 236, .68);
}
.learning-goal > span { flex: 0 0 auto; width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; color: var(--night); background: var(--green); font-weight: 950; }
.learning-goal p { margin: 0; display: grid; gap: 2px; }
.learning-goal small { color: var(--green-deep); font-size: .62rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.learning-goal strong { color: var(--night); font-size: .87rem; line-height: 1.35; }

.laboratory-grid { display: grid; grid-template-columns: minmax(0, 1fr) 365px; gap: 14px; align-items: start; }
.stage-panel, .control-panel, .graph-section, .learning-row {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.stage-panel { grid-column: 1; grid-row: 1; min-width: 0; overflow: hidden; }
.stage-toolbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
}
.stage-toolbar h2 { margin: 2px 0 0; color: var(--night); font-size: clamp(1rem, 1.8vw, 1.28rem); line-height: 1.2; letter-spacing: -.025em; }
.transport-controls { display: flex; align-items: center; gap: 8px; }
.primary-button, .quiet-button, .dialog-close {
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 8px 12px;
  background: var(--paper);
  font-weight: 850;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background-color .16s ease;
}
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-color: var(--green); background: var(--green); box-shadow: var(--shadow-soft); }
.primary-button:hover, .quiet-button:hover { transform: translateY(-1px); border-color: var(--green); }
.play-icon { min-width: 14px; font-weight: 950; }

.circuit-frame {
  position: relative;
  min-height: 475px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 47%, rgba(34, 198, 112, .12), transparent 32%),
    linear-gradient(180deg, #0b2019, #061510);
}
.circuit-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .22;
  background-image:
    linear-gradient(rgba(99, 229, 255, .13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 229, 255, .13) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.5), transparent 86%);
}
#circuit-canvas { display: block; width: 100%; height: 475px; }
.circuit-legend {
  position: absolute;
  left: 15px;
  bottom: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 13px;
  padding: 7px 9px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 10px;
  color: rgba(236,255,247,.78);
  background: rgba(4, 20, 14, .7);
  font-size: .67rem;
  font-weight: 750;
  backdrop-filter: blur(8px);
}
.circuit-legend span { display: inline-flex; align-items: center; gap: 5px; }
.electron-key { width: 16px; height: 16px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--night); background: var(--cyan); font-size: .7rem; font-style: normal; font-weight: 950; }
.charge-key { width: 14px; height: 4px; border-radius: 99px; }
.charge-key.negative { background: var(--cyan); }
.charge-key.positive { background: var(--gold); }
.current-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  min-width: 145px;
  display: grid;
  justify-items: end;
  padding: 9px 11px;
  border: 1px solid rgba(99,229,255,.22);
  border-radius: 11px;
  color: rgba(236,255,247,.72);
  background: rgba(4,20,14,.72);
  backdrop-filter: blur(8px);
}
.current-badge small { font-size: .61rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.current-badge strong { color: var(--cyan); font-size: .92rem; }
.event-strip {
  min-height: 70px;
  display: grid;
  grid-template-columns: minmax(250px, .8fr) minmax(300px, 1.2fr);
  align-items: center;
  gap: 20px;
  padding: 10px 15px;
  border-top: 1px solid rgba(34,198,112,.12);
  color: #dff8ea;
  background: var(--night);
}
.event-strip div { display: grid; gap: 2px; }
.event-strip div span { color: #8fb7a5; font-size: .61rem; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
.event-strip div strong { font-size: .78rem; }
.event-strip p { margin: 0; color: #a8c9ba; font-size: .74rem; }
.event-strip p strong { color: var(--green); }

.control-panel { grid-column: 2; grid-row: 1 / span 2; padding: 14px; }
.control-section + .control-section { margin-top: 13px; }
.step-label { margin-bottom: 8px; display: flex; align-items: center; gap: 7px; }
.step-label b { width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 7px; color: var(--night); background: var(--green); font-size: .67rem; }
.mode-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.mode-buttons button {
  min-height: 70px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #f9fcfa;
  text-align: left;
  cursor: pointer;
}
.mode-buttons button strong { font-size: .75rem; line-height: 1.2; }
.mode-buttons button small { color: var(--muted); font-size: .61rem; }
.mode-buttons button[aria-pressed="true"] { border-color: var(--green); background: var(--mint); box-shadow: 0 0 0 3px rgba(34,198,112,.14); }
.notice-card { margin: 12px 0; padding: 11px 12px; border-left: 4px solid var(--green); border-radius: 10px; background: var(--mint); }
.notice-card > span { display: block; color: var(--green-deep); font-size: .61rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.notice-card > strong { display: block; margin-top: 2px; color: var(--night); font-size: .88rem; }
.notice-card p { margin: 4px 0 0; color: #3f6153; font-size: .7rem; line-height: 1.4; }
.parameter-section { padding-top: 2px; }
.range-control { display: grid; gap: 5px; margin-top: 9px; }
.range-control > span { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: .75rem; }
.range-control output { color: var(--green-deep); font-size: .72rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.range-control input { width: 100%; margin: 0; accent-color: var(--green); cursor: pointer; }
.range-control > small { display: flex; justify-content: space-between; color: var(--muted); font-size: .56rem; }
.range-control.compact { margin-top: 11px; padding-top: 9px; border-top: 1px solid var(--line); }
.range-control.compact > small { display: block; }
.parameter-note { margin: 8px 0 0; color: var(--muted); font-size: .6rem; }
.tau-card { margin-top: 12px; padding: 10px 11px; border: 1px solid var(--mint-strong); border-radius: 11px; background: #f8fcfa; }
.tau-card > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .62rem; }
.tau-card > div:first-child strong { color: var(--green-deep); font-size: .72rem; }
.tau-track { position: relative; height: 7px; margin: 10px 0 7px; overflow: visible; border-radius: 99px; background: #dceae3; }
.tau-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--cyan)); transition: width .1s linear; }
.tau-track b { position: absolute; top: -4px; left: 20%; width: 2px; height: 15px; background: var(--violet); }
.tau-card p { margin: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tau-card p strong { font-size: .72rem; font-variant-numeric: tabular-nums; }
.tau-card p span { color: var(--muted); font-size: .56rem; text-align: right; }
.readout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
.readout-grid div { min-width: 0; padding: 8px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.readout-grid span { display: block; color: var(--muted); font-size: .57rem; font-weight: 750; }
.readout-grid strong { display: block; margin-top: 2px; color: var(--green-deep); font-size: .79rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.graph-section { grid-column: 1; grid-row: 2; margin-top: 0; padding: 15px; }
.graph-section > header { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 11px; }
.graph-section h2 { margin: 2px 0 0; font-size: clamp(1.05rem, 1.8vw, 1.35rem); letter-spacing: -.025em; }
.graph-section header p { max-width: 480px; margin: 0; color: var(--muted); font-size: .75rem; text-align: right; }
.graph-deck { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.graph-card {
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 128px auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: #fbfefc;
  text-align: left;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.graph-card:hover { transform: translateY(-2px); border-color: var(--green); box-shadow: var(--shadow-soft); }
.graph-card > span { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; padding: 10px 11px 6px; }
.graph-card > span small { grid-column: 1 / -1; color: var(--green-deep); font-size: .58rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.graph-card > span strong { font-size: .79rem; }
.graph-card output { color: var(--green-deep); font-size: .75rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.graph-card canvas { display: block; width: 100%; height: 128px; }
.graph-card > i { display: flex; justify-content: space-between; padding: 7px 11px; border-top: 1px solid var(--line); color: var(--muted); font-size: .61rem; font-style: normal; font-weight: 800; }
.graph-card > i b { color: var(--green-deep); }

.learning-row { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); overflow: hidden; }
.learning-row article { min-width: 0; display: flex; gap: 10px; padding: 13px 15px; border-right: 1px solid var(--line); }
.learning-row article:last-child { border-right: 0; }
.learning-row article > span { flex: 0 0 auto; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; color: var(--night); background: var(--green); font-size: .69rem; font-weight: 950; }
.learning-row article strong { display: block; font-size: .78rem; }
.learning-row article p { margin: 2px 0 0; color: var(--muted); font-size: .67rem; }
.site-footer { width: min(1540px, calc(100% - 28px)); margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted); font-size: .65rem; }
.site-footer img { width: 25px; height: 25px; object-fit: contain; }
.site-footer i { width: 4px; height: 4px; border-radius: 50%; background: var(--green); }

dialog {
  width: min(970px, calc(100% - 24px));
  max-height: calc(100svh - 24px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 19px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 30px 90px rgba(5,50,27,.28);
}
dialog::backdrop { background: rgba(4, 18, 13, .64); backdrop-filter: blur(5px); }
.dialog-shell > header { display: flex; align-items: start; justify-content: space-between; gap: 22px; padding: 16px 18px 13px; }
.dialog-shell h2 { margin: 2px 0 1px; font-size: clamp(1.25rem, 3vw, 1.8rem); letter-spacing: -.035em; }
.dialog-shell header p { margin: 0; color: var(--muted); font-size: .79rem; }
.dialog-close { width: 41px; padding: 0; font-size: 1.55rem; line-height: 1; }
.detail-graph-wrap { height: min(54vh, 500px); min-height: 330px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fbfefc; }
#detail-graph { display: block; width: 100%; height: 100%; }
.dialog-shell > footer { display: grid; grid-template-columns: 1fr 1.2fr 2fr; gap: 9px; padding: 12px 16px 16px; }
.dialog-shell > footer > div { min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; }
.dialog-shell footer span { display: block; color: var(--muted); font-size: .58rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.dialog-shell footer strong { display: block; margin-top: 2px; color: var(--green-deep); font-size: .76rem; }
.equation-chip { background: var(--mint); }

@media (max-width: 1080px) {
  .laboratory-grid { grid-template-columns: minmax(0, 1fr) 330px; }
  .circuit-frame, #circuit-canvas { min-height: 445px; height: 445px; }
  .event-strip { grid-template-columns: 1fr; gap: 4px; }
}
@media (max-width: 860px) {
  .intro { grid-template-columns: 1fr; gap: 12px; }
  .learning-goal { max-width: 620px; }
  .laboratory-grid { grid-template-columns: 1fr; }
  .stage-panel { grid-column: 1; grid-row: 1; }
  .control-panel { grid-column: 1; grid-row: 2; }
  .graph-section { grid-column: 1; grid-row: 3; }
  .control-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .control-section + .control-section, .notice-card, .tau-card, .readout-grid { margin-top: 0; }
  .switch-section { grid-column: 1; }
  .notice-card { grid-column: 1; }
  .parameter-section { grid-column: 2; grid-row: 1 / span 2; }
  .tau-card { grid-column: 1; }
  .readout-grid { grid-column: 2; }
}
@media (max-width: 680px) {
  .site-header, main, .site-footer { width: min(100% - 18px, 1540px); }
  main { padding-top: 13px; }
  .level-pill { display: none; }
  .intro h1 { font-size: 1.65rem; }
  .stage-toolbar { align-items: start; }
  .transport-controls { flex-direction: column; align-items: stretch; }
  .transport-controls button { min-height: 34px; padding: 6px 9px; font-size: .7rem; }
  .circuit-frame, #circuit-canvas { min-height: 420px; height: 420px; }
  .current-badge { min-width: 126px; }
  .event-strip { min-height: 82px; }
  .control-panel { display: block; }
  .control-panel > * + * { margin-top: 12px; }
  .graph-section > header { align-items: start; flex-direction: column; gap: 5px; }
  .graph-section header p { text-align: left; }
  .graph-deck { grid-template-columns: 1fr; }
  .graph-card { grid-template-columns: minmax(0, .9fr) minmax(150px, 1.1fr); grid-template-rows: auto auto; }
  .graph-card > span { grid-row: 1; grid-column: 1; align-content: center; }
  .graph-card canvas { grid-row: 1 / span 2; grid-column: 2; height: 120px; }
  .graph-card > i { grid-row: 2; grid-column: 1; }
  .learning-row { grid-template-columns: 1fr; }
  .learning-row article { border-right: 0; border-bottom: 1px solid var(--line); }
  .learning-row article:last-child { border-bottom: 0; }
  .dialog-shell > footer { grid-template-columns: 1fr 1fr; }
  .dialog-shell > footer .equation-chip { grid-column: 1 / -1; }
}
@media (max-width: 430px) {
  .brand > span:last-child small { display: none; }
  .site-header { min-height: 56px; }
  .brand-mark { width: 37px; height: 37px; }
  .brand-mark img { width: 34px; height: 34px; }
  .learning-goal { align-items: start; }
  .stage-toolbar { display: grid; }
  .transport-controls { flex-direction: row; }
  .circuit-frame, #circuit-canvas { min-height: 390px; height: 390px; }
  .circuit-legend { right: 12px; }
  .current-badge { top: 10px; right: 10px; }
  .mode-buttons { grid-template-columns: 1fr; }
  .graph-card { grid-template-columns: 1fr; grid-template-rows: auto 120px auto; }
  .graph-card > span, .graph-card canvas, .graph-card > i { grid-column: 1; }
  .graph-card > span { grid-row: 1; }
  .graph-card canvas { grid-row: 2; }
  .graph-card > i { grid-row: 3; }
  .detail-graph-wrap { min-height: 285px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
