: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: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.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: center; justify-content: space-between; gap: var(--gap-md); flex-wrap: wrap; }
.toolbar .search-chips { display: flex; gap: var(--gap-xs); flex-wrap: wrap; }
.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-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-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;
}
.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;
}

/* ── 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; }
}
