/* ---------------------------------------------------------------------
   Komponenten
   --------------------------------------------------------------------- */

/* ---- Karten, Überschriften ---- */
.card {
  background: var(--md-sys-color-surface-container-high);
  border-radius: 12px; padding: 16px; margin-bottom: 12px; border: none;
}
.card-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
              color: var(--md-sys-color-on-surface-variant); margin-bottom: 8px; }
.section-title { font-size: 11px; font-weight: 700; color: var(--md-sys-color-on-surface-variant);
                 text-transform: uppercase; letter-spacing: 1px;
                 margin-bottom: 10px; margin-top: 20px; }
.section-title:first-child { margin-top: 0; }
/* Puls der Karte des aktiven Fahrers (Einsätze), Farbe aus --rc */
@keyframes slotPulse {
  0%, 100% { background: color-mix(in srgb, var(--rc) 15%, transparent); }
  50%       { background: color-mix(in srgb, var(--rc) 40%, transparent); }
}
.is-pulsing { animation: slotPulse 1.85s ease-in-out infinite; box-shadow: 0 0 8px 2px var(--rc); }

/* ---- Buttons (JS-erzeugtes HTML; Material-Web-Buttons haben eigene Styles) ---- */
.btn { width: 100%; padding: 14px 16px; font-size: 14px; font-weight: 500;
       border: none; border-radius: 20px; cursor: pointer; margin-bottom: 10px;
       transition: opacity .1s; -webkit-tap-highlight-color: transparent;
       display: flex; align-items: center; justify-content: center; gap: 6px;
       letter-spacing: .1px; }
.btn:active  { opacity: .85; }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn-green  { background: var(--green-btn);                       color: #00210F; }
.btn-blue   { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.btn-red    { background: var(--red-btn);                         color: #fff; }
.btn-yellow { background: var(--yellow); color: #1f1a00; }
.btn-neutral { background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-on-surface); }
/* Kleine Buttons; steht bewusst nach den Farbklassen: Textfarbe weiß auch bei .btn-blue */
.btn-sm { padding: 8px 14px; font-size: 12px; font-weight: 500; border: none;
          border-radius: 20px; cursor: pointer; color: white; transition: opacity .2s; }
.btn-sm:active { opacity: .7; }
/* Aktionszeile unter einer ausgewählten Listenzeile (Fahrer, Team) */
.rider-row-actions, .team-page-actions { flex-basis: 100%; display: flex; gap: 8px; }
.rider-row-actions .btn-sm, .team-page-actions .btn-sm { flex: 1; min-height: 40px; display: inline-flex; align-items: center;
                                                         justify-content: center; gap: 4px; white-space: nowrap; }
md-filled-button, md-tonal-button, md-outlined-button, md-text-button {
  --md-filled-button-container-height: 40px;
}

/* ---- Fahrer: Punkt, Startnummer, Name ---- */
.rider-dot-sm { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.rider-tag { display: inline-flex; align-items: center; gap: 6px; }
.rider-num { display: inline-flex; align-items: center; justify-content: center;
             min-width: 22px; height: 20px; padding: 0 5px; border-radius: 4px;
             font-size: 11px; font-weight: 800; letter-spacing: .5px; flex-shrink: 0;
             /* dunkler 2-px-Ring wie bei den Live-Buttons (inset: Größe bleibt gleich), hebt sich von farbigen Flächen ab */
             box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .55); }
.rider-num.lg { min-width: 32px; height: 28px; border-radius: 6px; font-size: 16px; padding: 0 8px; }
.rider-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.rider-chip { display: flex; align-items: center; gap: 6px; padding: 8px 14px;
              border-radius: 20px; border: 1px solid var(--md-sys-color-outline);
              background: transparent; cursor: pointer; font-size: 13px; font-weight: 500;
              transition: background .15s; -webkit-tap-highlight-color: transparent;
              color: var(--md-sys-color-on-surface); }
.rider-chip:hover { background: var(--md-sys-color-surface-variant); }
.color-swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent;
                cursor: pointer; flex-shrink: 0; transition: border-color .15s; }
.color-swatch:hover { border-color: var(--md-sys-color-on-surface-variant); }
.color-swatch.sm { width: 20px; height: 20px; }

/* ---- Chips: Rundenangabe, Zeiten, Sonne, Wetter, Lichtpflicht ---- */
/* Rundenangabe „R: 7–10“ (lapChipHtml): transparenter Chip mit Kontur in der Fahrerfarbe */
.lap-chip { display: inline-flex; align-items: center; flex-shrink: 0; white-space: nowrap; font-variant-numeric: tabular-nums;
            height: 20px; padding: 0 7px; border-radius: 10px; border: 1.5px solid var(--rc); color: var(--md-sys-color-on-surface);
            font-size: 12px; font-weight: 600; line-height: 1; margin-left: 6px; vertical-align: middle; }
.lap-chip-done { gap: 2px; padding-left: 5px; }
.lap-chip-done .msym { width: 14px; height: 14px; }
/* Dunkle Chips: Uhrzeiten, Sonne, Wetter, Pausen, Rennende */
.sun-chip { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; height: 24px; min-width: 24px;
            padding: 0 5px; border-radius: 12px; background: var(--chip-bg); font-size: 13.5px; font-weight: 600;
            vertical-align: middle; white-space: nowrap; }
.sun-chip:has(svg:only-child) { justify-content: center; }
.sun-chip:not(:has(svg:only-child)) { padding-right: 8px; }
.sun-chip svg { width: 15px; height: 15px; flex-shrink: 0; }
.sun-chip-rise { color: var(--sun-rise); }
.sun-chip-set  { color: var(--sun-set); }
.temp-chip     { color: var(--chip-text); }
.temp-chip svg { color: #94a3b8; }
.temp-chip.wx-sun svg, .temp-chip.wx-cloudSun svg { color: var(--sun-rise); }
.temp-chip.wx-moon svg, .temp-chip.wx-cloudMoon svg { color: #c7d2fe; }
.temp-chip.wx-rain svg, .temp-chip.wx-drizzle svg, .temp-chip.wx-none svg { color: var(--rain); }
.temp-chip.wx-snow svg { color: #f8fafc; }
.temp-chip.wx-thunder svg { color: var(--sun-set); }
.rain-chip     { color: var(--rain); }
.thunder-chip  { color: #fff; background: var(--thunder-bg); }
/* Plan: Rundenzeiten (Abflug/Durchfahrt/Landung) und Pausen vor/nach dem Block */
.lap-time-chip { color: var(--chip-text); }
.lap-time-chip svg { color: var(--lap-time-icon); }
/* Zeiten ab jetzt (niemand fährt, etaFromNow): gestrichelt. Stil mit !important, weil Block- und
   Trennlinien-Chips ihren Rand inline setzen (Breite/Farbe bleiben) */
.lap-time-chip-provisional { border: 1px dashed var(--chip-text); border-style: dashed !important; }
.eta-from-now-hint { display: flex; align-items: center; gap: 6px; grid-column: 1 / -1; }
.eta-from-now-hint svg { width: 16px; height: 16px; flex-shrink: 0; }
.rest-chip     { color: var(--chip-text); }
.rest-chip svg { color: var(--rest-icon); }
/* Flagge (Lucide flag) + Uhrzeit an der Runde mit dem Rennende */
.race-end-chip { color: #fff; }
/* Glühbirne vor Blöcken in der Lichtpflicht (Plan, Live, Einsätze, Setup): gelb auf dunklem Grund */
.lights-badge, .start-lap-badge { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
                width: 22px; height: 22px; border-radius: 50%; background: var(--chip-bg); color: var(--lights-fg);
                vertical-align: middle; }
.lights-badge svg, .start-lap-badge svg { width: 14px; height: 14px; }

/* ---- Formulare ---- */
/* Textfeld in Dialogen; .setup-input = dasselbe mit 44 px Mindesthöhe (Setup-Seite) */
.text-input, .setup-input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--md-sys-color-surface-variant);
                            background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface); font-size: 15px; }
.setup-input { min-height: 44px; font-family: inherit; }
.setup-input:invalid, .setup-input.is-missing { border-color: var(--md-sys-color-error); }
/* Große Zeiteingabe MM:SS */
.time-panel-input {
  width: 100%; padding: 14px 16px; border-radius: 10px;
  border: 1px solid var(--md-sys-color-outline-variant); background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface); font-size: 28px; font-family: monospace;
  text-align: center; letter-spacing: 3px; box-sizing: border-box; }
.time-panel-input:disabled { opacity: .38; }
.time-panel-input.is-missing { border-color: var(--md-sys-color-error); }
/* Runde bearbeiten (Ergebnisse): Kopf mit Fahrer/R-Zahl und gemessenen Zeiten, Schalter „Gewertet“,
   offizielle Zeit nur bei gewerteter Runde */
.slot-edit-info { margin-bottom: 8px; }
.slot-edit-rider { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-weight: 600; }
.slot-edit-times { margin-top: 6px; font-size: 14px; color: var(--md-sys-color-on-surface-variant); font-variant-numeric: tabular-nums; }
.slot-edit-switch { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; font-size: 14px; }
#slotEditOfficialSection.is-hidden { display: none; }
.slot-edit-official-label { display: flex; align-items: center; gap: 6px; }
.slot-edit-official-icon { display: inline-flex; }
/* Block startet nach dem Rennende (afterRaceEndBadgeHtml) */
/* runde Plakette: schwarzer Hintergrund, weißer Rand – der Rand gedämpft wie die gedimmte Zeile (50 %),
   das rote Symbol bleibt kräftig */
.after-end-badge { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; vertical-align: middle;
  width: 24px; height: 24px; border-radius: 50%; background: #000; border: 2px solid rgb(255 255 255 / .5); box-sizing: border-box; }
.after-end-badge .lucide-icon { width: 14px; height: 14px; }
/* offizielle Rundenzeit: Zeit + Lucide shield-check (LUCIDE_SHIELD_CHECK) */
.official-time { display: inline-flex; align-items: center; gap: 3px; }
.official-time .lucide-icon { width: 15px; height: 15px; }
.time-panel-input::placeholder { color: var(--md-sys-color-on-surface-variant); letter-spacing: 1px; font-size: 18px; }
/* Einzeiliges Formular: Feld + Farbe + Button (Fahrer hinzufügen) */
.add-form { display: flex; gap: 8px; margin-bottom: 12px; }
.add-form input[type=text] { flex: 1; padding: 12px; border-radius: 12px;
                              border: 1px solid var(--md-sys-color-outline);
                              background: var(--md-sys-color-surface-variant);
                              color: var(--md-sys-color-on-surface); font-size: 15px; }
.add-form input[type=text]:focus { outline: none; border-color: var(--md-sys-color-primary); }
.add-form .btn-sm { padding: 0 16px; }

/* ---- Dialoge ---- */
/* Material-Web-Dialoge */
md-dialog {
  --md-dialog-container-color: var(--md-sys-color-surface-container-highest);
  --md-dialog-headline-color: var(--md-sys-color-on-surface);
  --md-dialog-supporting-text-color: var(--md-sys-color-on-surface-variant);
}
md-dialog [slot="content"] { color: var(--md-sys-color-on-surface); }
md-dialog input[type=number], md-dialog input[type=time], md-dialog input[type=text] {
  background: var(--md-sys-color-surface-variant);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px; color: var(--md-sys-color-on-surface);
  padding: 8px; font-size: 15px;
}
md-dialog input:focus { outline: none; border-color: var(--md-sys-color-primary); }
/* Formular im Dialog: Beschriftung über dem Feld, eine Zeile je Feld */
md-dialog .dialog-form { min-width: 280px; display: flex; flex-direction: column; gap: 10px; }
md-dialog .dialog-form.narrow { min-width: 260px; }
md-dialog .dialog-form.roomy { gap: 12px; }
/* Spezifischer als md-dialog input[type=text] (8 px Innenabstand), damit .text-input in Dialogen gilt */
md-dialog .dialog-form .text-input { padding: 10px 12px; }
.field-label { display: block; font-size: 13px; color: var(--md-sys-color-on-surface-variant); }
.form-error { font-size: 13px; color: var(--md-sys-color-error); }
.dialog-text { max-width: 320px; }
.dialog-text p { margin: 0; }
.color-input { width: 44px; height: 44px; border: none; border-radius: 8px; cursor: pointer; padding: 2px;
               background: var(--md-sys-color-surface-variant); }
.color-row { display: flex; gap: 10px; align-items: center; }
/* Eigene Dialoge (Team-Auswahl, Runde bearbeiten): gleiche Optik wie md-dialog */
.tp-backdrop { display:none; position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:500;
               align-items:center; justify-content:center; padding:16px; }
.tp-backdrop.open { display:flex; }
.tp-dialog { background:var(--md-sys-color-surface-container-highest); border-radius:28px;
             width:100%; max-width:440px; max-height:80vh;
             display:flex; flex-direction:column; overflow:hidden;
             box-shadow:0 8px 32px rgba(0,0,0,.5); }
.tp-headline { font-size:22px; font-weight:500; padding:24px 24px 12px;
               color:var(--md-sys-color-on-surface); }
.tp-content { padding:4px 24px 8px; overflow-y:auto; flex:1; }
.tp-actions { padding:12px 16px 16px; display:flex; gap:4px; justify-content:flex-end; }
.tp-btn { background:none; border:none; color:var(--md-sys-color-primary);
          font-size:14px; font-weight:500; letter-spacing:.025em;
          padding:10px 16px; border-radius:20px; cursor:pointer;
          font-family:inherit; transition:background .15s; }
.tp-btn:hover { background:color-mix(in srgb, var(--md-sys-color-primary) 12%, transparent); }
/* Checkbox-Zeile im Dialog (Runde bearbeiten: „Gewertet“) */
.check-row { display: flex; align-items: center; gap: 10px; margin-top: 16px; cursor: pointer; font-size: 14px; }
.check-row input { width: 18px; height: 18px; accent-color: var(--md-sys-color-primary); }
/* Farbwahl: Popup wie alle Popups in der Bildschirmmitte, nicht am angetippten Element */
.color-picker-popup { display: none; position: fixed; z-index: 500;
                      left: 50%; top: 50%; transform: translate(-50%, -50%);
                      background: var(--md-sys-color-surface-container-highest);
                      border-radius: 16px; padding: 12px;
                      box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.color-picker-popup.show { display: block; }
.cp-grid { display: grid; grid-template-columns: repeat(6, 28px); gap: 6px; }
.cp-swatch { width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
             border: 2px solid transparent; transition: border-color .1s, transform .1s; }
.cp-swatch:hover { transform: scale(1.15); }
.cp-swatch.selected { border-color: var(--md-sys-color-on-surface); }
/* Rückfrage-Popup für rote Aktionen (#redConfirmModal, Vorschau in aktionen.html) */
.red-confirm-title { display: flex; align-items: center; gap: 8px; color: var(--md-sys-color-error); }
.red-confirm-text { max-width: 320px; line-height: 1.45; }
/* Schiebe-Regler zum Bestätigen (Vorbild x.html): roter Griff mit Aktionssymbol, Text blendet beim Ziehen aus */
.confirm-slider { position: relative; height: 56px; margin-top: 16px; border-radius: 28px; overflow: hidden;
                  display: flex; align-items: center; justify-content: center; padding: 0 56px;
                  background: color-mix(in srgb, var(--red-btn) 16%, transparent); border: 1px solid var(--red-btn);
                  user-select: none; -webkit-user-select: none; transition: background-color .2s; }
.confirm-slider-text { font-size: 14px; font-weight: 600; text-align: center; pointer-events: none; }
.confirm-slider-handle { position: absolute; left: 4px; top: 3px; width: 48px; height: 48px; border-radius: 50%;
                         background: var(--red-btn); color: #fff; display: flex; align-items: center; justify-content: center;
                         cursor: grab; touch-action: none; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.confirm-slider-handle:active { cursor: grabbing; }
.confirm-slider-handle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.confirm-slider.is-confirmed { background: var(--red-btn); }
.confirm-slider.is-confirmed .confirm-slider-text { opacity: 0 !important; }

/* ---- Listen: Ziehen (Fahrer, Teams, Plan) ---- */
/* Drag nur vertikal: schwebende Kopie unsichtbar, die Zeile in der Liste wirkt „angehoben“.
   Steht vor den Ansichten: .is-selected/.is-roster haben bei gleicher Spezifität Vorrang. */
.drag-fallback-hidden { opacity: 0 !important; }
/* Drag-Quellen: kein Markieren von Text und kein Langdruck-Menü – sonst selektiert Chrome (Android) beim
   Halten den Namen, der Touch geht an die Auswahl, und Ziehen/Antippen bleibt dort wirkungslos */
#slotList, #appendChips, #riderList, #teamsPageList { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.rider-row.drag-ghost-lifted, .team-page-card.drag-ghost-lifted, .slot-item.drag-ghost-lifted {
  background: var(--md-sys-color-secondary-container); border-radius: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); }

/* ---- Wegweiser (guideStepsHtml in common.js): Willkommens-Popup und Karte vor dem Rennstart ---- */
.welcome-content { max-width: 340px; }
.welcome-content p { margin-bottom: 12px; line-height: 1.45; }
.guide-steps { display: flex; flex-direction: column; gap: 6px; }
.guide-step { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 8px 8px 12px;
  border: 1px solid var(--md-sys-color-outline-variant); border-radius: 12px; text-align: left;
  background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface); font: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent; }
.guide-step:active { opacity: .85; }
.guide-step-static { cursor: default; opacity: .75; }
.guide-step-hl { border: 2px solid var(--md-sys-color-primary); }
.guide-icon { display: flex; flex-shrink: 0; color: var(--md-sys-color-primary); }
.guide-icon svg { width: 22px; height: 22px; }
.guide-icon .msym { width: 22px; height: 22px; }
.guide-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.guide-title { font-size: 14px; font-weight: 700; }
.guide-sub { font-size: 12px; color: var(--md-sys-color-on-surface-variant); }
.guide-chevron { flex-shrink: 0; color: var(--md-sys-color-on-surface-variant); }

/* Aktiver Fahrer: activity „wabert“ – heller Abschnitt läuft wie eine EKG-Spur über die schwache Linie
   (activityPulseHtml() in icons.js; Live-Status und Einsätze-Spalte) */
.pulse-wave .pulse-wave-base { opacity: .35; }
.pulse-wave .pulse-wave-trace { stroke-dasharray: 38 62; animation: pulse-wave 1.6s linear infinite; }
@keyframes pulse-wave { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .pulse-wave .pulse-wave-trace { animation: none; stroke-dasharray: none; }
}

/* Drei Knöpfe in einer Reihe, einer gewählt (choiceRowHtml() in tab-me.js: Ich keine/meine/alle, Einsätze Alle/Meine/alle Teams) */
.choice-row { display: flex; border: 1px solid var(--md-sys-color-outline); border-radius: 20px; overflow: hidden; }
.choice-btn { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 4px 8px; border: 0; background: transparent;
              color: var(--md-sys-color-on-surface); font: inherit; font-size: 13px; font-weight: 500; line-height: 1.2;
              cursor: pointer; -webkit-tap-highlight-color: transparent; }
.choice-btn + .choice-btn { border-left: 1px solid var(--md-sys-color-outline); }
.choice-btn.is-selected { background: var(--md-sys-color-secondary-container, color-mix(in srgb, var(--md-sys-color-primary) 24%, transparent));
                          color: var(--md-sys-color-on-secondary-container, var(--md-sys-color-on-surface)); }
.choice-btn:disabled { opacity: .38; cursor: default; }
