:root {
  --bg: #0D0D0D;
  --bg2: #141418;
  --card: #1a1a22;
  --text: #e4e4e7;
  --muted: #a1a1aa;
  --accent: #D466F2;
  --accent2: #27DEF2;
  --accent3: #A854BF;
  --accent4: #9538F2;
  --border: #2a2a35;
  --danger: #ef4444;
  --success: #22c55e;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

.offline-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  padding: 6px 16px;
  padding-top: calc(6px + env(safe-area-inset-top, 0px));
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  text-align: center;
}
.header h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.header-logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.header .sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* Content area */
.content {
  padding: 20px 16px;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 20px);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Section titles */
.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
.card-accent {
  border-left: 3px solid var(--accent);
}

/* Home tab */
.home-hero {
  text-align: center;
  padding: 28px 0 0;
  padding-top: calc(28px + env(safe-area-inset-top, 0px));
}
.home-logo {
  width: 128px;
  height: 128px;
  margin: 0 auto 16px;
  display: block;
  filter: drop-shadow(0 0 16px rgba(212,102,242,0.6)) drop-shadow(0 0 32px rgba(168,84,191,0.4));
}
.home-hero h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}
.home-hero .tagline {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 20px;
}
/* To Do tiles */
.todo-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(39,222,242,0.15), rgba(39,222,242,0.05));
  border: 1px solid var(--accent2);
  border-radius: 12px;
  margin-bottom: 12px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
a.todo-tile, button.todo-tile { color: var(--text); }
.todo-tile:active { background: var(--bg2); }
.todo-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent2);
}
.todo-icon.accent-bg {
  color: var(--accent);
}
.accent2-bg { background: rgba(39, 222, 242, 0.15); }
.accent-bg { background: rgba(212, 102, 242, 0.15); }
.todo-purple {
  background: linear-gradient(135deg, rgba(212,102,242,0.1), rgba(168,84,191,0.08));
  border-color: var(--accent3);
}
.todo-text {
  flex: 1;
  min-width: 0;
}
.todo-text h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.todo-text p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.todo-action {
  flex-shrink: 0;
}
.todo-arrow {
  color: var(--muted);
  font-size: 18px;
  flex-shrink: 0;
  margin-left: auto;
}
.btn-install {
  padding: 12px 18px;
  background: var(--accent);
  color: #0D0D0D;
  font-weight: 700;
  font-size: 13px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
  min-height: 44px;
}
.btn-install:hover { opacity: 0.9; }
.btn-install:disabled { opacity: 0.4; cursor: not-allowed; display: none; }
.btn-notif {
  padding: 12px 18px;
  background: var(--accent);
  color: #0D0D0D;
  font-weight: 700;
  font-size: 13px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
  min-height: 44px;
}
.btn-notif:hover { opacity: 0.9; }
.btn-notif:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-join {
  display: inline-block;
  padding: 12px 18px;
  background: var(--accent);
  color: #0D0D0D;
  font-weight: 700;
  font-size: 13px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s;
}
.btn-join:hover { opacity: 0.9; }
.btn-join { min-height: 44px; }
.waiver-dropdown {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 16px;
}
.waiver-dropdown.open { display: flex; }
.waiver-option {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.2s, border-color 0.2s;
}
.waiver-option:hover { background: var(--bg2); border-color: var(--accent2); }
.waiver-option svg { flex-shrink: 0; color: var(--accent2); }
.waiver-option-arrow { margin-left: auto; color: var(--muted); font-size: 18px; }
.waiver-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  background: var(--bg);
  flex-direction: column;
}
.waiver-modal.open { display: flex; }
.waiver-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.waiver-modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}
.waiver-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 10px 8px;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.waiver-modal-close:hover { color: var(--text); }
.waiver-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 20px);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}
.waiver-modal-body h3 {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  margin: 16px 0 6px;
}
.modal-heading {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}
.modal-para {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 16px;
}
.modal-para:last-child {
  margin-bottom: 0;
}
.waiver-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 4px;
}
.waiver-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}
.waiver-date {
  font-size: 12px;
  color: var(--accent2);
  margin-bottom: 12px;
  font-weight: 600;
}
.waiver-modal-body h4 {
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
  margin: 12px 0 6px;
}
.waiver-modal-body ul {
  font-size: 12px;
  color: var(--muted);
  padding-left: 18px;
  margin: 8px 0;
}
.waiver-modal-body h3:first-child { margin-top: 0; }
.waiver-modal-body p { margin-bottom: 8px; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent2);
  text-decoration: underline;
  cursor: pointer;
  text-align: left;
}
.link-btn:hover { color: var(--accent2); opacity: 0.85; }

/* Popup overlay */
.popup-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200;
  background: rgba(0,0,0,0.7);
  justify-content: center;
  align-items: center;
  padding: 24px;
}
.popup-overlay.open { display: flex; }
.popup-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 400px;
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.popup-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent2);
}
#checkin-modal .popup-header h2 { color: #fff; }
.popup-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.popup-close:hover { color: var(--text); }
.popup-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.popup-body h3 {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  margin: 16px 0 8px;
}
.popup-body h3:first-child { margin-top: 0; }
.popup-body p { margin-bottom: 8px; }
.popup-body ol, .popup-body ul {
  padding-left: 18px;
  margin-bottom: 12px;
}
.popup-body ol li, .popup-body ul li {
  margin-bottom: 6px;
}

/* Schedule */
.schedule-day {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}
.day-header-row {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}
.day-arrow {
  font-size: 12px;
  transition: transform 0.25s ease;
  color: var(--muted);
}
.schedule-day.expanded .day-header-row {
  border-bottom: 1px solid var(--border);
}
.schedule-day.expanded .day-arrow {
  transform: rotate(180deg);
}
.schedule-day-body {
  display: none;
}
.schedule-day.expanded .schedule-day-body {
  display: block;
}
.schedule-item {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.schedule-item:last-child { border-bottom: none; }
.schedule-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  min-width: 72px;
  white-space: nowrap;
}
.schedule-event {
  font-size: 14px;
  color: var(--text);
}
.schedule-detail {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.pill {
  position: absolute;
  top: 10px;
  right: 16px;
  background: var(--accent3);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Emergency */
.emergency-header {
  text-align: center;
  padding: 20px 0;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
}
.emergency-header .icon {
  font-size: 40px;
  margin-bottom: 2px;
}
.emergency-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--danger);
}
.emergency-header p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.contact-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.2s;
}
.contact-card:active { background: var(--bg2); }
.contact-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.contact-icon.red { background: rgba(239, 68, 68, 0.15); }
.contact-icon.amber { background: rgba(212, 102, 242, 0.15); }
.contact-icon.cyan { background: rgba(39, 222, 242, 0.15); }
.contact-info h3 {
  font-size: 14px;
  font-weight: 600;
}
.contact-info p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.contact-action {
  margin-left: auto;
  color: var(--muted);
  font-size: 18px;
}

/* Routes */
.route-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  margin-bottom: 16px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
}
.route-card:hover { border-color: var(--accent2); }
.route-card:active { transform: scale(0.98); }
.route-warmup { border-left: 4px solid var(--accent2); }
.route-r1 { border-left: 4px solid var(--accent2); }
.route-r2 { border-left: 4px solid var(--accent2); }
.route-r3 { border-left: 4px solid var(--accent2); }
.route-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
}
.route-header .open-icon {
  font-size: 14px;
  color: var(--accent2);
  opacity: 0.6;
  transition: opacity 0.2s;
}
.route-card:hover .open-icon { opacity: 1; }
.route-number {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}
.route-number.warmup { background: rgba(39, 222, 242, 0.15); color: var(--accent2); }
.route-number.r1 { background: rgba(212, 102, 242, 0.15); color: var(--accent); }
.route-number.r2 { background: rgba(168, 84, 191, 0.15); color: var(--accent3); }
.route-number.r3 { background: rgba(149, 56, 242, 0.15); color: var(--accent4); }
.route-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent2);
}
.route-body {
  padding: 0 16px 14px;
}
.route-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.route-meta span { display: flex; align-items: center; gap: 4px; }
/* Route tips */
.route-tips h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 10px;
}
.route-tips p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 8px;
}
.route-tips p:last-child { margin-bottom: 0; }
.route-tips strong {
  color: var(--text);
}
.routes-heading {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-top: 20px;
  margin-bottom: 16px;
}
.route-day-header {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.route-day-header:first-child {
  margin-top: 0;
}
/* Per-route lock */
.route-card.locked {
  pointer-events: none;
  position: relative;
}
.route-card.locked .route-lock {
  display: flex;
}
.route-card .route-lock {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(13,13,13,0.85);
  border-radius: 10px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  z-index: 2;
}
.route-lock-icon {
  font-size: 28px;
  opacity: 0.6;
}
.route-lock-text {
  font-size: 12px;
  color: var(--accent2);
  font-weight: 700;
}


/* Roster */
.roster-item {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.roster-item:last-child { border-bottom: none; }
.roster-car {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.roster-names {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.staff-pill {
  display: inline;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 3px;
  background: var(--accent2);
  color: var(--bg);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  vertical-align: super;
  line-height: 1;
  margin-left: 2px;
}
.admin-pill {
  background: #FFD700;
  color: #1a1a1a;
}
.media-pill {
  background: var(--accent4);
  color: #fff;
}

/* Bottom Nav */
/* Onboarding Tour */
.tour-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.4);
}
.tour-overlay.active { display: block; }
.tour-spotlight {
  position: absolute;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.50);
  z-index: 501;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.tour-card {
  position: absolute;
  z-index: 502;
  background: var(--card);
  border: 1px solid var(--accent3);
  border-radius: 14px;
  padding: 20px;
  width: calc(100vw - 40px);
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  transition: top 0.35s cubic-bezier(0.4, 0, 0.2, 1), left 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}
.tour-card.centered {
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%);
}
.tour-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 8px;
}
.tour-body {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 16px;
}
.tour-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 16px;
}
.tour-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s;
}
.tour-dot.active { background: var(--accent); }
.tour-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tour-btn-skip {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 12px 16px;
  min-height: 44px;
  transition: color 0.2s;
}
.tour-btn-skip:hover { color: var(--text); }
.tour-btn-next {
  background: var(--accent);
  color: #0D0D0D;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  min-height: 44px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.tour-btn-next:hover { opacity: 0.9; }
.nav-item.tour-highlight {
  color: var(--accent);
  position: relative;
}
.nav-item.tour-highlight svg {
  fill: var(--accent);
}
.nav-item.tour-highlight::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 12px;
  border: 2px solid var(--accent);
  box-shadow: 0 0 12px rgba(212, 102, 242, 0.5);
  animation: tour-pulse 1.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes tour-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(212, 102, 242, 0.5); }
  50% { box-shadow: 0 0 20px rgba(212, 102, 242, 0.8); }
}
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: var(--safe-bottom);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: var(--accent); }
.nav-item svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }