/* MyRower – dunkles Design, für Tablet am Rudergerät optimiert (große Ziele, gut lesbare Zahlen). */
:root {
  --bg: #0b1220;
  --panel: #131c2e;
  --panel-2: #1a2540;
  --line: #24314f;
  --text: #e6edf7;
  --muted: #8a9ab8;
  --accent: #0ea5a4;
  --accent-2: #f59e0b;
  --accent-3: #8b5cf6;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: #5eead4; }
h1 { font-size: 1.6rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .8rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .6rem; }
code { background: var(--panel-2); padding: .1rem .35rem; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* Kopfzeile */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: .6rem max(1rem, env(safe-area-inset-left)); background: rgba(11, 18, 32, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.app-logo { width: 34px; height: 34px; }
.mainnav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.mainnav a, .logout { color: var(--muted); text-decoration: none; padding: .5rem .8rem; border-radius: 10px; white-space: nowrap; }
.mainnav a.active { color: var(--text); background: var(--panel-2); }
.mainnav a:hover, .logout:hover { color: var(--text); }
.container { max-width: 1100px; margin: 0 auto; padding: 1.2rem max(1rem, env(safe-area-inset-left)) 3rem; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem; }

/* Bausteine */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin: 0 0 1rem; }
.flash { background: #0f3b38; border: 1px solid #14706b; padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.flash.error { background: #3f1518; border-color: #8b2a30; }
.section-title { margin-top: 1.4rem; }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: .65rem 1.1rem; border-radius: 10px; font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #3a4b74; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04201f; font-weight: 600; }
.btn.danger { background: transparent; border-color: #8b2a30; color: #fca5a5; }
.btn.small { padding: .4rem .8rem; font-size: .9rem; }
.btn.wide { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .6rem; }
.actions form { margin: 0; }

/* Formulare */
.form label { display: block; margin: 0 0 .8rem; color: var(--muted); font-size: .9rem; }
.form input, .form select { display: block; width: 100%; margin-top: .3rem; padding: .65rem .75rem; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.form input[type=color] { height: 2.8rem; padding: .25rem; }
.form label.check { display: flex; gap: .6rem; align-items: center; color: var(--text); }
.form label.check input { width: auto; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; align-items: end; }
.form-grid .actions { grid-column: 1 / -1; }
.form.inline { display: flex; gap: .8rem; align-items: end; flex-wrap: wrap; margin-top: 1rem; }
.form.inline label { flex: 1 1 220px; margin: 0; }

/* Anmeldung */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-shell { width: min(420px, 100%); }
.auth-brand { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.auth-brand strong { display: block; font-size: 1.4rem; }
.auth-brand small { color: var(--muted); }
.auth-logo { width: 56px; height: 56px; }

/* Start: Sensorstatus, Live, Personen */
.device-status { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(34, 197, 94, .18); }
.dot.off { background: #64748b; }
.live { border-color: #14706b; background: linear-gradient(180deg, #0f2a33, var(--panel)); }
.live-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .8rem; }
.live-badge { background: var(--accent); color: #04201f; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; font-size: .85rem; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.live-person { font-weight: 600; font-size: 1.1rem; }
.live-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }   /* immer 2 × 3: Dauer/Schläge, Frequenz/Strecke, Puls/Kalorien */
.live-grid > div { background: rgba(0, 0, 0, .18); border-radius: 12px; padding: .7rem .9rem; }
.live-value { display: block; white-space: nowrap; font-size: clamp(1.8rem, 4.2vw, 3rem); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.live-label { color: var(--muted); font-size: .9rem; }

.person-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.tile { --person: #64748b; display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 1.1rem .6rem; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); color: var(--text); font: inherit; cursor: pointer; min-height: 140px; justify-content: center; }
.tile:hover { border-color: var(--person); }
.tile-initial { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--person); color: #fff; font-size: 1.5rem; font-weight: 700; }
.tile-name { font-weight: 600; font-size: 1.1rem; }
.tile-hint { color: var(--muted); font-size: .8rem; min-height: 1.2em; }
.tile.selected { border-color: var(--person); background: color-mix(in srgb, var(--person) 18%, var(--panel)); }
.tile.selected .tile-hint { color: var(--text); }
.tile-none { --person: #475569; }

/* Listen */
.person-chip { --person: #64748b; display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; white-space: nowrap; }
.person-chip::before { content: ""; width: .75rem; height: .75rem; border-radius: 50%; background: var(--person); }
.person-chip.big { font-size: 1.1rem; }
.session-list { display: grid; gap: .5rem; }
.session-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(160px, 1.3fr) 2fr; gap: .8rem; align-items: center; padding: .8rem 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none; }
.session-row:hover { border-color: #3a4b74; }
.session-stats { display: flex; gap: 1.2rem; flex-wrap: wrap; justify-content: flex-end; color: var(--muted); }
.session-stats strong { color: var(--text); }
.filter { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filter a { --person: transparent; padding: .45rem .9rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-decoration: none; border-left: 4px solid var(--person); }
.filter a.active { color: var(--text); background: var(--panel-2); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; background: var(--panel); }
.table th, .table td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.table th { color: var(--muted); font-weight: 500; font-size: .85rem; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--panel-2); }
.table tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }

/* Kennzahlen */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; }
.stat-value { display: block; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .85rem; }
.detail-head { margin-bottom: 1rem; }
.detail-head h1 { margin: .4rem 0 .2rem; }
.note { background: var(--panel-2); padding: .5rem .8rem; border-radius: 10px; display: inline-block; }

/* Diagramme */
.chart-wrap { margin: 0; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: #3a4b74; }
.chart .tick { fill: var(--muted); font-size: 12px; }
.chart .line { fill: none; stroke-width: 2.5; stroke-linejoin: round; }
.chart .line.s1, .chart .dot.s1 { stroke: var(--accent); } .chart .dot.s1 { fill: var(--accent); }
.chart .line.s2, .chart .dot.s2 { stroke: var(--accent-2); } .chart .dot.s2 { fill: var(--accent-2); }
.chart .line.s3, .chart .dot.s3 { stroke: var(--accent-3); } .chart .dot.s3 { fill: var(--accent-3); }
.chart .bar.s1 { fill: var(--accent); } .chart .bar.s2 { fill: var(--accent-2); } .chart .bar.s3 { fill: var(--accent-3); }
.legend { display: flex; gap: 1rem; color: var(--muted); font-size: .85rem; margin-top: .3rem; }
.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.swatch.s1 { background: var(--accent); } .swatch.s2 { background: var(--accent-2); } .swatch.s3 { background: var(--accent-3); }

/* Personen, Geräte, Benutzer */
.person-list { display: grid; gap: .6rem; margin-bottom: 1rem; }
details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
details[open] > summary { margin-bottom: 1rem; }
.person-card.inactive { opacity: .6; }
.device-card { border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; margin-bottom: .6rem; background: var(--bg); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.api-key { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.api-key form { margin: 0; }
.api-doc { margin-top: 1rem; }
.api-doc pre { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .8rem; overflow-x: auto; font-size: .85rem; }
.api-doc code { background: none; padding: 0; }
.token-box { border: 1px solid var(--accent); background: #0f2a33; border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
.token-box input { font-family: ui-monospace, monospace; }
.token-box label { display: block; color: var(--muted); margin-bottom: .6rem; }
.token-box label input { display: block; width: 100%; margin-top: .3rem; padding: .6rem; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }

/* Symbole und Knöpfe */
.icon { width: 1.35em; height: 1.35em; vertical-align: -0.3em; flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; padding: 0; }
.icon-btn.active { border-color: var(--accent); color: var(--accent); }
.btn .icon { margin-right: .35rem; }
.install-hint { display: flex; align-items: center; gap: .8rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: .6rem .8rem; margin-bottom: 1rem; font-size: .9rem; }
.install-hint span { flex: 1; }
.auto-focus { display: flex; gap: .6rem; align-items: center; margin: 1rem 0 .4rem; cursor: pointer; }
.auto-focus input { width: 1.2rem; height: 1.2rem; }

/* Kurzmeldung (ohne Neuladen) */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1.2rem + env(safe-area-inset-bottom)); z-index: 200; background: #0f3b38; border: 1px solid #14706b; color: var(--text); padding: .8rem 1.1rem; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: calc(100% - 2rem); display: flex; gap: 1rem; align-items: center; }
.toast.error { background: #3f1518; border-color: #8b2a30; }
@media (max-width: 820px) { .toast { bottom: calc(5.5rem + env(safe-area-inset-bottom)); } }

/* Navigation unten (Handy, Tablet hochkant) */
.bottomnav { display: none; }

/* Großanzeige: Live-Karte füllt den ganzen Bildschirm */
.live-actions { display: flex; gap: .5rem; align-items: center; margin-left: auto; }
.end-form { margin: 0; }
.live-actions .btn { white-space: nowrap; }
.end-btn { border-color: #8b2a30; color: #fecaca; background: rgba(127, 29, 29, .35); }
.focus-close { display: none; }
.live.focus { position: fixed; inset: 0; z-index: 100; margin: 0; border-radius: 0; border: 0; display: flex; flex-direction: column; background: #070d18;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
.live.focus .focus-open { display: none; }
.live.focus .focus-close { display: inline-grid; }
.live.focus .end-btn { padding: .7rem 1.2rem; font-size: 1rem; }
.live.focus .live-head { margin-bottom: 1rem; }
.live.focus .live-person { font-size: clamp(1.2rem, 3.5vmin, 2rem); }
.live.focus .live-grid { flex: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: clamp(.5rem, 1.5vmin, 1rem); }
.live.focus .live-grid > div { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: .5rem; }
.live.focus .live-value { font-size: clamp(2.4rem, min(16vmin, 11vw), 11rem); }
.live-label small { opacity: .7; }
.live-value small { font-size: .45em; font-weight: 600; opacity: .75; }
.live-value .approx { margin-right: .15em; }
.live-value .unit { margin-left: .2em; }
/* Trend der Schlagfrequenz zum Sitzungsdurchschnitt */
.live-value .trend { display: inline-block; font-size: .36em; font-weight: 700; vertical-align: .55em; margin-left: .45em; padding: .2em .5em; border-radius: 8px; line-height: 1.2; }
.trend.up { background: rgba(14, 165, 164, .2); color: #5eead4; }
.trend.down { background: rgba(245, 158, 11, .2); color: #fcd34d; }
[data-field="spm-avg"] { white-space: nowrap; }
.trend.flat { background: rgba(138, 154, 184, .18); color: var(--muted); }
.live.focus .live-label { font-size: clamp(.9rem, 2.4vmin, 1.4rem); }
.live.focus .small { font-size: clamp(.85rem, 2vmin, 1.1rem); text-align: center; margin: .6rem 0 0; }
body.has-focus { overflow: hidden; }

/* Installierte App im Vollbild: Platz für Notch/Statusleiste */
.is-app .topbar { padding-top: max(.6rem, env(safe-area-inset-top)); }

/* Tablet hochkant und Handy */
@media (max-width: 820px) {
  .mainnav, .logout { display: none; }
  .topbar { justify-content: space-between; }
  .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(11, 18, 32, .96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: .3rem max(.3rem, env(safe-area-inset-right)) max(.3rem, env(safe-area-inset-bottom)) max(.3rem, env(safe-area-inset-left)); }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .45rem 0; color: var(--muted); text-decoration: none; font-size: .75rem; border-radius: 10px; }
  .bottomnav a.active { color: var(--text); background: var(--panel-2); }
  .bottomnav .icon { width: 1.5rem; height: 1.5rem; }
  .container { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  .footer { display: none; }
}


/* Handy */
@media (max-width: 600px) {
  .chart .tick { font-size: 22px; }
  body { font-size: 15px; }
  h1 { font-size: 1.35rem; }
  .container { padding-top: .8rem; }
  .card { padding: .9rem; }
  .session-row { grid-template-columns: 1fr; gap: .3rem; }
  .session-stats { justify-content: flex-start; gap: .9rem; }
  .live-grid { gap: .5rem; }
  .live-grid > div { padding: .55rem .7rem; }
  .live-value { font-size: 2rem; }
  .live-head { flex-wrap: wrap; }
  .live-actions { margin-left: 0; width: 100%; }
  .live-actions .focus-open, .live-actions .end-form { flex: 1; }
  .live-actions .btn { width: 100%; white-space: nowrap; padding: .55rem .5rem; }
  .live.focus .live-actions { width: auto; margin-left: auto; }
  .live.focus .live-actions .end-form { flex: none; }
  .person-tiles { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .tile { min-height: 112px; padding: .8rem .4rem; }
  .tile-initial { width: 46px; height: 46px; font-size: 1.25rem; }
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .stat-value { font-size: 1.3rem; }
  .table th, .table td { padding: .6rem .6rem; }
  .form.inline { display: block; }
  .form.inline label { margin-bottom: .8rem; }
  .facts { grid-template-columns: 1fr; }
  .facts dd { margin-bottom: .4rem; }
}

