@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@300;400;500&family=Syne:wght@700;800&display=swap');

/* ── Tokens — Dark (default) ────────────────────────────── */
:root {
  --bg:           #06090C;
  --bg-surface:   #0C1118;
  --bg-card:      #101820;
  --border:       #1A2535;
  --border-hi:    #263045;
  --text:         #DCE4EC;
  --text-2:       #5C7080;
  --text-3:       #1E2C3A;
  --amber:        #F0A500;
  --amber-dim:    rgba(240,165,0,0.10);
  --amber-glow:   rgba(240,165,0,0.09);
  --amber-glow2:  rgba(240,165,0,0.04);
  --green:        #22C55E;
  --red:          #EF4444;
  --ff-head:      'Syne', sans-serif;
  --ff-body:      'IBM Plex Sans', sans-serif;
  --ff-mono:      'IBM Plex Mono', monospace;
  --radius:       10px;
  --bg-dot:       #182230;
  --header-bg:    rgba(6,9,12,0.88);
  --ticker-border:#1C2A38;
  --shadow-card:  0 24px 60px rgba(0,0,0,0.5);
  --shadow-arch:  0 8px 36px rgba(0,0,0,0.35);
}

/* ── Tokens — Light ─────────────────────────────────────── */
[data-theme="light"] {
  --bg:           #F4EFE6;
  --bg-surface:   #EDE7DB;
  --bg-card:      #FAF8F4;
  --border:       #D4C9BA;
  --border-hi:    #B8AB9A;
  --text:         #1C1510;
  --text-2:       #7A6A5A;
  --text-3:       #C4B8A8;
  --amber:        #C87800;
  --amber-dim:    rgba(200,120,0,0.10);
  --amber-glow:   rgba(200,120,0,0.07);
  --amber-glow2:  rgba(200,120,0,0.03);
  --green:        #166534;
  --red:          #B91C1C;
  --bg-dot:       #D8CFBE;
  --header-bg:    rgba(244,239,230,0.90);
  --ticker-border:#C4B8A8;
  --shadow-card:  0 24px 60px rgba(0,0,0,0.12);
  --shadow-arch:  0 8px 36px rgba(0,0,0,0.10);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ── Base ───────────────────────────────────────────────── */
body {
  font-family: var(--ff-body);
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--bg-dot) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s, color 0.25s;
}

/* ── Header ─────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  transition: background 0.25s, border-color 0.25s;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.brand-mark {
  color: var(--amber);
  font-size: 1rem;
  line-height: 1;
}

.brand-name {
  font-family: var(--ff-head);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--text-2);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
  transition: background 0.4s, box-shadow 0.4s;
}

.status-dot.live {
  background: var(--green);
  box-shadow: 0 0 7px var(--green);
  animation: blink 2.4s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* ── Theme Toggle ───────────────────────────────────────── */
.theme-toggle {
  background: var(--bg-surface);
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1;
  margin-left: 0.75rem;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-dim);
}

.theme-icon {
  pointer-events: none;
  line-height: 1;
}

/* ── Main ───────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 4.5rem 2rem 5rem;
  display: flex;
  flex-direction: column;
  gap: 5.5rem;
}

/* ── Login ──────────────────────────────────────────────── */
#login-section {
  display: flex;
  justify-content: center;
  padding: 1rem 0;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 14px;
  padding: 2.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  box-shadow: var(--shadow-card);
  transition: background 0.25s, border-color 0.25s;
}

.login-heading { display: flex; flex-direction: column; gap: 0.3rem; }

.login-heading h1 {
  font-family: var(--ff-head);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.login-heading p {
  font-size: 0.85rem;
  color: var(--text-2);
  font-weight: 300;
}

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

.form-label {
  font-family: var(--ff-mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-2);
}

.form-input {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 0.9rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-dim);
}

.btn-primary {
  background: var(--amber);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem;
  font-family: var(--ff-head);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-primary:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.45; cursor: default; }

.form-error {
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  color: var(--red);
  text-align: center;
  display: none;
}

/* ── Ticker Display ─────────────────────────────────────── */
#ticker-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
}

.ticker-meta {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.ticker-label {
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-2);
}

.stop-badge {
  font-family: var(--ff-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--amber);
  background: var(--amber-dim);
  border: 1px solid rgba(240,165,0,0.18);
  border-radius: 4px;
  padding: 0.18rem 0.5rem;
}

.ticker-display {
  position: relative;
  overflow: hidden;
  background: #000;
  border-radius: 14px;
  padding: 1.25rem;
  border: 1px solid var(--ticker-border);
  box-shadow:
    0 0 0 1px var(--amber-glow2),
    0 0 50px var(--amber-glow),
    0 0 110px var(--amber-glow2),
    0 32px 72px rgba(0,0,0,0.7);
  transition: border-color 0.25s;
}

.ticker-display::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.07) 3px,
    rgba(0,0,0,0.07) 4px
  );
  pointer-events: none;
}

#container { line-height: 0; }

.ticker-footer {
  font-family: var(--ff-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--text-3);
}

/* ── Architecture ───────────────────────────────────────── */
.architecture {
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
}

.arch-header {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.arch-header h2 {
  font-family: var(--ff-head);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.arch-header p {
  font-size: 0.92rem;
  color: var(--text-2);
  font-weight: 300;
  line-height: 1.65;
  max-width: 540px;
}

.arch-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.arch-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem 1.75rem 1.5rem;
  overflow: hidden;
  box-shadow: inset 0 2px 0 var(--amber);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.arch-card:hover {
  border-color: var(--border-hi);
  box-shadow: inset 0 2px 0 var(--amber), var(--shadow-arch);
}

.arch-num {
  position: absolute;
  bottom: -1rem;
  right: 0.75rem;
  font-family: var(--ff-head);
  font-size: 5.5rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--text-3);
  user-select: none;
  pointer-events: none;
}

/* Wraps all content above the decorative number in its own stacking layer */
.arch-content {
  position: relative;
  z-index: 1;
}

.arch-step {
  font-family: var(--ff-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: var(--amber);
  text-transform: uppercase;
  margin-bottom: 0.6rem;
  display: block;
}

.arch-card h3 {
  font-family: var(--ff-head);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.65rem;
  letter-spacing: 0.01em;
}

.arch-card p {
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.7;
  font-weight: 300;
}

.tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1.25rem;
}

.tech-tag {
  font-family: var(--ff-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--text-2);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.18rem 0.52rem;
}

/* ── Footer ─────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
  text-align: center;
}

footer p {
  font-family: var(--ff-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--text-3);
}

/* ── Navigation ─────────────────────────────────────────── */
.header-inner {
  /* override to 3-column so nav sits in the middle */
  justify-content: space-between;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.nav-link {
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--text);
  border-color: var(--border-hi);
  background: var(--bg-surface);
  outline: none;
}

.nav-link.active {
  color: var(--amber);
  border-color: rgba(240,165,0,0.25);
  background: var(--amber-dim);
}

.nav-logout {
  color: var(--text-2);
}

.nav-logout:hover {
  color: var(--red);
  border-color: rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.08);
}

/* ── Location bar (home page) ────────────────────────────── */
.location-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  align-self: stretch;
  justify-content: center;
}

.location-select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 2rem 0.5rem 0.85rem;
  color: var(--text);
  font-family: var(--ff-mono);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235C7080' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 180px;
}

.location-select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-dim);
}

/* ── Settings page layout ────────────────────────────────── */
.settings-main {
  gap: 3rem;
}

.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: background 0.25s, border-color 0.25s;
}

.settings-header {
  padding: 1.75rem 2rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.settings-header h2 {
  font-family: var(--ff-head);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.settings-header p {
  font-size: 0.85rem;
  color: var(--text-2);
  font-weight: 300;
}

.settings-body {
  padding: 1.75rem 2rem;
}

/* ── Form layout helpers ─────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-divider {
  font-family: var(--ff-mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 1rem 0 0.75rem;
  border-top: 1px solid var(--border);
  margin: 0.5rem 0;
}

.form-divider-note {
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-3);
  font-family: var(--ff-body);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 0.75rem;
}

.btn-inline {
  width: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.form-msg {
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  display: none;
}

.form-msg-ok    { color: var(--green); }
.form-msg-error { color: var(--red);   }

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235C7080' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2rem;
  cursor: pointer;
}

.form-group-action {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ── Secondary and danger buttons ────────────────────────── */
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font-family: var(--ff-head);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-dim);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-danger {
  background: none;
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  font-family: var(--ff-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239,68,68,0.1);
  border-color: var(--red);
}

.btn-danger:disabled { opacity: 0.4; cursor: default; }

/* ── Locations list ──────────────────────────────────────── */
.locations-list {
  padding: 0 2rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.location-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.location-item:first-child {
  padding-top: 1.5rem;
}

.location-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.location-item-name {
  font-family: var(--ff-head);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-item-detail {
  font-family: var(--ff-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--text-2);
}

/* ── Add location form ───────────────────────────────────── */
.add-location-form {
  padding: 1.5rem 2rem 2rem;
  border-top: 1px solid var(--border);
}

.section-subtitle {
  font-family: var(--ff-mono);
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 1.25rem;
}

/* ── Selected station display ────────────────────────────── */
.selected-station {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--amber-dim);
  border: 1px solid rgba(240,165,0,0.2);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.station-summary {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.station-summary-name {
  font-family: var(--ff-head);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--amber);
}

.station-summary-detail {
  font-family: var(--ff-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--text-2);
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  font-family: var(--ff-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--text-2);
  padding: 1.5rem 0;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-family: var(--ff-head);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--text); }

.modal-subtext {
  font-size: 0.85rem;
  color: var(--text-2);
  font-weight: 300;
  padding: 0.75rem 1.5rem 0;
}

.station-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.station-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.station-item:hover { background: var(--bg-surface); }

.station-item.selected {
  border-color: var(--amber);
  background: var(--amber-dim);
}

.station-radio {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-hi);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.15s;
}

.station-item.selected .station-radio {
  border-color: var(--amber);
}

.station-item.selected .station-radio::after {
  content: '';
  position: absolute;
  inset: 2px;
  background: var(--amber);
  border-radius: 50%;
}

.station-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.station-item-name {
  font-family: var(--ff-head);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.station-item-detail {
  font-family: var(--ff-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--text-2);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .arch-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .form-row { grid-template-columns: 1fr; }
  .settings-header,
  .settings-body,
  .add-location-form,
  .locations-list { padding-left: 1.25rem; padding-right: 1.25rem; }
}

@media (max-width: 600px) {
  .arch-grid { grid-template-columns: 1fr; }
  main { padding: 3rem 1.25rem 4rem; gap: 4rem; }
  .arch-header h2 { font-size: 1.5rem; }
  .header-nav { gap: 0; }
  .nav-link { padding: 0.3rem 0.45rem; font-size: 0.62rem; }
}
