@font-face {
  font-family: "Source Han Serif CN Display";
  src: url("assets/fonts/source-han-serif-cn-heavy-display.woff2") format("woff2");
  font-style: normal;
  font-weight: 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #07111F;
  --surface: #0C1C2B;
  --surface-raised: #10283A;
  --grid: #173247;
  --text: #C7D8E6;
  --muted: #8FA9BC;
  --cyan: #56D6FF;
  --available: #00E0A4;
  --occupied: #B76DFF;
  --full: #FF5566;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display-cn: "Source Han Serif CN Display", "Songti SC", "STSong", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--font-body);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(7, 17, 31, .2), rgba(7, 17, 31, .36)),
    linear-gradient(rgba(86, 214, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(86, 214, 255, .045) 1px, transparent 1px),
    url("assets/cyberpunk-parking-bg.png"),
    radial-gradient(circle at 18% 0%, rgba(0, 224, 164, .12), transparent 32%),
    radial-gradient(circle at 90% 18%, rgba(183, 109, 255, .1), transparent 34%);
  background-size: cover, 32px 32px, 32px 32px, cover, auto, auto;
  background-position: center, center, center, right center, center, center;
  background-repeat: no-repeat, repeat, repeat, no-repeat, no-repeat, no-repeat;
  background-blend-mode: normal, normal, normal, screen, normal, normal;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: .1;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, .018) 3px 4px);
}

button { font: inherit; }

.page-shell { width: min(1240px, calc(100% - 34px)); margin: 0 auto; padding: 32px 0 48px; }

.terminal-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 2px 20px;
  border-bottom: 1px solid var(--grid);
  animation: terminal-boot .45s ease-out both;
}

.header-copy { min-width: 0; }

.terminal-kicker,
.panel-kicker,
.metric-label,
.terminal-label,
.live-status,
.terminal-readout span {
  font-family: var(--font-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.terminal-kicker,
.panel-kicker {
  margin: 0 0 9px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
}

h1, h2, p { margin-top: 0; }

h1 { margin-bottom: 0; font-size: clamp(30px, 4vw, 48px); line-height: 1; letter-spacing: -.055em; }

.page-title > span,
.hero-label,
.stat-label,
.chart-header h2,
.range-button,
.refresh-modal-card h2,
.modal-close-button {
  font-family: var(--font-display-cn);
  font-weight: 900;
}

.page-title { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--available);
  border: 1px solid rgba(0, 224, 164, .42);
  background: rgba(0, 224, 164, .06);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.live-status i {
  display: block;
  width: 7px;
  height: 7px;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
  animation: live-pulse 1.8s ease-in-out infinite;
}

.refresh-button {
  border: 0;
  border-radius: 0;
  padding: 13px 22px;
  color: var(--muted);
  font-size: 15px;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

.refresh-button:disabled { cursor: wait; opacity: .65; }

.refresh-icon-button {
  position: relative;
  display: grid;
  width: 64px;
  height: 64px;
  padding: 0;
  place-items: center;
  border-radius: 0;
  background: transparent;
  transition: color 0.5s ease-in-out;
}

.refresh-icon-button svg {
  width: 54px;
  height: 54px;
  fill: currentColor;
  stroke: none;
  transform: rotate(0deg);
  transition: transform 0.5s ease-in-out;
}

.refresh-icon-button:hover { color: var(--text); background: transparent; }
.refresh-icon-button:hover svg { transform: rotate(45deg); }
.refresh-icon-button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.refresh-icon-button::after {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  padding: 4px 7px;
  border: 1px solid var(--grid);
  border-radius: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  content: "刷新";
  background: var(--surface-raised);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -3px);
  transition: opacity .16s ease, transform .16s ease;
}

.refresh-icon-button:hover::after,
.refresh-icon-button:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }

.terminal-panel {
  position: relative;
  border: 1px solid var(--grid);
  border-radius: 2px;
  background-color: rgba(12, 28, 43, .76);
  box-shadow: 0 0 0 1px rgba(86, 214, 255, .025), 0 18px 45px rgba(0, 0, 0, .2);
}

.terminal-panel::before,
.terminal-panel::after {
  position: absolute;
  width: 14px;
  height: 5px;
  content: "";
  pointer-events: none;
}

.terminal-panel::before {
  top: -1px;
  left: 16px;
  border-top: 2px solid var(--cyan);
  border-left: 1px solid var(--cyan);
}

.terminal-panel::after {
  right: 16px;
  bottom: -1px;
  border-right: 1px solid var(--available);
  border-bottom: 2px solid var(--available);
}

.current-terminal {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .85fr);
  gap: 28px;
  min-height: 224px;
  margin: 24px 0 12px;
  overflow: hidden;
}

.current-terminal-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 30px 34px;
  background: linear-gradient(110deg, rgba(0, 224, 164, .08), transparent 58%);
}

.terminal-label { margin-bottom: 10px; color: var(--cyan); font-size: 11px; font-weight: 700; }
.hero-label { display: block; color: var(--muted); font-size: 14px; font-weight: 700; }
.hero-main strong, .current-terminal-main strong { display: block; margin: 10px 0 5px; color: var(--available); font-family: var(--font-mono); font-size: clamp(66px, 11vw, 112px); line-height: .86; letter-spacing: -.1em; text-shadow: 0 0 18px rgba(0, 224, 164, .35); }
.hero-hint { color: var(--muted); font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em; }

.current-terminal-side {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-content: center;
  gap: 16px;
  padding: 28px 30px;
  border-left: 1px solid var(--grid);
  background: rgba(16, 40, 58, .62);
}

.terminal-readout { padding: 12px 14px; border: 1px solid var(--grid); background: rgba(7, 17, 31, .38); }
.terminal-readout span { display: block; color: var(--muted); font-size: 10px; line-height: 1.4; }
.terminal-readout strong { display: block; margin-top: 8px; color: var(--text); font-family: var(--font-mono); font-size: clamp(24px, 4vw, 38px); line-height: 1; }
.current-terminal-side .terminal-readout:nth-child(2) strong { color: var(--cyan); }
.terminal-updated { grid-column: 1 / -1; margin: 0; color: var(--muted); font-family: var(--font-mono); font-size: 11px; }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }

.metric-card {
  position: relative;
  min-height: 128px;
  padding: 17px 19px;
  border: 1px solid var(--grid);
  border-radius: 2px;
  background: rgba(12, 28, 43, .84);
}

.metric-card::before { position: absolute; top: 0; right: 0; width: 20px; height: 2px; content: ""; background: var(--grid); }
.metric-label { display: block; margin-bottom: 12px; color: var(--cyan); font-size: 10px; font-weight: 700; }
.stat-label { display: block; color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-card strong, .stat-card strong { display: block; margin: 9px 0 4px; color: var(--text); font-family: var(--font-mono); font-size: clamp(30px, 5vw, 48px); line-height: 1; letter-spacing: -.07em; }
.stat-hint { color: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.stat-card-capacity strong { color: var(--cyan); }
.stat-card-occupied strong { color: var(--occupied); text-shadow: 0 0 12px rgba(183, 109, 255, .25); }
.stat-card-usage strong { color: var(--available); }

.chart-terminal { padding: 22px 24px 12px; overflow: hidden; background-color: rgba(12, 28, 43, .64); }
.chart-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.panel-kicker { margin-bottom: 7px; color: var(--muted); font-size: 10px; }
h2 { margin-bottom: 6px; color: var(--text); font-size: 20px; letter-spacing: -.03em; }
.status-text { margin-bottom: 0; color: var(--muted); font-family: var(--font-mono); font-size: 11px; white-space: nowrap; }

.range-switcher { display: flex; gap: 3px; padding: 4px; border: 1px solid var(--grid); border-radius: 2px; background: rgba(7, 17, 31, .7); }
.range-button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 13px 7px; color: var(--muted); font-size: 12px; background: transparent; cursor: pointer; }
.range-button:hover { color: var(--text); background: rgba(86, 214, 255, .08); }
.range-button.is-active { color: var(--cyan); border-bottom-color: var(--cyan); background: rgba(86, 214, 255, .1); box-shadow: none; }
.range-button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 13px 20px; margin: 18px 0 3px; color: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.legend span { white-space: nowrap; }
.legend span[hidden] { display: none; }
.legend-dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border: 1px solid rgba(255, 255, 255, .25); border-radius: 1px; vertical-align: -1px; }
.remaining-dot { background: var(--available); box-shadow: 0 0 8px rgba(0, 224, 164, .45); }
.occupied-dot { background: var(--occupied); box-shadow: 0 0 8px rgba(183, 109, 255, .35); }
.forecast-dot { background: var(--muted); }
.full-time-dot { background: var(--full); box-shadow: 0 0 8px rgba(255, 85, 102, .35); }

.chart-wrap { position: relative; min-height: 290px; }
#parking-chart { display: block; width: 100%; height: 360px; }
.empty-state { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-family: var(--font-mono); font-size: 13px; }
.empty-state[hidden] { display: none; }

.refresh-modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(2, 8, 17, .78); }
.refresh-modal[hidden] { display: none; }
.refresh-modal-card { width: min(360px, 100%); padding: 24px; text-align: center; }
.refresh-modal-card h2 { margin-bottom: 10px; }
.refresh-modal-card > p:not(.terminal-kicker) { margin-bottom: 20px; color: var(--muted); font-size: 14px; }
.modal-close-button { border: 1px solid var(--cyan); border-radius: 0; padding: 9px 20px; color: var(--cyan); font-size: 12px; background: rgba(86, 214, 255, .08); cursor: pointer; }
.modal-close-button:hover { color: var(--bg); background: var(--cyan); }
.modal-close-button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

@keyframes terminal-boot { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes live-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

.site-footer {
  padding: 20px 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-align: center;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--cyan);
}

@media (max-width: 820px) {
  .terminal-header { align-items: flex-start; }
  .current-terminal { grid-template-columns: 1fr; gap: 0; }
  .current-terminal-side { border-top: 1px solid var(--grid); border-left: 0; }
}

@media (max-width: 560px) {
  body { background-position: center, center, center, 72% center, center, center; }
  .page-shell { width: min(100% - 20px, 1240px); padding-top: 24px; }
  .terminal-header { gap: 12px; padding-bottom: 16px; }
  .terminal-kicker { font-size: 9px; letter-spacing: .08em; }
  h1 { font-size: clamp(26px, 8vw, 36px); }
  .live-status { padding: 6px 8px; font-size: 9px; }
  .refresh-icon-button { width: 52px; height: 52px; }
  .refresh-icon-button svg { width: 44px; height: 44px; }
  .current-terminal { margin-top: 16px; }
  .current-terminal-main { padding: 24px 22px 28px; }
  .current-terminal-side { grid-template-columns: repeat(2, 1fr); padding: 18px 20px 20px; }
  .terminal-readout { padding: 10px 11px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 118px; padding: 14px; }
  .metric-card:last-child { grid-column: 1 / -1; }
  .chart-terminal { padding: 18px 12px 8px; }
  .chart-header { flex-direction: column; gap: 14px; }
  .range-switcher { align-self: stretch; }
  .range-button { flex: 1; padding-inline: 5px; }
  .legend { gap: 10px 12px; margin-top: 15px; font-size: 10px; }
  #parking-chart { height: 320px; }
}

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