/* Replay-Seite (replay.html): Aufzeichnung laden, Zeitleiste, Pitwall/Telemetrie als Rahmen, Nachbesprechung. Baut auf styles.css auf. */
body.replay { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
body[data-state="empty"] .loaded-only, body[data-state="loaded"] .empty-only { display: none !important; }
body[data-state="empty"] { overflow: auto; }

/* ---------- Kopf ---------- */
.r-top {
  display: flex; align-items: center; gap: 18px; padding: 0 18px; height: 54px; flex: 0 0 auto;
  background: var(--panel); border-bottom: 3px solid var(--team);
}
.r-brand { display: flex; align-items: baseline; gap: 8px; color: var(--text); text-decoration: none; white-space: nowrap; }
.r-brand b { font-size: 20px; }
.r-brand span { color: var(--team); font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.r-title { min-width: 0; }
.r-h { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-tabs { display: flex; gap: 2px; margin-left: auto; }
.r-tabs button { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 5px 12px; cursor: pointer; font-weight: 600; border-radius: 2px; }
.r-tabs button:hover { color: var(--text); }
.r-tabs button[aria-selected="true"] { color: var(--text); border-color: var(--line-2); background: var(--panel-2); }
.r-right { display: flex; align-items: center; gap: 8px; }
.r-right .small { max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 900px) { .r-right .small, .r-sub { display: none; } }

/* ---------- Laden ---------- */
.r-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.r-load { max-width: 760px; margin: 5vh auto 40px; padding: 0 20px; width: 100%; }
.r-load h1 { margin: 0 0 8px; font-size: 30px; }
.r-load code { font-family: var(--f-mono); font-size: 12px; background: var(--panel-2); padding: 1px 5px; border-radius: 2px; }
.r-drop {
  margin: 22px 0 10px; padding: 34px 20px; text-align: center; cursor: pointer;
  background: var(--panel); border: 2px dashed var(--line-2); border-radius: 4px; display: grid; gap: 6px;
}
.r-drop:hover, .r-drop.over { border-color: var(--team); background: var(--panel-2); }
.r-drop-i { font-size: 28px; color: var(--team); }
.r-err { color: #ff9c95; }
.r-last { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); margin: 14px 0; }
.r-last b { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-local { margin-top: 26px; }
.r-local h2 { font-size: 18px; margin: 0 0 4px; }
.r-list { display: grid; gap: 6px; margin-top: 10px; }
.r-item { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "t b" "s b"; gap: 4px 14px; align-items: center; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--team); }
.r-item b { font-size: 15px; grid-area: t; }
.r-item .l2 { color: var(--muted); font-size: 12px; grid-area: s; }
.r-item .btn { grid-area: b; }
.r-how { margin-top: 28px; }
a { color: var(--team); }

/* ---------- Rahmen ---------- */
.r-view { flex: 1 1 auto; min-height: 0; position: relative; }
.r-frames { position: absolute; inset: 0; }
.r-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg); display: none; }
body[data-view="pitwall"] .r-frame[data-frame="pitwall"], body[data-view="telemetry"] .r-frame[data-frame="telemetry"] { display: block; }
.r-debrief { position: absolute; inset: 0; overflow: auto; padding: 16px 18px 30px; display: none; }
body[data-view="debrief"] .r-debrief { display: block; }

/* ---------- Zeitleiste ---------- */
.r-bar {
  flex: 0 0 auto; display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 16px;
  padding: 8px 14px; background: var(--panel); border-top: 1px solid var(--line-2);
}
.r-ctrl { display: flex; align-items: center; gap: 6px; }
.r-ctrl .ibtn { height: 30px; min-width: 34px; font-size: 14px; }
.r-play { background: var(--team) !important; color: #000 !important; border-color: var(--team) !important; font-weight: 700; min-width: 40px !important; }
.r-rate { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 2px; height: 30px; padding: 0 6px; }
.r-lap { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.r-lap input { width: 60px; height: 30px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 2px; padding: 0 6px; }
.r-time { font-size: 18px; white-space: nowrap; display: flex; align-items: baseline; gap: 2px; }
.r-time-sub { margin-left: 10px; font-family: var(--f-ui); }
.r-timeline { position: relative; min-width: 0; }
.r-timeline canvas { width: 100%; height: 54px; display: block; cursor: pointer; }
.r-tip { position: absolute; bottom: 58px; transform: translateX(-50%); background: var(--panel-3); border: 1px solid var(--line-2); padding: 4px 8px; font-size: 12px; white-space: nowrap; pointer-events: none; z-index: 2; }
@media (max-width: 1100px) {
  .r-bar { grid-template-columns: 1fr 1fr; }
  .r-timeline { grid-column: 1 / -1; }
}

/* ---------- Nachbesprechung ---------- */
.d-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.d-tile { background: var(--panel); border: 1px solid var(--line); padding: 8px 12px; }
.d-tile .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.d-tile .v { font: 600 20px/1.3 var(--f-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-tile .v.txt { font-family: var(--f-ui); font-size: 16px; }
.d-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px; }
.d-box { background: var(--panel); border: 1px solid var(--line); min-width: 0; display: flex; flex-direction: column; grid-column: span 6; }
.d-box header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.d-box h2 { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; }
.d-chart { grid-column: span 8; }
.d-chart canvas { width: 100%; height: 260px; display: block; cursor: crosshair; }
.d-chart .small { padding: 4px 12px 8px; }
.d-cars { display: flex; gap: 10px; flex-wrap: wrap; }
.d-cars label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.d-cars label i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--c); }
.d-box:nth-child(2) { grid-column: span 4; }
.d-laps { grid-column: span 12; }
.d-scroll { overflow: auto; max-height: 420px; }
.d-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.d-table th, .d-table td { padding: 5px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.d-table th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; position: sticky; top: 0; background: var(--panel); }
.d-table th:first-child, .d-table td:first-child { text-align: left; }
.d-table tr[data-t] { cursor: pointer; }
.d-table tr[data-t]:hover td { background: var(--panel-2); }
.d-table tr.best td { color: var(--purple); }
.d-table tr.pit td { color: var(--muted); font-style: italic; }
.d-table tr.now td { background: var(--panel-3); }
.d-list { list-style: none; margin: 0; padding: 4px 0; }
.d-list li { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 5px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.d-list li:hover { background: var(--panel-2); }
.d-list .when { font-family: var(--f-mono); color: var(--muted); font-size: 12px; }
.d-list .from { color: var(--team); }
.d-list .eng .from { color: var(--purple); }
.d-list .k { display: inline-block; min-width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--c, var(--muted)); vertical-align: middle; }
@media (max-width: 1000px) {
  .d-box, .d-chart, .d-box:nth-child(2) { grid-column: span 12; }
}
.d-table td.d-tel { padding-top: 2px; padding-bottom: 2px; }
.d-tel .ibtn { height: 22px; font-size: 11px; padding: 0 8px; }
