:root {
  --page-background: #eef4e9;
  --surface: #fff;
  --primary: #315d3a;
  --primary-dark: #24462b;
  --text: #1f3022;
  --muted: #526258;
  --notice: #fff8d6;
  --notice-border: #d4a72c;
  --focus: #1e6fba;
  --footer-height: 5.25rem;
  --icon-button-size: 3.25rem;
}

html,
body {
  min-height: 100%;
  background: var(--page-background);
  color: var(--text);
  overscroll-behavior-y: contain;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
audio {
  font: inherit;
}

button,
[data-page-target] {
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

#app-shell,
.app-page {
  min-height: 100dvh;
}

.app-page {
  background: var(--page-background);
}

#app-shell.has-navigation .app-page {
  padding-bottom: calc(var(--footer-height) + env(safe-area-inset-bottom));
}

.app-page > header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  min-height: 3.5rem;
  padding: env(safe-area-inset-top) max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
  background: var(--primary);
  color: #fff;
  box-shadow: 0 .15rem .5rem rgba(0, 0, 0, .2);
}

.app-page > header.has-back-button {
  grid-template-columns: var(--icon-button-size) minmax(0, 1fr) var(--icon-button-size);
  gap: .5rem;
}

.app-page > header.has-back-button::after {
  content: "";
}

.app-page > header h1 {
  min-width: 0;
  margin: 0;
  padding: .85rem 0;
  overflow: hidden;
  font-size: 1.25rem;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-page > header .back-button.ui-button {
  display: grid;
  place-items: center;
  width: var(--icon-button-size);
  min-width: var(--icon-button-size);
  min-height: var(--icon-button-size);
  margin: 0;
  padding: .35rem;
  border-color: rgba(255, 255, 255, .45);
  border-radius: .45rem;
  background: var(--primary-dark);
  color: #fff;
}

.app-page > header .back-button.ui-button img {
  width: 1.25rem;
  height: 1.25rem;
  pointer-events: none;
}

.content {
  width: min(48rem, 100%);
  box-sizing: border-box;
  margin: 0 auto;
  padding: 1rem max(1rem, env(safe-area-inset-right)) calc(1.5rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.notice {
  margin: 0 0 1rem;
  padding: .75rem;
  border-left: .35rem solid var(--notice-border);
  border-radius: .25rem;
  background: var(--notice);
}

#routes-page .content > section + section {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid #c8d3ca;
}

#routes-page h2 {
  margin-bottom: .75rem;
}

#routes-page label {
  display: block;
  margin-bottom: .35rem;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 600;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .35rem;
}

#route-search {
  width: 100%;
  min-height: 3rem;
  box-sizing: border-box;
  padding: .65rem .75rem;
  border: 1px solid #aebcaf;
  border-radius: .3rem;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

#route-search:focus {
  outline: .2rem solid var(--focus);
  outline-offset: .1rem;
}

#clear-route-search.ui-button {
  min-width: 3rem;
  min-height: 3rem;
  margin: 0;
}

#all-routes-summary {
  margin: .75rem 0;
  color: var(--muted);
  font-size: .9rem;
}

.ui-autocomplete {
  max-height: min(16rem, 45dvh);
  overflow: auto;
}

.route-list {
  display: grid;
  gap: .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.route-list button {
  display: grid;
  width: 100%;
  min-height: 3.5rem;
  box-sizing: border-box;
  gap: .25rem;
  padding: 1rem;
  border: 1px solid #c8d3ca;
  border-radius: .65rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 .12rem .35rem rgba(0, 0, 0, .08);
  text-align: left;
  cursor: pointer;
}

.route-list button > strong {
  font-size: 1.05rem;
}

.route-list button > span,
.route-list button > small {
  color: var(--muted);
}

.route-list button > small {
  margin-top: .25rem;
  font-weight: 600;
}

.route-list button:focus-visible,
.ui-button:focus-visible {
  outline: .2rem solid var(--focus);
  outline-offset: .15rem;
}

.route-list button:disabled {
  cursor: progress;
  opacity: .65;
}

#poi-list button {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

#poi-list button > strong,
#poi-list button > span:not(.poi-proximity) {
  grid-column: 1;
}

.poi-proximity {
  display: grid;
  grid-column: 2;
  grid-row: 1 / span 2;
  place-items: center;
  min-width: 3.75rem;
  gap: .15rem;
  padding-left: .5rem;
}

.poi-proximity svg {
  width: 1.65rem;
  height: 1.65rem;
  fill: var(--primary-dark);
  transform: rotate(0deg);
  transform-origin: 50% 50%;
  transition: transform 180ms linear;
  will-change: transform;
}

.poi-proximity small {
  color: var(--text);
  font-size: .8rem;
  font-weight: 700;
  white-space: nowrap;
}

#poi-list button[aria-current="step"] {
  border-color: var(--primary);
  background: #e7f1e9;
  box-shadow: inset .35rem 0 0 var(--primary), 0 .12rem .35rem rgba(0, 0, 0, .08);
}

#poi-list button[aria-current="step"] > strong::after {
  content: " · aktuelle Station";
  color: var(--primary-dark);
  font-size: .85rem;
  font-weight: 600;
}

.route-list > li > p {
  margin: 0;
  padding: 1rem;
  border-radius: .5rem;
  background: var(--surface);
  color: var(--muted);
}

#route-page dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
  margin: 1rem 0;
}

#route-page dl > div {
  padding: .75rem;
  border-radius: .5rem;
  background: var(--surface);
  text-align: center;
}

#route-page dt {
  color: var(--muted);
  font-size: .8rem;
}

#route-page dd {
  margin: .25rem 0 0;
  font-weight: 700;
}

#route-page fieldset,
#slideshow > fieldset {
  min-width: 0;
  border: 0;
}

#route-page fieldset {
  display: grid;
  padding: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
  margin: 0 0 1rem;
}

#route-page fieldset button.ui-button {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 3.25rem;
  box-sizing: border-box;
  padding: .55rem;
  border: 1px solid transparent;
  border-radius: .55rem;
  box-shadow: 0 .12rem .35rem rgba(0, 0, 0, .12);
  cursor: pointer;
  touch-action: manipulation;
}

#route-page fieldset button.ui-button:focus-visible {
  outline: .2rem solid var(--focus);
  outline-offset: .15rem;
}

#route-page fieldset button.ui-button:disabled {
  cursor: default;
  filter: grayscale(.65);
  opacity: .42;
}

#route-page fieldset button.ui-button img {
  width: 2rem;
  height: 2rem;
  pointer-events: none;
}

#route-page fieldset > legend,
#slideshow > fieldset > legend {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#start-route {
  background: var(--primary);
  border-color: var(--primary-dark);
}

#pause-route {
  background: #9a6500;
  border-color: #704a00;
}

#stop-route {
  background: #9b2c2c;
  border-color: #701f1f;
}

#slideshow {
  overflow: hidden;
  border-radius: .75rem;
  background: #172019;
  color: #fff;
  touch-action: pan-y;
}

#slideshow figure {
  margin: 0;
}

#slide-image {
  display: block;
  width: 100%;
  height: min(55vh, 28rem);
  height: min(55dvh, 28rem);
  object-fit: contain;
  background: #111;
}

#slideshow > fieldset {
  display: grid;
  grid-template-columns: var(--icon-button-size) minmax(0, 1fr) var(--icon-button-size);
  align-items: center;
  gap: .5rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: 0;
  padding: .65rem;
}

#slideshow > fieldset > button.ui-button {
  display: grid;
  place-items: center;
  width: var(--icon-button-size);
  height: var(--icon-button-size);
  min-width: var(--icon-button-size);
  min-height: var(--icon-button-size);
  margin: 0;
  padding: .45rem;
}

#slideshow > fieldset .ui-button img {
  width: 1.2rem;
  height: 1.2rem;
  pointer-events: none;
}

#slideshow > fieldset > div {
  display: flex;
  align-self: stretch;
  min-width: 0;
  min-height: var(--icon-button-size);
  padding: .25rem .4rem;
  border-radius: .45rem;
  background: rgba(255, 255, 255, .06);
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

#slide-caption {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

#slide-position {
  display: block;
  margin-top: .15rem;
  color: rgba(255, 255, 255, .86);
  font-size: .9rem;
  font-weight: 600;
}

#poi-audio {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-top: 1rem;
}

#poi-audio[hidden] {
  display: none;
}

#navigation-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 3.75rem minmax(0, 1fr);
  align-items: center;
  min-height: var(--footer-height);
  box-sizing: border-box;
  gap: .85rem;
  padding: .6rem max(1rem, env(safe-area-inset-right)) calc(.6rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  border-top: 1px solid rgba(255, 255, 255, .35);
  background: rgba(36, 70, 43, .96);
  color: #fff;
  box-shadow: 0 -.25rem .8rem rgba(0, 0, 0, .2);
  backdrop-filter: blur(.4rem);
}

#navigation-arrow {
  width: 3.5rem;
  height: 3.5rem;
  fill: currentColor;
  transform: rotate(0deg);
  transform-origin: 50% 50%;
  transition: transform 180ms linear;
  will-change: transform;
}

#navigation-footer p {
  display: grid;
  gap: .15rem;
  margin: 0;
}

#navigation-mode {
  overflow: hidden;
  font-size: .78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#navigation-distance {
  font-size: 1.5rem;
  line-height: 1.1;
}

@media (hover: hover) {
  .route-list button:hover {
    border-color: var(--primary);
    box-shadow: 0 .2rem .55rem rgba(0, 0, 0, .13);
  }

  .app-page > header .back-button.ui-button:hover,
  .app-page > header .back-button.ui-button:focus,
  #start-route:not(:disabled):hover,
  #start-route:not(:disabled):focus {
    background: var(--primary-dark);
    color: #fff;
  }

  #pause-route:not(:disabled):hover,
  #pause-route:not(:disabled):focus {
    background: #704a00;
  }

  #stop-route:not(:disabled):hover,
  #stop-route:not(:disabled):focus {
    background: #701f1f;
  }
}

@media (max-width: 32rem) {
  .search-row {
    grid-template-columns: minmax(0, 1fr) 3rem;
  }

  #route-page dl {
    gap: .35rem;
  }

  #route-page dl > div {
    padding: .6rem .25rem;
  }
}

@media (max-width: 22rem) {
  #route-page dl {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

.info-button {
  position: fixed;
  top: calc(env(safe-area-inset-top) + .45rem);
  right: max(.65rem, env(safe-area-inset-right));
  z-index: 10001;
  display: grid;
  place-items: center;
  width: var(--icon-button-size);
  height: var(--icon-button-size);
  padding: 0;
  border: 2px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  background: var(--primary-dark);
  color: #fff;
  box-shadow: 0 .15rem .55rem rgba(0, 0, 0, .28);
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.info-button:focus-visible {
  outline: .2rem solid #fff;
  outline-offset: .15rem;
}

.app-page > header:not(.has-back-button) h1 {
  padding-right: calc(var(--icon-button-size) + 1rem);
  padding-left: calc(var(--icon-button-size) + 1rem);
}

.switch-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .85rem;
  box-sizing: border-box;
  width: 100%;
  padding: .75rem;
  border: 1px solid #c8d3ca;
  border-radius: .65rem;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.switch-row > span:first-child {
  display: grid;
  min-width: 0;
  gap: .2rem;
}

.switch-row small {
  color: var(--muted);
  line-height: 1.35;
}

.switch-row > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  display: inline-block;
  width: 3.25rem;
  height: 1.8rem;
  border: 2px solid #6b786e;
  border-radius: 999px;
  background: #d9ded9;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.switch-track::after {
  position: absolute;
  top: .15rem;
  left: .15rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 .08rem .2rem rgba(0, 0, 0, .35);
  content: "";
  transition: transform 160ms ease;
}

.switch-row > input:checked + .switch-track {
  border-color: var(--primary-dark);
  background: var(--primary);
}

.switch-row > input:checked + .switch-track::after {
  transform: translateX(1.45rem);
}

.switch-row > input:focus-visible + .switch-track {
  outline: .2rem solid var(--focus);
  outline-offset: .15rem;
}

.switch-disabled {
  cursor: not-allowed;
  opacity: .72;
}

.compact-switch {
  margin: 1rem 0;
}

.info-dialog {
  width: min(48rem, calc(100% - 1.5rem));
  max-width: 48rem;
  height: min(48rem, calc(100dvh - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  box-sizing: border-box;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: .85rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 .8rem 2.5rem rgba(0, 0, 0, .35);
}

.info-dialog::backdrop {
  background: rgba(12, 20, 14, .72);
  backdrop-filter: blur(.15rem);
}

.info-dialog-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

.info-dialog-header {
  display: grid;
  grid-template-columns: var(--icon-button-size) minmax(0, 1fr) var(--icon-button-size);
  align-items: center;
  gap: .4rem;
  padding: max(.4rem, env(safe-area-inset-top)) .5rem .4rem;
  background: var(--primary);
  color: #fff;
}

.info-dialog-header h2 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 1.15rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.info-dialog-header button {
  display: grid;
  place-items: center;
  width: var(--icon-button-size);
  height: var(--icon-button-size);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: .45rem;
  background: var(--primary-dark);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.info-dialog-content {
  min-height: 0;
  padding: 1rem max(1rem, env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.info-menu {
  display: grid;
  gap: .75rem;
}

.info-menu button {
  min-height: 3.5rem;
  padding: .85rem 1rem;
  border: 1px solid #aebcaf;
  border-radius: .65rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 .12rem .35rem rgba(0, 0, 0, .08);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.info-page {
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.info-page h3 {
  margin: 1.4rem 0 .45rem;
  color: var(--primary-dark);
}

.info-page h3:first-of-type {
  margin-top: .5rem;
}

.info-page code {
  padding: .08rem .25rem;
  border-radius: .2rem;
  background: #e8eee7;
}

.legal-warning {
  margin: 0 0 1rem;
  padding: .8rem;
  border-left: .35rem solid var(--notice-border);
  border-radius: .25rem;
  background: var(--notice);
}

@media (max-width: 34rem) {
  .info-dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .switch-row {
    gap: .55rem;
    padding: .65rem;
  }
}
