/* =====================================================================
   Darstellung (Einfach / Komplex), Navigation, Dashboard, Karten-Zoom
   Wird nach styles.css geladen. "Komplex" ist die bisherige Optik.
   ===================================================================== */

/* ---------- Hilfsklassen ---------- */
html[data-ui="simple"] .pro-only { display: none !important; }
html:not([data-ui="simple"]) .simple-only { display: none !important; }
body:not([data-tab="pitwall"]) .pitwall-only { display: none !important; }

/* ---------- Navigation: sichtbare Reiter ---------- */
.navtabs { display: flex; align-items: stretch; align-self: stretch; gap: 2px; flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.navtabs::-webkit-scrollbar { display: none; }
.navtabs > button, .navtabs > .navlink, .navgear {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  border: 0; background: none; color: var(--muted); cursor: pointer; text-decoration: none;
  font-weight: 600; font-size: 13.5px; padding: 0 12px; position: relative;
}
.navtabs > button:hover, .navtabs > .navlink:hover, .navgear:hover { color: var(--text); }
.navtabs > button[aria-selected="true"], .navgear[aria-selected="true"] { color: var(--text); }
.navtabs > button[aria-selected="true"]::after, .navgear[aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; background: var(--team); border-radius: 3px 3px 0 0;
}
.navtabs > .navlink { color: var(--muted); }
.navtabs > .navlink span { font-size: 11px; }
.navgear { align-self: stretch; flex: 0 0 auto; }
.navgear > span[aria-hidden] { font-size: 15px; }
.tabs .stable { margin-left: 8px; padding-left: 12px; border-left: 1px solid var(--line); }
.tabs .menu-btn { gap: 6px; }
.menu-seg { margin: 4px 10px 8px; align-self: flex-start; }
.menu-seg button { padding: 3px 14px; font-size: 13px; }
@media (max-width: 1250px) { .navgear-l { display: none; } .tabs .stable { display: none; } }

/* ---------- Karte verschieben/zoomen (map-pan.js) ---------- */
canvas.pannable { cursor: grab; }
canvas.pannable.panning { cursor: grabbing; }
.mappan {
  position: absolute; right: 10px; top: 10px; z-index: 5;
  display: flex; flex-direction: column; gap: 4px; align-items: flex-end;
}
.mappan button {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line-2);
  background: color-mix(in srgb, var(--panel-2) 88%, transparent); color: var(--text);
  font-size: 17px; line-height: 1; cursor: pointer; padding: 0; display: grid; place-items: center;
  backdrop-filter: blur(6px);
}
.mappan button:hover { border-color: var(--muted); }
.mappan button[aria-pressed="true"] { background: var(--team); border-color: var(--team); color: #000; }
.mappan [data-mp="reset"] { visibility: hidden; }
.mappan[data-changed="1"] [data-mp="reset"] { visibility: visible; }
.mappan-hint { font-size: 11px; color: var(--muted); background: color-mix(in srgb, var(--panel) 85%, transparent); padding: 1px 6px; border-radius: 6px; white-space: nowrap; opacity: 0; transition: opacity .2s; pointer-events: none; }
.mappan:hover .mappan-hint, canvas.pannable:hover ~ .mappan .mappan-hint { opacity: 1; }
html:not([data-ui="simple"]) .mappan button { border-radius: 2px; }

/* ---------- Auswahl der Darstellung (Erststart und Einstellungen) ---------- */
.um-dlg {
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text);
  padding: 0; border-radius: 18px; width: min(860px, 94vw); max-height: 92vh; overflow: auto;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.um-dlg::backdrop { background: rgba(4, 6, 10, .78); backdrop-filter: blur(4px); }
.um-inner { padding: 28px 28px 24px; }
.um-head { margin-bottom: 20px; }
.um-brand { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--team); }
.um-head h2 { margin: 6px 0 6px; font-size: 26px; line-height: 1.15; }
.um-head p { margin: 0; color: var(--muted); }
.um-foot { display: flex; justify-content: flex-end; margin-top: 18px; }
.um-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 640px) { .um-pick { grid-template-columns: 1fr; } }
.um-card {
  display: flex; flex-direction: column; gap: 10px; text-align: left; cursor: pointer;
  background: var(--panel-2); border: 2px solid var(--line-2); border-radius: 14px; padding: 14px; color: var(--text);
  transition: border-color .15s, transform .15s, background .15s; position: relative;
}
.um-card:hover { border-color: var(--muted); transform: translateY(-2px); }
.um-card[aria-checked="true"] { border-color: var(--team); background: color-mix(in srgb, var(--team) 8%, var(--panel-2)); }
.um-name { font-size: 20px; font-weight: 700; display: flex; flex-direction: column; line-height: 1.15; }
.um-name small { font-size: 13px; font-weight: 600; color: var(--muted); }
.um-text { font-size: 13px; color: var(--muted); line-height: 1.45; }
.um-on { position: absolute; top: 22px; right: 22px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--team); color: #000; padding: 2px 8px; border-radius: 999px; display: none; }
.um-card[aria-checked="true"] .um-on { display: block; }
/* kleine Vorschau-Bilder */
.um-prev { height: 132px; border-radius: 10px; padding: 8px; display: grid; gap: 6px; }
.um-prev i { display: block; }
.um-prev-simple { background: #0c1016; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(3, 1fr); }
.um-prev-simple i { background: #1b222c; border-radius: 6px; border: 1px solid #28313d; }
.um-prev-simple i.w2 { grid-column: span 2; }
.um-prev-simple i.h2 { grid-row: span 2; background: radial-gradient(ellipse 45% 32% at 50% 50%, transparent 62%, #3a4656 64% 70%, transparent 72%), #1b222c; }
.um-prev-simple i:nth-child(2) { background: linear-gradient(#1b222c 55%, transparent 55%), linear-gradient(90deg, var(--team) 60%, #28313d 60%) 8px 75% / calc(100% - 16px) 5px no-repeat, #1b222c; }
.um-prev-pro { background: #000; grid-template-columns: 1fr 1.6fr 1fr; grid-template-rows: repeat(3, 1fr); gap: 2px; padding: 2px; }
.um-prev-pro i { background: repeating-linear-gradient(#07090c 0 5px, #121820 5px 6px); }
.um-prev-pro i.c2 { background: #07090c; }
.um-prev-pro i.c2.s { background: repeating-linear-gradient(90deg, #07090c 0 9px, #1d2630 9px 10px); }
.um-prev-pro i:first-child { border-top: 2px solid var(--team); }
.set-look { margin-bottom: 14px; max-width: 1600px; }
.set-look .um-pick { max-width: 860px; margin-top: 10px; }
.set-look .um-prev { height: 110px; }

/* =====================================================================
   Darstellung "Einfach": ruhiger, runder, größer
   ===================================================================== */
html[data-ui="simple"] {
  --bg: #0b0f14;
  --panel: #131920;
  --panel-2: #1a212a;
  --panel-3: #222b35;
  --line: #222a34;
  --line-2: #2f3945;
  --text: #eef2f6;
  --muted: #95a1af;
  --dim: #5f6b79;
  --tabs-h: 50px;
  --top-h: 74px;
}
html[data-ui="simple"] body { font-size: 15px; }
html[data-ui="simple"] .top { border-bottom-width: 4px; }
html[data-ui="simple"] .t-weather, html[data-ui="simple"] .t-src, html[data-ui="simple"] .t-sub2:empty { display: none; }
html[data-ui="simple"] .t-cell { padding: 0 22px; }
html[data-ui="simple"] .t-clock .t-big { font-size: 38px; }
html[data-ui="simple"] .flagbox { border-radius: 999px; padding: 3px 16px; }
html[data-ui="simple"] .tabs { padding: 0 14px; gap: 8px; }
html[data-ui="simple"] .navtabs { gap: 4px; align-self: center; height: 36px; }
html[data-ui="simple"] .navtabs > button, html[data-ui="simple"] .navtabs > .navlink, html[data-ui="simple"] .navgear {
  border-radius: 999px; padding: 0 16px; font-size: 14.5px;
}
html[data-ui="simple"] .navgear { align-self: center; height: 36px; }
html[data-ui="simple"] .navtabs > button[aria-selected="true"], html[data-ui="simple"] .navgear[aria-selected="true"] { background: var(--panel-3); }
html[data-ui="simple"] .navtabs > button[aria-selected="true"]::after, html[data-ui="simple"] .navgear[aria-selected="true"]::after { display: none; }
html[data-ui="simple"] .btn { border-radius: 10px; }
html[data-ui="simple"] .seg { border-radius: 10px; }
html[data-ui="simple"] .menu-pop, html[data-ui="simple"] .sesnav-pop { border-radius: 14px; padding: 8px; }
html[data-ui="simple"] .menu-pop > button { border-radius: 8px; border-left: 0; }
html[data-ui="simple"] .mon { border-radius: 14px; border: 1px solid var(--line); }
html[data-ui="simple"] .page.active { padding: 18px 20px 48px; }
html[data-ui="simple"] .dlg { border-radius: 14px; }
html[data-ui="simple"] input, html[data-ui="simple"] select, html[data-ui="simple"] textarea { border-radius: 8px; }

/* ---------- Dashboard ---------- */
.dash-view.active { display: block; }
.dash-scroll { height: 100%; overflow: auto; padding: 18px 20px 48px; }
.dash {
  /* Blockraster: Spaltenzahl, Blockbreite und -höhe setzt dash.js aus der Pixelbreite (immer 4, unter 700 px 2) */
  --cols: 4; --row: 170px; --gap: 14px; --colw: 300px;
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-auto-rows: var(--row); grid-auto-flow: row dense; gap: var(--gap);
  margin: 0 auto; position: relative;
}
@media (max-width: 680px) { .dash-scroll { padding: 12px 12px 40px; } }
/* Beim Anpassen das leere Raster sichtbar machen */
body.dash-editing .dash, body.dash-resizing .dash {
  background-image: linear-gradient(color-mix(in srgb, var(--panel-2) 70%, transparent), color-mix(in srgb, var(--panel-2) 70%, transparent));
  background-size: var(--colw) var(--row);
  background-repeat: space;
  border-radius: 18px;
}

.dcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; overflow: hidden;
  container-type: size;
  transition: border-color .2s, box-shadow .2s, opacity .2s;
}
.dcard[data-level="warn"] { border-color: color-mix(in srgb, var(--yellow) 55%, var(--line)); }
.dcard[data-level="crit"] { border-color: var(--red); box-shadow: 0 0 0 1px var(--red), 0 0 28px rgba(255, 59, 48, .18); }
.dcard-h { display: flex; align-items: center; gap: 6px; padding: 12px 14px 2px 10px; cursor: grab; user-select: none; -webkit-user-select: none; min-height: 40px; }
.dcard-h h2 { margin: 0; font-size: 12.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dcard-grip {
  border: 0; background: none; color: var(--dim); cursor: grab; font-size: 15px; line-height: 1;
  width: 22px; height: 26px; padding: 0; border-radius: 6px; opacity: .35; transition: opacity .15s, background .15s; touch-action: none;
}
.dcard:hover .dcard-grip, .dcard-grip:focus-visible, body.dash-editing .dcard-grip { opacity: 1; }
.dcard-grip:hover { background: var(--panel-3); color: var(--text); }
@media (hover: none) { .dcard-grip { opacity: .9; } .dcard-h { cursor: default; } }
.dcard-x { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dcard-edit { display: none; gap: 6px; margin-left: 8px; flex: 0 0 auto; }
body.dash-editing .dcard-edit { display: inline-flex; }
body.dash-editing .dcard { outline: 1px dashed var(--line-2); outline-offset: 3px; }
.dcard-edit .ibtn { font-size: 12px; padding: 2px 8px; border-radius: 8px; }
.dcard-b { padding: 8px 18px 18px; flex: 1; display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.dcard.dragging { opacity: .35; outline: 2px dashed var(--team); outline-offset: -2px; }
.dcard.dragging > * { visibility: hidden; }
.dcard-ghost {
  position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; margin: 0;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 0 0 2px var(--team); opacity: .96; cursor: grabbing;
}
body.dash-dragging, body.dash-dragging * { cursor: grabbing !important; user-select: none; }

.dash-edit {
  margin: 0 0 16px; padding: 14px 18px; border-radius: 16px;
  background: color-mix(in srgb, var(--team) 9%, var(--panel)); border: 1px solid color-mix(in srgb, var(--team) 40%, var(--line));
  display: flex; gap: 18px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap;
}
.dash-edit p { margin: 4px 0 10px; }
.dash-edit .row { display: flex; gap: 8px; }
.d-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.d-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-2); font-size: 13px; cursor: pointer; }
.d-chip:has(input:checked) { border-color: var(--team); }

/* Inhalt der Karten */
.d-note { margin: 0; font-size: 13px; color: var(--muted); }
.d-note:empty { display: none; }
.d-note.bad { color: var(--orange); }
.d-hero { display: flex; align-items: baseline; gap: 10px 14px; flex-wrap: wrap; }
.d-hero-l { color: var(--muted); font-size: 15px; }
.d-hero-v { font-size: clamp(26px, min(15cqw, 17cqh), 96px); font-weight: 700; line-height: .95; letter-spacing: -.02em; }
.d-hero-s { color: var(--muted); font-size: 14px; line-height: 1.3; }
.dcard[data-card="stop"] .d-hero { flex-direction: column; gap: 4px; }
.dcard[data-card="stop"] .d-hero-s { font-size: 16px; color: var(--text); font-weight: 600; }
.dcard[data-level="crit"] .d-hero-v { color: var(--red); }
.dcard[data-level="warn"] .d-hero-v { color: var(--yellow); }
.d-full { width: 100%; justify-content: center; }

.d-kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; margin: 0; }
.d-kv dt { font-size: 12px; color: var(--muted); }
.d-kv dd { margin: 0; font-size: 16px; font-weight: 700; }

.d-bars { display: grid; gap: 12px; }
.d-bar { display: grid; grid-template-columns: 64px 1fr auto; grid-template-rows: auto auto; align-items: center; gap: 2px 12px; }
.d-bar > span { font-size: 13px; color: var(--muted); }
.d-bar > b { font-size: 16px; }
.d-bar > small { grid-column: 2 / 4; font-size: 12px; color: var(--dim); }
.d-bar-t { height: 10px; background: var(--panel-3); border-radius: 999px; overflow: hidden; }
.d-bar-t i { display: block; height: 100%; background: var(--team); border-radius: 999px; transition: width .4s; }
.d-bar-t i.warn { background: var(--yellow); }
.d-bar-t i.crit { background: var(--red); }

.d-gaps { display: grid; gap: 8px; }
.d-gap { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); }
.d-gap-l { font-size: 12px; color: var(--muted); }
.d-gap-car { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.d-gap-car .cb { width: 4px; height: 16px; border-radius: 2px; flex: 0 0 auto; }
.d-gap-v { font-size: clamp(16px, min(6cqw, 7cqh), 34px); }
.d-gap.ahead .d-gap-v { color: var(--text); }
.d-gap.behind .d-gap-v { color: var(--muted); }
.d-gap.me { background: color-mix(in srgb, var(--team) 14%, var(--panel-2)); box-shadow: inset 3px 0 0 var(--team); padding: 7px 12px; }
.d-gap.none { grid-template-columns: 76px 1fr; }

.d-tyres { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: 1; }
.d-tyre { position: relative; overflow: hidden; border-radius: 12px; background: var(--panel-2); padding: 10px 12px; display: flex; flex-direction: column; justify-content: space-between; min-height: 70px; }
.d-tyre > span { font-size: 12px; color: var(--muted); position: relative; z-index: 1; }
.d-tyre > b { font-size: clamp(18px, min(8cqw, 8cqh), 52px); line-height: 1; position: relative; z-index: 1; }
.d-tyre > b small { font-size: 14px; color: var(--muted); margin-left: 2px; }
.d-tyre > i { position: absolute; left: 0; right: 0; bottom: 0; background: color-mix(in srgb, var(--green) 16%, transparent); transition: height .4s; }
.d-tyre.warn > i { background: color-mix(in srgb, var(--yellow) 22%, transparent); }
.d-tyre.crit > i { background: color-mix(in srgb, var(--red) 28%, transparent); }
.d-tyre.warn > b { color: var(--yellow); }
.d-tyre.crit > b { color: var(--red); }

.d-radio { display: grid; grid-template-columns: 1fr; gap: 16px; flex: 1; min-height: 0; }
@container (min-width: 560px) { .d-radio { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
.d-radio-l { display: flex; flex-direction: column; gap: 10px; }
.d-boxbox { font-size: 20px; padding: 10px; justify-content: center; border-radius: 12px; }
.d-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.d-quick .btn { font-size: 13px; padding: 4px 10px; }
.d-say { display: flex; gap: 6px; }
.d-say input { flex: 1; min-width: 0; padding: 8px 12px; background: var(--panel-2); border: 1px solid var(--line-2); }
.d-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; overflow: auto; max-height: 260px; }
.d-log li { display: grid; grid-template-columns: 62px 1fr; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); font-size: 13.5px; }
.d-log li .when { color: var(--dim); font-family: var(--f-mono); font-size: 11.5px; padding-top: 2px; }
.d-log li.urgent > span:last-child { color: var(--red); font-weight: 700; }
.d-log li .from { color: var(--muted); }
.d-log li.empty-li { background: none; }

.d-trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.d-trio > div { background: var(--panel-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.d-trio span { font-size: 12px; color: var(--muted); }
.d-trio b { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-chart svg { width: 100%; height: 64px; display: block; border-radius: 8px; }
.d-lapform { display: flex; gap: 6px; flex-wrap: wrap; }
.d-lapform input { flex: 1 1 90px; min-width: 0; padding: 6px 10px; background: var(--panel-2); border: 1px solid var(--line-2); }

.d-class { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.d-class li { display: grid; grid-template-columns: 26px 36px minmax(0, 1fr) auto 78px; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 9px; font-size: 14px; }
.d-class li:nth-child(odd) { background: var(--panel-2); }
.d-class li.me { background: color-mix(in srgb, var(--team) 18%, var(--panel-2)); box-shadow: inset 3px 0 0 var(--team); font-weight: 700; }
.d-class .p { color: var(--muted); font-weight: 700; }
.d-class .n { color: var(--muted); font-size: 12.5px; }
.d-class .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-class .g { text-align: right; font-size: 13px; }
.d-class .st.box { font-size: 10px; font-weight: 700; color: #000; background: var(--yellow); border-radius: 4px; padding: 0 5px; }
.d-class li.empty-li { display: block; background: none; }

.d-car { display: flex; gap: 16px; align-items: center; }
.d-car-svg { width: 74px; flex: 0 0 74px; }
.d-car-svg:empty { display: none; }
.d-car-svg svg { width: 100%; height: auto; display: block; }
.d-car-state { display: block; font-size: 18px; margin-bottom: 10px; }
.d-st.ok { color: var(--green); }
.d-st.warn { color: var(--yellow); }
.d-st.bad { color: var(--red); }

.d-wx .d-trio b { font-size: 21px; }
.d-fc { margin: 4px 0 0; font-size: 14px; color: var(--text); background: var(--panel-2); border-radius: 10px; padding: 8px 12px; }

.d-map { flex: 1; min-height: 120px; border-radius: 12px; overflow: hidden; background: var(--panel-2); }
.dcard[data-card="map"] .dcard-b { padding: 6px 10px 10px; }
.d-map .rc { max-width: min(420px, 75%); }

/* Einzelfenster (?panel=…): immer bildschirmfüllend, auch in schmalen Fenstern (vorher fiel die Karte dort auf 0 Pixel zusammen) */
body[data-solo] main { height: 100vh !important; overflow: hidden; }
body[data-solo] .view.active { height: 100% !important; }
body[data-solo] .col { min-height: 0 !important; }
body[data-solo] .mon-map { min-height: 0 !important; }
body[data-solo] .row-bottom[data-all-collapsed="1"] { display: none !important; }
.dcard-pop { flex: 0 0 auto; padding: 0 7px; border-radius: 8px; }

/* Größe ändern: Ecke unten rechts */
.dcard-rs {
  position: absolute; right: 0; bottom: 0; width: 26px; height: 26px; cursor: nwse-resize; z-index: 6; touch-action: none;
  opacity: 0; transition: opacity .15s;
  background: linear-gradient(135deg, transparent 55%, var(--muted) 55% 61%, transparent 61% 70%, var(--muted) 70% 76%, transparent 76%);
  border-bottom-right-radius: 18px;
}
.dcard:hover .dcard-rs, body.dash-editing .dcard-rs, .dcard.resizing .dcard-rs { opacity: 1; }
@media (hover: none) { .dcard-rs { opacity: .8; } }
.dcard.resizing { outline: 2px solid var(--team); outline-offset: -2px; z-index: 3; }
body.dash-resizing, body.dash-resizing * { cursor: nwse-resize !important; user-select: none; }
.dcard-sz { display: none; font-family: var(--f-mono); font-size: 13px; color: var(--team); font-weight: 700; align-self: center; padding: 0 4px; white-space: nowrap; }
.dcard.resizing .dcard-sz { display: inline; }
.dcard-hide { width: 26px; padding: 0 !important; }
.dcard.resizing .dcard-edit { display: inline-flex; }
.dcard.resizing .dcard-hide { display: none; }
