:root {
  --ink: #17202a;
  --muted: #64748b;
  --line: #d8e1e8;
  --surface: #ffffff;
  --soft: #f4f8fb;
  --teal: #0f7b83;
  --teal-dark: #0b5960;
  --green: #18a957;
  --yellow: #f5aa1b;
  --coral: #e94e3d;
  --brown: #5a3529;
  --shadow: 0 16px 40px rgba(35, 48, 65, .12);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  background: #edf3f6;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

.app-shell {
  min-height: 100vh;
}

.min-w-0 {
  min-width: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.icon-btn .bi {
  font-size: 1.05rem;
  line-height: 1;
}

.btn-primary {
  --bs-btn-bg: var(--teal);
  --bs-btn-border-color: var(--teal);
  --bs-btn-hover-bg: var(--teal-dark);
  --bs-btn-hover-border-color: var(--teal-dark);
}

.btn-success {
  --bs-btn-bg: var(--green);
  --bs-btn-border-color: var(--green);
}

.btn-warning {
  --bs-btn-bg: var(--yellow);
  --bs-btn-border-color: var(--yellow);
  --bs-btn-color: #2d2212;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr);
  min-height: 100vh;
}

.auth-visual {
  display: flex;
  align-items: center;
  padding: 42px;
  background: #dfeff1;
  border-right: 1px solid var(--line);
}

.auth-visual-inner {
  width: min(760px, 100%);
}

.auth-eyebrow,
.section-eyebrow {
  margin: 0 0 .45rem;
  color: var(--teal-dark);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-title {
  max-width: 620px;
  margin: 0 0 1rem;
  font-size: 2.25rem;
  line-height: 1.08;
  font-weight: 850;
}

.auth-copy {
  max-width: 620px;
  color: #425466;
  font-size: 1rem;
}

.auth-preview {
  margin-top: 30px;
  padding: 22px;
  border: 1px solid rgba(15, 123, 131, .2);
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--shadow);
}

.auth-preview img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
}

.auth-panel-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--surface);
}

.auth-panel {
  width: min(430px, 100%);
}

.auth-panel h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 820;
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 24px 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.auth-switch button {
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.auth-switch button.active {
  color: var(--teal-dark);
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(23, 32, 42, .08);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(216, 225, 232, .85);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 320px) auto;
  gap: 18px;
  align-items: center;
  padding: 14px 24px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  color: #fff;
  background: var(--teal);
  font-weight: 900;
}

.brand-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 840;
}

.brand-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
}

.progress-block {
  min-width: 0;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 750;
}

.progress {
  height: 10px;
  border-radius: 999px;
  background: #dce7ec;
}

.progress-bar {
  background: var(--green);
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.main-view {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.page-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-title {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.15;
  font-weight: 850;
}

.page-copy {
  margin: .45rem 0 0;
  color: var(--muted);
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: stretch;
}

.lab-stage,
.side-panel,
.tool-panel,
.training-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(47, 63, 82, .08);
}

.lab-stage {
  overflow: hidden;
}

.lab-scene {
  position: relative;
  min-height: 420px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(244, 248, 251, .96)),
    url("../img/storyboard-home.png") center / cover no-repeat;
}

.lab-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, .78);
}

.lab-scene > * {
  position: relative;
}

.assistant-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.assistant-avatar {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border-radius: 50%;
  border: 4px solid #fff;
  background: #e7f5f4;
  box-shadow: 0 8px 24px rgba(23, 32, 42, .12);
}

.assistant-avatar .bi {
  color: var(--teal);
  font-size: 3rem;
}

.assistant-bubble {
  padding: 14px 16px;
  border: 1px solid #cfe2e5;
  border-radius: 8px;
  background: #fff;
}

.assistant-bubble p {
  margin: 0;
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.activity-card {
  display: flex;
  min-height: 184px;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.activity-card:hover,
.activity-card:focus-within {
  transform: translateY(-3px);
  border-color: rgba(15, 123, 131, .35);
  box-shadow: 0 14px 28px rgba(15, 123, 131, .12);
}

.activity-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--teal);
}

.activity-card:nth-child(2) .activity-icon {
  background: var(--coral);
}

.activity-card:nth-child(3) .activity-icon {
  color: #2d2212;
  background: var(--yellow);
}

.activity-icon .bi {
  font-size: 1.7rem;
}

.activity-card h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 850;
}

.activity-card p {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-size: .93rem;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.mini-stat {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.mini-stat-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
}

.mini-stat p {
  margin: 0;
  color: var(--muted);
  font-size: .88rem;
}

.mini-stat strong {
  display: block;
  color: var(--ink);
}

.balance-sim {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 86px;
  gap: 18px;
  align-items: center;
  width: 100%;
  min-height: 250px;
  padding: 18px;
  border: 1px solid #cbd8df;
  border-radius: 8px;
  background: #fbfdfe;
}

.balance-sim.compact {
  min-height: 220px;
}

.pan-area {
  position: relative;
  display: grid;
  min-height: 192px;
  place-items: center;
}

.pan-plate {
  position: absolute;
  top: 52px;
  width: 142px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #eef8ff, #a9bdca);
  box-shadow: inset 0 -3px 0 rgba(42, 70, 85, .14);
}

.pan-stem {
  position: absolute;
  top: 66px;
  width: 8px;
  height: 88px;
  border-radius: 8px;
  background: #8aa8bc;
}

.pan-base {
  position: absolute;
  top: 151px;
  width: 90px;
  height: 18px;
  border-radius: 50%;
  background: #cfdbe2;
}

.pan-load {
  position: absolute;
  top: 8px;
  display: grid;
  width: 112px;
  min-height: 68px;
  place-items: center;
  text-align: center;
  pointer-events: none;
}

.pan-load img {
  display: block;
  max-width: 74px;
  max-height: 62px;
  object-fit: contain;
}

.pan-load span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}

.calibration-controls {
  position: absolute;
  right: 0;
  bottom: 4px;
  display: flex;
  gap: 8px;
}

.round-control {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #50697e;
  box-shadow: 0 8px 18px rgba(33, 50, 67, .18);
}

.round-control:hover {
  background: var(--teal);
}

.beam-area {
  display: grid;
  gap: 18px;
}

.beam-row {
  display: grid;
  grid-template-columns: 112px minmax(120px, 1fr) 68px;
  gap: 12px;
  align-items: center;
}

.beam-label {
  color: var(--teal-dark);
  font-size: .76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.beam-value {
  text-align: right;
  color: var(--ink);
  font-size: .85rem;
  font-weight: 850;
}

.rider-range {
  width: 100%;
  accent-color: var(--coral);
}

.rider-range:disabled {
  opacity: 1;
}

.total-panel {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #eafaff;
  background: #124b70;
  font-size: 1.05rem;
  font-weight: 850;
  text-align: center;
}

.z-index {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.z-box {
  position: relative;
  width: 58px;
  height: 164px;
  border: 2px solid #cbd8df;
  border-radius: 8px;
  background: #fff;
}

.z-line {
  position: absolute;
  top: 50%;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--coral);
}

.z-needle {
  --tilt: 0deg;
  position: absolute;
  top: 50%;
  left: 8px;
  width: 42px;
  height: 3px;
  border-radius: 999px;
  background: #1f3344;
  transform: rotate(var(--tilt));
  transform-origin: left center;
  transition: transform .22s ease;
}

.z-label {
  color: var(--yellow);
  font-size: .74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.training-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 18px;
}

.training-panel {
  padding: 18px;
}

.trainer-strip {
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 8px;
  background: #f7fafb;
}

.trainer-strip img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
}

.part-map {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.part-map img {
  display: block;
  width: 100%;
  height: auto;
}

.hotspot {
  position: absolute;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--coral);
  box-shadow: 0 6px 14px rgba(233, 78, 61, .34);
  font-weight: 900;
  transform: translate(-50%, -50%);
}

.hotspot:hover,
.hotspot.active {
  background: var(--teal);
}

.hotspot[data-part="1"] {
  left: 7.5%;
  top: 84%;
}

.hotspot[data-part="2"] {
  left: 20.5%;
  top: 84%;
}

.hotspot[data-part="3"] {
  left: 45.8%;
  top: 84%;
}

.hotspot[data-part="4"] {
  left: 62.5%;
  top: 84%;
}

.hotspot[data-part="5"] {
  left: 84.8%;
  top: 84%;
}

.part-info h2 {
  margin: .25rem 0 .65rem;
  font-size: 1.45rem;
  font-weight: 850;
}

.part-info p {
  color: var(--muted);
}

.lesson-audio {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.lesson-audio audio {
  display: block;
  width: 100%;
}

.experiment-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 18px;
}

.tool-panel {
  padding: 18px;
}

.object-tray {
  display: grid;
  gap: 10px;
}

.object-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 76px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: grab;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.object-card:hover,
.object-card.active {
  transform: translateY(-2px);
  border-color: rgba(15, 123, 131, .45);
  box-shadow: 0 12px 24px rgba(37, 54, 72, .09);
}

.object-card:active {
  cursor: grabbing;
}

.object-thumb {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 8px;
  background: var(--soft);
}

.object-thumb img {
  max-width: 48px;
  max-height: 48px;
}

.object-card strong {
  display: block;
}

.object-card span {
  color: var(--muted);
  font-size: .82rem;
}

.drop-hint {
  border: 2px dashed rgba(15, 123, 131, .38);
  background: rgba(15, 123, 131, .06);
}

.calibration-status {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 800;
}

.calibration-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 4px rgba(233, 78, 61, .12);
}

.calibration-light.ok {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(24, 169, 87, .16);
}

.answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 16px;
}

.quiz-shell {
  display: grid;
  gap: 18px;
}

.quiz-topline {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.quiz-object {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 850;
}

.quiz-object img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.result-panel {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 36px 18px;
  text-align: center;
}

.result-badge {
  display: grid;
  width: 78px;
  height: 78px;
  place-items: center;
  border-radius: 50%;
  color: #2d2212;
  background: var(--yellow);
  font-size: 2.1rem;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(520px, 100%);
}

.score-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.score-item strong {
  display: block;
  font-size: 1.35rem;
}

.dialog-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 50%;
  color: #fff;
  font-size: 1.8rem;
}

.dialog-icon.success {
  background: var(--green);
}

.dialog-icon.danger {
  background: var(--coral);
}

.dialog-icon.info {
  background: var(--teal);
}

.modal-content {
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-header,
.modal-footer {
  border-color: var(--line);
}

@media (max-width: 992px) {
  .auth-layout,
  .home-grid,
  .training-layout,
  .experiment-layout {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    min-height: auto;
    padding: 28px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .auth-title {
    font-size: 1.9rem;
  }

  .header-inner {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .header-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .main-view {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .auth-panel-wrap {
    padding: 22px;
  }

  .activity-grid,
  .score-grid {
    grid-template-columns: 1fr;
  }

  .lab-scene {
    padding: 16px;
  }

  .assistant-row {
    grid-template-columns: 1fr;
  }

  .balance-sim {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px;
  }

  .beam-row {
    grid-template-columns: 92px minmax(0, 1fr) 58px;
    gap: 8px;
  }

  .z-index {
    grid-template-columns: auto 1fr;
    justify-items: start;
  }

  .z-box {
    width: 100%;
    height: 58px;
  }

  .z-line,
  .z-needle {
    top: 50%;
  }

  .answer-row {
    grid-template-columns: 1fr;
  }

  .page-top,
  .quiz-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .hotspot {
    width: 36px;
    height: 36px;
    font-size: .9rem;
  }
}
