:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --paper: #f4f7fb;
  --panel: #ffffff;
  --line: #d9e2ef;
  --blue: #2f6fed;
  --blue-strong: #1557d0;
  --green: #20a66a;
  --red: #ef4444;
  --amber: #f59e0b;
  --shadow: 0 24px 70px rgba(25, 38, 66, 0.16);
  --x: 0%;
  --y: 0%;
  --w: 10%;
  --h: 10%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.training-shell {
  min-height: 100vh;
  padding: 18px;
}

.workspace {
  width: min(1880px, 100%);
  margin: 0 auto;
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

.toolbar,
.controls,
.mode-switch {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-switch {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.lang-button,
.ghost-button,
.secondary-button,
.primary-button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, opacity 180ms ease;
}

.lang-button {
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
}

.lang-button.is-active {
  color: #fff;
  background: var(--ink);
}

.ghost-button,
.secondary-button {
  padding: 0 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--panel);
}

.primary-button {
  padding: 0 18px;
  color: #fff;
  background: var(--blue);
}

.primary-button:hover {
  background: var(--blue-strong);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary-button.full {
  width: 100%;
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
  align-items: start;
}

.stage {
  min-width: 0;
}

.simulator-frame {
  position: relative;
  overflow: auto;
  max-height: calc(100vh - 132px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.simulator-canvas {
  position: relative;
  width: 100%;
  min-width: 1180px;
}

.backend-image {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}

.focus-mask {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(11, 20, 38, 0.2);
}

.target-zone {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  border: 3px solid var(--red);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow:
    0 0 0 9999px rgba(11, 20, 38, 0.16),
    0 0 0 8px rgba(239, 68, 68, 0.14);
  cursor: pointer;
  animation: target-breathe 1.45s ease-in-out infinite;
}

.target-zone.is-wrong {
  animation: target-shake 300ms ease, target-breathe 1.45s ease-in-out infinite;
}

.pulse-dot {
  position: absolute;
  left: calc(var(--x) + var(--w) / 2);
  top: calc(var(--y) + var(--h) / 2);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--red);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.52);
  pointer-events: none;
  animation: dot-pulse 1.25s ease-out infinite;
}

.cursor-hand {
  position: absolute;
  left: calc(var(--x) + var(--w) * 0.74);
  top: calc(var(--y) + var(--h) * 0.72);
  width: 34px;
  height: 34px;
  pointer-events: none;
  background: center / contain no-repeat
    url("data:image/svg+xml,%3Csvg width='42' height='42' viewBox='0 0 42 42' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9 4L33 23.5L21.8 25.2L17.1 37L9 4Z' fill='white'/%3E%3Cpath d='M9 4L33 23.5L21.8 25.2L17.1 37L9 4Z' stroke='%23111827' stroke-width='2.5' stroke-linejoin='round'/%3E%3Cpath d='M21.2 25.4L29.2 34.6' stroke='%23111827' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
  filter: drop-shadow(0 8px 12px rgba(17, 24, 39, 0.28));
  transform: translate(-6px, -4px);
  animation: cursor-tap 1.65s ease-in-out infinite;
}

.training-input {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  display: none;
  border: 2px solid var(--blue);
  border-radius: 5px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 0 5px rgba(47, 111, 237, 0.14);
  z-index: 4;
}

.training-input.is-visible {
  display: block;
}

.mini-tip {
  position: absolute;
  left: min(calc(var(--x) + var(--w) + 1%), 78%);
  top: var(--y);
  max-width: 260px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 214, 10, 0.72);
  border-radius: 8px;
  color: #ffe100;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 12px 32px rgba(17, 24, 39, 0.16);
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.42),
    0 0 8px rgba(115, 84, 0, 0.28);
  backdrop-filter: blur(4px);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  pointer-events: none;
}

.loading-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 760;
  z-index: 5;
}

.loading-layer[hidden] {
  display: none;
}

.loader {
  width: 38px;
  height: 38px;
  border: 4px solid rgba(47, 111, 237, 0.2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.step-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.step-chip {
  min-width: 40px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--panel);
  cursor: pointer;
  font-weight: 760;
}

.step-chip.is-active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.step-chip.is-done {
  border-color: rgba(32, 166, 106, 0.32);
  color: var(--green);
  background: #eefaf4;
}

.lesson-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 14px;
}

.progress-card,
.instruction-card,
.practice-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 42px rgba(25, 38, 66, 0.08);
}

.progress-card {
  padding: 16px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.progress-track {
  overflow: hidden;
  height: 8px;
  border-radius: 99px;
  background: #e8eef8;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 260ms ease;
}

.instruction-card,
.practice-card {
  padding: 20px;
}

.panel-label {
  margin-bottom: 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.instruction-card h2,
.practice-card h2 {
  margin-bottom: 10px;
  font-size: 22px;
  line-height: 1.2;
}

.instruction-card p {
  color: var(--muted);
  line-height: 1.6;
}

.field-note {
  margin-top: 16px;
  padding: 14px;
  border-left: 3px solid var(--amber);
  border-radius: 6px;
  background: #fff8e8;
  color: #704b00;
  line-height: 1.55;
}

.action-feedback {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--red);
  font-weight: 760;
}

.action-feedback.is-ok {
  color: var(--green);
}

.check-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  position: relative;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.45;
}

.check-list li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.6em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  transform: translateY(-50%);
}

.check-list .check-list-heading {
  padding-left: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 820;
  text-transform: uppercase;
}

.check-list .check-list-heading::before {
  content: none;
}

.question-list {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.question-list label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.question-list input,
.question-list select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

.result-message {
  min-height: 24px;
  margin: 12px 0 0;
  font-weight: 720;
}

.result-message.is-ok {
  color: var(--green);
}

.result-message.is-error {
  color: var(--red);
}

.controls {
  justify-content: flex-end;
}

@keyframes target-breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.012);
  }
}

@keyframes target-shake {
  0%,
  100% {
    translate: 0 0;
  }
  25% {
    translate: -7px 0;
  }
  75% {
    translate: 7px 0;
  }
}

@keyframes dot-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
  }
  100% {
    box-shadow: 0 0 0 22px rgba(239, 68, 68, 0);
  }
}

@keyframes cursor-tap {
  0%,
  100% {
    transform: translate(-6px, -4px) scale(1);
  }
  52% {
    transform: translate(-11px, -9px) scale(1);
  }
  60% {
    transform: translate(-6px, -4px) scale(0.94);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .lesson-layout {
    grid-template-columns: 1fr;
  }

  .lesson-panel {
    position: static;
    grid-template-columns: 1fr 1fr;
  }

  .controls {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .training-shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
    justify-content: space-between;
  }

  .lesson-panel {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 25px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
