/* MotionCaddie demo — design tokens from the team design spec */
:root {
  --bg: #faf9f5;
  --ink: #1d2b24;
  --muted: #6b7a72;
  --green: #0C5C3A;          /* primary forest green */
  --green-soft: #e6f4ec;
  --accent: #379A6D;         /* accent green — dark enough for 3:1 non-text contrast on white */
  --amber: #E8B23E;          /* "watch" */
  --amber-soft: #fdf3dd;
  --purple: #6d4ad0;         /* coach chat accent (Anthropic editorial) */
  --purple-soft: #f2ecfc;
  --gray: #9AA3AE;           /* "low confidence" */
  --gray-soft: #f0f1f3;
  --card: #ffffff;
  --radius: 16px;
  --shadow: 0 2px 6px rgba(29, 43, 36, .06), 0 12px 28px rgba(29, 43, 36, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Satoshi", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 1120px; margin: 0 auto; padding: 24px 24px 80px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ------------------------------- top bar ------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1120px; margin: 0 auto; padding: 20px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; color: var(--green); }
/* the brand doubles as a "back to home" link */
a.brand { text-decoration: none; }
a.brand:hover .brand-name { text-decoration: underline; }
.brand-logo { height: 36px; width: auto; display: block; }

.site-links { display: flex; align-items: center; gap: 4px; }

.progress-nav { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.pstep { display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; transition: all .25s; }
.pnum {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gray-soft); color: var(--muted); font-size: 12px; font-weight: 700;
}
.pstep.active { background: var(--green-soft); color: var(--green); font-weight: 600; }
.pstep.active .pnum { background: var(--green); color: #fff; }
.pstep.done .pnum { background: var(--accent); color: #fff; }
.psep { width: 26px; height: 2px; background: #e3e5e0; border-radius: 2px; }

/* ------------------------------- 1 · pick ------------------------------ */
.hero { text-align: center; padding: 36px 0 28px; }
.hero h1 { font-size: 40px; margin: 0 0 12px; letter-spacing: -0.5px; color: var(--green); }
.hero-sub { max-width: 560px; margin: 0 auto; color: var(--muted); font-size: 17px; }

.sample-panel { padding: 28px; max-width: 760px; margin: 0 auto; text-align: center; }
.sample-head h2 { margin: 0 0 4px; font-size: 22px; }
.sample-head p { margin: 0 0 20px; }

.clip-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 340px));
  justify-content: center; gap: 14px; margin-bottom: 22px; }
.clip-card {
  border: 2px solid #edeeea; border-radius: 12px; padding: 10px; cursor: pointer;
  background: #fff; text-align: left; transition: border-color .15s, transform .15s;
  font: inherit; color: inherit;
}
.clip-card:hover { transform: translateY(-2px); }
.clip-card.selected { border-color: var(--green); background: var(--green-soft); }
.clip-card video { width: 100%; border-radius: 8px; display: block; background: #000; pointer-events: none; }
.clip-card .clip-title { font-weight: 600; margin: 8px 0 2px; font-size: 14px; }
.clip-card .clip-meta { font-size: 12px; color: var(--muted); }

.btn-primary {
  background: var(--green); color: #fff; border: none; border-radius: 999px;
  padding: 14px 34px; font-size: 16px; font-weight: 600; cursor: pointer;
  transition: filter .15s, transform .15s;
}
.btn-primary:hover { filter: brightness(1.12); transform: translateY(-1px); }
.btn-secondary {
  background: #fff; color: var(--green); border: 2px solid var(--green); border-radius: 999px;
  padding: 10px 24px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-ghost { background: var(--gray-soft); border: none; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 15px; }

/* ----------------------------- 2 · analyze ----------------------------- */
.analyze-panel { max-width: 560px; margin: 48px auto; padding: 32px 36px; }
.analyze-panel h2 { margin: 0 0 20px; color: var(--green); }
.analyze-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.analyze-steps li { display: flex; align-items: flex-start; gap: 12px; opacity: .35; transition: opacity .3s; }
.analyze-steps li.doing, .analyze-steps li.done { opacity: 1; }
.analyze-steps strong { display: block; font-size: 15px; }
.analyze-steps span:not(.check) { font-size: 13px; color: var(--muted); }

/* live cloud processing (.analyze-live, set by startCloudAnalyzeUI): sample
   3D swing loop + one advancing step line replace the 7-item checklist.
   The <ol> stays in the DOM (visually hidden below) for screen readers and
   as the single source of the step copy. Demo clips keep the classic list. */
.analyze-preview-wrap { display: none; }
.analyze-live .analyze-preview-wrap { display: block; margin: 4px 0 2px; }
#analyze-preview { display: block; width: 100%; height: 300px; border-radius: 12px;
  background: #0f2019; opacity: .85; }        /* ghosted, recedes behind the copy */
.analyze-preview-caption { margin: 8px 0 0; text-align: center; font-size: 13px;
  color: var(--muted); }
#analyze-step-line { min-height: 22px; margin: 14px 0 0; font-size: 15px;
  font-weight: 600; color: var(--green); opacity: 0; transition: opacity .5s ease; }
#analyze-step-line.show { opacity: 1; }
.analyze-live .analyze-steps { position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.check {
  flex: 0 0 auto; width: 22px; height: 22px; margin-top: 2px; border-radius: 50%;
  border: 2px solid #dfe1dc; position: relative; transition: all .25s;
}
li.doing .check { border-color: var(--amber); }
li.done .check { border-color: var(--green); background: var(--green); }
li.done .check::after {
  content: "✓"; position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; color: #fff; font-size: 13px; font-weight: 700;
}

/* ----------------------------- 3 · results ----------------------------- */
.results-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin: 8px 0 20px;
}
.results-clip-label { margin: 0; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.results-head h2 { margin: 4px 0 0; font-size: 28px; color: var(--green); max-width: 640px; letter-spacing: -0.3px; }

.view-toggle { display: flex; background: #edeeea; border-radius: 999px; padding: 4px; }
.tab {
  border: none; background: transparent; padding: 8px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tab.active { background: #fff; color: var(--green); box-shadow: 0 1px 4px rgba(0,0,0,.10); }

.results-grid { --panel-h: 924px;   /* = the numbers tab's natural height (9 rows + legend) */
  display: grid; grid-template-columns: 1fr 400px; gap: 20px; align-items: start; }
.results-main { min-width: 0; }
/* every tab panel gets the SAME height; long content scrolls inside it */
.view-panel { padding: 24px; height: var(--panel-h); overflow-y: auto; scrollbar-width: thin; }
/* the numbers tab sets the reference size — it never scrolls internally, and a
   clip with extra metrics just grows it */
#view-numbers { height: auto; min-height: var(--panel-h); }

/* plain-english — bento grid of section cards, each holding fact tiles */
#view-plain.card { background: transparent; box-shadow: none; padding: 0 2px 8px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px;
  align-content: start; align-items: start; }   /* natural heights — no stretching to the row partner */
#view-plain.card[hidden] { display: none; }   /* display:grid would otherwise beat the hidden attr */
.eval-section { padding: 18px 20px; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); }
.eval-section.wide { grid-column: 1 / -1; }   /* set by renderPlain for tile-heavy sections */
.eval-tagrow { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.eval-tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  padding: 3px 10px; border-radius: 999px;
}
.eval-tag.good { background: var(--green-soft); color: var(--green); }
.eval-tag.watch { background: var(--amber-soft); color: #9a7016; }
.eval-tag.low { background: var(--gray-soft); color: #5d6772; }
.eval-tag.info { background: var(--gray-soft); color: #5d6772; }
.eval-section h3 { margin: 0; font-size: 17px; }
.eval-section p { margin: 6px 0 0; color: #3c4a43; }
/* key-point tiles inside a section card */
.fact-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; margin-top: 12px; }
.fact-tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px;
  border-radius: 12px; background: var(--bg); border: 1px solid #e7e8e3; }
.fact-label { font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1.3; }
.fact-value { font-size: 20px; font-weight: 700; letter-spacing: -.3px; color: var(--ink); }
.fact-tour { font-size: 11px; color: var(--muted); }
.fact-tile.good { background: #f3faf6; border-color: #cfe6d9; }
.fact-tile.good .fact-value { color: var(--green); }
.fact-tile.watch { background: var(--amber-soft); border-color: #eed9a9; }
.fact-tile.watch .fact-value { color: #9a7016; }
.fact-tile.low { background: var(--gray-soft); border-color: #dfe1e5; }
/* legacy inline chips (older cached bundles) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: var(--bg); border: 1px solid #e7e8e3; color: var(--muted);
}
.chip b { color: var(--ink); font-weight: 600; }

/* numbers view */
.numbers-legend { display: flex; gap: 18px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.dot-in { background: var(--green); }
.dot-watch { background: var(--amber); }
.dot-low { background: var(--gray); }

.metric-row { display: grid; grid-template-columns: 190px 1fr 130px; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid #f0f1ed; }
.metric-row:last-child { border-bottom: none; }
.metric-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.metric-name strong { font-size: 14px; }
.metric-blurb { grid-column: 1 / -1; margin: -8px 0 0; font-size: 12.5px; color: var(--muted); }
.metric-vals { text-align: right; font-size: 13px; white-space: nowrap; }
.metric-vals .you-val { font-weight: 700; font-size: 15px; }
.metric-vals .tour-val { color: var(--muted); }

.axis { position: relative; height: 26px; }
.axis-track { position: absolute; top: 11px; left: 0; right: 0; height: 4px; border-radius: 2px; background: #edeeea; }
.axis-band { position: absolute; top: 8px; height: 10px; border-radius: 5px; background: var(--accent); opacity: .5; }
.axis-you {
  position: absolute; top: 4px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%;
  border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); background: var(--green);
}
.axis-you.watch { background: var(--amber); }
.axis-you.low { background: var(--gray); }
.axis-tour { position: absolute; top: 7px; width: 2px; height: 12px; margin-left: -1px; background: rgba(12,92,58,.45); border-radius: 1px; }

/* media column — capped to the tab-panel height so the two columns align;
   overlay / replay / ball flight scroll inside the rail */
.results-media { display: flex; flex-direction: column; gap: 14px;
  max-height: var(--panel-h); overflow-y: auto; scrollbar-width: thin;
  padding: 2px 2px 8px; }
.media-card { flex: 0 0 auto; padding: 16px; }
/* big blurred card shadows clip at a scrolling container's edge — swap for a
   hairline border + tight shadow inside the rail */
.results-media .media-card { box-shadow: 0 1px 4px rgba(29, 43, 36, .08);
  border: 1px solid #eceee9; }
.media-card h3 { margin: 0 0 10px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.media-card h3 .muted { text-transform: none; letter-spacing: 0; font-weight: 500; }
.media-card select { font: inherit; font-size: 12.5px; padding: 3px 8px;
  border: 1px solid #dcdcd6; border-radius: 8px; background: #fff; }
.media-card video, #replay-canvas { width: 100%; border-radius: 10px; display: block; background: #10231a; }
/* Phone uploads are 9:16 once the camera rotation is baked in (see
   Scripts/video_orientation.py). Unconstrained, width:100% renders those ~1000px
   tall and pushes the 3D replay + ball flight out of the rail. Cap and
   letterbox; the baked demo clips are square/landscape so they never hit this. */
.media-card video { max-height: 300px; object-fit: contain; }
.replay-controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.replay-controls input[type=range] { flex: 1; accent-color: var(--green); }

.results-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 26px; }
.results-footer p { max-width: 560px; text-align: right; }

/* ============================ coach chat ============================= */
.chat-ctx { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid #ececec; font-size: 13px; }
.chat-active { font-weight: 600; color: var(--ink); }
.chat-compare { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.chat-compare select { font: inherit; padding: 3px 6px; border: 1px solid #dcdcd6; border-radius: 8px; background: #fff; }
.chat-mode { margin-left: auto; color: var(--purple); background: var(--purple-soft);
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
/* the chat panel is a flex column filling the shared panel height: the stream
   stretches and the input row stays pinned to the bottom */
#view-chat { display: flex; flex-direction: column; }
#view-chat[hidden] { display: none; }   /* display:flex would otherwise beat the hidden attr */
.chat-stream { flex: 1 1 auto; min-height: 120px; overflow-y: auto; display: flex;
  flex-direction: column; gap: 12px; padding: 4px 2px; }
.chat-turn { display: flex; flex-direction: column; gap: 3px; }
.chat-turn .who { font-size: 11px; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--muted); }
.msg { padding: 11px 14px; border-radius: 14px; line-height: 1.5; white-space: pre-wrap;
  max-width: 85%; font-size: 14.5px; }
.msg.user { align-self: flex-end; background: var(--green); color: #fff; border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: var(--green-soft); color: var(--ink); border-bottom-left-radius: 5px; }
.msg.bot.refuse { background: #f4f2ee; color: #5c5850; }
.msg .grade { display: inline-block; margin-top: 7px; font-size: 11px; color: var(--green); font-weight: 600; }
.msg .grade.warn { color: #b3781a; }
.trace { align-self: flex-start; max-width: 90%; font-size: 12px; color: var(--muted); }
.trace summary { cursor: pointer; color: var(--purple); }
.trace-body { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.trace .tc { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px;
  background: var(--purple-soft); border-radius: 8px; padding: 5px 8px; overflow-x: auto; }
.trace .call { color: var(--purple); font-weight: 700; }
.trace .arg { color: #7a6a3a; }
.trace .res { color: #5b6b61; }
.typing { align-self: flex-start; color: var(--muted); font-size: 13px; padding: 4px 2px; }
.typing .dot { display: inline-block; width: 5px; height: 5px; margin-left: 2px; border-radius: 50%;
  background: var(--muted); animation: blink 1.2s infinite both; }
.typing .dot:nth-child(2) { animation-delay: .2s; }
.typing .dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 10px; }
.chip-btn { font: inherit; font-size: 13px; color: var(--green); background: #fff;
  border: 1px solid #d7e4db; border-radius: 20px; padding: 6px 12px; cursor: pointer; }
.chip-btn:hover { background: var(--green-soft); }
.voice-toggle { font: inherit; font-size: 11px; font-weight: 600; cursor: pointer;
  color: var(--muted); background: #f0f1f3; border: 1px solid transparent;
  padding: 3px 10px; border-radius: 20px; }
.voice-toggle:hover { border-color: #dcdcd6; }
.voice-pick { font: inherit; font-size: 11px; color: var(--muted); max-width: 150px;
  padding: 3px 6px; border: 1px solid #dcdcd6; border-radius: 8px; background: #fff; }
.voice-toggle[aria-pressed="true"] { color: var(--green); background: var(--green-soft); }
.chat-input { display: flex; gap: 10px; }
.chat-input input { flex: 1; font: inherit; padding: 11px 14px; border: 1px solid #dcdcd6;
  border-radius: 12px; background: #fff; }
.btn-mic { flex: 0 0 auto; width: 44px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); background: #fff; border: 1px solid #dcdcd6; border-radius: 12px; cursor: pointer; }
.btn-mic:hover { color: var(--green); border-color: var(--green); }
.btn-mic.rec { color: #c0392b; border-color: #c0392b; background: #fdecea;
  animation: micpulse 1.2s ease-in-out infinite; }
@keyframes micpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, .28); }
  50% { box-shadow: 0 0 0 7px rgba(192, 57, 43, .10); }
}
.chat-input input:focus { outline: none; border-color: var(--green); }
.chat-foot { margin-top: 12px; }
.chat-foot code { background: #f0f1f3; padding: 1px 5px; border-radius: 5px; font-size: 12px; }

.msg .grade::before { content: ""; display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: middle; }

/* ========================= 3D Swing View (Blender render) ===================== */
.render-phases { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.render-video { grid-column: 1 / -1; width: 100%; border-radius: 10px; display: block; background: #2b2f36; }
.render-phase { margin: 0; }
.render-phase img { width: 100%; border-radius: 10px; display: block; background: #2b2f36; }
.render-phase figcaption { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--muted);
  text-align: center; text-transform: uppercase; letter-spacing: .04em; }
.render-caption { margin: 16px 0 0; line-height: 1.5; }
@media (max-width: 620px) { .render-phases { grid-template-columns: 1fr; } }

/* ============================ topbar account ========================== */
.topbar { flex-wrap: wrap; gap: 12px; }
.account-area { display: flex; align-items: center; gap: 10px; }
.acct-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.btn-text { background: none; border: none; color: var(--green); font: inherit; font-weight: 600;
  font-size: 14px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.btn-text:hover { background: var(--green-soft); }
.btn-sm { padding: 8px 16px; font-size: 14px; }

/* ============================ landing / upload ======================== */
.hero { padding: 44px 0 26px; }
.hero-points { list-style: none; display: flex; flex-wrap: wrap; justify-content: center;
  gap: 8px; margin: 16px auto 0; padding: 0; max-width: 620px; }
.hero-points li { font-size: 13px; font-weight: 600; color: var(--green);
  background: var(--green-soft); border: 1px solid #cfe6d9; border-radius: 999px;
  padding: 5px 13px; }
.hero-actions { margin-top: 22px; }
.btn-lg { padding: 16px 40px; font-size: 17px; }
.upload-hint { margin: 14px auto 0; max-width: 480px; }
.upload-status { max-width: 460px; margin: 18px auto 0; padding: 14px 16px; text-align: left;
  background: var(--card); border: 1px solid #e7e8e3; border-radius: 12px; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.upload-status[hidden] { display: none; }   /* display:flex would otherwise beat the hidden attr */
.upload-file { display: flex; align-items: center; gap: 10px; min-width: 0; }
.upload-file-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 220px; }
.upload-badge { font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: #9a7016; background: var(--amber-soft); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.upload-status .btn-primary { padding: 10px 22px; font-size: 14px; }

.section-head { max-width: 1120px; margin: 8px 0 16px; }
.section-head h2 { margin: 0 0 2px; font-size: 22px; }
.section-head p { margin: 0; }
.demo-section { margin-top: 30px; }
.clip-gallery { margin-bottom: 0; }
.clip-cta { margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--green); }

/* ============================== dashboard ============================= */
.dashboard { margin: 26px 0 6px; padding: 22px 24px; }
.dash-eyebrow { margin: 0; font-size: 13px; color: var(--muted); }
.dash-title { margin: 2px 0 14px; font-size: 20px; }
.dash-swings { display: flex; flex-direction: column; gap: 8px; }
/* fixed column tracks so date / status / actions line up across rows
   (flex space-between let every row space its own cells independently) */
.dash-swing { display: grid; align-items: center; gap: 12px;
  grid-template-columns: minmax(0, 1fr) 80px 112px 106px 32px 32px;
  padding: 10px 14px; border: 1px solid #eceee9; border-radius: 10px; }
.dash-swing-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.dash-swing .dash-swing-date { grid-column: 2; }
.dash-swing .upload-badge { grid-column: 3; justify-self: start; }
.dash-swing .lib-open { grid-column: 4; justify-self: start; }
.dash-swing .lib-rename { grid-column: 5; }
.dash-swing .lib-remove { grid-column: 6; }
@media (max-width: 640px) {
  /* phones: name gets its own line; meta wraps naturally below */
  .dash-swing { display: flex; flex-wrap: wrap; }
  .dash-swing-name { flex: 1 1 100%; }
}

/* ========================= prototype banner ========================== */
.banner { margin: 4px 0 18px; padding: 12px 16px; border-radius: 12px; font-size: 14px;
  background: var(--amber-soft); border: 1px solid #efd9ae; color: #7a5a12; }
.banner strong { color: #6b4e0f; }

/* ============================ button icon ============================= */
.btn-secondary { display: inline-flex; align-items: center; gap: 7px; }
.btn-ico { width: 16px; height: 16px; }
#replay-play svg { width: 15px; height: 15px; display: block; }
#replay-play { display: inline-flex; align-items: center; justify-content: center; }

/* ============================== modals =============================== */
body.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 30, 25, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-backdrop[hidden] { display: none; }   /* class display must not beat [hidden] */
.modal { width: 100%; max-width: 440px; padding: 24px 26px 26px; max-height: 92vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h2 { margin: 0; font-size: 22px; color: var(--green); }
.modal-x { background: none; border: none; font-size: 24px; line-height: 1; color: var(--muted);
  cursor: pointer; padding: 2px 6px; border-radius: 8px; }
.modal-x:hover { background: var(--gray-soft); color: var(--ink); }
.modal-micro { margin: 0 0 16px; font-size: 12px; font-weight: 600; color: var(--purple);
  background: var(--purple-soft); padding: 5px 10px; border-radius: 8px; display: inline-block; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field em { color: var(--muted); font-weight: 400; font-style: normal; }
.field input { width: 100%; font: inherit; padding: 11px 13px; border: 1px solid #dcdcd6;
  border-radius: 10px; background: #fff; }
.field input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.consent { margin: 6px 0 18px; padding: 14px; background: var(--bg); border: 1px solid #ececec; border-radius: 12px; }
.consent-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; font-size: 13.5px; cursor: pointer; }
.consent-row input { margin-top: 3px; flex: 0 0 auto; width: 16px; height: 16px; accent-color: var(--green); }
.consent-note { display: block; color: var(--muted); font-style: normal; font-size: 12px; margin-top: 2px; }
.consent-summary { margin: 4px 0 0; line-height: 1.5; }
.privacy-link { color: var(--green); font-weight: 600; }
.btn-block { width: 100%; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; filter: none; transform: none; }
.switch-line { text-align: center; margin: 14px 0 0; }
.switch-line .btn-text { padding: 2px 4px; }

/* ============================ privacy doc ============================ */
.doc { max-width: 760px; }
.doc-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--purple); margin: 8px 0 0; }
.doc h1 { font-size: 32px; color: var(--green); margin: 8px 0 4px; }
.doc-updated { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.doc-intro { font-size: 16px; color: #3c4a43; }
.doc h2 { font-size: 18px; margin: 26px 0 6px; }
.doc p { color: #3c4a43; }
.doc-foot { margin-top: 32px; }

@media (max-width: 920px) {
  .results-grid { grid-template-columns: 1fr; }
  .clip-gallery { grid-template-columns: 1fr; }
  #view-plain.card { grid-template-columns: 1fr; }
  /* stacked layout: natural heights beat equal panels */
  .view-panel { height: auto; max-height: none; }
  .results-media { max-height: none; overflow: visible; }
  .results-media .media-card { box-shadow: var(--shadow); border: none; }
  .chat-stream { max-height: 460px; }
  .media-card video { max-height: 60vh; }
  .hero h1 { font-size: 30px; }
  .msg { max-width: 92%; }
  .topbar { justify-content: center; text-align: center; }
  .progress-nav { order: 3; width: 100%; justify-content: center; }
  .brand-logo { height: 30px; }
}

/* ===================== production features (library, markers, compare) ===================== */
.results-actions { display: flex; gap: 10px; margin-top: 6px; }
.results-actions .btn-ghost.small, .btn-ghost.small {
  font-size: 12.5px; padding: 4px 12px; border: 1px solid var(--line, #d8e0d9);
  border-radius: 8px; background: transparent; cursor: pointer; color: inherit;
  text-decoration: none; display: inline-flex; align-items: center; }
.results-actions .btn-ghost.small:hover { background: rgba(55, 154, 109, .12); }

/* detected-event markers under the overlay video */
.event-markers { position: relative; height: 34px; margin-top: 8px; }
.event-markers .ev-track { position: absolute; left: 0; right: 0; top: 6px; height: 3px;
  background: rgba(55, 154, 109, .3); border-radius: 2px; }
.event-markers .ev-tick { position: absolute; top: 0; width: 12px; height: 15px; padding: 0;
  transform: translateX(-50%); background: none; border: none; cursor: pointer; z-index: 1; }
.event-markers .ev-tick::before { content: ""; display: block; width: 3px; height: 15px;
  margin: 0 auto; background: var(--green, #0c5c3a); border-radius: 2px; }
.event-markers .ev-tick:hover::before, .event-markers .ev-tick:focus-visible::before { background: #379a6d; }
.event-markers .ev-label { position: absolute; top: 17px; left: 50%; transform: translateX(-50%) rotate(0);
  font-size: 9px; letter-spacing: .02em; color: var(--muted, #6b7a72); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s; }
.event-markers .ev-tick:hover .ev-label, .event-markers .ev-tick:focus-visible .ev-label,
.event-markers .ev-tick:nth-child(1) .ev-label, .event-markers .ev-tick:nth-child(4) .ev-label,
.event-markers .ev-tick:nth-child(6) .ev-label, .event-markers .ev-tick:nth-child(8) .ev-label { opacity: 1; }

/* lock-to-video toggle */
.sync-toggle { display: flex; align-items: center; gap: 6px; margin: 6px 2px 0; color: var(--muted, #6b7a72); cursor: pointer; }

/* recent-swings rail */
.recent-rail { display: flex; align-items: center; gap: 12px; margin: 18px 0 4px; overflow-x: auto; }
.recent-rail[hidden] { display: none; }   /* display:flex would otherwise beat the hidden attr */
.rail-cards { display: flex; gap: 10px; }
.rail-card { display: flex; flex-direction: column; gap: 4px; width: 120px; flex: none;
  background: none; border: 1px solid var(--line, #d8e0d9); border-radius: 10px; padding: 6px;
  cursor: pointer; font: inherit; color: inherit; text-align: left; }
.rail-card video { width: 100%; height: 64px; object-fit: cover; border-radius: 6px; pointer-events: none; }
.rail-card span { font-size: 11px; line-height: 1.25; color: var(--muted, #6b7a72); }
.rail-card:hover { border-color: var(--green, #0c5c3a); }

/* compare dot + expandable "why" on the numbers tab */
.numbers-compare { margin-left: auto; font-size: 12.5px; color: var(--muted, #6b7a72); }
.numbers-compare select { margin-left: 6px; }
.axis-cmp { position: absolute; top: 50%; width: 10px; height: 10px; border-radius: 50%;
  background: #6d4ad0; transform: translate(-50%, -50%); opacity: .85; }
.metric-label { background: none; border: none; padding: 0; font: inherit; color: inherit;
  cursor: pointer; text-align: left; }
.metric-label:hover strong { text-decoration: underline dotted; }
.metric-why { grid-column: 1 / -1; margin: 2px 0 0; font-size: 12.5px; color: var(--muted, #6b7a72);
  background: rgba(55, 154, 109, .10); border-radius: 8px; padding: 8px 10px; }

/* library badges */
.upload-badge.ok { background: #e2f5e9; color: #0c5c3a; }
.upload-badge.err { background: #f5e2e2; color: #a33131; }
.pulse { animation: mc-pulse 1.2s infinite; }
@keyframes mc-pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* ============ contour-line background (hills.js, index only) ============
   Fixed behind all content: #hills-canvas at z-index 0, content at z-index 1. */
#hills-canvas { position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; z-index: 0; pointer-events: none; }
.topbar, main { position: relative; z-index: 1; }

/* muted copy that can scroll over the hills gets a page-colored backdrop
   so contrast never drops below the plain-background baseline */
.section-head p.muted, .results-footer p.muted, p.upload-hint {
  display: inline-block; background: rgba(250, 249, 245, .88);
  border-radius: 8px; padding: 2px 8px; }

/* ---- chat markdown (vendored marked; bot messages only) ---- */
.msg.bot p { margin: 0 0 8px; }
.msg.bot p:last-child { margin-bottom: 0; }
.msg.bot ul, .msg.bot ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.bot li { margin: 2px 0; }
.msg.bot code { background: rgba(0,0,0,.07); padding: 0 4px; border-radius: 4px; font-size: .9em; }
.msg.bot h1, .msg.bot h2, .msg.bot h3, .msg.bot h4 { font-size: 1em; margin: 8px 0 4px; }
