@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url(../fonts/barlow-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url(../fonts/barlow-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url(../fonts/barlow-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 500; font-display: swap; src: url(../fonts/barlow-condensed-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url(../fonts/barlow-condensed-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url(../fonts/barlow-condensed-latin-700-normal.woff2) format('woff2'); }

:root {
  --paper: #EEF1EC;
  --paper-2: #E2E8E0;
  --card: #F8FAF6;
  --ink: #0F2A24;
  --ink-2: #3E5650;
  --muted: #61756E;
  --turf: #2F6B4F;
  --fairway: #8CC084;
  --flag: #F2C230;
  --flag-deep: #A97F06;
  --red: #C8392B;
  --line: #C9D3C7;
  --stage: #0F2A24;
  --radius-s: 6px;
  --radius-m: 10px;
  --cond: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tabbar-h: 0px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--cond); font-weight: 700; line-height: 1.05; margin: 0; letter-spacing: 0.005em; }
h1 { font-size: clamp(30px, 4.2vw, 46px); }
h2 { font-size: 22px; margin-bottom: 12px; }
p { margin: 0 0 12px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--flag); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Kopfzeile & Navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px clamp(14px, 3vw, 32px);
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--ink); color: var(--paper);
}
.wordmark { display: flex; align-items: center; gap: 8px; color: var(--paper); text-decoration: none; font: 700 26px/1 var(--cond); }
.wordmark svg { width: 20px; height: 28px; }
.tabs { display: flex; gap: 4px; }
.tabs a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--radius-s);
  color: #C8D6CF; text-decoration: none; font: 600 18px/1 var(--cond);
}
.tabs a svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a svg .fill { fill: currentColor; stroke: none; }
.tabs a:hover { color: #fff; }
.tabs a.is-active { color: var(--ink); background: var(--flag); }

main { padding: clamp(12px, 2.4vw, 28px) clamp(12px, 3vw, 32px) 40px; max-width: 1480px; margin: 0 auto; }

/* ---------- Bausteine ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 22px; border-radius: 999px; border: 2px solid transparent;
  font: 600 19px/1 var(--cond); letter-spacing: 0.01em; text-decoration: none;
}
.btn-flag { background: var(--flag); color: var(--ink); }
.btn-flag:hover { background: #F6CF55; }
.btn-ghost { border-color: currentColor; background: transparent; }
.btn-sm { min-height: 36px; padding: 0 16px; font-size: 16px; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-text { background: none; border: 0; padding: 6px 4px; color: var(--turf); font: 600 16px/1.2 var(--cond); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.btn-text:hover { color: var(--ink); }
.btn-text.danger { color: var(--red); }

.seg { display: inline-flex; background: var(--paper-2); border-radius: var(--radius-s); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 4px; font: 600 16px/1.1 var(--cond); color: var(--ink-2); }
.seg button:hover { color: var(--ink); }
.seg button.is-on { background: var(--ink); color: var(--paper); }
.seg-wide { display: flex; }
.seg-wide button { flex: 1; }

.field { margin-bottom: 14px; }
.field-label { display: block; font: 500 15px/1.2 var(--body); color: var(--muted); margin-bottom: 6px; }

/* ---------- Analyse-Layout ---------- */
.analyse-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
.col-panel { display: flex; flex-direction: column; gap: 16px; }
#results, .results-main { display: flex; flex-direction: column; gap: 16px; }
.results-main { margin-top: 18px; }
.results-main[hidden] { display: none; }

.stage {
  position: relative; background: var(--stage); color: var(--paper);
  border-radius: var(--radius-m); min-height: 380px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.stage.is-drop { box-shadow: inset 0 0 0 3px var(--flag); }
.stage-empty { max-width: 520px; padding: 40px 28px; }
.stage-empty h1 { color: var(--paper); margin-bottom: 14px; }
.stage-empty p { color: #BFD0C8; max-width: 46ch; }
.stage-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 10px; }
.stage-actions .btn-ghost { color: var(--paper); }
.drop-hint { font-size: 14px; color: #8FA79D !important; }
.player-host { width: 100%; display: flex; justify-content: center; }
.player-box { position: relative; }
.player-box video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.player-overlay { position: absolute; inset: 0; touch-action: none; }
.player-overlay.is-drawing { cursor: crosshair; }

.progress { position: absolute; inset: 0; background: rgba(15, 42, 36, 0.86); display: flex; align-items: center; justify-content: center; z-index: 5; }
.progress-inner { width: min(360px, 84%); text-align: center; }
.progress-title { font: 600 22px/1.2 var(--cond); }
.bar { height: 6px; background: rgba(255,255,255,0.15); border-radius: 3px; overflow: hidden; margin: 14px 0 8px; }
.bar span { display: block; height: 100%; width: 0; background: var(--flag); transition: width 0.15s linear; }
.progress-sub { font-size: 14px; color: #BFD0C8; }
.progress .btn-ghost { color: var(--paper); }

/* Transport */
.transport { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.transport-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--card); display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg .fill { fill: var(--ink); stroke: none; }
.icon-btn-main { width: 54px; height: 54px; background: var(--ink); border-color: var(--ink); }
.icon-btn-main svg { stroke: var(--flag); }
.icon-btn-main svg .fill { fill: var(--flag); }
.icon-btn .i-pause { display: none; }
.icon-btn.is-playing .i-play { display: none; }
.icon-btn.is-playing .i-pause { display: block; }
.timecode { font: 600 20px/1 var(--cond); margin-left: auto; font-variant-numeric: tabular-nums; }
.ribbon { width: 100%; height: 96px; display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-m); cursor: pointer; touch-action: none; }
.phase-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.phase-chips button {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 12px; font: 600 15px/1.1 var(--cond); color: var(--ink-2);
}
.phase-chips button b { color: var(--muted); font-weight: 500; margin-right: 4px; }
.phase-chips button.is-on { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.phase-chips button.is-on b { color: var(--flag); }
.toolrow { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }

/* Einstellungen */
.setup-help summary { cursor: pointer; font: 600 17px/1.2 var(--cond); color: var(--turf); padding: 4px 0; }
.setup-figs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.setup-figs figure { margin: 0; }
.setup-figs svg { width: 100%; background: #DCE7D8; border-radius: var(--radius-s); }
.setup-figs .target { stroke: var(--turf); stroke-width: 2; fill: none; stroke-dasharray: 5 4; }
.setup-figs .ball { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.setup-figs .player { fill: var(--ink); }
.setup-figs .phone { fill: var(--flag); stroke: var(--ink); stroke-width: 1.5; }
.setup-figs .sight { stroke: var(--flag-deep); stroke-width: 1.5; stroke-dasharray: 2 3; fill: none; }
.setup-figs figcaption { font-size: 13px; line-height: 1.35; color: var(--ink-2); margin-top: 6px; }
.tips { margin: 6px 0 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
.tips li { margin-bottom: 4px; }

/* Scorekarte – wie auf dem Platz: Kreis = gut, Quadrat = Baustelle */
.scorecard-head { display: flex; justify-content: space-between; align-items: baseline; }
.scorecard { width: 100%; border-collapse: collapse; table-layout: fixed; font-family: var(--cond); }
.scorecard th, .scorecard td { border: 1px solid var(--line); text-align: center; padding: 6px 2px; }
.scorecard th { font-weight: 600; font-size: 14px; color: var(--muted); background: var(--paper-2); line-height: 1.1; }
.scorecard th span { display: block; font-size: 12px; font-weight: 500; }
.scorecard th { overflow-wrap: anywhere; }
.scorecard td { font-size: 20px; font-weight: 700; height: 52px; }
.scorecard td button { border: 0; background: none; padding: 0; width: 100%; height: 100%; font: inherit; }
.scorecard .total { background: var(--ink); color: var(--flag); font-size: 30px; }
.scorecard th.total-h { background: var(--ink); color: var(--paper); }
.mk { display: inline-grid; place-items: center; width: 34px; height: 34px; font: 700 18px/1 var(--cond); }
.mk-good { border: 2px solid var(--turf); border-radius: 50%; color: var(--turf); }
.mk-ok { color: var(--ink); }
.mk-bad { border: 2px solid var(--red); color: var(--red); }
.mk-none { color: var(--muted); font-weight: 500; }
.legend { margin: 10px 0 0; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.legend .mk { width: 24px; height: 24px; font-size: 13px; margin-left: 6px; }

/* Coach */
.coach { border-left: 6px solid var(--flag); }
.coach h2 { margin-bottom: 4px; }
.coach .focus-name { font: 700 28px/1.05 var(--cond); margin: 2px 0 10px; }
.coach .moment { display: inline-block; margin-bottom: 10px; }
.coach .cue { font: 600 21px/1.2 var(--cond); background: #FDF4D6; border-radius: var(--radius-s); padding: 10px 12px; margin: 10px 0; }
.coach .cue small { display: block; font: 500 13px/1.2 var(--body); color: var(--flag-deep); margin-bottom: 3px; }
.coach .drill { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.coach .drill h3 { font-size: 19px; margin-bottom: 4px; }
.coach .check { font-size: 14px; color: var(--ink-2); }
.coach ul { margin: 6px 0 0; padding-left: 18px; }
.coach .memory { background: var(--paper-2); border-radius: var(--radius-s); padding: 10px 12px; margin-top: 12px; font-size: 14px; }
.coach .memory strong { font-family: var(--cond); font-size: 16px; }

/* Messwerte */
.metrics { list-style: none; margin: 0; padding: 0; }
.metrics li { border-top: 1px solid var(--line); }
.metrics li:first-child { border-top: 0; }
.metrics button {
  width: 100%; display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center;
  border: 0; background: none; text-align: left; padding: 10px 2px;
}
.metrics button:hover { background: var(--paper-2); }
.metrics .m-label { font-weight: 500; line-height: 1.25; }
.metrics .m-target { display: block; font-size: 13px; color: var(--muted); }
.metrics .m-value { font: 700 22px/1 var(--cond); font-variant-numeric: tabular-nums; white-space: nowrap; }
.metrics .mk { width: 30px; height: 30px; font-size: 15px; }
.fineprint { font-size: 12.5px; color: var(--muted); margin: 12px 0 0; }
.warnings p { background: #FDF4D6; border-radius: var(--radius-s); padding: 10px 12px; font-size: 14px; margin-bottom: 8px; }
.error-box { background: #FBE3DF; color: #6E1E15; border-radius: var(--radius-m); padding: 14px 16px; }
.error-box h3 { font-size: 20px; margin-bottom: 4px; }

/* ---------- Live ---------- */
.live-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
.live-stage { min-height: min(72vh, 760px); }
.live-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.live-stage video.mirror, .live-stage canvas.mirror { transform: scaleX(-1); }
.live-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.live-empty { position: relative; z-index: 2; }
.live-status {
  position: absolute; top: 14px; left: 14px; z-index: 3;
  background: rgba(15, 42, 36, 0.8); color: var(--paper); border-radius: 999px; padding: 6px 14px 6px 30px;
  font: 600 17px/1.2 var(--cond);
}
.live-status::before { content: ''; position: absolute; left: 12px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--muted); }
.live-status.is-ready::before { background: var(--fairway); }
.live-status.is-swing::before { background: var(--red); }
.live-result {
  position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 3;
  background: rgba(248, 250, 246, 0.96); color: var(--ink); border-radius: var(--radius-m); padding: 14px 18px;
  display: grid; grid-template-columns: auto 1fr; gap: 4px 18px; align-items: center;
}
.live-result .lr-score { grid-row: span 2; font: 700 64px/0.9 var(--cond); }
.live-result .lr-focus { font: 700 26px/1.05 var(--cond); }
.live-result .lr-cue { font-size: 16px; color: var(--ink-2); }
.session { list-style: none; margin: 0; padding: 0; }
.session li { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; border-top: 1px solid var(--line); padding: 8px 0; }
.session li:first-child { border-top: 0; }
.session li.empty { display: block; color: var(--muted); font-size: 14px; }
.session .s-no { font: 600 16px/1 var(--cond); color: var(--muted); }
.session .s-focus { font-size: 14px; color: var(--ink-2); line-height: 1.25; }

/* ---------- Vergleich ---------- */
.compare-pickers { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 12px; }
.picker span { display: block; font: 600 17px/1.2 var(--cond); margin-bottom: 4px; }
.picker select { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--card); }
.compare-stages { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.compare-stage { min-height: 320px; }
.compare-stage .player-host { display: flex; }
.stage-note { color: #BFD0C8; padding: 24px; text-align: center; max-width: 30ch; }
.compare-transport .check { display: flex; align-items: center; gap: 6px; font-size: 15px; margin-left: auto; }
.compare-table-card { margin-top: 16px; }
.cmp-table { width: 100%; border-collapse: collapse; }
.cmp-table th, .cmp-table td { padding: 8px 6px; border-top: 1px solid var(--line); text-align: right; }
.cmp-table th:first-child, .cmp-table td:first-child { text-align: left; }
.cmp-table thead th { font: 600 16px/1.2 var(--cond); color: var(--muted); border-top: 0; }
.cmp-table td.v { font: 700 19px/1 var(--cond); white-space: nowrap; }
.cmp-table .better { color: var(--turf); }
.cmp-table .worse { color: var(--red); }

/* ---------- Verlauf ---------- */
.history-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.history-head p { margin: 6px 0 0; }
.trend { width: min(420px, 100%); height: 90px; }
.history { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.history li { display: grid; grid-template-columns: 96px 1fr auto; gap: 14px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 10px; }
.history img, .history .noimg { width: 96px; height: 72px; object-fit: cover; border-radius: var(--radius-s); background: var(--stage); display: block; }
.history .h-title { font: 600 19px/1.15 var(--cond); }
.history .h-meta { font-size: 14px; color: var(--muted); }
.history .h-focus { font-size: 14px; color: var(--ink-2); }
.history .h-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.history .h-score { font: 700 34px/1 var(--cond); min-width: 48px; text-align: right; }
.history .empty { display: block; color: var(--muted); background: none; border: 1.5px dashed var(--line); padding: 24px; text-align: center; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--tabbar-h) + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font: 600 17px/1.2 var(--cond);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Mobil ---------- */
@media (max-width: 980px) {
  .analyse-grid, .live-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  :root { --tabbar-h: 64px; }
  .topbar { justify-content: center; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--ink); justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  }
  .tabs a { flex-direction: column; gap: 3px; font-size: 14px; padding: 6px 10px; flex: 1; }
  .tabs a.is-active { background: transparent; color: var(--flag); }
  main { padding: 10px 10px 30px; }
  .stage { min-height: 300px; border-radius: var(--radius-s); }
  .stage-empty { padding: 28px 20px; }
  .compare-pickers, .compare-stages { grid-template-columns: 1fr 1fr; gap: 8px; }
  .compare-stage { min-height: 220px; }
  .history li { grid-template-columns: 72px 1fr; }
  .history img, .history .noimg { width: 72px; height: 56px; }
  .history .h-actions { grid-column: 1 / -1; justify-content: space-between; }
  .live-result .lr-score { font-size: 48px; }
  .scorecard th { font-size: 0; }
  .scorecard th span { font-size: 13px; font-weight: 600; }
  .scorecard td { height: 46px; }
  .scorecard .mk { width: 30px; height: 30px; font-size: 16px; }
  .timecode { font-size: 17px; }
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn-main { width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
