body[data-launch] {
  --map-edge: 16px;
  --footer-space: 46px;
  --panel-width: clamp(326px, 34vw, 420px);
  --surface: #fbfdfc;
  --accent: #006e59;
  --ring: #d6e7df;
  --panel-shadow: 0 15px 44px #19362b25, 0 2px 5px #19362b14;
}

body[data-launch] .top {
  left: max(var(--map-edge), env(safe-area-inset-left));
  top: max(var(--map-edge), env(safe-area-inset-top));
  grid-template-columns: auto auto;
  gap: 10px;
  padding: 6px;
  border-radius: 15px;
  background: var(--surface);
}
body[data-launch] .identity { padding-right: 4px; font-size: 15px; }
body[data-launch] .logo { background: none; }
body[data-launch] .logo img { display: block; width: 36px; height: 36px; }
body[data-launch] #open-search { width: auto; padding: 0 12px; display: flex; gap: 7px; min-width: 44px; min-height: 44px; align-items: center; font-weight: 730; font-size: 13px; }
body[data-launch] .feed {
  top: max(19px, env(safe-area-inset-top));
  left: 50%;
  right: auto;
  translate: -50% 0;
  max-width: 38vw;
  padding: 10px 13px;
  background: var(--surface);
  font-size: 12px;
}
body[data-launch] .feed small { display: none; }
body[data-launch] .feed strong { line-height: 1.2; }

.map-dock {
  position: fixed;
  z-index: 610;
  bottom: calc(var(--footer-space) + max(10px, env(safe-area-inset-bottom)));
  left: 50%;
  translate: -50% 0;
  display: flex;
  max-width: calc(100% - 20px);
  gap: 4px;
  padding: 5px;
  border: 1px solid #fff;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--panel-shadow);
}
.map-dock button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  padding: 6px 13px;
  background: transparent;
  color: #153a36;
  font-size: 13px;
  font-weight: 720;
}
.map-dock svg { width: 19px; height: 19px; color: var(--accent); }
body[data-launch]:not([data-view="home"]) .map-dock { display: none; }
.city-panel {
  width: min(360px, calc(100% - 20px));
  background: var(--surface);
}
.city-panel::backdrop { background: #14283b44; }
.city-panel .dialog-heading { margin-bottom: 8px; }
.city-panel .dialog-heading form { margin: 0; }
.city-panel .launch-icon { width: 44px; height: 44px; background: #ebf3ef; color: #234a42; }
.city-panel nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  font-size: .9375rem;
}
.city-panel nav a[aria-current="page"] { color: #075b49; background: #e5f1ec; font-weight: 750; }
.city-panel nav a:active { background: #dceee7; }
body[data-launch] .beta-notice {
  position: fixed;
  left: 50%;
  bottom: env(safe-area-inset-bottom);
  translate: -50% 0;
  z-index: 611;
  width: max-content;
  max-width: calc(100% - 16px);
  box-sizing: border-box;
  padding: 5px 10px;
  text-align: center;
  border: 1px solid #e0ebe5;
  border-radius: 12px 12px 0 0;
  background: #f7faf7f5;
  line-height: 1.2;
  color: #33534b;
}
body[data-launch] .beta-notice button { min-height: 28px; margin-left: 5px; color: #005944; }

body[data-launch][data-view="home"] .sidebar { display: none; }
body[data-launch] .sidebar {
  top: calc(max(var(--map-edge), env(safe-area-inset-top)) + 70px);
  bottom: calc(var(--footer-space) + env(safe-area-inset-bottom));
  left: max(var(--map-edge), env(safe-area-inset-left));
  width: var(--panel-width);
  border: 1px solid #e1ede7;
  border-radius: 22px;
  background: var(--surface);
  overflow: hidden;
}
body[data-launch] .sidebar[data-selection]:not([data-selection=""]) { right: max(var(--map-edge), env(safe-area-inset-right)); left: auto; }
body[data-launch] .sidebar[data-selection]:not([data-selection=""]) :is(.intro,.tabs) { display: none; }
.panel-rail { position: relative; height: 50px; flex: none; display: flex; justify-content: flex-end; align-items: center; gap: 6px; padding-inline: 8px; }
.panel-rail #detail-back { position: absolute; z-index: 1; inset-inline-start: 8px; }
:is(#detail-back,#edit-selection,#share-selection,#close-panel) { width: 44px; height: 44px; background: #ebf3ef; color: #234a42; }
:is(#detail-back,#edit-selection,#share-selection)[hidden] { display: none; }
.launch-icon .card-icon { width: 21px; height: 21px; fill: currentColor; stroke: none; }
.sidebar[data-selection="bus"] .panel-rail { padding-inline: 12px; }
.sidebar[data-selection="bus"] #detail-back { inset-inline-start: 12px; }
.sidebar[data-selection="bus"] .panel-rail .launch-icon { border-radius: 50%; touch-action: manipulation; }
.sidebar[data-selection="bus"] .panel-rail .launch-icon:active { background: #cee7dc; }
body[data-launch] :is(#detail-nav, #map-clear) { display: none; }
body[data-launch] #map-selection:has(#map-fit[hidden]) { display: none; }
.stop-header { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; column-gap: 8px; }
.detail-actions { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 5px; }
body[data-launch] .results > .sources { margin-top: 12px; padding: 9px 0 0; }
body[data-launch] .sidebar:is([data-selection="bus"],[data-selection="stop"]) .results { padding-top: 7px; }
body[data-launch] .intro { padding: 0 16px 12px; }
body[data-launch] .intro h1 { margin: 0 0 10px; font-size: 22px; }
body[data-launch] .search { background: #edf5f1; border-color: var(--ring); }
body[data-launch] .tabs button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
body[data-launch] .row strong { font-size: 14px; }
body[data-launch] .detail h2 { font-size: clamp(23px, 5vw, 28px); line-height: 1.15; color: #14372c; }
body[data-launch] .bus-identity { gap: 5px; margin-bottom: 9px; }
body[data-launch] .bus-identity h2 { font-size: clamp(1.625rem, 6vw, 1.875rem); }
.bus-identity h2[tabindex="-1"]:focus { outline: none; }
.bus-identity .bus-badges { margin-bottom: 2px; }
.bus-identity .bus-badges .code { min-width: 0; background: #086b55; color: #fff; font-size: .875rem; padding: 5px 9px; border-radius: 8px; }
.bus-identity p.bus-origin { font-size: .9375rem; }
.bus-identity p.bus-meta { font-size: .8125rem; margin-top: 3px; }
.bus-identity .bus-meta strong { font-weight: 650; }
body[data-launch] .detail .bus-facts { margin: 6px 0; padding: 0; background: transparent; }
body[data-launch] #reported-speed:not([hidden]) { display: flex; align-items: baseline; gap: 7px; }
body[data-launch] .bus-actions { gap: 7px; }
body[data-launch] .bus-actions :is(.primary-action,.nav-action) { flex: 0 0 auto; min-height: 44px; padding-inline: 9px; font-size: 12px; }
body[data-launch] .bus-actions .primary-action { background: var(--accent); border-radius: 9px; }
.bus-timeline-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; border-top: 1px solid var(--ring); padding-top: 7px; }
.bus-timeline-head h3 { margin: 0; font-size: .9375rem; }
.bus-timeline-head .bus-progress-jump { border: 0; border-radius: 18px; background: #e5f2eb; color: #125847; padding: 6px 10px; font-size: .8125rem; }
.bus-timeline-head .bus-progress-jump:active { background: #cee7dc; }
.bus-stops li { font-size: .9375rem; border-radius: 9px; }
.bus-stops li > :is(button,.unmapped-stop) { line-height: 1.25; }
.bus-stops li[data-progress="passed"] .bus-stop-name { color: var(--muted); }
.bus-stops li .bus-stop-progress { display: block; margin-top: 3px; color: #006652; font-size: .75rem; font-weight: 700; }
body[data-launch] :is(.map-notice,.map-selection:not([hidden])) { left: max(var(--map-edge), env(safe-area-inset-left)); top: 82px; }
body[data-launch] .map-selection:not([hidden]) ~ .map-notice { top: 139px; }
body[data-launch][data-view="browse"] .map-notice { left: calc(var(--panel-width) + var(--map-edge) + 12px); }
body[data-launch] .map-area .leaflet-control-zoom { margin-top: 82px; }
body[data-launch] .map-controls { top: 185px; }
body[data-launch] .map-area .leaflet-bottom { bottom: calc(var(--footer-space) + 5px); }

@media(min-width:721px) {
  body[data-launch]:is([data-view="bus"],[data-view="stop"],[data-view="route"]) .leaflet-right,
  body[data-launch]:is([data-view="bus"],[data-view="stop"],[data-view="route"]) .map-controls {
    right: calc(var(--map-edge) + var(--panel-width) + 8px);
  }
  .panel-rail { margin-bottom: -7px; }
  .panel-rail:not(:has(#close-panel, #detail-back:not([hidden]))) { display: none; }
}
@media(max-width:720px) {
  body[data-launch] { --map-edge: 9px; --footer-space: 57px; }
  body[data-launch] .top { gap: 4px; padding: 4px; }
  body[data-launch] .identity { gap: 5px; padding-right: 2px; }
  body[data-launch] .identity strong { font-size: 13px; }
  body[data-launch] #open-search { padding: 0; justify-content: center; }
  body[data-launch] #open-search span { display: none; }
  body[data-launch] .feed { translate: none; top: max(17px, env(safe-area-inset-top)); left: auto; right: max(9px, env(safe-area-inset-right)); max-width: 38%; padding: 7px 8px; white-space: normal; }
  .map-dock { bottom: calc(var(--footer-space) + max(5px, env(safe-area-inset-bottom))); }
  .map-dock button { padding: 4px 8px; gap: 4px; }
  .city-panel {
    inset: auto 0 max(8px, env(safe-area-inset-bottom));
    width: calc(100% - 16px);
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
    margin: 0 auto;
    overscroll-behavior: contain;
  }
  body[data-launch] .beta-notice { padding: 3px 7px; }
  body[data-launch] .sidebar,
  body[data-launch] .sidebar[data-selection]:not([data-selection=""]) {
    top: auto;
    left: max(6px,env(safe-area-inset-left));
    right: max(6px,env(safe-area-inset-right));
    width: auto;
    bottom: calc(var(--footer-space) + env(safe-area-inset-bottom));
    max-height: calc(100dvh - 126px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  body[data-launch] .sidebar[data-snap="half"] { --sheet-height: clamp(277px,48dvh,440px); }
  body[data-launch] .sidebar[data-snap="half"][data-selection="bus"] { --sheet-height: clamp(277px,64dvh,510px); }
  body[data-launch] .sidebar[data-snap="collapsed"][data-selection="bus"] { --sheet-height: 132px; }
  body[data-launch] .sidebar[data-snap="collapsed"][data-selection="stop"],
  body[data-launch] .sidebar[data-snap="collapsed"][data-selection="route"] { --sheet-height: 100px; }
  body[data-launch] .sidebar[data-snap="full"] { --sheet-height: calc(100dvh - 126px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  body[data-launch][data-keyboard] .sidebar[data-sheet-open="true"] { --sheet-height: calc(var(--app-height,100dvh) - 126px); max-height: var(--sheet-height); }
  .panel-rail { height: 48px; padding-inline: 5px; }
  body[data-launch] #sheet-handle { position: absolute; left: 0; inset-block: 0; height: 100%; }
  .sidebar[data-selection="bus"] #sheet-handle span { position: absolute; inset-inline-start: 42%; transform: translateX(-50%); }
  .panel-rail:not(:has(#close-panel, #detail-back:not([hidden]))) { height: 31px; }
  .panel-rail :is(#edit-selection,#share-selection,#close-panel) { position: relative; z-index: 1; }
  .panel-rail #detail-back { inset-inline-start: 5px; }
  body[data-launch] .intro { padding: 0 10px 6px; }
  body[data-launch] .map-area .leaflet-control-zoom { margin-top: max(71px,env(safe-area-inset-top)); margin-right: 9px; }
  body[data-launch] .map-controls { top: 168px; right: max(9px,env(safe-area-inset-right)); }
  body[data-launch] .legend-items { max-height: 235px; }
  body[data-launch]:not([data-view="home"]):has(.sidebar[data-snap="full"]) .map-legend { display: none; }
  body[data-launch] .map-selection:not([hidden]) { display: flex; max-width: calc(100% - 73px); top: 70px; left: 9px; }
  body[data-launch] .map-selection .nav-action { min-height: 36px; font-size: 11px; }
  body[data-launch] .map-notice,body[data-launch][data-view="browse"] .map-notice { left: 9px; top: 70px; }
  body[data-launch] .map-selection:not([hidden]) ~ .map-notice { top: 122px; }
  body[data-launch] .map-area .leaflet-bottom { bottom: calc(var(--footer-space) + 61px); }
  body[data-launch]:has(.sidebar[data-snap="half"]) .map-area .leaflet-bottom { bottom: calc(var(--footer-space) + min(48dvh,440px)); }
  body[data-launch]:has(.sidebar[data-snap="half"][data-selection="bus"]) .map-area .leaflet-bottom { bottom: calc(var(--footer-space) + clamp(277px,64dvh,510px)); }
  body[data-launch]:has(.sidebar[data-snap="full"]) .map-area .leaflet-bottom { display: none; }
}
@media(max-width:720px) and (max-height:650px) {
  body[data-launch] .map-legend { order: -2; }
  body[data-launch] .legend-items { max-height: 137px; }
}
@media(max-width:720px) and (min-height:810px) {
  body[data-launch] .legend-items { bottom: -46px; max-height: 280px; }
}
@media(max-width:360px) {
  .map-dock button { flex-direction: column; gap: 2px; }
}
@media (hover:hover) and (pointer:fine) {
  .map-dock button:hover, #open-search:hover, #detail-back:hover, #edit-selection:hover, #share-selection:hover, #close-panel:hover { background: #dceee7; }
  .city-panel nav a:hover { background: #e5f1ec; }
}
@media (prefers-reduced-motion:no-preference) {
  .map-dock button:active, #open-search:active, #close-panel:active { transform: scale(.97); }
  .map-dock button, #open-search, #close-panel { transition: transform 150ms ease-out, background-color 150ms ease-out; }
}
