:root {
  color-scheme: light;
  --ink: #17332d;
  --muted: #52645f;
  --paper: #fffefa;
  --canvas: #f7f4ec;
  --primary: #12624f;
  --primary-dark: #0b4538;
  --accent: #ffd84d;
  --line: #c9d4cf;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 280px;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.55;
}

button { font: inherit; }

.app-shell {
  width: min(100%, 72rem);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2.25rem);
}

.panel {
  width: min(100%, 42rem);
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 0.35rem 1.5rem rgb(23 51 45 / 9%);
}

.error-panel { border-color: #a33a32; }

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--primary);
  font-weight: 750;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.65rem, 6vw, 2.35rem);
  line-height: 1.15;
}

.instruction {
  margin: 0 0 1.25rem;
  font-size: clamp(1.1rem, 3vw, 1.3rem);
}

.button-stack,
.actions {
  display: grid;
  gap: 0.8rem;
}

.button {
  min-height: 3.25rem;
  padding: 0.8rem 1.15rem;
  border: 2px solid var(--primary);
  border-radius: 0.75rem;
  cursor: pointer;
  font-weight: 750;
}

.button-primary { color: #fff; background: var(--primary); }
.button-secondary { color: var(--primary-dark); background: #fff; }
.button:hover { filter: brightness(0.96); }
.button:disabled { cursor: default; }

.button:focus-visible,
.hotspot:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 3px;
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.25rem, 3vw, 2rem);
}

.lesson-copy {
  width: min(100%, 52rem);
  margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 1.75rem);
  background: var(--paper);
  border-radius: 1rem;
}

.device-stage {
  position: relative;
  width: min(100%, 50rem);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #eee9dd;
  cursor: pointer;
  touch-action: manipulation;
  contain: layout paint;
}

.device-stage.is-observe { cursor: default; }

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

.hotspot {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: var(--hit-width, calc(var(--w) * 1%));
  height: var(--hit-height, calc(var(--h) * 1%));
  padding: 0;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.hotspot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--visual-width, 100%);
  height: var(--visual-height, 100%);
  transform: translate(-50%, -50%);
  border: 4px solid transparent;
  border-radius: 50%;
  pointer-events: none;
}

.hotspot.is-highlighted::after {
  border-color: #fff;
  background: rgb(255 216 77 / 38%);
  box-shadow: 0 0 0 6px var(--primary), 0 0 0 11px rgb(255 255 255 / 88%);
  animation: calm-pulse 1.8s ease-in-out infinite;
}

.enlarge-button {
  width: min(100%, 50rem);
  margin: 0 auto -0.5rem;
}

.image-enlargement {
  display: grid;
  gap: 1rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: clamp(0.5rem, 2vw, 1rem);
  border: 2px solid var(--primary);
  border-radius: 1rem;
  background: var(--paper);
}

.image-enlargement__toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.image-enlargement__note {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 0.65rem;
  background: #eef7f3;
  font-weight: 650;
}

.image-enlargement__pan {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  touch-action: pan-x pan-y;
}

.image-enlargement__pan:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 3px;
}

.image-enlargement .device-stage { width: 100%; max-width: none; }
.image-enlargement__feedback { margin-top: 0; }
.lesson-layout.is-enlarged > .lesson-copy,
.lesson-layout.is-enlarged > .enlarge-button { display: none; }

.feedback {
  min-height: 3.5rem;
  margin: 1rem 0 0;
  padding: 0.8rem 1rem;
  border-left: 0.35rem solid var(--primary);
  border-radius: 0.4rem;
  background: #eef7f3;
  font-weight: 650;
}

.feedback:empty { visibility: hidden; }
.actions { margin-top: 1rem; }
.is-hidden { display: none; }
.small-note { color: var(--muted); font-size: 0.95rem; }

@keyframes calm-pulse {
  50% { box-shadow: 0 0 0 8px var(--primary), 0 0 0 15px rgb(255 255 255 / 65%); }
}

@media (min-width: 58rem) {
  .lesson-copy { padding-inline: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .hotspot.is-highlighted::after { animation: none; }
}

@media (max-width: 40rem) {
  .app-shell { padding: 0.75rem 0.25rem 1rem; }
  .lesson-layout { gap: 1rem; }
  .lesson-copy { width: calc(100% - 1rem); padding: 1rem; }
  .enlarge-button { width: calc(100% - 1rem); margin-bottom: -0.4rem; }
  .device-stage { width: 100%; border-radius: 0.75rem; }
  .image-enlargement { padding: 0.35rem; }
  .lesson-layout.is-enlarged { min-width: 0; overflow-x: clip; }
  .image-enlargement__pan .device-stage { width: 165vw; margin: 0; }
}
