/* ==========================================================================
   סימולטור חוסן פיננסי — UI shell styles
   Dark, dense, McKinsey-style Monte Carlo dashboard. RTL Hebrew.
   Design tokens follow the LifeOS system, finance-gold accent variant.
   ========================================================================== */

:root {
  /* Canvas / surfaces */
  --bg-canvas: #05060d;
  --bg-secondary: #090b16;
  --glass-035: rgba(255, 255, 255, .035);
  --glass-06: rgba(255, 255, 255, .06);
  --glass-09: rgba(255, 255, 255, .09);
  --glass-12: rgba(255, 255, 255, .12);
  --border-default: rgba(255, 255, 255, .08);
  --border-soft: rgba(255, 255, 255, .05);

  /* Text */
  --text-primary: #f2f4fb;
  --text-muted: #9aa3bd;
  --text-faint: #5c6484;

  /* Accent */
  --gold: #f0b34a;
  --gold-gradient: linear-gradient(135deg, #f0b34a, #e8608f);
  --danger: #e8608f;
  --success: #3fd0b0;
  --info: #4c86e8;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Radius */
  --radius-control: 12px;
  --radius-card: 20px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .4);
  --glow-gold: 0 0 28px rgba(240, 179, 74, .25);
  --focus-ring: 0 0 0 3px rgba(240, 179, 74, .35);

  /* Type */
  --font-stack: "Inter", "Segoe UI", system-ui, sans-serif;

  /* Motion */
  --ease-standard: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur-fast: 0.18s;
  --dur-slow: 0.32s;
}

/* ==========================================================================
   Reset / base
   ========================================================================== */

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

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 1200px 600px at 15% -10%, rgba(240, 179, 74, .07), transparent 60%),
    radial-gradient(ellipse 900px 500px at 100% 0%, rgba(76, 134, 232, .05), transparent 55%),
    var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-stack);
  font-size: 14px;
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, fieldset, legend {
  margin: 0;
  padding: 0;
  border: 0;
}

h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 19px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); }

button {
  font-family: inherit;
}

input, select, button {
  color: inherit;
}

/* Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--glass-12) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--glass-12);
  border-radius: var(--radius-pill);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--glass-12);
  background: rgba(255, 255, 255, .18);
}

/* LTR numeric islands */
[dir="ltr"] {
  text-align: left;
}

/* ==========================================================================
   Universal focus-visible ring — gold, consistent on every interactive
   element (buttons, pills, tabs, inputs, details>summary, legend chips,
   chart containers). Component-specific rules below may repeat this value
   deliberately; this is the fallback for everything else.
   ========================================================================== */

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ==========================================================================
   Entrance animation
   ========================================================================== */

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

.kpi-card,
.card,
.verdict-hero {
  animation: fade-up var(--dur-slow) var(--ease-standard) both;
}

.kpi-card:nth-child(1) { animation-delay: 0.02s; }
.kpi-card:nth-child(2) { animation-delay: 0.06s; }
.kpi-card:nth-child(3) { animation-delay: 0.10s; }
.kpi-card:nth-child(4) { animation-delay: 0.14s; }

@media (prefers-reduced-motion: reduce) {
  .kpi-card, .card, .verdict-hero {
    animation: none;
  }
}

/* Full reduced-motion coverage: entrance animation, skeleton pulse, hover/
   active transforms, chart transitions — every animation/transition in the
   app collapses to effectively-instant, per prefers-reduced-motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Header
   ========================================================================== */

#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-6);
  background: var(--glass-035);
  border-bottom: 1px solid var(--border-default);
  flex-wrap: wrap;
}

.header-title-block h1 {
  color: var(--text-primary);
}

.subtitle {
  margin-top: var(--sp-1);
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-pill);
  background: rgba(63, 208, 176, .12);
  border: 1px solid rgba(63, 208, 176, .3);
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
}

.seed-control {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.seed-control input[type="number"] {
  width: 76px;
}

.sr-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ==========================================================================
   View switcher — segmented pills on desktop, bottom tab bar on ≤700px
   ========================================================================== */

#view-switcher {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6) 0;
}

.view-tab {
  appearance: none;
  cursor: pointer;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-default);
  background: var(--glass-035);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: background var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              transform var(--dur-fast) var(--ease-standard);
}

.view-tab:hover {
  background: var(--glass-06);
  color: var(--text-primary);
}

.view-tab:active {
  transform: scale(0.97);
}

.view-tab:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.view-tab.active {
  background: var(--gold-gradient);
  border-color: transparent;
  color: #17110a;
  box-shadow: var(--glow-gold);
}

.view-tab-icon { flex-shrink: 0; }

/* ==========================================================================
   View panels
   ========================================================================== */

#view-container {
  padding: var(--sp-5) var(--sp-6) var(--sp-8);
}

.view-panel { display: none; }

.view-panel.active {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

/* ==========================================================================
   Story flow — View 2 (התוצאה), Scroll-Triggered Storytelling pattern.
   Desktop: generous stacked sections, auto height, no snap, no rail.
   Mobile (≤700px, see Responsive section below): one chapter ≈ one
   viewport, scroll-snap-align proximity, progress dots + scroll cue.
   ========================================================================== */

.story-flow {
  display: flex;
  flex-direction: column;
  gap: var(--sp-12);
}

.story-chapter {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.chapter-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
}

.chapter-num {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chapter-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.chapter-subtitle {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.chapter-narration {
  margin-top: var(--sp-2);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
  max-width: 70ch;
}

/* Progress dots (mobile-only rail, see Responsive section) */
.chapter-dots {
  display: none;
}

.chapter-dot {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chapter-dot::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--glass-12);
  transition: background var(--dur-fast) var(--ease-standard),
              transform var(--dur-fast) var(--ease-standard);
}

.chapter-dot.active::after {
  background: var(--gold);
  transform: scale(1.4);
  box-shadow: var(--glow-gold);
}

/* Chapter-1 "scroll to continue" affordance — mobile only, bounces once */
.scroll-cue {
  display: none;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  margin-top: var(--sp-4);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.scroll-cue-arrow {
  display: inline-block;
}

@keyframes scroll-cue-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* ==========================================================================
   Chapter 4 closing CTA — combined-insights climax
   ========================================================================== */

.combined-cta-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-4);
  padding: var(--sp-6);
  border-radius: var(--radius-card);
  background:
    radial-gradient(ellipse 500px 180px at 50% -20%, rgba(240, 179, 74, .10), transparent 60%),
    var(--glass-035);
  border: 1px solid rgba(240, 179, 74, .25);
}

.combined-cta-line {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 50ch;
}

.btn-combined-cta {
  padding: var(--sp-3) var(--sp-8);
  font-size: 14px;
}

/* ==========================================================================
   Sticky mobile run CTA (hidden on desktop)
   ========================================================================== */

.cta-run-mobile {
  display: none;
  appearance: none;
  cursor: pointer;
  touch-action: manipulation;
  border: none;
  border-radius: var(--radius-control);
  background: var(--gold-gradient);
  color: #17110a;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  box-shadow: var(--glow-gold), var(--shadow-lg);
  transition: transform var(--dur-fast) var(--ease-standard);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  appearance: none;
  cursor: pointer;
  touch-action: manipulation;
  border-radius: var(--radius-control);
  padding: var(--sp-2) var(--sp-4);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border-default);
  background: var(--glass-06);
  color: var(--text-primary);
  transition: transform var(--dur-fast) var(--ease-standard),
              background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard);
}

.btn:hover {
  background: var(--glass-09);
  border-color: var(--glass-12);
}

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

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn-primary {
  background: var(--gold-gradient);
  border-color: transparent;
  color: #17110a;
  box-shadow: var(--glow-gold);
}

.btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 0 34px rgba(240, 179, 74, .35);
}

.btn-secondary {
  background: var(--glass-035);
}

.btn-icon {
  padding: var(--sp-2) var(--sp-3);
  line-height: 1;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  filter: none;
  box-shadow: none;
  transform: none;
}

.btn:disabled:hover {
  background: var(--glass-035);
  border-color: var(--border-default);
}

/* ==========================================================================
   Report export CTA (פרק 4) — mirrors the combined-cta-block spacing so it
   reads as the story's closing action, not a stray control.
   ========================================================================== */

.report-export-inline {
  display: flex;
  justify-content: center;
  margin-top: var(--sp-4);
}

/* ==========================================================================
   KPI strip
   ========================================================================== */

#kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
}

.kpi-card {
  background: var(--glass-035);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-fast) var(--ease-standard),
              transform var(--dur-fast) var(--ease-standard);
}

.kpi-card:hover {
  border-color: var(--glass-12);
  transform: translateY(-1px);
}

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.kpi-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.1;
}

/* ==========================================================================
   Controls panel (View 1) — essential zone + advanced accordions
   ========================================================================== */

#controls {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.zone-heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.essential-zone {
  background: var(--glass-035);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  box-shadow: var(--shadow-sm);
}

.advanced-zone {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  align-items: start;
}

.advanced-zone .zone-heading {
  grid-column: 1 / -1;
  color: var(--text-muted);
}

.advanced-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.essential-pair {
  gap: var(--sp-4);
}

details.accordion-group {
  background: var(--glass-035);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  overflow: hidden;
}

details.accordion-group > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--glass-035);
  transition: background var(--dur-fast) var(--ease-standard);
  user-select: none;
}

details.accordion-group > summary::-webkit-details-marker {
  display: none;
}

details.accordion-group > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-inline-start: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform var(--dur-fast) var(--ease-standard);
  flex-shrink: 0;
  margin-inline-start: var(--sp-2);
}

details.accordion-group[open] > summary::after {
  transform: rotate(-135deg);
}

details.accordion-group > summary:hover {
  background: var(--glass-06);
}

.group-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-top: 1px solid var(--border-soft);
}

.divider {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: var(--sp-1) 0;
}

/* Field layout */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.field-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}

.field-row.triple {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ==========================================================================
   Inputs
   ========================================================================== */

input[type="number"],
input[type="text"],
input[type="month"],
select {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  padding: var(--sp-2) var(--sp-3);
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard);
}

input[type="number"]:hover,
input[type="text"]:hover,
input[type="month"]:hover,
select:hover {
  border-color: var(--glass-12);
}

input[type="number"]:focus,
input[type="text"]:focus,
input[type="month"]:focus,
select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--focus-ring);
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 0.4;
}

select {
  cursor: pointer;
}

/* ==========================================================================
   Checkboxes / radios — hand-styled
   ========================================================================== */

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--gold);
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-option,
.radio-option {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  padding: var(--sp-1) 0;
}

.checkbox-option.sub-checkbox {
  margin-inline-start: var(--sp-6);
  color: var(--text-muted);
  font-size: 12px;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.radio-group legend {
  margin-bottom: var(--sp-1);
}

.toggle-inline {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   Range slider — custom styled
   ========================================================================== */

.badge-value {
  display: inline-block;
  margin-inline-start: var(--sp-1);
  padding: 1px var(--sp-2);
  border-radius: var(--radius-pill);
  background: rgba(240, 179, 74, .14);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--glass-12);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--glass-12);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--gold-gradient);
  border: 2px solid #17110a;
  box-shadow: var(--glow-gold);
  transition: transform var(--dur-fast) var(--ease-standard);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold-gradient);
  border: 2px solid #17110a;
  box-shadow: var(--glow-gold);
}

input[type="range"]:focus-visible {
  outline: none;
  box-shadow: none; /* the thumb carries the ring, not the (invisible) track */
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: var(--focus-ring), var(--glow-gold);
}

/* ==========================================================================
   Results area / cards
   ========================================================================== */

.card {
  background: var(--glass-035);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}

.card > h3 {
  margin-bottom: var(--sp-4);
}

.card-head h3 {
  margin-bottom: 0;
}

.chart-box {
  min-height: 240px;
  border-radius: var(--radius-control);
  background: var(--bg-secondary);
  border: 1px solid var(--border-soft);
}

#ledger {
  border-radius: var(--radius-control);
  background: var(--bg-secondary);
  border: 1px solid var(--border-soft);
  min-height: 120px;
}

/* Tabular figures everywhere numbers appear, so digits never jitter the
   layout as they change (KPIs, verdict, insight rows, chart numerals,
   tabular data). */
.kpi-value,
.verdict-num,
.insight-numbers,
.badge-value,
#stress-matrix td,
#ledger td {
  font-variant-numeric: tabular-nums;
}

.chart-box svg text {
  font-variant-numeric: tabular-nums;
}

/* Fan chart: crosshair-scrubbable — pointer says so, and vertical drag
   doesn't fight the page's vertical scroll on touch. */
#fan-chart {
  cursor: crosshair;
  touch-action: pan-y;
}

#breach-strip svg rect {
  cursor: pointer;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-top: var(--sp-3);
}

.legend-item {
  appearance: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-control);
  background: transparent;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease-standard),
              transform var(--dur-fast) var(--ease-standard);
}

.legend-item:hover {
  background: var(--glass-06);
  color: var(--text-primary);
}

.legend-item:active {
  transform: scale(0.97);
}

.legend-item[aria-pressed="false"] {
  opacity: 0.4;
}

.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.swatch-median { background: var(--gold); }
.swatch-band-50 { background: rgba(240, 179, 74, .4); }
.swatch-band-90 { background: rgba(240, 179, 74, .18); }
.swatch-red { background: var(--danger); }
.swatch-green { background: var(--success); }

/* Fan legend sits ABOVE the chart (HTML chips, not svg text) */
#fan-legend {
  margin-top: 0;
  margin-bottom: var(--sp-3);
}

/* ==========================================================================
   Verdict hero — פרק 1 (the hook): the percentage isolated and huge, the
   one-sentence verdict below it, then two quiet stat rows. Nothing else
   shares this chapter's viewport on mobile.
   ========================================================================== */

.verdict-hero {
  border: 1px solid rgba(240, 179, 74, .25);
  border-radius: var(--radius-card);
  background:
    radial-gradient(ellipse 600px 200px at 80% -20%, rgba(240, 179, 74, .08), transparent 60%),
    var(--glass-035);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-8) var(--sp-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-4);
}

.verdict-percent {
  font-size: clamp(48px, 10vw, 64px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
  direction: ltr;
}

.verdict-percent.sev-success,
.verdict-num.sev-success { color: var(--success); }
.verdict-percent.sev-warn,
.verdict-num.sev-warn { color: var(--gold); }
.verdict-percent.sev-danger,
.verdict-num.sev-danger { color: var(--danger); }

.verdict-headline {
  max-width: 44ch;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-primary);
}

.verdict-num { white-space: nowrap; }

.verdict-stat-rows {
  margin-top: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: 100%;
  max-width: 420px;
}

.verdict-subline {
  font-size: 14px;
  color: var(--text-muted);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-control);
  background: var(--bg-secondary);
  border: 1px solid var(--border-soft);
}

.verdict-subline strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ==========================================================================
   Insights card — auto what-if engine ("מנוע מסקנות")
   ========================================================================== */

#card-insights > h3 {
  margin-bottom: var(--sp-1);
}

.insights-caption {
  margin-bottom: var(--sp-4);
  font-size: 12px;
  color: var(--text-muted);
}

.insights-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.insight-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  grid-template-areas: "label numbers chip apply";
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-control);
  background: var(--bg-secondary);
  border: 1px solid var(--border-soft);
}

.insight-row-combined {
  margin-top: var(--sp-2);
  padding-top: calc(var(--sp-3) + var(--sp-2));
  border-top: 1px solid var(--border-default);
}

.insight-label {
  grid-area: label;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.insight-numbers {
  grid-area: numbers;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.insight-chip {
  grid-area: chip;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.insight-chip--strong { color: var(--success); background: rgba(63, 208, 176, .12); }
.insight-chip--medium { color: var(--gold); background: rgba(240, 179, 74, .12); }
.insight-chip--weak { color: var(--text-muted); background: var(--glass-06); }

.insight-apply-btn {
  grid-area: apply;
  appearance: none;
  cursor: pointer;
  touch-action: manipulation;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-default);
  background: var(--glass-06);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              transform var(--dur-fast) var(--ease-standard);
}

.insight-apply-btn:hover {
  background: var(--gold-gradient);
  border-color: transparent;
  color: #17110a;
}

.insight-apply-btn:active { transform: scale(0.97); }

.insights-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: var(--sp-3) var(--sp-1);
}

/* Skeleton rows while experiments run — CSS-only pulse, no layout shift on fill */
.skeleton-block {
  display: block;
  height: 14px;
  border-radius: var(--radius-control);
  background: var(--glass-09);
  animation: insight-pulse 1.2s ease-in-out infinite;
}

.skeleton-label { grid-area: label; width: 60%; }
.skeleton-numbers { grid-area: numbers; width: 70px; }
.skeleton-chip { grid-area: chip; width: 46px; height: 22px; border-radius: var(--radius-pill); }
.skeleton-btn { grid-area: apply; width: 64px; height: 28px; border-radius: var(--radius-pill); }

@keyframes insight-pulse {
  0%, 100% { opacity: .35; }
  50% { opacity: .8; }
}

/* ==========================================================================
   Chart captions — one plain-language line under every chart
   ========================================================================== */

.chart-caption {
  margin-top: var(--sp-2);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Tables (stress matrix, ledger) scroll inside their box, never the page */
#stress-matrix,
#ledger {
  overflow-x: auto;
}

/* "עוד תוצאות" wrapper details — cards inside keep their own chrome */
#more-results .group-body,
#view-deep .group-body {
  gap: var(--sp-5);
}

#more-results .card,
#view-deep .card {
  animation: none;
}

/* ==========================================================================
   Stress strip — pill buttons
   ========================================================================== */

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.pill-btn {
  appearance: none;
  cursor: pointer;
  touch-action: manipulation;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-default);
  background: var(--glass-06);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  transition: background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              transform var(--dur-fast) var(--ease-standard);
}

.pill-btn:hover {
  background: var(--glass-09);
  border-color: var(--glass-12);
  transform: translateY(-1px);
}

.pill-btn:active {
  transform: scale(0.97);
}

.pill-btn.active {
  background: var(--gold-gradient);
  border-color: transparent;
  color: #17110a;
  box-shadow: var(--glow-gold);
}

#stress-offset {
  width: auto;
  min-width: 190px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

#app-footer {
  padding: var(--sp-6);
  border-top: 1px solid var(--border-default);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.footer-main {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.footer-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1100px) {
  #kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .advanced-zone {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   ≤700px — phone layout: bottom tab bar, sticky CTA, 44px touch inputs
   -------------------------------------------------------------------------- */

@media (max-width: 700px) {
  body {
    /* clear the fixed tab bar (56px) + sticky CTA (52px + gap) */
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 84px);
  }

  #app-header {
    flex-direction: column;
    align-items: stretch;
    padding: var(--sp-4);
  }

  .header-controls {
    justify-content: flex-start;
  }

  /* run button lives in the sticky CTA on mobile */
  #app-header #btn-run {
    display: none;
  }

  #view-container {
    padding: var(--sp-4) var(--sp-4) var(--sp-6);
  }

  /* Bottom fixed tab bar: 3 tabs, 56px + safe area */
  #view-switcher {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    padding: 0 0 env(safe-area-inset-bottom, 0px);
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    background: rgba(9, 11, 22, .96);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border-default);
  }

  .view-tab {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: var(--sp-1) 0;
    border: none;
    border-radius: 0;
    background: transparent;
    font-size: 11px;
    color: var(--text-muted);
  }

  .view-tab:hover {
    background: transparent;
  }

  .view-tab.active {
    background: transparent;
    color: var(--gold);
    box-shadow: none;
  }

  /* Sticky run CTA above the tab bar — visible only in View 1 */
  body[data-active-view="input"] .cta-run-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: var(--sp-4);
    right: var(--sp-4);
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + var(--sp-3));
    height: 52px;
    z-index: 40;
  }

  .cta-run-mobile:active {
    transform: translateY(1px);
  }

  /* Touch-friendly inputs: ≥44px tall, 16px font (no iOS zoom-on-focus) */
  input[type="number"],
  input[type="text"],
  input[type="month"],
  select {
    min-height: 44px;
    font-size: 16px;
  }

  .checkbox-option,
  .radio-option {
    min-height: 44px;
    padding: var(--sp-1) 0;
    font-size: 15px;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
  }

  .field-label {
    font-size: 12px;
  }

  /* full-width rows, label above input */
  .field-row,
  .field-row.triple,
  .essential-pair {
    grid-template-columns: 1fr;
  }

  /* KPI cards (moved into "עוד תוצאות" by JS) — compact 2-up */
  #kpi-strip {
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
  }

  .kpi-card {
    padding: var(--sp-4);
  }

  .kpi-value {
    font-size: 24px;
  }

  /* Verdict: slightly smaller headline on phones */
  .verdict-headline {
    font-size: 20px;
  }

  /* Fan chart: full-bleed feel, 60vw tall (min 240px) */
  .chart-box-fan {
    height: 60vw;
    min-height: 240px;
  }

  .card {
    padding: var(--sp-4);
  }

  /* Insights rows: stack label above numbers/chip/button, full-width 44px CTA */
  .insight-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "label label"
      "numbers chip"
      "apply apply";
    row-gap: var(--sp-2);
  }

  .insight-apply-btn {
    min-height: 44px;
    width: 100%;
  }

  .skeleton-btn {
    width: 100%;
    height: 44px;
  }

  /* Touch targets: stress pills + legend chips reach 44px tall via padding,
     staying visually compact through smaller font/gap rather than bulking up. */
  .pill-btn,
  .legend-item {
    min-height: 44px;
  }

  .pill-row {
    gap: var(--sp-2);
  }

  .legend-row {
    gap: var(--sp-2);
  }

  /* ------------------------------------------------------------------------
     Story flow — mobile: scroll-snap PROXIMITY (not mandatory) on the
     document scroll, so free scrolling still works. Only active while View 2
     (results) is the visible panel — other views/desktop are untouched.
     ------------------------------------------------------------------------ */
  body[data-active-view="results"] {
    scroll-snap-type: y proximity;
  }

  .story-chapter {
    min-height: 88dvh;
    scroll-snap-align: start;
    justify-content: flex-start;
    padding: var(--sp-6) 0;
  }

  #chapter-1 {
    justify-content: center;
  }

  .story-flow {
    gap: 0;
  }

  /* Progress rail — 4 dots on the right edge (physical edge, independent of
     RTL reading direction), visible only in the results view. */
  body[data-active-view="results"] .chapter-dots {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: fixed;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 45;
  }

  .chapter-dot {
    width: 24px;
    height: 24px;
  }

  .scroll-cue {
    display: flex;
    animation: scroll-cue-bounce 1.6s ease-in-out 1;
  }
}
