/* ============================================================
   A320 Cockpit · Apple-inspired design system
   ============================================================ */

:root {
  /* Palette */
  --bg: #0b0b0e;
  --bg-elev: #16161b;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.10);
  --hairline: rgba(255, 255, 255, 0.10);
  --hairline-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f5f7;
  --text-dim: rgba(245, 245, 247, 0.62);
  --text-faint: rgba(245, 245, 247, 0.38);
  --accent: #0a84ff;
  --ok: #30d158;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --accent-ring: rgba(10, 132, 255, 0.85);
  --danger: #ff453a;

  /* Motion */
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --dur-fast: 180ms;
  --dur-med: 320ms;
  --dur-slow: 420ms;

  /* Sizing */
  --header-h: 56px;
  --phase-h: 40px;
  --footer-h: 36px;
  --panel-w: 380px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  padding: 2px 5px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  color: var(--text-dim);
  line-height: 1;
}

/* ============================================================
   Header
   ============================================================ */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 18px;
  background: rgba(11, 11, 14, 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--hairline);
  z-index: 20;
}

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

.brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background:
    radial-gradient(circle at 30% 30%, #3a82ff 0%, #0a84ff 42%, #0a5dcf 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.25),
    0 1px 3px rgba(0,0,0,0.5);
  position: relative;
  flex-shrink: 0;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1.5px solid rgba(255,255,255,0.85);
  border-radius: 3px;
  border-bottom: 0;
  border-left: 0;
  transform: rotate(-45deg);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-title {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.015em;
  white-space: nowrap;
}
.brand-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Filter chips (Apple-style segmented control feel) */
.filter-chips {
  display: inline-flex;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  gap: 2px;
}
.chip {
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
  border-radius: 7px;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.chip:hover:not(.is-active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}
.chip.is-active {
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.4), inset 0 0 0 0.5px var(--hairline-strong);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

/* Search trigger */
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 10px;
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.search-trigger:hover { background: var(--surface-strong); color: var(--text); }
.search-trigger .search-label { font-weight: 500; }
.search-trigger .kbd-hint {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  padding: 2px 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: var(--text-faint);
}

/* ============================================================
   Stage / cockpit canvas
   ============================================================ */
/* Phase filter bar (second row) */
.phase-bar {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  height: var(--phase-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  background: rgba(11, 11, 14, 0.60);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--hairline);
  z-index: 19;
  overflow-x: auto;
  scrollbar-width: none;
}
.phase-bar::-webkit-scrollbar { display: none; }

/* Coverage readout — how much of the active panel has been opened */
.progress {
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
}
.progress-track {
  width: 72px;
  height: 4px;
  border-radius: 2px;
  background: var(--hairline-strong);
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: var(--ok, #30d158);
  transition: width var(--dur-med) var(--ease-out);
}
.progress-text {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.progress-reset {
  font-size: 10.5px;
  color: var(--text-faint);
  padding: 3px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.progress-reset:hover { color: var(--text); background: rgba(255,255,255,0.06); }
@media (max-width: 720px) {
  .progress-track, .progress-reset { display: none; }
}

/* Controls already opened stay faintly marked on the cockpit */
.hotspot.is-seen:not(.is-active) {
  stroke: rgba(48, 209, 88, 0.42);
  stroke-width: 0.16;
}
.phase-label {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-right: 2px;
}
.phase-chip {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.phase-chip:hover:not(.is-active) {
  color: var(--text);
  background: var(--surface-strong);
}
.phase-chip.is-active {
  background: var(--accent);
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(10, 132, 255, 0.35);
}

.stage {
  position: absolute;
  top: calc(var(--header-h) + var(--phase-h));
  left: 0;
  right: 0;
  bottom: var(--footer-h);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  transition: padding-right var(--dur-slow) var(--ease-spring);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.stage::-webkit-scrollbar { width: 10px; }
.stage::-webkit-scrollbar-track { background: transparent; }
.stage::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

body.panel-open .stage { padding-right: calc(var(--panel-w) + 24px); }

.cockpit-frame {
  position: relative;
  width: min(720px, 100%);
  max-width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow:
    0 0 0 1px var(--hairline),
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 8px 24px rgba(0, 0, 0, 0.35);
  background: #000;
  isolation: isolate;
  transition: height var(--dur-slow) var(--ease-spring);
}

.cockpit-inner {
  position: relative;
  width: 100%;
  top: 0;
  transition: top var(--dur-slow) var(--ease-spring);
}

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

.hotspot-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Phase dim overlay — spotlights matching controls when a phase is active */
.phase-dim-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease-out);
  z-index: 1;
}
.phase-dim-overlay.is-active { opacity: 1; }
.phase-dim-fill { fill: rgba(0, 0, 0, 0.58); }
body.theme-light .phase-dim-fill { fill: rgba(0, 0, 0, 0.30); }
.hotspot-layer > * { pointer-events: auto; }

/* Hotspots */
.hotspot {
  fill: transparent;
  stroke: transparent;
  stroke-width: 0.25;
  cursor: pointer;
  transition:
    stroke var(--dur-fast) var(--ease-out),
    fill var(--dur-fast) var(--ease-out),
    opacity var(--dur-med) var(--ease-out);
}
.hotspot:hover,
.hotspot:focus-visible {
  fill: rgba(10, 132, 255, 0.10);
  stroke: var(--accent-ring);
  outline: none;
}
.hotspot.is-active {
  fill: rgba(10, 132, 255, 0.18);
  stroke: var(--accent-ring);
  stroke-width: 0.35;
}
.hotspot.is-dim {
  opacity: 0.08;
  pointer-events: none;
}
/* Sub-controls at full-cockpit zoom: removed outright, not dimmed, so they
   cannot intercept clicks meant for the panel box they sit on. */
.hotspot.is-hidden { display: none; }

@keyframes hotspot-pulse {
  0%, 100% { stroke: rgba(10,132,255,0.0); }
  50%      { stroke: rgba(10,132,255,0.55); }
}
.hotspot-layer.is-introducing .hotspot:not(.is-dim) {
  animation: hotspot-pulse 2.4s var(--ease-out) infinite;
  stroke-width: 0.3;
}

/* ============================================================
   Info panel (right-side sheet)
   ============================================================ */
.info-panel {
  position: fixed;
  top: calc(var(--header-h) + var(--phase-h));
  right: 0;
  bottom: var(--footer-h);
  width: var(--panel-w);
  transform: translateX(calc(100% + 24px));
  transition: transform var(--dur-slow) var(--ease-spring);
  padding: 12px;
  z-index: 10;
}
body.panel-open .info-panel { transform: translateX(0); }

.panel-inner {
  height: 100%;
  background: rgba(22, 22, 27, 0.72);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.5),
    0 8px 20px rgba(0,0,0,0.3);
  position: relative;
}

.panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--hairline);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  z-index: 2;
}
.panel-close:hover { color: var(--text); background: var(--surface-strong); }

.panel-content {
  padding: 52px 22px 16px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

/* Breadcrumb */
.panel-breadcrumb {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.panel-breadcrumb .crumb {
  display: inline-flex;
  align-items: center;
}
.panel-breadcrumb .crumb + .crumb::before {
  content: "›";
  margin: 0 6px;
  color: var(--text-faint);
  font-weight: 400;
}
.panel-breadcrumb .crumb:last-child {
  color: var(--text-dim);
}

/* Clickable crumb: looks like text until hover */
.crumb-link {
  border: 0;
  padding: 2px 6px;
  margin: -2px 0 -2px -6px;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.crumb-link:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.crumb-link[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}
.crumb-link[aria-pressed="true"]::after {
  content: "●";
  margin-left: 4px;
  font-size: 8px;
}

.panel-title {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.panel-summary {
  margin: 0 0 18px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
}
/* Second paragraph: when and why the control is used, set apart from the
   one-line definition above it. */
.panel-detail {
  margin: -6px 0 18px;
  padding-left: 12px;
  border-left: 2px solid var(--hairline-strong);
  color: var(--text-faint);
  font-size: 13.5px;
  line-height: 1.6;
}
.panel-detail[hidden] { display: none; }

.panel-section { margin-top: 18px; }
.panel-section h3 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 8px;
}
.panel-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.panel-section li {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
}

/* Cross-reference chip (inline in summary) */
.xref-chip {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  margin: 0 1px;
  height: 18px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.01em;
  border: 1px solid rgba(10, 132, 255, 0.28);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
  vertical-align: 1px;
}
.xref-chip:hover {
  background: rgba(10, 132, 255, 0.32);
}

/* Related: tag badge */
.related-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-right: 6px;
  padding: 1px 5px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

/* Hotspot pulse after smooth-scroll arrival */
@keyframes pulse-ring {
  0%   { stroke: rgba(10,132,255,0.0); stroke-width: 0.3; }
  40%  { stroke: rgba(10,132,255,0.95); stroke-width: 0.6; }
  100% { stroke: rgba(10,132,255,0.0); stroke-width: 0.3; }
}
.hotspot.is-pulse {
  animation: pulse-ring 1.4s var(--ease-out);
}

/* Related controls — clickable */
.related-list button {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.related-list button:hover {
  background: var(--surface-strong);
  border-color: var(--hairline-strong);
}
.related-list .related-arrow {
  color: var(--text-faint);
  font-size: 12px;
  flex-shrink: 0;
}

.panel-source {
  display: inline-block;
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--accent);
}

.panel-nav {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--hairline);
  justify-content: space-between;
  align-items: center;
}
.nav-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--hairline);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nav-btn:hover:not(:disabled) { background: var(--surface-strong); color: var(--text); }
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.nav-count {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Search palette (Cmd/Ctrl-K)
   ============================================================ */
.palette {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
}
.palette[aria-hidden="false"] {
  display: block;
}
.palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 11, 14, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in var(--dur-med) var(--ease-out);
}
.palette-panel {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  margin: 15vh auto 0;
  background: rgba(24, 24, 28, 0.92);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--hairline-strong);
  border-radius: 14px;
  box-shadow:
    0 40px 80px rgba(0, 0, 0, 0.55),
    0 8px 24px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  animation: palette-in var(--dur-med) var(--ease-spring);
}
@keyframes palette-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline);
}
.palette-icon { color: var(--text-faint); flex-shrink: 0; }
.palette-input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.palette-input::placeholder { color: var(--text-faint); }
.palette-input::-webkit-search-cancel-button { display: none; }
.palette-esc {
  font-size: 10.5px;
  color: var(--text-faint);
}

.palette-results {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 50vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.palette-results li {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background var(--dur-fast) var(--ease-out);
}
.palette-results li:hover,
.palette-results li.is-active {
  background: rgba(10, 132, 255, 0.18);
}
.palette-result-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.palette-result-meta {
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}
/* Why a result matched, when the hit was not in the control's name. */
.palette-result-why {
  font-size: 11.5px;
  color: var(--accent, #0a84ff);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.palette-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--hairline);
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  gap: 10px;
  align-items: center;
}
.palette-footer kbd { margin-right: 2px; }

/* ============================================================
   Coach mark (first-visit welcome)
   ============================================================ */
/* ============================================================
   Guided flow — steps through a real procedure control by control,
   sharing the quiz bar's shape so the two modes feel like siblings
   ============================================================ */
.flow {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  width: min(560px, calc(100vw - 24px));
  padding: 14px 16px;
  background: rgba(24, 24, 28, 0.92);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--hairline-strong);
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0,0,0,0.55);
  animation: coach-in 380ms var(--ease-spring);
}
.flow[hidden] { display: none; }
.flow-head { display: flex; align-items: baseline; gap: 10px; }
.flow-name {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.flow-step-count {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.flow-action {
  margin: 6px 0 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.flow-note {
  margin: 7px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-dim);
}
.flow-actions { display: flex; gap: 8px; margin-top: 13px; }
.flow-btn-next { background: var(--accent-soft); color: var(--accent); }
.flow-btn-next:hover { background: rgba(10, 132, 255, 0.3); color: var(--accent); }

/* Flow entries at the top of the procedures modal */
.proc-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 4px 0 8px;
}
.proc-group-label + .proc-list { margin-bottom: 20px; }
.proc-flow-steps {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Find-it quiz — floats over the bottom of the deck so the
   whole cockpit stays visible while the user hunts for a control
   ============================================================ */
.quiz {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  width: min(520px, calc(100vw - 24px));
  padding: 14px 16px;
  background: rgba(24, 24, 28, 0.92);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--hairline-strong);
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0,0,0,0.55);
  animation: coach-in 380ms var(--ease-spring);
}
.quiz[hidden] { display: none; }
.quiz-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.quiz-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  flex-shrink: 0;
}
.quiz-target {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.quiz-score {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.quiz-hint {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-faint);
}
.quiz-feedback {
  margin: 8px 0 0;
  font-size: 12.5px;
  font-weight: 500;
  min-height: 1.2em;
  color: var(--text-dim);
}
.quiz-feedback.is-right { color: var(--ok); }
.quiz-feedback.is-wrong { color: #ff6b6b; }
.quiz-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.quiz-btn {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  background: rgba(255,255,255,0.07);
  padding: 7px 12px;
  border-radius: 8px;
}
.quiz-btn:hover { color: var(--text); background: rgba(255,255,255,0.12); }
.quiz-btn-danger { margin-left: auto; color: #ff6b6b; }
.quiz-btn-danger:hover { color: #ff8787; background: rgba(255,80,80,0.14); }

/* Answer feedback on the deck itself */
@keyframes hotspot-right {
  0%   { stroke: rgba(48,209,88,0); fill: rgba(48,209,88,0); }
  30%  { stroke: rgba(48,209,88,0.95); fill: rgba(48,209,88,0.35); }
  100% { stroke: rgba(48,209,88,0); fill: rgba(48,209,88,0); }
}
@keyframes hotspot-wrong {
  0%   { stroke: rgba(255,69,58,0); fill: rgba(255,69,58,0); }
  30%  { stroke: rgba(255,69,58,0.95); fill: rgba(255,69,58,0.3); }
  100% { stroke: rgba(255,69,58,0); fill: rgba(255,69,58,0); }
}
.hotspot.is-right { animation: hotspot-right 1100ms var(--ease-out); stroke-width: 0.4; }
.hotspot.is-wrong { animation: hotspot-wrong 700ms var(--ease-out);  stroke-width: 0.4; }

/* During a quiz the cursor is a crosshair — you are aiming, not browsing */
body.is-quizzing .hotspot { cursor: crosshair; }

.coach {
  position: fixed;
  top: calc(var(--header-h) + var(--phase-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  max-width: min(440px, calc(100vw - 32px));
  animation: coach-in 420ms var(--ease-spring);
  pointer-events: auto;
}
.coach[hidden] { display: none; }
@keyframes coach-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.coach-inner {
  background: rgba(24, 24, 28, 0.9);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.coach-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.coach-body {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.5;
}
.coach-body kbd { vertical-align: middle; }
.coach-dismiss {
  align-self: flex-end;
  margin-top: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  transition: background var(--dur-fast) var(--ease-out);
}
.coach-dismiss:hover { background: #0070e6; }

/* ============================================================
   Footer
   ============================================================ */
.app-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 16px;
  border-top: 1px solid var(--hairline);
  background: rgba(11, 11, 14, 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  z-index: 20;
  font-size: 11px;
  color: var(--text-faint);
}
.app-footer p { margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-footer a { color: var(--text-dim); }
.app-footer a:hover { color: var(--text); }

.phase-badge {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.phase-badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #30d158;
  margin-right: 6px;
  box-shadow: 0 0 0 2px rgba(48, 209, 88, 0.18);
  vertical-align: 1px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 820px) {
  .app-header {
    grid-template-columns: auto 1fr auto;
    padding: 0 12px;
    gap: 10px;
  }
  .brand-text { display: none; }
  .filter-chips {
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 100%;
  }
  .filter-chips::-webkit-scrollbar { display: none; }
  .search-trigger .search-label,
  .search-trigger .kbd-hint { display: none; }
  .search-trigger { padding: 7px; }

  .app-footer p { font-size: 10px; }

  /* Bottom-sheet panel on mobile */
  :root { --panel-w: 100vw; }
  body.panel-open .stage { padding-right: 24px; padding-bottom: 50vh; }
  .info-panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    height: 62vh;
    padding: 0;
    transform: translateY(calc(100% + 8px));
    transition: transform var(--dur-slow) var(--ease-spring);
  }
  body.panel-open .info-panel { transform: translateY(0); }
  .panel-inner {
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
  }
  .panel-inner::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--hairline-strong);
  }
  .panel-content { padding-top: 28px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   Icon buttons (header)
   ============================================================ */
.icon-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-strong); color: var(--text); }
.icon-btn .icon-moon { display: none; }
body.theme-light .icon-btn .icon-sun  { display: none; }
body.theme-light .icon-btn .icon-moon { display: inline-block; }

/* ============================================================
   Cheat sheet modal
   ============================================================ */
.cheatsheet {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
}
.cheatsheet[aria-hidden="false"] { display: block; }
.cheatsheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(11, 11, 14, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in var(--dur-med) var(--ease-out);
}
.cheatsheet-panel {
  position: relative;
  width: min(500px, calc(100vw - 32px));
  margin: 12vh auto 0;
  background: rgba(24, 24, 28, 0.92);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--hairline-strong);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 40px 80px rgba(0,0,0,0.55);
  animation: palette-in var(--dur-med) var(--ease-spring);
}
.cheatsheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 14px;
}
.cheatsheet-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.cheatsheet-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cheatsheet-list > div {
  display: grid;
  grid-template-columns: minmax(140px, max-content) 1fr;
  gap: 14px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--hairline);
  font-size: 13px;
}
.cheatsheet-list > div:last-child { border-bottom: 0; }
.cheatsheet-list dt { margin: 0; color: var(--text-dim); display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.cheatsheet-list dd { margin: 0; color: var(--text); }

/* ============================================================
   Flashcards (Study mode)
   ============================================================ */
.study {
  position: fixed; inset: 0; z-index: 43; display: none;
}
.study[aria-hidden="false"] { display: block; }
.study-backdrop {
  position: absolute; inset: 0;
  background: rgba(11, 11, 14, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade-in var(--dur-med) var(--ease-out);
}
.study-panel {
  position: relative;
  width: min(620px, calc(100vw - 32px));
  margin: 6vh auto 0;
  background: rgba(24, 24, 28, 0.94);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--hairline-strong);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 40px 80px rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: palette-in var(--dur-med) var(--ease-spring);
}
.study-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.study-count {
  flex: 1;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.study-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(10, 132, 255, 0.28);
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.study-filter-tag::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.card-wrap { perspective: 1200px; }
.card {
  position: relative;
  width: 100%;
  min-height: 280px;
  transform-style: preserve-3d;
  transition: transform 520ms var(--ease-spring);
  cursor: pointer;
}
.card.is-flipped { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 10px;
}
.card-front { }
.card-back { transform: rotateY(180deg); background: rgba(10, 132, 255, 0.08); border-color: rgba(10, 132, 255, 0.25); }
.card-side-label {
  position: absolute;
  top: 14px;
  left: 18px;
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.card-text {
  margin: 0;
  font-size: 19px;
  line-height: 1.45;
  letter-spacing: -0.015em;
  color: var(--text);
  max-width: 520px;
}
.card-back .card-text { color: var(--accent); font-weight: 500; }
.card-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 11px;
  color: var(--text-faint);
}

/* Links from a card's answer back to the real control on the deck */
.card-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}
.card-links:empty { display: none; }
.card-links-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-right: 2px;
}

/* Leitner grading */
.study-grade {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 14px 0 4px;
}
.study-grade[hidden] { display: none; }
.grade-btn {
  min-width: 96px;
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--dur-fast) var(--ease-out);
}
.grade-again { background: rgba(255, 69, 58, 0.16); color: #ff6b6b; }
.grade-again:hover { background: rgba(255, 69, 58, 0.28); }
.grade-good { background: rgba(48, 209, 88, 0.16); color: var(--ok); }
.grade-good:hover { background: rgba(48, 209, 88, 0.28); }

.study-box {
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.study-box-1 { background: rgba(255, 69, 58, 0.16); color: #ff6b6b; }
.study-box-2 { background: rgba(255, 159, 10, 0.16); color: #ff9f0a; }
.study-box-3 { background: rgba(48, 209, 88, 0.16);  color: var(--ok); }

.study-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.study-flip {
  min-width: 100px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: white;
  background: var(--accent);
  border-radius: 999px;
  transition: background var(--dur-fast) var(--ease-out);
}
.study-flip:hover { background: #0070e6; }

/* ============================================================
   Procedures modal
   ============================================================ */
.procmodal {
  position: fixed; inset: 0; z-index: 42; display: none;
}
.procmodal[aria-hidden="false"] { display: block; }
.procmodal-backdrop {
  position: absolute; inset: 0;
  background: rgba(11, 11, 14, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade-in var(--dur-med) var(--ease-out);
}
.procmodal-panel {
  position: relative;
  width: min(640px, calc(100vw - 32px));
  max-height: 80vh;
  margin: 8vh auto 0;
  display: flex;
  flex-direction: column;
  background: rgba(24, 24, 28, 0.94);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--hairline-strong);
  border-radius: 14px;
  box-shadow: 0 40px 80px rgba(0,0,0,0.55);
  animation: palette-in var(--dur-med) var(--ease-spring);
  overflow: hidden;
}
.procmodal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
}
.procmodal-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.procmodal-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.proc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.proc-list > li > button {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--dur-fast) var(--ease-out);
}
.proc-list > li > button:hover { background: var(--surface-strong); }
.proc-severity {
  flex-shrink: 0;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
}
.proc-severity.critical { background: rgba(255, 69, 58, 0.18); color: #ff6961; }
.proc-severity.caution  { background: rgba(255, 159, 10, 0.18); color: #ffb45e; }
.proc-severity.info     { background: rgba(48, 209, 88, 0.16); color: #4ade80; }
.proc-name { font-weight: 600; font-size: 14px; }
.proc-category {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Detail view — replaces the list inside the same modal */
.proc-detail { padding: 16px 18px; }
.proc-back {
  font-size: 12.5px;
  color: var(--accent);
  margin-bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.proc-trigger {
  margin: 0 0 16px;
  padding: 10px 12px;
  background: rgba(255, 159, 10, 0.08);
  border-left: 3px solid rgba(255, 159, 10, 0.5);
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.55;
}
.proc-steps {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  counter-reset: step;
}
.proc-steps li {
  counter-increment: step;
  padding: 10px 12px 10px 36px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 6px;
  position: relative;
}
.proc-steps li::before {
  content: counter(step);
  position: absolute;
  left: 10px;
  top: 10px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.proc-step-chips {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.proc-notes {
  margin: 0;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.55;
  font-style: italic;
}

/* ============================================================
   Light theme overrides
   ============================================================ */
body.theme-light {
  --bg: #f5f5f7;
  --bg-elev: #ffffff;
  --surface: rgba(0, 0, 0, 0.045);
  --surface-strong: rgba(0, 0, 0, 0.08);
  --hairline: rgba(0, 0, 0, 0.10);
  --hairline-strong: rgba(0, 0, 0, 0.18);
  --text: #1d1d1f;
  --text-dim: rgba(29, 29, 31, 0.62);
  --text-faint: rgba(29, 29, 31, 0.42);
}
body.theme-light .app-header,
body.theme-light .app-footer {
  background: rgba(245, 245, 247, 0.72);
}
body.theme-light .panel-inner,
body.theme-light .palette-panel,
body.theme-light .cheatsheet-panel,
body.theme-light .coach-inner,
body.theme-light .procmodal-panel,
body.theme-light .study-panel {
  background: rgba(255, 255, 255, 0.94);
}
body.theme-light .card-face { background: rgba(0, 0, 0, 0.03); }
body.theme-light .card-back {
  background: rgba(10, 132, 255, 0.08);
  border-color: rgba(10, 132, 255, 0.28);
}
body.theme-light .study-backdrop,
body.theme-light .procmodal-backdrop,
body.theme-light .cheatsheet-backdrop,
body.theme-light .palette-backdrop {
  background: rgba(0, 0, 0, 0.25);
}
body.theme-light .cockpit-frame {
  box-shadow:
    0 0 0 1px var(--hairline),
    0 20px 60px rgba(0, 0, 0, 0.12),
    0 8px 24px rgba(0, 0, 0, 0.08);
}
body.theme-light .brand-mark {
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 1px 3px rgba(0,0,0,0.15);
}
body.theme-light .coach-dismiss { background: #0071e3; color: #fff; }
body.theme-light .coach-dismiss:hover { background: #0062c4; }

/* ============================================================
   Calibration mode
   ============================================================ */
body.is-calibrating .stage { cursor: crosshair; }
body.is-calibrating .hotspot { pointer-events: none; }

/* Visible reference boxes for main-panel hotspots during calibration */
body.is-calibrating .hotspot[data-panel="Main Instrument Panel"] {
  stroke: rgba(255, 255, 255, 0.45);
  stroke-width: 0.25;
  fill: rgba(255, 255, 255, 0.04);
}
body.is-calibrating .hotspot.is-calib-current {
  stroke: rgba(10, 132, 255, 1);
  stroke-width: 0.4;
  fill: rgba(10, 132, 255, 0.18);
}
body.is-calibrating .hotspot.is-calib-done {
  stroke: rgba(52, 199, 89, 0.9);
  stroke-width: 0.3;
  fill: rgba(52, 199, 89, 0.15);
}

/* Labels over each main-panel hotspot */
.calib-label {
  position: absolute;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: white;
  background: rgba(10, 132, 255, 0.85);
  border-radius: 4px;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 4px));
  white-space: nowrap;
  z-index: 3;
}
.calib-label.is-done { background: rgba(52, 199, 89, 0.85); }
.calib-label.is-other { background: rgba(0, 0, 0, 0.6); color: rgba(255,255,255,0.7); }

.calib-hud {
  position: fixed;
  top: calc(var(--header-h) + var(--phase-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  background: rgba(24, 24, 28, 0.94);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--hairline-strong);
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  font-size: 12px;
  color: var(--text);
  pointer-events: auto;
  max-width: calc(100vw - 24px);
  white-space: nowrap;
}
.calib-hud[hidden] { display: none; }
.calib-step {
  padding: 0 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calib-step b { color: var(--accent); font-weight: 600; }

.calib-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
}
.calib-btn:hover { background: var(--surface-strong); }
.calib-btn-danger { color: #ff6961; border-color: rgba(255,105,97,0.3); }

.calib-crosshair {
  position: fixed;
  width: 16px; height: 16px;
  margin-left: -8px; margin-top: -8px;
  border: 2px solid #ff6961;
  border-radius: 50%;
  pointer-events: none;
  z-index: 51;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.8);
}
.calib-crosshair[hidden] { display: none; }
.calib-crosshair::before,
.calib-crosshair::after {
  content: "";
  position: absolute;
  background: #ff6961;
}
.calib-crosshair::before { left: 50%; top: -12px; width: 1px; height: 12px; }
.calib-crosshair::after  { top: 50%; left: -12px; width: 12px; height: 1px; }

.calib-rect {
  position: fixed;
  pointer-events: none;
  z-index: 49;
  border: 2px solid rgba(52, 199, 89, 0.95);
  background: rgba(52, 199, 89, 0.15);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}
.calib-rect[hidden] { display: none; }

/* Result modal */
.calib-result {
  position: fixed;
  inset: 0;
  z-index: 52;
  display: none;
}
.calib-result[aria-hidden="false"] { display: block; }
.calib-result-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 11, 14, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.calib-result-panel {
  position: relative;
  width: min(640px, calc(100vw - 32px));
  max-height: 82vh;
  margin: 6vh auto 0;
  background: rgba(24, 24, 28, 0.95);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--hairline-strong);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 40px 80px rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
body.theme-light .calib-result-panel { background: rgba(255, 255, 255, 0.94); }
.calib-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.calib-result-head h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
.calib-result-hint { margin: 0; font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.calib-result-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  padding: 1px 5px;
  background: var(--surface);
  border-radius: 4px;
}
.calib-result-text {
  width: 100%;
  flex: 1;
  min-height: 280px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  resize: vertical;
  line-height: 1.5;
  outline: none;
}
.calib-result-text:focus { border-color: var(--accent); }
.calib-result-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ============================================================
   Dev helper
   ============================================================ */
body:not(.is-dev) .dev-readout { display: none; }
.dev-readout {
  position: fixed;
  bottom: calc(var(--footer-h) + 12px);
  left: 12px;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: rgba(22,22,27,0.9);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  color: var(--text);
  z-index: 30;
  pointer-events: none;
}
