body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #f9f9fb;
  color: #111;
  margin: 0;
  padding: 0;
}

.app-container {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 20px;
}

.app-header {
  text-align: center;
  margin-bottom: 32px;
}

h1 {
  font-weight: 600;
  margin-bottom: 6px;
}

.subheader {
  color: #555;
  font-size: 0.95rem;
}


.input-section,
.results {
  background: #fcfcfd; /* slightly off-white for contrast */
  border: 1px solid #e3e3e8;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}


.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(300px, 1fr)); /* balanced width */
  column-gap: 24px;   /* slightly wider gap between columns */
  row-gap: 16px;      /* reduced vertical spacing */
  align-items: end;   /* aligns sliders/buttons nicely */
  margin-bottom: 8px; /* slightly tighter overall */
}


.input-group label {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 6px;
  color: #222; /* darker gray for visual anchor */
  letter-spacing: 0.02em;
}

.input-group label {
  font-size: 0.95rem;   /* unified size */
  color: #222;
  margin-bottom: 4px;
  font-weight: 600;
}


.input-group {
  margin-bottom: 4px; /* more space between groups */
}



.input-group--dual .control-dual {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 10px;
  align-items: center;
}

.control-dual input[type="number"],
.control-dual input[type="text"] {
  height: 20px;              /* exactly matches slider height */
  padding: 0 6px !important; /* tighter padding so text centers vertically */
  font-size: 0.8rem;         /* smaller font so it doesn’t force the box taller */
  border-radius: 6px;        /* match slider thumb radius visually */
  line-height: 1;            /* perfect vertical alignment */
  box-sizing: border-box;
}


.toggle-group {
  display: inline-flex;
  border-radius: 10px;
  overflow: hidden;
  width: 100%;
  max-width: 380px;
}

#genderToggle, #distanceToggle {
  gap: 4px; /* reduce space between buttons */
}


.toggle,
.toggle-distance {
  flex: 1;
  background: #f2f2f3;
  color: #111;
  border: none;
  padding: 0;
  font-size: 0.8rem;          /* slightly smaller text */
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.05s ease;
  height: 30px;               /* slightly shorter buttons */
  line-height: 1;             /* tighter vertical centering */
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;         /* smoother corner to match input boxes */
}



/* subtle divider only between buttons */
.toggle + .toggle,
.toggle-distance + .toggle-distance {
  border-left: 1px solid #e0e0e0;
}



.toggle.active,
.toggle-distance.active {
  background: linear-gradient(180deg, #111 0%, #222 100%);
  color: #fff;
}


/* disabled state */
.toggle.disabled,
.toggle-distance.disabled {
  background: #f1f1f4;
  color: #999;
  pointer-events: none;
  cursor: not-allowed;
  opacity: 0.5;
}


/* Disabled toggle state when data for that distance isn't present */
.toggle.disabled {
  background: #f1f1f4;
  color: #999;
  pointer-events: none;
  cursor: not-allowed;
  opacity: 0.5;
}

.radio-group {
  display: flex;
  gap: 14px;
  font-size: 0.9rem;
}
.calculate-btn {
  background: #111;
  color: #fff;
  border: 1px solid #111;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: none;
}
.calculate-btn:active {
  transform: scale(0.97);
  background: #000;
  transition: transform 0.05s ease;
}

.calculate-btn:hover { background: #222; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

/* Summary text max-width for comfortable line length */
#summaryText { max-width: 58ch; }

/* Centered summary block for results */
.completion-summary { text-align: center; max-width: 60ch; margin: 0 auto 16px; }

/* Center and balance button area */
.calculate-btn {
  display: block;
  margin: 20px auto 0;  /* centers on desktop, keeps spacing */
  width: 220px;         /* readable size, not full width */
  font-size: 0.9rem;
}


.placement-percentage {
  display: block;
  font-size: 0.9rem;
  color: #555;
  margin-top: 4px;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  max-width: 720px;
  height: 280px;       /* fixed height prevents stretching */
  margin: 24px auto;
}

.chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.chart-wrapper { margin-left: auto; margin-right: auto; }

/* Chart controls + highlight zone UI */
.chart-controls { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.chart-controls-right { display:flex; gap:10px; align-items:center; }
.hz-toggle { background:#111; color:#fff; border:none; padding:6px 8px; border-radius:8px; cursor:pointer; font-size:0.85rem; }
.hz-toggle.off { background:#fff; color:#111; border:1px solid #ddd; }
.explore-hint { font-size:0.86rem; color:#666; }
.explore { display:flex; align-items:center; gap:8px; margin-top:8px; }
.explore input[type=range] { width:100%; }
.exit-explore { background:none; border:1px solid #ddd; padding:4px 8px; border-radius:6px; cursor:pointer; }

/* --- Full-width invisible drag overlay --- */
#highlightOverlay {
  position: absolute;
  inset: 0;               /* top/left/right/bottom: 0 */
  width: 100%;
  height: 100%;
  cursor: ew-resize;
  z-index: 20;            /* above canvas, below drag hint (25) */
  background: transparent;
  touch-action: none;     /* ensure touch events are delivered for dragging */
}

/* Ripple created at drag start (auto-removed by JS) */
.drag-ripple {
  position: absolute;
  width: 8px;
  height: 8px;
  left: 0; top: 0;
  border-radius: 999px;
  background: rgba(17,17,17,0.18);
  transform: translate(-50%, -50%) scale(1);
  animation: ripplePop 500ms ease-out forwards;
  pointer-events: none;
  z-index: 18;
}

@keyframes ripplePop {
  0%   { opacity: 0.0; transform: translate(-50%, -50%) scale(0.8); }
  20%  { opacity: 1.0; }
  100% { opacity: 0.0; transform: translate(-50%, -50%) scale(6); }
}


.drag-instruction {
  text-align: center;
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.6rem;
}

/* Visually hidden helper for accessibility announcements */
.visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
  border: 0; padding: 0; margin: -1px;
}

/* --- Dynamic 'Drag ⇆' Pulse Hint --- */
#dragHint {
  position: absolute;
  left: 50%;
  top: 38%; /* visually centered over the chart */
  transform: translateX(-50%);
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(40, 40, 40, 0.85);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  padding: 4px 10px;
  z-index: 25; /* sit above overlay */
  pointer-events: auto; /* allow clicks and drags */
  cursor: grab;
  opacity: 0;
  animation: dragPulse 2.8s ease-in-out infinite;
}

@keyframes dragPulse {
  0%, 100% { opacity: 0.2; transform: translate(-50%, -2px) scale(1); }
  50% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
}

/* Fading out after user interaction */
.dragHint-hide {
  animation: fadeOutHint 0.6s ease forwards;
}

@keyframes fadeOutHint {
  from { opacity: 1; transform: translate(-50%, 0) scale(1); }
  to { opacity: 0; transform: translate(-50%, 0) scale(0.95); }
}

/* (old dragFade removed) */

/* Floating label shown while dragging highlight band */
#dragLabel {
  position: absolute;
  pointer-events: none;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(6, 120, 160, 0.9);
  color: #fff;
  white-space: nowrap;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.15s ease-in-out, top 0.15s ease-in-out;
}

/* When visible (JS sets inline style to show), fade in smoothly */
#dragLabel.visible { opacity: 1; }

.chart-stats { margin-top:8px; font-size:12px; color:#666; display:flex; gap:14px; align-items:center; }

/* add extra space between chart and the following section header */
.chart-wrapper + .section-header { 
  margin-top: 32px;  /* was 18px */
}
/* subtle fade-in */
.chart-wrapper { animation: fadeIn 0.8s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity:1; transform: translateY(0); } }

/* Modal styles per BRD */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
  transition: opacity 0.2s ease;
  opacity: 0;
  pointer-events: none;
}
.modal-backdrop.active {
  opacity: 1;
  pointer-events: all;
}
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal.hidden { display: none; }
.modal-content {
  background: #fff;
  border-radius: 14px;
  padding: 28px 32px;
  width: 90%;
  max-width: 740px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  position: relative;
}
.modal-close {
  border: none;
  background: none;
  font-size: 1.6rem;
  position: absolute;
  top: 16px;
  right: 20px;
  cursor: pointer;
  color: #555;
}

/* Cleaner, monochrome slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px; /* slightly thicker track */
  background: #d9d9df;
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: #d9d9df;
  border-radius: 999px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: #111;
  border-radius: 50%;
  border: 1px solid #111;
  margin-top: -6px;
}
input[type="range"]:focus { outline: none; }

/* Firefox */
input[type="range"]::-moz-range-track {
  height: 4px;
  background: #d9d9df;
  border-radius: 999px;
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #111;
  border-radius: 50%;
  border: 1px solid #111;
}

.results p {
  margin-top: 0;
  color: #333;
  font-size: 1rem;
  line-height: 1.5;
}

.results section {
  background: #fafafa;
  border-radius: 10px;
  padding: 16px 20px 22px;
  margin-bottom: 14px;
}

.section-header {
  margin: 0 0 12px;
}

.section-header h2 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #2a2a2a;
  display: inline;
  margin-right: 10px;
}

.section-header p {
  display: inline;
  font-size: 0.85rem;
  color: #777;
}

.divider {
  background-color: #e5e7eb;
  height: 1px;
  margin: 6px 0 12px;
}

.cards-row { margin-top: 16px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; }

/* Add vertical spacing between rows of cards and the following section headers */
.cards-row,
.stats-row,
.snapshot-row {
  margin-bottom: 1.5rem; /* ~24px */
}

/* Ensure section headers have a little top spacing when following card rows */
.section-header {
  margin-top: 1.75rem; /* ~28px */
}

.stat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
  color: #444;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.stat-list li { white-space: nowrap; }

.result-card {
  border: 1px solid #e5e6eb;
  border-radius: 10px;
  background: #fff;
  padding: 18px 20px;
  flex: 1;
  min-width: 180px;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.result-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.result-number {
  font-size: 1.6rem;
  font-weight: 600;
  color: #111;
  margin-bottom: 4px;
}

/* Unified typography for all stat/result cards to match placement card */
.result-card,
.result-card h3,
.result-card p,
.result-card .result-sub {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #111;
  line-height: 1.3;
}

/* Ensure headings and subtext use a medium weight by default; numeric styling (.result-number) stays as-is */
.result-card h3,
.result-card .result-sub {
  font-weight: 500;
  text-align: center;
}

.result-sub {
  font-size: 0.85rem;
  color: #666;
  line-height: 1.3;
}

.hidden {
  display: none;
}

/* --- MOBILE OPTIMIZATION (zero regressions) --- */
@media (max-width: 768px) {
  .app-container {
    margin: 20px auto;
    padding: 0 14px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .input-section {
    padding: 18px;
  }

  .calculate-btn {
    width: 100%;
    margin-top: 10px;
  }

  .chart-wrapper {
    max-width: 100%;
    height: 300px; /* improves touch precision */
  }

  .cards-row {
    flex-direction: column;
    align-items: stretch;
  }

  .result-card {
    min-width: unset;
    width: 100%;
  }

  .drag-instruction {
    font-size: 0.9rem;
    margin-top: 8px;
  }
}

/* --- INPUT ALIGNMENT + SLIDER POLISH (clean + consistent) --- */
.control-dual {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Text/number inputs next to sliders */
.control-dual input[type="number"],
.control-dual input[type="text"] {
  height: 28px;
  border: none;               /* ✅ fixed syntax */
  background: none;        /* ✅ matches toggle buttons */
  border-radius: 8px;
  padding: 0 8px;
  font-size: 0.9rem;
  box-sizing: border-box;
  outline: none;              /* ✅ removes blue highlight */
}


/* Simplified slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #d9d9df;       /* same as input border */
  border-radius: 999px;
  cursor: pointer;
  margin-top: 8px;
}

/* Slider thumb */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: #111;
  border-radius: 50%;
  border: 1px solid #111;
  margin-top: -5px;
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #111;
  border-radius: 50%;
  border: 1px solid #111;
}



/* --- MOBILE CARD WRAP FIX --- */
@media (max-width: 768px) {
  .cards-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px; /* slightly tighter on mobile */
    overflow-x: hidden; /* prevent horizontal scroll */
  }

  .result-card {
    flex: none;
    width: 100%;
    min-width: 0; /* override desktop min width */
    box-sizing: border-box;
  }

  .results section {
    padding: 14px 16px;
  }
}

/* --- REAL iPHONE SAFE-AREA + OVERFLOW FIX --- */

/* Ensure full-width elements never exceed viewport on real devices */
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* Prevent result cards from extending beyond safe area */
.result-card {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Handle Safari's dynamic safe-area insets (notch + bottom bar) */
@supports (padding: env(safe-area-inset-left)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* Optional tighter mobile layout for cards */
@media (max-width: 768px) {
  .cards-row {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* --- MODERNIZED SELECT DROPDOWN (primary input style) --- */
select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background-color: #f2f2f3;      /* slightly darker gray to draw attention */
  border: none;                   /* removes native border */
  border-radius: 8px;
  padding: 10px 36px 10px 12px;   /* leaves room for dropdown arrow */
  font-size: 0.95rem;
  color: #111;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg fill='none' stroke='%23111' stroke-width='2' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E<path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

select:hover,
select:focus {
  background-color: #e8e8ea;     /* subtle hover/focus cue */
  outline: none;
  box-shadow: 0 0 0 2px #111;    /* dark ring draws user’s eye */
}


.header-banner-img {
  display: block;
  margin: 16px auto 20px;
  width: 100%;
  max-width: 900px;
  height: 200px;               /* ↓ sets smaller height */
  object-fit: cover;           /* crops nicely without distortion */
  border-radius: 10px;
  opacity: 0.95;
  transition: opacity 0.3s ease-in-out;
}

.header-banner-img:hover {
  opacity: 1;
}


@media (max-width: 600px) {
  .header-banner-img {
    height: 80px;              /* ↓ even smaller for mobile */
    margin: 12px auto 16px;
  }
}

