:root {
  --bg: #0b1220;
  --panel: #0f172a;
  --panel-2: #0b1329;
  --muted: #94a3b8;
  --text: #e2e8f0;
  --primary: #22d3ee;
  --danger: #ef4444;
  --border: #1e293b;
  --raised: #1f2937;
  /* Popup cards, menus, dialogs */
  --card: #1e293b;
  --card-border: #334155;
  --card-inset: #0f172a;
  --card-hover: #172036;
  --heading: #f8fafc;
  --soft-text: #cbd5e1;
  --faint: #64748b;
  --glass: rgba(15, 23, 42, 0.98);
  --tooltip-bg: rgba(11, 18, 32, 0.94);
  --shadow: rgba(0, 0, 0, 0.5);
  --on-primary: #0b1220;
  --scroll-thumb: #6b7280;
  --scroll-thumb-hover: #9ca3af;
  --scroll-thumb-active: #d1d5db;
  --map-navy: #0b1220; /* the dark map's background, whatever the interface mode */
}

* { box-sizing: border-box; }
html, body { 
  height: 100%; 
  overflow: hidden; /* Disable page scrolling */
}
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

#app {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
  overflow: hidden; /* Prevent any scroll propagation */
}

#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: scroll; /* Force scrollbar to always be visible */
  overflow-x: hidden;
  height: 100vh; /* Ensure sidebar has its own scroll context */
  position: relative;
}

/* Custom scrollbar for sidebar - more visible and always present */
#sidebar::-webkit-scrollbar {
  width: 8px;
}

#sidebar::-webkit-scrollbar-track {
  background: var(--panel-2);
  border-radius: 4px;
  border: 1px solid var(--border);
}

#sidebar::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 4px;
  border: 1px solid var(--scroll-thumb-hover);
}

#sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

#sidebar::-webkit-scrollbar-thumb:active {
  background: var(--scroll-thumb-active);
}

/* Firefox scrollbar - more visible */
#sidebar {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--panel-2);
}

/* Force scrollbar to always be visible */
#sidebar {
  scrollbar-gutter: stable;
  /* Ensure content always overflows to force scrollbar */
  min-height: calc(100vh + 1px);
}

#main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden; /* Prevent any scroll propagation */
}

/* List view styles */
#listView {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  padding: 16px;
  height: calc(100vh - 56px); /* Fixed height to ensure independent scroll */
  position: relative;
}

/* Setup title on the first tier header's line ("POWER ..."): title centered, site URL right-aligned by the
   search button. Narrower desktops put the title on its own line above (see the media query below) */
#listWatermark {
  position: absolute;
  top: 16px; /* #listView padding: the first header's top */
  left: 16px;
  right: 56px; /* clear of the search button */
  height: 31px; /* the first header's height (see below) */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  z-index: 100;
  pointer-events: none;
  white-space: nowrap;
}

#listWatermark .setup-title {
  grid-column: 2;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  line-height: 24px;
}

#listWatermark .list-watermark-url {
  grid-column: 3;
  justify-self: end;
}

/* Narrower desktops: not enough room for the title between "POWER ..." and the URL, so the title gets its own
   line above them (the list moves down 36px; the URL and search button stay on the POWER line) */
@media (max-width: 1200px) {
  #listView { padding-top: 52px; }
  #listWatermark {
    top: 16px;
    height: 67px; /* title row + the first header's row */
    grid-template-rows: 36px 31px;
  }
  #listWatermark .setup-title { grid-row: 1; grid-column: 1 / -1; justify-self: center; }
  #listWatermark .list-watermark-url { grid-row: 2; }
  #listViewSearchButton { top: 57px !important; }
}

/* The first tier header is tall enough for the setup title on its line */
#listContainer > .list-section-header:first-child {
  padding-top: 8px;
  padding-bottom: 8px;
}

#listWatermark .setup-title:empty {
  display: none;
}

/* The setup title is clickable to rename (the rest of the watermark ignores the mouse) */
.setup-title {
  pointer-events: auto;
  cursor: text;
}

#listWatermark .setup-title:hover {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

#mapWatermark .setup-title:hover {
  fill: #0891b2;
}

.setup-title-input {
  position: fixed;
  transform: translateY(-50%);
  z-index: 10001;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--accent, #22d3ee);
  background: var(--panel, #0f172a);
  color: var(--text);
  box-sizing: border-box;
}

#listContainer {
  display: flex;
  flex-direction: column;
}

/* List view tier headers: small caps title + counts */
.list-section-header {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 4px 0 4px 0;
  border-bottom: 1px solid var(--border);
  margin: 0 4px 10px;
}

/* Hidden block: "Hidden" divider, then one smaller header per tier */
.list-hidden-header { margin-top: 10px; color: var(--text); }
.list-section-subheader {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 4px 6px;
  opacity: 0.85;
}

/* Conference cards for each tier */
.list-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
  padding: 4px;
  border: 1px dashed transparent;
  border-radius: 10px;
}

.conference-column {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.conference-column-header {
  background: var(--panel-2);
  padding: 8px 10px;
  border-left: 4px solid var(--muted);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
}

.conference-column-name { flex: 1; min-width: 0; }

.conference-column-count {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.conference-color-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* School chips flow and wrap inside the card */
.conference-column-content {
  flex: 1;
  padding: 7px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
  min-height: 34px;
  border-radius: 0 0 10px 10px;
}

.school-item {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  cursor: grab;
  transition: border-color 0.15s, background-color 0.15s, opacity 0.2s;
  background: var(--raised);
  user-select: none;
}

.school-item:hover {
  border-color: var(--muted);
}

.school-item:active {
  cursor: grabbing;
}

/* Selected school/conference indication in list view */
.school-item.selected-school {
  border-color: var(--primary);
  color: var(--primary);
}

/* Search matched school in list view */
.school-item.search-matched {
  background: rgba(251, 191, 36, 0.25) !important;
  border-color: #fbbf24;
  font-weight: 600;
}

.conference-column.selected-conference {
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.3);
}

.conference-column.selected-conference .conference-column-header {
  background: rgba(34, 211, 238, 0.1);
}

/* Selected conference in sidebar */
.confButton.selected-conference-btn {
  border: 2px solid var(--primary) !important;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.5) !important;
}

/* Inline editing in list view */
.school-item.editing {
  flex-basis: 100%;
  padding: 2px;
  position: relative;
  border-color: var(--primary);
}

.school-item.editing input {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--primary);
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
}

.school-item.editing input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.2);
}

/* Floating actions for list view inline editing */
#listViewFloatingActions {
  position: fixed;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: none;
  gap: 6px;
  z-index: 1000;
}

#listViewFloatingActions button {
  white-space: nowrap;
  border-radius: 8px;
  font-size: 13px;
  padding: 8px 16px;
  font-weight: 500;
}

/* Drag and drop visual feedback */
.conference-column-content.drag-over {
  background: rgba(34, 211, 238, 0.06);
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}

/* Conference drag and drop styles */
.confButton.dragging {
  opacity: 0.7;
  cursor: grabbing !important;
  border: 2px solid var(--primary) !important;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.5);
}

.conference-column-header.dragging {
  opacity: 0.5;
  cursor: grabbing !important;
}

.tier-drop-zone-active {
  background: rgba(34, 211, 238, 0.1);
  border: 2px dashed var(--primary);
  border-radius: 4px;
  padding: 4px;
  transition: all 0.2s ease;
}

.list-section-grid.tier-drop-zone-active {
  background: rgba(34, 211, 238, 0.05);
  border: 1px dashed var(--primary);
  padding: 4px;
}

.conference-column-header.tier-drop-zone-active {
  background: rgba(34, 211, 238, 0.2);
  border: none;
  border-left: 4px solid var(--primary);
  box-shadow: inset 0 0 0 2px var(--primary);
  padding: 8px 10px;
}

.empty-conference {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

#toolbar {
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  padding: 8px; 
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
}

#toolbar .left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
}

#toolbar .left button {
  white-space: nowrap;
}

#toolbar .right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  height: 100%;
  flex: 0 1 auto;
}

/* Dropdown menu styles */
.dropdown-container {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  min-width: 150px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-height: 70vh;
  overflow-y: auto;
}

.dropdown-section-label {
  padding: 6px 12px 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
  transition: background-color 0.2s;
}

.dropdown-item:hover {
  background: rgba(34, 211, 238, 0.1);
  color: var(--primary);
}

h1 { font-size: 18px; margin: 0; line-height: 1; }
h2 { font-size: 14px; margin: 0; color: var(--muted); line-height: 1; }

.section { margin-bottom: 0; }
.section:not(:first-child) {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 0;
}
.section:first-child {
  margin-bottom: 12px;
}

/* Section header with consistent height */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 32px;
  margin-bottom: 12px;
}

/* Clickable section headers (for collapsible editors) */
#schoolSectionHeader,
#conferenceSectionHeader {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
  border-radius: 4px;
  padding: 0;
}

#schoolSectionHeader:hover,
#conferenceSectionHeader:hover {
  background-color: rgba(34, 211, 238, 0.1);
}

#schoolSectionHeader.clickable h2::after,
#conferenceSectionHeader.clickable h2::after {
  content: " ▸";
  font-size: 14px;
  color: var(--muted);
  transition: transform 0.2s ease;
  display: inline-block;
}

#schoolSectionHeader.expanded h2::after,
#conferenceSectionHeader.expanded h2::after {
  content: " ▾";
  font-size: 14px;
  color: var(--muted);
  display: inline-block;
}
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }

input[type="text"], input[type="number"], select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 8px;
}

input[type="color"] { width: 40px; height: 32px; border: none; background: transparent; }

button {
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
button.primary { border-color: #0ea5b0; color: var(--primary); }
button.danger { border-color: #7f1d1d; color: var(--danger); }
button:disabled { opacity: 0.4; cursor: default; }
#toolbar button:hover:not(:disabled),
#sidebar button:not(.confButton):hover:not(:disabled),
#floatingActions button:hover, #listViewFloatingActions button:hover,
#resetZoomBtn button:hover, #historyView button:hover:not(:disabled) { border-color: var(--muted); }

/* Sidebar buttons are all the same grey (no cyan Save) */
#sidebar button.primary, #sidebar button.secondary { border-color: var(--border); color: var(--text); }
#sidebar button.danger { border-color: var(--border); color: var(--danger); }

/* Toolbar buttons */
#toolbar .left button {
  font-size: 13px;
  padding: 6px 10px;
  line-height: 1.2;
}
#toolbar .left button svg { display: block; }
#toolbar .left .icon-btn, #toolbar .right .icon-btn { padding: 0 9px; }
/* Every toolbar button the same height (text, icon and toggle buttons) */
#toolbar .left button, #toolbar .right button, #toolbar .toggle-btn {
  height: 30px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Segmented control (sport selector next to the logo, territory style picker) */
.seg {
  display: inline-flex;
  flex: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.brand-row { gap: 14px; }
.brand-row .sport-toggle { margin-left: auto; }
.sport-toggle .seg-btn { padding: 4px 9px; font-size: 15px; line-height: 1.2; }
.sport-toggle .seg-btn:not(.active) { opacity: 0.45; }
.sport-toggle .seg-btn:not(.active):hover { opacity: 0.8; }

.toolbar-sport { display: none; }
.seg-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 0;
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
}
.seg-btn:hover:not(.active) { color: var(--text); }
#toolbar .seg-btn:hover { border-color: transparent; }
.seg-btn.active { background: var(--raised); color: var(--text); }

/* Toolbar view options (Labels, Territories, Regions, History, List View): buttons that stay
   selected while on. Each wraps a hidden checkbox, so clicking toggles it */
.toggle-btn {
  display: inline-flex;
  align-items: center;
  margin: 0;
  background: var(--raised);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.toggle-btn:hover { border-color: var(--muted); color: var(--text); }
.toggle-btn:has(input:checked) {
  background: rgba(34, 211, 238, 0.15);
  border-color: rgba(34, 211, 238, 0.55);
  color: var(--primary);
}
.toggle-btn:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); }

/* Narrower desktops: tighter toolbar so the toggles fit */
@media (max-width: 1500px) {
  #toolbar .left { gap: 5px; }
  #toolbar .left button { font-size: 12px; padding: 6px 8px; }
  #toolbar .right { gap: 6px; }
  .toggle-btn { font-size: 12px; padding: 6px 8px; }
}

label { margin-bottom: 16px; }
label span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

.checkbox { display: inline-flex; align-items: center; gap: 6px; }

/* Map option buttons move into the Settings menu when the toolbar is too narrow (fitToolbar() in app.js) */
#toolbar.condensed .map-option { display: none; }
#toolbar:not(.condensed) .settings-map-options { display: none; }

/* A closed card flies into Settings (minimizeIntoSettings() in app.js), which then pulses */
.info-card-ghost { overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
@keyframes settings-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.7); border-color: var(--primary); color: var(--primary); }
  70% { box-shadow: 0 0 0 10px rgba(34, 211, 238, 0); border-color: var(--primary); color: var(--primary); }
  100% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0); }
}
.settings-pulse { animation: settings-pulse 0.7s ease-out 2; }

/* Settings menu (⚙ in the toolbar): rows of label + switch */
.settings-container { position: relative; display: inline-flex; }
#settingsBtn.active { border-color: var(--muted); color: var(--text); }
.settings-menu { left: auto; right: 0; min-width: 210px; padding: 4px 0 6px; text-align: left; }
.settings-menu[hidden] { display: none; }
.settings-section-label {
  padding: 8px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.settings-section-label + .settings-row { margin-top: 0; }
.settings-row + .settings-section-label,
#toolbar.condensed .settings-map-options + .settings-section-label { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 10px; }
label.settings-row, div.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.settings-row:hover { background: var(--raised); }
.settings-row span.settings-row-label { display: inline; margin: 0; font-size: 13px; color: var(--text); }
label.settings-row span.toggle-switch { display: inline-flex; margin: 0; }
label.settings-row span.toggle-slider { margin: 0; }
.settings-row:has(input:focus-visible) .toggle-slider { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Toggle Switch Styles (v4): small dark track with a grey knob, muted label after it; cyan when on */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  cursor: pointer;
}

.toggle-container .toggle-label { order: 2; }

.toggle-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  line-height: 1;
}

.toggle-switch {
  position: relative;
  display: inline-flex;
  width: 30px;
  height: 17px;
  margin: 0;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background-color 0.15s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 13px;
  width: 13px;
  left: 1px;
  top: 1px;
  background-color: var(--muted);
  border-radius: 50%;
  transition: transform 0.15s, background-color 0.15s;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: rgba(34, 211, 238, 0.25);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(13px);
  background-color: var(--primary);
}

.toggle-switch:hover .toggle-slider {
  border-color: var(--muted);
}

.toggle-container:has(input:checked) .toggle-label { color: var(--text); }

.muted { color: var(--muted); font-size: 13px; }

.list { display: flex; flex-direction: column; gap: 14px; width: 100%; }

/* Tier grouping styles (tier headers carry their own underline) */
.tier-divider { display: none; }

.list-section-count {
  margin-left: 10px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
}

.tier-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

/* Tier header: TIER over its counts, [Show All] [Hide All] on the right; the divider sits above it so
   each label reads as the start of its own group */
.tier-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 6px;
  row-gap: 2px;
  padding-top: 10px;
  margin-bottom: 4px;
  border-top: 1px solid var(--border);
}
.tier-header .tier-title { grid-column: 1; grid-row: 1; }
.tier-header .tier-meta { grid-column: 1; grid-row: 2; }
.tier-header .tier-toggle-btn { grid-row: 1 / 3; }

.tier-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.tier-meta {
  flex: 1;
  min-width: 0;
  font-size: 10px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Small grey chip buttons (tier Show All / Hide All, section header buttons, conference Hide/Show) */
.chip-btn, .tier-toggle-btn, .conf-toggle-btn {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  line-height: 1.3;
  white-space: nowrap;
  border-radius: 6px;
}

/* School count between a conference button and its Show/Hide button */
.conf-school-count {
  min-width: 20px;
  text-align: right;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.tier-conferences {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
  padding: 2px;
  border-radius: 4px;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.tier-conferences.tier-drop-zone-active {
  background: rgba(34, 211, 238, 0.15);
  border: 2px dashed var(--primary);
  padding: 8px;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.3);
}

/* Editor spacing */
.editor {
  margin-top: 0;
  display: block;
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}

.editor.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.editor .row { margin-bottom: 16px; }
.editor label .row { margin-bottom: 0; }
.editor label { margin-bottom: 10px !important; display: block; }
#addNewConferenceBtn { margin-top: 16px !important; }
.confRow { display: grid; grid-template-columns: 1fr auto 46px; gap: 6px; align-items: center; width: 100%; }
.confRow .colorDot {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border);
}
.confRow .confButton {
  min-width: 0;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.confRow .conf-toggle-btn { width: 100%; text-align: center; padding: 3px 0; }

/* Hidden conference: faded chip with strikethrough */
.confRow.schools-hidden .confButton {
  opacity: 0.35;
  text-decoration: line-through;
}
.confRow.schools-hidden .conf-school-count { opacity: 0.6; }
/* Its Show button dims with it (full strength on hover) */
.confRow.schools-hidden .conf-toggle-btn { opacity: 0.5; }
.confRow.schools-hidden .conf-toggle-btn:hover,
.confRow.schools-hidden .conf-toggle-btn:focus-visible { opacity: 1; }

.fileLabel { display: inline-flex; align-items: center; gap: 8px; }
.fileLabel input { display: none; }
.fileLabel span { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--raised); }

#canvasContainer { position: relative; width: 100%; flex: 1; min-height: 0; overflow: hidden; } /* fills below the toolbar */
#mapCanvas { width: 100%; height: 100%; background: #ffffff; overflow: hidden; }

/* Floating action buttons on map */
#floatingActions {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  gap: 6px;
}

#floatingActions button {
  white-space: nowrap;
  border-radius: 8px;
}
.states { stroke: #64748b; stroke-width: 2; fill: none; }

.point { cursor: pointer; }
.point circle { stroke: none; }
.point .label { font-size: 16px; font-weight: 600; fill: #0b1220; paint-order: stroke; stroke: #ffffff; stroke-width: 1.5px; }
.point.selected circle { 
  stroke: #22d3ee; 
  stroke-width: 3;
  filter: drop-shadow(0 0 4px rgba(34, 211, 238, 0.6));
  animation: pulse-glow 2s ease-in-out infinite;
}
.point.selected .label { cursor: pointer; }

/* Pulsing glow animation for selected school */
@keyframes pulse-glow {
  0%, 100% { 
    filter: drop-shadow(0 0 4px rgba(34, 211, 238, 0.6));
    stroke-width: 3;
  }
  50% { 
    filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.9));
    stroke-width: 3.5;
  }
}

/* Conference highlighting - higher specificity to override selected */
.point.conference-selected circle { stroke: #000; stroke-width: 2; }
.point.selected.conference-selected circle { stroke: #000; stroke-width: 2; }

.hidden { display: none; }

/* Search match highlighting */
.point.search-matched text {
  font-weight: bold;
  paint-order: stroke fill;
  stroke: #fbbf24 !important;
  stroke-width: 4px !important;
  filter: drop-shadow(0 0 3px rgba(251, 191, 36, 0.8));
}

.tips { margin: 0; padding-left: 18px; color: var(--muted); }
.tips li { margin: 6px 0; }

/* Search button hover effect */
#searchButton circle,
#searchButton line {
  transition: stroke 0.2s;
}
#searchButton:hover circle,
#searchButton:hover line {
  stroke: #22d3ee;
}

/* List view search button hover effect */
#listViewSearchButton svg {
  transition: stroke 0.2s;
}
#listViewSearchButton:hover svg {
  stroke: #22d3ee;
}

/* ==================== MOBILE STYLES ==================== */

/* Default (desktop): hide toolbar title and mobile dropdowns */
#toolbarTitle {
  display: none;
}

/* Logo: primary mark + wordmark side by side (dark-background versions, see build_brand_assets.py) */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark { height: 30px; width: auto; display: block; }
.brand-wordmark { height: 30px; width: auto; display: block; }
#toolbarTitle .brand-mark { height: 18px; }
#toolbarTitle .brand-wordmark { height: 18px; }

.mobile-dropdown-container {
  display: none;
  position: relative;
  z-index: 10000;
}

.mobile-dropdown-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  white-space: nowrap;
}

.mobile-dropdown-btn:after {
  content: "▼";
  font-size: 10px;
  opacity: 0.7;
}

.mobile-dropdown-btn.open:after {
  content: "▲";
}

.mobile-dropdown-menu {
  display: none;
  position: fixed; /* Changed to fixed to ensure it's above everything */
  top: auto;
  left: auto;
  right: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 10001;
  max-height: 80vh; /* Allow it to take up most of screen if needed */
  overflow-y: auto;
  min-width: 200px;
}

.mobile-dropdown-menu.open {
  display: block;
}

.mobile-dropdown-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
}

.mobile-dropdown-item:last-child {
  border-bottom: none;
}

.mobile-dropdown-item:active {
  background: rgba(34, 211, 238, 0.15);
}

.mobile-dropdown-item-label {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  flex: 1;
}

/* Toggle switch in dropdown - remove transform and ensure proper sizing */
.mobile-dropdown-item .toggle-container {
  margin: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  height: auto;
}

.mobile-dropdown-item .toggle-switch {
  position: relative;
  display: inline-flex;
  width: 40px;
  height: 22px;
}

.mobile-dropdown-item .toggle-slider:before {
  height: 18px;
  width: 18px;
}

.mobile-dropdown-item .toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(18px);
}

/* Submenu styles */
.mobile-dropdown-submenu-trigger {
  position: relative;
}

.mobile-dropdown-submenu-trigger .submenu-arrow {
  font-size: 11px;
  opacity: 0.6;
  margin-left: auto;
  transition: transform 0.2s ease;
}

.mobile-dropdown-submenu-trigger:active {
  background: rgba(34, 211, 238, 0.1);
}

.mobile-dropdown-submenu {
  display: none;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
}

.mobile-dropdown-submenu.open {
  display: block;
}

.mobile-dropdown-submenu .mobile-dropdown-item {
  padding-left: 32px; /* Indent submenu items */
  background: var(--panel-2);
  min-height: 48px;
}

.mobile-dropdown-submenu .mobile-dropdown-item:hover {
  background: rgba(34, 211, 238, 0.08);
}

/* Drawer handle styles (hidden by default, shown in mobile list view) */
.drawer-handle {
  display: none;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--panel);
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  text-align: center;
  user-select: none;
}

.drawer-handle-bar {
  width: 40px;
  height: 4px;
  background: var(--muted);
  border-radius: 2px;
  margin: 0 auto 8px;
  opacity: 0.5;
}

.drawer-handle-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.drawer-handle:active .drawer-handle-bar {
  opacity: 0.8;
}

/* Prevent double-tap zoom on mobile */
button, a, .confButton, .school-item {
  touch-action: manipulation;
}

/* Setup title bar above the map / list, phones in portrait only */
#mobileTitleBar { display: none; }

/* Mobile Portrait (Vertical) - Stack everything vertically */
@media (max-width: 768px) and (orientation: portrait) {
  #mobileTitleBar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 8px 12px 7px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    text-align: center;
  }
  #mobileTitleBar .setup-title { font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.25; }
  #mobileTitleBar .setup-title:empty { display: none; }
  .mobile-title-url { font-size: 11px; font-weight: 600; color: var(--muted); }
  #mapWatermark { display: none; } /* ~7px at phone width; the title bar replaces it */

  /* The map is only ~230px tall here, so the popup card and Move to don't fit on it: they dock to the
     bottom of the screen instead (Move to at the bottom, the card above it), overriding the inline
     left/top info-cards.js sets. Above the list view's drawer handle. */
  body .info-card, body .info-card-aside { /* body: beats the base rules further down */
    position: fixed;
    left: 8px !important;
    right: 8px;
    top: auto !important;
    bottom: 8px;
    width: auto !important;
    max-height: 60vh !important;
  }
  body .info-card-aside { height: 34vh; max-height: 34vh !important; }
  body:has(.info-card-aside) .info-card { bottom: calc(34vh + 14px); max-height: calc(66vh - 90px) !important; }
  body.list-view-active .info-card-aside,
  body.list-view-active:not(:has(.info-card-aside)) .info-card { bottom: 56px; }
  body.list-view-active:has(.info-card-aside) .info-card { bottom: calc(34vh + 62px); }

  html, body {
    height: auto;
    overflow: auto; /* Enable page scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }

  #app {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  #toolbar {
    position: sticky;
    top: 0;
    z-index: 9000;
    background: var(--panel);
    padding: 8px 12px;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    display: flex;
  }

  /* Sport selector beside the toolbar logo (the sidebar one is hidden with the sidebar title) */
  .toolbar-sport { display: inline-flex; }

  /* Show compact toolbar title on mobile portrait only */
  #toolbarTitle {
    display: flex !important;
    flex: 0 0 auto;
    font-size: 12px !important;
    white-space: nowrap;
    align-items: center;
    gap: 6px;
  }


  /* Hide entire sidebar title section on mobile portrait */
  #sidebar .section:first-child {
    display: none !important;
  }

  #appTitle {
    display: none !important;
  }

  #toolbar .left,
  #toolbar .right {
    flex: 0 0 auto;
    display: none; /* Hide individual buttons */
  }

  /* Show mobile dropdown containers and position them */
  .mobile-dropdown-container {
    display: block;
    flex-shrink: 0;
  }

  /* No overflow scrolling here: iOS Safari clips the position: fixed menus to a scrolling toolbar,
     so they vanish behind the map. The toolbar is sized to fit instead (narrow phones below). */
  #toolbar {
    flex-wrap: nowrap;
    overflow: visible;
  }

  @media (max-width: 380px) {
    #toolbar { padding: 8px; gap: 6px; }
    .mobile-dropdown-btn { padding: 6px 8px; }
  }

  @media (max-width: 340px) {
    #toolbarTitle .brand-wordmark { display: none; }
  }

  /* Hide "Save to Current File" button on mobile */
  #saveToCurrentFileBtn {
    display: none !important;
  }

  #main {
    order: 1;
    height: auto;
    overflow: visible;
    position: relative;
    z-index: 1; /* Keep main below toolbar/dropdowns */
  }

  #canvasContainer {
    width: 100%;
    height: auto !important; /* Override base height rule */
    flex: none;
    aspect-ratio: 1700 / 1020; /* Match SVG viewBox ratio exactly */
    position: relative;
    overflow: hidden;
  }

  #mapCanvas {
    width: 100%;
    height: 100%;
    touch-action: pan-x pan-y pinch-zoom; /* Enable pinch-zoom on map */
  }

  /* Ensure SVG and its children don't interfere with dropdowns */
  svg#mapCanvas {
    position: relative;
    z-index: 0;
  }

  #listView {
    height: auto;
    min-height: 50vh;
    max-height: none;
    padding: 12px;
  }

  /* Hide list view watermark on mobile to save space */
  #listWatermark {
    display: none;
  }

  /* Compact list section headers */
  .list-section-header {
    font-size: 11px;
    padding: 6px 0 4px 0;
    margin-bottom: 8px;
  }

  /* Sidebar as pull-up drawer in list view only */
  body.list-view-active #sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 50vh;
    max-height: 50vh;
    background: var(--panel);
    border-top: 2px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding: 0;
    overflow: hidden;
    z-index: 8000;
    transform: translateY(calc(100% - 48px)); /* Show only handle by default */
    transition: transform 0.3s ease;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    display: flex !important;
    flex-direction: column;
  }

  body.list-view-active #sidebar.drawer-open {
    transform: translateY(0); /* Fully visible */
  }

  /* Show drawer handle only in list view */
  body.list-view-active .drawer-handle {
    display: block;
    flex-shrink: 0;
  }

  /* Sidebar content scrollable in drawer */
  body.list-view-active .sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }

  /* Scrollbar for sidebar content in drawer */
  body.list-view-active .sidebar-content::-webkit-scrollbar {
    width: 6px;
  }

  body.list-view-active .sidebar-content::-webkit-scrollbar-track {
    background: var(--panel-2);
  }

  body.list-view-active .sidebar-content::-webkit-scrollbar-thumb {
    background: var(--muted);
    border-radius: 3px;
  }

  /* Hide drawer handle in map view */
  body:not(.list-view-active) .drawer-handle {
    display: none;
  }

  /* Sidebar normal on map view */
  body:not(.list-view-active) #sidebar {
    order: 2;
    width: 100%;
    height: auto;
    max-height: none;
    overflow-y: visible;
    border-right: none;
    border-top: 2px solid var(--border);
    padding: 0;
    display: block !important;
    position: relative;
    transform: none;
  }

  body:not(.list-view-active) .sidebar-content {
    padding: 12px;
  }

  /* Adjust list view grid for mobile - 2-3 columns */
  .list-section-grid {
    grid-template-columns: repeat(2, 1fr); /* Two columns on mobile */
    gap: 8px;
  }

  .conference-column-header {
    font-size: 12px;
    padding: 8px 10px;
  }

  .school-item {
    font-size: 12px;
    padding: 5px 8px;
  }

  /* On very small screens, use 2 columns */
  @media (max-width: 400px) {
    .list-section-grid {
      grid-template-columns: repeat(2, 1fr);
      gap: 6px;
    }
  }

  /* On medium mobile screens, try 3 columns */
  @media (min-width: 401px) and (max-width: 768px) {
    .list-section-grid {
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
    }
  }

  /* Drawer backdrop */
  body.list-view-active::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 7999;
  }

  body.list-view-active #sidebar.drawer-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
  }

  /* Adjust conference list for mobile */
  .confRow {
    grid-template-columns: 1fr auto auto;
  }

  /* Hide search overlay better on mobile */
  #searchOverlay {
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    top: 70px;
    min-width: calc(100vw - 40px);
    max-width: calc(100vw - 40px);
  }

  /* Adjust floating actions for mobile */
  #floatingActions {
    padding: 4px;
    gap: 4px;
  }

  #floatingActions button {
    font-size: 11px;
    padding: 6px 10px;
  }

  /* Compact section headers */
  .section-header {
    height: auto;
    min-height: 28px;
    margin-bottom: 8px;
  }

  h1 {
    font-size: 16px;
  }

  h2 {
    font-size: 13px;
  }

  /* Ensure inputs and selects look good on mobile */
  input[type="text"],
  input[type="number"],
  select {
    font-size: 14px;
    padding: 8px 10px;
  }

  label span {
    font-size: 11px;
    margin-bottom: 4px;
  }

  /* Keep editor layout same as desktop - multiple elements per row */
  .editor .row {
    flex-direction: row;
    gap: 8px;
    flex-wrap: wrap;
  }

  .editor .row input {
    flex: 1;
    min-width: 0;
  }

  .editor .row select {
    flex: 1;
    min-width: 0;
  }

  .editor .row button {
    flex: 0 1 auto;
    white-space: nowrap;
  }

  /* Input color should not stretch */
  .editor .row input[type="color"] {
    flex: 0 0 40px;
  }

  /* Make coordinate tracker readable on mobile */
  #coordinateTracker {
    font-size: 10px;
    padding: 4px 8px;
  }

  /* Better touch targets for mobile */
  button {
    min-height: 36px;
    touch-action: manipulation;
    font-size: 12px;
    padding: 6px 10px;
  }

  /* Smaller buttons in editor rows */
  .editor .row button {
    min-height: 32px;
    font-size: 11px;
    padding: 6px 10px;
  }

  .confButton {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 13px;
  }

  .confRow { grid-template-columns: 1fr auto 52px; }
  .confRow .conf-toggle-btn, .tier-toggle-btn, .chip-btn {
    min-height: 32px;
    padding: 4px 6px;
    font-size: 12px;
  }

  /* Hide toggle labels on very small screens */
  @media (max-width: 400px) {
    .toggle-label {
      display: none;
    }

    #toolbar .right {
      gap: 8px;
    }
  }
}

/* Mobile Landscape - Keep split view but optimize dimensions */
@media (max-width: 1024px) and (orientation: landscape) {
  #app {
    grid-template-columns: 280px 1fr; /* Slightly narrower sidebar */
  }

  #sidebar {
    padding: 8px;
  }

  #sidebar .section {
    margin-bottom: 8px;
  }

  .section-header {
    height: auto;
    min-height: 24px;
    margin-bottom: 6px;
  }

  #toolbar {
    padding: 8px;
  }

  /* Hide toolbar title in landscape, show sidebar title */
  #toolbarTitle {
    display: none !important;
  }

  #appTitle {
    display: flex !important;
  }

  /* Show options dropdown but hide toggles dropdown (the ⚙ menu is on the toolbar) */
  .mobile-dropdown-container:has(#mobileOptionsBtn) {
    display: block;
    margin-left: 0;
  }

  .mobile-dropdown-container:has(#mobileTogglesBtn) {
    display: none !important;
  }

  /* Hide desktop left buttons */
  #toolbar .left {
    display: none !important;
  }

  /* Show desktop toggles inline in landscape */
  #toolbar .right {
    display: flex !important;
    flex: 1;
    justify-content: flex-end;
    gap: 12px;
  }

  /* Ensure toolbar uses flexbox properly */
  #toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* Make toggles compact for landscape */
  #toolbar .toggle-container {
    margin-right: 6px !important;
  }

  #toolbar .toggle-label {
    font-size: 10px;
  }

  .toggle-switch {
    width: 26px;
    height: 15px;
  }

  .toggle-slider:before {
    height: 11px;
    width: 11px;
  }

  .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(11px);
  }

  /* Compact dropdown button for landscape */
  .mobile-dropdown-btn {
    font-size: 10px;
    padding: 4px 10px;
    min-height: 28px;
  }

  /* Compact conference buttons in landscape */
  .confButton {
    min-height: 30px;
    padding: 4px 10px;
    font-size: 12px;
  }

  .list-section-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  h1 {
    font-size: 14px;
  }

  h2 {
    font-size: 12px;
  }

  /* Compact buttons in landscape */
  button {
    font-size: 11px;
    padding: 5px 8px;
    min-height: 30px;
  }

  .editor .row button {
    font-size: 10px;
    padding: 4px 8px;
    min-height: 28px;
  }

  /* Compact inputs */
  input[type="text"],
  input[type="number"],
  select {
    font-size: 13px;
    padding: 6px 8px;
  }

  label span {
    font-size: 10px;
  }

  /* Adjust search overlay for landscape mobile */
  #searchOverlay {
    min-width: 350px;
  }
}

/* Tablet Portrait - Optimize for medium screens */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: portrait) {
  #app {
    grid-template-columns: 300px 1fr;
  }

  .list-section-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  /* Hide toolbar title, show sidebar title */
  #toolbarTitle {
    display: none !important;
  }

  #appTitle {
    display: flex !important;
  }

  /* Hide mobile dropdowns */
  .mobile-dropdown-container {
    display: none !important;
  }
}

/* Desktop and larger tablets - ensure proper title display */
@media (min-width: 769px) {
  /* Hide toolbar title, show sidebar title */
  #toolbarTitle {
    display: none !important;
  }

  #appTitle {
    display: flex !important;
  }
}


/* History View Styles */
#historyView {
  position: relative;
  width: 100%;
  height: 100%;
}

#historyYearSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #22d3ee;
  cursor: pointer;
  border: 2px solid var(--card-inset);
}

#historyYearSlider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #22d3ee;
  cursor: pointer;
  border: 2px solid var(--card-inset);
}

/* History map labels: dark with a white halo like the editor's (light ones in dark map mode, below) */
#historyPointsLayer .label { fill: #0b1220; font-weight: 600; paint-order: stroke; stroke: #ffffff; stroke-width: 1.5px; }

/* Year-to-year animation: dots fade in when a school joins a conference, fade out when it leaves,
   and change color when it switches (HISTORY_FADE_MS in app.js matches) */
.history-point {
  transition: opacity 0.45s ease;
}
.history-point circle {
  transition: fill 0.45s ease;
}
.history-point.entering,
.history-point.leaving {
  opacity: 0;
}
.history-point.leaving {
  pointer-events: none;
}

.history-point:hover circle {
  r: 8;
  stroke-width: 2;
  stroke: #22d3ee;
}

.history-point:hover text {
  font-weight: 600;
  fill: #22d3ee;
}

/* Mobile adjustments for history view */
@media (max-width: 768px) {
  #historyYearDisplay {
    top: 10px;
    padding: 12px 24px;
  }

  #historyYearDisplay > div:first-child {
    font-size: 24px;
  }

  #historySliderContainer {
    bottom: 10px;
    width: 95%;
    padding: 16px 20px;
  }


  #historyPrevBtn,
  #historyNextBtn {
    min-width: 60px;
    padding: 6px 12px;
    font-size: 12px;
  }
}

/* Mobile portrait specific for history view */
@media (max-width: 768px) and (orientation: portrait) {
  /* The map is short here: the year shrinks to a corner badge and the slider panel sits under the
     map (buttons on one row, the slider on its own row below) instead of covering it */
  #historyMapContainer { height: auto !important; aspect-ratio: 1700 / 1020; }

  #historySliderContainer {
    position: static !important;
    transform: none !important;
    width: auto !important;
    margin: 8px;
    padding: 10px 14px 26px !important;
  }

  #historySliderContainer > div { flex-wrap: wrap; justify-content: space-between; gap: 10px !important; }
  #historySliderContainer > div > div { flex: 1 1 100% !important; order: 1; }

  #historyYearMarkers {
    font-size: 9px;
  }
}
/* Phones (portrait, or landscape where the map is short): the History year is a small corner badge */
@media (max-width: 768px) and (orientation: portrait), (orientation: landscape) and (max-height: 500px) {
  #historyYearDisplay {
    top: 6px;
    left: auto !important;
    right: 6px;
    transform: none !important;
    padding: 4px 10px !important;
    border-width: 1px !important;
  }

  #historyYearDisplay > div:first-child { font-size: 18px !important; }
  #historyYearDisplay > div:last-child { display: none; }
}

/* Popup info cards (info-cards.js): school conference history / conference members */
.info-card {
  position: absolute;
  z-index: 250;
  width: min(340px, calc(100% - 16px));
  max-height: min(540px, calc(100% - 16px));
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 10px 30px var(--shadow);
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
}
.info-card button { font: inherit; color: inherit; }

/* Panel docked beside a card (InfoCards aside option): the editor's Move to picker */
.info-card-aside {
  position: absolute;
  z-index: 250;
  width: 210px;
  max-height: min(540px, calc(100% - 16px));
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 10px 30px var(--shadow);
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
}
.info-card-aside button { font: inherit; color: inherit; }
.info-card-aside.dragging { box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); }
/* Title bar: drags the card and aside together; × closes only the aside */
.info-card-aside-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 6px 12px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.info-card-aside.dragging .info-card-aside-header { cursor: grabbing; }
.info-card-aside-title {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.info-card-aside-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
/* Phones in landscape: the map is too short for Move to under the card, so both narrow to fit side by side */
@media (orientation: landscape) and (max-height: 500px) {
  .info-card { width: min(300px, calc(100% - 16px)); }
  .info-card-aside { width: 190px; }
}
.move-picker { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.move-picker-search {
  margin: 0 10px 8px;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
}
.move-picker-search:focus { outline: none; border-color: var(--primary); }
.move-picker-list { overflow-y: auto; padding: 0 6px 8px; min-height: 0; flex: 1; }
.move-picker-group[hidden], .move-picker-item[hidden] { display: none; }
.move-picker-group + .move-picker-group { margin-top: 4px; }
.move-picker-tier {
  padding: 6px 6px 2px;
  font-size: 11px;
  color: var(--muted);
}
.move-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 6px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.move-picker-item:hover { background: var(--card-border); }
.move-picker-item.current { background: rgba(34, 211, 238, 0.12); cursor: default; }
.move-picker-item.current .move-picker-name::after { content: ' ✓'; color: var(--primary); }
.move-picker-swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.move-picker-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.move-picker-count { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.info-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 12px 0 14px;
  cursor: grab;
  touch-action: none; /* header drags the card */
  user-select: none;
}
.info-card.dragging { box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); }
.info-card-kind { cursor: grab; touch-action: none; user-select: none; }
.info-card.dragging .info-card-header, .info-card.dragging .info-card-kind { cursor: grabbing; }
.info-card-title {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 650;
  color: var(--heading);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-wrap: anywhere;
}
.info-card-swatch { flex: none; width: 12px; height: 12px; border-radius: 3px; }
.info-card-close, .info-card-back {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted) !important;
  font-size: 20px !important;
  line-height: 1;
  cursor: pointer;
}
.info-card-close:hover, .info-card-back:hover { background: var(--card-border); color: var(--heading) !important; }
.info-card-kind {
  padding: 0 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.info-card-place {
  text-transform: none;
  letter-spacing: normal;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.info-card-tabs {
  display: flex;
  gap: 4px;
  margin: 10px 14px 0;
  padding: 3px;
  background: var(--card-inset);
  border-radius: 7px;
}
.info-card-tab, .info-card-filter-btn {
  flex: 1;
  padding: 5px 8px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--muted) !important;
  font-size: 12px !important;
  cursor: pointer;
}
.info-card-tab.active, .info-card-filter-btn.active { background: var(--card-border); color: var(--heading) !important; }
.info-card-tab:disabled { opacity: 0.35; cursor: default; }
.info-card-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 10px 14px 12px;
}
.info-card-sub { color: var(--soft-text); margin-bottom: 8px; }
.info-card-sub strong { color: var(--heading); }
.info-card-filter { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 4px; }
.info-card-filter-btn { background: var(--card-inset); flex: 1 0 auto; padding: 5px 6px; white-space: nowrap; }

/* Timeline: conference blocks over the years, cyan tick at the season being viewed */
.info-card-bar {
  position: relative;
  height: 14px;
  background: var(--card-inset);
  border-radius: 3px;
  overflow: hidden;
}
.info-card-bar.thin { height: 5px; margin-top: 4px; border-radius: 2px; }
.info-card-bar.dim .info-card-bar-block { opacity: 0.45; }
.info-card-bar-block { position: absolute; top: 0; bottom: 0; }
.info-card-bar-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--primary);
}
.info-card-axis {
  display: flex;
  justify-content: space-between;
  margin: 3px 0 8px;
  font-size: 10px;
  color: var(--faint);
}

.info-card-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  margin-right: -6px;
  padding-right: 6px;
}
.info-card-list.compact { gap: 2px; }
.info-card-row, .info-card-member {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: var(--card-inset);
  cursor: pointer;
}
.info-card-row {
  padding: 7px 10px;
  border-left: 3px solid transparent;
  border-radius: 5px;
}
.info-card-member { padding: 6px 8px; border-radius: 5px; }
.info-card-row:hover, .info-card-member:hover { background: var(--card-hover); }
.info-card-row.current { box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.55); }
.info-card-member:not(.current) .info-card-row-name { color: var(--muted); }
.info-card-row-main { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.info-card-row-name { font-weight: 600; color: var(--heading); min-width: 0; }
.info-card-member .info-card-row-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-card-row-years { color: var(--muted); font-size: 12px; text-align: right; }
.info-card-member .info-card-row-years { flex: none; }
.info-card-stint { display: block; white-space: nowrap; } /* one line per stint */
.info-card-row .info-card-row-years { text-align: left; margin-top: 1px; }
.info-card-row-note { font-size: 11px; color: var(--faint); margin-top: 2px; }
.info-card-badge {
  flex: none;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--card-border);
  color: var(--soft-text);
  font-size: 10px;
  font-weight: 600;
}
.info-card-prov { color: #fbbf24; margin-left: 2px; }
.info-card-empty { color: var(--muted); padding: 8px 0; }
.info-card-foot { margin-top: 8px; font-size: 11px; color: var(--faint); }

/* Hover tooltip for school dots (editor and History maps) */
.map-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9500;
  max-width: 260px;
  pointer-events: none;
  background: var(--tooltip-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.map-tooltip[hidden] { display: none; }
.map-tooltip-title { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.map-tooltip-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.map-tooltip-sub { color: var(--muted); margin-top: 2px; }
.map-tooltip-place { color: var(--faint); margin-top: 2px; }

/* History play button */
#historyPlayBtn {
  min-width: 44px;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1;
}
#historyPlayBtn.playing { border-color: var(--primary); color: var(--primary); }

/* ---- Appearance: map mode / list mode (⚙ Settings; applyViewModes() in app.js) ---- */
/* Light / Dark selectors in the settings menus */
.mode-seg { flex: none; }
.mode-seg .seg-btn { padding: 4px 10px; font-size: 12px; cursor: pointer; }
#toolbar .mode-seg .seg-btn { height: 26px; padding: 0 10px; }
.mode-seg .seg-btn.active { background: var(--primary); color: var(--on-primary); font-weight: 600; }

/* Dark map: the page's navy behind the map, white state lines and labels */
body.map-dark #mapCanvas,
body.map-dark #historyCanvas,
body.map-dark #historyMapContainer { background: var(--map-navy); }
body.map-dark .map-bg { fill: var(--map-navy); }
body.map-dark #statesLayer path,
body.map-dark #historyStatesLayer path { stroke: rgba(255, 255, 255, 0.28); }
body.map-dark .point .label { fill: #cbd5e1; stroke: var(--map-navy); } /* softer than white: easier on the eyes */
body.map-dark #historyPointsLayer .label { fill: #cbd5e1; stroke: var(--map-navy); }
/* Thin light ring so dark conference colors (ACC navy, ...) stay visible on navy */
body.map-dark .point circle,
body.map-dark .history-point circle { stroke: rgba(255, 255, 255, 0.35); stroke-width: 1; }
body.map-dark .point.selected circle { stroke: #22d3ee; stroke-width: 3; }
body.map-dark .point.conference-selected circle,
body.map-dark .point.selected.conference-selected circle { stroke: #ffffff; stroke-width: 2; }
body.map-dark #mapWatermark { fill: #f8fafc; }
body.map-dark #mapWatermark .map-url { fill: #94a3b8; }
body.map-dark #coordinateTracker { fill: #94a3b8; }
/* Overlapping territories: multiply would vanish on navy */
body.map-dark #territoriesLayer path,
body.map-dark #historyTerritoriesLayer path { mix-blend-mode: screen !important; }

/* Light list view: the list's own color variables. They go on the list's content, not #listView itself,
   because the popup card and Move to are placed inside #listView and follow the interface mode */
body.list-light #listView { background: #f8fafc; }
body.list-light #listView > :not(.info-card, .info-card-aside) {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --muted: #64748b;
  --text: #0f172a;
  --border: #e2e8f0;
  --raised: #eef2f7;
  --primary: #0891b2;
  color: var(--text);
}
div.settings-row { cursor: default; }

/* Light interface (sidebar, toolbar, menus, cards, dialogs): the same variables, light values */
body.ui-light {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --muted: #64748b;
  --text: #0f172a;
  --primary: #0891b2;
  --danger: #dc2626;
  --border: #e2e8f0;
  --raised: #eef2f7;
  --card: #ffffff;
  --card-border: #e2e8f0;
  --card-inset: #f1f5f9;
  --card-hover: #f1f5f9;
  --heading: #0f172a;
  --soft-text: #334155;
  --faint: #64748b;
  --glass: rgba(255, 255, 255, 0.98);
  --tooltip-bg: rgba(255, 255, 255, 0.97);
  --shadow: rgba(15, 23, 42, 0.18);
  --on-primary: #ffffff;
  --scroll-thumb: #cbd5e1;
  --scroll-thumb-hover: #94a3b8;
  --scroll-thumb-active: #64748b;
}

/* Dark list view inside a light interface: the dark values again, just for the list (not its cards) */
body.list-dark #listView { background: #0b1220; }
body.list-dark #listView > :not(.info-card, .info-card-aside) {
  --bg: #0b1220;
  --panel: #0f172a;
  --panel-2: #0b1329;
  --muted: #94a3b8;
  --text: #e2e8f0;
  --primary: #22d3ee;
  --border: #1e293b;
  --raised: #1f2937;
  color: var(--text);
}

/* Logo: dark-background art (white outline / white "COLLEGE") or the originals in the light interface */
.logo-on-light { display: none; }
body.ui-light .logo-on-dark { display: none; }
body.ui-light .logo-on-light { display: inline; }

/* "Match system" switch row and the Light / Dark buttons it drives */
.mode-seg.following .seg-btn.active { opacity: 0.75; }

/* Sources & disclaimers: link at the foot of the sidebar / ⚙ menu, opens a scrollable dialog */
.sidebar-footer { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.link-btn { background: none; border: none; padding: 0; font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--text); }
#settingsMenu button.settings-link {
  display: block;
  padding: 7px 14px;
  font-size: 13px;
  width: 100%;
  margin-top: 4px;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: none;
  text-align: left;
  color: var(--muted);
}
#settingsMenu button.settings-link:hover { color: var(--text); }
.doc-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.7);
}
.doc-overlay[hidden] { display: none; }
.doc-panel {
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: calc(100dvh - 32px);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--text);
}
.doc-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 8px; }
.doc-header h2 { margin: 0; font-size: 18px; color: var(--heading); }
button.doc-close { background: none; border: none; padding: 0 4px; font-size: 24px; line-height: 1; color: var(--muted); }
button.doc-close:hover { color: var(--text); }
.doc-body { overflow-y: auto; padding: 0 20px 16px; font-size: 13px; line-height: 1.5; color: var(--soft-text); }
.doc-body h3 { margin: 14px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.doc-body ul { margin: 0; padding-left: 18px; }
.doc-body li + li { margin-top: 6px; }
.doc-body a { color: var(--primary); }

/* No popup cards on phones for now (InfoCards skips them), so their switches are hidden too */
@media (max-width: 768px) and (orientation: portrait), (orientation: landscape) and (max-height: 500px) {
  .card-setting { display: none !important; }
}
.doc-body p { margin: 0 0 4px; }
.doc-body b { color: var(--text); font-weight: 600; }
.doc-body p.doc-feedback { margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; background: var(--card-inset); color: var(--text); }
/* Feedback line at the bottom of the ⚙ menu: one line, the menu widens to fit */
a.settings-feedback { display: block; padding: 7px 14px; font-size: 13px; color: var(--muted); text-decoration: none; white-space: nowrap; }
a.settings-feedback:hover { color: var(--text); }
a.feedback-row .mobile-dropdown-item-label { white-space: nowrap; }
a.mobile-dropdown-item { text-decoration: none; }
