/* Military Academy Tactical Command & Assessment Center : data-terminal (seed 1556140769)
   Grid arithmetic at 1440px: 56px icon rail + 1384px canvas (32px left/right pad = 1320px inner width;
   12 columns × 88px + 11 × 24px gap = 1056 + 264 = 1320px). */

/* Night theme: true neutral darks (app-screens.md §9.3), colour only on data and status.
   Every text and status token is at least 4.5:1 on ground, surface and raised (lowest: faint on raised, 5.2:1). */
:root {
  --ground: #0e0e0f;
  --surface: #161617;
  --raised: #222224;
  --active: #222224;
  --border: #2a2a2d;
  --rule: #222224;
  --control: #4a4a4f;
  --text: #f4f4f5;
  --muted: #b4b4b4;
  --faint: #949494;
  --accent: #6aa6f5;
  --primary: #f4f4f5;
  --primary-ink: #111111;
  --positive: #3fc07a;
  --negative: #f0707f;
  --warning: #e6b14c;
  --chart-1: #6aa6f5;
  --chart-2: #f0707f;
  --chart-3: #f4f4f5;
  --chart-muted: #3a3a3d;
  --grid: #2b2b2b;
  --axis-ink: #949494;
  --ink: #f4f4f5;
  --pill-positive-bg: #172a1d; --pill-positive-ink: #3fc07a;
  --pill-negative-bg: #2c1a20; --pill-negative-ink: #f0707f;
  --pill-warning-bg: #2b2414; --pill-warning-ink: #e6b14c;
  --pill-neutral-bg: #232325; --pill-neutral-ink: #d4d4d6;

  --radius-card: 6px;
  --radius-control: 6px;
  --row-height: 42px;
  --sidebar-width: 56px;
  --gap: 24px;
  --pad: 32px;
  --card-pad: 22px;
  --control-height: 36px;
  --font: "Cairo", "Segoe UI", system-ui, sans-serif;
  --fs-title: 24px;
  --fs-section: 16px;
  --fs-kpi: 26px;
  --fs-body: 13px;
  --fs-small: 12px;
}

html[data-theme="light"] {
  --ground: #f3f5f8;
  --surface: #ffffff;
  --raised: #ebeef4;
  --active: #e5eaf2;
  --border: #e1e6ef;
  --rule: #eaeff5;
  --control: #94a3b8;
  --text: #0f1926;
  --muted: #435266;
  --faint: #5a6b82;
  --accent: #1856a8;
  --primary: #122036;
  --primary-ink: #ffffff;
  --positive: #127852;
  --negative: #c42942;
  --warning: #9e6306;
  --chart-1: #1856a8;
  --chart-2: #c42942;
  --chart-3: #0f1926;
  --chart-muted: #cbd5e1;
  --grid: #e1e6ef;
  --axis-ink: #5a6b82;
  --ink: #0f1926;
  --pill-positive-bg: #dcfce7; --pill-positive-ink: #127852;
  --pill-negative-bg: #fee2e2; --pill-negative-ink: #c42942;
  --pill-warning-bg: #fef3c7; --pill-warning-ink: #92400e;
  --pill-neutral-bg: #e8edf4; --pill-neutral-ink: #2c3a4f;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: var(--fs-body)/20px var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul[class], ol[class] { padding: 0; list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.num, table, .kpi-value, .clock, .coord { font-variant-numeric: tabular-nums; }

/* Shell: 56px Icon Rail + Fluid Canvas */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100svh;
}
.rail {
  position: sticky;
  top: 0;
  height: 100svh;
  background: var(--ground);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 8px;
  z-index: 10;
}
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--accent);
  margin-bottom: 12px;
}
.rail-rule {
  width: 20px;
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}
.rail-btn {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.rail-btn svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.5;
}
.rail-btn:hover:not(:disabled) { color: var(--text); }
.rail-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
/* The move: every selection is a 1px accent line on the nearest edge */
.rail-btn[aria-current="page"] {
  color: var(--text);
  border-inline-start: 1px solid var(--accent);
}
.rail-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.canvas {
  min-width: 0;
  width: 100%;
  padding: var(--pad);
  max-width: 1680px;
}

/* Top context bar inside canvas */
.workspace-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.workspace-id {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-small);
  color: var(--muted);
}
.workspace-id strong {
  color: var(--text);
  font-weight: 600;
  font-size: var(--fs-body);
}
.workspace-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Title row */
.title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.title-row h1 {
  font-size: var(--fs-title);
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.title-row .sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--fs-body);
}
.title-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Tabs with 1px accent selection line (The Move) */
.mode-tabs {
  display: flex;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--gap);
  overflow-x: auto;
}
.mode-tab {
  position: relative;
  padding: 10px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-body);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.mode-tab:hover:not(:disabled) { color: var(--text); }
/* A step not reached yet is a label in the stepper, not a control */
.mode-tab:disabled {
  color: var(--faint);
  cursor: default;
}
.btn.icon-btn { width: var(--control-height); padding: 0; }
.icon-btn svg { width: 16px; height: 16px; flex: none; }
.icon-btn[data-next="night"] .i-day,
.icon-btn[data-next="day"] .i-night { display: none; }
.mode-tab[aria-selected="true"] {
  color: var(--text);
}
.mode-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: -1px;
  height: 1px;
  background: var(--accent);
}

/* KPI divided strip */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  margin-bottom: var(--gap);
}
.kpi {
  padding: 16px var(--card-pad);
}
.kpi + .kpi {
  border-inline-start: 1px solid var(--border);
}
.kpi-label {
  color: var(--muted);
  font-size: var(--fs-small);
}
.kpi-value {
  margin-top: 6px;
  font-size: var(--fs-kpi);
  line-height: 1.15;
  font-weight: 600;
  color: var(--text);
}
.kpi-value.lead {
  font-size: 32px;
}
.kpi-value small {
  font-size: var(--fs-small);
  color: var(--muted);
  font-weight: 400;
  margin-inline-start: 4px;
}
.delta {
  margin-top: 4px;
  font-size: var(--fs-small);
  color: var(--muted);
}
.delta .pos { color: var(--positive); }
.delta .neg { color: var(--negative); }

/* 12-column grid */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
}
.grid.top { align-items: start; }
.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-7 { grid-column: span 7; }
.col-6 { grid-column: span 6; }
.col-5 { grid-column: span 5; }
.col-4 { grid-column: span 4; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--card-pad);
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.panel-head h1,
.panel-head h2 {
  font-size: var(--fs-section);
  line-height: 1.3;
  font-weight: 600;
  color: var(--text);
}
.panel-head .meta {
  color: var(--faint);
  font-size: var(--fs-small);
}

/* Controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--control-height);
  padding: 0 14px;
  border-radius: var(--radius-control);
  border: 1px solid var(--control);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--raised); }
.btn.primary {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: var(--primary);
  font-weight: 600;
}
.btn.primary:hover { opacity: 0.92; }
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.select, .input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: var(--control-height);
  padding: 0 10px;
  border-radius: var(--radius-control);
  border: 1px solid var(--control);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-body);
}
.textarea {
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--control);
  background: var(--ground);
  color: var(--text);
  font-size: var(--fs-body);
  line-height: 1.5;
  resize: vertical;
}

/* Quick Launch Command Bar */
.field-group {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.field-group label {
  font-size: var(--fs-small);
  color: var(--muted);
  font-weight: 500;
}

/* Tables */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  height: 36px;
  padding: 0 10px;
  text-align: start;
  font-weight: 400;
  font-size: var(--fs-small);
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
  font-size: var(--fs-body);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr[aria-selected="true"] td {
  background: var(--raised);
}
th.n, td.n {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.scorecard .step-cell { width: 28%; }
td .sub {
  display: block;
  font-size: var(--fs-small);
  color: var(--muted);
  margin-top: 2px;
}

/* Status pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-control);
  font-size: var(--fs-small);
  font-weight: 500;
  background: var(--pill-neutral-bg);
  color: var(--pill-neutral-ink);
  white-space: nowrap;
  flex: none;
}
.pill.pos { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill.neg { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.pill.warn { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }

/* Signature Element: Tactical Phase & Sitrep Strip */
.phase-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  margin-bottom: var(--gap);
}
.phase-step {
  padding: 12px 14px;
  border-inline-end: 1px solid var(--border);
  position: relative;
}
.phase-step:last-child { border-inline-end: 0; }
.phase-step.done .step-meta {
  color: var(--positive);
}
.phase-step.locked {
  opacity: 0.42;
}
.phase-step[aria-current="step"] {
  background: var(--raised);
  border-bottom: 1px solid var(--accent);
}
.phase-step .step-meta {
  font-size: var(--fs-small);
  color: var(--faint);
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.phase-step .step-name {
  margin-top: 4px;
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tactical Choice Rows (1px accent selection line + tactile badge) */
.choice-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.choice-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: start;
  padding: 13px 16px;
  background: var(--ground);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  cursor: pointer;
}
.choice-item:hover {
  background: var(--raised);
  border-color: var(--control);
}
.choice-item[aria-checked="true"] {
  background: var(--raised);
  border-color: var(--accent);
  border-inline-start: 1px solid var(--accent);
}
.choice-badge {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--fs-small);
  font-weight: 600;
  display: inline-grid;
  place-items: center;
  flex: none;
  margin-top: 1px;
}
.choice-item[aria-checked="true"] .choice-badge {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--primary-ink);
}
.choice-text {
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--text);
}

/* Sitrep briefing box */
.sitrep-box {
  padding: 16px;
  background: var(--ground);
  border: 1px solid var(--border);
  border-inline-start: 1px solid var(--accent);
  border-radius: var(--radius-card);
  margin-bottom: 16px;
}
.sitrep-box p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}
.sitrep-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 8px;
  font-size: var(--fs-small);
  color: var(--muted);
}

/* Key-value rows */

/* Text action inside tables */
.row-action {
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  font-size: var(--fs-small);
  padding: 4px 8px;
  border-bottom: 1px solid var(--control);
  cursor: pointer;
  white-space: nowrap;
}
.row-action:hover {
  border-bottom-color: var(--accent);
}

/* Tactical Command Intro Splash View (shown on website entry) */
body.intro-active .app { display: none; }

/* Motion & Smooth Micro-Animations */
@keyframes viewFadeSlide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes radarSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.view-animate {
  animation: viewFadeSlide 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* Entrance motion: classes are added by motion.js playEntrance() only when a screen is entered,
   so re-renders inside a screen (choosing an answer, filtering) never replay it. */
.is-entering {
  animation: viewFadeSlide 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--n, 0) * 70ms);
}
@keyframes growX { from { transform: scaleX(0); } }
.grow-x { transform-origin: left center; }
[dir="rtl"] .grow-x { transform-origin: right center; }
.grow-x.is-playing { animation: growX 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both; }
@keyframes drawRoute { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.route-draw { stroke-dasharray: 1; }
.route-draw.is-playing { animation: drawRoute 0.9s cubic-bezier(0.65, 0, 0.35, 1) 0.1s both; }
@keyframes popIn { from { opacity: 0; transform: scale(0.2); } }
.waypoint-pop.is-playing { animation: popIn 0.36s cubic-bezier(0.34, 1.56, 0.64, 1) both; animation-delay: calc(0.25s + var(--i, 0) * 0.11s); }
@keyframes ringPulse { 0% { opacity: 0.9; transform: scale(0.7); } 100% { opacity: 0; transform: scale(1.6); } }
.pulse-ring, .t-pulse { animation: ringPulse 1.8s cubic-bezier(0.22, 1, 0.36, 1) infinite; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.choice-item, .btn, .mode-tab, .rail-btn, .phase-step {
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.16s ease, opacity 0.18s ease;
}
.choice-item:active:not(:disabled), .btn:active:not(:disabled) {
  transform: scale(0.99);
}

/* Competency Track Filter & Cadet Chips */
.field-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field-label-row .row-action { padding: 0 0 1px; }

/* Collapsible Details Drawer (reduces text overload) */
.compact-details {
  margin-top: 8px;
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}
.compact-details summary {
  cursor: pointer;
  font-size: var(--fs-small);
  color: var(--accent);
  font-weight: 500;
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.compact-details summary::-webkit-details-marker {
  display: none;
}
.compact-details .details-body {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--ground);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  font-size: var(--fs-small);
  line-height: 1.55;
  color: var(--muted);
  animation: viewFadeSlide 0.22s ease both;
}

/* Zero-Scroll Viewport Fit & Compact Mode */
body.sim-active .workspace-bar,
body.sim-active .title-row {
  display: none;
}
body.sim-active .canvas {
  padding-top: 14px;
  padding-bottom: 14px;
}
body.sim-active .mode-tabs {
  margin-bottom: 10px;
}
body.sim-active .phase-strip {
  margin-bottom: 10px;
}
body.sim-active .sitrep-box {
  padding: 10px 14px;
  margin-bottom: 10px;
}
body.sim-active .sitrep-meta {
  margin-bottom: 4px;
}
body.sim-active .sitrep-box p {
  font-size: 13px;
  line-height: 1.45;
}
body.sim-active .choice-list {
  gap: 8px;
  margin-top: 8px;
}
body.sim-active .choice-item {
  padding: 10px 12px;
}
body.sim-active .choice-text {
  font-size: 13px;
  line-height: 1.38;
}
.mobile-only-brief {
  display: none;
}

/* Responsive Tablet & Phone rules (references/app-screens.md §12) */
@media (max-width: 1024px) {
  .col-8, .col-7, .col-6, .col-5, .col-4 { grid-column: span 12; }
  .phase-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  body.sim-active .sim-side-panel { display: none; }
  body.sim-active .mobile-only-brief { display: block; margin-top: 8px; }
}
@media (max-width: 860px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    padding-bottom: 52px;
  }
  .rail {
    position: fixed;
    top: auto;
    bottom: 0;
    inset-inline: 0;
    height: 46px;
    width: 100%;
    flex-direction: row;
    justify-content: space-around;
    padding: 0 12px;
    border-inline-end: 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
  }
  .brand-mark, .rail-rule, .rail-bottom { display: none; }
  .rail-btn[aria-current="page"] {
    border-inline-start: 0;
    border-top: 1px solid var(--accent);
  }
  .canvas { padding: 10px 18px; }
  .workspace-bar { gap: 8px; padding-bottom: 8px; margin-bottom: 8px; }
  #ws-scope, #ws-stamp, .workspace-id span:nth-child(2) { display: none; }
  .title-row { gap: 6px; margin-bottom: 8px; }
  .title-row h1 { font-size: 19px; }
  .title-row .finding { font-size: 12px; margin-top: 2px; }
  .mode-tabs { margin-bottom: 10px; gap: 14px; }
  .mode-tab { padding: 6px 0; font-size: 12px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 10px; }
  .kpi { padding: 8px 10px; }
  .kpi-value { font-size: 18px; }
  .kpi-value.lead { font-size: 20px; }
  .kpi + .kpi { border-inline-start: 0; }
  .kpi:nth-child(2n) { border-inline-start: 1px solid var(--border); }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .panel { padding: 12px; }
  .panel-head { margin-bottom: 8px; padding-bottom: 8px; }
  .phase-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 8px; gap: 4px; }
  .phase-step { padding: 4px 2px; text-align: center; }
  .phase-step .step-meta { justify-content: center; font-size: 11px; }
  .phase-step .step-status-text, .phase-step .step-name { display: none; }
  .choice-item { padding: 9px 11px; gap: 8px; }
  .sim-actions { flex-direction: column; align-items: stretch !important; margin-top: 10px !important; gap: 8px !important; }
  .sim-actions .btn { width: 100%; height: 38px; }
  .overview-map-only, .desktop-only-kv { display: none; }
  td, th { padding: 7px 6px; }
  .workspace-id span:nth-child(4) { display: none; }
  /* Report KPIs: the final score leads on its own row, so its pass/fail badge has room */
  .kpi:first-child, .kpi:last-child { grid-column: 1 / -1; }
  .kpi:nth-child(2n) { border-inline-start: 0; }
  .kpi:nth-child(3) { border-inline-start: 1px solid var(--border); }
  .kpi:nth-child(n + 2) { border-top: 1px solid var(--border); }
  /* Start screen: setting up the exercise comes first on a phone; the figures follow as a 2x2 grid */
  #view-container { display: flex; flex-direction: column; }
  #view-container > .overview-kpis { order: 1; }
  #view-container > .grid + .grid { order: 2; }
  .overview-kpis .kpi:first-child, .overview-kpis .kpi:last-child { grid-column: auto; }
  .overview-kpis .kpi:nth-child(2n) { border-inline-start: 1px solid var(--border); }
  .overview-kpis .kpi:nth-child(3) { border-inline-start: 0; }
  .overview-kpis .kpi:nth-child(2) { border-top: 0; }
  .overview-kpis .delta { display: none; }
}
/* Phone: scorecard rows become two-line items so the score never scrolls out of view */
@media (max-width: 640px) {
  /* Skill rows: full skill name and figure on one line, the bar on its own line underneath */
  .bullet-list li, .cadet-bars li { grid-template-columns: minmax(0, 1fr) auto !important; row-gap: 6px; }
  .bullet-list li > :nth-child(1), .cadet-bars .cb-name { grid-column: 1; grid-row: 1; white-space: normal !important; }
  .bullet-list li > :nth-child(3), .cadet-bars .cb-value { grid-column: 2; grid-row: 1; }
  .bullet-list li > :nth-child(2), .cadet-bars .cb-track { grid-column: 1 / -1; grid-row: 2; }
  .scorecard thead { display: none; }
  .scorecard tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
  .scorecard tbody tr:last-child { border-bottom: 0; }
  .scorecard td, .scorecard .step-cell { display: block; width: auto; padding: 0; border: 0; }
  .scorecard td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; margin-top: 6px; }
}
.results-more { margin-top: 10px; }
.sub-inline { color: var(--muted); font-size: var(--fs-small); margin-inline-start: 4px; }
.kpi-missing { color: var(--faint); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* The chosen mission, read before starting */

/* Training area map (start screen) */
.theater-map { display: block; background: var(--ground); border: 1px solid var(--border); border-radius: var(--radius-card); }
.theater-map .t-grid line { stroke: var(--rule); stroke-width: 1; }
.theater-map .t-contour path { fill: none; stroke: var(--border); stroke-width: 1.2; stroke-dasharray: 4 4; }
.theater-map .t-wadi { fill: none; stroke: var(--control); stroke-width: 1.5; opacity: 0.6; }
.theater-map .t-compass { font-size: 11px; font-weight: 600; fill: var(--muted); }
.t-marker { cursor: pointer; outline: none; }
.t-marker .t-hit { fill: transparent; }
.t-marker .t-dot { fill: var(--surface); stroke: var(--control); stroke-width: 1.8; transition: r 0.2s ease, fill 0.2s ease, stroke 0.2s ease; }
.t-marker .t-check { fill: none; stroke: var(--positive); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.t-marker .t-code { font-size: 11px; font-weight: 600; fill: var(--muted); transition: fill 0.2s ease; }
.t-marker:hover .t-dot, .t-marker:focus-visible .t-dot { stroke: var(--accent); r: 8; }
.t-marker:focus-visible .t-hit { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 2; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 10px 0 0; padding: 0; color: var(--muted); font-size: var(--fs-small); }
.map-legend li { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 10px; height: 10px; border-radius: 50%; border: 1.8px solid var(--control); background: var(--surface); flex: none; }
.lg-done { border-color: var(--positive); }
.route-map { display: block; background: var(--ground); border: 1px solid var(--border); border-radius: var(--radius-card); margin-bottom: 4px; }
/* Maps are drawn left to right; without this, Arabic pages anchor their corner labels the other way and clip them */
.route-map, .theater-map { direction: ltr; unicode-bidi: isolate; }
.how-to { color: var(--muted); font-size: var(--fs-small); line-height: 1.5; margin-top: 8px; }

/* Average per cadet */
.sub-heading { font-size: var(--fs-small); font-weight: 600; color: var(--muted); margin: 18px 0 10px; }
.cadet-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cadet-bars li { display: grid; grid-template-columns: minmax(110px, 34%) 1fr auto; align-items: center; gap: 12px; font-size: 13px; }
.cb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-track { position: relative; height: 8px; background: var(--rule); border-radius: 2px; }
.cb-fill { position: absolute; inset-block: 0; inset-inline-start: 0; background: var(--chart-muted); border-radius: 2px; }
.cb-fill.is-pass { background: var(--accent); }
.cb-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-inline-start: -1px; background: var(--text); }
.cb-value { min-width: 9ch; text-align: right; }
.cb-value small { color: var(--muted); font-size: 12px; }


@page { margin: 14mm; }
@media print {
  .intro-overlay, .rail, .workspace-actions, .title-controls, .mode-tabs,
  button, details > summary { display: none !important; }
  body, .canvas, .panel { background: #fff !important; color: #000 !important; border-color: #ccc !important; }
  tr, .panel { break-inside: avoid; }
}

/* Academy and evaluator settings */
.edit-profile { padding: 2px 4px; border-bottom: 0; color: var(--muted); display: inline-flex; align-items: center; }
.edit-profile:hover { color: var(--text); }
.profile-dialog { border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); color: var(--text); padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18); } /* taste-skill-ignore: a dialog floats */
.profile-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.profile-dialog h2 { font-size: var(--fs-section); font-weight: 600; margin-bottom: 4px; }
.profile-dialog .field-group { margin-top: 14px; }
.profile-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; }
.profile-actions .row-action { margin-inline-start: auto; }

/* ==========================================================================
   Design layer: "Editorial greeting" (taste skill app style, seed 604697599).
   Face: field-canvas stone panels on a warm white page; serif greeting naming the evaluator;
   the map is the signature element and the one white inner card. One accent: deep teal.
   Grid: centred 1100px column, 12 columns of 77px with 16px gutters (12 x 77 + 11 x 16 = 1100);
   rows span 3/3/3/3 and 6/6 so every inner edge meets one above it.
   ========================================================================== */
:root {
  --ground: #0e0e0f; --surface: #171716; --raised: #222220; --active: #262624;
  --border: #2a2a28; --rule: #232321; --control: #5a5952;
  --accent: #5cbcaf; --chart-1: #5cbcaf; --primary: #f4f4f2; --primary-ink: #111111;
  --radius-card: 22px; --radius-control: 999px; --radius-inner: 16px;
  --gap: 16px; --pad: 32px; --card-pad: 24px; --control-height: 38px;
  --sidebar-width: 236px;
  --font: "Cairo", "Segoe UI", system-ui, sans-serif;
  --font-greeting: "Cairo", "Segoe UI", system-ui, sans-serif;
  --fs-title: 30px; --fs-section: 15px; --fs-kpi: 32px; --fs-body: 14px; --fs-small: 12px;
}
html[data-theme="light"] {
  --ground: #fbfaf7; --surface: #f2f0e9; --raised: #ffffff; --active: #e8e5db;
  --border: #e6e3d9; --rule: #ebe8df; --control: #8a877d;
  --text: #1f201d; --muted: #57564f; --faint: #66655d; --ink: #1f201d;
  --accent: #1b6e66; --primary: #1f201d; --primary-ink: #ffffff;
  --positive: #27702c; --negative: #b42318; --warning: #8a4a0a;
  --chart-1: #1b6e66; --chart-2: #b42318; --chart-3: #1f201d; --chart-muted: #cfcbbf;
  --grid: #e6e3d9; --axis-ink: #66655d;
  --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
  --pill-negative-bg: #fdecea; --pill-negative-ink: #7a1d14;
  --pill-warning-bg: #fdf3dc; --pill-warning-ink: #7a4108;
  --pill-neutral-bg: #e8e5db; --pill-neutral-ink: #3d3d3a;
}
body { font: var(--fs-body)/21px var(--font); }

/* Shell: open plane, labelled sidebar on the page ground */
.sidebar {
  position: sticky; top: 0; height: 100svh; z-index: 10;
  display: flex; flex-direction: column; gap: 28px;
  padding: 24px 14px; background: var(--ground); border-inline-end: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { width: 28px; height: 28px; margin: 0; color: var(--accent); flex: none; }
.brand-text { display: grid; gap: 2px; min-width: 0; line-height: 1.3; }
.brand-text strong { font-size: 13px; font-weight: 600; }
.brand-text span { font-size: var(--fs-small); color: var(--muted); }
.side-nav { display: grid; gap: 2px; }
.sidebar .rail-btn {
  width: 100%; height: 36px; display: flex; align-items: center; justify-content: flex-start; gap: 10px;
  padding: 0 12px; border: 0; border-radius: 10px; color: var(--muted); font-size: 14px; text-align: start;
}
.sidebar .rail-btn svg { width: 16px; height: 16px; flex: none; }
.sidebar .rail-btn:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.sidebar .rail-btn[aria-current="page"] { background: var(--active); color: var(--text); border: 0; }
.sidebar .rail-btn:disabled { opacity: 1; color: var(--faint); cursor: default; }
.side-foot { margin-top: auto; display: grid; gap: 14px; padding: 0 8px; }
.user-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user-row #ws-officer { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-initial { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface); color: var(--accent); font-weight: 600; }
.side-actions { display: flex; gap: 8px; }

/* Canvas and the greeting */
.canvas { max-width: calc(1100px + 2 * var(--pad)); margin-inline: auto; padding: 36px var(--pad) 56px; }
.title-row { margin-bottom: 28px; }
.greeting { font-family: var(--font-greeting); font-weight: 700; font-size: var(--fs-title); line-height: 1.12; letter-spacing: -0.01em; }
body[data-mode="overview"] .greeting { font-size: 44px; }
:lang(ar) .greeting { line-height: 1.45; letter-spacing: 0; }
.title-row .sub { margin-top: 8px; font-size: 15px; color: var(--muted); }

/* Tonal panels, one layer each; the maps are the one white inner card */
.grid { gap: var(--gap); }
.panel { background: var(--surface); border: 0; border-radius: var(--radius-card); padding: var(--card-pad); }
.panel-head h1, .panel-head h2 { font-size: var(--fs-section); font-weight: 600; }
.theater-map, .route-map { background: var(--raised); border: 0; border-radius: var(--radius-inner); }
.kpis { gap: var(--gap); background: transparent; border: 0; border-radius: 0; }
.kpi, .kpi + .kpi { background: var(--surface); border: 0; border-radius: var(--radius-card); padding: 20px 22px; }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font-size: var(--fs-kpi); font-weight: 600; line-height: 1.2; margin-top: 6px; }
.kpi-value.lead { font-size: 40px; }
.kpi-value strong, .kpi-value b { font-weight: 400; }

/* Controls: pills, white fields */
.btn { height: var(--control-height); padding: 0 18px; border-radius: var(--radius-control); background: var(--raised); border: 1px solid var(--border); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.icon-btn { width: var(--control-height); }
.select, .input, .textarea { background: var(--raised); border: 1px solid var(--control); border-radius: 12px; }
.select, .input { height: 40px; }
.pill { border-radius: var(--radius-control); padding: 0 10px; }

/* Exercise: the situation is read first, answers are white cards */
.phase-strip { background: var(--surface); border: 0; border-radius: var(--radius-card); padding: 6px; gap: 6px; }
.phase-step { border: 0; border-radius: 14px; }
.phase-step[aria-current="step"] { background: var(--raised); }
.sitrep-box, body.sim-active .sitrep-box { background: transparent; border: 0; padding: 0; margin-bottom: 18px; }
.sitrep-box p, body.sim-active .sitrep-box p { font-size: 17px; line-height: 1.65; color: var(--text); margin-top: 10px; }
.choice-item { background: var(--raised); border: 1px solid var(--border); border-radius: var(--radius-inner); padding: 14px 16px; }
.choice-item:hover { border-color: var(--control); }
.choice-item[aria-checked="true"] { border-color: var(--accent); outline: 1px solid var(--accent); outline-offset: -2px; background: var(--raised); }

/* Intro */

@media print { .sidebar { display: none !important; } .app { display: block; } }

/* Phone and tablet: the sidebar becomes a top bar, the three steps a bottom bar */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); padding-bottom: 68px; }
  .sidebar { position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 16px; border-inline-end: 0; border-bottom: 1px solid var(--border); z-index: 20; }
  .brand { padding: 0; min-width: 0; flex: 1; }
  .brand-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand-text span { display: none; }
  .side-foot { margin: 0; padding: 0; display: flex; align-items: center; gap: 8px; }
  .user-row .user-meta { display: none; }
  .side-nav { position: fixed; bottom: 0; inset-inline: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--ground); border-top: 1px solid var(--border); }
  .sidebar .rail-btn { height: 52px; flex-direction: column; justify-content: center; gap: 4px; padding: 0 4px; font-size: 12px; text-align: center; border-top: 0; }
  .canvas { padding: 20px 16px 32px; }
  body[data-mode="overview"] .greeting { font-size: 30px; }
  .greeting { font-size: 24px; }
  .kpis { gap: 10px; }
  .kpi, .kpi + .kpi { border: 0 !important; padding: 14px 16px; }
  .kpi-value { font-size: 24px; }
  .kpi-value.lead { font-size: 30px; }
  .panel { padding: 18px; }
  .sitrep-box p, body.sim-active .sitrep-box p { font-size: 16px; }
}

.user-meta { display: grid; min-width: 0; line-height: 1.3; }
.user-meta #ws-officer { font-weight: 500; }
.user-role { font-size: var(--fs-small); color: var(--muted); }
/* In a half-width panel the two selects share a row and the start button takes the next one */
.launch-bar { grid-template-columns: minmax(0, 1fr); gap: 14px; } /* stacked, so full mission names fit in a half-width panel */
#btn-launch-now { grid-column: 1 / -1; height: 44px; }

/* Report: the notes boxes are the review card's content, sized to sit level with the route and skills card */
#aar-notes, #aar-plan { min-height: 168px; }

/* The map panel matches the setup card's height by letting the white map card grow, not by leaving a gap */
.overview-map-only { display: flex; flex-direction: column; }
.overview-map-only .theater-map { flex: 1; min-height: 250px; }
@media (max-width: 1024px) { .overview-map-only .theater-map { flex: none; } }

/* Step-by-step guide: a spotlight on one part of the page and a card that explains it */
.guide { position: fixed; inset: 0; z-index: 200; }
.guide-spot {
  position: fixed; border-radius: 18px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(15, 16, 14, 0.62); /* taste-skill-ignore: the dimmed page around the spotlight */
  outline: 2px solid var(--accent); outline-offset: 0;
  transition: top 0.28s cubic-bezier(0.22, 1, 0.36, 1), left 0.28s cubic-bezier(0.22, 1, 0.36, 1), width 0.28s cubic-bezier(0.22, 1, 0.36, 1), height 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.guide.is-centred .guide-spot { top: 50% !important; left: 50% !important; width: 0 !important; height: 0 !important; outline: 0; }
.guide-card {
  position: fixed; width: min(380px, calc(100vw - 24px)); padding: 20px 22px;
  background: var(--raised); color: var(--text); border-radius: var(--radius-card);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25); /* taste-skill-ignore: the guide card floats over the page */
  transition: top 0.28s cubic-bezier(0.22, 1, 0.36, 1), left 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.guide.is-centred .guide-card { top: 50% !important; left: 50% !important; transform: translate(-50%, -50%); }
.guide-count { font-size: var(--fs-small); color: var(--muted); margin-bottom: 6px; }
.guide-card h2 { font-family: var(--font-greeting); font-weight: 700; font-size: 24px; line-height: 1.2; margin-bottom: 8px; }
:lang(ar) .guide-card h2 { line-height: 1.5; }
.guide-card p#guide-body { color: var(--muted); line-height: 1.6; }
.guide-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 18px; }
.guide-nav { display: flex; gap: 8px; }
@media (max-width: 600px) {
  .guide-card, .guide.is-centred .guide-card { top: auto !important; left: 12px !important; right: 12px; bottom: 12px; width: auto; transform: none; }
}
.guide [hidden] { display: none !important; }
@media (max-width: 600px) { .guide.dock-top .guide-card { top: 12px !important; bottom: auto; } }

.picker-btn .picker-text, .picker-option .picker-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   Motion layer: feedback on every control, state changes that move, and entrances on entering a screen.
   Easing: one curve for movement (--ease-out) and a slight overshoot for things that pop (--ease-pop).
   Everything here is switched off by the prefers-reduced-motion rule earlier in this file.
   ========================================================================== */
:root { --ease-out: cubic-bezier(0.22, 1, 0.36, 1); --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1); }

/* Controls: lift on hover, press in on tap */
.btn, .track-btn, .picker-btn, .rail-btn, .row-action, .choice-item, .picker-option, .t-marker .t-dot {
  transition: transform 0.18s var(--ease-out), background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}
.btn:hover:not(:disabled), .track-btn:hover { transform: translateY(-1px); }
.btn:active:not(:disabled), .track-btn:active, .picker-btn:active { transform: translateY(0) scale(0.97); transition-duration: 0.08s; }
.btn.primary:hover:not(:disabled) { opacity: 0.94; }
.row-action { background-image: linear-gradient(currentColor, currentColor); background-repeat: no-repeat; background-size: 0 1px; background-position: 100% 100%; } /* taste-skill-ignore: an underline drawn with a 1px image, not a gradient fill */
.row-action:hover { background-size: 100% 1px; background-position: 0 100%; transition: background-size 0.25s var(--ease-out), color 0.2s ease; }

/* Answers: slide toward the reader on hover, the letter pops when chosen, the chosen answer flashes on confirm */
.choice-item:hover:not([aria-checked="true"]) { transform: translateX(4px); }
[dir="rtl"] .choice-item:hover:not([aria-checked="true"]) { transform: translateX(-4px); }
.choice-item:active { transform: scale(0.99); }
@keyframes badgePop { 0% { transform: scale(0.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
.choice-item[aria-checked="true"] .choice-badge { animation: badgePop 0.34s var(--ease-pop); }
@keyframes confirmFlash { 0% { background-color: var(--raised); } 45% { background-color: var(--pill-positive-bg); } 100% { background-color: var(--raised); } }
.choice-item.is-confirmed { animation: confirmFlash 0.24s ease; border-color: var(--accent); }

/* Sidebar: one highlight slides to the current step */
@media (min-width: 861px) { .side-nav { position: relative; } } /* phones keep the fixed bottom bar, which anchors the highlight too */
.nav-indicator { position: absolute; top: 0; left: 0; border-radius: 10px; background: var(--active); pointer-events: none; z-index: 0; }
.nav-indicator.is-ready { transition: transform 0.4s var(--ease-out), width 0.4s var(--ease-out), height 0.4s var(--ease-out); }
.side-nav .rail-btn { position: relative; z-index: 1; }
.sidebar .side-nav .rail-btn[aria-current="page"] { background: transparent; }
.rail-btn svg { transition: transform 0.25s var(--ease-pop); }
.rail-btn:hover:not(:disabled) svg { transform: scale(1.12); }

/* Map: markers pop in one by one, the chosen one grows */
@keyframes markerPop { from { opacity: 0; transform: scale(0.3); } }
.t-marker { transform-box: fill-box; transform-origin: center; }
.t-marker.is-playing { animation: markerPop 0.42s var(--ease-pop) both; animation-delay: calc(0.2s + var(--i, 0) * 0.06s); }
.t-marker:hover .t-code { fill: var(--text); }

/* Tables and lists: rows warm on hover */
tbody tr td { transition: background-color 0.2s ease; }
tbody tr:hover td { background: color-mix(in srgb, var(--active) 55%, transparent); }

/* Sheets and dialogs come in from where they belong */
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes dialogIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
.profile-dialog[open] { animation: dialogIn 0.28s var(--ease-out); }
.guide { animation: fadeIn 0.25s ease; }
.guide-card { animation: dialogIn 0.3s var(--ease-out); }

/* Theme switch: colours cross-fade for a moment */
.theme-switching *, .theme-switching *::before, .theme-switching *::after {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, fill 0.4s ease, stroke 0.4s ease !important;
}

/* The intro mark keeps a slow sweep; the step strip's current cell eases in */
.phase-step { transition: background-color 0.3s ease, color 0.3s ease; }
@keyframes softRise { from { opacity: 0; transform: translateY(6px); } }
.title-row .greeting, .title-row .sub { animation: softRise 0.5s var(--ease-out) both; }
.title-row .sub { animation-delay: 0.08s; }
/* Parts inside a panel follow quickly: all three answers are in within about half a second */
.choice-item.is-entering, .sitrep-box.is-entering, .mission-brief.is-entering { animation-duration: 0.36s; animation-delay: calc(90ms + var(--k, 0) * 45ms); }

/* Readiness check-in */
.readiness-dialog { width: min(480px, calc(100vw - 24px)); max-height: calc(100svh - 24px); overflow-y: auto; }
.readiness-item { border: 0; padding: 0; margin: 16px 0 0; }
.readiness-item legend { font-weight: 500; margin-bottom: 8px; }
.readiness-scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.readiness-option { position: relative; }
.readiness-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.readiness-option span { display: grid; place-items: center; height: 40px; border: 1px solid var(--control); border-radius: 12px; background: var(--raised); cursor: pointer; transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.18s var(--ease-out); }
.readiness-option:hover span { border-color: var(--accent); }
.readiness-option input:checked + span { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); animation: badgePop 0.3s var(--ease-pop); }
.readiness-option input:focus-visible + span { outline: 1px solid var(--accent); outline-offset: 2px; }
.readiness-ends { display: flex; justify-content: space-between; margin-top: 4px; font-size: var(--fs-small); color: var(--muted); }
.readiness-block { margin-bottom: 16px; }
.readiness-block .sub-heading { margin-top: 0; }
.readiness-values { list-style: none; margin: 0 0 6px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.readiness-values li { display: grid; gap: 2px; padding: 10px 12px; background: var(--raised); border-radius: 12px; font-size: var(--fs-small); color: var(--muted); }
.readiness-values strong { font-size: 18px; font-weight: 400; color: var(--text); }
@media (max-width: 600px) { .readiness-values { grid-template-columns: repeat(2, 1fr); } }

/* Thinking-under-pressure drill */
.drill-timer { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; margin-bottom: 18px; }
.drill-timer-text { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); min-width: 4ch; }
.drill-timer-track { height: 6px; border-radius: 999px; background: var(--rule); overflow: hidden; }
.drill-timer-fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; transform-origin: left center; }
[dir="rtl"] .drill-timer-fill { transform-origin: right center; }
.drill-lead { color: var(--muted); margin-bottom: 10px; }
.drill-passage { font-size: 18px; line-height: 1.7; padding: 18px 20px; background: var(--raised); border-radius: var(--radius-inner); margin-bottom: 18px; }
.drill-filler { color: var(--muted); }
.drill-question { font-size: 18px; line-height: 1.6; font-weight: 500; margin-bottom: 14px; }
.drill-confirm { margin-top: 14px; width: 100%; height: 44px; }
.drill-verdict { display: flex; align-items: baseline; gap: 12px; font-size: 18px; font-weight: 600; margin-bottom: 14px; }
.drill-verdict .num { font-size: 13px; font-weight: 400; color: var(--muted); }
.drill-verdict.is-right { color: var(--positive); }
.drill-verdict.is-wrong { color: var(--negative); }
.drill-order { margin: 0 0 12px; padding-inline-start: 20px; display: grid; gap: 4px; }
.priority-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.priority-task { width: 100%; }
.priority-task[aria-pressed="true"] { border-color: var(--accent); }
.priority-task[aria-pressed="true"] .choice-badge { background: var(--accent); border-color: var(--accent); color: var(--primary-ink); animation: badgePop 0.3s var(--ease-pop); }
html[data-theme="light"] .priority-task[aria-pressed="true"] .choice-badge { color: #ffffff; }
.drill-types { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
.drill-types li { display: grid; gap: 2px; padding: 12px 14px; background: var(--raised); border-radius: var(--radius-inner); }
.drill-types li span { color: var(--muted); }
.drill-intro .btn.primary, .drill-card .btn.primary { margin-top: 14px; }
.drill-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.drill-summary .kpi { background: var(--raised); }
.drill-task.is-new .drill-passage, .drill-task.is-new .drill-question, .drill-task.is-new .choice-list, .drill-task.is-new .priority-list, .drill-task.is-new .drill-verdict { animation: softRise 0.35s var(--ease-out) both; }
@media (max-width: 860px) { .drill-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } .drill-passage, .drill-question { font-size: 16px; } }

/* Home: choose the kind of training first */
.training-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.training-option {
  display: grid; gap: 6px; text-align: start; font: inherit; color: var(--text); cursor: pointer;
  padding: 18px 22px; border-radius: var(--radius-card);
  background: var(--surface); border: 1px solid var(--border);
  transition: background-color 0.2s var(--ease-out), border-color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.training-option:hover { background: var(--raised); transform: translateY(-1px); }
.training-option:active { transform: scale(0.99); }
.training-option[aria-pressed="true"] { background: var(--raised); border-color: var(--accent); outline: 1px solid var(--accent); outline-offset: -2px; }
.training-title { font-family: var(--font-greeting); font-weight: 700; font-size: 20px; line-height: 1.2; }
.training-desc { color: var(--muted); font-size: var(--fs-body); }
.training-meta { color: var(--faint); font-size: var(--fs-small); }
.training-option[aria-pressed="true"] .training-meta { color: var(--accent); }
.drill-card .launch-bar { margin-top: 12px; }
@media (max-width: 860px) {
  .training-choice { gap: 8px; margin-bottom: 10px; }
  .training-option { padding: 12px 14px; gap: 4px; }
  .training-title { font-size: 18px; }
  .training-desc { display: none; }
}
.record-finding { margin: 0 0 14px; font-size: var(--fs-body); }
.device-note { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 var(--gap); color: var(--muted); font-size: var(--fs-small); }
.device-note .row-action { font-size: var(--fs-small); }
.profile-dialog [hidden] { display: none !important; }

/* ==========================================================================
   Entrance (js/intro.js): a title sequence in the theme of the page (night palette here, day palette further down).
   Base styles are the end state; each animation only says where a thing comes from,
   so reduced motion (animations off) and a skip both land on the finished frame.
   0.0s crosshair, 0.3s terrain draws, 1.1s radar, 1.4s objectives, 2.0s route, 2.3s title, 3.3s controls
   ========================================================================== */
.intro-overlay {
  --i-bg: #060807; --i-ink: #eef0ea; --i-muted: #c2c8c1; --i-line: #5cbcaf; --i-hot: #e8b04a;
  position: fixed; inset: 0; z-index: 100; overflow: hidden;
  background: var(--i-bg); color: var(--i-ink);
  display: grid; align-items: end;
}

/* Map: a slow camera push, then a drift that never stops */
.intro-map { position: absolute; inset: 0; width: 100%; height: 100%; will-change: transform; animation: imPush 5.5s var(--ease-out) both, imDrift 40s ease-in-out 5.5s infinite alternate; }
@keyframes imPush { from { transform: scale(1.35) rotate(-2.5deg); } }
@keyframes imDrift { to { transform: scale(1.06) translate(-1.5%, 1%); } }
.im-grid line { stroke: var(--i-line); stroke-opacity: 0.08; stroke-width: 1; }
.im-grid { animation: imFade 1.2s ease 0.6s both; }
@keyframes imFade { from { opacity: 0; } }
.im-terrain path { fill: none; stroke: var(--i-line); stroke-opacity: 0.32; stroke-width: 1.2; stroke-dasharray: 1; stroke-dashoffset: 0;
  animation: imDraw 1.6s var(--ease-out) both; animation-delay: calc(0.3s + var(--c) * 0.035s); }
.im-terrain path.is-index { stroke-opacity: 0.6; stroke-width: 1.8; }
@keyframes imDraw { from { stroke-dashoffset: 1; } }

/* Radar: three rings ping out from the centre while the beam turns */
.intro-radar { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.ir-ring { position: absolute; left: 50%; top: 50%; width: 90vmax; height: 90vmax; margin: -45vmax 0 0 -45vmax; border-radius: 50%; border: 2px solid var(--i-line);
  opacity: 0; will-change: transform, opacity; animation: imPing 3.6s var(--ease-out) infinite; animation-delay: calc(1.1s + var(--s) * 1.2s); }
@keyframes imPing { 0% { opacity: 0.5; transform: scale(0.05); } 100% { opacity: 0; transform: scale(1); } }
.ir-sweep { position: absolute; left: 50%; top: 50%; width: 120vmax; height: 120vmax; margin: -60vmax 0 0 -60vmax; background: var(--i-line); opacity: 0.07;
  clip-path: polygon(50% 50%, 50% 0, 85% 0); will-change: transform; animation: imFade 1s ease 1.1s both, radarSpin 7s linear 1.1s infinite; }

/* Objectives pop in one by one, then a route links them */
.im-mark { color: var(--i-hot); }
.im-mark circle { fill: currentColor; }
.im-mark .im-mark-ring { fill: none; stroke: currentColor; stroke-width: 1.5; opacity: 0.5; }
.im-mark text { fill: var(--i-ink); fill-opacity: 0.75; font: 600 15px var(--font); letter-spacing: 0.08em; }
.im-mark > * { transform-box: fill-box; transform-origin: center; animation: imPop 0.5s var(--ease-pop) both; animation-delay: calc(1.4s + var(--m) * 0.09s); }
.im-mark text { animation-name: imFade; animation-delay: calc(1.6s + var(--m) * 0.09s); }
@keyframes imPop { from { opacity: 0; transform: scale(0.3); } }
.im-route { fill: none; stroke: var(--i-hot); stroke-width: 2; stroke-dasharray: 1; stroke-dashoffset: 0; opacity: 0.8; animation: imDraw 1.4s var(--ease-out) 2s both; }
.im-vig { pointer-events: none; }

/* Crosshair: two lines open from the centre, then step back */
.intro-cross { position: absolute; inset: 0; pointer-events: none; }
.intro-cross span { position: absolute; background: var(--i-line); opacity: 0.18; }
.ic-h { left: 0; right: 0; top: 50%; height: 2px; animation: icOpenX 1s var(--ease-out) both, icSettle 1s ease 1s both; }
.ic-v { top: 0; bottom: 0; left: 50%; width: 2px; animation: icOpenY 1s var(--ease-out) both, icSettle 1s ease 1s both; }
@keyframes icOpenX { from { transform: scaleX(0.02); opacity: 1; } }
@keyframes icOpenY { from { transform: scaleY(0.02); opacity: 1; } }
@keyframes icSettle { from { opacity: 0.7; } }

/* Corner brackets and live readouts */
.intro-hud { position: absolute; inset: clamp(14px, 3vw, 32px); pointer-events: none; font-size: 14px; font-weight: 600; letter-spacing: 0.08em; color: var(--i-muted); }
.hud-c { position: absolute; width: 22px; height: 22px; border-color: var(--i-line); border-style: solid; border-width: 0; opacity: 0.8; animation: hudIn 0.6s var(--ease-out) 1.5s both; }
.hud-tl { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; --dx: -10px; --dy: -10px; }
.hud-tr { top: 0; right: 0; border-top-width: 2px; border-right-width: 2px; --dx: 10px; --dy: -10px; }
.hud-bl { bottom: 0; left: 0; border-bottom-width: 2px; border-left-width: 2px; --dx: -10px; --dy: 10px; }
.hud-br { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; --dx: 10px; --dy: 10px; }
@keyframes hudIn { from { opacity: 0; transform: translate(var(--dx), var(--dy)); } }
.hud-read { position: absolute; top: 4px; display: inline-flex; align-items: center; gap: 8px; animation: imFade 0.8s ease 1.7s both; }
.hud-read-tl { inset-inline-start: 34px; }
.hud-read-tr { inset-inline-end: 34px; }
.hud-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--i-hot); animation: imBlink 1s steps(2, jump-none) infinite; }
@keyframes imBlink { 50% { opacity: 0.2; } }

/* Title block: bottom-start, like the opening card of a film. Hidden until the sequence starts, so the bare title never flashes */
.intro-overlay:not(.is-playing):not(.is-skipped) .intro-content { visibility: hidden; }
.intro-content { position: relative; padding: 0 clamp(20px, 7vw, 110px) clamp(40px, 9vh, 96px); max-width: 1100px; }
.intro-academy { color: var(--i-line); font-size: 16px; font-weight: 700; letter-spacing: 0.06em; margin-bottom: 14px; animation: imWipe 0.9s var(--ease-out) 2.2s both; }
@keyframes imWipe { from { clip-path: inset(0 100% 0 0); } }
[dir="rtl"] .intro-academy { animation-name: imWipeRtl; }
@keyframes imWipeRtl { from { clip-path: inset(0 0 0 100%); } }
.intro-title { font-family: var(--font-greeting); font-weight: 800; font-size: clamp(42px, 7.6vw, 112px); line-height: 1.1; letter-spacing: -0.015em; color: var(--i-ink); margin: 0 0 18px; }
:lang(ar) .intro-title { line-height: 1.35; letter-spacing: 0; font-size: clamp(40px, 7vw, 100px); }
.iw { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: 0.08em; }
.iw-in { display: inline-block; animation: iwRise 1s var(--ease-out) both; animation-delay: calc(2.3s + var(--w) * 0.12s); }
.intro-overlay.is-relabeled .iw-in { animation-duration: 0.6s; animation-delay: calc(var(--w) * 0.08s); }
@keyframes iwRise { from { transform: translateY(105%) rotate(4deg); opacity: 0; } }
.intro-sub { color: var(--i-ink); font-size: clamp(17px, 1.5vw, 20px); font-weight: 500; line-height: 1.6; max-width: 52ch; margin-bottom: 26px; animation: iwFadeUp 0.8s var(--ease-out) 2.8s both; }
@keyframes iwFadeUp { from { opacity: 0; transform: translateY(10px); } }
.intro-stats { display: flex; flex-wrap: wrap; gap: 10px clamp(22px, 4vw, 54px); margin-bottom: 30px; }
.intro-stat { display: grid; gap: 2px; color: var(--i-muted); font-size: 15px; font-weight: 600; animation: iwFadeUp 0.7s var(--ease-out) both; animation-delay: calc(2.9s + var(--n, 0) * 0.1s); }
.intro-stat-n { font-family: var(--font-greeting); font-weight: 700; font-size: clamp(34px, 3.6vw, 52px); line-height: 1; color: var(--i-ink); }
.intro-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; animation: iwFadeUp 0.7s var(--ease-out) 3.3s both; }
.intro-overlay .btn { height: 52px; padding: 0 24px; font-size: 17px; font-weight: 700; background: transparent; color: var(--i-ink); border: 2px solid color-mix(in srgb, var(--i-ink) 30%, transparent); }
.intro-overlay .btn:hover { background: color-mix(in srgb, var(--i-ink) 10%, transparent); }
.intro-overlay .intro-enter-btn { min-width: 200px; background: var(--i-hot); color: #1a1205; border-color: var(--i-hot); font-weight: 600; }
.intro-overlay .intro-enter-btn:hover { background: #f2c063; }
.intro-overlay .btn:focus-visible { outline: 2px solid var(--i-ink); outline-offset: 3px; }

/* A scan beam crosses the screen once while the terrain draws */
.intro-flash { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--i-line); opacity: 0; pointer-events: none; animation: imScan 1.6s var(--ease-out) 0.25s both; }
@keyframes imScan { 0% { opacity: 0.9; transform: translateY(0); } 85% { opacity: 0.5; } 100% { opacity: 0; transform: translateY(100vh); } }

/* Skip: every entrance jumps to its end; the looping ambience keeps going */
.intro-overlay.is-skipped .im-grid, .intro-overlay.is-skipped .im-terrain path, .intro-overlay.is-skipped .im-route,
.intro-overlay.is-skipped .im-mark text, .intro-overlay.is-skipped .intro-cross span, .intro-overlay.is-skipped .hud-c,
.intro-overlay.is-skipped .hud-read, .intro-overlay.is-skipped .intro-academy, .intro-overlay.is-skipped .iw-in,
.intro-overlay.is-skipped .intro-sub, .intro-overlay.is-skipped .intro-stat, .intro-overlay.is-skipped .intro-actions,
.intro-overlay.is-skipped .intro-flash { animation: none; }
.intro-overlay.is-skipped .intro-map { animation: imDrift 40s ease-in-out infinite alternate; }
.intro-overlay.is-skipped .im-mark circle:not(.im-mark-ring) { animation: none; }

@media (max-width: 700px) {
  .intro-content { padding-bottom: max(56px, env(safe-area-inset-bottom)); }
  .intro-actions .btn { flex: 1 1 auto; }
  .hud-read-tr { display: none; }
  .intro-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
  .intro-stat { font-size: 13px; }
}

/* Entrance, day theme: paper and ink, with the same teal terrain and an amber route */
html[data-theme="light"] .intro-overlay { --i-field: #fffdf8; --i-bg: #f3f1ea; --i-ink: #141513; --i-muted: #3f413a; --i-line: #1b6e66; --i-hot: #a8620a; --i-hot-ink: #ffffff; }
.intro-overlay { --i-hot-ink: #1a1205; --i-field: #0e1210; }
.im-stop { stop-color: var(--i-bg); }
html[data-theme="light"] .im-terrain path { stroke-opacity: 0.38; }
html[data-theme="light"] .im-grid line { stroke-opacity: 0.1; }
html[data-theme="light"] .ir-sweep { opacity: 0.06; }
.intro-overlay .intro-enter-btn { color: var(--i-hot-ink); }
html[data-theme="light"] .intro-overlay .intro-enter-btn:hover { background: #8f5208; }

/* Title and setup share the lower-start corner; one steps out as the other steps in */
.intro-content, .intro-setup { grid-area: 1 / 1; align-self: end; }
.intro-content { transition: opacity 0.45s var(--ease-out), transform 0.6s var(--ease-out), visibility 0.6s; }
.intro-overlay.is-setup .intro-content { opacity: 0; transform: translateY(-36px); visibility: hidden; pointer-events: none; }
.intro-map { transition: translate 1.4s var(--ease-out), scale 1.4s var(--ease-out), opacity 0.8s var(--ease-out); }
.intro-overlay.is-setup .intro-map { translate: 6% -6%; scale: 1.16; opacity: 0.35; }
.intro-overlay.is-setup .intro-radar { opacity: 0.4; transition: opacity 0.8s var(--ease-out); }

.intro-setup {
  position: relative; width: min(560px, 100%); margin-inline-start: clamp(20px, 7vw, 110px); margin-bottom: clamp(40px, 9vh, 96px);
  display: grid; gap: 14px; visibility: hidden; pointer-events: none;
}
.intro-overlay.is-setup .intro-setup { visibility: visible; pointer-events: auto; }
/* The form can be taller than the space the keyboard leaves: the entrance scrolls, and "safe" keeps its top reachable */
.intro-overlay.is-setup { overflow-y: auto; overscroll-behavior: contain; align-items: safe end; }
.intro-hud { transition: opacity 0.4s var(--ease-out); }
.intro-overlay.is-setup .intro-hud { opacity: 0; }
.intro-setup > * { opacity: 0; transform: translateY(24px); transition: opacity 0.55s var(--ease-out), transform 0.7s var(--ease-out); }
.intro-overlay.is-setup .intro-setup > * { opacity: 1; transform: none; }
.intro-overlay.is-setup .intro-setup > :nth-child(1) { transition-delay: 0.25s; }
.intro-overlay.is-setup .intro-setup > :nth-child(2) { transition-delay: 0.33s; }
.intro-overlay.is-setup .intro-setup > :nth-child(3) { transition-delay: 0.41s; }
.intro-overlay.is-setup .intro-setup > :nth-child(4) { transition-delay: 0.49s; }
.intro-overlay.is-setup .intro-setup > :nth-child(5) { transition-delay: 0.57s; }
.setup-title { font-weight: 800; font-size: clamp(32px, 4.6vw, 64px); line-height: 1.15; color: var(--i-ink); }
.setup-privacy { display: flex; gap: 12px; align-items: flex-start; color: var(--i-ink); font-size: 17px; font-weight: 500; line-height: 1.65; max-width: 52ch; }
.setup-lock { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--i-hot-ink); background: var(--i-hot); }
.setup-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.setup-field { display: grid; gap: 8px; font-size: 16px; font-weight: 600; color: var(--i-ink); }
.setup-input {
  height: 52px; padding: 0 16px; border-radius: 12px; font: 600 18px var(--font); color: var(--i-ink);
  background: var(--i-field); border: 2px solid color-mix(in srgb, var(--i-ink) 45%, transparent);
  transition: border-color 0.2s var(--ease-out), background-color 0.2s var(--ease-out);
}
.setup-input:focus { outline: none; border-color: var(--i-line); background: var(--i-bg); }
.setup-name .setup-input { height: 56px; font-size: 20px; font-weight: 600; }
.setup-actions { margin-top: 6px; animation: none; }
.intro-setup.is-shaking .setup-name { animation: setupShake 0.4s var(--ease-out); }
@keyframes setupShake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* Leaving: the whole entrance closes into the button that was pressed while the app settles in behind it */
.intro-overlay.is-leaving { animation: irisClose 0.95s cubic-bezier(0.7, 0, 0.2, 1) both; pointer-events: none; }
@keyframes irisClose { from { clip-path: circle(150vmax at var(--ix, 50%) var(--iy, 50%)); } to { clip-path: circle(0 at var(--ix, 50%) var(--iy, 50%)); } }
.intro-overlay.is-leaving .intro-setup, .intro-overlay.is-leaving .intro-content { opacity: 0; transform: scale(0.96); transition: opacity 0.35s var(--ease-out), transform 0.5s var(--ease-out); }
.intro-overlay.is-hidden { display: none; }
body.app-arriving .app { animation: appArrive 1s var(--ease-out) both; }
@keyframes appArrive { from { transform: scale(1.06); opacity: 0.3; } }

/* The cut into an exercise or drill: a card sweeps across, names the mission, sweeps away */
.mission-wipe {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px;
  background: var(--text); color: var(--ground); pointer-events: none; visibility: hidden;
  clip-path: inset(0 100% 0 0);
}
.mission-wipe[data-dir="rtl"] { clip-path: inset(0 0 0 100%); }
.mission-wipe.is-in { visibility: visible; pointer-events: auto; clip-path: inset(0 0 0 0); transition: clip-path 0.52s cubic-bezier(0.7, 0, 0.2, 1); }
.mission-wipe.is-in.is-out { clip-path: inset(0 0 0 100%); transition: clip-path 0.56s cubic-bezier(0.7, 0, 0.2, 1); }
.mission-wipe[data-dir="rtl"].is-in.is-out { clip-path: inset(0 100% 0 0); }
.mw-inner { width: min(760px, 100%); display: grid; gap: 10px; }
.mw-code { font-size: 13px; letter-spacing: 0.08em; opacity: 0.72; }
.mw-title { font-weight: 800; font-size: clamp(30px, 5vw, 64px); line-height: 1.15; }
.mw-meta { font-size: 15px; opacity: 0.75; }
.mw-bar { display: block; height: 3px; margin-top: 14px; background: color-mix(in srgb, var(--ground) 20%, transparent); border-radius: 2px; overflow: hidden; }
.mw-bar span { display: block; height: 100%; background: var(--ground); transform-origin: left center; transform: scaleX(0); }
.mission-wipe[data-dir="rtl"] .mw-bar span { transform-origin: right center; }
.mission-wipe.is-in .mw-bar span { animation: mwBar 1.1s var(--ease-out) 0.2s forwards; }
@keyframes mwBar { to { transform: scaleX(1); } }
.mission-wipe.is-in .mw-inner > * { animation: mwRise 0.6s var(--ease-out) both; }
.mission-wipe.is-in .mw-code { animation-delay: 0.22s; }
.mission-wipe.is-in .mw-title { animation-delay: 0.3s; }
.mission-wipe.is-in .mw-meta { animation-delay: 0.38s; }
.mission-wipe.is-in .mw-bar { animation-delay: 0.42s; }
@keyframes mwRise { from { opacity: 0; transform: translateY(18px); } }

@media (max-width: 700px) {
  .intro-setup { margin-inline: 20px; width: auto; margin-bottom: max(56px, env(safe-area-inset-bottom)); }
  .setup-row { grid-template-columns: 1fr; }
  .intro-overlay.is-setup .intro-map { translate: 0 -10%; }
}

/* ==========================================================================
   Screen transitions (motion.js sectionTransition; html[data-vt] names the kind).
   The sidebar keeps its own name so only the content moves. Forward follows the reading
   direction (--vt-dir flips it in Arabic); step lifts one card away for the next.
   ========================================================================== */
:root { --vt-dir: 1; --vt-ease: cubic-bezier(0.77, 0, 0.18, 1); }
html[dir="rtl"] { --vt-dir: -1; }
.sidebar { view-transition-name: sidebar; }
::view-transition-group(root), ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.8s; animation-timing-function: var(--vt-ease); }
::view-transition-group(sidebar) { animation-duration: 0.8s; }

html[data-vt="forward"]::view-transition-old(root) { animation-name: vtOutForward; }
html[data-vt="forward"]::view-transition-new(root) { animation-name: vtInForward; }
html[data-vt="back"]::view-transition-old(root) { animation-name: vtOutBack; }
html[data-vt="back"]::view-transition-new(root) { animation-name: vtInBack; }
@keyframes vtOutForward { to { transform: translateX(calc(var(--vt-dir) * -16%)) scale(0.88); opacity: 0; filter: blur(8px); } }
@keyframes vtInForward { from { transform: translateX(calc(var(--vt-dir) * 28%)) scale(1.08); opacity: 0; filter: blur(8px); } }
@keyframes vtOutBack { to { transform: translateX(calc(var(--vt-dir) * 16%)) scale(0.88); opacity: 0; filter: blur(8px); } }
@keyframes vtInBack { from { transform: translateX(calc(var(--vt-dir) * -28%)) scale(1.08); opacity: 0; filter: blur(8px); } }

/* A new decision or drill task: the old card tips back and rises out, the next one climbs in from below */
html[data-vt="step"]::view-transition-old(root) { animation-name: vtOutStep; animation-duration: 0.6s; }
html[data-vt="step"]::view-transition-new(root) { animation-name: vtInStep; animation-duration: 0.75s; }
@keyframes vtOutStep { to { transform: perspective(1400px) translateY(-14%) rotateX(14deg) scale(0.9); opacity: 0; filter: blur(6px); } }
@keyframes vtInStep { from { transform: perspective(1400px) translateY(22%) rotateX(-10deg) scale(0.96); opacity: 0; } }

/* Exercise / drill switch: one falls away into depth while the other lands from the front */
html[data-vt="swap"]::view-transition-old(root) { animation-name: vtOutSwap; animation-duration: 0.55s; }
html[data-vt="swap"]::view-transition-new(root) { animation-name: vtInSwap; animation-duration: 0.7s; }
@keyframes vtOutSwap { to { transform: scale(0.84); opacity: 0; filter: blur(10px); } }
@keyframes vtInSwap { from { transform: scale(1.12); opacity: 0; filter: blur(10px); } }

/* Drill picker: one tap on an area starts six tasks in it; each card carries your record in that area */
.drill-picker .record-finding { font-size: 15px; }
.drill-area {
  display: grid; gap: 6px; width: 100%; text-align: start; font: inherit; color: var(--text); cursor: pointer;
  padding: 16px; border-radius: var(--radius-inner); background: var(--raised); border: 2px solid transparent;
  transition: transform 0.18s var(--ease-out), border-color 0.18s var(--ease-out), background-color 0.18s var(--ease-out);
}
.drill-area:hover { transform: translateY(-2px); border-color: var(--border); }
.drill-area:active { transform: scale(0.98); }
.drill-area:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.drill-area.is-weakest { border-color: var(--warning); }
.drill-area.is-mixed { background: var(--text); color: var(--ground); margin-bottom: 12px; padding: 18px 20px; }
.drill-area.is-mixed .da-desc { color: color-mix(in srgb, var(--ground) 75%, transparent); }
.da-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.da-name { font-weight: 700; font-size: 16px; }
.drill-area.is-mixed .da-name { font-size: 20px; }
.da-go { font-weight: 700; padding: 6px 16px; border-radius: var(--radius-control); background: var(--ground); color: var(--text); }
.da-desc { color: var(--muted); font-size: 13px; line-height: 1.5; }
.da-stat { font-size: 13px; font-weight: 600; }
.drill-areas { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.drill-area .cb-track { margin-top: 2px; }
@media (max-width: 1100px) { .drill-areas { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .drill-areas { grid-template-columns: 1fr; } }

/* The gridded map for spot the change and Kim's game */
.drill-map { margin: 0 0 16px; }
.drill-map svg { display: block; width: 100%; max-width: 560px; height: auto; margin-inline: auto; }
.dm-bg { fill: var(--raised); }
.dm-line { stroke: var(--border); stroke-width: 1.5; }
.dm-axis { fill: var(--muted); font: 600 13px var(--font); }
.dm-unit { fill: color-mix(in srgb, var(--accent) 18%, var(--raised)); stroke: var(--accent); stroke-width: 2; }
.dm-unit-mark { stroke: var(--accent); stroke-width: 1.5; }
.dm-object { fill: var(--raised); stroke: var(--text); stroke-width: 2.5; }
.dm-label { fill: var(--text); font: 700 13px var(--font); }
.drill-task.is-new .dm-mark { animation: softRise 0.4s var(--ease-out) both; animation-delay: calc(var(--i) * 0.04s); }
.drill-map.is-blank .dm-bg { fill: var(--ground); }

/* Freeze check: the updates arrive one at a time, then the picture freezes */
.freeze-updates { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.freeze-updates li { font-size: 17px; line-height: 1.65; padding: 14px 16px; border-radius: var(--radius-inner); background: var(--raised); border-inline-start: 4px solid var(--accent); animation: freezeIn 0.5s var(--ease-out) both; }
@keyframes freezeIn { from { opacity: 0; transform: translateY(12px); } }
.drill-freeze-banner { font-weight: 800; font-size: 20px; letter-spacing: 0.04em; color: var(--accent); margin-bottom: 6px; }

/* SALUTE: each report is six short lines */
.choice-list.is-reports .choice-text, .drill-right.is-report strong { white-space: pre-line; line-height: 1.6; }
.choice-list.is-reports .choice-item { align-items: flex-start; }
.drill-right.is-report strong { display: block; padding: 12px 14px; border-radius: var(--radius-inner); background: var(--raised); font-weight: 600; }

/* Sources and credits */
.credits-dialog { width: min(640px, calc(100vw - 24px)); max-height: calc(100svh - 32px); overflow-y: auto; }
.credits-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.credits-head h2 { font-size: 20px; font-weight: 700; }
.credits-group { margin-top: 18px; }
.credits-group h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.credits-group ul { margin: 8px 0 0; padding-inline-start: 18px; display: grid; gap: 6px; text-align: left; }
.credits-group a { color: var(--accent); text-underline-offset: 3px; word-break: break-word; }
.credits-group a:hover { color: var(--text); }

/* Key-value rows (exercise screen) */
.kv-list {
  display: grid;
}
.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
  font-size: var(--fs-body);
}
.kv-row:last-child { border-bottom: 0; }
.kv-row .k { color: var(--muted); }
.kv-row .v { font-weight: 500; text-align: end; }
.profile-dialog[open]::backdrop { animation: fadeIn 0.25s ease; }

/* Mission cards share the drill card design; the mission code sits where an area's tag would */
.mc-code { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); }
.mission-picker .is-mixed .da-name { font-size: 18px; }

/* Entrance, connected to the content: the real missions (hollow until completed, then filled and ticked),
   your record under the title, four figures and a ticker naming the drill areas */
.im-mark .im-mark-dot { fill: var(--i-bg); stroke: currentColor; stroke-width: 2.5; }
.im-mark.is-done .im-mark-dot { fill: currentColor; }
.im-mark-check { fill: none; stroke: var(--i-bg); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.intro-record { display: inline-flex; padding: 6px 14px; border-radius: var(--radius-control); background: color-mix(in srgb, var(--i-hot) 16%, transparent); color: var(--i-ink); font-size: 15px; font-weight: 700; margin-bottom: 14px; animation: iwFadeUp 0.7s var(--ease-out) 2.75s both; }
.intro-record[hidden] { display: none; }
.hud-read-br { top: auto; bottom: 4px; inset-inline-end: 34px; }
.intro-ticker { display: inline-block; font-weight: 700; color: var(--i-ink); }
.intro-ticker.is-in { animation: tickerIn 0.45s var(--ease-out) both; }
@keyframes tickerIn { from { opacity: 0; transform: translateY(8px); } }
.intro-overlay.is-skipped .intro-record { animation: none; }
@media (max-width: 700px) {
  .intro-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hud-read-br { top: 4px; bottom: auto; inset-inline: 34px; justify-content: center; }
  .hud-read-tl { display: none; }
}
