:root {
  --bg: #0b1220;
  --bg-elev: #141c2c;
  --bg-card: #1a2438;
  --line: #2a364c;
  --text: #f4f7fb;
  --muted: #9aa6b8;
  --ice: #7ec8ff;
  --gold: #f5c518;
  --go: #e23d3d;
  --ready: #f0a202;
  --watch: #3db8ff;
  --clear: #1f9d55;
  --none: #6b778c;
  --danger: #ff7a7a;
  --radius: 18px;
  --font: "SF Pro Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --tabbar-h: 84px;
  --topbar-h: 86px;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  background:
    radial-gradient(1200px 400px at 50% -80px, rgba(126, 200, 255, 0.10), transparent 60%),
    var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 10px;
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-logo-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  background: #f4f6f8;
  border-radius: 10px;
}
.brand-logo {
  display: block;
  height: 28px;
  width: auto;
  max-width: min(120px, 38vw);
  object-fit: contain;
}
.brand-text { min-width: 0; }
.topbar h1 {
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.updated-ago {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-meta { text-align: right; flex-shrink: 0; }
.live-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 15px;
  color: var(--muted);
}
.mode-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 4px;
}
.mode-pill[data-mode="demo"] { background: #5a3d08; color: var(--gold); }
.mode-pill[data-mode="live"] { background: #143321; color: #7dffb0; }
.mode-pill[data-mode="offline"] { background: #3a1c1c; color: var(--danger); }

.main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 18px);
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  max-width: 520px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
  background: #0b1220ee;
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  padding: 6px 2px;
  border-radius: 12px;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  -webkit-tap-highlight-color: transparent;
}
.tab[aria-current="page"] {
  color: var(--text);
  background: var(--bg-card);
}
.tab-icon { font-size: 18px; line-height: 1; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.level-card {
  text-align: center;
  padding: 22px 16px 20px;
}
.level-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.level-name {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  text-transform: uppercase;
}
.level-card[data-level="go"] { background: linear-gradient(180deg, #4a1212, var(--bg-card)); }
.level-card[data-level="go"] .level-name { color: #ff6b6b; }
.level-card[data-level="get_ready"] { background: linear-gradient(180deg, #4a3208, var(--bg-card)); }
.level-card[data-level="get_ready"] .level-name { color: var(--gold); font-size: 32px; }
.level-card[data-level="watch"] { background: linear-gradient(180deg, #0d2a44, var(--bg-card)); }
.level-card[data-level="watch"] .level-name { color: var(--ice); }
.level-card[data-level="all_clear"] { background: linear-gradient(180deg, #0d2e1c, var(--bg-card)); }
.level-card[data-level="all_clear"] .level-name { color: #5ee09a; }
.level-card[data-level="none"] .level-name { color: var(--muted); font-size: 34px; }

.what-to-do {
  font-size: 22px;
  font-weight: 650;
  line-height: 1.35;
  margin-top: 14px;
}
.detail {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 12px;
  white-space: pre-wrap;
}
.muted { color: var(--muted); }
.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 4px 4px 10px;
}

.station {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.station + .station {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.station-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.station-name { font-size: 18px; font-weight: 750; }
.station-meta { font-size: 13px; color: var(--muted); text-align: right; }
.station-temp {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.station-bits {
  font-size: 16px;
  color: var(--text);
  line-height: 1.4;
}
.stale { color: var(--danger); }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--muted);
  vertical-align: middle;
}
.badge-fallback { background: #2a2a12; color: var(--gold); }
.badge-cancel { background: #3a1515; color: #ff8a8a; }
.badge-delay { background: #3a2a08; color: var(--gold); }

.forecast-legend {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.strip {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 120px;
  padding: 0 0 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.hour {
  flex: 0 0 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 16px;
}
.bar {
  width: 12px;
  border-radius: 4px 4px 2px 2px;
  background: #7ec8ff;
  min-height: 2px;
}
.bar[data-zero="1"] { background: #2a364c; min-height: 2px; }
.hour-lab {
  font-size: 9px;
  color: var(--muted);
  margin-top: 4px;
  writing-mode: horizontal-tb;
}
.temp-row {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  margin-top: 8px;
  position: relative;
  padding-top: 8px;
  border-top: 1px dashed #3a6a88;
}
.temp-cell {
  flex: 0 0 18px;
  min-width: 16px;
  text-align: center;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.temp-cell.freeze { color: var(--ice); }
.temp-cell.above { color: #f0c27b; }
.freeze-note {
  font-size: 13px;
  color: var(--ice);
  margin-top: 8px;
}

.ferry {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ferry + .ferry {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.ferry-kind {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ice);
}
.ferry-time {
  font-size: 24px;
  font-weight: 800;
}
.ferry-route { font-size: 16px; }
.ferry-clear { font-size: 16px; color: var(--gold); font-weight: 650; }

.log-item + .log-item {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.log-when { font-size: 13px; color: var(--muted); }
.log-level { font-size: 20px; font-weight: 800; text-transform: uppercase; }
.log-level[data-level="go"] { color: #ff6b6b; }
.log-level[data-level="get_ready"] { color: var(--gold); }
.log-level[data-level="watch"] { color: var(--ice); }
.log-level[data-level="all_clear"] { color: #5ee09a; }
.log-msg { font-size: 15px; margin-top: 6px; line-height: 1.4; }

.settings-note { font-size: 15px; line-height: 1.4; margin-bottom: 14px; }
label.field {
  display: block;
  margin-bottom: 12px;
}
label.field span {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 4px;
}
input, select, button.btn {
  font: inherit;
}
input[type="number"],
input[type="password"],
input[type="text"],
select {
  width: 100%;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 18px;
  min-height: 48px;
}
input:disabled, select:disabled {
  opacity: 0.7;
}
.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 18px;
  font-weight: 750;
  width: 100%;
  min-height: 52px;
  background: #2a7de1;
  color: white;
  margin-top: 8px;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: 0.5; }
.btn-secondary { background: var(--bg-elev); color: var(--text); border: 1px solid var(--line); }
.pin-row { display: flex; gap: 8px; align-items: center; }
.pin-row input { flex: 1; letter-spacing: 0.3em; text-align: center; font-size: 24px; }
.unlocked { color: #5ee09a; font-size: 14px; font-weight: 700; margin-bottom: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
  transform: translateX(-50%);
  background: #f4f7fb;
  color: #0b1220;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 650;
  font-size: 15px;
  max-width: 90%;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.empty {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.4;
}
