:root {
    --bg: #f5f4ee;
    --surface: #ffffff;
    --surface-2: #eeede4;
    --text: #1b2620;
    --muted: #66706a;
    --line: #e0ded2;
    --primary: #1f5c43;
    --primary-2: #2f7d5b;
    --primary-ink: #ffffff;
    --accent: #d9a441;
    --warn: #b5651d;
    --danger: #b23a3a;
    --ok: #2f7d5b;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 4px 16px rgba(20, 40, 30, .05);
    --tabbar-h: 64px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #101613;
        --surface: #18211c;
        --surface-2: #212c26;
        --text: #e8ece9;
        --muted: #98a39c;
        --line: #2b3832;
        --primary: #3f9a72;
        --primary-2: #4fb084;
        --primary-ink: #08140e;
        --accent: #e5b65a;
        --warn: #e09a55;
        --danger: #e07070;
        --ok: #5cc08f;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: .4rem 0; }
a { color: var(--primary-2); }
code { background: var(--surface-2); padding: .1rem .35rem; border-radius: 6px; font-size: .9em; word-break: break-all; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.warn { color: var(--warn); }
.ok-text { color: var(--ok); }

/* Layout */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
    background: var(--primary); color: var(--primary-ink);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.brand img { border-radius: 7px; }
.topbar-user {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: rgba(255,255,255,.18); color: inherit; text-decoration: none; font-weight: 600; font-size: .85rem;
}

.page { max-width: 760px; margin: 0 auto; padding: 14px 14px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
.page-narrow { max-width: 440px; padding-bottom: 32px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 4px 0 8px; }

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: .7rem; min-height: 48px;
}
.tabbar a .ti { font-size: 1.3rem; filter: grayscale(1); opacity: .75; }
.tabbar a.active { color: var(--primary-2); font-weight: 600; }
.tabbar a.active .ti { filter: none; opacity: 1; }

.banner { display: block; padding: 10px 16px; text-decoration: none; font-size: .9rem; }
.banner-warn { background: #fbecd2; color: #6b4210; }
.banner-info { background: #dcefe5; color: #1d4a35; }
@media (prefers-color-scheme: dark) {
    .banner-warn { background: #3a2c14; color: #f2d29d; }
    .banner-info { background: #183428; color: #bfe6d1; }
}

/* Karten */
.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px; margin: 12px 0; box-shadow: var(--shadow);
}
.card.empty { text-align: center; padding: 28px 16px; }
.card.status.ok { border-left: 4px solid var(--ok); }
.card.status.off { border-left: 4px solid var(--warn); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover:not(:disabled) { background: var(--primary-2); }
.btn-ghost { background: transparent; color: var(--primary-2); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .88rem; }
.btn-block { width: 100%; }
.btn.danger { color: var(--danger); }
.btn-big { min-height: 54px; width: 100%; font-size: 1.1rem; font-weight: 600; margin: 8px 0; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.connect-hero { text-align: center; }
.connect-hero .steps { text-align: left; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }

/* Formulare */
.form label { display: block; margin-bottom: 12px; font-size: .9rem; font-weight: 600; }
input, select, textarea {
    display: block; width: 100%; margin-top: 4px;
    font: inherit; font-weight: 400; color: var(--text);
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-2); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; }

.alert { background: #f8dede; color: #7a2020; border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: .92rem; }
@media (prefers-color-scheme: dark) { .alert { background: #3b1c1c; color: #f2b8b8; } }
.toast { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: .92rem; }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

/* Login */
.login { padding-top: 6vh; }
.login-head { text-align: center; margin-bottom: 20px; }
.login-head img { border-radius: 16px; }
.login-head h1 { margin-top: 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.seg button { border: 0; background: transparent; font: inherit; font-weight: 600; padding: 8px; border-radius: 9px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Sessionliste */
.group-title { margin: 20px 4px 6px; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; color: inherit; text-decoration: none; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item:hover { background: var(--surface-2); }
.li-date { width: 42px; text-align: center; flex: none; }
.li-date .d { display: block; font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.li-date .m { display: block; font-size: .72rem; text-transform: uppercase; color: var(--muted); }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; }
.li-sub { font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-coach { font-size: .88rem; margin-top: 2px; }
.chev { color: var(--muted); font-size: 1.4rem; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; vertical-align: middle; margin-left: 4px; }
.badge-live { background: var(--accent); color: #2b1e05; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-left: 6px; vertical-align: middle; }

.back { display: inline-block; margin: 4px 0 8px; text-decoration: none; font-weight: 600; }

/* Coach */
.coach { border-top: 4px solid var(--accent); }
.coach-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.coach-badge { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.coach-headline { font-size: 1.25rem; }
.focus { display: grid; grid-template-columns: 30px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.focus-num { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-weight: 700; }
.target { font-weight: 600; color: var(--primary-2); }
.positive { background: var(--surface-2); padding: 8px 12px; border-radius: 10px; }

.finding { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin: 12px 0; }
.finding.sev-2 { border-left-color: var(--warn); }
.finding.sev-1 { border-left-color: var(--accent); }
.finding.sev-0 { border-left-color: var(--ok); }
.finding p { font-size: .93rem; }
details summary { cursor: pointer; padding: 4px 0; }
details p { font-size: .92rem; }

/* Tabellen */
.table-scroll { overflow-x: auto; margin: 8px -16px 0; padding: 0 16px; }
table.stats { border-collapse: collapse; width: 100%; font-size: .85rem; font-variant-numeric: tabular-nums; }
table.stats th, table.stats td { padding: 7px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.stats thead th { color: var(--muted); font-weight: 600; font-size: .75rem; }
table.stats th:first-child, table.stats td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
table.shots tr.mishit td { text-decoration: line-through; color: var(--muted); }

.trends { list-style: none; padding: 0; margin: 0; }
.trends li { padding: 6px 0; border-top: 1px solid var(--line); font-size: .92rem; }
.trends li:first-child { border-top: 0; }
.trends li.up { color: var(--ok); }
.trends li.down { color: var(--warn); }

/* Charts */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis-target { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .tick { fill: var(--muted); font-size: 10px; }
.chart .line { fill: none; stroke: var(--primary-2); stroke-width: 2.5; stroke-linejoin: round; }
.chart .band { fill: var(--primary-2); opacity: .14; }
.chart .dot { fill: var(--primary-2); stroke: var(--surface); stroke-width: 1.5; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.legend i.ring { border: 1.5px solid var(--muted); }
.mini-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; padding: 6px 12px; border-radius: 99px; cursor: pointer; text-align: left; }
.chip.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 120px; }
.chat-empty { text-align: center; padding: 20px 0; }
.chat-empty .chips { justify-content: center; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: .95rem; }
.bubble p { margin: .3rem 0; }
.bubble.me { align-self: flex-end; background: var(--primary); color: var(--primary-ink); border-bottom-right-radius: 4px; }
.bubble.coach { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.typing { display: flex; gap: 4px; padding: 14px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-input {
    position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    display: flex; gap: 8px; align-items: flex-end;
    max-width: 760px; margin: 0 auto; padding: 10px 16px;
    background: var(--bg); border-top: 1px solid var(--line);
}
.chat-input textarea { margin: 0; }

/* Verbinden */
.steps { padding-left: 20px; }
.steps li { margin: 14px 0; }
.bookmarklet {
    display: inline-block; padding: 10px 16px; border-radius: 10px;
    background: var(--accent); color: #2b1e05; font-weight: 700; text-decoration: none; cursor: grab;
}
@media (hover: none) { .desktop-only { display: none; } }

.invites { list-style: none; padding: 0; }
.invites li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--line); }

.splash { min-height: 100vh; display: grid; place-content: center; text-align: center; color: var(--muted); }
.splash img { border-radius: 18px; margin: 0 auto 8px; }

#blazor-error-ui {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
    background: #fbecd2; color: #6b4210; padding: 12px 16px;
}
#blazor-error-ui .dismiss { float: right; cursor: pointer; }


/* ---------- Smartphone zuerst: Tastatur, Runden, Schläger ---------- */

/* Tastatur offen: Tab-Leiste weg, Eingabe direkt über der Tastatur */
body.typing .tabbar { display: none; }
body.typing .chat-input { bottom: 0; padding-bottom: 10px; }
body.typing .page { padding-bottom: 120px; }
.chat-input textarea { font-size: 16px; } /* verhindert Auto-Zoom auf dem iPhone */
input, select, textarea { font-size: 16px; }

.section-title { margin: 22px 4px 8px; font-size: 1.05rem; }
.seg-3 { grid-template-columns: repeat(3, 1fr); margin: 8px 0 4px; }
.seg button { min-height: 40px; }
.chip { min-height: 36px; }

/* Sessionliste */
.badge-round { background: var(--primary); color: var(--primary-ink); margin: 0 4px 0 0; }
.li-score { font-weight: 800; font-size: 1.15rem; color: var(--warn); min-width: 36px; text-align: right; }
.li-score.good { color: var(--ok); }

/* Schlägerkarten */
.club-cards { display: flex; flex-direction: column; gap: 10px; }
.club-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.club-head {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 12px 14px 6px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.club-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.club-name strong { font-size: 1.02rem; }
.club-carry { text-align: right; line-height: 1.1; }
.club-carry .big { font-size: 1.5rem; font-weight: 800; }
.club-carry .unit { font-size: .85rem; color: var(--muted); }
.club-carry .small { display: block; }
.dot-warn { background: var(--warn); color: #fff; font-size: .72rem; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 5px; }
.club-head .chev { font-size: 1rem; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.metric { background: var(--surface); padding: 8px 10px; display: flex; flex-direction: column; }
.m-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.m-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.m-value small { font-weight: 400; color: var(--muted); }
.metric.warn .m-value { color: var(--danger); }
.club-detail { padding: 10px 14px 14px; border-top: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 8px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* Runde */
.round-hero { display: flex; align-items: center; gap: 16px; }
.round-score { display: flex; flex-direction: column; align-items: center; min-width: 74px; }
.round-score .score { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.round-score .topar { font-weight: 700; color: var(--warn); }
.round-score .topar.good { color: var(--ok); }
.round-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.t-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.t-value { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.t-sub { font-size: .85rem; color: var(--muted); }
.t-hint { font-size: .8rem; color: var(--warn); margin-top: 2px; }

.scorecard { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.sc-hole {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
    background: var(--surface-2); border: 2px solid transparent; border-radius: 10px; color: inherit; font: inherit; cursor: pointer;
}
.sc-hole.on { border-color: var(--primary-2); }
.sc-no { font-size: .7rem; color: var(--muted); }
.sc-par { font-size: .62rem; color: var(--muted); }
.sc-score { font-weight: 800; width: 28px; height: 28px; display: grid; place-items: center; }
.sc-score.eagle, .sc-score.birdie { border-radius: 50%; background: var(--ok); color: #fff; }
.sc-score.par { }
.sc-score.bogey { border: 2px solid var(--accent); border-radius: 4px; }
.sc-score.double { background: var(--warn); color: #fff; border-radius: 4px; }
.hole-detail { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.hole-head { display: flex; flex-direction: column; }
.hole-shots { padding-left: 22px; margin: 8px 0 0; }
.hole-shots li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.hole-shots li:last-child { border-bottom: 0; }
.hs-club { font-weight: 600; min-width: 96px; }
.hs-dist { font-variant-numeric: tabular-nums; min-width: 48px; }
.hs-lie { font-size: .78rem; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); }
.lie-fairway { background: #d7ecd9; color: #1e5a32; }
.lie-green, .lie-hole { background: #2f7d5b; color: #fff; }
.lie-rough { background: #e9e3c9; color: #5e5317; }
.lie-bunker { background: #f1e2bf; color: #6f4e12; }
.lie-other { background: #f3d5d5; color: #7a2020; }
@media (prefers-color-scheme: dark) {
    .lie-fairway { background: #1e3a28; color: #b9e2c4; }
    .lie-rough { background: #3a3518; color: #e6dba3; }
    .lie-bunker { background: #3d3118; color: #f0d6a0; }
    .lie-other { background: #3b1c1c; color: #f2b8b8; }
}

/* Distanzen */
.gapping { display: flex; flex-direction: column; gap: 4px; }
.gap-row { display: grid; grid-template-columns: 92px 1fr 52px; align-items: center; gap: 8px; }
.gap-club { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gap-bar { position: relative; height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; }
.gap-fill { position: absolute; left: 0; top: 4px; bottom: 4px; background: var(--primary-2); border-radius: 3px; }
.gap-range { position: absolute; top: 0; bottom: 0; background: var(--primary-2); opacity: .2; }
.gap-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .9rem; }
.gap-diff { font-size: .74rem; color: var(--muted); padding-left: 100px; }
.gap-diff.warn { color: var(--warn); }

table.shots tr.partial td { font-style: italic; color: var(--muted); }
