:root {
  color-scheme: light;
  --paper: #e2d6c2;
  --paper-strong: #f3ede3;
  --ink: #102b35;
  --muted: #697a7d;
  --line: rgba(16, 43, 53, 0.15);
  --line-strong: rgba(16, 43, 53, 0.26);
  --blue: #0b579f;
  --cyan: #42a7c7;
  --navy: #123f69;
  --violet: #3f3c78;
  --amber: #d16928;
  --brand-gold: #a47b28;
  --green: #3b8b72;
  --panel: rgba(246, 241, 232, 0.52);
  --control: rgba(250, 247, 241, 0.94);
  --control-soft: rgba(246, 239, 228, 0.82);
  --detail-bg: rgba(246, 241, 232, 0.5);
  --map-empty: #dfe8e6;
  --elevated: #faf7f1;
  --wash: rgba(66, 167, 199, 0.16);
  --grid-tint: rgba(16, 43, 53, 0.025);
  --track: rgba(16, 43, 53, 0.16);
  --soft-fill: rgba(16, 43, 53, 0.065);
  --chart-ink: rgba(17, 40, 50, 0.72);
  --chart-muted: rgba(73, 90, 94, 0.82);
  --chart-grid: rgba(17, 40, 50, 0.18);
  --chart-blue: rgba(11, 87, 162, 0.98);
  --chart-cyan: rgba(67, 164, 198, 0.68);
  --chart-amber: rgba(209, 105, 40, 0.9);
  --timeline-bar: rgba(11, 87, 159, 0.38);
  --shadow: 0 18px 50px rgba(26, 42, 48, 0.11);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", "Noto Sans JP", "PingFang TC", "Hiragino Sans",
    sans-serif;
  font-synthesis: none;
}

:root[data-theme="gray"] {
  color-scheme: dark;
  --paper: #202426;
  --paper-strong: #2d3235;
  --ink: #f0f3f3;
  --muted: #aab2b4;
  --line: rgba(240, 243, 243, 0.16);
  --line-strong: rgba(240, 243, 243, 0.3);
  --blue: #83bce5;
  --cyan: #79c2cf;
  --navy: #456981;
  --violet: #77779a;
  --amber: #e99a64;
  --green: #71b69d;
  --panel: rgba(38, 43, 46, 0.88);
  --control: rgba(49, 55, 58, 0.96);
  --control-soft: rgba(49, 55, 58, 0.82);
  --detail-bg: rgba(38, 43, 46, 0.8);
  --map-empty: #303638;
  --elevated: #3a4144;
  --wash: rgba(78, 121, 143, 0.17);
  --grid-tint: rgba(240, 243, 243, 0.035);
  --track: rgba(240, 243, 243, 0.2);
  --soft-fill: rgba(240, 243, 243, 0.085);
  --chart-ink: rgba(240, 243, 243, 0.82);
  --chart-muted: rgba(198, 207, 209, 0.88);
  --chart-grid: rgba(240, 243, 243, 0.22);
  --chart-blue: rgba(131, 188, 229, 0.98);
  --chart-cyan: rgba(121, 194, 207, 0.74);
  --chart-amber: rgba(233, 154, 100, 0.95);
  --timeline-bar: rgba(131, 188, 229, 0.45);
}

:root[data-theme="white"] {
  --paper: #f8f9f8;
  --paper-strong: #fff;
  --ink: #132d36;
  --muted: #6c7a7e;
  --line: rgba(19, 45, 54, 0.14);
  --line-strong: rgba(19, 45, 54, 0.25);
  --panel: rgba(255, 255, 255, 0.55);
  --control: rgba(255, 255, 255, 0.94);
  --control-soft: rgba(255, 255, 255, 0.72);
  --detail-bg: rgba(255, 255, 255, 0.42);
  --map-empty: #e7eded;
  --elevated: #fff;
  --wash: rgba(66, 167, 199, 0.11);
  --grid-tint: rgba(19, 45, 54, 0.02);
  --track: rgba(19, 45, 54, 0.15);
  --soft-fill: rgba(19, 45, 54, 0.055);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #030708;
  --paper-strong: #0d1417;
  --ink: #eef4f3;
  --muted: #a8b5b7;
  --line: rgba(238, 244, 243, 0.16);
  --line-strong: rgba(238, 244, 243, 0.29);
  --blue: #72b8ff;
  --cyan: #67c5db;
  --navy: #315e86;
  --violet: #7671b5;
  --amber: #ef9b5e;
  --green: #65b99b;
  --panel: rgba(8, 14, 17, 0.94);
  --control: rgba(16, 24, 28, 0.98);
  --control-soft: rgba(16, 24, 28, 0.88);
  --detail-bg: rgba(8, 14, 17, 0.9);
  --map-empty: #111b1f;
  --elevated: #19252a;
  --wash: rgba(45, 110, 155, 0.17);
  --grid-tint: rgba(238, 244, 243, 0.035);
  --track: rgba(238, 244, 243, 0.17);
  --soft-fill: rgba(238, 244, 243, 0.075);
  --chart-ink: rgba(238, 244, 243, 0.8);
  --chart-muted: rgba(190, 203, 205, 0.86);
  --chart-grid: rgba(238, 244, 243, 0.2);
  --chart-blue: rgba(114, 184, 255, 0.98);
  --chart-cyan: rgba(103, 197, 219, 0.72);
  --chart-amber: rgba(239, 155, 94, 0.95);
  --timeline-bar: rgba(114, 184, 255, 0.5);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-width: 1280px;
  color: var(--ink);
  background:
    radial-gradient(circle at 72% -12%, var(--wash), transparent 34%),
    linear-gradient(var(--grid-tint) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-tint) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 44px 44px, 44px 44px, auto;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(11, 87, 159, 0.3);
  outline-offset: 2px;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  color: var(--ink);
  background: var(--paper);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

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

.loading-drop {
  position: relative;
  width: 44px;
  height: 44px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.loading-drop::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 17px;
  width: 10px;
  height: 14px;
  border-radius: 70% 70% 60% 60% / 80% 80% 45% 45%;
  background: var(--blue);
  transform: rotate(45deg);
  animation: drop-pulse 1s ease-in-out infinite alternate;
}

.loading-drop::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(11, 87, 159, 0.28);
  border-radius: 50%;
  animation: ring-pulse 1s ease-out infinite;
}

@keyframes drop-pulse {
  to { transform: rotate(45deg) translate(2px, 2px); }
}

@keyframes ring-pulse {
  from { transform: scale(0.5); opacity: 1; }
  to { transform: scale(1.18); opacity: 0; }
}

.loading-screen strong {
  font-size: 14px;
  letter-spacing: 0.08em;
}

.loading-screen small {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.05em;
}

.app-shell {
  display: grid;
  grid-template-rows: 58px 92px minmax(0, 1fr) 75px 24px;
  width: 100%;
  height: 100dvh;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.app-shell.is-ready {
  opacity: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: max-content;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: block;
  width: 38px;
  height: 34px;
  flex: 0 0 38px;
  overflow: visible;
  color: var(--brand-gold);
  background: radial-gradient(circle at 50% 2px, currentColor 0 1.4px, transparent 1.6px);
}

.brand-mark::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 2px;
  width: 34px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-bottom: 0;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: 24px;
  left: 18px;
  width: 7px;
  height: 8px;
  border-bottom: 1.5px solid currentColor;
  border-left: 1.5px solid currentColor;
  border-radius: 0 0 0 7px;
}

.brand-mark .brand-kanji {
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 1;
  color: var(--ink);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  font-size: 19px;
  font-style: normal;
  font-weight: 600;
  line-height: 1;
  transform: translateX(-50%);
}

.brand > span:last-child {
  display: grid;
  gap: 1px;
  width: 92px;
}

.brand b,
.brand small {
  display: block;
  width: 100%;
  text-align: justify;
  text-align-last: justify;
  text-justify: inter-character;
  white-space: nowrap;
}

.brand b {
  font-size: 13px;
  letter-spacing: 0;
}

.brand small {
  color: var(--muted);
  font-size: 7px;
  letter-spacing: 0.04em;
  line-height: 1;
}

.dashboard-header {
  padding: 9px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.dashboard-header .timeline-topbar {
  height: 40px;
}

.timeline-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 22px 4px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.timeline-panel .play-button {
  width: 28px;
  min-width: 28px;
  height: 26px;
  flex: 0 0 28px;
  padding: 0;
  font-size: 9px;
}

.playback-controls {
  display: grid;
  grid-template-rows: repeat(2, 26px);
  gap: 3px;
  width: 28px;
  flex: 0 0 28px;
  margin-left: 4px;
}

.fast-forward-button .speed-icon {
  display: inline-block;
  font-size: 8px;
  letter-spacing: -2px;
  line-height: 1;
  transform: translateX(-1px);
}

.timeline-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 13px;
  min-width: 0;
}

.map-controls {
  position: static;
  z-index: auto;
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.time-readout {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 13px;
}

.selected-time {
  display: grid;
  grid-template-columns: 126px 54px;
  align-items: center;
  gap: 10px;
  width: 207px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.selected-time strong {
  font-size: clamp(19px, 1.4vw, 24px);
  letter-spacing: -0.045em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.selected-clock {
  display: grid;
  grid-template-rows: 10px 17px;
  align-items: center;
  width: 54px;
}

.selected-clock small {
  color: var(--muted);
  font-size: 8px;
  line-height: 10px;
  white-space: nowrap;
}

.selected-clock b {
  color: var(--blue);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  line-height: 17px;
  white-space: nowrap;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.control-button,
.play-button {
  height: 32px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--control);
  cursor: pointer;
}

.control-button {
  min-width: 54px;
  padding: 0 10px;
  border-radius: 999px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 9px;
}

.play-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 82px;
  padding: 0 13px;
  border-color: var(--ink);
  border-radius: 999px;
  color: var(--paper-strong);
  background: var(--ink);
  font-size: 11.5px;
}

.play-button[aria-pressed="true"] {
  background: var(--blue);
  border-color: var(--blue);
}

.timeline-panel .fast-forward-button {
  margin-left: 0;
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--control);
}

.timeline-panel .fast-forward-button[aria-pressed="true"] {
  color: var(--paper-strong);
  border-color: var(--blue);
  background: var(--blue);
}

.control-button:hover:not(:disabled),
.play-button:hover {
  transform: translateY(-1px);
}

.timeline-panel .play-button:hover {
  transform: none;
}

.control-button:hover:not(:disabled) {
  color: var(--blue);
  border-color: rgba(11, 87, 159, 0.5);
}

.control-button:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.date-jump {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  margin-left: 0;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control-soft);
}

.date-jump input {
  width: 94px;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 9px;
  cursor: pointer;
}

.range-row {
  position: relative;
  display: grid;
  grid-template-rows: 49px 16px;
  align-content: start;
  min-width: 0;
  flex: 1 1 auto;
}

.daily-bars {
  display: grid;
  grid-template-columns: repeat(var(--day-count, 365), minmax(0, 1fr));
  align-items: end;
  gap: 1px;
  height: 49px;
  padding: 2px 1px 8px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.daily-bar {
  display: block;
  width: 100%;
  height: var(--bar-height, 0%);
  background: var(--timeline-bar);
  opacity: 0.64;
  transition: opacity 0.14s ease, background 0.14s ease;
}

.daily-bar.is-current {
  background: var(--timeline-bar);
  opacity: 0.64;
}

.daily-bar.is-record {
  background: var(--amber);
  box-shadow: 0 -2px 0 var(--ink);
  opacity: 1;
}

.range-row input[type="range"] {
  position: absolute;
  top: 40px;
  left: 0;
  z-index: 2;
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: ew-resize;
}

.timeline-cursor {
  position: absolute;
  top: 2px;
  left: 100%;
  z-index: 3;
  width: 2px;
  height: 47px;
  border: 0;
  border-radius: 0;
  background: var(--blue);
  box-shadow: 0 0 0 1px var(--paper-strong);
  pointer-events: none;
  transform: translateX(-50%);
  transition: none;
  will-change: left;
}

.timeline-cursor::after {
  content: "";
  position: absolute;
  top: 37px;
  left: 50%;
  width: 13px;
  height: 13px;
  border: 3px solid var(--paper-strong);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1px var(--blue), 0 2px 5px rgba(16, 43, 53, 0.24);
  transform: translateX(-50%);
}

.range-row input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: var(--track);
}

.range-row input[type="range"]::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  margin-top: -6px;
  appearance: none;
  border: 3px solid var(--paper-strong);
  border-radius: 50%;
  opacity: 0;
}

.range-row input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 3px;
  background: var(--track);
}

.range-row input[type="range"]::-moz-range-progress {
  height: 3px;
  background: var(--track);
}

.range-row input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 3px solid var(--paper-strong);
  border-radius: 50%;
  opacity: 0;
}

.month-ticks {
  position: relative;
  grid-row: 2;
  height: 16px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.month-tick {
  position: absolute;
  top: -1px;
  display: grid;
  justify-items: center;
  gap: 1px;
  transform: translateX(-50%);
  white-space: nowrap;
}

.month-tick::before {
  width: 1px;
  height: 5px;
  background: var(--line-strong);
  content: "";
}

.month-tick b {
  font-size: 8px;
  font-weight: 500;
  line-height: 9px;
}

.month-tick:first-child {
  justify-items: start;
  transform: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.day-summary {
  display: flex;
  align-items: center;
  gap: 15px;
}

.day-summary > span {
  display: flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}

.day-summary small {
  color: var(--muted);
  font-size: 9px;
}

.day-summary strong {
  font-size: 17px;
  letter-spacing: -0.04em;
}

.day-summary strong i {
  margin-left: 3px;
  color: var(--muted);
  font-size: 8px;
  font-style: normal;
  font-weight: 500;
}

.instant-rail {
  min-width: 0;
  overflow: hidden;
  overflow-y: hidden;
  padding: 3px 22px 4px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  scrollbar-width: thin;
}

.instant-stations {
  display: grid;
  grid-template-columns: repeat(var(--station-count, 25), minmax(0, 1fr));
  gap: 2px;
  min-width: 0;
}

.instant-stations button {
  display: grid;
  grid-template-rows: 20px 54px 9px;
  justify-items: center;
  gap: 1px;
  min-width: 0;
  height: 86px;
  padding: 1px 3px 2px;
  border: 0;
  border-left: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  font-size: 8px;
  cursor: pointer;
  text-align: center;
}

.instant-stations .instant-name {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 10px;
  white-space: normal;
}

.instant-stations .station-word {
  white-space: nowrap;
}

.instant-bar {
  display: flex;
  align-items: end;
  justify-content: center;
  width: 9px;
  height: 54px;
  background: var(--track);
}

.instant-bar i {
  display: block;
  width: 100%;
  height: 0;
  background: var(--timeline-bar);
}

.instant-stations .instant-value {
  display: grid;
  grid-template-columns: 0.75ch 1ch 0.8ch;
  width: 2.55ch;
  font-family: inherit;
  font-size: 8px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.15em;
  line-height: 9px;
}

.number-prefix { text-align: right; }
.number-ones { text-align: center; }
.number-fraction { text-align: left; }

.app-shell.is-playing .timeline-cursor {
  transition: none;
}

.instant-stations button:first-child {
  border-left: 0;
}

.instant-stations button:hover,
.instant-stations button.is-selected {
  background: var(--soft-fill);
}

.main-stage {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) 560px;
  gap: 14px;
  min-height: 0;
  padding: 14px 18px 12px;
}

.map-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.map-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  min-height: 45px;
  padding: 0 4px 9px;
}

.map-heading h1,
.detail-heading h2,
.ranking-heading h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.025em;
}

.map-heading-tools {
  display: flex;
  align-items: center;
  gap: 13px;
}

.basemap-picker select {
  height: 28px;
  padding: 0 27px 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background-color: var(--control-soft);
  font-size: 9px;
  cursor: pointer;
}

.theme-picker {
  position: relative;
  z-index: 1200;
}

.theme-trigger {
  display: grid;
  place-items: center;
  width: 32px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--control-soft);
  cursor: pointer;
}

.theme-trigger:hover,
.theme-trigger[aria-expanded="true"] {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
}

.theme-current,
.theme-swatch {
  display: block;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--swatch-color);
}

.theme-current {
  width: 19px;
  height: 19px;
  box-shadow: 0 0 0 2px var(--control-soft);
}

[data-theme-swatch="dark"] { --swatch-color: #030708; }
[data-theme-swatch="gray"] { --swatch-color: #34383b; }
[data-theme-swatch="beige"] { --swatch-color: #d4c1a3; }
[data-theme-swatch="white"] { --swatch-color: #f8f9f8; }

.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--control);
  box-shadow: var(--shadow);
}

.theme-menu[hidden] {
  display: none;
}

.theme-swatch-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.theme-swatch {
  width: 22px;
  height: 22px;
}

.theme-swatch-button:hover {
  border-color: var(--line-strong);
}

.theme-swatch-button[aria-selected="true"] {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
}

.rain-legend {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 8px;
  white-space: nowrap;
}

.rain-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.rain-legend i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(16, 43, 53, 0.13);
}

.legend-0 { background: #eef0ed; }
.legend-1 { background: #7cd1df; }
.legend-2 { background: #3695bd; }
.legend-3 { background: #225f9c; }
.legend-4 { background: #423d79; }

.map-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--map-empty);
}

.leaflet-map {
  width: 100%;
  height: 100%;
  background: var(--map-empty);
}

.leaflet-container {
  color: var(--ink);
  font-family: inherit;
  font-size: 10px;
}

.leaflet-control-zoom.leaflet-bar {
  overflow: hidden;
  border: 0;
  border-radius: 7px;
  box-shadow: 0 7px 20px rgba(16, 43, 53, 0.22);
}

.leaflet-control-zoom.leaflet-bar a {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-color: var(--line);
  color: var(--ink);
  background: var(--control);
  font: 500 20px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.leaflet-control-zoom.leaflet-bar a:hover {
  color: var(--blue);
  background: var(--elevated);
}

.leaflet-control-attribution {
  color: var(--muted);
  background: var(--control-soft) !important;
  font-size: 8px !important;
  backdrop-filter: blur(8px);
}

.leaflet-control-attribution a {
  color: var(--blue);
}

.reset-map-button {
  position: absolute;
  top: 84px;
  right: 10px;
  left: auto;
  z-index: 800;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--ink);
  background: var(--control);
  box-shadow: 0 7px 20px rgba(16, 43, 53, 0.22);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}

.reset-map-button:hover {
  color: var(--blue);
  background: var(--elevated);
}

.rain-map-icon {
  border: 0;
  background: transparent;
}

.station-marker {
  position: absolute;
  bottom: 0;
  left: 50%;
  display: grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--paper-strong);
  border-radius: 50% 50% 50% 0;
  color: #17313a;
  background: #eef0ed;
  box-shadow: 0 2px 6px rgba(16, 43, 53, 0.23);
  transform: translateX(-50%) rotate(-45deg);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease, background-color 0.25s linear;
}

.station-marker > .station-value {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 0.75ch 1ch 0.8ch;
  width: 2.55ch;
  font-family: inherit;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.15em;
  line-height: 1;
  transform: rotate(45deg) scaleY(1.1);
}

.station-marker.rain-1 { background: #7cd1df; }
.station-marker.rain-2 { color: #f8fbfa; background: #3695bd; }
.station-marker.rain-3 { color: #f8fbfa; background: #225f9c; }
.station-marker.rain-4 { color: #f8fbfa; background: #423d79; }

.rain-map-icon:hover .station-marker,
.rain-map-icon:focus .station-marker {
  transform: translateX(-50%) rotate(-45deg);
  box-shadow: 0 5px 13px rgba(16, 43, 53, 0.3);
}

.station-marker.is-selected {
  box-shadow: 0 0 0 2px var(--ink), 0 6px 15px rgba(16, 43, 53, 0.3);
  transform: translateX(-50%) rotate(-45deg);
}

.station-marker.is-anomaly {
  color: #fff;
  background: var(--amber);
  filter: saturate(1.15);
}

.station-tooltip.leaflet-tooltip {
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: #f7f8f4;
  background: rgba(16, 43, 53, 0.95);
  box-shadow: 0 12px 28px rgba(16, 43, 53, 0.28);
}

.station-tooltip.leaflet-tooltip-top::before {
  border-top-color: rgba(16, 43, 53, 0.95);
}

.station-tooltip-content {
  display: grid;
  min-width: 154px;
  padding: 10px 11px;
}

.station-tooltip-content strong {
  max-width: 190px;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-tooltip-content span,
.station-tooltip-content small {
  color: rgba(247, 248, 244, 0.68);
  font-size: 8px;
}

.station-tooltip-content b {
  margin: 5px 0 2px;
  font-size: 18px;
}

.station-tooltip-content b i {
  font-size: 8px;
  font-style: normal;
  font-weight: 500;
}

.detail-rail {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: var(--detail-bg);
}

.station-detail {
  min-height: 0;
  overflow: hidden;
  padding: 13px 19px;
}

.station-detail {
  display: grid;
  grid-template-rows: auto auto auto minmax(150px, 1fr);
  gap: 11px;
  border-bottom: 1px solid var(--line);
}

.detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.quality-badge {
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--green);
  background: rgba(59, 139, 114, 0.1);
  font-size: 8px;
  font-weight: 700;
}

.quality-badge.has-warning {
  color: var(--amber);
  background: rgba(209, 105, 40, 0.12);
}

.station-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.station-title > span {
  width: 11px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #eef0ed;
}

.station-title > span.rain-1 { background: #7cd1df; }
.station-title > span.rain-2 { background: #3695bd; }
.station-title > span.rain-3 { background: #225f9c; }
.station-title > span.rain-4 { background: #423d79; }
.station-title > span.is-anomaly { background: var(--amber); }

.station-title > div {
  display: grid;
  min-width: 0;
}

.station-title small,
.current-reading small,
.detail-stats small {
  color: var(--muted);
  font-size: 8px;
}

.station-title strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-reading {
  display: flex;
  align-items: end;
  gap: 5px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.current-reading > span {
  display: grid;
}

.current-reading strong {
  font-size: clamp(30px, 3vw, 45px);
  letter-spacing: -0.07em;
  line-height: 0.95;
}

.current-reading em {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-stats span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.detail-stats b {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-chart-wrap {
  position: relative;
  min-height: 0;
}

.mini-chart-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#chartCursor {
  position: absolute;
  top: 9px;
  bottom: 18px;
  z-index: 2;
  width: 2px;
  background: var(--blue);
  box-shadow: 0 0 0 1px var(--paper-strong);
  pointer-events: none;
  transform: translateX(-50%);
  will-change: left;
}

.ranking-section {
  display: grid;
  grid-template-rows: auto 13px minmax(0, 1fr);
  gap: 3px;
  border-bottom: 1px solid var(--line);
}

.ranking-heading > b {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 8px;
}

.ranking-list {
  display: grid;
  align-content: start;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  scrollbar-width: thin;
}

.ranking-scale {
  display: grid;
  grid-template-columns: minmax(116px, 1fr) minmax(144px, 1.45fr) 39px;
  gap: 6px;
  height: 13px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 7px;
}

.ranking-scale > span {
  position: relative;
  grid-column: 2;
  display: block;
  border-top: 1px solid var(--line);
}

.ranking-scale i {
  position: absolute;
  top: 2px;
  font-style: normal;
  transform: translateX(-50%);
}

.ranking-scale i:first-child {
  transform: none;
}

.ranking-scale i:last-child {
  transform: translateX(-100%);
}

.ranking-list button {
  display: grid;
  grid-template-columns: minmax(116px, 1fr) minmax(144px, 1.45fr) 39px;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 13px;
  padding: 2px 3px;
  border: 0;
  border-radius: 4px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.ranking-list button:hover,
.ranking-list li.is-selected button {
  background: var(--soft-fill);
}

.rank-number {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 8px;
}

.rank-name {
  overflow: hidden;
  font-size: 8px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-track {
  height: 4px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--track);
}

.rank-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.ranking-list strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 8px;
  text-align: right;
}

.ranking-list li.is-anomaly .rank-track i {
  background: var(--amber);
}

.ranking-list li.is-over-limit .rank-track i {
  background: var(--amber);
}

.data-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 22px;
  color: var(--muted);
  font-size: 8px;
}

.footer-motto {
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.data-note a {
  text-decoration: none;
  white-space: nowrap;
}

.data-note a:hover {
  color: var(--blue);
}

.data-note .source-link {
  margin-left: 0;
  font-weight: 700;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.error-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: grid;
  gap: 2px;
  max-width: 330px;
  padding: 12px 14px;
  border: 1px solid rgba(209, 105, 40, 0.4);
  border-radius: 9px;
  color: #6c3518;
  background: #fff4e9;
  box-shadow: var(--shadow);
}

.error-toast strong {
  font-size: 11px;
}

.error-toast span {
  font-size: 9px;
}

@media (max-width: 1360px) {
  .timeline-topbar {
    gap: 14px;
  }

  .rain-legend {
    gap: 7px;
  }
}

@media (max-height: 790px) {
  .app-shell {
    grid-template-rows: 54px 80px minmax(0, 1fr) 72px 22px;
  }

  .timeline-panel {
    padding-top: 3px;
    padding-bottom: 3px;
  }

  .main-stage {
    padding-top: 10px;
    padding-bottom: 8px;
  }

  .map-heading {
    min-height: 37px;
    padding-bottom: 6px;
  }

  .station-detail {
    padding-top: 9px;
    padding-bottom: 9px;
  }

  .station-detail {
    gap: 7px;
  }

  .detail-rail {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .instant-stations button {
    grid-template-rows: 18px 42px 9px;
    height: 72px;
  }

  .instant-bar {
    height: 42px;
  }

}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .app-shell {
    grid-template-rows: 94px 80px minmax(0, 1fr) 72px 22px;
    width: 100%;
    min-width: 0;
  }

  .dashboard-header {
    padding: 8px 12px;
  }

  .dashboard-header .timeline-topbar {
    height: 77px;
  }

  .timeline-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 41px 28px;
    gap: 8px 10px;
  }

  .time-readout {
    grid-column: 1 / -1;
    justify-content: space-between;
    gap: 8px;
  }

  .selected-time {
    grid-template-columns: 110px 50px;
    gap: 5px;
    width: auto;
    padding-left: 0;
    border-left: 0;
  }

  .selected-time strong {
    font-size: 18px;
  }

  .selected-clock {
    width: 50px;
  }

  .control-row {
    grid-column: 1;
    grid-row: 2;
  }

  .date-jump {
    height: 28px;
    padding: 0 8px;
  }

  .date-jump input {
    width: 92px;
  }

  .map-controls {
    grid-column: 2;
    grid-row: 2;
    gap: 5px;
    margin-left: 0;
  }

  .basemap-picker select {
    max-width: 124px;
  }

  .instant-rail {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 3px 0 4px;
    scrollbar-width: none;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
  }

  .instant-rail::-webkit-scrollbar {
    display: none;
  }

  .instant-stations {
    grid-template-columns: repeat(var(--station-count, 25), 58px);
    gap: 0;
    width: max-content;
    min-width: max-content;
    padding: 0 6px;
  }

  .instant-stations button {
    grid-template-rows: 18px 42px 9px;
    width: 58px;
    height: 72px;
    padding-inline: 2px;
  }

  .instant-bar {
    height: 42px;
  }

  .main-stage {
    position: relative;
    display: grid;
    grid-template-areas: "map" "detail";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 118px;
    gap: 8px;
    min-width: 0;
    min-height: 0;
    padding: 8px 8px 6px;
  }

  .map-panel,
  .map-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .map-panel {
    grid-area: map;
  }

  .detail-rail {
    grid-area: detail;
    position: static;
    right: auto;
    bottom: auto;
    left: auto;
    z-index: auto;
    display: block;
    width: 100%;
    height: auto;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 0;
    background: var(--control);
    box-shadow: none;
  }

  .station-detail {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    grid-template-rows: 24px 40px minmax(30px, 1fr);
    gap: 2px 10px;
    height: 100%;
    min-height: 0;
    padding: 10px 12px;
    border-bottom: 0;
  }

  .station-title {
    grid-column: 1;
    grid-row: 1;
  }

  .station-title > span {
    width: 8px;
    height: 21px;
  }

  .station-title strong {
    font-size: 12px;
  }

  .current-reading {
    grid-column: 1;
    grid-row: 2;
    padding-bottom: 0;
    border-bottom: 0;
  }

  .current-reading strong {
    font-size: 26px;
  }

  .current-reading em {
    margin-bottom: 2px;
  }

  .detail-stats {
    grid-column: 1;
    grid-row: 3;
    gap: 5px;
  }

  .detail-stats b {
    font-size: 9px;
  }

  .mini-chart-wrap {
    grid-column: 2;
    grid-row: 1 / 4;
  }

  .timeline-panel {
    gap: 8px;
    min-width: 0;
    padding: 4px 10px 3px;
  }

  .timeline-panel .fast-forward-button {
    margin-left: 0;
  }

  .month-tick b {
    font-size: 7px;
  }

  .data-note {
    gap: 8px;
    padding: 0 10px;
    font-size: 7px;
  }

  .footer-motto {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .theme-menu {
    right: 0;
  }

  .error-toast {
    right: 10px;
    bottom: 10px;
    left: 10px;
    max-width: none;
  }
}

@media (max-width: 360px) {
  .dashboard-header {
    padding-inline: 10px;
  }

  .brand {
    gap: 7px;
  }

  .brand-mark {
    width: 31px;
    flex-basis: 31px;
    transform: scale(0.84);
    transform-origin: left center;
  }

  .brand > span:last-child {
    width: 76px;
  }

  .brand b {
    font-size: 11px;
  }

  .brand small {
    display: block;
    font-size: 5.5px;
  }

  .selected-time {
    grid-template-columns: 96px 44px;
    gap: 3px;
  }

  .selected-time strong {
    font-size: 16px;
  }

  .selected-clock {
    width: 44px;
  }

  .selected-clock b {
    font-size: 13px;
  }

  .basemap-picker select {
    max-width: 108px;
  }

  .detail-rail {
    right: auto;
    left: auto;
  }

  .station-detail {
    grid-template-columns: 124px minmax(0, 1fr);
    padding-inline: 10px;
  }
}

@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .app-shell {
    grid-template-rows: 58px 0 minmax(0, 1fr) 62px 20px;
  }

  .dashboard-header {
    padding: 8px 10px;
  }

  .dashboard-header .timeline-topbar {
    height: 41px;
  }

  .timeline-topbar {
    display: flex;
    gap: 9px;
  }

  .time-readout {
    grid-column: auto;
    flex: 0 1 auto;
    justify-content: flex-start;
  }

  .selected-time {
    grid-template-columns: 105px 46px;
    gap: 4px;
  }

  .selected-time strong {
    font-size: 17px;
  }

  .control-row {
    grid-column: auto;
    grid-row: auto;
  }

  .map-controls {
    grid-column: auto;
    grid-row: auto;
    margin-left: auto;
  }

  .instant-rail {
    visibility: hidden;
    padding: 0;
    border: 0;
  }

  .main-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 96px;
    gap: 6px;
    padding: 6px 8px;
  }

  .detail-rail {
    position: static;
    width: auto;
    height: auto;
    border-radius: 0;
    box-shadow: none;
  }

  .station-detail {
    grid-template-columns: 142px minmax(0, 1fr);
    grid-template-rows: 20px 30px minmax(28px, 1fr);
    padding: 7px 10px;
  }

  .timeline-panel {
    padding-top: 2px;
    padding-bottom: 1px;
  }

  .daily-bars {
    height: 43px;
  }

  .range-row {
    grid-template-rows: 43px 16px;
  }

  .timeline-cursor {
    height: 41px;
  }

  .timeline-cursor::after {
    top: 31px;
  }

  .data-note {
    height: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
