/* OpenRide — donker thema, leesbaar vanaf de fiets op 1,5 meter afstand. */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2230;
  --line: #262d3a;
  --text: #e6edf3;
  --dim: #8b98a8;
  --accent: #ffc454;
  --accent-2: #4a9eff;
  --green: #4caf72;
  --red: #e05f5f;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h2 { font-size: 15px; margin: 0 0 12px; letter-spacing: .02em; }
h3 { font-size: 13px; margin: 0; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand span { letter-spacing: .04em; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button {
  background: none; border: none; color: var(--dim);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.tabs button:hover { background: var(--panel-2); color: var(--text); }
.tabs button.active { background: var(--panel-2); color: var(--text); font-weight: 600; }

.chips { display: flex; gap: 6px; }
.chip {
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2); white-space: nowrap;
}
.chip.on { border-color: var(--green); color: #8fe0ac; }
.chip.off { color: var(--dim); opacity: .65; }

/* ---------- layout ---------- */
main { padding: 18px; max-width: 1180px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.grid-2 .card { margin-bottom: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.card-head .right { color: var(--dim); }

/* ---------- knoppen ---------- */
button, .btn {
  font: inherit; font-size: 13px;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  transition: background .12s, border-color .12s;
}
button:hover:not(:disabled), .btn:hover { background: #262d3a; }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary { background: var(--accent); color: #1a1205; border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled) { background: #ffd074; }
button.ghost { background: transparent; }
button.danger { color: var(--red); border-color: #46262b; }
button.danger:hover { background: #2a1a1d; }
button.big { padding: 14px 32px; font-size: 16px; }
button.small { padding: 4px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; align-items: center; }
.btn-row.tight { margin: 0; }
.btn.file { display: inline-block; }
.spacer { flex: 1; }

.segmented { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { border: none; border-radius: 0; flex: 1; background: transparent; }
.segmented button.active { background: var(--accent-2); color: #041020; font-weight: 600; }

/* ---------- formulieren ---------- */
.field { display: block; margin-bottom: 12px; color: var(--dim); font-size: 12px; }
.field input, .field select {
  display: block; width: 100%; margin-top: 4px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px;
  font: inherit;
}
.field-row { margin-top: 14px; }
.field-row label { display: flex; justify-content: space-between; color: var(--dim); font-size: 12px; }
.field-row .value { color: var(--text); font-family: ui-monospace, monospace; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 6px 0 2px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12px; margin-top: 8px; }
.listbox {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 4px; font: inherit;
}
.listbox option { padding: 6px 8px; border-radius: 5px; }
textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  font-family: ui-monospace, monospace; font-size: 13px; resize: vertical;
}
select.mini { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-size: 12px; }
.mini-field { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12px; }
.mini-field input[type=range] { width: 130px; margin: 0; }

.hint { color: var(--dim); font-size: 12px; margin: 6px 0; }
.status { font-size: 12px; color: var(--dim); min-height: 18px; margin-top: 6px; }
.status.ok { color: #8fe0ac; }
.status.err { color: var(--red); }
details summary { cursor: pointer; color: var(--dim); font-size: 12px; margin-top: 10px; }
pre { overflow-x: auto; background: var(--bg); padding: 8px; border-radius: 6px; margin: 8px 0 0; }

/* ---------- canvas ---------- */
canvas.profile { width: 100%; height: 130px; display: block; margin: 12px 0 8px; background: var(--bg); border-radius: 8px; }
canvas.profile.tall { height: 190px; }
canvas.chart { width: 100%; height: 170px; display: block; background: var(--bg); border-radius: 8px; }
canvas.workoutbar { width: 100%; height: 90px; display: block; background: var(--bg); border-radius: 8px; margin-top: 10px; }

.stat-line { display: flex; flex-wrap: wrap; gap: 6px 20px; color: var(--dim); font-size: 12px; margin-top: 8px; }
.stat-line b { color: var(--text); font-weight: 600; font-family: ui-monospace, monospace; }
.big-stats { font-size: 14px; gap: 10px 32px; }

/* ---------- ritweergave ---------- */
.metrics {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px;
}
@media (max-width: 820px) { .metrics { grid-template-columns: repeat(2, 1fr); } }
.metric {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; min-width: 0;
}
.metric .label { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .07em; }
.metric .val { font-size: 38px; line-height: 1.05; font-weight: 600; font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.metric .unit { font-size: 11px; color: var(--dim); }
.metric .sub { font-size: 11px; color: var(--dim); margin-top: 2px; font-family: ui-monospace, monospace; }
.big-metric {
  grid-column: span 2; grid-row: span 2;
  background: linear-gradient(135deg, #1b2230, #161b22);
  justify-content: center;
}
.big-metric .val { font-size: 92px; color: var(--accent); }
@media (max-width: 820px) {
  .big-metric { grid-column: span 2; grid-row: span 1; }
  .big-metric .val { font-size: 52px; }
}

.erg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.erg-head .label { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .07em; display: block; }
.erg-watts { font-size: 30px; font-weight: 600; font-family: ui-monospace, monospace; color: var(--accent-2); }
.erg-remaining { font-size: 15px; color: var(--dim); font-family: ui-monospace, monospace; margin-left: 10px; }
.bias { color: var(--dim); font-size: 12px; }

.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.empty { text-align: center; padding: 60px 20px; color: var(--dim); }
.empty button { margin-top: 12px; }

.start-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.start-summary { color: var(--dim); font-size: 13px; }
.start-summary b { color: var(--text); }

/* ---------- tabellen ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--dim); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel-2); }
td.num, th.num { text-align: right; font-family: ui-monospace, monospace; }

/* ---------- dialogen ---------- */
dialog {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; max-width: 620px; width: calc(100% - 40px);
}
dialog::backdrop { background: rgba(0, 0, 0, .65); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 999px; z-index: 50; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.toast.err { border-color: var(--red); color: #ffb0b0; }


/* ---------- wereldweergave ---------- */
.world-card { padding: 0; overflow: hidden; position: relative; background: #0a0d12; }
canvas.world { width: 100%; height: 390px; display: block; }
/* De stapeling van het WebGL-doek en het 2D-doek staat in world.js, niet hier.
   Eén plek die dat regelt: anders kan een oude stylesheet uit de cache het
   WebGL-doek in de tekststroom zetten en het beeld naar beneden duwen. */

.world-card:fullscreen { border-radius: 0; border: none; }
.world-card:fullscreen canvas.world { height: 100vh; }
.check.tight { margin-top: 0; white-space: nowrap; }

.listbox optgroup { color: var(--dim); font-size: 11px; font-style: normal; padding-top: 4px; }
.listbox optgroup option { color: var(--text); font-size: 13px; }
.stat-line .muted { color: var(--dim); font-weight: 400; font-family: inherit; }

.mini-field select.mini, .mini-field input.mini { margin: 0; }
.mini-field input[type=number].mini { width: 62px; padding: 3px 6px; background: var(--bg);
  color: var(--text); border: 1px solid var(--line); border-radius: 6px; font-size: 12px; }

/* ---------- tegenstander ---------- */
.opponent-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.opp-gap { font-size: 34px; font-weight: 600; font-family: ui-monospace, monospace; display: block; }
.opp-gap.ahead { color: #4caf72; }
.opp-gap.behind { color: var(--red); }
.opp-sub { font-size: 12px; color: var(--dim); font-family: ui-monospace, monospace; }
.opp-right { text-align: right; }
.opp-finish { font-size: 22px; font-weight: 600; font-family: ui-monospace, monospace; display: block; }
.opp-bar { position: relative; height: 6px; background: var(--panel-2); border-radius: 3px; margin-top: 12px; }
.opp-bar::before { content: ''; position: absolute; left: 50%; top: -3px; width: 2px; height: 12px;
  background: rgba(255,255,255,0.35); }
.opp-marker { position: absolute; top: -3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); transform: translateX(-50%); transition: left .25s linear; left: 50%; }

/* ---------- analyse achteraf ---------- */
.curve { display: flex; flex-direction: column; gap: 4px; }
.curve-row { display: grid; grid-template-columns: 52px 1fr 60px 62px; align-items: center; gap: 8px;
  font-size: 12px; font-family: ui-monospace, monospace; }
.curve-label { color: var(--dim); }
.curve-bar { background: var(--panel-2); height: 14px; border-radius: 3px; overflow: hidden; }
.curve-bar i { display: block; height: 100%; background: linear-gradient(90deg,#8a6a20,var(--accent)); }
.curve-val { text-align: right; font-weight: 600; }
.curve-wkg { text-align: right; color: var(--dim); }
.zone-bar { display: flex; height: 16px; border-radius: 4px; overflow: hidden; margin-top: 6px; }
.zone-bar i { display: block; height: 100%; }
.zone-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px;
  font-size: 11px; color: var(--dim); font-family: ui-monospace, monospace; }
.zone-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.ftp-voorstel { margin-top: 16px; padding: 12px 14px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.ftp-voorstel button { margin-left: 10px; }

.world-buttons { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.world-buttons button { background: rgba(0, 0, 0, .45); border-color: rgba(255, 255, 255, .18);
  color: #fff; font-size: 12px; padding: 5px 10px; backdrop-filter: blur(3px); }
