/* ==========================================================================
   Doughbert — design system & components

   Layered roughly: tokens → reset → utilities → layout → components.
   ========================================================================== */

:root {
  /* Color */
  --bg: #fdf6ec;
  --surface: #fffaf2;
  --surface-warm: #fff7e8;
  --surface-warmer: #fff0d9;
  --crust: #d9a55a;
  --crust-dark: #b07a31;
  --crust-light: #e7b46a;
  --crumb: #6b4a2b;
  --ink: #3a2a1a;
  --muted: #5e4d3a; /* WCAG AA on --bg */
  --line: #f0e2cb;
  --line-strong: #ead7b1;
  --danger: #b3261e;
  --success: #2f7a3a;
  --remove: #c25b4a;

  /* Effects */
  --shadow: 0 8px 24px rgba(107, 74, 43, 0.18);
  --shadow-soft: 0 2px 6px rgba(107, 74, 43, 0.10);
  --shadow-strong: 0 16px 48px rgba(58, 42, 26, 0.4);
  --bevel-up:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -2px 0 rgba(107, 74, 43, 0.25);
  --bevel-down:
    inset 0 2px 4px rgba(107, 74, 43, 0.35),
    inset 0 -1px 0 rgba(255, 255, 255, 0.15);

  /* Geometry */
  --radius: 22px;
  --radius-pill: 999px;

  /* Motion */
  --motion-fast: 100ms;
  --motion-base: 150ms;
  --motion-slow: 240ms;

  /* Focus */
  --focus-ring: 0 0 0 3px rgba(176, 122, 49, 0.45);
}

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

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

body:has(.step) {
  overflow: hidden;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  padding: 8px 16px;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  border-radius: 0 0 12px 0;
  transform: translateY(-110%);
  transition: transform var(--motion-base) ease;
  z-index: 10000;
}

.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid var(--crust);
  outline-offset: 2px;
}

/* Universal focus-visible ring on interactive elements. */
:where(a, button, input, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 8px;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(12px, 2.5vh, 24px) 20px calc(clamp(12px, 2.5vh, 24px) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.header {
  text-align: center;
  padding: clamp(4px, 1vh, 12px) 0 clamp(6px, 1.5vh, 16px);
}

/* Welcome and results screens own the full viewport — hide the chrome. */
.app:has(.step.active[data-step="1"]) .header,
.app:has(.step.active[data-step="6"]) .header {
  display: none;
}

/* ==========================================================================
   Logo
   ========================================================================== */

.logo {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: var(--crumb);
  text-decoration: none;
}

.logo-mark {
  filter: drop-shadow(0 2px 3px rgba(107, 74, 43, 0.25));
}

.logo-text {
  font-family: "Georgia", "Times New Roman", serif;
}

/* ==========================================================================
   Steps (multi-step wizard)
   ========================================================================== */

.step {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: clamp(10px, 2vh, 16px);
  animation: pop var(--motion-slow) ease-out;
}

.step.active {
  display: flex;
}

.step-form {
  display: contents;
}

.step-title {
  margin: 0;
  font-size: clamp(24px, 4.5vh, 32px);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.15;
}

.step-hint {
  margin: 0 0 8px;
  font-size: clamp(15px, 2.2vh, 17px);
  color: var(--muted);
  max-width: 320px;
}

.step-icon {
  margin: 0 0 4px;
  font-size: clamp(56px, 11vh, 88px);
  line-height: 1;
}

/* Per-step tweaks */
.step[data-step="5"] .step-icon { font-size: clamp(40.5px, 7.95vh, 63.6px); }
.step[data-step="6"] .step-icon { font-size: clamp(27px, 5.4vh, 43.2px); }
.step[data-step="6"] .step-title { font-size: clamp(21.6px, 4.05vh, 28.8px); }
.step[data-step="6"]            { gap: clamp(6px, 1.2vh, 12px); }

.step[data-step="1"] .step-title {
  font-family: "Georgia", "Times New Roman", serif;
  color: var(--crumb);
  font-size: clamp(36px, 6.5vh, 48px);
  letter-spacing: 0.3px;
}

.step[data-step="1"] .app-icon { margin-bottom: 1.5rem; }
.step[data-step="1"] .step-hint { margin: 0 0 1.5rem; }

.app-icon {
  width: clamp(109px, 18.7vh, 143px);
  height: clamp(109px, 18.7vh, 143px);
  border-radius: 26%;
  box-shadow:
    0 18px 36px rgba(107, 74, 43, 0.28),
    0 6px 14px rgba(107, 74, 43, 0.18),
    0 1px 2px rgba(107, 74, 43, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 8px rgba(107, 74, 43, 0.12);
}

@keyframes pop {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Card surfaces (shared between checklist items & timing options)
   ========================================================================== */

.surface-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  transition: border-color var(--motion-base) ease, background var(--motion-base) ease;
}

.surface-card:hover {
  border-color: var(--crust);
  background: var(--surface-warm);
}

/* ==========================================================================
   Checklist
   ========================================================================== */

.checklist {
  list-style: none;
  padding: 0;
  margin: 8px auto 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: max-content;
  max-width: 100%;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font-size: clamp(13px, 4.2vw, 17px);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--motion-base) ease, background var(--motion-base) ease;
  white-space: nowrap;
}

.check-item:has(input:checked) {
  border-color: var(--crust);
  background: var(--surface-warm);
}

.check-item input[type="checkbox"] {
  appearance: none;
  width: 28px;
  height: 28px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-warmer);
  color: var(--crumb);
  font: 900 15px/1 inherit;
  -webkit-text-stroke: 0.75px currentColor;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
  display: grid;
  place-content: center;
  transition: border-color var(--motion-base) ease, background var(--motion-base) ease, color var(--motion-base) ease;
}

.check-item input[type="checkbox"]::before {
  content: attr(data-step-num);
  transition: transform var(--motion-base) ease;
}

.check-item input[type="checkbox"]:checked {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  font-size: 16px;
}

.check-item input[type="checkbox"]:checked::before { content: '✓'; }

@media (max-width: 380px) {
  .check-item { gap: 10px; padding: 14px; }
  .check-item input[type="checkbox"] { width: 26px; height: 26px; font-size: 13px; }
  .check-item input[type="checkbox"]:checked { font-size: 15px; }
}

/* ==========================================================================
   Timing options (menu of cards)
   ========================================================================== */

.timing-options {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1vh, 10px);
  width: 100%;
  max-width: 360px;
  margin: 4px 0 8px;
  padding: 0;
}

.timing-card {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  padding: clamp(10px, 1.6vh, 14px) clamp(12px, 3vw, 16px);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition:
    border-color var(--motion-base) ease,
    background var(--motion-base) ease,
    transform var(--motion-fast) ease;
}

.timing-card:hover {
  border-color: var(--crust);
  background: var(--surface-warm);
}

.timing-card:active {
  transform: scale(0.98);
  border-color: var(--crust-dark);
  background: var(--surface-warmer);
}

.timing-icon {
  font-size: 26px;
  line-height: 1;
  width: 36px;
  text-align: center;
}

.timing-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.timing-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}

.timing-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* ==========================================================================
   Weight input
   ========================================================================== */

.input-wrap {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin: 4px 0 12px;
}

.weight-input {
  width: 100%;
  font-size: clamp(40px, 7vh, 56px);
  font-weight: 800;
  text-align: center;
  padding: clamp(12px, 2.2vh, 18px) 56px clamp(12px, 2.2vh, 18px) 16px;
  border: 3px solid var(--crust);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  box-shadow: var(--shadow);
  transition: border-color var(--motion-base) ease, transform var(--motion-base) ease;
  font-family: inherit;
}

.weight-input:focus {
  border-color: var(--crust-dark);
  transform: scale(1.01);
}

.unit {
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 24px;
  font-weight: 700;
  color: var(--muted);
  pointer-events: none;
}

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

.btn {
  width: 100%;
  max-width: 340px;
  min-height: clamp(56px, 9vh, 72px);
  font-size: clamp(18px, 2.8vh, 22px);
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  padding: 14px 24px;
  transition:
    transform var(--motion-fast) ease,
    box-shadow var(--motion-base) ease,
    background var(--motion-base) ease;
  font-family: inherit;
}

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

.btn-primary {
  background: linear-gradient(180deg, #e3b673 0%, var(--crust) 55%, #c8924a 100%);
  color: #fff;
  border: 1px solid var(--crust-dark);
  text-shadow: 0 1px 0 rgba(107, 74, 43, 0.35);
  box-shadow: var(--bevel-up), var(--shadow);
}

.btn-primary:hover {
  background: linear-gradient(180deg, var(--crust) 0%, var(--crust-dark) 100%);
}

.btn-primary:active { box-shadow: var(--bevel-down); }

.btn-primary:disabled {
  background: #ece1cc;
  color: #c9b48a;
  border-color: #d9caaa;
  text-shadow: none;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.85;
}

.btn-primary:disabled:active { transform: none; }

.btn-secondary {
  background: transparent;
  color: var(--muted);
  min-height: 56px;
  font-size: 17px;
  box-shadow: none;
}

.btn-secondary:hover { color: var(--ink); }

.btn-accept {
  background: linear-gradient(180deg, #7dd47f 0%, #4caf50 55%, #3d8a42 100%);
  color: #fff;
  border: 1px solid #3d8a42;
  text-shadow: 0 1px 0 rgba(0, 50, 20, 0.35);
  box-shadow: var(--bevel-up), var(--shadow);
}

.btn-accept:hover {
  background: linear-gradient(180deg, #66c46a 0%, #3d8a42 100%);
}

.btn-decline {
  background: linear-gradient(180deg, #ec8a8a 0%, #d9534f 55%, #aa3f3b 100%);
  color: #fff;
  border: 1px solid #aa3f3b;
  text-shadow: 0 1px 0 rgba(80, 20, 18, 0.35);
  box-shadow: var(--bevel-up), var(--shadow);
}

.btn-decline:hover {
  background: linear-gradient(180deg, #d97070 0%, #aa3f3b 100%);
}

/* Glimmer effect on primary CTAs */
.btn-glimmer {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.btn-glimmer:not(:disabled) {
  animation: btn-pulse 4s ease-in-out infinite;
}

.btn-glimmer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  transform: translateX(-100%);
  pointer-events: none;
}

.btn-glimmer:not(:disabled)::before {
  animation: btn-shimmer 4s ease-in-out infinite;
}

@keyframes btn-shimmer {
  0%, 25%   { transform: translateX(-100%); }
  75%, 100% { transform: translateX(100%); }
}

@keyframes btn-pulse {
  0%, 100% {
    box-shadow: var(--bevel-up), var(--shadow);
  }
  50% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.55),
      inset 0 -2px 0 rgba(107, 74, 43, 0.25),
      0 6px 20px rgba(184, 134, 70, 0.45);
  }
}

/* Tertiary text-button (formerly .link-back) */
.link-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 12px;
  margin: 4px 0 2px;
  transition: color var(--motion-base) ease;
}

.link-btn:hover {
  color: var(--ink);
  text-decoration: underline;
}

.link-btn:active { color: var(--crust-dark); }

/* ==========================================================================
   Ratio chip (results header)
   ========================================================================== */

.ratio-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 10px;
  background: linear-gradient(180deg, #fff5e1 0%, #ffe7be 100%);
  border: 2px solid var(--crust);
  border-radius: var(--radius-pill);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 4px 10px rgba(184, 134, 70, 0.22);
  color: var(--crumb);
  animation: ratio-pop 320ms ease-out;
  margin-top: 1rem;
}

.ratio-chip-label,
.ratio-chip-ready {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #fff;
  background: var(--crust-dark);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

.ratio-chip-ready {
  background: #3f8a4a;
  border: none;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--motion-fast) ease, filter var(--motion-base) ease;
}

.ratio-chip-ready:hover  { filter: brightness(1.08); }
.ratio-chip-ready:active { transform: scale(0.96); }
.ratio-chip-ready[hidden] { display: none; }

/* Keep the shimmer sweep on this small button, suppress the larger pulse. */
.ratio-chip-ready.btn-glimmer:not(:disabled) { animation: none; }

.ratio-chip-value {
  font-size: 19px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.4px;
}

.ratio-sep {
  color: var(--muted);
  font-weight: 700;
  margin: 0 2px;
  opacity: 0.7;
}

.ratio-hint-note {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  text-align: center;
  max-width: 320px;
}

.ratio-hint-note[hidden] { display: none; }

@keyframes ratio-pop {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   Scale control (− / + buttons)
   ========================================================================== */

.scale-control {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 6px 10px;
  background: var(--surface);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow);
  margin: clamp(8px, 1.5vh, 16px) 0 clamp(6px, 1vh, 12px);
}

.scale-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--crust);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--motion-base) ease, transform var(--motion-fast) ease;
}

.scale-btn:hover    { background: var(--crust-dark); }
.scale-btn:active   { transform: scale(0.94); }
.scale-btn:disabled {
  background: #e5d3b3;
  cursor: not-allowed;
  transform: none;
}

.scale-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  min-width: 56px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Results
   ========================================================================== */

.results {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(12px, 2vh, 20px) clamp(18px, 4vw, 24px);
  margin: clamp(4px, 1vh, 8px) 0 clamp(8px, 1.5vh, 16px);
}

.result-row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: clamp(6px, 1.2vh, 10px) 0;
  border-bottom: 1px solid var(--line);
}

.result-row:last-child,
.result-row:has(+ .result-row--total) {
  border-bottom: none;
}

.result-row--starter {
  padding-bottom: 12px;
  border-bottom: 2px solid var(--crust);
}

.result-row--total {
  grid-template-columns: 1fr auto;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 2px solid var(--crust);
  border-bottom: none;
}

.result-row--delta {
  grid-template-columns: 1fr auto;
  padding: 4px 0 0;
  border-bottom: none;
}

.result-row--delta[hidden] { display: none; }

.result-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.result-icon--add    { background: var(--crust); }
.result-icon--remove { background: var(--remove); }

.result-label {
  margin: 0;
  font-size: clamp(15px, 2.4vh, 18px);
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}

.result-row--total .result-label { color: var(--ink); }

.result-value {
  margin: 0;
  font-size: clamp(22px, 3.6vh, 28px);
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.result-unit {
  font-size: clamp(15px, 2.4vh, 18px);
  font-weight: 600;
  color: var(--muted);
  margin-left: 2px;
}

.result-row--delta .result-label { font-size: 14px; font-weight: 500; }
.result-row--delta .result-value { font-size: 16px; color: var(--muted); }
.result-row--delta .result-unit  { font-size: 14px; font-weight: 800; }

.result-row--delta.delta-up   .result-value,
.result-row--delta.delta-up   .result-unit  { color: var(--success); }
.result-row--delta.delta-down .result-value,
.result-row--delta.delta-down .result-unit  { color: var(--danger); }

/* ==========================================================================
   Jokes
   ========================================================================== */

.jokes {
  margin-top: clamp(6px, 1.5vh, 12px);
  margin-bottom: clamp(8px, 4vh, 32px);
  padding: clamp(8px, 2vh, 16px) 20px 4px;
  height: clamp(80px, 11vh, 96px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.jokes[hidden] { display: none; }

.joke {
  margin: 0;
  font-style: italic;
  font-size: 16px;
  color: var(--muted);
  max-width: 320px;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 700ms ease;
}

.joke.visible { opacity: 1; }

/* ==========================================================================
   Page links (footer nav)
   ========================================================================== */

.page-links {
  margin-top: 8px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.page-links[hidden] { display: none; }

.page-links a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 8px;
}

.page-links a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.page-links a + a::before {
  content: '·';
  margin-right: 14px;
  margin-left: 2px;
  color: var(--muted);
  pointer-events: none;
}

.page-icon { vertical-align: middle; }

/* ==========================================================================
   Static pages (Help, Terms)
   ========================================================================== */

.page {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 4px 24px;
  color: var(--ink);
  text-align: left;
  line-height: 1.55;
}

.page h1 {
  font-size: 28px;
  margin: 0 0 12px;
  color: var(--crumb);
}

.page h2 {
  font-size: 18px;
  margin: 24px 0 6px;
  color: var(--ink);
}

.page p {
  margin: 0 0 14px;
  font-size: 16px;
}

.page ol,
.page ul {
  margin: 0 0 14px;
}

.page li { margin-bottom: 6px; }

.page b { color: var(--crumb); }

/* ==========================================================================
   Modals (native <dialog>)
   ========================================================================== */

.modal {
  border: none;
  padding: 28px 24px 24px;
  max-width: 360px;
  width: calc(100% - 40px);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  text-align: center;
}

.modal[open] {
  animation: pop var(--motion-slow) ease-out;
}

.modal::backdrop {
  background: rgba(58, 42, 26, 0.45);
  animation: fadeIn 200ms ease;
}

.modal--chart {
  max-width: 480px;
  padding: 20px 18px;
  text-align: left;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
}

.modal--chart .page {
  padding: 0;
  max-width: none;
}

.modal--chart .page h2 {
  margin-top: 0;
  margin-bottom: 8px;
  padding-right: 40px;
  font-size: 22px;
  line-height: 1.2;
  color: var(--crumb);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: color var(--motion-base) ease, background var(--motion-base) ease;
}

.modal-close:hover  { color: var(--ink); background: rgba(107, 74, 43, 0.08); }
.modal-close:active {                     background: rgba(107, 74, 43, 0.16); }

.modal-icon {
  width: 96px;
  height: 96px;
  margin: 0 auto 12px;
  filter: drop-shadow(0 3px 4px rgba(107, 74, 43, 0.25));
}

.modal-title {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
}

.modal-body {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 16px;
}

.modal-body b { color: var(--ink); font-weight: 700; }

.modal .btn {
  width: 100%;
  min-height: 56px;
}

.modal-actions-split {
  display: flex;
  gap: 12px;
  margin: 0;
}

.modal-actions-split[hidden] { display: none; }

.modal-actions-split .btn {
  flex: 1;
  width: auto;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ==========================================================================
   Install prompt steps (Safari)
   ========================================================================== */

.install-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.install-steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
}

.install-steps .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--crust);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.install-steps .step-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: #007aff;
  flex-shrink: 0;
}

/* ==========================================================================
   Chart
   ========================================================================== */

.chart-wrap {
  width: 100%;
  margin: 6px 0 14px;
  padding: 12px 12px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.chart {
  width: 100%;
  height: auto;
  font-family: inherit;
}

.curve {
  transition: opacity 180ms ease, stroke-width 180ms ease;
}

.chart-caption {
  display: block;
  margin: 12px 0 0;
  padding: 12px 16px;
  font-size: 12px;
  line-height: 1.5;
  color: #000;
  background: #ebcc9b;
  border: 1px solid #c8a06a;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
}

.chart-caption b {
  color: #000;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Legend
   ========================================================================== */

.legend {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  width: 100%;
}

.legend li {
  grid-column: span 2;
  display: flex;
  min-width: 0;
}

.legend li:nth-child(4) { grid-column: 2 / span 2; }
.legend li:nth-child(5) { grid-column: 4 / span 2; }

.legend-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 10px;
  background: linear-gradient(180deg, #fffdf8 0%, #fff3dc 100%);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-pill);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    var(--shadow-soft);
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  transition:
    transform var(--motion-fast) ease,
    border-color var(--motion-base) ease,
    background var(--motion-base) ease,
    box-shadow var(--motion-base) ease;
}

.legend-chip:hover {
  border-color: var(--crust);
  transform: translateY(-1px);
}

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

.legend-chip.active {
  border-color: var(--crust-dark);
  background: linear-gradient(180deg, #ffe7be 0%, #f3c785 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 0 rgba(107, 74, 43, 0.18),
    0 4px 10px rgba(184, 134, 70, 0.28);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 0 0 1.5px var(--surface),
    0 0 0 2.5px rgba(0, 0, 0, 0.06);
}

.swatch-r05 { background: #c25b4a; }
.swatch-r1  { background: #d9a55a; }
.swatch-r2  { background: #8a5a22; }
.swatch-r4  { background: #3f8a4a; }
.swatch-r10 { background: #5b6cb0; }

.legend-label {
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

/* ==========================================================================
   Compact viewport — fit short screens (e.g. iPhone SE, 375x667)
   without scrolling. Body uses overflow:hidden during the wizard, so
   anything that doesn't fit gets clipped — these rules trim padding,
   font sizes and gaps so step 5 (timing) and step 6 (results) fit.
   ========================================================================== */

@media (max-height: 700px) {
  .app {
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  }

  .step { gap: 10px; }
  .step[data-step="6"] { justify-content: flex-start; }

  /* Step 5 — 5 timing cards plus chart link & back */
  .step[data-step="5"] .step-icon { font-size: 40px; }
  .step[data-step="5"] .step-title { font-size: 24px; }
  .timing-options { gap: 8px; }
  .timing-card { padding: 10px 14px; gap: 12px; }
  .timing-icon { font-size: 24px; width: 32px; }
  .timing-title { font-size: 15px; }
  .timing-time { font-size: 13px; }

  /* Step 6 — results, the densest screen */
  .step[data-step="6"] { gap: 8px; }
  .step[data-step="6"] .step-icon { font-size: 30px; }
  .step[data-step="6"] .step-title { font-size: 24px; }

  .ratio-chip { margin-top: 6px; padding: 5px 12px 5px 8px; gap: 8px; }
  .ratio-chip-value { font-size: 18px; }
  .ratio-chip-label, .ratio-chip-ready { font-size: 11px; padding: 3px 8px; }
  .ratio-hint-note { font-size: 12px; margin-top: 4px; }

  .scale-control { margin: 6px 0; padding: 5px 10px; gap: 12px; }
  .scale-btn { width: 36px; height: 36px; }
  .scale-value { font-size: 17px; }

  .results { padding: 12px 18px; margin: 4px 0 8px; }
  .result-row {
    grid-template-columns: 24px 1fr auto;
    gap: 10px;
    padding: 8px 0;
  }
  .result-row--total,
  .result-row--delta { grid-template-columns: 1fr auto; }
  .result-row--total { padding-top: 12px; }
  .result-icon { width: 22px; height: 22px; }
  .result-icon svg { width: 13px; height: 13px; }
  .result-label { font-size: 15px; }
  .result-value { font-size: 22px; }
  .result-unit { font-size: 14px; }

  .btn { min-height: 54px; font-size: 18px; padding: 12px 20px; }
  .btn-secondary { min-height: 44px; font-size: 16px; }
  .link-btn { font-size: 14px; padding: 6px 10px; margin: 4px 0; }
}

/* ==========================================================================
   Reduced motion — disable non-essential animation
   ========================================================================== */

@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;
  }

  .joke { transition: none; opacity: 1; }
}
