:root {
  --paper: #f1e6cf;
  --ink: #1d2330;
  --muted: #4a5263;
  --card: rgba(255, 255, 255, 0.94);
  --accent: #1d2330;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink);
  font-family: system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; -webkit-text-size-adjust: 100%; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; }

/* Miniature (tilt-shift) feel: slight blur on the far top and near bottom bands. */
.tilt { position: fixed; inset: 0; pointer-events: none; }
.tilt::before, .tilt::after { content: ""; position: absolute; left: 0; right: 0; height: 12%;
  -webkit-backdrop-filter: blur(1.6px); backdrop-filter: blur(1.6px); }
.tilt::before { top: 0; -webkit-mask-image: linear-gradient(#000, transparent); mask-image: linear-gradient(#000, transparent); }
.tilt::after { bottom: 0; -webkit-mask-image: linear-gradient(transparent, #000); mask-image: linear-gradient(transparent, #000); }

.bar { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px; display: flex; align-items: center; gap: 10px; }
.bar h1 { margin: 0; font-size: 17px; font-weight: 800; }
.back, .clock { color: var(--ink); text-decoration: none; font-weight: 700; font-size: 14px; background: var(--card);
  padding: 8px 12px; border-radius: 999px; box-shadow: 0 2px 10px rgba(60, 40, 10, 0.15); white-space: nowrap; }
.back { min-height: 36px; display: inline-flex; align-items: center; }
.clock { margin-left: auto; font-variant-numeric: tabular-nums; }

.empty { position: fixed; left: 50%; top: calc(max(12px, env(safe-area-inset-top)) + 52px); transform: translateX(-50%); margin: 0; max-width: calc(100% - 48px);
  background: var(--card); padding: 12px 16px; border-radius: 14px; font-weight: 700; font-size: 15px; text-align: center;
  box-shadow: 0 6px 24px rgba(60, 40, 10, 0.18); }
.empty[hidden] { display: none; }

.legend { position: fixed; left: 12px; right: 12px; bottom: calc(76px + var(--safe-bottom)); max-width: 560px; margin: 0 auto;
  background: var(--card); border-radius: 18px; padding: 10px 12px; box-shadow: 0 6px 24px rgba(60, 40, 10, 0.18); }
.legend h2 { margin: 0 0 6px; font-size: 15px; font-weight: 800; }
.legend-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.legend-rows li { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 8px;
  align-items: center; font-size: 13px; }
.legend-rows .pastille { grid-row: 1 / span 2; justify-self: start; }
.trip { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.when { grid-column: 2; color: var(--muted); font-variant-numeric: tabular-nums; }
.running { grid-column: 3; grid-row: 1 / span 2; font-weight: 800; font-size: 12px; color: #0a7a3d; }
.running.idle { display: none; }

.pastille { display: inline-flex; align-items: center; justify-content: center; background: var(--bg); color: var(--fg);
  font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.pastille-rail { width: 30px; height: 30px; border-radius: 8px; font-size: 20px; }
.pastille-bus { min-width: 48px; height: 26px; padding: 0 6px; border-radius: 8px; font-size: 14px; }
.pastille-none { background: #e6e2da; color: var(--muted); }

.selector { position: fixed; left: 8px; right: 8px; bottom: calc(10px + var(--safe-bottom)); max-width: 560px; margin: 0 auto;
  display: grid; grid-template-columns: 0.7fr 1fr 1fr 1.15fr 0.85fr; gap: 2px; padding: 4px; background: var(--card); border-radius: 16px;
  box-shadow: 0 6px 24px rgba(60, 40, 10, 0.18); }
.selector button { appearance: none; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 12px;
  font-weight: 700; padding: 6px 2px; border-radius: 12px; min-height: 48px; cursor: pointer; line-height: 1.15; }
.selector button[aria-pressed="true"] { background: var(--accent); color: #fff; }
