/* Enhanced GPS Studio Styles - Dark Theme with BCC Red */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;850&display=swap');

:root {
  /* BCC red brand colors */
  --brand-h: 354; --brand-s: 86%; --brand-l: 54%;          /* BCC red */
  --brand: hsl(var(--brand-h) var(--brand-s) var(--brand-l));
  --brand-600: hsl(var(--brand-h) var(--brand-s) calc(var(--brand-l) - 8%));
  --brand-700: hsl(var(--brand-h) var(--brand-s) calc(var(--brand-l) - 14%));

  /* dark neutrals */
  --bg:    hsl(222 18% 8%);     /* page */
  --surface:hsl(222 18% 12%);    /* cards/sections */
  --text:  hsl(0 0% 98%);
  --muted: hsl(220 10% 66%);
  --line:  hsl(220 12% 20%);

  --radius: 12px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.35);
  --shadow-2: 0 10px 40px rgba(0,0,0,.45);
}

/* Light theme variant */
[data-theme="light"] {
  --bg: hsl(0 0% 100%);
  --surface: hsl(0 0% 100%);
  --text: hsl(222 24% 12%);
  --muted: hsl(222 10% 40%);
  --line: hsl(220 10% 88%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    /* Procedural dots background */
    background:
        radial-gradient(hsl(0 0% 100% / .06) 1px, transparent 1px) 0 0 / 22px 22px,
        radial-gradient(hsl(0 0% 100% / .03) 1px, transparent 1px) 11px 11px / 22px 22px,
        var(--bg);
}

/* Authentication Styles */
#auth-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg) 0%, hsl(222 18% 10%) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#auth-container h2 {
    margin-bottom: 20px;
    color: var(--text);
    font-size: 1.8rem;
    font-weight: 600;
}

#login-form {
    display: flex;
    flex-direction: column;
    width: 300px;
    gap: 15px;
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    border: 1px solid var(--line);
}

#login-form input {
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: hsl(222 18% 10%);
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#login-form input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px hsl(var(--brand-h) var(--brand-s) / .1);
}

#login-button, #logout-button {
    padding: 12px 20px;
    background: var(--brand);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background-color 0.2s ease;
}

#login-button:hover, #logout-button:hover {
    background: var(--brand-600);
}

.error-message {
    color: #ff6b6b;
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
}

#user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    border: 1px solid var(--line);
}

#app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header */
#app-header {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(1200px 600px at 80% -10%, hsl(var(--brand-h) var(--brand-s) / .18), transparent 60%),
        var(--surface);
    color: var(--text);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-2);
    z-index: 1000;
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0;
}

#app-header h1 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 850;
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
    line-height: .95;
    letter-spacing: -.01em;
    margin: 0;
}

#header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Mode Toggle Styles */
#mode-toggle-container {
    display: flex;
    align-items: center;
}

.mode-toggle-label {
    font-weight: 600;
    margin-right: 10px;
    font-size: 0.9em;
    color: var(--text);
}

.mode-toggle {
    display: flex;
    background-color: hsl(220 12% 20%);
    border-radius: 20px;
    padding: 3px;
    position: relative;
    overflow: hidden;
}

.mode-toggle input[type="radio"] {
    display: none;
}

.mode-toggle label {
    padding: 6px 16px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    border-radius: 20px;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
    margin: 0;
    width: auto;
    color: var(--muted);
}

.mode-toggle input[type="radio"]:checked + label {
    color: white;
    background-color: var(--brand);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Compact Apple-like segmented control for small toggles */
.mode-toggle-small {
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  background: hsl(220 12% 16%);
  padding: 4px;
}
.mode-toggle-small label {
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--muted);
}
.mode-toggle-small input[type="radio"]:checked + label {
  background: var(--brand);
  color: #fff;
}
.mode-toggle-small label:hover {
  background: hsl(220 12% 22%);
  color: var(--text);
}

/* iOS-style toggle with side labels */
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.switch-label {
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}
.switch-label.active {
  color: var(--text);
}
.ios-switch {
  position: relative;
  display: inline-block;
  width: 54px;
  height: 30px;
}
.ios-switch input { /* hide native checkbox */
  opacity: 0;
  width: 0;
  height: 0;
}
.ios-slider {
  position: absolute;
  inset: 0;
  background: hsl(220 12% 25%);
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s ease;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.35);
}
.ios-slider::before {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  transition: transform .2s ease;
}
.ios-switch input:checked + .ios-slider {
  background: var(--brand);
}
.ios-switch input:checked + .ios-slider::before {
  transform: translateX(24px);
}

/* Compact/small variant for headers */
.ios-switch.sm { width: 44px; height: 24px; }
.ios-switch.sm .ios-slider { border-radius: 999px; }
.ios-switch.sm .ios-slider::before { width: 18px; height: 18px; top: 3px; left: 3px; }
.ios-switch.sm input:checked + .ios-slider::before { transform: translateX(20px); }

/* Main Content */
#main-content {
    height: calc(100vh - 80px - 300px - 60px); /* viewport - header - dashboard - footer */
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Left Panel - Athletes */
#athlete-panel {
    width: 400px;
    min-width: 300px;
    max-width: 600px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-1);
    position: relative;
    resize: horizontal;
    overflow: hidden;
}

/* Resize handle for left panel */
#athlete-panel::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: transparent;
    cursor: ew-resize;
    z-index: 10;
}

#athlete-panel:hover::after {
    background: var(--brand);
    opacity: 0.3;
}

/* Form Sections */
.form-section {
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow-1);
    position: relative;
}

.form-section.collapsed {
    min-height: 0 !important;
    height: auto !important;
    overflow: hidden;
}
.form-section.collapsed .section-content {
    display: none !important;
    padding: 0 !important;
    margin: 0 !important;
    height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
}

.section-header {
    position: relative;
    overflow: visible;
    background:
        radial-gradient(800px 400px at 50% -20%, hsl(var(--brand-h) var(--brand-s) / .08), transparent 50%),
        hsl(222 18% 14%);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
    transition: all 0.2s ease;
}

.section-header:hover {
    background:
        radial-gradient(800px 400px at 50% -20%, hsl(var(--brand-h) var(--brand-s) / .12), transparent 50%),
        hsl(222 18% 16%);
}

.section-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    margin-right: 0.5rem; /* small space before switch */
}

/* Styles for the new points countdown display */
.header-points-display {
    display: none; /* Hidden by default, shown by JS when data is available */
    align-items: center;
    gap: 10px;
    margin-left: 15px; /* Space from the "Athletes" title */
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    background-color: hsl(222 18% 10%);
    padding: 5px 10px;
    border-radius: 15px;
    border: 1px solid var(--line);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

.header-points-display span {
    display: flex;
    align-items: center;
    gap: 5px;
}

#male-points-countdown,
#female-points-countdown {
    color: var(--brand); /* Use brand color for emphasis */
    font-weight: 800;
    letter-spacing: 0.5px;
}

/* Header Actions Container */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto; /* push actions to the far right */
}

/* small spacing to keep titles readable when a header switch is present */
.section-header .ios-switch.sm { margin-left: 8px; }

/* Split button + dropdown styles */
.btn-group-split { position: relative; display: inline-flex; align-items: center; }
.btn-caret { padding: 0.375rem 0.55rem; border-left: 1px solid hsl(0 0% 100% / .2); }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: hsl(222 18% 12%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-2);
  padding: 6px;
  min-width: 120px;
  z-index: 1000;
  display: none;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.dropdown-item:hover { background: hsl(222 18% 16%); }

.hidden-action { display: none !important; }

.collapse-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--muted);
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.collapse-btn:hover {
    background: hsl(220 12% 25%);
    color: var(--text);
}

.section-content {
    padding: 1rem;
    overflow-y: auto;
    flex-shrink: 0;
}

/* Fixed heights for specific sections */
#athletes-content {
    height: 400px;
    max-height: 400px;
}

#quick-settings-content {
    height: 280px;
    max-height: 280px;
}

/* Ensure legend has proper scrolling */
#legend {
    max-height: none;
    overflow-y: auto;
    flex: 1;
}

/* Form Groups */
.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 0.875rem;
    background: hsl(222 18% 10%);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px hsl(var(--brand-h) var(--brand-s) / .1);
}

.form-group small {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
}

/* Checkbox Groups */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-direction: row;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.checkbox-group label {
    margin: 0;
    font-weight: normal;
    cursor: pointer;
}

/* Chip-style checkbox (opt-in) */
.checkbox-group.chip {
  position: relative;
  align-items: center;
}
.checkbox-group.chip input[type="checkbox"] {
  /* keep accessible but visually hidden */
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.checkbox-group.chip label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: hsl(222 18% 12%);
  color: var(--text);
  font-weight: 600;
  line-height: 1;
  min-height: 28px; /* normalize chip height */
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, color .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.checkbox-group.chip label::before {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid hsl(0 0% 100% / .35);
  background: transparent;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.checkbox-group.chip input[type="checkbox"]:checked + label {
  background: hsl(var(--brand-h) var(--brand-s) / .12);
  border-color: var(--brand);
  color: var(--text);
  box-shadow: inset 0 0 0 1px hsl(var(--brand-h) var(--brand-s) / .35);
}
.checkbox-group.chip input[type="checkbox"]:checked + label::before {
  background: var(--brand);
  border-color: var(--brand);
}
.checkbox-group.chip input[type="checkbox"]:focus { outline: none !important; }
.checkbox-group.chip input[type="checkbox"]:focus-visible + label {
  /* Compact focus treatment: no layout shift */
  box-shadow: 0 0 0 2px hsl(var(--brand-h) var(--brand-s) / .5);
}
.checkbox-group.chip input[type="checkbox"]:checked:focus-visible + label {
  /* Maintain the inner accent when checked */
  box-shadow: 0 0 0 2px hsl(var(--brand-h) var(--brand-s) / .55),
              inset 0 0 0 1px hsl(var(--brand-h) var(--brand-s) / .35);
}
.checkbox-group.chip.compact label {
  padding: 6px 12px; /* keep vertical rhythm consistent */
  font-weight: 600;
  font-size: 0.85rem;
  min-height: 28px;
}

/* Layout helper for multiple chip checkboxes */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  width: 100%; /* ensure each chips row occupies full width */
}
.chips + .chips { margin-top: 6px; }

/* Console styles */
.console-output {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: hsl(222 18% 10%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  min-height: 200px;
  max-height: 100%;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.35;
}
.console-output:empty::before {
  content: 'Console output will appear here.';
  color: var(--muted);
}
.console-output.is-active::before {
  content: '';
}
.console-output.is-active {
  background: hsl(222 18% 8%);
}
.console-output.is-error {
  border-color: hsl(0 80% 60%);
}
.console-output.is-warn {
  border-color: hsl(40 90% 60%);
}
.console-output.is-info {
  border-color: var(--brand);
}

/* Ensure console tab fills its container */
#console-tab {
  padding: 1rem;
}

#console-tab .dashboard-section {
  flex: 1 1 auto;
}

#console-tab .form-section {
  margin-bottom: 0;
  min-height: 0;
  max-height: none;
}

#console-tab .form-section .section-content {
  display: flex;
  flex: 1 1 auto;
  max-height: none;
}

#console-tab #app-console {
  flex: 1 1 auto;
  min-height: 0;
}
.console-line { margin: 0 0 6px 0; color: var(--text); }
.console-line .ts { color: var(--muted); margin-right: 8px; }
.console-line.status { color: hsl(210 10% 75%); }
.console-line.info { color: var(--text); }
.console-line.warn { color: hsl(40 90% 60%); }
.console-line.error { color: hsl(0 80% 70%); }
.console-line .source { color: var(--muted); margin-right: 6px; }

/* Make chips rows ignore default form-group spacing */
.chips > .form-group { margin-bottom: 0; }

/* Circular dual-state icon toggle (demo + reusable) */
.icon-toggles { display: flex; align-items: center; gap: 10px; }
.icon-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, hsl(222 18% 18%), hsl(222 18% 12%));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 4px 10px rgba(0,0,0,.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: box-shadow .2s ease, transform .05s ease, background .2s ease, border-color .2s ease;
}
.icon-toggle { color: hsl(0 0% 100% / .65); }
.icon-toggle svg { width: 18px; height: 18px; fill: currentColor; }
.icon-toggle[aria-pressed="true"] {
  background: radial-gradient(circle at 35% 30%, hsl(var(--brand-h) var(--brand-s) / .35), transparent 55%),
              linear-gradient(180deg, hsl(222 18% 16%), hsl(222 18% 10%));
  border-color: hsl(var(--brand-h) var(--brand-s) / .55);
  box-shadow: inset 0 0 0 1px hsl(var(--brand-h) var(--brand-s) / .35), 0 6px 16px rgba(0,0,0,.45);
}
.icon-toggle[aria-pressed="true"] { color: var(--brand); }
.icon-toggle:active { transform: translateY(1px); }
.icon-toggle:focus-visible { outline: none; box-shadow: 0 0 0 2px hsl(var(--brand-h) var(--brand-s) / .5), 0 4px 10px rgba(0,0,0,.35); }
.icon-toggle-demo small.help-text { color: var(--muted); }

/* Buttons */
.btn {
    position: relative;
    isolation: isolate;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1.1rem;
    border-radius: 999px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid hsl(0 0% 100% / .08);
    background: hsl(222 18% 14%);
    color: var(--text);
    box-shadow: var(--shadow-1);
    transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
    cursor: pointer;
    font-size: 0.875rem;
}

/* Primary button - White hollow */
.btn-primary {
    background: transparent;
    color: var(--text);
    border: 1px solid hsl(0 0% 100% / .3);
}

.btn-primary:hover {
    background: hsl(0 0% 100% / .1);
    border-color: hsl(0 0% 100% / .5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Secondary buttons - Red glow emanating from behind */
.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid hsl(var(--brand-h) var(--brand-s) / .2);
    position: relative;
    z-index: 1;
}

.btn-secondary::before {
    content: "";
    position: absolute;
    inset: -40% -25%;
    background: radial-gradient(closest-side, var(--brand) 0%, transparent 70%);
    filter: blur(18px);
    opacity: .55;
    z-index: -1;
    transition: opacity .2s, transform .2s;
}

.btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 40px hsl(var(--brand-h) var(--brand-s) / .15);
    border-color: hsl(var(--brand-h) var(--brand-s) / .4);
}

.btn-secondary:hover::before {
    opacity: .8;
    transform: scale(1.04);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* Outline button - White hollow */
.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid hsl(0 0% 100% / .3);
}

.btn-outline:hover {
    background: hsl(0 0% 100% / .1);
    border-color: hsl(0 0% 100% / .5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.btn-outline:active {
    transform: translateY(0);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--line);
    background: hsl(222 18% 14%);
    margin: 0 -1rem -1rem -1rem;
}

.form-actions .btn {
    flex: 1;
}

/* Section Actions - Individual trigger buttons */
.section-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.section-actions .btn {
    min-width: 0;
}

/* Streaming Control Layout */
#streaming-main {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.control-columns {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 1.5rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.control-left,
.control-right {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (max-width: 1100px) {
    .control-columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    #streaming-main {
        padding: 1.5rem 1rem;
    }
}

.control-card-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background:
        radial-gradient(900px 500px at 10% -40%, hsl(var(--brand-h) var(--brand-s) / .12), transparent 60%),
        linear-gradient(160deg, hsl(222 18% 16%), hsl(222 18% 12%));
}

.control-card-content .form-actions {
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    justify-content: flex-end;
}

.control-card-content .form-actions .btn {
    flex: 0 0 auto;
}

#vm-status-card .section-header h3,
#create-session-form .section-header h3,
#sessions-container .section-header h3 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 3px hsl(0 0% 100% / .06);
}

.status-running { background-color: #4caf50; }
.status-stopped { background-color: #f44336; }
.status-starting { background-color: #ff9800; }
.status-unknown { background-color: #777; }

.vm-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.stacked-text {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.grid-detail {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.grid-detail p {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.grid-detail p strong {
    min-width: 140px;
    font-weight: 600;
    color: var(--text);
}

.cost-info {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-1);
    background:
        radial-gradient(1200px 600px at 90% 0%, hsl(var(--brand-h) var(--brand-s) / .18), transparent 65%),
        hsl(222 18% 14%);
    color: var(--muted);
    font-size: 0.9rem;
}

.cost-info strong {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text);
    font-size: 1rem;
}

.cost-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem 1rem;
}

.cost-grid span:nth-child(odd) {
    color: var(--muted);
    font-weight: 500;
}

.cost-grid span:nth-child(even) {
    text-align: right;
    color: var(--text);
    font-weight: 600;
}

#current-cost::before,
#hourly-rate::before,
#monthly-cost::before {
    content: '$';
    margin-right: 0.1rem;
    color: inherit;
}

.status-banner {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: hsl(var(--brand-h) var(--brand-s) / .12);
    color: var(--text);
    font-size: 0.85rem;
    box-shadow: inset 0 0 0 1px hsl(0 0% 100% / .04);
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1 1 220px;
}

.sessions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.session-card {
    position: relative;
    isolation: isolate;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
    background:
        radial-gradient(1000px 600px at 100% 0%, hsl(var(--brand-h) var(--brand-s) / .2), transparent 65%),
        hsl(222 18% 14%);
    box-shadow: var(--shadow-1);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.session-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.session-type {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    background: hsl(var(--brand-h) var(--brand-s) / .2);
    color: var(--text);
    text-transform: uppercase;
}

.session-info {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.session-info strong {
    color: var(--text);
    font-weight: 600;
}

.session-actions {
    display: flex;
    gap: 0.5rem;
}

.session-actions .btn {
    flex: 1;
    justify-content: center;
}

.empty-state {
    padding: 2.5rem 1.25rem;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: hsl(222 18% 12%);
}

.logs-container {
    background: hsl(222 18% 10%);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1rem;
    font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text);
    max-height: 320px;
    overflow-y: auto;
}

.hls-player {
    width: 100%;
    max-width: 640px;
    aspect-ratio: 16 / 9;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #000;
}

#app-container .error-message,
#app-container .success-message,
#app-container .info-message {
    margin: 0;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-1);
    font-size: 0.85rem;
}

#app-container .error-message {
    background: hsl(0 74% 28% / .35);
    color: hsl(0 70% 85%);
    border-color: hsl(0 70% 46% / .4);
}

#app-container .success-message {
    background: hsl(146 70% 24% / .35);
    color: hsl(146 60% 80%);
    border-color: hsl(146 60% 45% / .45);
}

#app-container .info-message {
    background: hsl(204 70% 32% / .35);
    color: hsl(204 70% 80%);
    border-color: hsl(204 70% 45% / .45);
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.mode-link {
    color: inherit;
    text-decoration: none;
}

.mode-link:hover {
    text-decoration: none;
}

/* Athletes Section Specific Styles */
#legend-sort-controls {
    margin-bottom: 8px;
    font-size: 0.9em;
    text-align: center;
    color: var(--text);
}

#legend-sort-controls button {
    padding: 5px 10px;
    margin: 0 3px;
    cursor: pointer;
    border: 1px solid var(--line);
    border-radius: 4px;
    background-color: hsl(222 18% 14%);
    color: var(--muted);
    font-size: 0.85em;
    transition: all 0.2s ease;
}

#legend-sort-controls button:hover {
    background-color: hsl(222 18% 18%);
    border-color: var(--muted);
}

#legend-sort-controls button.active {
    background-color: var(--brand);
    color: white;
    border-color: var(--brand);
}

#legend-filter-controls {
    margin-bottom: 10px;
    font-size: 0.9em;
    text-align: center;
    color: var(--text);
}

.filter-select {
    padding: 5px 8px;
    margin: 0 3px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background-color: hsl(222 18% 10%);
    color: var(--text);
    font-size: 0.85em;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.filter-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px hsl(var(--brand-h) var(--brand-s) / .2);
    outline: none;
}

#legend-search-controls {
    margin-bottom: 10px;
    text-align: center;
}

.search-input {
    padding: 6px 10px;
    width: 90%;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 0.9em;
    background-color: hsl(222 18% 10%);
    color: var(--text);
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.search-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px hsl(var(--brand-h) var(--brand-s) / .2);
    outline: none;
}

/* Legend Items */
#legend {
    overflow-y: auto;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px;
    border-bottom: 1px solid var(--line);
    position: relative;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    cursor: move;
}

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

.legend-item:hover {
    background-color: hsl(222 18% 16%);
}

.legend-item.focused {
    background-color: hsl(var(--brand-h) var(--brand-s) / .15);
    border-left: 4px solid var(--brand);
    padding-left: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.legend-item.focused:hover {
    background-color: hsl(var(--brand-h) var(--brand-s) / .2);
}

.drag-handle {
    margin-right: 8px;
    color: var(--muted);
    cursor: grab;
    font-size: 1.2em;
    flex-shrink: 0;
    user-select: none;
}

.drag-handle:hover {
    color: var(--text);
}

.drag-handle:active {
    cursor: grabbing;
}

.legend-color {
    width: 16px;
    height: 16px;
    border: 1px solid var(--line);
    margin-right: 10px;
    flex-shrink: 0;
    border-radius: 3px;
}

.legend-color.cap-color {
    border: 2px solid var(--text);
    box-shadow: 0 0 0 1px var(--bg);
}

.legend-headshot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background-color: hsl(222 18% 20%);
    border: 1px solid var(--line);
}

.legend-details {
    display: flex;
    flex-direction: column;
    font-size: 0.85em;
    line-height: 1.4;
    flex-grow: 1;
    min-width: 0;
    margin-right: 30px;
}

.legend-info {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    margin-bottom: 2px;
}

.legend-distances {
    color: var(--muted);
    font-size: 0.9em;
    line-height: 1.3;
}

.focus-toggle-button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    color: var(--muted);
    transition: color 0.2s;
}

.focus-toggle-button:hover {
    color: var(--text);
}

/* Map Panel */
#map-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

#map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
}

/* Bottom Dashboard */
#dashboard-container {
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    height: 300px;
    min-height: 200px;
    max-height: 500px;
    resize: vertical;
    overflow: hidden;
    position: fixed;
    bottom: 60px; /* Above the status footer - reduced from 150px */
    left: 0;
    right: 0;
    z-index: 100;
}

/* Resize handle for bottom dashboard */
#dashboard-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: transparent;
    cursor: ns-resize;
    z-index: 10;
}

#dashboard-container:hover::before {
    background: var(--brand);
    opacity: 0.3;
}

/* Collapsed dashboard shows only headers; height is controlled by JS */
#dashboard-container.is-collapsed #dashboard-content .form-section .section-content {
    display: none !important;
}
#dashboard-container.is-collapsed #dashboard-content {
    overflow: hidden;
}
#dashboard-container.is-collapsed #dashboard-content .form-section {
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    align-self: flex-start !important;
    flex: 1 1 0% !important;
}

/* Settings Overlay */
.settings-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 84px 32px 120px;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1400;
}

.settings-overlay.open {
    display: flex;
}

.settings-overlay[aria-hidden="true"] {
    pointer-events: none;
}

.settings-overlay.open[aria-hidden="false"] {
    pointer-events: auto;
}

.settings-panel {
    width: min(420px, 92vw);
    max-height: calc(100vh - 168px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-2);
    display: flex;
    flex-direction: column;
}

.settings-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem 0.75rem;
}

.settings-panel-header h2 {
    font-size: 1.2rem;
    margin: 0;
}

.icon-button {
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 999px;
    transition: background 0.2s ease, color 0.2s ease;
}

.icon-button:hover,
.icon-button:focus-visible {
    color: var(--brand);
    background: hsl(222 18% 18%);
    outline: none;
}

.settings-panel-body {
    padding: 0 1.5rem 1.75rem;
    overflow-y: auto;
}

.settings-panel-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.settings-panel-section:last-of-type {
    margin-bottom: 0;
}

.settings-panel-section label {
    font-weight: 600;
    font-size: 0.85rem;
}

.settings-panel-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

#preset-name-input {
    flex: 1;
    min-width: 0;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: hsl(222 18% 10%);
    color: var(--text);
}

#preset-name-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px hsl(var(--brand-h) var(--brand-s) / 0.25);
}

.settings-panel-hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0;
}

.settings-panel-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.settings-empty {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.settings-presets-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.settings-presets-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: hsl(222 18% 10%);
}

.settings-presets-list li.is-active {
    border-color: hsl(var(--brand-h) var(--brand-s) / 0.6);
    box-shadow: 0 0 0 1px hsl(var(--brand-h) var(--brand-s) / 0.3);
}

.settings-presets-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.settings-presets-name {
    font-weight: 600;
    font-size: 0.9rem;
    word-break: break-word;
}

.settings-presets-meta {
    font-size: 0.75rem;
    color: var(--muted);
}

.settings-presets-controls {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.settings-presets-controls .btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.75rem;
    border-radius: 20px;
}

.settings-presets-controls .btn-danger {
    background: transparent;
    color: #ff6b6b;
    border: 1px solid rgba(255, 107, 107, 0.5);
}

.settings-presets-controls .btn-danger:hover {
    background: rgba(255, 107, 107, 0.12);
}

#dashboard-tabs {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: hsl(222 18% 14%);
    border-bottom: 1px solid var(--line);
    padding: 0 1rem;
    overflow-x: auto;
}

#dashboard-tabs-left {
    display: flex;
    overflow-x: auto;
}

#dashboard-tabs-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

#permission-mode-toggle-container {
    display: flex;
    align-items: center;
}

.dashboard-toggle-btn {
    background: none;
    border: 1px solid var(--line);
    color: var(--muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 1.2rem;
    font-weight: bold;
}

.dashboard-toggle-btn:hover {
    background: hsl(220 12% 25%);
    color: var(--text);
    border-color: var(--muted);
}

.dashboard-toggle-btn:active {
    transform: scale(0.95);
}

.dashboard-tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.dashboard-tab:hover {
    color: var(--text);
    background: hsl(222 18% 16%);
}

.dashboard-tab.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    background: hsl(222 18% 16%);
}

#dashboard-content {
    height: calc(100% - 60px); /* Account for tabs height */
    overflow-y: auto; /* Changed from hidden to auto */
    overflow-x: hidden; /* Added to prevent horizontal scrolling */
    background: var(--surface);
    display: flex;
    flex-direction: column;
}

.dashboard-pane {
    display: none;
    padding: 1rem;
    flex: 1;
    overflow: hidden;
}

.dashboard-pane.active {
    display: flex;
    flex-direction: column;
}

.dashboard-section {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    flex: 1;
    overflow: hidden;
    align-items: flex-start; /* allow collapsed cards to be header-height */
}

.dashboard-section .form-section {
    flex: 1 1 auto;
    min-width: 300px;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 200px; /* Ensure minimum usable height */
    max-height: calc(100% - 40px); /* Leave room for scrolling and margins */
}

/* Remove min-height when a single section is collapsed */
.dashboard-section .form-section.collapsed {
    min-height: 0 !important;
    max-height: none !important;
    flex: 0 0 auto !important; /* shrink to header height */
}

/* Make dashboard sections flexible and responsive */
.dashboard-pane .form-section .section-content {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 150px; /* Minimum content height */
    max-height: calc(100% - 60px); /* Account for header height */
}

/* Collapsed content should not reserve space */
.dashboard-pane .form-section.collapsed .section-content {
    min-height: 0 !important;
    max-height: 0 !important;
}

/* Special handling for sections with many parameters */
.dashboard-pane .form-section {
    /* Removed max-height to allow content to expand and rely on parent scrolling */
}

/* Status Display - Fixed Footer */
#status-display {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface); /* Changed to surface for consistency */
    border-top: 1px solid var(--line);
    font-size: 0.85em;
    color: var(--muted);
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease-out; /* For dismiss animation */
}

#status-display.dismissed {
    transform: translateY(100%); /* Move off-screen when dismissed */
}

#status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: hsl(222 18% 14%); /* Darker header for distinction */
    border-bottom: 1px solid var(--line);
}

#status {
    margin: 0; /* Remove default margin */
    font-weight: 600;
    color: var(--text);
}

.dismiss-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
    transition: color 0.2s;
}

.dismiss-btn:hover {
    color: var(--brand);
}

#status-content {
    padding: 0.5rem 1rem;
    max-height: 150px; /* Max height for scrollable content */
    overflow-y: auto;
}

#controller-response-container {
    margin-top: 10px;
    padding: 10px;
    background: hsl(222 18% 12%); /* Consistent with --surface */
    border: 1px solid var(--line);
    border-radius: 4px;
    max-height: 200px; /* Allow it to grow if needed, but with a max */
    overflow-y: auto;
}

.controller-response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px; /* Space between header and pre tag */
}

#controller-response {
    background: hsl(222 18% 10%); /* Slightly darker for code block */
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.5rem;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 100px;
    overflow-y: auto;
}

/* Viewer/Operator Mode Styles */
body.viewer-mode .operator-only {
    display: none !important;
}

/* Hide tabs/panes marked viewer-hidden when in Viewer mode */
body.viewer-mode .dashboard-tab.viewer-hidden,
body.viewer-mode .dashboard-pane.viewer-hidden {
    display: none !important;
}

/* Custom Scrollbars */
#athlete-panel::-webkit-scrollbar,
#dashboard-content::-webkit-scrollbar,
#legend::-webkit-scrollbar,
#status-display::-webkit-scrollbar,
#controller-response::-webkit-scrollbar,
.section-content::-webkit-scrollbar {
    width: 6px;
}

#athlete-panel::-webkit-scrollbar-track,
#dashboard-content::-webkit-scrollbar-track,
#legend::-webkit-scrollbar-track,
#status-display::-webkit-scrollbar-track,
#controller-response::-webkit-scrollbar-track,
.section-content::-webkit-scrollbar-track {
    background: var(--surface);
}

#athlete-panel::-webkit-scrollbar-thumb,
#dashboard-content::-webkit-scrollbar-thumb,
#legend::-webkit-scrollbar-thumb,
#status-display::-webkit-scrollbar-thumb,
#controller-response::-webkit-scrollbar-thumb,
.section-content::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 3px;
}

#athlete-panel::-webkit-scrollbar-thumb:hover,
#dashboard-content::-webkit-scrollbar-thumb:hover,
#legend::-webkit-scrollbar-thumb:hover,
#status-display::-webkit-scrollbar-thumb:hover,
#controller-response::-webkit-scrollbar-thumb:hover,
.section-content::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--surface);
    margin: auto;
    padding: 2rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    width: 80%;
    max-width: 400px;
    box-shadow: var(--shadow-2);
    display: flex;
    flex-direction: column;
    gap: 15px;
    text-align: center;
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--text);
    font-size: 1.2em;
}

.modal-content input[type="email"],
.modal-content input[type="text"],
.modal-content select {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: hsl(222 18% 10%);
    color: var(--text);
    width: 100%;
    box-sizing: border-box;
}

.modal-content button {
    padding: 10px 15px;
    background-color: var(--brand);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

.modal-content button:hover {
    background-color: var(--brand-600);
}

.modal-content .secondary-button {
    background-color: hsl(220 10% 40%);
}

.modal-content .secondary-button:hover {
    background-color: hsl(220 10% 35%);
}

.message {
    margin-top: 10px;
    font-size: 0.9em;
    font-weight: 500;
}

/* Custom Collection Container */
#custom-collection-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

#custom-collection-container label {
    flex-shrink: 0;
    font-size: 0.875rem;
}

#custom-collection-container input[type="text"] {
    flex-grow: 1;
}

/* Responsive Design */
@media (max-width: 1024px) {
    #main-content {
        flex-direction: column;
    }
    
    #athlete-panel {
        width: 100%;
        max-height: 50vh;
    }
    
    #map-panel {
        min-height: 50vh;
    }
    
    #dashboard-container {
        order: -1;
    }

    .settings-overlay {
        justify-content: center;
        padding: 72px 24px 96px;
    }
}

@media (max-width: 768px) {
    #app-header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    #app-header h1 {
        font-size: 1.25rem;
    }
    
    #header-controls {
        gap: 0.5rem;
    }
    
    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }
    
    #athlete-panel {
        max-height: 60vh;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .dashboard-section {
        flex-direction: column;
    }
    
    .dashboard-section .form-section {
        min-width: auto;
    }
    
    #dashboard-tabs {
        padding: 0 0.5rem;
    }
    
    .dashboard-tab {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .settings-panel {
        width: min(480px, 100%);
        border-radius: 14px;
    }

    .settings-overlay {
        padding: 64px 16px 90px;
    }

    .settings-panel-section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    #delete-all-presets-button {
        align-self: flex-start;
    }
}

/* Focus states for accessibility */
.collapse-btn:focus,
.btn:focus,
input:focus,
select:focus {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* Animation for smooth transitions */
.section-content {
    transition: all 0.3s ease;
}

.form-section {
    transition: all 0.2s ease;
}

/* Drag and drop styles */
.legend-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.legend-item.drag-over {
    border-top: 3px solid var(--brand);
    background-color: hsl(var(--brand-h) var(--brand-s) / .1);
}

.legend-item.drag-disabled {
    cursor: default;
}

.legend-item.drag-disabled .drag-handle {
    color: var(--line);
    cursor: not-allowed;
}

/* Animations */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Print styles */
@media print {
    #app-header,
    #athlete-panel,
    #dashboard-container,
    #status-display {
        display: none;
    }

    #map-panel {
        width: 100%;
        height: 100vh;
    }
}
