/* =====================================================
   BAGGAP v2 — Custom Bag Builder
   Fairway Green palette · Cabinet Grotesk + Satoshi
   ===================================================== */

:root, [data-theme='light'] {
  --text-xs:   clamp(0.72rem,  0.68rem + 0.2vw,  0.82rem);
  --text-sm:   clamp(0.85rem,  0.80rem + 0.3vw,  0.95rem);
  --text-base: clamp(0.95rem,  0.90rem + 0.25vw, 1.05rem);
  --text-lg:   clamp(1.1rem,   1.0rem  + 0.5vw,  1.35rem);
  --text-xl:   clamp(1.4rem,   1.1rem  + 1.0vw,  1.9rem);

  --sp1: 0.25rem; --sp2: 0.5rem;  --sp3: 0.75rem; --sp4: 1rem;
  --sp5: 1.25rem; --sp6: 1.5rem;  --sp8: 2rem;    --sp10: 2.5rem;
  --sp12: 3rem;   --sp16: 4rem;

  /* Light — fresh fairway */
  --bg:         #eef2ec;
  --surface:    #f5f8f3;
  --surface2:   #f9fbf8;
  --offset:     #e4ebe1;
  --offset2:    #d8e2d4;
  --divider:    #c8d6c2;
  --border:     #b8cab1;

  --text:       #162014;
  --muted:      #52694d;
  --faint:      #93ab8d;
  --inverse:    #eef2ec;

  --primary:         #257832;
  --primary-h:       #1a5f25;
  --primary-hl:      #bddfc3;
  --primary-subtle:  #e2f0e4;

  --wide:    #c0392b;
  --wide-hl: #fde8e6;
  --tight:   #b87200;
  --tight-hl:#fdefd0;
  --overlap: #c66000;
  --overlap-hl:#fdebd0;
  --good:    #237832;
  --good-hl: #d0edda;

  --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px;
  --radius-xl: 16px; --radius-full: 9999px;
  --ease: 160ms cubic-bezier(0.16,1,0.3,1);

  --shadow-sm: 0 1px 3px rgba(15,35,12,0.08);
  --shadow-md: 0 4px 14px rgba(15,35,12,0.10);
  --shadow-lg: 0 12px 32px rgba(15,35,12,0.14);

  --font-d: 'Cabinet Grotesk', 'Helvetica Neue', sans-serif;
  --font-b: 'Satoshi', 'Helvetica Neue', sans-serif;

  --panel-w: 320px;
  --content: 1120px;
}

[data-theme='dark'] {
  --bg:        #0a1209;
  --surface:   #0f1a0e;
  --surface2:  #141f13;
  --offset:    #172316;
  --offset2:   #1c2a1b;
  --divider:   #223321;
  --border:    #2c4229;

  --text:      #c4d6bf;
  --muted:     #7a9473;
  --faint:     #456840;
  --inverse:   #0a1209;

  --primary:        #52c068;
  --primary-h:      #3aa852;
  --primary-hl:     #1a3520;
  --primary-subtle: #152819;

  --wide:    #e05c4e; --wide-hl:    #33100e;
  --tight:   #e8b84a; --tight-hl:   #2e2108;
  --overlap: #f0903a; --overlap-hl: #2e1a06;
  --good:    #52c068; --good-hl:    #1a3520;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg:#0a1209; --surface:#0f1a0e; --surface2:#141f13; --offset:#172316; --offset2:#1c2a1b;
    --divider:#223321; --border:#2c4229; --text:#c4d6bf; --muted:#7a9473; --faint:#456840;
    --inverse:#0a1209; --primary:#52c068; --primary-h:#3aa852; --primary-hl:#1a3520;
    --primary-subtle:#152819; --wide:#e05c4e; --wide-hl:#33100e; --tight:#e8b84a;
    --tight-hl:#2e2108; --overlap:#f0903a; --overlap-hl:#2e1a06; --good:#52c068; --good-hl:#1a3520;
    --shadow-sm:0 1px 3px rgba(0,0,0,.3); --shadow-md:0 4px 14px rgba(0,0,0,.4); --shadow-lg:0 12px 32px rgba(0,0,0,.5);
  }
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body {
  font-family: var(--font-b);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  line-height: 1.55;
  transition: background .25s, color .25s;
  /* iOS momentum scrolling */
  -webkit-overflow-scrolling: touch;
  /* Prevent callout on long press */
  -webkit-touch-callout: none;
}

/* ── iOS Safe Area ── */
.site-header {
  padding-top: env(safe-area-inset-top, 0px);
}
.site-footer {
  padding-bottom: calc(var(--sp5) + env(safe-area-inset-bottom, 0px));
}
.app-layout {
  padding-left: max(var(--sp5), env(safe-area-inset-left, 0px));
  padding-right: max(var(--sp5), env(safe-area-inset-right, 0px));
}
/* Modal safe area */
.modal {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
button { cursor: pointer; font: inherit; color: inherit; background: none; border: none; }
input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
h1,h2,h3,h4 { font-family: var(--font-d); line-height: 1.15; text-wrap: balance; }
svg { display: block; flex-shrink: 0; }
a,button,input,select { transition: color var(--ease), background var(--ease), border-color var(--ease), box-shadow var(--ease), opacity var(--ease); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: var(--radius-sm); }

/* ── Header ── */
.site-header {
  position: sticky; top: 0; z-index: 200;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.header-inner {
  max-width: var(--content); margin: 0 auto;
  padding: var(--sp3) var(--sp5);
  display: flex; align-items: center; justify-content: space-between;
}
.logo-mark { display: flex; align-items: center; gap: var(--sp3); }
.logo-text {
  font-family: var(--font-d); font-weight: 800;
  font-size: var(--text-lg); letter-spacing: -0.025em;
}
.logo-text em { font-style: normal; color: var(--primary); }
.header-actions { display: flex; align-items: center; gap: var(--sp3); }

.unit-switch {
  display: flex;
  background: var(--offset);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}
.unit-btn {
  padding: 4px 14px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.04em;
  color: var(--muted);
}
.unit-btn.active {
  background: var(--primary); color: white;
  box-shadow: var(--shadow-sm);
}
.unit-btn:not(.active):hover { background: var(--offset2); color: var(--text); }

.icon-btn {
  /* 44pt minimum Apple touch target */
  width: 44px; height: 44px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.icon-btn:hover { background: var(--offset); color: var(--text); }

/* ── App Layout: two-column ── */
.app-layout {
  max-width: var(--content); margin: 0 auto;
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  gap: var(--sp6);
  padding: var(--sp6) var(--sp5) var(--sp16);
  align-items: start;
}

/* ── Bag Panel (left) ── */
.bag-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: sticky;
  top: calc(56px + var(--sp4));
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp4) var(--sp5);
  border-bottom: 1px solid var(--divider);
}
.panel-title { font-size: var(--text-lg); font-weight: 800; letter-spacing: -0.02em; }
.panel-sub { font-size: var(--text-xs); color: var(--muted); margin-top: 1px; }

/* Bag list */
.bag-list {
  min-height: 120px;
  max-height: 420px;
  overflow-y: auto;
}
.bag-list::-webkit-scrollbar { width: 4px; }
.bag-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.bag-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: var(--sp3);
  padding: var(--sp10) var(--sp4);
  color: var(--faint); font-size: var(--text-sm); text-align: center;
}

/* Bag club row */
.bag-row {
  display: grid;
  grid-template-columns: 1fr 100px 28px;
  align-items: center;
  gap: var(--sp2);
  padding: var(--sp3) var(--sp4);
  border-bottom: 1px solid var(--divider);
  transition: background var(--ease);
}
.bag-row:last-child { border-bottom: none; }
.bag-row:hover { background: var(--offset); }

.bag-row-name {
  font-family: var(--font-d);
  font-weight: 700; font-size: var(--text-sm);
  display: flex; align-items: center; gap: var(--sp2);
}

.type-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.dot-wood    { background: var(--tight); }
.dot-hybrid  { background: var(--primary); }
.dot-iron    { background: var(--muted); }
.dot-wedge   { background: var(--overlap); }

.dist-input-wrap {
  display: flex; align-items: center; gap: 3px;
  background: var(--offset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 5px 8px;
}
.dist-input-wrap:focus-within {
  border-color: var(--primary);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--primary-hl);
}
.dist-input {
  width: 52px; background: none; border: none; outline: none;
  font-size: var(--text-sm); font-weight: 700;
  text-align: right; color: var(--text);
  -moz-appearance: textfield;
}
.dist-input::-webkit-outer-spin-button,
.dist-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.dist-unit { font-size: 10px; color: var(--muted); font-weight: 600; }

.remove-btn {
  /* 44pt minimum Apple touch target */
  width: 44px; height: 44px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--faint); flex-shrink: 0;
}
.remove-btn:hover { background: var(--wide-hl); color: var(--wide); }

/* Presets */
.presets-section {
  padding: var(--sp4) var(--sp4) var(--sp5);
  border-top: 1px solid var(--divider);
  display: flex; flex-direction: column; gap: var(--sp3);
}
.presets-label {
  font-size: var(--text-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted);
}
.presets-row { display: flex; gap: var(--sp2); flex-wrap: wrap; }
.preset-btn {
  padding: 5px 12px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--offset); color: var(--muted);
}
.preset-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-subtle); }
.full-width { width: 100%; justify-content: center; }

/* ── Analysis Panel (right) ── */
.analysis-panel {
  display: flex; flex-direction: column; gap: var(--sp5);
}

.analysis-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp4) var(--sp5);
  border-bottom: 1px solid var(--divider);
}
.card-title {
  font-size: var(--text-base); font-weight: 700; letter-spacing: -0.01em;
}

/* Overall badge */
.overall-badge {
  padding: 3px 12px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--offset2); color: var(--muted);
}
.overall-badge.good { background: var(--good-hl); color: var(--good); }
.overall-badge.warn { background: var(--tight-hl); color: var(--tight); }
.overall-badge.bad  { background: var(--wide-hl);  color: var(--wide); }

/* Chart */
.chart-area {
  padding: var(--sp4) var(--sp5) var(--sp5);
  overflow-x: auto;
}
.chart-placeholder {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: var(--sp3);
  min-height: 160px;
  color: var(--faint); font-size: var(--text-sm); text-align: center;
}
.chart-inner {
  display: flex; align-items: flex-end; gap: 6px;
  height: 180px; min-width: 400px;
  position: relative; padding-top: 28px;
}
.chart-group {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 5px;
  min-width: 36px; position: relative;
}
.chart-bar-wrap {
  width: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  height: 152px; position: relative;
}
.chart-bar {
  width: 72%; border-radius: 4px 4px 0 0;
  position: relative; cursor: pointer;
  transition: height .45s cubic-bezier(0.16,1,0.3,1), opacity .2s;
}
.chart-bar.c-good    { background: var(--primary); opacity: .82; }
.chart-bar.c-wide    { background: var(--wide); opacity: .88; }
.chart-bar.c-tight   { background: var(--tight); opacity: .88; }
.chart-bar.c-overlap { background: var(--overlap); opacity: .88; }
.chart-bar:hover { opacity: 1 !important; }

.bar-tooltip {
  position: absolute; top: -28px; left: 50%;
  transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 2px 7px;
  font-size: 11px; font-weight: 700; color: var(--text);
  white-space: nowrap; pointer-events: none; opacity: 0;
  transition: opacity .15s; z-index: 5;
}
.chart-group:hover .bar-tooltip { opacity: 1; }

.gap-flag {
  position: absolute; top: -16px; right: -3px;
  font-size: 10px; font-weight: 800; color: var(--faint);
  white-space: nowrap;
}
.gap-flag.f-wide    { color: var(--wide); }
.gap-flag.f-tight   { color: var(--tight); }
.gap-flag.f-overlap { color: var(--overlap); }

.bar-label {
  font-family: var(--font-d); font-size: var(--text-xs);
  font-weight: 700; color: var(--muted);
  text-align: center; white-space: nowrap;
}

.chart-legend {
  display: flex; gap: var(--sp5); flex-wrap: wrap;
  padding: var(--sp3) var(--sp5);
  border-top: 1px solid var(--divider);
}
.leg-item { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--muted); }
.leg-dot { width: 9px; height: 9px; border-radius: 2px; }
.leg-dot.good    { background: var(--primary); }
.leg-dot.wide    { background: var(--wide); }
.leg-dot.tight   { background: var(--tight); }
.leg-dot.overlap { background: var(--overlap); }

/* Stats grid */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp3);
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp4);
  display: flex; flex-direction: column; gap: var(--sp1);
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat-num {
  font-family: var(--font-d); font-size: var(--text-xl);
  font-weight: 800; letter-spacing: -0.03em; line-height: 1;
  margin-top: 2px; color: var(--text);
}
.wide-color { color: var(--wide); }
.good-color { color: var(--good); }

/* Table */
.table-wrap { overflow-x: auto; }
.gap-table th {
  background: var(--offset);
  padding: var(--sp3) var(--sp4);
  text-align: left; font-size: var(--text-xs);
  font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.gap-table td {
  padding: var(--sp3) var(--sp4);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--divider);
  color: var(--text);
}
.gap-table tr:last-child td { border-bottom: none; }
.gap-table tr:hover td { background: var(--offset); }
.gap-table .t-name { font-family: var(--font-d); font-weight: 700; display: flex; align-items: center; gap: 7px; }
.gap-table .t-dist { font-weight: 600; font-variant-numeric: tabular-nums; }
.gap-table .t-gap  { font-weight: 600; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 800;
}
.pill-good    { background: var(--good-hl);    color: var(--good); }
.pill-wide    { background: var(--wide-hl);    color: var(--wide); }
.pill-tight   { background: var(--tight-hl);   color: var(--tight); }
.pill-overlap { background: var(--overlap-hl); color: var(--overlap); }
.pill-last    { background: var(--offset2);    color: var(--faint); }

/* Recommendations */
.reco-empty { padding: var(--sp5); color: var(--faint); font-size: var(--text-sm); text-align: center; }
.reco-list { display: flex; flex-direction: column; gap: 0; }
.reco-item {
  display: flex; gap: var(--sp3); align-items: flex-start;
  padding: var(--sp4) var(--sp5);
  border-bottom: 1px solid var(--divider);
  font-size: var(--text-sm);
}
.reco-item:last-child { border-bottom: none; }
.reco-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.reco-text { color: var(--text); line-height: 1.55; }
.reco-text strong { font-weight: 700; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: var(--sp2);
  border-radius: var(--radius-md); font-weight: 700;
  cursor: pointer; border: none; white-space: nowrap;
}
.btn-primary {
  background: var(--primary); color: white;
  padding: var(--sp2) var(--sp4);
  /* 44pt min height for iOS */
  min-height: 44px;
}
.btn-primary:hover { background: var(--primary-h); }
.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1.5px solid var(--border);
  padding: var(--sp2) var(--sp4);
  min-height: 44px;
}
.btn-ghost:hover { background: var(--offset); color: var(--text); }
.btn-sm { font-size: var(--text-sm); padding: 6px 12px; min-height: 44px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%; max-width: 560px;
  max-height: 82dvh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform .25s cubic-bezier(0.16,1,0.3,1);
  box-shadow: var(--shadow-lg);
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp4) var(--sp5);
  border-bottom: 1px solid var(--divider);
  position: sticky; top: 0;
  background: var(--surface); z-index: 1;
}
.modal-title { font-size: var(--text-lg); font-weight: 800; letter-spacing: -0.02em; }

/* Category tabs */
.cat-tabs {
  display: flex; gap: 2px;
  padding: var(--sp3) var(--sp4);
  border-bottom: 1px solid var(--divider);
  overflow-x: auto;
  background: var(--offset);
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  padding: 6px 16px; border-radius: var(--radius-full);
  font-size: var(--text-sm); font-weight: 700; white-space: nowrap;
  color: var(--muted);
}
.cat-tab.active { background: var(--primary); color: white; }
.cat-tab:not(.active):hover { background: var(--offset2); color: var(--text); }

/* Club picker grid */
.club-picker {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--sp3); padding: var(--sp4) var(--sp5);
}
.pick-btn {
  display: flex; flex-direction: column; align-items: center;
  gap: 5px; padding: var(--sp4) var(--sp3);
  background: var(--offset); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm); font-weight: 700;
  color: var(--text); text-align: center;
  transition: all var(--ease);
}
.pick-btn:hover { border-color: var(--primary); background: var(--primary-subtle); color: var(--primary); }
.pick-btn.already-in { opacity: .38; pointer-events: none; }
.pick-btn .pick-badge {
  font-size: var(--text-xs); font-weight: 600;
  padding: 2px 8px; border-radius: var(--radius-full);
}
.pick-btn.already-in::after { content: '✓ Added'; font-size: 10px; font-weight: 700; color: var(--primary); }

/* Custom form */
.custom-club-form {
  padding: var(--sp4) var(--sp5) var(--sp6);
  display: flex; flex-direction: column; gap: var(--sp4);
}
.form-row { display: flex; flex-direction: column; gap: var(--sp2); }
.form-label { font-size: var(--text-sm); font-weight: 700; color: var(--muted); }
.form-input {
  padding: var(--sp3) var(--sp4);
  background: var(--offset); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); font-size: var(--text-base);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-hl); }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--sp5); text-align: center;
  font-size: var(--text-xs); color: var(--faint);
}

/* ── Responsive ── */
@media (max-width: 820px) {
  .app-layout {
    grid-template-columns: 1fr;
    padding: var(--sp4) var(--sp3) var(--sp12);
  }
  .bag-panel { position: static; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .modal { border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-width: 100%; }
  .club-picker { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .club-picker { grid-template-columns: repeat(2, 1fr); }
  .header-inner { padding: var(--sp3) var(--sp4); }
}

/* Drag handle hint */
.bag-row { user-select: none; }

/* =====================================================
   COURSE CONDITIONS TAB
   ===================================================== */

/* ── App Tabs (top nav) ── */
.app-tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 54px;
  z-index: 150;
}
.tabs-inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 var(--sp5);
  display: flex;
  gap: 2px;
}
.app-tab {
  display: flex; align-items: center; gap: var(--sp2);
  padding: var(--sp3) var(--sp5);
  font-size: var(--text-sm); font-weight: 700;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  min-height: 44px;
  transition: color var(--ease), border-color var(--ease);
}
.app-tab:hover { color: var(--text); }
.app-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Course Panel Layout ── */
.course-panel {
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--sp6) var(--sp5) var(--sp16);
}
.course-layout {
  display: flex;
  flex-direction: column;
  gap: var(--sp5);
  max-width: 800px;
}

/* ── Search card ── */
.course-search-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp5) var(--sp6);
  box-shadow: var(--shadow-sm);
}

.search-row {
  display: flex;
  gap: var(--sp3);
  align-items: center;
}

.search-input-wrap {
  flex: 1;
  display: flex; align-items: center; gap: var(--sp2);
  background: var(--offset);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--sp3);
  min-height: 44px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.search-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-hl);
  background: var(--bg);
}
.search-icon { color: var(--muted); flex-shrink: 0; }
.search-input {
  flex: 1; background: none; border: none; outline: none;
  font-size: var(--text-base); color: var(--text);
  min-width: 0;
}
.search-input::placeholder { color: var(--faint); }
.search-clear {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.search-clear:hover { background: var(--offset2); color: var(--text); }

/* Search results */
.search-results {
  margin-top: var(--sp2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.search-result-item {
  padding: var(--sp3) var(--sp4);
  cursor: pointer;
  border-bottom: 1px solid var(--divider);
  transition: background var(--ease);
  min-height: 44px;
  display: flex; flex-direction: column; justify-content: center;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--offset); }
.result-name { font-weight: 700; font-size: var(--text-sm); color: var(--text); }
.result-location { font-size: var(--text-xs); color: var(--muted); margin-top: 1px; }
.search-no-results {
  padding: var(--sp4); text-align: center;
  font-size: var(--text-sm); color: var(--faint);
}

/* Selected course */
.selected-course {
  margin-top: var(--sp4);
  background: var(--primary-subtle);
  border: 1px solid var(--primary-hl);
  border-radius: var(--radius-md);
  padding: var(--sp3) var(--sp4);
}
.selected-course-inner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp3);
  flex-wrap: wrap;
}
.selected-name { font-weight: 800; font-size: var(--text-base); color: var(--text); display: block; }
.selected-location { font-size: var(--text-xs); color: var(--muted); margin-top: 2px; display: block; }
.meta-chip {
  background: var(--primary-hl); color: var(--primary);
  padding: 3px 12px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 700; white-space: nowrap;
}

/* Loading spinner */
.weather-loading {
  display: flex; align-items: center; justify-content: center;
  gap: var(--sp3); padding: var(--sp12);
  color: var(--muted); font-size: var(--text-sm);
}
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Day tabs ── */
.day-tabs {
  display: flex; gap: var(--sp2); flex-wrap: wrap;
}
.day-tab {
  flex: 1; min-width: 120px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp3) var(--sp4);
  text-align: center; cursor: pointer;
  transition: all var(--ease);
}
.day-tab:hover { border-color: var(--primary); }
.day-tab.active {
  border-color: var(--primary);
  background: var(--primary-subtle);
  box-shadow: 0 0 0 3px var(--primary-hl);
}
.day-tab-date { font-size: var(--text-xs); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.day-tab-label { font-size: var(--text-base); font-weight: 800; color: var(--text); font-family: var(--font-d); margin: 2px 0; }
.day-tab-summary { font-size: var(--text-xs); color: var(--muted); }
.day-tab.active .day-tab-date,
.day-tab.active .day-tab-label { color: var(--primary); }

/* ── Conditions card ── */
.conditions-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.conditions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}
.cond-tile {
  padding: var(--sp5) var(--sp4);
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp2); text-align: center;
  border-right: 1px solid var(--divider);
}
.cond-tile:last-child { border-right: none; }
.cond-icon { font-size: 28px; line-height: 1; }
.cond-label { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cond-value { font-family: var(--font-d); font-size: var(--text-lg); font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.cond-sub { font-size: var(--text-xs); color: var(--muted); }

/* Time-of-day selector */
.tod-row {
  display: flex; gap: 0;
  border-top: 1px solid var(--divider);
}
.tod-btn {
  flex: 1; padding: var(--sp3);
  text-align: center; font-size: var(--text-sm); font-weight: 700;
  color: var(--muted); border-right: 1px solid var(--divider);
  min-height: 44px;
  transition: background var(--ease), color var(--ease);
}
.tod-btn:last-child { border-right: none; }
.tod-btn.active { background: var(--primary-subtle); color: var(--primary); }
.tod-btn:hover:not(.active) { background: var(--offset); color: var(--text); }

/* ── Wind card ── */
.wind-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp5) var(--sp6);
  display: flex; align-items: center; gap: var(--sp8);
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.wind-compass {
  position: relative;
  width: 100px; height: 100px; flex-shrink: 0;
}
.compass-ring {
  width: 100px; height: 100px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--offset);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.compass-labels {
  position: absolute; inset: 0;
  font-size: 10px; font-weight: 800; color: var(--muted);
  font-family: var(--font-d);
}
.compass-labels span {
  position: absolute;
}
.compass-labels .cn { top: 4px; left: 50%; transform: translateX(-50%); color: var(--primary); }
.compass-labels .cs { bottom: 4px; left: 50%; transform: translateX(-50%); }
.compass-labels .cw { left: 6px; top: 50%; transform: translateY(-50%); }
.compass-labels .ce { right: 6px; top: 50%; transform: translateY(-50%); }
.wind-arrow {
  width: 4px; height: 44px;
  background: linear-gradient(to bottom, var(--primary) 50%, transparent 50%);
  border-radius: 2px;
  transform-origin: center bottom;
  transition: transform 0.6s cubic-bezier(0.16,1,0.3,1);
  position: absolute;
  bottom: 50%;
}
.wind-info { flex: 1; min-width: 200px; }
.wind-speed-big {
  font-family: var(--font-d); font-size: var(--text-xl);
  font-weight: 800; color: var(--text); letter-spacing: -.03em;
}
.wind-dir-label { font-size: var(--text-sm); color: var(--muted); margin-top: 2px; }
.wind-impact-row { margin-top: var(--sp4); }
.wind-impact-label { font-size: var(--text-xs); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: var(--sp2); }
.wind-bar-wrap { display: flex; align-items: center; gap: var(--sp3); }
.wind-bar-track {
  flex: 1; height: 6px; background: var(--offset2);
  border-radius: var(--radius-full); overflow: hidden;
}
.wind-bar-fill {
  height: 100%; border-radius: var(--radius-full);
  transition: width 0.5s var(--ease);
}
.wind-bar-fill.head { background: var(--wide); }
.wind-bar-fill.tail { background: var(--good); }
.wind-bar-fill.cross { background: var(--tight); }
.wind-bar-val { font-size: var(--text-xs); font-weight: 700; width: 52px; text-align: right; }

/* ── Adjusted distances ── */
.adjusted-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.adj-note {
  padding: var(--sp3) var(--sp5);
  font-size: var(--text-sm);
  color: var(--muted);
  background: var(--offset);
  border-bottom: 1px solid var(--divider);
}
.adj-badge {
  padding: 3px 12px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em;
  background: var(--offset2); color: var(--muted);
}
.adj-badge.play-longer { background: var(--good-hl); color: var(--good); }
.adj-badge.play-shorter { background: var(--wide-hl); color: var(--wide); }
.adj-badge.play-normal { background: var(--primary-hl); color: var(--primary); }

.adj-table .t-change {
  font-weight: 700; font-variant-numeric: tabular-nums;
}
.adj-table .t-change.pos { color: var(--good); }
.adj-table .t-change.neg { color: var(--wide); }
.adj-table .t-playAs { font-weight: 800; font-family: var(--font-d); color: var(--primary); }
.adj-table .t-adj { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Factors card ── */
.factors-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp5) var(--sp6);
  box-shadow: var(--shadow-sm);
}
.factors-title { font-size: var(--text-base); font-weight: 700; font-family: var(--font-d); margin-bottom: var(--sp4); }
.factors-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp3); }
.factor-row {
  display: flex; align-items: center; gap: var(--sp3);
  padding: var(--sp3) var(--sp4);
  background: var(--offset);
  border-radius: var(--radius-md);
}
.factor-icon { font-size: 20px; flex-shrink: 0; }
.factor-info { flex: 1; min-width: 0; }
.factor-label { font-size: var(--text-xs); font-weight: 700; color: var(--muted); }
.factor-value { font-family: var(--font-d); font-weight: 800; font-size: var(--text-base); color: var(--text); }
.factor-impact { font-size: var(--text-xs); font-weight: 700; }
.factor-impact.pos { color: var(--good); }
.factor-impact.neg { color: var(--wide); }
.factor-impact.neu { color: var(--muted); }

/* ── Course empty state ── */
.course-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: var(--sp4);
  padding: var(--sp16) var(--sp4);
  color: var(--faint); text-align: center;
  font-size: var(--text-sm); line-height: 1.7;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .conditions-grid { grid-template-columns: repeat(2, 1fr); }
  .cond-tile { border-bottom: 1px solid var(--divider); }
  .cond-tile:nth-child(2n) { border-right: none; }
  .cond-tile:nth-last-child(-n+2) { border-bottom: none; }
  .factors-grid { grid-template-columns: 1fr; }
  .wind-card { gap: var(--sp5); }
  .adj-table th:nth-child(4),
  .adj-table td:nth-child(4) { display: none; }
  .course-panel { padding: var(--sp4) var(--sp3) var(--sp12); }
}

/* =====================================================
   SAVED BAGS
   ===================================================== */

/* Saved bags bar at top of panel */
.saved-bags-bar {
  display: flex;
  align-items: center;
  gap: var(--sp2);
  padding: var(--sp2) var(--sp3) var(--sp2) var(--sp4);
  border-bottom: 1px solid var(--divider);
  background: var(--offset);
  min-height: 46px;
}

.saved-bags-scroll {
  display: flex;
  gap: var(--sp2);
  overflow-x: auto;
  flex: 1;
  padding: 2px 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.saved-bags-scroll::-webkit-scrollbar { display: none; }

/* Bag chip */
.bag-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  min-height: 32px;
  transition: all var(--ease);
  flex-shrink: 0;
}
.bag-chip:hover {
  border-color: var(--primary);
  color: var(--text);
}
.bag-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}
.bag-chip-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
  flex-shrink: 0;
}

.save-new-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1.5px solid var(--border);
  flex-shrink: 0;
}
.save-new-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-subtle);
}

/* Autosave indicator */
.autosave-indicator {
  font-size: 10px;
  font-weight: 700;
  color: var(--good);
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
}
.autosave-indicator.show { opacity: 1; }

/* Rename modal */
#renameOverlay .modal {
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

/* =====================================================
   FULL-WIDTH FEATURE PANELS (Pro Compare, Stats, Tools)
   ===================================================== */

/* Make tabs scrollable on mobile for 5 tabs */
.tabs-inner {
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1px;
}
.tabs-inner::-webkit-scrollbar { display: none; }

/* Full-panel container */
.full-panel {
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--sp6) var(--sp5) var(--sp16);
  min-height: 60dvh;
}
.full-panel-inner {
  display: flex;
  flex-direction: column;
  gap: var(--sp5);
}

/* Sub-tabs (Stats: SG/Handicap, Tools: Compare/Share/Planner) */
.sub-tabs {
  display: flex;
  gap: var(--sp2);
  background: var(--offset);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.sub-tabs::-webkit-scrollbar { display: none; }
.sub-tab {
  flex: 1;
  padding: var(--sp2) var(--sp4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm); font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  min-height: 40px;
  transition: all var(--ease);
}
.sub-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.sub-tab:not(.active):hover {
  background: var(--offset2);
  color: var(--text);
}

/* Responsive */
@media (max-width: 640px) {
  .full-panel {
    padding: var(--sp4) var(--sp3) var(--sp12);
  }
  .sub-tab {
    font-size: var(--text-xs);
    padding: var(--sp2) var(--sp3);
  }
}
