:root {
  --db-red: #e2001a;
  --splash: #6d1730;
  --ink: #2b2b2b;
  --muted: #6c6c6c;
  --line: #d9d9d9;
  --soft: #eef3f5;
  --nav: #292c35;
  --role: #bd2857;
  --role-dark: #74142d;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  background: #fff;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
}

.template-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  pointer-events: none;
}

.screen > :not(.template-bg) {
  position: relative;
  z-index: 1;
}

.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash {
  display: grid;
  place-items: center;
  background: var(--splash);
  color: #fff;
}

.splash h1 {
  position: absolute;
  top: 53.3%;
  left: 50%;
  width: min(84vw, 560px);
  transform: translateX(-50%);
  margin: 0;
  font-size: clamp(22px, 4.2vw, 30px);
  line-height: 1.12;
  text-align: center;
  letter-spacing: 0;
  font-weight: 800;
}

.splash .db-logo,
.splash h1 {
  opacity: 0;
}

.db-logo--white {
  position: absolute;
  top: 9%;
  left: 50%;
  width: 66px;
  height: auto;
  transform: translateX(-50%);
  color: #fff;
}

.db-logo--red {
  flex: 0 0 auto;
  width: clamp(48px, 12vw, 58px);
  height: auto;
  color: var(--db-red);
}

.db-logo-img {
  flex: 0 0 auto;
  width: 50px;
  height: 34px;
  object-fit: contain;
  transform: translateZ(0);
}

.db-frame {
  fill: none;
  stroke: currentColor;
  stroke-width: 9;
}

.db-text {
  fill: currentColor;
  stroke: none;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 48px;
  font-weight: 900;
  letter-spacing: -3px;
}

.home {
  display: flex;
  flex-direction: column;
}

.topbar,
.searchbar,
.journey-header,
.editor-header {
  position: relative;
  z-index: 4;
  min-height: 70px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px 14px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.brand strong {
  overflow: hidden;
  color: #2a2a2a;
  font-size: clamp(19px, 4.9vw, 25px);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.actions,
.journey-header {
  display: flex;
  align-items: center;
}

.actions {
  gap: clamp(10px, 3vw, 18px);
  margin-left: 8px;
}

.actions button,
.journey-header button {
  display: grid;
  place-items: center;
  width: clamp(32px, 8.2vw, 42px);
  height: clamp(32px, 8.2vw, 42px);
  padding: 0;
  border: 0;
  background: transparent;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.actions svg,
.journey-header svg,
.search-field svg,
.choice-icon svg,
.inline-train {
  width: 100%;
  height: 100%;
  stroke-width: 2.2;
}

.header-icon,
.search-field-icon,
.choice-icon-img,
.journey-logout-icon,
.journey-action-icon,
.tab-icon,
.badge-train-icon {
  display: block;
  object-fit: contain;
}

.header-icon {
  width: 36px;
  height: 36px;
}

.header-icon--menu {
  width: 31px;
  height: 31px;
}

.header-icon--back {
  width: 31px;
  height: 31px;
}

.content {
  display: flex;
  flex: 1;
  align-items: flex-end;
  min-height: 0;
  height: calc(100% - 70px);
  padding: 0 clamp(20px, 6vw, 34px) 38px;
  background: linear-gradient(180deg, var(--soft) 0%, var(--soft) 80%, #f8fafb 100%);
}

.card-stack {
  display: grid;
  width: 100%;
  gap: 18px;
}

.choice-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 36px;
  align-items: center;
  width: 100%;
  min-height: 100px;
  padding: 17px clamp(18px, 5vw, 24px);
  border: 1px solid #d2d2d2;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
  text-align: left;
}

.choice-card--compact {
  min-height: 76px;
  grid-template-columns: 48px minmax(0, 1fr) 36px;
}

.choice-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #2f2f2f;
}

.train-icon {
  width: 42px;
  height: 60px;
}

.choice-icon-img--train {
  width: 42px;
  height: 60px;
}

.choice-icon-img--bell {
  width: 35px;
  height: 40px;
}

.choice-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.choice-copy strong {
  overflow-wrap: anywhere;
  font-size: clamp(20px, 4.2vw, 24px);
  font-weight: 800;
  line-height: 1;
}

.choice-copy span {
  color: var(--muted);
  font-size: clamp(16px, 3.4vw, 20px);
  line-height: 1.15;
}

.arrow {
  justify-self: end;
  font-size: 34px;
  line-height: 1;
}

.app-page {
  display: flex;
  flex-direction: column;
}

.searchbar {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 32px;
  align-items: center;
  column-gap: 11px;
  min-height: 86px;
  padding: 12px 11px 9px 20px;
}

.icon-button,
.menu-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #252525;
  font-size: 36px;
  line-height: 1;
}

.menu-button {
  font-size: 29px;
}

.search-field {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 28px;
  align-items: center;
  min-height: 58px;
  padding: 0 12px;
  border-bottom: 2px solid #252a31;
  border-radius: 5px 5px 0 0;
  background: #eef3f6;
}

.search-field svg,
.search-field-icon {
  width: 27px;
  height: 27px;
  color: #303030;
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 18px;
  caret-color: transparent;
  z-index: 2;
}

.search-caret {
  position: absolute;
  left: 56px;
  top: 14px;
  display: none;
  width: 3px;
  height: 32px;
  background: #c61d50;
  animation: slow-caret 1.35s steps(1, end) infinite;
}

.search-field:focus-within .search-caret {
  display: block;
}

.search-field.has-value .search-caret {
  display: none;
}

@keyframes slow-caret {
  0%, 48% { opacity: 1; }
  49%, 100% { opacity: 0; }
}

.clear-button {
  width: 25px;
  height: 25px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #5d6670;
  color: #fff;
  font-size: 22px;
  line-height: 1;
}

.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px max(22px, env(safe-area-inset-bottom));
  background: var(--soft);
  scrollbar-width: none;
}

.page-body::-webkit-scrollbar {
  display: none;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 72%;
  color: #4b4b4b;
  text-align: center;
}

.empty-state .inline-train {
  width: 46px;
  height: 63px;
  margin-bottom: 24px;
  stroke-width: 2.1;
}

.empty-state p {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.date-list {
  padding-top: 16px;
}

.recent-list {
  padding-top: 27px;
}

.recent-list h2 {
  margin: 0 0 30px;
  color: #262b34;
  font-size: 22px;
  font-weight: 800;
}

.recent-group {
  display: grid;
  justify-items: start;
  gap: 13px;
  margin-bottom: 28px;
}

.recent-group p {
  margin: 0;
  color: #2d3037;
  font-size: 18px;
}

.recent-badge {
  border: 0;
  min-height: 28px;
  padding: 4px 6px;
  gap: 5px;
  font-size: 14px;
}

.recent-badge .badge-train-icon {
  width: 16px;
  height: 20px;
}

.recent-badge .badge-separator {
  width: 1px;
  height: 22px;
}

.date-group {
  border-bottom: 1px solid #ddd;
}

.date-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 20px 0 19px;
  border: 0;
  background: transparent;
  color: #333;
  font-size: 22px;
  font-weight: 800;
  text-align: left;
}

.result-card {
  display: grid;
  grid-template-columns: 66px 28px minmax(0, 1fr);
  width: 100%;
  min-height: 148px;
  margin-bottom: 24px;
  padding: 22px 16px;
  border: 1px solid #d6d6d6;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  text-align: left;
}

.card-times {
  display: grid;
  align-content: space-between;
  min-height: 104px;
  text-align: right;
}

.card-times b {
  font-size: 19px;
}

.card-times em {
  color: #699256;
  font-size: 16px;
  font-style: italic;
}

.card-times span {
  color: #686868;
  white-space: pre-line;
  font-size: 15px;
}

.mini-route {
  position: relative;
  display: grid;
  justify-items: center;
}

.mini-route .ring {
  width: 15px;
  height: 15px;
  border: 3px solid #4e555c;
  border-radius: 50%;
}

.mini-route .line {
  width: 4px;
  height: 68px;
  margin-top: 4px;
  border-radius: 4px;
  background: #4e555c;
}

.mini-route .pin {
  width: 19px;
  height: 19px;
  margin-top: 8px;
  border-radius: 50% 50% 50% 0;
  background: #aeb4bd;
  transform: rotate(-45deg);
}

.card-places {
  display: grid;
  align-content: space-between;
  min-width: 0;
  padding-left: 10px;
}

.card-places b {
  font-size: 19px;
}

.train-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-self: start;
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 5px;
  background: #777986;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.train-badge .inline-train {
  width: 19px;
  height: 24px;
}

.badge-train-icon {
  width: 18px;
  height: 23px;
}

.badge-separator {
  width: 2px;
  height: 24px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.55);
}

.empty-state .badge-train-icon {
  width: 46px;
  height: 63px;
  margin-bottom: 24px;
}

.empty-state .badge-separator {
  display: none;
}

.sheet {
  position: absolute;
  inset: 0;
  z-index: 20;
}

.sheet .sheet-backdrop,
.sheet .sheet-panel {
  opacity: 1;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(30, 35, 45, 0.55);
}

.sheet-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  border: 1px solid #d6dbe0;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #fff;
  padding-bottom: 34px;
}

.sheet-panel p {
  display: grid;
  place-items: center;
  min-height: 66px;
  margin: 0;
  padding: 8px 14px 10px;
  border-bottom: 1px solid #d8d8d8;
  color: #242832;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.32;
  text-align: center;
}

.sheet-panel button {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-height: 51px;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid #d8d8d8;
  background: #fff;
  text-align: left;
}

.role-line {
  display: block;
  white-space: nowrap;
}

.role-line:first-child {
  transform: scaleX(0.88);
}

.sheet-panel button[data-role] b {
  justify-self: start;
  min-width: 61px;
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--role);
  color: #fff;
  font-size: 16px;
  line-height: 1.2;
  text-align: center;
}

.sheet-panel p b {
  font-weight: 800;
}

.sheet-panel button[data-role]:nth-of-type(3) b {
  background: var(--role-dark);
}

.sheet-panel button[data-role]:nth-of-type(4) b {
  background: #d8dce2;
  color: #39404a;
}

.sheet-panel span {
  overflow: hidden;
  color: #242832;
  font-size: 20px;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.journey-page {
  display: flex;
  flex-direction: column;
}

.safety-page {
  display: flex;
  flex-direction: column;
  background: var(--soft);
}

.journey-header {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 1px 46px 39px;
  gap: 8px;
  align-items: center;
  min-height: 91px;
  padding: 16px 20px 14px 18px;
  box-shadow: none;
}

.journey-header strong {
  align-self: center;
  font-size: 27px;
  font-weight: 800;
}

.logout-button {
  font-size: 28px;
}

.journey-logout-icon {
  width: 30px;
  height: 31px;
}

.journey-action-icon {
  width: 32px;
  height: 33px;
}

.journey-action-icon--menu {
  width: 28px;
  height: 28px;
}

.route-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 26px calc(105px + env(safe-area-inset-bottom)) 28px;
  background: #fff;
  scrollbar-width: none;
}

.route-scroll::-webkit-scrollbar {
  display: none;
}

.booked-role {
  margin: -12px 0 18px;
  color: #7b7b7b;
  font-size: 15px;
}

.route-list {
  position: relative;
  margin: 0;
  padding: 0 0 0 34px;
  list-style: none;
}

.route-list::before {
  position: absolute;
  top: 11px;
  bottom: 14px;
  left: 7px;
  width: 5px;
  border-radius: 3px;
  background: #d8dde5;
  content: "";
}

.route-list li {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 12px;
  min-height: 114px;
  padding: 0 0 26px;
  border-bottom: 1px solid #d9d9d9;
}

.route-list li + li {
  padding-top: 26px;
}

.route-node {
  position: absolute;
  top: 6px;
  left: -35px;
  width: 20px;
  height: 20px;
  border: 4px solid #cfd5dd;
  border-radius: 50%;
  background: #fff;
}

.route-list .first .route-node {
  border-color: #4d545b;
}

.route-list .last .route-node {
  border-color: #cfd5dd;
  border-radius: 50% 50% 50% 0;
  background: #cfd5dd;
  transform: rotate(-45deg);
}

.stop-main {
  display: grid;
  gap: 10px;
}

.stop-main b {
  font-size: 24px;
  line-height: 1.1;
}

.stop-main span,
.platform {
  color: #5d5d5d;
  font-size: 21px;
}

.platform {
  justify-self: end;
  padding-top: 4px;
}

.bottom-tabs {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: calc(91px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--nav);
}

.bottom-tabs button {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  padding: 10px 0 12px;
  border: 0;
  background: transparent;
  color: #aeb4bd;
  font-size: 15px;
}

.bottom-tabs button.active {
  color: #fff;
}

.bottom-tabs svg {
  width: 29px;
  height: 29px;
  stroke-width: 2.5;
}

.tab-icon {
  width: 33px;
  height: 30px;
}

.tab-icon--meinzug {
  width: 36px;
  height: 25px;
}

.tab-icon--bell {
  width: 32px;
  height: 30px;
}

.safety-header {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  min-height: 76px;
  padding: max(10px, env(safe-area-inset-top)) 20px 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.safety-header strong {
  font-size: 19px;
  font-weight: 800;
  white-space: nowrap;
}

.safety-close {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #252b33;
  font-size: 34px;
  line-height: 1;
}

.safety-body {
  flex: 1;
  padding: 28px 22px;
  overflow-y: auto;
}

.safety-card {
  padding: 22px 22px 16px;
  border: 1px solid #d7dce1;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
}

.safety-card h2 {
  margin: 0 0 22px;
  font-size: 20px;
}

.safety-card p {
  margin: 0 0 26px;
  font-size: 17px;
  line-height: 1.42;
}

.safety-option {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  font-size: 17px;
}

.safety-option input {
  position: absolute;
  opacity: 0;
}

.safety-option span {
  width: 28px;
  height: 28px;
  border: 3px solid #20242b;
  border-radius: 50%;
}

.safety-option input:checked + span {
  border-width: 8px;
  border-color: var(--role);
}

.checkout-button {
  width: 100%;
  min-height: 58px;
  margin-top: 28px;
  border: 0;
  border-radius: 4px;
  background: #6f7582;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.checkout-button:disabled {
  opacity: 0.62;
}

.editor-page {
  display: flex;
  flex-direction: column;
}

.editor-header {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 18px 14px;
}

.editor-header strong {
  align-self: center;
  font-size: 22px;
}

.save-editor {
  align-self: center;
  padding: 9px 12px;
  border: 0;
  border-radius: 4px;
  background: #bd2e5d;
  color: #fff;
  font-weight: 800;
}

.editor-form {
  display: grid;
  gap: 14px;
  overflow-y: auto;
  padding: 24px 22px 40px;
}

.editor-form label {
  display: grid;
  gap: 7px;
  color: #555;
  font-size: 15px;
}

.editor-form input,
.editor-form textarea {
  width: 100%;
  border: 1px solid #cfcfcf;
  border-radius: 4px;
  padding: 11px;
  outline: 0;
  background: #fff;
  font-size: 18px;
}

.editor-form textarea {
  min-height: 260px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.35;
}

.editor-hint {
  margin: 0;
  color: #666;
  font-size: 14px;
  line-height: 1.4;
}

@media (min-width: 600px) {
  body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    background: #f2f2f2;
  }

  .app-shell {
    width: min(100vw, 520px);
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }
}

@media (max-width: 360px) {
  .topbar {
    padding-inline: 18px;
  }

  .actions {
    gap: 12px;
    margin-left: 10px;
  }

  .choice-card {
    grid-template-columns: 48px minmax(0, 1fr) 34px;
    padding-inline: 17px;
  }

  .arrow {
    font-size: 38px;
  }

  .date-title {
    font-size: 21px;
  }

  .result-card {
    grid-template-columns: 62px 27px minmax(0, 1fr);
  }
}
