/* 공통 실험 UI. 색상은 .lab의 --lab-accent / --lab-soft로 재정의할 수 있다. */
.lab { --lab-accent: var(--accent, var(--physics)); --lab-soft: var(--accent-soft, var(--physics-soft)); }
.lab { padding-bottom: 80px; }
[hidden] { display: none !important; }
.lab-head { padding: 40px 0 20px; }
.lab-head .crumb { font-size: 14px; color: var(--text-mute); margin-bottom: 12px; }
.lab-head .crumb a:hover { color: var(--text); }
.lab-head h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; letter-spacing: -0.03em; }
.lab-head p { margin-top: 8px; color: var(--text-sub); }

/* ---------- Stepper ---------- */
.stepper {
  list-style: none; display: grid; grid-template-columns: repeat(var(--step-count, 6), 1fr); gap: 8px;
  margin: 8px 0 24px; counter-reset: step;
}
.stepper button {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg);
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text-mute); cursor: pointer; text-align: left; white-space: nowrap;
}
.stepper button:disabled { cursor: default; opacity: .55; }
.stepper .ico {
  flex: none; width: 28px; height: 28px; border-radius: 8px; background: var(--surface); display: grid; place-items: center;
}
.stepper .ico i {
  width: 18px; height: 18px; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.stepper .done button { color: var(--text-sub); }
.stepper .done .ico { background: var(--lab-soft); color: var(--lab-accent); }
.stepper .current button { border-color: var(--lab-accent); color: var(--text); box-shadow: 0 0 0 3px var(--lab-soft); }
.stepper .current .ico { background: var(--lab-accent); color: #fff; }

/* ---------- Layout ---------- */
.lab-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.col-left, .col-right { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col-left { position: sticky; top: 80px; }

/* ---------- Controls ---------- */
.controls { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--bg); }
.controls:empty { display: none; }
.controls h3, .work h3 { font-size: 14px; font-weight: 700; color: var(--text-mute); margin-bottom: 12px; }

.ctrl-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ctrl-row + .ctrl-row { margin-top: 16px; }
.ctrl-row label { font-size: 14px; font-weight: 600; min-width: 44px; }
.ctrl-row input[type=range] { flex: 1; min-width: 160px; accent-color: var(--lab-accent); height: 28px; }
.readout { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; min-width: 72px; text-align: right; }
.toggle {
  height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg);
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.toggle[aria-pressed=true] { background: #111; border-color: #111; color: #fff; }
.btn-sm { height: 44px; padding: 0 18px; font-size: 15px; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- Guide ---------- */
.guide { border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; background: var(--bg); }
.guide .step-no { font-size: 13px; font-weight: 700; color: var(--lab-accent); }
.guide h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 10px; }
.guide p { color: var(--text-sub); font-size: 15px; }
.guide .hero-img { width: 100%; border-radius: 12px; background: var(--surface); margin-bottom: 16px; display: block; }
.tasks { list-style: none; margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.tasks li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text-sub); }
.tasks li::before {
  content: ""; flex: none; width: 18px; height: 18px; margin-top: 2px; border-radius: 50%; border: 2px solid var(--line-strong);
}
.tasks li.ok { color: var(--text); }
.tasks li.ok::before {
  border-color: var(--biology); background: var(--biology)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.feedback { margin-top: 14px; padding: 10px 14px; border-radius: 10px; font-size: 14px; background: var(--surface); color: var(--text-sub); }
.feedback:empty { display: none; }
.feedback.warn { background: #fff4e5; color: #9a4b00; }
.feedback.good { background: var(--biology-soft); color: #0f6b32; }
.tip { margin-top: 12px; padding: 12px 14px; border-left: 3px solid var(--lab-accent); background: var(--lab-soft); border-radius: 0 10px 10px 0; font-size: 14px; color: #23408a; }

/* ---------- Work area ---------- */
.work { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--bg); }
.work:empty { display: none; }
.work > * + * { margin-top: 20px; }
.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.option {
  padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-align: left;
}
.option:hover { border-color: var(--line-strong); }
.option[aria-pressed=true] { border-color: var(--lab-accent); background: var(--lab-soft); color: #1d48c4; }
.option.right { border-color: var(--biology); background: var(--biology-soft); color: #0f6b32; }
.option.wrong { border-color: #f3b4b4; background: #fff1f1; color: #b42318; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th { font-weight: 600; color: var(--text-mute); text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.data td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--line); }
table.data th:first-child, table.data td:first-child { text-align: left; }
.table-wrap { max-height: 240px; overflow: auto; }
.empty-note { font-size: 14px; color: var(--text-mute); padding: 12px 0; }

.graph svg { width: 100%; height: auto; display: block; }
.graph .axis { stroke: #9aa1ab; stroke-width: 1.5; }
.graph .grid { stroke: #eef0f3; stroke-width: 1; }
.graph .tick { font-size: 12px; fill: var(--text-mute); }
.graph .label { font-size: 13px; fill: var(--text-sub); font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-sub); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.formula { text-align: center; padding: 24px; border-radius: 14px; background: var(--lab-soft); }
.formula b { display: block; font-size: 36px; font-weight: 800; letter-spacing: -0.02em; color: #1d48c4; }
.formula span { font-size: 14px; color: #23408a; }

.step-nav { display: flex; justify-content: space-between; gap: 12px; }
.step-nav .btn { height: 48px; }

.ghost { position: fixed; z-index: 100; width: 120px; pointer-events: none; transform: translate(-50%, -60%); filter: drop-shadow(0 8px 16px rgba(0,0,0,.18)); }
.ghost img { width: 100%; display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .stepper { grid-template-columns: repeat(var(--step-count, 6), auto); overflow-x: auto; padding-bottom: 4px; }
  .stepper .label { display: none; }
  .stepper .current .label { display: inline; }
  .lab-grid { display: flex; flex-direction: column; align-items: stretch; }
  .col-left, .col-right { display: contents; }
  .guide { order: 1; }
  .lab-stage, .bench { order: 2; }
  .controls { order: 3; }
  .work { order: 4; }
  .step-nav { order: 5; }
}
@media (max-width: 600px) {
  .lab-head { padding-top: 24px; }
  .guide, .work, .controls { padding: 16px; }
  .options { grid-template-columns: 1fr; }
}

/* 실험 제목 옆의 효과음 버튼 */
.sfx-toggle { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; color: var(--text-sub); border: 1px solid var(--line); border-radius: 50%; background: var(--bg); cursor: pointer; }
.sfx-toggle:hover { background: var(--surface); color: var(--text); }
.sfx-toggle:focus-visible { outline: 2px solid var(--accent, var(--physics)); outline-offset: 3px; }
.guide { scroll-margin-top: 80px; }
@media (max-width: 600px) {
  .sfx-toggle { width: 32px; height: 32px; }
}
