:root {
  --bg: #0b0d10;
  --surface: #111419;
  --surface-2: #171b21;
  --surface-3: #1d2229;
  --border: rgba(255,255,255,.09);
  --border-strong: rgba(255,255,255,.15);
  --text: #f5f7f8;
  --muted: #8d97a3;
  --muted-2: #68727e;
  --accent: #d8ff5d;
  --accent-ink: #11150a;
  --positive: #9ae6b4;
  --warning: #ffd37a;
  --negative: #ff9b9b;
  --blue: #95caff;
  --radius: 24px;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; background: var(--bg); }
html { color-scheme: dark; }
body {
  color: var(--text);
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 440px at 50% -240px, rgba(216,255,93,.12), transparent 70%),
    var(--bg);
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-frame {
  width: min(100%, 1040px);
  height: 100dvh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 20px max(10px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
}

.topbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--accent-ink); background: var(--accent);
  font-size: 12px; font-weight: 950; letter-spacing: -.02em;
}
.brand > div { display: grid; gap: 2px; min-width: 0; }
.brand strong { font-size: 14px; letter-spacing: -.01em; }
.source-line { color: var(--muted); font-size: 10px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-line.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--positive); box-shadow: 0 0 10px rgba(154,230,180,.4); }
.source-line.fallback { color: var(--warning); }
.top-actions { display: flex; align-items: center; gap: 7px; }
.action-button, .icon-button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  height: 36px;
  border-radius: 12px;
  cursor: pointer;
}
.action-button { padding: 0 12px; font-size: 11px; font-weight: 800; }
.install-button { border-color: rgba(216,255,93,.28); color: var(--accent); background: rgba(216,255,93,.07); }
.icon-button { width: 36px; font-size: 18px; }
.icon-button.loading { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toolbar { display: grid; grid-template-columns: auto minmax(180px, 300px); align-items: center; justify-content: space-between; gap: 10px; }
.tabs { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; }
.tab { border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; padding: 8px 12px; font-size: 12px; font-weight: 800; }
.tab.active { color: #111317; background: var(--text); }
.tab b { font-size: 10px; opacity: .5; margin-left: 4px; }
.search-wrap { height: 36px; position: relative; display: block; }
.search-wrap > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }
.search-wrap input { width: 100%; height: 100%; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); outline: none; padding: 0 12px 0 32px; font-size: 12px; }
.search-wrap input:focus { border-color: rgba(216,255,93,.35); box-shadow: 0 0 0 3px rgba(216,255,93,.06); }

.viewer { min-height: 0; overflow: hidden; }
.card-scroller {
  width: 100%; height: 100%;
  display: flex;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  touch-action: pan-y;
}
.card-scroller.dragging { scroll-behavior: auto; scroll-snap-type: none; }
.card-scroller::-webkit-scrollbar { display: none; }
.snap-card {
  flex: 0 0 100%; width: 100%; height: 100%;
  min-width: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  padding: 0 1px;
}
.trip-card {
  height: 100%; width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,.018), transparent 25%), var(--surface);
  box-shadow: 0 22px 70px rgba(0,0,0,.24);
  padding: clamp(15px, 2.2vh, 22px) clamp(16px, 2.8vw, 28px);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.trip-card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.trip-id { display: flex; align-items: baseline; gap: 8px; }
.trip-id span { font-size: 10px; letter-spacing: .16em; font-weight: 900; color: var(--muted); }
.trip-id small { font-size: 9px; color: var(--muted-2); }
.pill { display: inline-flex; align-items: center; height: 26px; padding: 0 9px; border-radius: 999px; font-size: 10px; font-weight: 850; border: 1px solid var(--border-strong); background: var(--surface-2); white-space: nowrap; }
.pill.positive { color: var(--positive); border-color: rgba(154,230,180,.24); background: rgba(154,230,180,.06); }
.pill.warning { color: var(--warning); border-color: rgba(255,211,122,.24); background: rgba(255,211,122,.06); }
.pill.negative { color: var(--negative); border-color: rgba(255,155,155,.24); background: rgba(255,155,155,.06); }

.route-block {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(88px, .36fr) minmax(0,1fr);
  align-items: center;
  gap: 16px;
  margin-top: clamp(15px, 2.5vh, 26px);
}
.city-block { min-width: 0; }
.city-block > span { display: block; font-size: 9px; letter-spacing: .16em; font-weight: 900; color: var(--muted-2); margin-bottom: 5px; }
.city-block h2 { margin: 0; font-size: clamp(27px, 5.2vh, 48px); line-height: .98; letter-spacing: -.055em; font-weight: 790; overflow-wrap: anywhere; }
.city-block-right { text-align: right; }
.route-link { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 7px; color: var(--accent); }
.route-link span { font-size: 9px; font-weight: 950; letter-spacing: .12em; }
.route-link i { height: 1px; background: linear-gradient(90deg, rgba(216,255,93,.2), var(--accent), rgba(216,255,93,.2)); }
.route-link b { font-size: 20px; line-height: 1; font-weight: 400; }
.transport-line { margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 24px; }
.transport-name, .train-number { font-size: 10px; font-weight: 850; }
.transport-name { color: var(--text); }
.train-number { color: var(--muted); padding-left: 7px; border-left: 1px solid var(--border-strong); }
.muted-value { color: var(--muted-2); }

.schedule-card {
  margin-top: clamp(12px, 2vh, 18px);
  display: grid;
  grid-template-columns: 1fr minmax(88px, .52fr) 1fr;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--border);
  background: #0d1014;
  border-radius: 17px;
  padding: clamp(11px, 1.7vh, 15px) 14px;
}
.schedule-point { display: grid; gap: 1px; }
.schedule-point:last-child { text-align: right; }
.schedule-point > span { font-size: 8px; letter-spacing: .14em; font-weight: 950; color: var(--muted-2); }
.schedule-point strong { font-size: clamp(18px, 3.1vh, 26px); line-height: 1.05; letter-spacing: -.03em; }
.schedule-point small { color: var(--muted); font-size: 9px; font-weight: 650; }
.schedule-point.is-missing strong, .schedule-point.is-missing small { color: var(--muted-2); }
.duration-block { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 7px; color: var(--muted); }
.duration-block i { height: 1px; background: var(--border-strong); }
.duration-block span { font-size: 9px; font-weight: 850; white-space: nowrap; }

.details-section { margin-top: clamp(12px, 1.8vh, 18px); }
.details-section-last { min-height: 0; }
.section-title { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; margin-bottom: 7px; }
.section-title span { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.section-title i { height: 1px; background: var(--border); }
.details-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 7px; }
.details-grid-secondary { grid-template-columns: repeat(2, minmax(0,1fr)); }
.datum { min-width: 0; border: 1px solid var(--border); background: var(--surface-2); border-radius: 13px; padding: 9px 10px; display: grid; align-content: center; gap: 4px; }
.datum-wide { grid-column: 1 / -1; }
.datum-label { color: var(--muted-2); font-size: 8px; text-transform: uppercase; letter-spacing: .1em; font-weight: 900; }
.datum-value { color: var(--text); font-size: 11px; line-height: 1.25; overflow-wrap: anywhere; }
.datum-value.positive { color: var(--positive); }
.datum-value.warning { color: var(--warning); }
.datum-value.negative { color: var(--negative); }
.datum-value.emphasis { color: var(--accent); font-size: 13px; }
.missing { color: var(--muted-2); font-weight: 650; }

.stay-card { background: linear-gradient(180deg, rgba(149,202,255,.035), transparent 34%), var(--surface); }
.stay-hero { text-align: center; margin: clamp(24px, 5vh, 54px) auto clamp(18px, 3vh, 30px); max-width: 680px; }
.stay-type { color: var(--blue); font-size: 10px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.stay-hero h2 { margin: 8px 0 9px; font-size: clamp(28px, 5vh, 48px); line-height: 1.02; letter-spacing: -.045em; overflow-wrap: anywhere; }
.platform-line { color: var(--muted); font-size: 11px; font-weight: 700; }
.stay-details { margin-top: clamp(18px, 3vh, 30px); }

.pager { min-height: 46px; display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; gap: 10px; }
.pager-button { width: 42px; height: 38px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: 17px; }
.pager-button:disabled { opacity: .25; cursor: default; }
.pager-center { display: grid; justify-items: center; gap: 5px; }
.pager-text { font-size: 10px; font-weight: 850; color: var(--muted); letter-spacing: .08em; }
.pager-dots { display: flex; gap: 4px; height: 4px; }
.pager-dots i { width: 4px; height: 4px; border-radius: 99px; background: #313740; transition: width .18s ease, background .18s ease; }
.pager-dots i.active { width: 13px; background: var(--accent); }

.empty-state { flex: 0 0 100%; height: 100%; display: grid; place-content: center; text-align: center; gap: 6px; color: var(--muted); }
.empty-state strong { color: var(--text); font-size: 18px; }
.empty-state span { font-size: 12px; }

.install-dialog { width: min(90vw, 360px); color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 22px; padding: 0; box-shadow: 0 24px 100px rgba(0,0,0,.55); }
.install-dialog::backdrop { background: rgba(0,0,0,.66); backdrop-filter: blur(5px); }
.install-dialog form { padding: 24px; text-align: center; }
.dialog-icon { width: 58px; height: 58px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 17px; background: var(--accent); color: var(--accent-ink); font-weight: 950; }
.install-dialog h2 { margin: 0 0 8px; font-size: 20px; }
.install-dialog p { margin: 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.dialog-close { width: 100%; height: 40px; border: 0; border-radius: 12px; background: var(--text); color: #111317; font-weight: 850; cursor: pointer; }

@media (max-width: 720px) {
  .app-frame { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .toolbar { grid-template-columns: 1fr minmax(120px, .72fr); }
  .tab { padding-left: 10px; padding-right: 10px; }
  .trip-card { border-radius: 21px; padding-left: 14px; padding-right: 14px; }
  .route-block { grid-template-columns: minmax(0,1fr) 66px minmax(0,1fr); gap: 8px; }
  .route-link { gap: 5px; }
  .city-block h2 { font-size: clamp(25px, 7vw, 34px); }
  .schedule-card { grid-template-columns: 1fr 62px 1fr; gap: 8px; padding-left: 10px; padding-right: 10px; }
  .details-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .booking-grid .datum { min-height: 48px; }
  .details-grid-secondary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .top-actions .action-button { padding: 0 9px; }
}

@media (max-width: 420px) {
  .app-frame { padding-top: max(9px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .brand-mark { width: 34px; height: 34px; flex-basis: 34px; border-radius: 10px; }
  .brand strong { font-size: 13px; }
  .source-line { font-size: 9px; max-width: 150px; }
  .action-button, .icon-button { height: 34px; }
  .icon-button { width: 34px; }
  .toolbar { gap: 6px; }
  .tabs { border-radius: 11px; }
  .tab { padding: 7px 8px; font-size: 11px; }
  .search-wrap { height: 34px; }
  .search-wrap input { font-size: 11px; }
  .trip-card { padding-top: 12px; padding-bottom: 12px; }
  .route-block { margin-top: 12px; }
  .city-block h2 { font-size: clamp(22px, 7vw, 30px); }
  .transport-line { margin-top: 7px; }
  .schedule-card { margin-top: 9px; padding-top: 9px; padding-bottom: 9px; }
  .schedule-point strong { font-size: 18px; }
  .details-section { margin-top: 9px; }
  .datum { padding: 7px 8px; border-radius: 11px; }
  .datum-label { font-size: 7px; }
  .datum-value { font-size: 10px; }
  .datum-value.emphasis { font-size: 11px; }
  .pager { min-height: 40px; }
  .pager-button { height: 34px; }
}

@media (max-height: 680px) {
  .app-frame { gap: 6px; }
  .topbar { min-height: 40px; }
  .brand-mark { width: 32px; height: 32px; flex-basis: 32px; }
  .action-button, .icon-button, .search-wrap { height: 32px; }
  .icon-button { width: 32px; }
  .tab { padding-top: 6px; padding-bottom: 6px; }
  .trip-card { padding-top: 10px; padding-bottom: 10px; }
  .trip-card-head .pill { height: 23px; }
  .route-block { margin-top: 8px; }
  .city-block h2 { font-size: clamp(22px, 5.5vh, 32px); }
  .transport-line { min-height: 18px; margin-top: 4px; }
  .schedule-card { margin-top: 6px; padding-top: 7px; padding-bottom: 7px; }
  .schedule-point strong { font-size: 17px; }
  .details-section { margin-top: 6px; }
  .section-title { margin-bottom: 5px; }
  .datum { padding: 6px 8px; }
  .pager { min-height: 34px; }
  .pager-button { height: 32px; }
}
