/* alSubte — Design tokens */
:root {
  /* Line colors */
  --linea-a-1: #58BBD9; --linea-a-2: #0078B1;
  --linea-b-1: #E13A40; --linea-b-2: #A72126;
  --linea-c-1: #2285BB; --linea-c-2: #09517D;
  --linea-d-1: #008B6E; --linea-d-2: #006515;
  --linea-e-1: #87307E; --linea-e-2: #52267D;
  --linea-h-1: #FFCC00; --linea-h-2: #D4A200;
  --linea-p-1: #FFC85C; --linea-p-2: #E79A14;
  --linea-u-1: #FF8C3A; --linea-u-2: #C85A0F;

  /* Neutrals */
  --ink-900: #0B1220;
  --ink-800: #101E37;
  --ink-700: #23334F;
  --ink-600: #38485C;
  --ink-500: #5C6A7A;
  --ink-400: #8A97A8;
  --ink-300: #B8C1CC;
  --ink-200: #E6EBF0;
  --ink-100: #F3F6F9;
  --ink-050: #FAFBFC;

  /* Surfaces (light) */
  --bg: #F3F6F9;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --border: #E6EBF0;
  --text: #101E37;
  --text-muted: #5C6A7A;
  --text-dim: #8A97A8;

  /* Semantic */
  --ok: #21826E;
  --warn: #F5B301;
  --error: #CC3333;
  --info: #0078B1;

  /* Radii & shadows */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(16,30,55,.06), 0 1px 1px rgba(16,30,55,.04);
  --shadow-md: 0 4px 12px rgba(16,30,55,.08), 0 2px 4px rgba(16,30,55,.04);
  --shadow-lg: 0 12px 32px rgba(16,30,55,.14), 0 4px 8px rgba(16,30,55,.06);

  /* Type */
  --font-display: 'Nunito', system-ui, sans-serif;
  --font-body: 'Open Sans', system-ui, sans-serif;

  /* Sidebar width (desktop) */
  --sidebar-w: 220px;
}

html[data-theme="dark"] {
  --bg: #07101F;
  --surface: #101E37;
  --surface-2: #0B1628;
  --border: #1E2C48;
  --text: #F3F6F9;
  --text-muted: #B8C1CC;
  --text-dim: #8A97A8;
  --ink-200: #1E2C48;
  --ink-100: #101E37;
  --ink-050: #0B1628;
}

/* ─── Reset ──────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
  overscroll-behavior: none;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; font-weight: 700; letter-spacing: -0.01em; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ─── App shell ──────────────────────────────────────────── */
#root {
  height: 100%;
  display: flex;
}

/* Full-height responsive layout */
.app-layout {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg);
}

/* ─── Sidebar (desktop only) ─────────────────────────────── */
.app-sidebar {
  display: none; /* hidden on mobile */
}

@media (min-width: 768px) {
  .app-sidebar {
    display: flex;
    flex-direction: column;
    /*width: var(--sidebar-w);*/
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    gap: 2px;
    overflow-y: auto;
  }
  .app-sidebar::-webkit-scrollbar { width: 0; }
}

.sidebar-logo {
  padding: 0 8px 18px;
}

.sidebar-item {
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  text-align: left;
  color: var(--text);
  transition: background .12s;
  width: 100%;
}
.sidebar-item:hover { background: var(--ink-100); }
.sidebar-item.active { background: var(--ink-900); color: #fff; }

.sidebar-footer {
  margin-top: auto;
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text-dim);
  justify-content: center;
}

/* ─── Bottom nav (mobile only) ───────────────────────────── */
.bottom-nav {
  height: 72px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 8px);
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .bottom-nav { display: none; }
}

.bottom-nav .nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
}
.bottom-nav .nav-item.active { color: var(--text); }
.bottom-nav .nav-item .dot-indicator {
  width: 4px; height: 4px; border-radius: 50%; background: var(--ink-900);
  margin-top: 2px; opacity: 0;
}
.bottom-nav .nav-item.active .dot-indicator { opacity: 1; }

/* ─── Line gradients & chips ─────────────────────────────── */
.grad-a { background: linear-gradient(180deg, var(--linea-a-1) 50%, var(--linea-a-2) 100%); }
.grad-b { background: linear-gradient(180deg, var(--linea-b-1) 50%, var(--linea-b-2) 100%); }
.grad-c { background: linear-gradient(180deg, var(--linea-c-1) 50%, var(--linea-c-2) 100%); }
.grad-d { background: linear-gradient(180deg, var(--linea-d-1) 50%, var(--linea-d-2) 100%); }
.grad-e { background: linear-gradient(180deg, var(--linea-e-1) 50%, var(--linea-e-2) 100%); }
.grad-h { background: linear-gradient(180deg, var(--linea-h-1) 50%, var(--linea-h-2) 100%); color: #0B1220; }
.grad-p { background: linear-gradient(180deg, var(--linea-p-1) 50%, var(--linea-p-2) 100%); }
.grad-u { background: linear-gradient(180deg, var(--linea-u-1) 50%, var(--linea-u-2) 100%); }

.solid-a { background: var(--linea-a-2); }
.solid-b { background: var(--linea-b-2); }
.solid-c { background: var(--linea-c-2); }
.solid-d { background: var(--linea-d-2); }
.solid-e { background: var(--linea-e-2); }
.solid-h { background: var(--linea-h-1); color: #0B1220; }
.solid-p { background: var(--linea-p-2); }
.solid-u { background: var(--linea-u-2); }

.line-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  font-family: var(--font-display); font-weight: 700; color: white;
  font-size: 16px; flex-shrink: 0;
}
.line-chip.lg { width: 48px; height: 48px; font-size: 22px; }
.line-chip.sm { width: 22px; height: 22px; font-size: 12px; }
.line-chip.h { color: #0B1220; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  transition: transform .1s, filter .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink-900); color: white; }
.btn-primary:hover { filter: brightness(1.15); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--ink-100); }
.btn-ghost { color: var(--text-muted); }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 16px 24px; font-size: 17px; }

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* ─── Top app bar ────────────────────────────────────────── */
.app-bar {
  padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg);
}
.app-bar h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.app-bar .subtitle { font-size: 12px; color: var(--text-muted); font-weight: 400; }

@media (min-width: 768px) {
  .app-bar { padding: 14px 23px; }
  .app-bar h1 { font-size: 23px; }
}

/* ─── Scroll area ────────────────────────────────────────── */
.scroll-area { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.scroll-area::-webkit-scrollbar { width: 4px; }
.scroll-area::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 2px; }

/* ─── Utility ────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ─── Icons ──────────────────────────────────────────────── */
.icon { width: 24px; height: 24px; stroke-width: 2; stroke: currentColor; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 18px; height: 18px; }
.icon.lg { width: 28px; height: 28px; }

/* ─── Tweaks panel ───────────────────────────────────────── */
.tweaks {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  padding: 16px;
  z-index: 1000;
  font-family: var(--font-display);
  font-size: 13px;
  min-width: 240px;
  display: none;
}
.tweaks.open { display: block; }
.tweaks h3 { font-size: 14px; margin-bottom: 12px; }
.tweaks .tweak-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; }
.tweaks .segmented { display: inline-flex; background: var(--ink-200); border-radius: 8px; padding: 2px; }
.tweaks .segmented button { padding: 5px 12px; font-size: 12px; font-weight: 700; border-radius: 6px; color: var(--text-muted); }
.tweaks .segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ─── Animations ─────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(1.3); }
}
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); margin-right: 6px; animation: pulse 1.8s ease-in-out infinite;
}

/* ─── Map ────────────────────────────────────────────────── */
.schematic-line { stroke-width: 8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.station-dot { fill: white; stroke-width: 2; }

/* ─── Skeleton ───────────────────────────────────────────── */
.ph-img {
  background:
    repeating-linear-gradient(45deg, rgba(0,0,0,.04) 0 8px, transparent 8px 16px),
    var(--ink-100);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  font-family: ui-monospace, monospace;
  font-size: 11px;
  border-radius: var(--r-md);
}

/* ─── Leaflet overrides ──────────────────────────────────── */
.leaflet-container { font-family: var(--font-body); }
.leaflet-station-tip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  padding: 3px 8px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.leaflet-station-tip::before { display: none; }

.leaflet-train-tip {
  background: var(--ink-900);
  border: none;
  border-radius: 6px;
  color: var(--bg);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  padding: 3px 8px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.leaflet-train-tip::before { display: none; }

.leaflet-entrance-tip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 11px;
  line-height: 1.4;
  padding: 4px 8px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  max-width: 220px;
  white-space: normal;
}
.leaflet-entrance-tip::before { display: none; }

/* ─── Responsive content padding ────────────────────────── */
@media (min-width: 768px) {
  .lines-grid { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (min-width: 1100px) {
  .lines-grid { grid-template-columns: repeat(4, 1fr) !important; }
}

/*
 * .page  — wraps every "narrow" screen (lineDetail, settings, news, etc.)
 * On desktop it centers the column and adds a subtle side border so it
 * doesn't stretch across a 1440px window like a bad WordPress theme.
 */
.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 100%;
}

@media (min-width: 768px) {
  .page {
    max-width: 680px;
    margin: 0 auto;
    border-left:  1px solid var(--border);
    border-right: 1px solid var(--border);
    background: var(--bg);
  }
}

/* Wider page variant (lineDetail, map full-screen) */
@media (min-width: 768px) {
  .page-wide { max-width: 860px; }
}

/* Scroll area shows thin scrollbar on desktop */
@media (min-width: 768px) {
  .scroll-area::-webkit-scrollbar { width: 4px; }
  .scroll-area::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 2px; }
}

/* ─── Blink (closing-soon warning) ──────────────────────── */
@keyframes alsubte-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: .38; }
}
.blink { animation: alsubte-blink 1.1s ease-in-out infinite; }

/* ─── Screen transitions ─────────────────────────────────── */
@keyframes screenEnter {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen-transition {
  display: contents;
  animation: screenEnter .18s ease;
}
/* screen-transition wraps the flex child — keep flex layout working */
.app-content > .screen-transition { display: flex; flex-direction: column; flex: 1; min-height: 0; }
