/* ─── CardioStrip · Educational EKG Simulator ─── */

:root {
  /* White · EMS blue · Gold */
  --bg: #f3f6fb;
  --bg-elevated: #ffffff;
  --bg-panel: rgba(255, 255, 255, 0.92);
  --bg-card: #ffffff;
  --bg-card-hover: #eef3fa;
  --border: rgba(0, 63, 135, 0.12);
  --border-strong: rgba(0, 63, 135, 0.22);
  --text: #0b1f3a;
  --text-muted: #4a5f78;
  --text-dim: #6b7f96;
  --accent: #c9a227;
  --accent-soft: #e8d48b;
  --accent-dim: rgba(201, 162, 39, 0.14);
  --accent-glow: rgba(201, 162, 39, 0.32);
  --cyan: #0057b8;
  --cyan-dim: rgba(0, 87, 184, 0.1);
  --amber: #c9a227;
  --amber-dim: rgba(201, 162, 39, 0.14);
  --rose: #c43c4e;
  --rose-dim: rgba(196, 60, 78, 0.1);
  --violet: #3d5a80;
  --violet-dim: rgba(61, 90, 128, 0.1);
  --success: #1a8f5c;
  --danger: #c43c4e;
  --paper: #ffffff;
  --ems: #003f87;
  --ems-mid: #0057b8;
  --ems-light: #2b7fd4;
  --gold: #c9a227;
  --gold-bright: #d4af37;
  --gold-soft: #f5e9c0;
  --surface: rgba(0, 63, 135, 0.04);
  --surface-hover: rgba(0, 63, 135, 0.07);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 9px;
  --shadow: 0 12px 40px rgba(0, 63, 135, 0.1);
  --shadow-soft: 0 6px 20px rgba(0, 63, 135, 0.08);
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sidebar-w: 300px;
  --header-h: 72px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(201, 162, 39, 0.35);
  color: #0b1f3a;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

kbd {
  font-family: var(--mono);
  font-size: 0.72em;
  font-weight: 600;
  padding: 0.12em 0.4em;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: 0 1px 0 rgba(0, 63, 135, 0.18);
}

/* ─── Ambient background ─── */

.bg-fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: orb-drift 18s var(--ease) infinite alternate;
}

.bg-orb-a {
  width: 520px;
  height: 520px;
  top: -12%;
  left: -8%;
  background: radial-gradient(circle, rgba(0, 87, 184, 0.18), transparent 68%);
}

.bg-orb-b {
  width: 460px;
  height: 460px;
  top: -8%;
  right: -6%;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.18), transparent 68%);
  animation-delay: -6s;
}

.bg-orb-c {
  width: 480px;
  height: 480px;
  bottom: -18%;
  left: 35%;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.12), transparent 70%);
  animation-delay: -11s;
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 63, 135, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 63, 135, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, #000 20%, transparent 75%);
}

.bg-noise {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

@keyframes orb-drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(30px, 24px) scale(1.08); }
}

/* ─── App shell ─── */

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-footer {
  margin-top: auto;
  flex-shrink: 0;
  padding: 0.75rem 1.5rem 1rem;
  text-align: center;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.site-footer p {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--ems);
  opacity: 0.75;
  font-weight: 500;
}

.hidden {
  display: none !important;
}

/* ─── Header ─── */

.header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  min-height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  justify-self: start;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 14px var(--accent-glow));
  transition: transform 0.35s var(--ease), filter 0.35s var(--ease);
}

.brand:hover .brand-mark {
  transform: scale(1.04) rotate(-2deg);
  filter: drop-shadow(0 0 20px var(--accent-glow));
}

.brand-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-text h1 {
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  background: linear-gradient(135deg, var(--ems) 0%, var(--ems-mid) 55%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-text p {
  font-size: 0.76rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.mode-switch {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 var(--surface);
  gap: 2px;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.05rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s;
}

.mode-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.mode-btn.active {
  color: #0b1f3a;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  box-shadow: 0 4px 18px rgba(201, 162, 39, 0.28);
}

.mode-btn.active svg {
  stroke: #0b1f3a;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  justify-self: end;
}

.pill {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  backdrop-filter: blur(8px);
}

.pill-accent {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(201, 162, 39, 0.28);
  box-shadow: 0 0 20px rgba(201, 162, 39, 0.1);
}

/* ─── Learn layout ─── */

.main {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  flex: 1;
  min-height: 0;
}

.main-quiz {
  grid-template-columns: 1fr;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2.5rem;
}

/* ─── Sidebar ─── */

.sidebar {
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #f5f8fc);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 87, 184, 0.22) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 87, 184, 0.2);
  border-radius: 99px;
}

.sidebar-head {
  padding: 1.35rem 1.2rem 0.85rem;
}

.sidebar-kicker {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 0.45rem;
}

.sidebar-head h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 0.45rem;
}

.sidebar-head p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.rhythm-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem 1rem;
  flex: 1;
}

.rhythm-btn {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.12rem 0.8rem;
  align-items: center;
  text-align: left;
  padding: 0.78rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition:
    background 0.2s var(--ease),
    border-color 0.2s var(--ease),
    transform 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.rhythm-btn:hover {
  background: var(--surface);
  border-color: var(--border);
  transform: translateX(2px);
}

.rhythm-btn.active {
  background: linear-gradient(135deg, rgba(201, 162, 39, 0.12), rgba(0, 87, 184, 0.06));
  border-color: rgba(201, 162, 39, 0.35);
  box-shadow:
    0 0 0 1px rgba(201, 162, 39, 0.2),
    0 8px 24px rgba(0, 63, 135, 0.1);
}

.rhythm-btn .idx {
  grid-row: span 2;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.rhythm-btn.active .idx {
  color: #0b1f3a;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(201, 162, 39, 0.25);
}

.rhythm-btn .r-name {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.rhythm-btn .r-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: var(--mono);
}

.rhythm-btn.active .r-meta {
  color: var(--text-muted);
}

.sidebar-foot {
  padding: 1rem 1.15rem 1.25rem;
  border-top: 1px solid var(--border);
}

.disclaimer-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.4;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-xs);
  background: var(--surface);
  border: 1px solid var(--border);
}

.disclaimer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.45);
  flex-shrink: 0;
}

/* ─── Workspace ─── */

.workspace {
  padding: 1.35rem 1.5rem 2.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

/* Explicit stack under the strip (DOM order reinforced) */
.workspace > .strip-panel { order: 1; }
.workspace > .info-grid-primary { order: 2; } /* How to Identify + Salient Features */
.workspace > .tools-row { order: 3; } /* Systematic Approach + Rate Helper */
.workspace > .info-grid-secondary { order: 4; } /* Clinical + Waveform */

.glass-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  overflow: hidden;
  position: relative;
}

.glass-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201, 162, 39, 0.25), transparent);
  pointer-events: none;
  z-index: 1;
}

.strip-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.35rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  background: linear-gradient(180deg, var(--surface), transparent);
}

.title-kicker {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 0.35rem;
}

.strip-title-block h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.strip-title-block p {
  margin-top: 0.3rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 52ch;
}

.strip-controls {
  display: flex;
  gap: 0.55rem;
  flex-shrink: 0;
}

/* ─── Buttons ─── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.58rem 1rem;
  border-radius: 11px;
  font-size: 0.86rem;
  font-weight: 600;
  transition:
    background 0.18s var(--ease),
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    transform 0.12s var(--ease),
    color 0.18s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.975);
}

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: rgba(0, 63, 135, 0.22);
}

.btn-primary {
  background: linear-gradient(135deg, #2b7fd4, #0057b8 55%, #003f87);
  color: #ffffff;
  border: 1px solid rgba(0, 87, 184, 0.35);
  box-shadow:
    0 4px 18px rgba(0, 63, 135, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-primary:hover {
  box-shadow:
    0 8px 26px rgba(0, 63, 135, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  filter: brightness(1.05);
}

.btn-primary[aria-pressed="true"] {
  background: linear-gradient(135deg, #d4af37, #c9a227 55%, #a8861a);
  border-color: rgba(0, 87, 184, 0.4);
  box-shadow: 0 4px 18px rgba(0, 63, 135, 0.28);
}

.btn-lg {
  padding: 0.85rem 1.4rem;
  font-size: 0.95rem;
  border-radius: 13px;
}

/* ─── Canvas ─── */

.canvas-shell {
  padding: 0.95rem 1.2rem 1.1rem;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), transparent 45%),
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(0, 87, 184, 0.04), transparent 60%);
}

.canvas-chrome {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.7rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.chrome-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  animation: pulse 2.2s ease-in-out infinite;
}

.chrome-dot.quiz-dot {
  background: var(--ems-mid);
  box-shadow: 0 0 10px rgba(0, 87, 184, 0.4);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.chrome-label {
  flex: 1;
  letter-spacing: 0.01em;
}

.chrome-stats {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--cyan);
  letter-spacing: 0.02em;
}

.chrome-stats.muted {
  color: var(--text-dim);
}

.canvas-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 200, 255, 0.25) transparent;
  display: flex;
  justify-content: center;
  align-items: center;
}

.canvas-frame {
  position: relative;
  border-radius: 12px;
  padding: 3px;
  background: linear-gradient(135deg, rgba(201, 162, 39, 0.28), rgba(0, 87, 184, 0.16), rgba(0, 63, 135, 0.1));
  box-shadow:
    0 0 0 1px rgba(0, 63, 135, 0.18),
    0 12px 36px rgba(0, 63, 135, 0.16);
  width: 100%;
  margin-inline: auto;
}

.canvas-frame::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px var(--surface-hover);
  pointer-events: none;
}

#ekg-canvas,
#quiz-canvas,
#compare-canvas-a,
#compare-canvas-b {
  display: block;
  width: 100%;
  height: auto;
  min-height: 200px;
  border-radius: 10px;
  background: var(--paper);
  cursor: crosshair;
  vertical-align: middle;
}

/* Life size (default) = true paper scale: 25 mm/s × 6 s = 150 mm wide; ~10 mm/mV tall */
html.strip-life-size .canvas-scroll {
  padding: 0.35rem 0 0.5rem;
  justify-content: center;
  /* Allow horizontal scroll when viewport < 150mm, still prefer centered content */
  scroll-snap-type: x proximity;
}

html.strip-life-size .canvas-frame {
  width: 150mm;
  max-width: none;
  flex-shrink: 0;
  margin-inline: auto;
  scroll-snap-align: center;
}

html.strip-life-size #ekg-canvas,
html.strip-life-size #quiz-canvas {
  width: 150mm !important;
  height: 52mm !important;
  min-height: 0;
  max-width: none;
}

html.strip-life-size #compare-canvas-a,
html.strip-life-size #compare-canvas-b {
  width: 150mm !important;
  height: 48mm !important;
  min-height: 0;
  max-width: none;
}

html.strip-life-size .canvas-shell {
  /* subtle cue that you're in calibrated view */
  box-shadow: inset 0 0 0 1px rgba(0, 87, 184, 0.1);
  border-radius: 0 0 12px 12px;
}

/* Zoomed (fit width) — strip fills the panel */
html:not(.strip-life-size) .canvas-scroll {
  justify-content: stretch;
}

html:not(.strip-life-size) .canvas-frame {
  width: 100%;
  margin-inline: 0;
}

.leg-scale {
  color: var(--cyan);
}

html.strip-life-size .leg-scale {
  color: var(--accent);
  font-weight: 600;
}

/* Mobile: suggest landscape for full life-size 6 s strip (~150 mm) */
.mobile-strip-tip {
  display: none;
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(0, 87, 184, 0.28);
  background: linear-gradient(135deg, rgba(0, 87, 184, 0.1), rgba(201, 162, 39, 0.08));
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.mobile-strip-tip strong {
  color: var(--cyan);
  font-weight: 700;
}

.compare-mobile-tip {
  margin-top: 0.75rem;
}

@media (max-width: 900px) {
  html.strip-life-size .mobile-strip-tip {
    display: block;
  }
}

/* Especially useful in portrait — still show on small landscape phones if narrow */
@media (max-width: 900px) and (orientation: portrait) {
  html.strip-life-size .mobile-strip-tip {
    border-color: rgba(201, 162, 39, 0.4);
  }
}

.canvas-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.75rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: var(--mono);
}

.canvas-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.leg-box {
  display: inline-block;
  border: 1px solid rgba(220, 90, 90, 0.55);
  background: rgba(220, 90, 90, 0.08);
  border-radius: 2px;
}

.leg-box.small {
  width: 8px;
  height: 8px;
}

.leg-box.large {
  width: 14px;
  height: 14px;
  border-width: 1.5px;
}

.leg-time {
  margin-left: auto;
  color: var(--text-muted);
}

/* ─── Info cards ─── */

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem 1.3rem;
  transition:
    border-color 0.25s var(--ease),
    background 0.25s var(--ease),
    transform 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  opacity: 0;
  transition: opacity 0.25s;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
}

.card:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

.card:hover::after {
  opacity: 1;
}

.card-identify::after { background: linear-gradient(90deg, var(--ems-mid), var(--gold)); }
.card-features::after { background: linear-gradient(90deg, var(--gold), var(--ems-light)); }
.card-clinical::after { background: linear-gradient(90deg, var(--ems), var(--ems-mid)); }
.card-waveform::after { background: linear-gradient(90deg, var(--gold-bright), var(--ems)); }

.card-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.95rem;
}

.card-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  flex-shrink: 0;
}

.icon-search { background: var(--accent-dim); color: var(--accent); }
.icon-bolt { background: var(--cyan-dim); color: var(--cyan); }
.icon-notes { background: var(--amber-dim); color: var(--amber); }
.icon-wave { background: var(--violet-dim); color: var(--violet); }

.card-head h3 {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.identify-list {
  padding-left: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.identify-list li {
  font-size: 0.9rem;
  color: var(--text);
  padding-left: 0.3rem;
  line-height: 1.5;
}

.identify-list li::marker {
  color: var(--accent);
  font-weight: 700;
}

.feature-list {
  display: grid;
  gap: 0.55rem;
}

.feature-list dt {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--cyan);
  margin-bottom: 0.12rem;
}

.feature-list dd {
  font-size: 0.88rem;
  color: var(--text);
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
  line-height: 1.45;
}

.feature-list > div:last-child dd {
  border-bottom: none;
  padding-bottom: 0;
}

#clinical-notes {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 0.95rem;
}

.condition-callout {
  margin-bottom: 0.95rem;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(201, 162, 39, 0.12), rgba(0, 87, 184, 0.06));
  border: 1px solid rgba(201, 162, 39, 0.28);
  border-left: 3px solid var(--amber);
}

.condition-kicker {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 0.35rem;
}

#condition-note {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.55;
  margin: 0;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  font-family: var(--mono);
  border: 1px solid transparent;
}

.tag-rate {
  background: var(--cyan-dim);
  color: var(--cyan);
  border-color: rgba(0, 87, 184, 0.2);
}
.tag-urgency-low {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(201, 162, 39, 0.28);
}
.tag-urgency-mod {
  background: var(--amber-dim);
  color: var(--amber);
  border-color: rgba(201, 162, 39, 0.28);
}
.tag-urgency-high {
  background: var(--rose-dim);
  color: var(--rose);
  border-color: rgba(196, 60, 78, 0.25);
}
.tag-type {
  background: var(--violet-dim);
  color: var(--violet);
  border-color: rgba(0, 63, 135, 0.18);
}

.wave-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.wave-list li {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 0.7rem;
  font-size: 0.88rem;
  align-items: start;
  padding: 0.45rem 0.5rem;
  margin: 0 -0.5rem;
  border-radius: 8px;
  transition: background 0.15s;
}

.wave-list li:hover {
  background: var(--surface);
}

.wave-list .wave-name {
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent);
  padding-top: 0.1rem;
}

.wave-list .wave-desc {
  color: var(--text-muted);
  line-height: 1.45;
}

/* ═══════════════════════════════════
   QUIZ MODE
   ═══════════════════════════════════ */

.quiz-stage {
  width: 100%;
  animation: fade-up 0.4s var(--ease);
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Setup hero */

.quiz-hero {
  padding: 2.5rem 2.25rem 2.25rem;
  text-align: center;
  max-width: 720px;
  margin: 1rem auto 0;
}

.quiz-hero-glow {
  position: absolute;
  top: -40%;
  left: 50%;
  transform: translateX(-50%);
  width: 70%;
  height: 220px;
  background: radial-gradient(ellipse, rgba(201, 162, 39, 0.16), transparent 70%);
  pointer-events: none;
}

.quiz-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(201, 162, 39, 0.28);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 1.1rem;
  position: relative;
}

.quiz-hero h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin-bottom: 0.75rem;
  position: relative;
  background: linear-gradient(135deg, #fff 20%, var(--accent-soft) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.quiz-lead {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 48ch;
  margin: 0 auto 1.75rem;
  line-height: 1.6;
  position: relative;
}

.quiz-config {
  display: grid;
  gap: 1.15rem;
  max-width: 420px;
  margin: 0 auto 1.5rem;
  text-align: left;
  position: relative;
}

.config-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.config-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.segmented {
  display: flex;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0, 63, 135, 0.45);
  border: 1px solid var(--border);
  gap: 3px;
}

.seg-btn {
  flex: 1;
  padding: 0.55rem 0.65rem;
  border-radius: 9px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}

.seg-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.seg-btn.active {
  color: #0b1f3a;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  box-shadow: 0 4px 14px rgba(201, 162, 39, 0.25);
}

.quiz-tips {
  list-style: none;
  text-align: left;
  max-width: 460px;
  margin: 0 auto 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  position: relative;
}

.quiz-tips li {
  font-size: 0.88rem;
  color: var(--text-muted);
  padding: 0.65rem 0.85rem 0.65rem 1rem;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid rgba(201, 162, 39, 0.5);
  line-height: 1.45;
}

.quiz-tips strong {
  color: var(--text);
  font-weight: 600;
}

/* Progress bar */

.quiz-progress-bar {
  padding: 1rem 1.25rem 1.1rem;
  margin-bottom: 1rem;
}

.quiz-progress-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.q-counter {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.quiz-score-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-left: auto;
}

.score-pill {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.score-correct {
  color: var(--success);
  background: rgba(94, 228, 160, 0.1);
  border-color: rgba(94, 228, 160, 0.22);
}

.score-wrong {
  color: var(--rose);
  background: var(--rose-dim);
  border-color: rgba(255, 122, 138, 0.22);
}

.score-streak {
  color: var(--amber);
  background: var(--amber-dim);
  border-color: rgba(255, 200, 87, 0.22);
}

.quiz-timer-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.timer-ring {
  width: 28px;
  height: 28px;
}

.timer-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: rgba(0, 63, 135, 0.12);
  stroke-width: 3;
}

.timer-fg {
  fill: none;
  stroke: var(--amber);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 97.4;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.2s linear, stroke 0.2s;
}

.timer-fg.urgent {
  stroke: var(--rose);
}

.timer-text {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--amber);
  min-width: 1.5rem;
}

.timer-text.urgent {
  color: var(--rose);
}

.progress-track {
  height: 5px;
  border-radius: 99px;
  background: var(--surface-hover);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  box-shadow: 0 0 12px rgba(201, 162, 39, 0.4);
  transition: width 0.4s var(--ease);
}

.quiz-strip {
  margin-bottom: 1rem;
}

/* Choices */

.quiz-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.choice-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  text-align: left;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  transition:
    border-color 0.2s var(--ease),
    background 0.2s var(--ease),
    transform 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
  position: relative;
  overflow: hidden;
}

.choice-btn:hover:not(:disabled) {
  border-color: rgba(201, 162, 39, 0.4);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

.choice-btn:disabled {
  cursor: default;
}

.choice-key {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
  transition: all 0.2s;
}

.choice-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.choice-name {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.choice-meta {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

.choice-btn.correct {
  border-color: rgba(94, 228, 160, 0.55);
  background: linear-gradient(135deg, rgba(94, 228, 160, 0.14), rgba(94, 228, 160, 0.04));
  box-shadow: 0 0 0 1px rgba(94, 228, 160, 0.15), 0 8px 28px rgba(40, 140, 90, 0.2);
}

.choice-btn.correct .choice-key {
  background: rgba(94, 228, 160, 0.2);
  color: var(--success);
  border-color: rgba(94, 228, 160, 0.4);
}

.choice-btn.incorrect {
  border-color: rgba(255, 107, 125, 0.5);
  background: linear-gradient(135deg, rgba(255, 107, 125, 0.12), rgba(255, 107, 125, 0.03));
}

.choice-btn.incorrect .choice-key {
  background: rgba(255, 107, 125, 0.18);
  color: var(--danger);
  border-color: rgba(255, 107, 125, 0.35);
}

.choice-btn.dimmed {
  opacity: 0.45;
}

/* Feedback */

.quiz-feedback {
  animation: fade-up 0.35s var(--ease);
}

.feedback-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.15rem;
  padding: 1.2rem 1.35rem;
}

.feedback-status {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.feedback-card.is-correct .feedback-status {
  background: rgba(94, 228, 160, 0.15);
  box-shadow: 0 0 24px rgba(94, 228, 160, 0.2);
}

.feedback-card.is-wrong .feedback-status {
  background: rgba(255, 107, 125, 0.14);
  box-shadow: 0 0 24px rgba(255, 107, 125, 0.18);
}

.feedback-body {
  flex: 1;
  min-width: 200px;
}

.feedback-body h3 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.feedback-card.is-correct .feedback-body h3 {
  color: var(--success);
}

.feedback-card.is-wrong .feedback-body h3 {
  color: var(--danger);
}

.feedback-body p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.65rem;
}

#btn-quiz-next {
  margin-left: auto;
}

/* Results */

.results-panel {
  padding: 2.25rem 2rem 2rem;
  max-width: 720px;
  margin: 0.5rem auto 0;
  text-align: center;
}

.results-glow {
  position: absolute;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 200px;
  background: radial-gradient(ellipse, rgba(0, 87, 184, 0.12), transparent 70%);
  pointer-events: none;
}

.results-header {
  position: relative;
  margin-bottom: 1.5rem;
}

.results-header h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0.75rem 0 0.4rem;
}

.results-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.results-score-ring {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 1.5rem;
}

.score-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-ring-bg {
  fill: none;
  stroke: rgba(0, 63, 135, 0.1);
  stroke-width: 8;
}

.score-ring-fg {
  fill: none;
  stroke: url(#none);
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 1s var(--ease);
}

.score-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-pct {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.score-frac {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.results-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  margin-bottom: 1.75rem;
  position: relative;
}

.stat-tile {
  padding: 0.9rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

.stat-val {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.stat-lbl {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.results-review {
  text-align: left;
  margin-bottom: 1.75rem;
  position: relative;
}

.results-review h3 {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.review-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 280px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 87, 184, 0.22) transparent;
}

.review-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 0.85rem;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.88rem;
}

.review-item.ok {
  border-color: rgba(94, 228, 160, 0.2);
}

.review-item.miss {
  border-color: rgba(255, 122, 138, 0.22);
}

.review-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.review-item.ok .review-mark {
  background: rgba(94, 228, 160, 0.14);
  color: var(--success);
}

.review-item.miss .review-mark {
  background: rgba(255, 122, 138, 0.14);
  color: var(--rose);
}

.review-main {
  min-width: 0;
}

.review-name {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.review-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}

.review-time {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-dim);
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  position: relative;
}

/* ─── Responsive ─── */

@media (max-width: 980px) {
  .header {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
  }

  .brand {
    justify-self: center;
  }

  .header-meta {
    justify-content: center;
    justify-self: center;
  }

  .main {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    min-height: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .rhythm-nav {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    padding-bottom: 1rem;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .quiz-choices {
    grid-template-columns: 1fr;
  }

  .results-stats {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 1rem;
  }

  .main-quiz {
    padding: 1rem 0.85rem 2rem;
  }

  .strip-toolbar {
    flex-direction: column;
  }

  .leg-time {
    margin-left: 0;
  }

  .quiz-hero {
    padding: 1.75rem 1.25rem 1.5rem;
  }

  .feedback-card {
    flex-direction: column;
    align-items: stretch;
  }

  #btn-quiz-next {
    margin-left: 0;
    width: 100%;
  }

  .results-panel {
    padding: 1.5rem 1.15rem;
  }

  .quiz-score-pills {
    margin-left: 0;
  }
}

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

/* ═══════════════════════════════════
   NEW EDUCATIONAL FEATURES
   ═══════════════════════════════════ */

.pill-btn {
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s, transform 0.12s;
}
.pill-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.pill-btn:active { transform: scale(0.97); }

.btn.active-tool {
  color: var(--cyan);
  border-color: rgba(0, 87, 184, 0.4);
  background: var(--cyan-dim);
  box-shadow: 0 0 16px rgba(0, 87, 184, 0.14);
}

.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  border-radius: 9px;
}

.btn-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-left: auto;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
}
.btn-text:hover {
  color: var(--text);
  background: var(--surface);
}

#ekg-canvas.caliper-cursor {
  cursor: col-resize;
}

.caliper-readout {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: rgba(0, 87, 184, 0.1);
  border: 1px solid rgba(0, 87, 184, 0.18);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--cyan);
}

/* Directly under strip — same 2-column footprint as the old tools row */
.info-grid-primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Stack identify + features on mobile (overrides 2-col above; general .info-grid MQ is not enough) */
@media (max-width: 980px) {
  .info-grid-primary {
    grid-template-columns: 1fr;
  }
}

/* Below identify/features: compact approach + rate helper */
.tools-row {
  display: grid;
  grid-template-columns: minmax(200px, 0.72fr) 1.28fr;
  gap: 0.85rem;
  align-items: start;
}

.card-approach::after { background: linear-gradient(90deg, var(--ems), var(--gold)); }
.card-rate-helper::after { background: linear-gradient(90deg, var(--gold), var(--ems-mid)); }

.card-approach-compact {
  padding: 0.75rem 0.85rem 0.85rem;
}

.card-approach-compact .card-head {
  margin-bottom: 0.55rem;
}

.card-approach-compact .card-head h3 {
  font-size: 0.72rem;
}

.card-approach-compact .card-icon {
  width: 26px;
  height: 26px;
}

.icon-list { background: var(--cyan-dim); color: var(--cyan); }
.icon-calc { background: var(--amber-dim); color: var(--amber); }

.approach-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.card-approach-compact .approach-list {
  gap: 0.22rem;
}

.approach-step label {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.card-approach-compact .approach-step label {
  gap: 0.45rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
}

.approach-step label:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}

.approach-step.done label {
  border-color: rgba(201, 162, 39, 0.28);
  background: rgba(201, 162, 39, 0.08);
}

.approach-step input {
  margin-top: 0.2rem;
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.card-approach-compact .approach-step input {
  margin-top: 0.12rem;
  width: 13px;
  height: 13px;
}

.as-body {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}

.as-title {
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
}

.card-approach-compact .as-title {
  font-size: 0.78rem;
}

.as-prompt {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.card-approach-compact .as-prompt {
  font-size: 0.7rem;
  line-height: 1.3;
}

.as-answer {
  display: block;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 0.35rem;
  line-height: 1.4;
}

.card-approach-compact .as-answer {
  font-size: 0.72rem;
  margin-top: 0.2rem;
}

.approach-hint {
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
}

.card-approach-compact .approach-hint {
  margin-top: 0.45rem;
  font-size: 0.68rem;
  line-height: 1.35;
}

.rate-helper-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.rate-methods {
  display: grid;
  gap: 0.5rem;
}

.rate-method {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.1rem 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.rm-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.rm-value {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--amber);
  grid-row: span 2;
  align-self: center;
  text-align: right;
}

.rm-note {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: var(--mono);
}

.rate-sequence-block {
  padding: 0.75rem 0.8rem;
  border-radius: 12px;
  background: rgba(0, 63, 135, 0.12);
  border: 1px solid var(--border);
}

.rs-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.2rem;
}

.rs-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 0.65rem;
  line-height: 1.4;
}

.rate-sequence {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.rs-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  padding: 0.45rem 0.25rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--mono);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.15s;
}

.rs-boxes {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-weight: 600;
}

.rs-boxes::after {
  content: " box";
  font-weight: 500;
  opacity: 0.8;
}

.rs-step[data-boxes="1"] .rs-boxes::after {
  content: " box";
}

.rs-step:not([data-boxes="1"]) .rs-boxes::after {
  content: " boxes";
}

.rs-arrow {
  font-size: 0.65rem;
  color: var(--text-dim);
  line-height: 1;
}

.rs-bpm {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.rs-bpm::after {
  content: "";
}

.rs-step.active {
  border-color: rgba(201, 162, 39, 0.45);
  background: rgba(255, 200, 87, 0.12);
  box-shadow: 0 0 16px rgba(255, 200, 87, 0.12);
  transform: translateY(-1px);
}

.rs-step.active .rs-bpm {
  color: var(--amber);
}

.rs-step.near {
  border-color: rgba(0, 87, 184, 0.28);
  background: rgba(0, 87, 184, 0.07);
}

.rs-step.rs-slow .rs-bpm {
  color: var(--rose);
}

.rs-match {
  margin-top: 0.65rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  font-family: var(--mono);
}

.rs-agonal-note {
  margin-top: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 9px;
  border: 1px solid rgba(255, 122, 138, 0.25);
  background: rgba(255, 122, 138, 0.08);
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.rs-agonal-note strong {
  color: var(--rose);
  font-weight: 600;
}

.rate-tip {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

@media (max-width: 560px) {
  .rate-sequence {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Compare mode */
.main-compare {
  grid-template-columns: 1fr;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.35rem 1.5rem 2.25rem;
}

.compare-workspace {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.compare-intro {
  padding: 1.25rem 1.4rem;
}

.compare-intro h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0.2rem 0 0.35rem;
}

.compare-intro p {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.compare-col {
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.compare-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.select-input {
  flex: 1;
  min-width: 140px;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: rgba(0, 63, 135, 0.45);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.select-input:focus {
  border-color: rgba(0, 87, 184, 0.35);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.12);
}

#compare-canvas-a,
#compare-canvas-b {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: var(--paper);
}

.compare-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cm-name {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.015em;
}

.cm-stats {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--cyan);
}

.cm-hallmark {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.compare-diff {
  padding: 1.2rem 1.35rem;
}

.diff-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: start;
  margin-top: 0.75rem;
}

.diff-col h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.diff-col ul {
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.diff-col li {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.diff-vs {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  padding-top: 0.35rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.diff-foot {
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
}

/* Quiz extras */
.quiz-stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
  max-width: 480px;
  margin: 0 auto 1.5rem;
  position: relative;
}

.mini-stat {
  padding: 0.7rem 0.4rem;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.ms-val {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.1rem;
}

.ms-lbl {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.toggle-row {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  background: rgba(0, 63, 135, 0.12);
  border: 1px solid var(--border);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
}

.toggle input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.vignette-box {
  margin-top: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(0, 63, 135, 0.08), rgba(0, 87, 184, 0.07));
  border: 1px solid rgba(0, 63, 135, 0.2);
  border-left: 3px solid var(--violet);
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
  max-width: 62ch;
}

/* Modals */
body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 35, 75, 0.55);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  animation: fade-up 0.25s var(--ease);
}

.modal {
  width: min(640px, 100%);
  max-height: min(82vh, 800px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 30, 70, 0.45);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface), transparent);
}

.modal-head h2 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-body {
  padding: 1.15rem 1.25rem 1.4rem;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 87, 184, 0.22) transparent;
}

.ref-section {
  margin-bottom: 1.25rem;
}

.ref-section h3 {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 0.55rem;
}

.ref-dl {
  display: grid;
  gap: 0.45rem;
}

.ref-dl > div {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}

.ref-dl dt {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
}

.ref-dl dd {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.ref-flags {
  padding-left: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ref-flags li {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.ref-flags li::marker {
  color: var(--rose);
}

.ref-sources {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.naming-formula {
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
}

.naming-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.naming-example {
  padding: 0.75rem 0.85rem;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.naming-cols {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.naming-lab {
  display: inline-block;
  min-width: 4.5rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-right: 0.35rem;
}

.naming-result {
  color: var(--text);
  margin-top: 0.15rem;
}

.naming-result strong {
  color: var(--accent);
  font-weight: 700;
}

.naming-note {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.45;
  font-style: italic;
}

.naming-cat-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 1rem 0 0.5rem;
}

.naming-cat-title:first-child {
  margin-top: 0.5rem;
}

.naming-more {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  opacity: 0.9;
}

.glossary-search-wrap {
  margin-bottom: 0.9rem;
}

.glossary-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.glossary-item {
  padding: 0.7rem 0.8rem;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.glossary-item dt {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  color: var(--accent);
  margin-bottom: 0.2rem;
}

.glossary-item dd {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.45;
}

@media (max-width: 980px) {
  .tools-row {
    grid-template-columns: 1fr;
  }
  .compare-grid {
    grid-template-columns: 1fr;
  }
  .diff-grid {
    grid-template-columns: 1fr;
  }
  .diff-vs {
    display: none;
  }
  .quiz-stats-bar {
    grid-template-columns: 1fr 1fr;
  }
  .ref-dl > div {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
  .mode-switch {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 560px) {
  .strip-controls {
    flex-wrap: wrap;
  }
  .main-compare {
    padding: 1rem 0.85rem 2rem;
  }
}
