:root {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: #f5f9fc;
  background: #081725;
  color-scheme: dark;
  --surface: #0b2032;
  --accent: #ffca55;
  --subtle: #b8c9d8;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.shell { max-width: 33rem; margin: auto; min-height: 100dvh; background: var(--surface); }
.masthead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid #294257; }
.language { font-size: .875rem; color: var(--subtle); }
select, input, button { font: inherit; min-height: 44px; }
select, input { width: 100%; padding: .3rem .65rem; border: 1px solid #637a8e; border-radius: .5rem; background: #122b40; color: #fff; }
select { appearance: none; padding-right: 2rem; background-image: linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%); background-position: right .9rem center, right .6rem center; background-size: .3rem .3rem; background-repeat: no-repeat; }
.player { padding: 1rem 1.25rem; }
.status { margin: 0; min-height: 1.5em; color: var(--accent); font-weight: 650; }
h1 { margin: .3rem 0 .75rem; font-size: clamp(1.85rem, 7vw, 2.75rem); line-height: 1.08; }
.meter p { margin: .45rem 0 .15rem; font-variant-numeric: tabular-nums; }
progress { width: 100%; height: .55rem; display: block; margin-bottom: 1rem; accent-color: var(--accent); border: none; border-radius: 1rem; }
progress::-webkit-progress-bar { background: #42586a; border-radius: 1rem; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 1rem; }
button { cursor: pointer; border: 1px solid #8fa7ba; border-radius: .8rem; background: transparent; color: inherit; padding: .65rem 1rem; font-weight: 700; }
button:disabled { cursor: default; opacity: .48; }
button.primary { background: var(--accent); border-color: var(--accent); color: #102033; width: 100%; min-height: 52px; font-size: 1.15rem; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: .7rem; }
.timeline { background: #122b40; color: #f5f9fc; padding: 1.25rem; }
.timeline h2 { margin: 0 0 1rem; }
.timeline ol { list-style: none; padding: 0 0 0 .9rem; margin: 0 .35rem; border-left: 2px solid #a8b4bc; }
.timeline li { position: relative; display: grid; align-items: center; grid-template-columns: 1fr auto; gap: .75rem; padding: .55rem 0; }
.timeline li::before { content: ""; position: absolute; left: -1.25rem; width: .5rem; height: .5rem; border: 2px solid #9bb4c6; border-radius: 50%; background: #122b40; }
.timeline li[data-current="true"]::before { background: #ffca55; }
.timeline small { display: block; color: var(--subtle); margin-top: .2rem; font-size: .875rem; }
.timeline button { border-color: #8fa7ba; color: inherit; }
.operator a { color: inherit; }
#playback-diagnostics { padding: 0 1.25rem 1.25rem; color: var(--subtle); }
summary { cursor: pointer; padding: .65rem 0; }
.operator { padding: 1.25rem; }
.operator canvas { display: block; max-width: 100%; height: auto; }
.operator form { display: grid; gap: .8rem; }
.operator pre { white-space: pre-wrap; overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid #48b9ed; outline-offset: 3px; }
.pack-status { color: var(--subtle); font-size: .875rem; margin: .45rem 0; }
.pack-status:empty { display: none; }
.connection-status { color: var(--subtle); margin: .25rem 0; }
#leave { width: 100%; margin-top: .7rem; }
.operator #route-picker { margin-top: .75rem; }
.operator #refresh-routes { margin-top: .5rem; }
.operator #departure, .operator #passenger-link { overflow-wrap: anywhere; }
.operator #end { width: 100%; }
.operator #result:empty, .operator #cue-result:empty, .operator #login-result:empty { display: none; }
.operator #send > .controls { margin-top: 0; }
.tour-status { padding: .75rem; margin: .75rem 0; background: #122b40; border-radius: .8rem; }
.tour-status div { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; padding: .35rem 0; }
.tour-status dt { color: var(--subtle); }
.tour-status dd { margin: 0; font-weight: 650; }

#card-swipe { touch-action: pan-y; }
.card-photo { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; border-radius: .85rem; }
#card-kind { color: var(--subtle); margin: .3rem 0; }
#card-navigation { margin-bottom: .75rem; }
#card-transcript { margin-top: .75rem; }
#transcript-text { white-space: pre-wrap; overflow-wrap: anywhere; }
#follow-live { grid-column: 1 / -1; }

#status { margin: 1rem 1.25rem 0; }
#status:empty { display: none; }
#language-gate { margin: 1.25rem; padding: 1.25rem; border: 1px solid #36546a; border-radius: 1rem; background: #122b40; }
#language-gate .language { display: grid; gap: .35rem; }
#language-actions { margin-top: 1rem; }
#view-stories { width: 100%; }
#card-swipe { position: relative; overflow: hidden; border-radius: .9rem; background: #122b40; }
#card-swipe h1, #card-kind { margin-inline: 1rem; }
#card-swipe h1 { padding-top: .7rem; overflow-wrap: anywhere; }
#card-kind { padding-bottom: .8rem; }
#card-swipe[data-no-photo] { padding-top: 2.5rem; background: linear-gradient(135deg, #1c4058, #122b40 65%); }

#progress { display: block; width: 100%; padding: 0; border: 0; background: transparent; accent-color: var(--accent); }
#progress:disabled { opacity: .6; }

#music-controls { position: fixed; z-index: 5; left: max(calc((100% - 33rem) / 2 + .75rem), .75rem, env(safe-area-inset-left));
  bottom: max(.75rem, env(safe-area-inset-bottom)); }
.shell:has(#music-controls:not([hidden])) { padding-bottom: calc(3.5rem + env(safe-area-inset-bottom)); }
.audio-toolbar { display: flex; align-items: flex-end; gap: .5rem; }
.audio-toolbar .meter { flex: 1; min-width: 0; }
#music-volume-control { position: relative; }
#music-volume-control summary { display: grid; place-items: center; list-style: none; min-height: 44px;
  min-width: 44px; padding: 0; border-radius: .5rem; color: var(--subtle); background: var(--surface); }
#music-volume-control summary:hover, #music-volume-control[open] summary { color: #fff; }
#music-volume-control summary::-webkit-details-marker { display: none; }
#music-volume-icon { display: block; width: 20px; height: 20px; }
#music-volume-icon .volume-mute, #music-volume-icon[data-muted] .volume-wave { display: none; }
#music-volume-icon[data-muted] .volume-mute { display: inline; }
#card-photo-credit { position: absolute; top: .5rem; right: .5rem; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%; color: #fff; background: #081725bd; text-decoration: none; }
#music-volume { position: absolute; z-index: 2; top: 50%; left: calc(100% + .25rem); transform: translateY(-50%);
  width: min(10rem, 55vw); height: 44px;
  padding: 0 .6rem; margin: 0; border: 1px solid #36546a; background: #122b40; accent-color: var(--accent); }

#transport { margin-top: .35rem; }
#transport:has(#primary[data-icon]) { display: grid; grid-template-columns: repeat(2, 44px) 56px repeat(2, 44px);
  justify-content: center; align-items: center; gap: clamp(.15rem, 2vw, .6rem); }
#transport:not(:has(#primary)) { display: none; }
#transport .transport-icon { display: grid; place-items: center; width: 44px; height: 44px;
  padding: 0; border: 0; border-radius: 50%; }
#transport .transport-icon:not(:disabled):hover { background: #1c4058; }
#transport svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.65;
  stroke-linecap: round; stroke-linejoin: round; }
#primary svg { display: none; }
#primary[data-icon] { display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border-radius: 50%; }
#primary[data-icon] #primary-label { display: none; }
#primary[data-icon] .play-symbol, #primary[data-icon][data-pausing] .pause-symbol { display: block; width: 27px; height: 27px; }
#primary[data-icon][data-pausing] .play-symbol { display: none; }

.shell:has(#language-gate:not([hidden])) .masthead { border-bottom: 0; padding: 1.5rem 1.25rem .5rem; }
.shell:has(#language-gate:not([hidden])) .site-brand img { width: 8.75rem; }
#language-gate { margin: 0; padding: 1rem 1.25rem 2rem; border: 0; border-radius: 0; background: transparent; }
#language-heading { margin-bottom: .65rem; }
#language-prompt { color: var(--subtle); line-height: 1.5; margin: 0 0 1.25rem; }
#language-tiles { min-width: 0; margin: 0; padding: 0; border: 0; display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
#language-tiles label { position: relative; display: flex; align-items: center; justify-content: space-between;
  min-width: 0; min-height: 52px; padding: .65rem .75rem; gap: .4rem; border: 1px solid #496278;
  border-radius: .65rem; background: #122b40; cursor: pointer; }
#language-tiles input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; padding: 0; }
#language-tiles span { overflow-wrap: anywhere; }
#language-tiles label::after { content: ''; flex: 0 0 .95rem; text-align: center; }
#language-tiles label:has(input:checked) { border-color: var(--accent); background: #223545; }
#language-tiles label:has(input:checked)::after { content: '✓'; color: var(--accent); font-weight: 700; }
#language-tiles label:has(input:focus-visible) { outline: 3px solid #48b9ed; outline-offset: 2px; }
#language-actions { margin-top: 1.15rem; display: grid; gap: .35rem; }
#view-stories, #back-to-languages { border: 0; background: transparent; color: var(--subtle); text-decoration: underline; }
#back-to-languages { padding-inline: 0; }
#view-stories:hover, #back-to-languages:hover { color: #fff; }
#primary:not([data-icon]) { display: flex; align-items: center; justify-content: center; gap: .55rem; }
#primary:not([data-icon]) .headphone-symbol { display: block; width: 20px; height: 20px; }
#language-gate #status { margin: .8rem 0 0; color: var(--subtle); font-size: .88rem; font-weight: 500; }
#language-gate #status:not(:empty)::before { content: ''; display: inline-block; width: .45rem; height: .45rem;
  margin-right: .45rem; border-radius: 50%; background: #9db3c5; vertical-align: .1em; }

#language-tiles { max-width: 15rem; gap: .65rem .9rem; }
#language-tiles label:has(.language-tile-flag) { justify-content: center; min-height: 64px; padding: .35rem;
  border-radius: .55rem; background: transparent; }
#language-tiles label:has(.language-tile-flag):has(input:checked) { background: #122b40; }
#language-tiles label:has(.language-tile-flag)::after { position: absolute; top: .24rem; right: .32rem;
  font-size: .75rem; line-height: 1; }
#language-tiles .language-tile-flag { display: block; width: 54px; height: 40.5px; object-fit: contain; border-radius: 2px; }
