/* ================================================================
   OpenYardage — Main Stylesheet
   ================================================================ */

/* ── CSS Custom Properties ──────────────────────────────────────── */
:root {
  --color-primary:        #2d7a4a;
  --color-primary-dark:   #1f5934;
  --color-primary-light:  #4eca7f;
  --color-accent:         #34e884;

  --color-bg:             #f4f6f3;
  --color-surface:        #ffffff;
  --color-surface-alt:    #f8faf7;
  --color-border:         #dde3d9;
  --color-border-light:   #eef1ec;

  --color-text:           #1a2318;
  --color-text-muted:     #5a6e55;
  --color-text-faint:     #8fa085;

  --color-error:          #c0392b;
  --color-error-bg:       #fdf3f2;

  --header-height:        58px;
  --footer-height:        64px;
  --radius-sm:            6px;
  --radius-md:            10px;
  --radius-lg:            16px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.14), 0 4px 10px rgba(0,0,0,0.06);

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;

  --transition: 180ms ease;
}

/* ── Reset & Base ────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── App Header ──────────────────────────────────────────────────── */
.app-header {
  flex-shrink: 0;
  height: var(--header-height);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 20px;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  gap: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.20);
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 22px;
  line-height: 1;
}

.logo-text {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #fff;
}

.logo-beta {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
  color: rgba(255,255,255,0.6);
  vertical-align: sub;
  margin-left: 3px;
}

.header-about-link {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  flex-shrink: 0;
  margin-left: auto;
  text-decoration: none;
}
.header-about-link:hover {
  color: #fff;
  text-decoration: underline;
}

/* ── Step Navigator (header) ─────────────────────────────────────── */
.step-nav {
  display: flex;
  align-items: center;
  gap: 0;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  opacity: 0.45;
  cursor: default;
  transition: opacity var(--transition);
  white-space: nowrap;
}

.step-item.active {
  opacity: 1;
}

.step-item.completed {
  opacity: 0.75;
  cursor: pointer;
}

.step-item.completed:hover {
  opacity: 1;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.step-item.active .step-num {
  background: #fff;
  color: var(--color-primary);
  border-color: #fff;
}

.step-item.completed .step-num {
  background: var(--color-primary-light);
  border-color: var(--color-primary-light);
  color: #fff;
}

.step-label {
  font-size: 13px;
  font-weight: 500;
}

.step-divider {
  width: 28px;
  height: 1px;
  background: rgba(255,255,255,0.35);
  flex-shrink: 0;
}

/* ── App Main ────────────────────────────────────────────────────── */
.app-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Step Panels ─────────────────────────────────────────────────── */
.step-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.step-panel[hidden] {
  display: none;
}

/* ── Step Footer (shared) ────────────────────────────────────────── */
.step-footer {
  flex-shrink: 0;
  height: var(--footer-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  gap: 16px;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  transition: background var(--transition), opacity var(--transition), transform 80ms ease;
  text-decoration: none;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: #e8f5ee;
}

.regen-delete {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.btn-danger {
  background: var(--color-surface);
  color: #c0392b;
  border: 1.5px solid #c0392b;
}

.btn-danger:hover:not(:disabled) {
  background: #fdecea;
}

.btn-text {
  background: transparent;
  color: var(--color-text-muted);
  padding: 9px 12px;
}

.btn-text:hover:not(:disabled) {
  color: var(--color-text);
  background: var(--color-border-light);
}

.btn-arrow {
  font-size: 16px;
  line-height: 1;
}

/* ════════════════════════════════════════════════════════════════
   STEP 1 — MAP
   ════════════════════════════════════════════════════════════════ */
.step-1-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
}

#map {
  flex: 1;
  width: 100%;
  min-height: 0;
  z-index: 1;
}

/* ── Search Overlay ──────────────────────────────────────────────── */
#search-overlay {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(480px, calc(100% - 100px));
  z-index: 500;
}

.search-wrap {
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 0 12px;
  gap: 8px;
  border: 1.5px solid transparent;
  transition: border-color var(--transition);
}

.search-wrap:focus-within {
  border-color: var(--color-primary-light);
}

.search-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  font-family: inherit;
  color: var(--color-text);
  padding: 11px 0;
}

.search-input::placeholder {
  color: var(--color-text-faint);
}

.search-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-faint);
  font-size: 14px;
  padding: 4px;
  border-radius: 50%;
  transition: color var(--transition), background var(--transition);
  line-height: 1;
}

.search-clear:hover {
  color: var(--color-text);
  background: var(--color-border-light);
}

/* Search results dropdown */
.search-results {
  margin-top: 6px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  list-style: none;
  overflow: hidden;
  border: 1px solid var(--color-border);
  max-height: 280px;
  overflow-y: auto;
}

.search-results[hidden] {
  display: none;
}

.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--transition);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item:focus {
  background: #e8f5ee;
  outline: none;
}

.result-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-detail {
  font-size: 12px;
  color: var(--color-text-muted);
  display: block;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-use-bbox {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary);
  background: #e8f5ee;
  padding: 2px 7px;
  border-radius: 10px;
}

.search-loading {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ── Map Hint ─────────────────────────────────────────────────────── */
.map-hint {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  z-index: 500;
  pointer-events: none;
  backdrop-filter: blur(4px);
  max-width: calc(100% - 32px);
  text-align: center;
  line-height: 1.4;
  transition: opacity 0.5s ease;
}

.map-hint.hidden {
  opacity: 0;
}

.hint-icon {
  margin-right: 4px;
}

/* ── BBox Info (footer) ─────────────────────────────────────────── */
.bbox-info {
  font-size: 13px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 440px;
}

.bbox-info .bbox-coords {
  color: var(--color-text);
}

/* Leaflet draw toolbar — keep it clean */
.leaflet-draw-toolbar a {
  border-radius: 4px !important;
}

/* ════════════════════════════════════════════════════════════════
   STEP 2 — CUSTOMIZE
   ════════════════════════════════════════════════════════════════ */
.step-2-layout {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 0;
}

.step-heading {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.3px;
}

.customize-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 760px) {
  .customize-grid {
    grid-template-columns: 1fr;
  }

  .step-2-layout {
    padding: 20px 16px;
  }
}

.customize-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

/* ── Color Options ───────────────────────────────────────────────── */
.color-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.color-label {
  font-size: 14px;
  color: var(--color-text);
  cursor: pointer;
  flex: 1;
}

.color-swatch-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.color-input {
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 2px;
  background: transparent;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 3px;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

.color-hex {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-muted);
  width: 62px;
}

/* ── Preset selector ─────────────────────────────────────────────── */
.preset-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  border-top: 1px solid var(--color-border);
  margin-top: 4px;
}

.preset-label {
  font-size: 14px;
  color: var(--color-text);
  flex: 1;
}

.preset-select {
  font-size: 16px;
  padding: 5px 8px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

.preset-select:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* ── Options ─────────────────────────────────────────────────────── */
.option-section {
  margin-bottom: 20px;
}

.option-section:last-child {
  margin-bottom: 0;
}

.option-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-faint);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border-light);
}

/* Toggle switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.toggle-label {
  font-size: 14px;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 22px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.20);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* Radio group */
.radio-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.radio-label {
  font-size: 14px;
  color: var(--color-text);
}

.radio-group {
  display: flex;
  gap: 4px;
  background: var(--color-bg);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.radio-opt {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.radio-opt input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-opt span {
  font-size: 13px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 4px;
  transition: background var(--transition), color var(--transition);
  color: var(--color-text-muted);
}

.radio-opt input:checked + span {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* Range slider */
.slider-row {
  margin-bottom: 12px;
}

.slider-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: var(--color-text);
  margin-bottom: 8px;
  cursor: pointer;
}

.slider-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
}

.range-input {
  width: 100%;
  accent-color: var(--color-primary);
  height: 4px;
  cursor: pointer;
}

.slider-hint {
  font-size: 12px;
  color: var(--color-text-faint);
  margin-top: 5px;
  line-height: 1.4;
}

/* Select */
.select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.select-label {
  font-size: 14px;
  color: var(--color-text);
}

.select-input {
  font-family: inherit;
  font-size: 16px;
  padding: 5px 10px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

.select-input:focus {
  outline: none;
  border-color: var(--color-primary-light);
}

/* Sub-options (toggled by switch) */
.sub-options {
  padding: 12px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-light);
  margin-top: 8px;
  margin-bottom: 12px;
}

.sub-options[hidden] {
  display: none;
}

/* Feature badge */
.feature-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: #fff3cd;
  color: #856404;
  padding: 2px 6px;
  border-radius: 10px;
}

/* Course summary */
.course-summary {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.course-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.course-summary-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-text-faint);
  white-space: nowrap;
  cursor: pointer;
}

.course-name-input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  color: var(--color-text);
  padding: 6px 10px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.course-name-input:hover {
  border-color: var(--color-text-faint);
}

.course-name-input:focus {
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(78, 202, 127, 0.15);
}

.bbox-summary {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--color-text-muted);
}

/* ════════════════════════════════════════════════════════════════
   HOLE BROWSER (Step 3, post-generation)
   ════════════════════════════════════════════════════════════════ */
.hole-browser {
  flex: 1;
  min-height: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.hole-browser[hidden] {
  display: none;
}

/* Navigation bar */
.hole-browser-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-surface-alt);
  flex-shrink: 0;
}

.hole-browser-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.2px;
}

/* Body: left/right split */
.hole-browser-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.hole-browser-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px;
  overflow-y: auto;
  background: var(--color-bg);
  min-width: 0;
}

.hole-browser-right {
  flex: 0 0 auto;
  max-width: 500px;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--color-border-light);
  order: -1;
}

.hole-browser-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hole-nav-btn {
  padding: 6px 14px;
  font-size: 13px;
}

.hole-osm-name {
  font-size: 12px;
  color: var(--color-text-muted, #6b7280);
  font-style: italic;
  margin-top: 2px;
}

.hole-select {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 10px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  min-width: 160px;
  text-align: center;
}

.hole-select:focus {
  outline: none;
  border-color: var(--color-primary-light);
}

.hole-canvas-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

.hole-display-canvas {
  max-width: 100%;
  width: auto;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.hole-green-wrap {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hole-green-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-text-faint);
}

.green-display-canvas {
  max-width: 100%;
  max-height: 240px;
  width: auto;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

/* Regeneration panel (right sidebar) */
.regen-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.regen-panel-title {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-faint);
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Toggle button — hidden on desktop, shown on mobile */
.btn-regen-toggle {
  display: none;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-primary);
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.4;
}

.regen-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--color-surface-alt);
}

.regen-sliders {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.regen-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.regen-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: var(--color-text);
  cursor: pointer;
}

.regen-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.regen-status-text {
  font-size: 13px;
  color: var(--color-text-muted);
  font-style: italic;
}

/* ════════════════════════════════════════════════════════════════
   STEP 3 — GENERATE
   ════════════════════════════════════════════════════════════════ */
.step-3-layout {
  flex: 1;
  overflow: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Generation Status ────────────────────────────────────────────── */
.generation-status {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 600px;
  width: 100%;
  margin: auto;
  padding: 32px 16px;
}

.generation-status[hidden] {
  display: none;
}

.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--color-border);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  border-radius: 10px;
  transition: width 0.4s ease;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress-status {
  font-size: 14px;
  color: var(--color-text-muted);
}

.progress-pct {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--color-primary);
}


/* ── Step 3 top bar ──────────────────────────────────────────────── */
.step3-top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 12px;
}

/* ── Step 3 footer ───────────────────────────────────────────────── */
.step3-footer {
  justify-content: flex-end;
}

.step3-footer[hidden] {
  display: none;
}

.step3-download-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Error State ─────────────────────────────────────────────────── */
.error-state[hidden] {
  display: none;
}

.error-state {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
  padding: 32px 24px;
  background: var(--color-error-bg);
  border: 1px solid #f5c6cb;
  border-radius: var(--radius-lg);
}

.error-icon {
  font-size: 36px;
  margin-bottom: 12px;
  color: var(--color-error);
}

.error-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-error);
  margin-bottom: 8px;
}

.error-message {
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

/* ── Spinner animation (used in hole status) ─────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Leaflet overrides ───────────────────────────────────────────── */
.leaflet-container {
  font-family: var(--font-sans);
}

.leaflet-draw-section .leaflet-draw-toolbar {
  margin-top: 0;
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE BREAKPOINTS
   ════════════════════════════════════════════════════════════════ */

/* ≤800px — hide header about link to free space */
@media (max-width: 800px) {
  .header-about-link { display: none; }
}

/* ≤560px — collapse step nav to numbers only; tighten header */
@media (max-width: 560px) {
  .app-header {
    padding: 0 12px;
    gap: 10px;
  }

  .step-label { display: none; }

  .step-divider { width: 14px; }

  .step-item { padding: 5px 6px; }
}

/* ≤600px — step 3 narrower layout adjustments + hole browser mobile */
@media (max-width: 600px) {
  .step-3-layout {
    padding: 20px 16px;
    gap: 20px;
  }

  .pdf-preview-frame { min-height: 260px; }

  .step-footer {
    padding: 0 14px;
  }

  .footer-actions { gap: 8px; }

  .btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  /* Hole browser: stack vertically on mobile */
  .hole-browser-body {
    flex-direction: column;
    overflow-y: auto;
  }

  .hole-browser-left {
    overflow-y: visible;
  }

  .hole-browser-right {
    order: 1;        /* images first, regen panel below */
    max-width: 100%;
    border-left: none;
    border-top: 1px solid var(--color-border-light);
  }

  /* Show the toggle button on mobile */
  .btn-regen-toggle {
    display: inline-flex;
  }

  /* Regen body hidden by default on mobile; shown when panel has .regen-open */
  .hole-browser-right .regen-body {
    display: none;
  }

  .hole-browser-right.regen-open .regen-body {
    display: flex;
  }
}

/* ≤480px — step 1 & 2 footer: stack on very narrow screens */
@media (max-width: 480px) {
  .step-footer:not(.step3-footer) {
    flex-direction: column;
    height: auto;
    padding: 10px 14px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }

  .footer-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .bbox-info {
    max-width: 100%;
    font-size: 11px;
  }
}

/* ════════════════════════════════════════════════════════════════
   EXPORT MODAL
   ════════════════════════════════════════════════════════════════ */
.export-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.export-modal-overlay[hidden] {
  display: none;
}

.export-modal-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.export-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--color-border);
}

.export-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.2px;
}

.export-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--color-text-faint);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: color var(--transition), background var(--transition);
}

.export-modal-close:hover {
  color: var(--color-text);
  background: var(--color-border-light);
}

.export-modal-body {
  display: flex;
  flex-direction: column;
}

.about-modal-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
}

.about-modal-body p {
  margin: 0;
}

.about-modal-body a {
  color: var(--color-primary);
  text-decoration: underline;
}

.export-option {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--color-border-light);
}

.export-option:last-child {
  border-bottom: none;
}

.export-option-info {
  flex: 1;
  min-width: 0;
}

.export-option-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.export-option-desc {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.45;
}

.export-option .btn {
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .export-option {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .export-option .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ── Yardage Book Viewer ─────────────────────────────────────────── */

.viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: #1a2318;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* iOS safe areas for notch / home indicator */
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.viewer-overlay[hidden] {
  display: none;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  flex-shrink: 0;
  z-index: 1;
}

.viewer-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.viewer-close:hover {
  background: rgba(255,255,255,0.15);
}

.viewer-title {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-page-indicator {
  font-size: 13px;
  opacity: 0.8;
  white-space: nowrap;
}

.viewer-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  touch-action: pan-y;
}

/* Each page mimics the PDF booklet layout */
.viewer-page {
  display: none;
  width: 100%;
  height: 100%;
  max-width: 500px;
  max-height: 650px;
  background: #fff;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  flex-direction: row;
}

.viewer-page.active {
  display: flex;
}

/* Cover page */
.viewer-page-cover {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
}

.viewer-page-cover .viewer-cover-name {
  font-size: 22px;
  font-weight: 700;
  color: #1a2318;
  margin-bottom: 8px;
}

.viewer-page-cover .viewer-cover-sub {
  font-size: 14px;
  color: var(--color-text-muted);
}

.viewer-page-cover .viewer-cover-credit {
  position: absolute;
  bottom: 16px;
  font-size: 10px;
  color: var(--color-text-faint);
  text-align: center;
}

/* Left panel (40%) */
.viewer-left {
  width: 40%;
  display: flex;
  flex-direction: column;
  padding: 12px;
  position: relative;
  flex-shrink: 0;
}

.viewer-hole-num {
  font-size: 20px;
  font-weight: 700;
  color: #1a2318;
}

.viewer-par {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.viewer-notes-label {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 16px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 2px;
}

.viewer-green-wrap {
  margin-top: auto;
}

.viewer-green-wrap img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
}

/* Right panel (60%) — hole image */
.viewer-right {
  width: 60%;
  position: relative;
  overflow: hidden;
}

.viewer-right img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Nav arrows */
.viewer-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2001;
  background: rgba(0,0,0,0.45);
  color: #fff;
  border: none;
  font-size: 32px;
  line-height: 1;
  padding: 12px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.viewer-nav:hover {
  background: rgba(0,0,0,0.7);
}

.viewer-nav:disabled {
  opacity: 0.25;
  pointer-events: none;
}

.viewer-nav-prev { left: 8px; }
.viewer-nav-next { right: 8px; }

/* Mobile: make pages fill more of the screen */
@media (max-width: 600px) {
  .viewer-page {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .viewer-nav {
    padding: 16px 8px;
    font-size: 28px;
    background: rgba(0,0,0,0.3);
  }

  .viewer-left {
    padding: 10px 8px;
  }
}

/* ── Scrollbar styling ───────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-faint);
}
