:root {
  --bg: #f4f4f6; --panel: #fff; --text: #16161a; --muted: #6b6b76; --line: #e2e2e8;
  --accent: #ff3c14; --purple: #9b30d9; --green: #1f9d55; --red: #d92d20;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111114; --panel: #1c1c21; --text: #f2f2f5; --muted: #9a9aa6; --line: #2e2e36; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
header { display: flex; align-items: center; gap: 24px; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1000; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; }
nav { display: flex; gap: 16px; align-items: center; flex: 1; flex-wrap: wrap; }
nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
nav a.active { color: var(--accent); }
nav .spacer { flex: 1; }
main { max-width: 1320px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 26px; margin: 4px 0 16px; }
h2 { font-size: 18px; margin: 24px 0 10px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; color: inherit; text-decoration: none; display: block; }
.card img { width: 100%; height: 150px; object-fit: cover; display: block; background: #333; }
.card .body { padding: 12px 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
tr.click { cursor: pointer; }
tr.click:hover td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
tr.selected td { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.best { color: var(--purple); font-weight: 700; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: #ff9f0a; color: #000; }
button, .btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--red); }
button.active { outline: 2px solid var(--accent); }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); width: 100%; }
a { color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.login { max-width: 360px; margin: 60px auto; }
.error { color: var(--red); margin-top: 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.editor { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
@media (max-width: 860px) { .editor { grid-template-columns: 1fr; } }
.map { height: 620px; border-radius: 12px; border: 1px solid var(--line); }
.map.short { height: 480px; }
.hint { background: #111a; color: #fff; padding: 6px 12px; border-radius: 99px; font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 20px; font-family: ui-monospace, Menlo, monospace; }
.marker { width: 18px; height: 18px; border-radius: 50%; color: #fff; font: 700 11px/18px sans-serif; text-align: center; border: 2px solid #fff; box-shadow: 0 1px 3px #0008; }
.marker.brake { background: var(--red); }
.marker.throttle { background: var(--green); }
.sector-label { background: #ffd60a; color: #000; font-weight: 700; font-size: 11px; padding: 1px 4px; border-radius: 4px; white-space: nowrap; }
.editor.compare { grid-template-columns: minmax(0, 1fr) 360px; }
@media (max-width: 960px) { .editor.compare { grid-template-columns: 1fr; } }
.board { max-height: 900px; overflow: auto; }
.board table td, .board table th { padding: 6px 6px; }
.board .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.board .who-sub { white-space: normal; }
.handle { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 4px #000a; cursor: grab; }
.handle.move { background: var(--accent); color: #fff; font: 700 12px/12px sans-serif; text-align: center; border-color: #fff; }
.handle.dot { width: 10px; height: 10px; border-width: 2px; border-color: #30d158; }
.zoomable { cursor: grab; touch-action: none; user-select: none; }
body.chart-dragging .zoomable { cursor: grabbing; }
.zoomhint { white-space: nowrap; }
@media (max-width: 700px) { .zoomhint { display: none; } }
.kart { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; white-space: nowrap;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.kart-edit { padding: 4px 0; }
.kart-edit .row > input { min-width: 0; }
.kart-row td { background: color-mix(in srgb, var(--accent) 5%, transparent); cursor: default; }
.kart-note { white-space: pre-wrap; color: var(--muted); }
