:root {
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, sans-serif;
  --bg: #f4f6fa;
  --text: #121212;
  --text-muted: #5b6470;
  --surface: #fff;
  --surface-border: #e1e6ee;
  --btn-border: #d4dae2;
  --btn-bg: #fff;
  --share-bg: #e8f1ff;
  --share-border: #9ec5fe;
  --share-text: #0f3d8a;
  --share-active: #d0e4ff;
  --banner-bg: #fff6cf;
  --banner-border: #f0d879;
  --banner-text: #6a5400;
  --notice-bg: #eef4fc;
  --notice-border: #c5d8f5;
  --notice-text: #3d4f66;
  --overlay-bg: rgba(17, 24, 39, 0.45);
  --logo-shadow: rgba(15, 98, 254, 0.28);
  --badge-open-bg: #dcfce7;
  --badge-open-text: #166534;
  --badge-closing-bg: #fee2e2;
  --badge-closing-text: #b91c1c;
  --badge-soon-bg: #dbeafe;
  --badge-soon-text: #1d4ed8;
  --badge-closed-bg: #efefef;
  --badge-closed-text: #555;
  --route-bg: #0f62fe;
  --route-text: #fff;
  --toast-bg: #111;
  --toast-text: #fff;
  --top-toast-bg: #c5e4ff;
  --top-toast-border: #4da3ff;
  --top-toast-text: #062a5c;
  --top-toast-close: #1e4a7a;
  --top-toast-close-active: #9ed0ff;
  --link: #0f62fe;
  --theme-color: #0f62fe;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f1419;
  --text: #e8eaed;
  --text-muted: #9aa0a8;
  --surface: #1a222d;
  --surface-border: #2d3848;
  --btn-border: #3d4a5c;
  --btn-bg: #1a222d;
  --share-bg: #1a2d4a;
  --share-border: #2a5080;
  --share-text: #8ec0ff;
  --share-active: #243d5c;
  --banner-bg: #2a2410;
  --banner-border: #5c4f1a;
  --banner-text: #e8d48a;
  --notice-bg: #1a2433;
  --notice-border: #2d4260;
  --notice-text: #e2ebf5;
  --overlay-bg: rgba(0, 0, 0, 0.65);
  --logo-shadow: rgba(15, 98, 254, 0.15);
  --badge-open-bg: #143322;
  --badge-open-text: #6ee7a0;
  --badge-closing-bg: #3a1717;
  --badge-closing-text: #fca5a5;
  --badge-soon-bg: #152a4a;
  --badge-soon-text: #7eb8ff;
  --badge-closed-bg: #2a3038;
  --badge-closed-text: #a8adb5;
  --route-bg: #2563eb;
  --route-text: #fff;
  --toast-bg: #e8eaed;
  --toast-text: #121212;
  --link: #7eb8ff;
  --theme-color: #1a222d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.25s ease, color 0.25s ease;
}

.container {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

@media (min-width: 480px) {
  .container { max-width: 480px; padding-left: 16px; padding-right: 16px; }
}

.header { margin-bottom: 0; }
.header-main { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.header-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.site-logo {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px var(--logo-shadow);
}
.page-title { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.15; }
.page-subtitle { margin: 0; font-size: 13px; font-weight: 500; color: var(--text-muted); line-height: 1.25; }
.time { font-size: 38px; font-weight: 700; line-height: 1; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.header-date { color: var(--text-muted); font-size: 14px; line-height: 1.2; }
.muted { color: var(--text-muted); font-size: 13px; }

.btn {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.btn-share {
  width: 100%;
  margin: 10px 0 8px;
  background: var(--share-bg);
  border-color: var(--share-border);
  color: var(--share-text);
  font-weight: 600;
}
.btn-share:active { background: var(--share-active); }

.btn-map {
  width: 100%;
  margin: 0 0 8px;
  background: var(--surface);
  border-color: var(--surface-border);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.btn-map:active { background: var(--share-active); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 200;
  max-width: calc(100% - 32px);
  text-align: center;
}

.top-toast {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 250;
  width: min(480px, calc(100% - 24px));
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--top-toast-bg);
  border: 1px solid var(--top-toast-border);
  color: var(--top-toast-text);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 500;
  box-shadow: 0 8px 28px rgba(15, 98, 254, 0.22);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.top-toast p {
  margin: 0;
  flex: 1;
}

.top-toast a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.top-toast-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--top-toast-close);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.top-toast-close:active {
  background: var(--top-toast-close-active);
}

.top-toast.top-toast-hide {
  opacity: 0;
  transform: translateX(-50%) translateY(-8px);
  pointer-events: none;
}

.top-toast.hidden {
  display: none;
}

.banner {
  margin: 12px 0;
  background: var(--banner-bg);
  border: 1px solid var(--banner-border);
  color: var(--banner-text);
  border-radius: 10px;
  padding: 10px;
}

.site-notice {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  color: var(--notice-text);
  font-size: 13px;
  line-height: 1.45;
}

.site-notice p {
  margin: 0;
}

.site-notice strong {
  color: var(--text);
  font-weight: 600;
}

.hidden { display: none; }

.plate {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px;
  margin: 12px 0;
  border: 1px solid var(--surface-border);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.plate-title { font-weight: 700; margin-bottom: 8px; }

/* Госномер остаётся светлым в обеих темах — как настоящая табличка */
.plate-frame {
  background: #fff;
  border: 3px solid #111;
  border-radius: 4px;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  overflow: hidden;
  min-height: 74px;
}
.plate-series { display: flex; align-items: center; justify-content: center; gap: 0; padding: 4px 4px; min-width: 0; flex-wrap: nowrap; white-space: nowrap; }
.plate-digit { font-size: 36px; font-weight: 800; line-height: 1; letter-spacing: 0; color: #111; }
.plate-letter { font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: 0; color: #111; }
.plate-digit-muted { color: #111; }
.plate-region { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 58px; padding: 6px 8px; border-left: 2px solid #111; flex-shrink: 0; }
.region { font-size: 26px; font-weight: 800; text-align: center; line-height: 1; color: #111; }
.plate-footer { display: flex; align-items: center; justify-content: center; gap: 3px; }
.rus { font-size: 8px; color: #174ab9; font-weight: 700; letter-spacing: 0.3px; line-height: 1; }
.plate-flag { width: 14px; height: 9px; border: 1px solid #bbb; background: linear-gradient(to bottom, #fff 33%, #0039a6 33% 66%, #d52b1e 66%); flex-shrink: 0; }
.ticker-wrap { height: 36px; width: 24px; overflow: hidden; display: block; flex-shrink: 0; border: 0; background: transparent; padding: 0; margin: 0; }
.ticker { display: flex; flex-direction: column; align-items: center; animation: tickerMove 4s linear infinite; }
.ticker .plate-digit { height: 36px; display: flex; align-items: center; justify-content: center; width: 100%; opacity: 1; }
@keyframes tickerMove { from { transform: translateY(0); } to { transform: translateY(-180px); } }
@media (prefers-reduced-motion: reduce) { .ticker { animation: none; } }

.list { display: grid; gap: 10px; }

.hourly-chart-wrap {
  margin: 16px 0 4px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
}

.hourly-chart-caption {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.hourly-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
  padding-top: 18px;
}

.hourly-chart-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}

.hourly-chart-value {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
  min-height: 10px;
}

.hourly-chart-bar {
  width: 100%;
  max-width: 18px;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--badge-open-text);
  opacity: 0.55;
  transition: height 0.2s ease;
}

.hourly-chart-bar--now {
  opacity: 1;
  background: var(--route-bg);
  box-shadow: 0 0 0 1px var(--route-bg);
}

.hourly-chart-label {
  font-size: 9px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.hourly-chart-col--now .hourly-chart-label {
  font-weight: 700;
  color: var(--text);
}

.soon-group { margin-bottom: 14px; }
.soon-group:last-child { margin-bottom: 0; }
.soon-group-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--badge-soon-text);
}

.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--surface-border);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.open { background: var(--badge-open-bg); color: var(--badge-open-text); }
.closing { background: var(--badge-closing-bg); color: var(--badge-closing-text); }
.soon { background: var(--badge-soon-bg); color: var(--badge-soon-text); }
.closed { background: var(--badge-closed-bg); color: var(--badge-closed-text); }
.card h4 { margin: 0 0 6px; }
.card p { margin: 4px 0; font-size: 14px; }
.row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }

.route {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 9px;
  border: 0;
  background: var(--route-bg);
  color: var(--route-text);
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  text-decoration: none;
}

.rules {
  margin-top: 14px;
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--surface-border);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.rules a { color: var(--link); }

.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 100;
}

.overlay-card {
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  max-width: 420px;
  padding: 18px;
  border: 1px solid var(--surface-border);
}

.overlay.hidden { display: none; }

section h3 { margin: 16px 0 10px; font-size: 16px; }

.seo-about {
  margin-top: 20px;
  padding: 16px 0 4px;
  border-top: 1px solid var(--surface-border);
}

.seo-about h2 {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.3;
}

.seo-about p,
.seo-about li {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

.seo-about ul {
  margin: 0;
  padding-left: 18px;
}

.seo-about a {
  color: var(--link);
}

.map-seo-about {
  margin-top: 12px;
  padding-top: 12px;
}

.site-footer {
  margin-top: 20px;
  padding: 16px 0 max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--surface-border);
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  color: var(--link);
  text-decoration: underline;
}

.footer-links a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

.legal-page { padding-bottom: 24px; }

.legal-header { margin-bottom: 20px; }

.legal-header h1 {
  margin: 12px 0 6px;
  font-size: 22px;
  line-height: 1.2;
}

.legal-back {
  display: inline-block;
  color: var(--link);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.legal-back:hover { text-decoration: underline; }

.legal-content {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 16px;
  font-size: 14px;
  line-height: 1.55;
}

.legal-content h2 {
  margin: 20px 0 8px;
  font-size: 16px;
}

.legal-content h2:first-of-type { margin-top: 8px; }

.legal-content p { margin: 0 0 12px; }

.legal-content ul {
  margin: 0 0 12px;
  padding-left: 20px;
}

.legal-content li { margin-bottom: 6px; }

.legal-content a { color: var(--link); }
