/* Preparation and the active ride share one map, without mixing their controls. */
html:has(#fahrt-dialog[open]), body:has(#fahrt-dialog[open]) { overflow: hidden; }
#fahrt-dialog:not(.fahrt-expanded) {
  width: min(1360px, calc(100% - 32px));
  height: min(920px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
}
#fahrt-dialog:not(.fahrt-expanded) #fahrt-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  height: 100%;
  min-height: 0;
}
#fahrt-dialog:not(.fahrt-expanded) .fahrt-heading {
  margin: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--fahrt-line);
}
#fahrt-dialog:not(.fahrt-expanded) .fahrt-heading h2 { font-size: 24px; }
.fahrt-workspace { min-width: 0; min-height: 0; }
#fahrt-dialog:not(.fahrt-expanded) .fahrt-workspace {
  display: grid;
  grid-template-columns: minmax(310px, 380px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px 20px;
  padding: 20px;
  overflow: hidden;
}
.fahrt-preparation {
  grid-column: 1;
  grid-row: 1 / 3;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #526775 transparent;
  padding-right: 4px;
}
.fahrt-preparation-head { margin: 0 0 12px; }
.fahrt-setup-summary { margin: 0; color: var(--fahrt-muted); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
#fahrt-setup-resume { margin-top: 10px; }
.fahrt-setup-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 16px;
  padding: 4px;
  border: 1px solid var(--fahrt-line);
  border-radius: 11px;
  background: var(--fahrt-panel);
}
.fahrt-setup-tabs button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--fahrt-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
}
.fahrt-setup-tabs button[aria-selected="true"] { background: #244654; border-color: #486e7d; color: #e4f4fc; }
.fahrt-setup-tabs button:hover:not(:disabled) { color: #fff; border-color: #658795; }
.fahrt-setup-panel { min-width: 0; }
#fahrt-dialog .fahrt-preparation .fahrt-settings {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
}
.fahrt-preparation .fahrt-settings-legend { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
.fahrt-preparation :is(.fahrt-route-field, .fahrt-bound-field, .fahrt-learning-mode) { grid-column: 1 / -1; }
#fahrt-dialog .fahrt-preparation :is(.fahrt-length, .fahrt-cruise-field) { grid-column: auto; }
#fahrt-dialog .fahrt-preparation .fahrt-length select { width: 100%; }
.fahrt-preparation .fahrt-mode-hint { grid-column: 1 / -1; margin: -4px 0 2px; color: var(--fahrt-muted); font-size: 12px; line-height: 1.55; }
.fahrt-setup-section { grid-column: 1 / -1; border-top: 1px solid var(--fahrt-line); }
.fahrt-setup-section > summary, .fahrt-scenario-section > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; cursor: pointer; list-style: none; color: #d1e1e8; font-size: 13px; font-weight: 600; }
.fahrt-setup-section > summary::-webkit-details-marker, .fahrt-scenario-section > summary::-webkit-details-marker { display: none; }
.fahrt-setup-section > summary::after, .fahrt-scenario-section > summary::after { content: '+'; color: #9bdafa; font-size: 18px; font-weight: 400; }
.fahrt-setup-section[open] > summary::after, .fahrt-scenario-section[open] > summary::after { content: '−'; }
.fahrt-setup-section-body { display: grid; gap: 12px; padding: 0 0 10px; }
.fahrt-preparation .fahrt-track-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fahrt-preparation .fahrt-track-panel { background: var(--fahrt-panel); }
.fahrt-preparation .fahrt-platforms { padding: 0; }
.fahrt-preparation :is(.fahrt-signal-panel, .fahrt-library) { margin: 0; padding: 0; border: 0; background: transparent; }
/* Panel tabs supply these names, so repeating a second disclosure adds no value. */
.fahrt-preparation #fahrt-library > summary { display: none; }
.fahrt-preparation #fahrt-signal-panel > summary { pointer-events: none; min-height: 0; margin-bottom: 12px; padding: 0; list-style: none; }
.fahrt-preparation #fahrt-signal-panel > summary::-webkit-details-marker { display: none; }
.fahrt-preparation #fahrt-signal-summary { display: block; float: none; margin: 4px 0 0; font-size: 11px; }
.fahrt-preparation .fahrt-map-instructions { display: block; margin: 0 0 16px; font-size: 12px; }
.fahrt-preparation .fahrt-map-instructions button { width: 100%; margin-top: 8px; }
.fahrt-preparation :is(.fahrt-setup-tools, .fahrt-signals, .fahrt-library-grid, .fahrt-comparison-cards) { grid-template-columns: minmax(0, 1fr); }
.fahrt-preparation .fahrt-signal-groups { max-height: none; overflow: visible; padding: 0; }
.fahrt-preparation .fahrt-library-grid { gap: 12px; }
.fahrt-scenario-section { min-width: 0; border-bottom: 1px solid var(--fahrt-line); }
.fahrt-preparation .fahrt-scenario-section > section { padding-bottom: 12px; }
#fahrt-dialog .fahrt-preparation :is(#fahrt-scenario-title, #fahrt-comparison-title, #fahrt-adaptive-title) { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); }
#fahrt-dialog .fahrt-preparation .small-button, #fahrt-preview {
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #405564;
  border-radius: 8px;
  background: var(--ui-surface-soft,#1b2b3b);
  color: #d5e3eb;
  font-size: 12px;
  line-height: 1.4;
}
#fahrt-dialog:not(.fahrt-expanded) .fahrt-overview { grid-column: 2; grid-row: 1; margin: 0; height: 42px; }
#fahrt-dialog:not(.fahrt-expanded) .fahrt-content { grid-column: 2; grid-row: 2; min-height: 0; grid-template-columns: minmax(0, 1fr); }
#fahrt-dialog[data-view="setup"]:not(.fahrt-expanded) .fahrt-details { display: none; }
#fahrt-dialog[data-view="setup"] #fahrt-back { display: none; }
#fahrt-dialog[data-view="setup"]:not(.fahrt-expanded) .fahrt-speedometer { display: none; }
#fahrt-dialog:not(.fahrt-expanded) #fahrt-map { height: 100%; min-height: 0; }
#fahrt-dialog:not(.fahrt-expanded) .fahrt-actions { position: relative; bottom: auto; margin: 0; padding: 12px 20px; }
#fahrt-dialog:not(.fahrt-expanded) .fahrt-navigation { width: min(100%, 440px); }
#fahrt-dialog:not(.fahrt-expanded) .fahrt-notes { margin: 0; padding: 0 20px; border-top: 1px solid var(--fahrt-line); max-height: 140px; overflow-y: auto; }
#fahrt-dialog:not(.fahrt-expanded) .fahrt-notes > summary { min-height: 36px; padding: 8px 0; font-size: 11px; }
#fahrt-dialog[data-view="ride"] .fahrt-preparation { display: none; }
#fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-workspace { grid-template-columns: minmax(0, 1fr); }
#fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) :is(.fahrt-overview, .fahrt-content) { grid-column: 1; }
#fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-content { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); }
#fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-details { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #587081 transparent; padding-right: 4px; }
#fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-card { flex: none; }
#fahrt-dialog:not(.fahrt-expanded) .fahrt-explanation { flex: none; max-height: none; overflow: visible; padding-right: 0; }
#fahrt-dialog:not(.fahrt-expanded) .fahrt-live-signal { flex: none; max-height: none; overflow: visible; }
#fahrt-dialog .fahrt-rule-summary { flex: none; }
#fahrt-dialog:not(.fahrt-expanded) .fahrt-detail-toolbar { grid-template-columns: minmax(0, 1fr) minmax(100px, .8fr); }
#fahrt-dialog[data-view="ride"]:not(.fahrt-expanded)[data-explanation-size="compact"] .fahrt-content { grid-template-columns: minmax(0, 2fr) minmax(280px, .8fr); }
#fahrt-dialog[data-view="ride"]:not(.fahrt-expanded)[data-explanation-size="large"] .fahrt-content { grid-template-columns: minmax(0, 1fr) minmax(340px, 1fr); }
#fahrt-dialog.fahrt-expanded .fahrt-workspace { display: contents; }
#fahrt-dialog.fahrt-expanded .fahrt-preparation { display: none; }
#fahrt-dialog.fahrt-expanded #fahrt-preview { display: none; }
@media (max-width: 760px) {
  #fahrt-dialog:not(.fahrt-expanded) { width: 100%; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-heading { padding: max(10px, env(safe-area-inset-top)) 12px 10px; gap: 8px; flex-wrap: nowrap; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-heading h2 { font-size: 20px; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-heading > div:first-child { flex: 1; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-heading .eyebrow { font-size: 9px; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-workspace { padding: 14px 12px; gap: 10px; }
  #fahrt-dialog[data-view="setup"]:not(.fahrt-expanded) .fahrt-workspace { display: block; overflow-y: auto; overscroll-behavior: contain; }
  .fahrt-preparation { overflow: visible; padding: 0; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-overview { height: 30px; margin: 14px 0 10px; }
  #fahrt-dialog[data-view="setup"]:not(.fahrt-expanded) .fahrt-map-frame { height: 300px; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-actions { padding: 10px 12px; gap: 8px; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-navigation { width: 100%; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-notes { padding: 0 12px max(2px, env(safe-area-inset-bottom)); }
  #fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-workspace { grid-template-rows: auto minmax(0, 1fr); }
  #fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-overview { margin: 0; height: 26px; }
  #fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-content { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(130px, 29dvh) minmax(0, 1fr); gap: 10px; }
  #fahrt-dialog[data-view="ride"]:not(.fahrt-expanded)[data-explanation-size="compact"] .fahrt-content { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(130px, 39dvh) minmax(0, 1fr); }
  #fahrt-dialog[data-view="ride"]:not(.fahrt-expanded)[data-explanation-size="large"] .fahrt-content { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(100px, 21dvh) minmax(0, 1fr); }
  #fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-details { padding-right: 2px; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-speedometer { top: auto; bottom: 10px; right: 10px; left: auto; min-width: 0; max-width: 148px; padding: 6px 8px; }
  #fahrt-dialog:not(.fahrt-expanded) #fahrt-speed { font-size: 24px; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-map-label { top: 8px; left: 8px; font-size: 10px; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-map-note { max-width: calc(100% - 170px); font-size: 9px; }
}
@media (max-width: 360px) {
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-heading { flex-wrap: wrap; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-heading > div:first-child { flex-basis: 100%; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-heading-actions { width: 100%; justify-content: flex-end; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-heading h2 { font-size: 19px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #fahrt-dialog:not(.fahrt-expanded) { width: 100%; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-heading { padding: 6px 12px; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-heading .eyebrow { display: none; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-heading h2 { margin: 0; font-size: 18px; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-workspace { padding: 8px 12px; gap: 8px; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-overview { display: none; }
  #fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-content { grid-row: 1 / 3; grid-template-columns: minmax(0, 1fr) minmax(250px, 1fr); grid-template-rows: minmax(0, 1fr); }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-actions { padding: 6px 12px; }
  #fahrt-dialog:not(.fahrt-expanded) .fahrt-notes { max-height: 80px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  #fahrt-dialog[data-view="ride"]:not(.fahrt-expanded):is([data-explanation-size="compact"], [data-explanation-size="large"]) .fahrt-content { grid-template-columns: minmax(0, 1fr) minmax(250px, 1fr); grid-template-rows: minmax(0, 1fr); }
}
/* Keep the reading/input area reachable when a portrait keyboard reduces height. */
@media (max-width: 760px) and (max-height: 650px) and (orientation: portrait) {
  #fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-workspace { display: block; overflow-y: auto; }
  #fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-overview { margin-bottom: 8px; }
  #fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-content { display: flex; flex-direction: column; }
  #fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-map-frame { flex: none; height: 170px; }
  #fahrt-dialog[data-view="ride"]:not(.fahrt-expanded) .fahrt-details { flex: none; overflow: visible; }
}

/* A pending change is announced inside the existing header, without changing the ride grid. */
#fahrt-dialog .fahrt-heading:has(.fahrt-external-state-note:not([hidden])) { flex-wrap: wrap; }
#fahrt-dialog .fahrt-external-state-note { flex: 1 0 100%; margin: 4px 0 0; padding: 8px 10px; border: 1px solid var(--fahrt-line); border-radius: 8px; background: var(--fahrt-panel); color: var(--fahrt-muted); font-size: 12px; line-height: 1.4; }

.fahrt-detail-map-note {margin:0 0 8px;font-size:.875rem;line-height:1.45;color:var(--ui-muted)}
