/**
 * Design System Component Styles
 *
 * Styles for the base component library (Phase 2).
 * All values reference semantic tokens from tokens.css.
 * Components are in /js/components/base/.
 */

/* ============================================================
 * Accessibility: Visually Hidden
 * ============================================================ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-to-content {
  position: fixed;
  top: -100%;
  left: var(--space-4);
  z-index: var(--z-tooltip);
  padding: var(--space-2) var(--space-4);
  background: var(--primary);
  color: var(--text-on-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: top var(--transition-fast);
}

.skip-to-content:focus {
  top: var(--space-4);
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ============================================================
 * BaseButton
 * ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-weight: var(--font-medium);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Sizes */
.btn--sm {
  height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
}

.btn--md {
  height: 40px;
  padding: 0 var(--space-4);
  font-size: var(--text-base);
  border-radius: var(--radius-md);
}

.btn--lg {
  height: 48px;
  padding: 0 var(--space-6);
  font-size: var(--text-md);
  border-radius: var(--radius-md);
}

.btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn--icon.btn--sm { width: 32px; height: 32px; }
.btn--icon.btn--lg { width: 48px; height: 48px; }

/* Variants */
.btn--primary {
  background: var(--primary);
  color: var(--text-on-primary);
  border-color: var(--primary);
}

.btn--primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: var(--shadow-glow-cyan);
}

.btn--secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--border-strong);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn--danger:hover:not(:disabled) {
  background: var(--p-red-600);
  border-color: var(--p-red-600);
  box-shadow: var(--shadow-glow-red);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn--ghost:hover:not(:disabled) {
  background: var(--surface-alt);
  color: var(--text);
}

/* ============================================================
 * BaseInput
 * ============================================================ */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.input-label {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
}

.input-label--required::after {
  content: ' *';
  color: var(--danger);
}

.input-field {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.input-field::placeholder {
  color: var(--text-muted);
}

.input-field:hover {
  border-color: var(--border-strong);
}

.input-field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.input-field--error {
  border-color: var(--danger);
}

.input-field--error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.input-helper {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.input-error {
  font-size: var(--text-xs);
  color: var(--danger);
}

/* ============================================================
 * BaseCard
 * ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card--elevated {
  box-shadow: var(--shadow-md);
  border-color: transparent;
}

.card--glow-cyan:hover {
  border-color: var(--p-cyan-800);
  box-shadow: var(--shadow-glow-cyan);
}

.card--glow-violet:hover {
  border-color: var(--p-violet-800);
  box-shadow: var(--shadow-glow-violet);
}

.card--interactive {
  cursor: pointer;
}

.card--interactive:hover {
  border-color: var(--border-strong);
}

.card--interactive:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.card__header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card__body {
  padding: var(--space-4);
}

.card__footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ============================================================
 * BaseBadge
 * ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  font-family: var(--font-condensed);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  letter-spacing: var(--tracking-wide);
  line-height: var(--leading-tight);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.badge--primary   { background: var(--primary-subtle); color: var(--p-cyan-300); }
.badge--accent    { background: var(--accent-subtle); color: var(--p-violet-300); }
.badge--success   { background: var(--success-subtle); color: var(--p-green-300); }
.badge--warning   { background: var(--warning-subtle); color: var(--p-amber-300); }
.badge--danger    { background: var(--danger-subtle); color: var(--p-red-300); }
.badge--info      { background: var(--info-subtle); color: var(--p-sky-300); }
.badge--neutral   { background: var(--surface-alt); color: var(--text-secondary); }

/* Dot indicator inside badge */
.badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ============================================================
 * BaseToggle
 * ============================================================ */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__track {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.toggle__input:checked + .toggle__track {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle__input:checked + .toggle__track .toggle__thumb {
  transform: translateX(20px);
  background: var(--text-on-primary);
}

.toggle__input:focus-visible + .toggle__track {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.toggle__label {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text);
}

/* ============================================================
 * BaseSkeleton
 * ============================================================ */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}

.skeleton {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton--text {
  height: 14px;
  border-radius: var(--radius-sm);
}

.skeleton--heading {
  height: 22px;
  width: 60%;
  border-radius: var(--radius-sm);
}

.skeleton--circle {
  border-radius: 50%;
}

.skeleton--card {
  height: 120px;
  border-radius: var(--radius-lg);
}

.skeleton--row {
  height: 48px;
  border-radius: var(--radius-md);
}

.skeleton--stat {
  height: 80px;
  border-radius: var(--radius-lg);
}

/* ============================================================
 * StatCard
 * ============================================================ */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.stat-card__value {
  font-family: var(--font-condensed);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-none);
  color: var(--text);
}

.stat-card__label {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.stat-card__trend {
  font-family: var(--font-condensed);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.stat-card__trend--up { color: var(--success); }
.stat-card__trend--down { color: var(--danger); }
.stat-card__trend--flat { color: var(--text-muted); }

/* ============================================================
 * NutritionBar
 * ============================================================ */
.nutrition-bar {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nutrition-bar__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.nutrition-bar__label {
  font-family: var(--font-condensed);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
}

.nutrition-bar__values {
  font-family: var(--font-condensed);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.nutrition-bar__track {
  height: 6px;
  background: var(--surface-inset);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.nutrition-bar__fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width var(--transition-slow);
  min-width: 2px;
}

/* Nutrition-specific fill colors */
.nutrition-bar--carbs .nutrition-bar__fill    { background: var(--carbs); }
.nutrition-bar--fluids .nutrition-bar__fill   { background: var(--fluids); }
.nutrition-bar--sodium .nutrition-bar__fill   { background: var(--sodium); }
.nutrition-bar--caffeine .nutrition-bar__fill { background: var(--caffeine); }
.nutrition-bar--protein .nutrition-bar__fill  { background: var(--protein); }
.nutrition-bar--fiber .nutrition-bar__fill    { background: var(--fiber); }

/* Status-based fill colors (when over/under target) */
.nutrition-bar--ok .nutrition-bar__fill       { background: var(--success); }
.nutrition-bar--warn .nutrition-bar__fill     { background: var(--warning); }
.nutrition-bar--critical .nutrition-bar__fill { background: var(--danger); }

/* ============================================================
 * InlineAlert
 * ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

.alert--success { background: var(--success-subtle); border-color: var(--p-green-800); color: var(--p-green-300); }
.alert--warning { background: var(--warning-subtle); border-color: var(--p-amber-800); color: var(--p-amber-300); }
.alert--danger  { background: var(--danger-subtle); border-color: var(--p-red-800); color: var(--p-red-300); }
.alert--info    { background: var(--info-subtle); border-color: var(--p-sky-800); color: var(--p-sky-300); }

.alert__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.alert__content { flex: 1; }

.alert__title {
  font-weight: var(--font-semibold);
  margin-bottom: 2px;
}

.alert__dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: currentColor;
  opacity: 0.6;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}

.alert__dismiss:hover { opacity: 1; }

/* ============================================================
 * Toast Notification
 * ============================================================ */
.toast-stack {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
  max-width: 380px;
  width: 100%;
  pointer-events: none;
}

@media (max-width: 767px) {
  .toast-stack {
    bottom: 80px; /* above mobile tab bar */
    right: var(--space-4);
    left: var(--space-4);
    max-width: none;
  }
}

.toast-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text);
  pointer-events: auto;
  animation: toast-in 0.3s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-item--exiting {
  animation: toast-out 0.2s ease forwards;
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

.toast-item--success .toast-item__icon { color: var(--success); }
.toast-item--warning .toast-item__icon { color: var(--warning); }
.toast-item--danger .toast-item__icon  { color: var(--danger); }
.toast-item--info .toast-item__icon    { color: var(--info); }

.toast-item__icon { flex-shrink: 0; margin-top: 1px; }
.toast-item__content { flex: 1; }
.toast-item__title { font-weight: var(--font-semibold); margin-bottom: 2px; }
.toast-item__message { color: var(--text-secondary); }

.toast-item__actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.toast-item__action {
  background: none;
  border: none;
  color: var(--primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  padding: 0;
}

.toast-item__action:hover { text-decoration: underline; }

.toast-item__close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  line-height: 1;
}

.toast-item__close:hover { color: var(--text); }

/* ============================================================
 * ProgressBar / Spinner
 * ============================================================ */
.progress {
  height: 6px;
  background: var(--surface-inset);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-pill);
  transition: width var(--transition-slow);
}

.progress--sm { height: 4px; }
.progress--lg { height: 10px; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner--sm { width: 16px; height: 16px; }
.spinner--md { width: 24px; height: 24px; }
.spinner--lg { width: 36px; height: 36px; }

/* ============================================================
 * ModalDialog
 * ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.8);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: backdrop-in 0.2s ease;
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.2s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal--sm { width: 400px; }
.modal--md { width: 560px; }
.modal--lg { width: 720px; }
.modal--full { width: 95vw; max-width: 1200px; }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.modal__title {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text);
}

.modal__close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__close:hover { color: var(--text); background: var(--surface-alt); }

.modal__body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* ============================================================
 * SlidePanel
 * ============================================================ */
.slide-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  z-index: var(--z-overlay);
  animation: backdrop-in 0.2s ease;
}

.slide-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  animation: slide-in 0.3s ease;
}

@keyframes slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.slide-panel--sm { width: 400px; }
.slide-panel--md { width: 560px; }
.slide-panel--lg { width: 50vw; min-width: 600px; }

@media (max-width: 767px) {
  .slide-panel { width: 100% !important; min-width: 0 !important; }
}

.slide-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.slide-panel__title {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text);
}

.slide-panel__close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}

.slide-panel__close:hover { color: var(--text); background: var(--surface-alt); }

.slide-panel__body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.slide-panel__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* ============================================================
 * CommandPalette
 * ============================================================ */
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  animation: backdrop-in 0.15s ease;
}

.cmd-palette {
  width: 560px;
  max-width: 95vw;
  max-height: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-in 0.15s ease;
}

.cmd-palette__input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.cmd-palette__icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.cmd-palette__input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  color: var(--text);
}

.cmd-palette__input::placeholder { color: var(--text-muted); }

.cmd-palette__results {
  overflow-y: auto;
  flex: 1;
  padding: var(--space-2);
}

.cmd-palette__group-label {
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-condensed);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.cmd-palette__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
}

.cmd-palette__item:hover,
.cmd-palette__item--active {
  background: var(--surface-alt);
}

.cmd-palette__item-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.cmd-palette__item-title { flex: 1; }

.cmd-palette__item-badge {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.cmd-palette__empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.cmd-palette__footer {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.cmd-palette__shortcut {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.cmd-palette__kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 4px;
  font-family: var(--font-sans);
  font-size: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ============================================================
 * DropdownMenu
 * ============================================================ */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown__menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: var(--z-dropdown);
  min-width: 180px;
  margin-top: var(--space-1);
  padding: var(--space-1);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: dropdown-in 0.15s ease;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.dropdown__item:hover,
.dropdown__item--active {
  background: var(--surface-alt);
}

.dropdown__item--danger { color: var(--danger); }
.dropdown__item--danger:hover { background: var(--danger-subtle); }

.dropdown__item-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.dropdown__divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-1) 0;
}

/* ============================================================
 * LapTimer (race-specific)
 * ============================================================ */
.lap-timer {
  text-align: center;
  padding: var(--space-4);
}

.lap-timer__clock {
  font-family: var(--font-condensed);
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-none);
  color: var(--text);
}

.lap-timer__lap-num {
  font-family: var(--font-condensed);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--primary);
  margin-top: var(--space-1);
}

.lap-timer__countdown {
  font-family: var(--font-condensed);
  font-size: var(--text-md);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.lap-timer__countdown--urgent {
  color: var(--warning);
}

.lap-timer__countdown--critical {
  color: var(--danger);
  animation: skeleton-pulse 1s ease-in-out infinite;
}

/* ============================================================
 * NutritionScorecard (race-specific)
 * ============================================================ */
.nutrition-scorecard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: var(--space-2);
}

.nutrition-scorecard__item {
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}

.nutrition-scorecard__value {
  font-family: var(--font-condensed);
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-none);
}

.nutrition-scorecard__label {
  font-family: var(--font-condensed);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.nutrition-scorecard__item--carbs .nutrition-scorecard__value    { color: var(--carbs); }
.nutrition-scorecard__item--fluids .nutrition-scorecard__value   { color: var(--fluids); }
.nutrition-scorecard__item--sodium .nutrition-scorecard__value   { color: var(--sodium); }
.nutrition-scorecard__item--caffeine .nutrition-scorecard__value { color: var(--caffeine); }
.nutrition-scorecard__item--protein .nutrition-scorecard__value  { color: var(--protein); }

/* ============================================================
 * WeatherStrip (race-specific)
 * ============================================================ */
.weather-strip {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-family: var(--font-condensed);
}

.weather-strip__temp {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text);
}

.weather-strip__detail {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.weather-strip__impact {
  margin-left: auto;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

.weather-strip__impact--low { color: var(--success); }
.weather-strip__impact--moderate { color: var(--warning); }
.weather-strip__impact--high { color: var(--danger); }

/* ============================================================
 * BaseSelect
 * ============================================================ */
.select-wrap {
  position: relative;
}

.select-field {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-8) 0 var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
}

.select-field:hover { border-color: var(--border-strong); }
.select-field:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15); }

.select-wrap__arrow {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* ============================================================
 * BaseCheckbox / BaseRadio
 * ============================================================ */
.checkbox,
.radio {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text);
}

.checkbox__input,
.radio__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox__box {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  background: var(--surface-inset);
}

.checkbox__input:checked + .checkbox__box {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox__input:focus-visible + .checkbox__box {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.checkbox__check {
  display: none;
  color: var(--text-on-primary);
}

.checkbox__input:checked + .checkbox__box .checkbox__check {
  display: block;
}

.radio__circle {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  background: var(--surface-inset);
}

.radio__input:checked + .radio__circle {
  border-color: var(--primary);
}

.radio__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  display: none;
}

.radio__input:checked + .radio__circle .radio__dot {
  display: block;
}

.radio__input:focus-visible + .radio__circle {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ============================================================
 * BaseTextarea
 * ============================================================ */
.textarea-field {
  width: 100%;
  min-height: 80px;
  padding: var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition-fast);
}

.textarea-field::placeholder { color: var(--text-muted); }
.textarea-field:hover { border-color: var(--border-strong); }
.textarea-field:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15); }

/* ============================================================
 * RangeSlider
 * ============================================================ */
.range-slider {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.range-slider__label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.range-slider__label {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
}

.range-slider__value {
  font-family: var(--font-condensed);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text);
}

.range-slider__input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--surface-inset);
  border-radius: var(--radius-pill);
  outline: none;
}

.range-slider__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

.range-slider__input::-webkit-slider-thumb:hover {
  box-shadow: var(--shadow-glow-cyan);
}

.range-slider__input:focus-visible::-webkit-slider-thumb {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.range-slider__input::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--surface);
}

/* ============================================================
 * BaseTooltip
 * ============================================================ */
.tooltip-wrap {
  position: relative;
  display: inline-block;
}

.tooltip-content {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-1) var(--space-2);
  background: var(--p-neutral-700);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
  white-space: nowrap;
  pointer-events: none;
  z-index: var(--z-tooltip);
  box-shadow: var(--shadow-md);
}

.tooltip-content::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--p-neutral-700);
}
