:root {
  --ink: #192320;
  --muted: #64706c;
  --line: #d5ddda;
  --paper: #ffffff;
  --ground: #edf1ef;
  --green: #1e745f;
  --green-soft: #d8eee5;
  --blue: #2469b2;
  --blue-soft: #dbeafb;
  --amber: #c77a18;
  --red: #ae3833;
  --charcoal: #283330;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--ground);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button { font: inherit; letter-spacing: 0; }

.app-shell {
  height: 100%;
  min-height: 680px;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
  color: white;
  background: var(--charcoal);
  border-bottom: 4px solid var(--amber);
}

.product-mark {
  display: block;
  color: #f6c66c;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h1 { margin: 3px 0 0; font-size: 25px; line-height: 1.15; }

.button-guide-title {
  display: block;
  margin-bottom: 5px;
  color: #aebbb7;
  font-size: 10px;
  font-weight: 800;
  text-align: right;
  text-transform: uppercase;
}

.button-status { display: flex; gap: 20px; }

.button-light {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #cbd4d1;
  font-size: 13px;
  font-weight: 700;
}

.button-light > span { display: grid; line-height: 1.05; }
.button-light b { font-size: 12px; }
.button-light small { margin-top: 4px; color: #9daba6; font-size: 10px; font-weight: 700; }

.button-light i {
  width: 11px;
  height: 11px;
  display: block;
  border-radius: 50%;
  background: #697571;
  border: 2px solid #92a09b;
}

.button-light.required { color: white; }
.button-light.required i { background: var(--red); border-color: #ef837d; box-shadow: 0 0 0 4px rgba(174, 56, 51, .22); }
.button-light.correct { color: white; }
.button-light.correct i { background: #35c48f; border-color: #8de5c5; box-shadow: 0 0 0 4px rgba(53, 196, 143, .2); }
.button-light.correct small { color: #8de5c5; }
.button-light.active:not(.required):not(.correct) i { background: #f6c66c; border-color: #f6c66c; }

.button-status.sequence-error .button-light i {
  animation: mouse-sequence-error 180ms steps(1, end) 4;
}

@keyframes mouse-sequence-error {
  0%, 49% { background: #ff4f47; border-color: #ffd0cd; box-shadow: 0 0 0 5px rgba(255, 79, 71, .28); }
  50%, 100% { background: #3d4945; border-color: #697571; box-shadow: none; }
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
}

.lesson-panel {
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.mode-switch button {
  height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #f7f9f8;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.mode-switch button:last-child { border-right: 0; }
.mode-switch button[aria-selected="true"] { color: white; background: var(--green); }

.lesson-copy { padding: 22px 0 18px; border-bottom: 1px solid var(--line); }
.lesson-number { color: var(--amber); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.lesson-copy h2 { margin: 6px 0 8px; font-size: 23px; }
.lesson-copy p { min-height: 66px; margin: 0; color: var(--muted); line-height: 1.5; }

.attempt-status {
  margin: 18px 0;
  padding: 14px;
  border-left: 4px solid var(--blue);
  background: var(--blue-soft);
}

.attempt-status strong, .attempt-status span { display: block; }
.attempt-status span { margin-top: 3px; color: var(--muted); font-size: 13px; }
.attempt-status[data-state="active"] { border-color: var(--amber); background: #fff0d6; }
.attempt-status[data-state="pass"] { border-color: var(--green); background: var(--green-soft); }
.attempt-status[data-state="fail"] { border-color: var(--red); background: #f9e1df; }

.coordinate-readout { margin: 0; border-top: 1px solid var(--line); }
.coordinate-readout div { min-height: 42px; display: grid; grid-template-columns: 76px 1fr; align-items: center; border-bottom: 1px solid var(--line); }
.coordinate-readout dt { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.coordinate-readout dd { margin: 0; text-align: right; font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px; }

.panel-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0 22px; }
.panel-actions button { min-height: 42px; border-radius: 5px; font-weight: 800; cursor: pointer; }
.secondary-action { border: 1px solid var(--line); color: var(--ink); background: white; }
.primary-action { border: 1px solid var(--green); color: white; background: var(--green); }
.primary-action:disabled { cursor: default; opacity: .42; }

.attempt-log { border-top: 1px solid var(--line); padding-top: 16px; }
.log-heading { display: flex; align-items: center; justify-content: space-between; }
.log-heading h3 { margin: 0; font-size: 16px; }
.log-heading button { border: 0; color: var(--blue); background: transparent; cursor: pointer; }
.attempt-log ol { margin: 12px 0 0; padding: 0; list-style: none; }
.attempt-log li { display: grid; grid-template-columns: auto 1fr; gap: 9px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.attempt-log .result { font-weight: 900; }
.attempt-log .pass .result { color: var(--green); }
.attempt-log .fail .result { color: var(--red); }
.attempt-log .empty-log { display: block; color: var(--muted); }

.practice-panel { min-width: 0; min-height: 0; padding: 18px; background: #cfd8d4; }

.viewport {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 520px;
  overflow: hidden;
  background: #f7faf9;
  border: 1px solid #b7c3bf;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

#scene { display: block; width: 100%; height: 100%; }

.model-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: rgba(247, 250, 249, .92);
  font-weight: 800;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.model-loading.hidden { opacity: 0; }

.mode-switch button[data-complete="true"] { color: var(--green); }

.center-reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  border: 2px solid #c43d2f;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 140ms ease;
}

.center-reticle::before,
.center-reticle::after {
  position: absolute;
  left: 50%;
  top: 50%;
  content: "";
  background: #c43d2f;
  transform: translate(-50%, -50%);
}

.center-reticle::before { width: 34px; height: 2px; }
.center-reticle::after { width: 2px; height: 34px; }
.center-reticle.active { opacity: 1; }

.zone {
  position: absolute;
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.zone span { padding: 3px 7px; border-radius: 3px; color: white; font-size: 11px; font-weight: 900; text-transform: uppercase; }
.start-zone { left: 28%; top: 64%; border: 3px dashed var(--blue); background: rgba(36, 105, 178, .08); }
.start-zone span { background: var(--blue); }
.target-zone { left: 72%; top: 36%; border: 3px dashed var(--green); background: rgba(30, 116, 95, .08); }
.target-zone span { background: var(--green); }
.zone.hit { border-style: solid; box-shadow: 0 0 0 8px rgba(30, 116, 95, .12); }

.cursor-coordinate, .gesture-badge {
  position: absolute;
  bottom: 12px;
  padding: 7px 10px;
  color: white;
  background: rgba(25, 35, 32, .84);
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
}

.cursor-coordinate { left: 12px; font-family: "Cascadia Mono", Consolas, monospace; }
.gesture-badge { right: 12px; font-weight: 800; }

@media (max-width: 820px) {
  .app-shell { height: auto; min-height: 100%; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .button-guide-title { text-align: left; }
  .workspace { grid-template-columns: 1fr; }
  .lesson-panel { overflow: visible; border-right: 0; }
  .practice-panel { height: 62vh; min-height: 520px; }
}
