:root {
  --bg:      oklch(98% 0.005 250);
  --surface: oklch(100% 0 0);
  --fg:      oklch(22% 0.02 240);
  --muted:   oklch(50% 0.018 240);
  --border:  oklch(90% 0.008 240);
  --accent:  oklch(58% 0.16 145);
  --fg-soft: color-mix(in oklch, var(--fg) 5%, transparent);

  --font-display: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  --fs-h1: clamp(44px, 6vw, 72px);
  --fs-lead: 18px;
  --gap-xs: 8px;
  --gap-sm: 12px;
  --gap-md: 20px;
  --gap-lg: 32px;
  --gap-xl: 56px;
  --container: 1160px;
  --gutter: 32px;
  --radius: 8px;
  --radius-lg: 14px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; }

.container { max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }

/* ── Topbar ── */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in oklch, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: center; padding-block: 14px; position: relative; }
.logo { font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.logo-dot {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  background: url('/favicon-32x32.png') center / contain no-repeat;
}
.admin-entry {
  position: absolute; inset-inline-end: var(--gutter);
  font-size: 13px; color: var(--muted); padding: 6px 10px; border-radius: var(--radius);
}
.admin-entry:hover { color: var(--fg); background: var(--fg-soft); }

/* ── Page Header ── */

.page-header { padding-block: clamp(48px, 8vw, 80px) 0; text-align: center; }
.page-header .eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: var(--gap-sm);
}
.page-header h1 { font-family: var(--font-display); font-size: var(--fs-h1); line-height: 1.06; letter-spacing: -0.02em; font-weight: 700; margin-bottom: var(--gap-sm); }
.page-header .lead { font-size: var(--fs-lead); color: var(--muted); max-width: 56ch; margin-inline: auto; }

/* ── Search Panel ── */

.search-panel { padding-bottom: 40px; transition: opacity 0.25s ease, max-height 0.3s ease; overflow: hidden; }
.search-panel.collapsed { max-height: 0; padding-bottom: 0; opacity: 0; pointer-events: none; }

.search-wrap { position: relative; max-width: 600px; margin-inline: auto; margin-top: 40px; margin-bottom: 24px; }
.search-wrap .search-icon {
  position: absolute; inset-inline-start: 16px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--muted); pointer-events: none; z-index: 1;
  display: flex; align-items: center; justify-content: center;
}
.search-wrap .search-icon svg { display: block; width: 18px; height: 18px; }
.search-input {
  width: 100%; padding: 14px 18px 14px 46px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--fg);
  font: inherit; font-size: 15px; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-input:focus { border-color: var(--fg); box-shadow: 0 0 0 3px var(--fg-soft); }
.search-input::placeholder { color: var(--muted); }

/* ── Toolbar ── */

.toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--gap-md); flex-wrap: wrap; }
.toolbar .search-chips {
  display: grid;
  gap: var(--gap-xs);
  min-width: 0;
  flex: 1;
}
.filter-layer {
  display: flex;
  align-items: center;
  gap: var(--gap-xs);
  flex-wrap: wrap;
}
.filter-label {
  min-width: 34px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.filter-empty {
  color: var(--muted);
  font-size: 13px;
}
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); color: var(--muted); background: var(--surface);
  cursor: pointer; transition: all 0.15s ease;
}
.chip:hover { border-color: var(--fg); color: var(--fg); }
.chip.active { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.chip[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); color: var(--bg); }

.sort-group { display: flex; align-items: center; gap: var(--gap-xs); }
.sort-label { font-size: 13px; color: var(--muted); flex-shrink: 0; }
.sort-static {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.sort-btn {
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
  color: var(--muted); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.15s ease; background: var(--surface);
}
.sort-btn:hover { border-color: var(--fg); color: var(--fg); }
.sort-btn.active { background: var(--fg); border-color: var(--fg); color: var(--bg); }

/* ── Collapsed Search Bar ── */

.search-collapsed {
  position: sticky; top: 53px; z-index: 9;
  background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 0; max-height: 0; overflow: hidden;
  transition: max-height 0.25s ease, padding 0.25s ease, border-color 0.25s ease;
}
.search-collapsed.visible {
  max-height: 56px; padding: 10px 0; border-color: var(--border);
}
.search-collapsed-inner {
  display: flex; align-items: center; gap: 4px; cursor: pointer;
  font-size: 14px; color: var(--muted); padding-inline: var(--gutter);
}
.search-collapsed-inner:hover { color: var(--fg); }
.search-collapsed-inner svg { flex-shrink: 0; width: 16px; height: 16px; }
.search-collapsed-inner .collapsed-sep { color: var(--border); margin-inline: 4px; }
.search-collapsed-inner .chevron { transition: transform 0.2s ease; margin-inline-start: auto; }

/* ── Recent Section ── */

.recent-section { margin-bottom: var(--gap-md); display: none; }
.recent-section.visible { display: block; }
.recent-section .recent-heading { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: var(--gap-sm); text-transform: uppercase; letter-spacing: 0.04em; }
.recent-row { display: flex; gap: var(--gap-sm); flex-wrap: wrap; }
.recent-card {
  display: flex; align-items: center; gap: var(--gap-xs);
  padding: 8px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13px; cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.recent-card:hover { border-color: var(--fg); box-shadow: 0 2px 12px var(--fg-soft); }
.recent-card .rc-logo {
  width: 24px; height: 24px; border-radius: 5px; flex-shrink: 0;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
}
.recent-card .rc-name { font-weight: 550; }
.recent-card .rc-price { color: var(--muted); font-family: var(--font-mono); font-size: 11px; margin-inline-start: 4px; }

/* ── Station Grid ── */

.station-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap-md); padding-bottom: var(--gap-xl); }
@media (max-width: 920px) { .station-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .station-grid { grid-template-columns: 1fr; } }

/* ── Station Card (rendered as <a>) ── */

.station-card {
  display: block;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
  cursor: pointer;
  position: relative;
}
.station-card:hover {
  border-color: var(--fg);
  box-shadow: 0 4px 24px color-mix(in oklch, var(--fg) 8%, transparent);
  transform: translateY(-2px);
}
.station-card[aria-hidden="true"] { display: none; }

.station-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-sm);
  padding-bottom: var(--gap-xl);
}
.station-pager[hidden] { display: none; }
.pager-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  padding: 8px 14px;
  font-weight: 650;
}
.pager-btn:hover:not(:disabled) {
  border-color: var(--fg);
}
.pager-btn:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}
.pager-info {
  color: var(--muted);
  font-size: 13px;
}

.station-card .card-ext-link {
  position: absolute; top: 14px; right: 14px;
  width: 16px; height: 16px; color: var(--muted); opacity: 0;
  transition: opacity 0.15s ease;
}
.station-card:hover .card-ext-link { opacity: 1; }

.station-top { display: flex; align-items: center; gap: 14px; }
.station-logo {
  width: 40px; height: 40px; border-radius: var(--radius); flex-shrink: 0;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 15px; font-weight: 700; letter-spacing: -0.02em;
  overflow: hidden;
}
.station-logo img,
.rc-logo img,
.detail-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.station-info { flex: 1; min-width: 0; }
.station-name { font-size: 17px; font-weight: 650; letter-spacing: -0.015em; line-height: 1.2; }
.station-price {
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  color: var(--muted); margin-top: 3px;
}
.station-price-note { font-size: 11px; font-weight: 400; color: var(--muted); margin-inline-start: 4px; }

/* Status bars */

.status-bars { display: flex; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.status-bars .bar { width: 3px; height: 20px; border-radius: 1.5px; transition: background 0.3s ease; }
.status-bars .bar.on  { background: oklch(58% 0.16 145); }
.status-bars .bar.off { background: var(--border); }

/* Station detail */

.station-detail {
  background: var(--fg-soft); border-radius: var(--radius);
  padding: 10px 12px; margin-top: 10px;
}
.station-detail .station-desc { font-size: 12px; color: var(--muted); line-height: 1.5; margin-bottom: 6px; }
.station-models { display: flex; gap: 6px; flex-wrap: wrap; }
.model-tag {
  display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.02em;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
  cursor: pointer;
}
.model-tag:hover { border-color: var(--fg); color: var(--fg); }
.model-tag:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

/* Protocol note */

.station-protocol {
  font-size: 11px; color: var(--muted); margin-top: 6px;
  display: flex; align-items: center; gap: 4px;
}

/* ── Station Detail Page ── */

.station-page { padding-block: 36px var(--gap-xl); }
.back-link {
  display: inline-flex;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 18px;
}
.back-link:hover { color: var(--fg); }
.station-detail-hero {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  padding-block: 12px 36px;
}
.detail-logo {
  width: 92px;
  height: 92px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
}
.detail-heading h1 {
  font-size: clamp(36px, 5vw, 64px);
  line-height: 1.06;
  margin-bottom: 10px;
}
.detail-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.detail-visit {
  position: relative;
  min-height: 44px;
  padding: 10px 14px 10px 18px;
  border: 1px solid oklch(64% 0.22 34);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
  box-shadow:
    0 0 0 4px oklch(64% 0.22 34 / 0.08),
    0 12px 28px oklch(18% 0.04 210 / 0.10);
  animation: detailCtaPulse 2.8s ease-in-out infinite;
}
.detail-visit::after {
  content: "";
  position: absolute;
  inset: -40% auto -40% -30%;
  width: 42%;
  background: linear-gradient(90deg, transparent, oklch(100% 0 0 / 0.38), transparent);
  transform: skewX(-18deg);
  animation: detailCtaShine 3.8s ease-in-out infinite;
}
.detail-visit span,
.detail-visit-icon {
  position: relative;
  z-index: 1;
}
.detail-visit-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: drop-shadow(0 5px 8px oklch(18% 0.04 210 / 0.26));
  animation: detailIconFloat 1.9s ease-in-out infinite;
}
.detail-visit:hover {
  transform: translateY(-1px);
  border-color: oklch(72% 0.23 42);
  background: oklch(99% 0.018 52);
  box-shadow:
    0 0 0 5px oklch(64% 0.22 34 / 0.16),
    0 16px 34px oklch(64% 0.22 34 / 0.14);
  animation-play-state: paused;
}
.detail-visit:hover .detail-visit-icon {
  animation-play-state: paused;
}
@keyframes detailCtaPulse {
  0%, 100% {
    box-shadow:
      0 0 0 4px oklch(64% 0.22 34 / 0.10),
      0 12px 28px oklch(18% 0.04 210 / 0.10);
  }
  50% {
    box-shadow:
      0 0 0 6px oklch(64% 0.22 34 / 0.18),
      0 16px 36px oklch(64% 0.22 34 / 0.14);
  }
}
@keyframes detailCtaShine {
  0%, 54% { left: -38%; }
  76%, 100% { left: 118%; }
}
@keyframes detailIconFloat {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-3px) rotate(5deg); }
}
@media (prefers-reduced-motion: reduce) {
  .detail-visit,
  .detail-visit::after,
  .detail-visit-icon {
    animation: none;
  }
}
.detail-status,
.model-count {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
}
.detail-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.detail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-md);
  margin-bottom: 14px;
}
.detail-section-head h2 { font-size: 24px; }
.model-table-wrap { overflow-x: auto; }
.model-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.model-table th,
.model-table td {
  border-top: 1px solid var(--border);
  padding: 10px;
  text-align: left;
}
.model-table th {
  color: var(--muted);
  font-weight: 650;
}
.availability {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}
.availability.on {
  color: oklch(45% 0.14 145);
  border-color: oklch(72% 0.12 145);
}
.availability.off {
  color: oklch(55% 0.18 25);
  border-color: oklch(72% 0.12 25);
}

/* ── No Results ── */

.no-results { display: none; text-align: center; color: var(--muted); padding: 60px 0; font-size: 15px; }
.no-results.visible { display: block; }

/* ── Footer ── */

.pagefoot { padding-block: var(--gap-xl) var(--gap-lg); color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); text-align: center; }

/* ── Mobile ── */

@media (max-width: 560px) {
  .search-input { font-size: 16px; }
  .station-card { padding: 16px; }
  .toolbar { flex-direction: column; align-items: flex-start; gap: var(--gap-sm); }
  .recent-row { flex-direction: column; }
  .station-detail-hero { grid-template-columns: 1fr; }
  .detail-logo { width: 72px; height: 72px; }
}
