:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f3f6);
  --text: var(--tg-theme-text-color, #111418);
  --hint: var(--tg-theme-hint-color, #7d8590);
  --accent: var(--tg-theme-button-color, #1f9d76);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #1f9d76);
  --danger: var(--tg-theme-destructive-text-color, #d9453b);
  --ok: #1f9d76;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #17191d; --bg2: #0f1013; --text: #eceef1; --hint: #8b929b;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding: 12px 12px 90px; }
h1 { font-size: 22px; margin: 0 0 2px; }
h2 { font-size: 18px; margin: 0; }
h3 { margin: 0; font-size: 17px; }
.hidden { display: none !important; }
.muted { color: var(--hint); margin: 0; }
.small { font-size: 13px; }
.center { text-align: center; margin: 14px 0; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.top { margin: 4px 4px 14px; }
.label { display: block; font-size: 13px; color: var(--hint); margin-bottom: 8px; font-weight: 500; }
.card { background: var(--bg); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
details.card summary { cursor: pointer; margin: 0; list-style: none; }
details.card summary::after { content: ' ▾'; }
details[open] summary { margin-bottom: 12px; }

.btn { width: 100%; border: 0; border-radius: 12px; padding: 14px; font-size: 16px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn:disabled { opacity: .5; }
.link { background: none; border: 0; color: var(--link); font-size: 15px; cursor: pointer; padding: 4px 0; }
.input { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--hint) 30%, transparent);
  background: var(--bg2); color: var(--text); font-size: 15px; margin-top: 6px; }
.tg .fallback-main, .tg .fallback-back { display: none; }

/* Route picker */
.route { position: relative; padding: 4px 14px; }
.station { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 12px 40px 12px 0; color: var(--text); cursor: pointer; }
.station + .swap + .station { border-top: 1px solid color-mix(in srgb, var(--hint) 20%, transparent); }
.station .label { margin: 0 0 2px; }
.station .value { font-size: 17px; font-weight: 600; }
.station .value.placeholder { color: var(--hint); font-weight: 400; }
.swap { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: var(--bg2); color: var(--accent); font-size: 18px; cursor: pointer; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid color-mix(in srgb, var(--hint) 35%, transparent); background: transparent; color: var(--text);
  padding: 7px 12px; border-radius: 999px; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* Trains */
.train-list { display: flex; flex-direction: column; gap: 8px; }
.train { border: 1.5px solid color-mix(in srgb, var(--hint) 22%, transparent); border-radius: 12px; padding: 10px 12px; cursor: pointer; background: none; color: var(--text); text-align: left; width: 100%; }
.train.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.train .times { font-weight: 700; font-size: 16px; }
.train .meta { color: var(--hint); font-size: 13px; }
.seats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.seat { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--bg2); }
.seat.zero { color: var(--danger); }
.seat.some { color: var(--ok); }

/* Watch cards */
.watch .route-title { font-weight: 700; font-size: 16px; }
.watch .status { margin-top: 8px; font-size: 14px; }
.watch .status.ok { color: var(--ok); font-weight: 600; }
.watch .actions { display: flex; gap: 8px; margin-top: 12px; }
.watch .actions a, .watch .actions button { flex: 1; text-align: center; padding: 9px; border-radius: 10px; font-size: 14px; font-weight: 600;
  text-decoration: none; border: 0; cursor: pointer; }
.watch .open { background: var(--accent); color: var(--accent-text); }
.watch .del { background: var(--bg2); color: var(--danger); }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px;
  animation: pulse 1.6s infinite; vertical-align: middle; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

.empty { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 44px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; font-size: 14px; }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--bg2); color: var(--accent); font-size: 20px; cursor: pointer; }

/* Sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; z-index: 10; }
.sheet-body { background: var(--bg); width: 100%; max-height: 85vh; border-radius: 18px 18px 0 0; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.list { overflow-y: auto; }
.list button { display: block; width: 100%; text-align: left; padding: 13px 4px; background: none; border: 0; color: var(--text);
  font-size: 16px; border-bottom: 1px solid color-mix(in srgb, var(--hint) 15%, transparent); cursor: pointer; }

.toast { position: fixed; left: 12px; right: 12px; bottom: 20px; background: #222; color: #fff; padding: 12px 14px; border-radius: 12px;
  text-align: center; z-index: 20; }
.skeleton { height: 56px; border-radius: 12px; background: var(--bg2); animation: pulse 1.2s infinite; }
