@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');

:root {
  /* Dark Glassmorphic HUD Design System (UI/UX Pro Max) */
  --bg-deep: #050811;
  --bg-surface: #0A0F1D;

  --glass-bg: rgba(16, 24, 40, 0.45);
  --glass-bg-hover: rgba(24, 36, 60, 0.6);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-border-highlight: rgba(255, 255, 255, 0.22);
  --glass-specular: inset 0 1px 0 0 rgba(255, 255, 255, 0.15);
  --glass-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.8), 0 0 1px 1px rgba(255, 255, 255, 0.05);

  /* Neon Biometric Palette */
  --neon-coral: #FF3B69;
  --neon-coral-glow: rgba(255, 59, 105, 0.45);

  --neon-emerald: #00E676;
  --neon-emerald-glow: rgba(0, 230, 118, 0.45);

  --neon-cyan: #00D2FF;
  --neon-cyan-glow: rgba(0, 210, 255, 0.45);

  --neon-amber: #FFB300;
  --neon-amber-glow: rgba(255, 179, 0, 0.45);

  --text-white: #FFFFFF;
  --text-muted: #CBD5E1;
  --text-dim: #94A3B8; /* WCAG 2.2 AA compliant contrast on dark surfaces */

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;

  --font-hud: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-fa: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

input, textarea, select {
  user-select: text;
}

/* Accessibility: High Visibility Focus Ring */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--neon-cyan) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 12px var(--neon-cyan-glow) !important;
}

html, body {
  background-color: var(--bg-deep);
  color: var(--text-white);
  font-family: var(--font-fa);
  direction: rtl;
  text-align: right;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Glowing Background with Sci-Fi Nebula Depth */
body {
  background:
    radial-gradient(circle at 50% 8%, rgba(0, 210, 255, 0.16) 0%, transparent 45%),
    radial-gradient(circle at 15% 45%, rgba(0, 230, 118, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(255, 59, 105, 0.12) 0%, transparent 45%),
    #050811;
  background-attachment: fixed;
}

/* App Viewport Container */
.app-viewport {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: calc(175px + var(--safe-bottom));
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

@media (min-width: 640px) {
  body {
    padding: 24px 0 80px 0;
  }
  .app-viewport {
    background: rgba(10, 15, 29, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 36px;
    box-shadow:
      0 0 0 1px rgba(0, 210, 255, 0.2),
      0 30px 80px -15px rgba(0, 0, 0, 0.9),
      var(--glass-specular);
    min-height: 94vh;
    max-width: 680px;
    width: 92%;
  }
  .modal-overlay {
    align-items: center !important;
    justify-content: center !important;
    padding: 24px;
  }
  .modal-sheet-hud {
    border-radius: var(--radius-xl) !important;
    border: 1px solid var(--glass-border-highlight) !important;
    box-shadow: 0 24px 64px -12px rgba(0, 0, 0, 0.9), var(--glass-specular) !important;
    max-height: 80vh !important;
    max-width: 440px !important;
    animation: modalPop 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }
  .modal-handle-hud {
    display: none !important;
  }
}

/* Tablet & Desktop Large Screen Responsive Optimization */
@media (min-width: 820px) {
  .app-viewport {
    max-width: 1040px;
    width: 94%;
    padding-bottom: 120px;
  }

  .hud-header {
    border-radius: 36px 36px 0 0;
    padding: 16px 28px;
  }

  .app-content {
    padding: 24px 28px;
    gap: 20px;
  }

  /* Two-Column Responsive Grid on Desktop */
  #screen-today.active {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: stretch;
  }

  /* Exercises Grid on Desktop */
  #workout-exercises-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  /* AI Hub Grid on Desktop */
  #screen-ai.active {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
  }

  /* Nutrition Subview Desktop Grid */
  .nutrition-subview.active {
    display: grid !important;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 20px;
    align-items: start;
  }

  .nutrition-subview:not(.active) {
    display: none !important;
  }

  .nutrition-summary-card {
    grid-column: 1 / 2;
  }

  .nutrition-quick-card {
    grid-column: 2 / 3;
  }

  .nutrition-meals-card {
    grid-column: 1 / -1;
  }

  /* Desktop Floating Dock */
  .hud-glass-dock {
    width: auto;
    min-width: 420px;
    max-width: 500px;
    bottom: 24px;
    background: rgba(14, 21, 38, 0.88);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), 0 0 1px 1px rgba(0, 210, 255, 0.3), var(--glass-specular);
  }
}

@media (min-width: 1280px) {
  .app-viewport {
    max-width: 1140px;
  }
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Glass Header with HUD Status */
.hud-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: calc(12px + var(--safe-top)) 18px 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(5, 8, 17, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hud-clock-group {
  text-align: center;
}

.hud-time {
  font-family: var(--font-hud);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-white);
  line-height: 1;
  direction: ltr;
  unicode-bidi: isolate;
}

.hud-date {
  font-family: var(--font-hud);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
  direction: ltr;
  unicode-bidi: isolate;
}

/* Touch Targets: minimum 44px */
.hud-icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-specular);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.hud-icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.12);
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
  box-shadow: 0 2px 8px rgba(0, 210, 255, 0.3), var(--glass-specular);
}

.hud-icon-btn.active {
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
  background: rgba(0, 210, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 210, 255, 0.25), var(--glass-specular);
}

/* Main Content Screen Views */
.app-content {
  flex: 1;
  padding: 14px 16px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.screen-view {
  display: none;
  flex-direction: column;
  gap: 16px;
  animation: hudFade 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.screen-view.active {
  display: flex;
}

@keyframes hudFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glassmorphism Cards */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), var(--glass-specular);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-panel:hover {
  border-color: var(--glass-border-highlight);
}

/* Glowing Top Biometric Activity Rings */
.biometric-rings-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 10px;
  padding: 6px 0 2px 0;
}

.ring-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.ring-svg-wrapper {
  width: 82px;
  height: 82px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 6.5;
}

.ring-progress {
  fill: none;
  stroke-width: 6.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.ring-progress.coral {
  stroke: var(--neon-coral);
}

.ring-progress.emerald {
  stroke: var(--neon-emerald);
}

.ring-progress.cyan {
  stroke: var(--neon-cyan);
}

.ring-center-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-center-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.ring-center-pct {
  font-family: var(--font-hud);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1;
  margin-top: 2px;
  direction: ltr;
  unicode-bidi: isolate;
}

.ring-caption {
  text-align: center;
  width: 100%;
}

/* Bidirectional Isolate Utility */
.bidi-metric {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
}

.ring-value-text {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.ring-value-text.coral { color: var(--neon-coral); }
.ring-value-text.emerald { color: var(--neon-emerald); }
.ring-value-text.cyan { color: var(--neon-cyan); }

.ring-label-text {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 700;
  margin-top: 2px;
  letter-spacing: 0.4px;
}

/* Real-Time Pulse / ECG Monitor Card */
.ecg-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.ecg-title-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-white);
}

.ecg-heart-icon {
  width: 20px;
  height: 20px;
  color: var(--neon-cyan);
  animation: pulseBeat 1.4s infinite ease-in-out;
}

@keyframes pulseBeat {
  0% { transform: scale(1); filter: drop-shadow(0 0 2px var(--neon-cyan)); }
  15% { transform: scale(1.2); filter: drop-shadow(0 0 8px var(--neon-cyan)); }
  30% { transform: scale(1); filter: drop-shadow(0 0 2px var(--neon-cyan)); }
  45% { transform: scale(1.12); filter: drop-shadow(0 0 5px var(--neon-cyan)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 2px var(--neon-cyan)); }
}

.ecg-minmax-row {
  display: flex;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  direction: ltr;
  unicode-bidi: isolate;
}

.ecg-minmax-row span b {
  color: var(--text-white);
  font-size: 13px;
  margin-left: 3px;
}

.ecg-live-bpm-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  direction: ltr;
  unicode-bidi: isolate;
}

.ecg-big-bpm {
  font-family: var(--font-hud);
  font-size: 36px;
  font-weight: 800;
  color: var(--text-white);
  line-height: 1;
  letter-spacing: -1px;
}

.ecg-bpm-unit {
  font-family: var(--font-hud);
  font-size: 13px;
  font-weight: 700;
  color: var(--neon-cyan);
  text-transform: uppercase;
}

.ecg-sparkline-box {
  width: 100%;
  height: 56px;
  margin-top: 8px;
  position: relative;
}

.ecg-sparkline-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Dual Metrics (Steps & Active Calories) */
.dual-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric-gauge-card {
  min-width: 0;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-specular);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-gauge-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.metric-gauge-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
  color: var(--text-white);
  line-height: 1.2;
  direction: ltr;
  unicode-bidi: isolate;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-gauge-val.cyan { color: var(--neon-cyan); }
.metric-gauge-val.emerald { color: var(--neon-emerald); }

.hud-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.hud-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.hud-progress-fill.cyan {
  background: linear-gradient(90deg, #0088EA, #00D2FF);
  box-shadow: 0 1px 4px rgba(0, 210, 255, 0.4);
}

.hud-progress-fill.emerald {
  background: linear-gradient(90deg, #059669, #00E676);
  box-shadow: 0 1px 4px rgba(0, 230, 118, 0.4);
}

.hud-progress-fill.coral {
  background: linear-gradient(90deg, #E11D48, #FF3B69);
  box-shadow: 0 1px 4px rgba(255, 59, 105, 0.4);
}

/* Workout Session Card */
.workout-session-card {
  background: linear-gradient(135deg, rgba(16, 24, 40, 0.7) 0%, rgba(10, 15, 29, 0.9) 100%);
  border: 1px solid rgba(0, 210, 255, 0.25);
  box-shadow: 0 10px 40px rgba(0, 210, 255, 0.1), var(--glass-specular);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.workout-card-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.workout-tag-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workout-main-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-white);
  line-height: 1.3;
}

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

.workout-action-cta {
  width: 100%;
  white-space: nowrap;
}

@media (min-width: 600px) {
  .workout-session-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .workout-action-cta {
    width: auto;
    min-width: 160px;
  }
}

.hud-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-hud);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  letter-spacing: 0.3px;
}

.hud-badge.cyan {
  background: rgba(0, 210, 255, 0.12);
  color: var(--neon-cyan);
  border: 1px solid rgba(0, 210, 255, 0.3);
}

.hud-badge.emerald {
  background: rgba(0, 230, 118, 0.12);
  color: var(--neon-emerald);
  border: 1px solid rgba(0, 230, 118, 0.3);
}

.hud-badge.coral {
  background: rgba(255, 59, 105, 0.12);
  color: var(--neon-coral);
  border: 1px solid rgba(255, 59, 105, 0.3);
}

.workout-main-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-white);
}

/* Segmented Glass Controls (Tabs) */
.glass-segmented-control {
  display: flex;
  background: rgba(10, 15, 29, 0.6);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-specular);
  border-radius: var(--radius-full);
  padding: 4px;
  gap: 4px;
}

.glass-seg-btn {
  flex: 1;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-fa);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 390px) {
  .glass-seg-btn {
    font-size: 12px;
    padding: 8px 8px;
    gap: 4px;
  }
}

.glass-seg-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-white);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), var(--glass-specular);
}

/* 7-Day Day Pills */
.hud-days-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px 2px;
  scrollbar-width: none;
}

.hud-days-scroll::-webkit-scrollbar {
  display: none;
}

.hud-day-pill {
  flex: 0 0 auto;
  padding: 8px 14px;
  min-height: 44px;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-specular);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: all 0.18s ease;
  min-width: 64px;
}

.hud-day-pill:active {
  transform: scale(0.94);
}

.hud-day-pill.active {
  background: rgba(0, 210, 255, 0.15);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px var(--neon-cyan-glow);
}

.hud-day-pill.active .hud-day-name {
  color: var(--neon-cyan);
}

.hud-day-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-white);
}

.hud-day-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
}

/* Exercise Cards inside HUD */
.hud-exercises-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hud-exercise-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-specular);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hud-ex-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-white);
  overflow-wrap: anywhere;
}

.hud-set-input-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.hud-inputs-3grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}

.btn-log-set {
  width: 100%;
  white-space: nowrap;
}

@media (min-width: 580px) {
  .hud-set-input-row {
    flex-direction: row;
    align-items: flex-end;
  }
  .hud-inputs-3grid {
    flex: 1;
  }
  .btn-log-set {
    width: auto;
    min-width: 120px;
  }
}

.hud-input-group {
  flex: 1;
}

.hud-input-group label {
  font-size: 11px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
}

/* Base Input: Default to Persian font for text */
.hud-input {
  width: 100%;
  min-height: 44px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font-fa);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-white);
  text-align: right;
  direction: rtl;
  outline: none;
  transition: all 0.18s ease;
}

/* Numeric Inputs: Use Monospace with LTR formatting */
.hud-input-number,
input[type="number"].hud-input {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  direction: ltr;
  unicode-bidi: isolate;
}

.hud-input::placeholder {
  color: #94A3B8;
  opacity: 0.85;
}

.hud-input:focus {
  border-color: var(--neon-cyan);
  background: rgba(0, 210, 255, 0.08);
  box-shadow: 0 0 10px var(--neon-cyan-glow);
}

/* Glowing Neon Buttons */
.btn-hud {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: var(--font-fa);
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  outline: none;
  min-height: 44px;
  white-space: nowrap;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-hud:active {
  transform: scale(0.96);
}

.btn-hud-cyan {
  background: linear-gradient(180deg, #00d2ff 0%, #0088ea 100%);
  color: #050811;
  box-shadow: 0 4px 14px rgba(0, 210, 255, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  font-weight: 800;
}

.btn-hud-emerald {
  background: linear-gradient(180deg, #00e676 0%, #059669 100%);
  color: #050811;
  box-shadow: 0 4px 14px rgba(0, 230, 118, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  font-weight: 800;
}

.btn-hud-coral {
  background: linear-gradient(180deg, #ff3b69 0%, #e11d48 100%);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(255, 59, 105, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  font-weight: 800;
}

.btn-hud-glass {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-specular);
  color: var(--text-white);
}

.btn-hud-glass:active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-hud-sm {
  min-height: 44px;
  padding: 8px 14px;
  font-size: 13px;
}

/* Quick Food Chips: touch target >= 44px */
.nutrition-subview {
  flex-direction: column;
  gap: 14px;
}

.food-chip {
  min-height: 44px;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  border-radius: var(--radius-full);
  white-space: normal;
  word-break: break-word;
  text-align: right;
  line-height: 1.35;
}

/* Floating Glass HUD Dock */
.hud-glass-dock {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 420px;
  height: 68px;
  background: rgba(14, 21, 38, 0.75);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 25px 60px rgba(0, 0, 0, 0.9),
    0 0 2px 1px rgba(0, 210, 255, 0.15),
    var(--glass-specular);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 16px;
  z-index: 50;
}

.hud-dock-item {
  width: 52px;
  height: 52px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-full);
  background: transparent;
  border: none;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.hud-dock-item:active {
  transform: scale(0.9);
}

.hud-dock-item.active {
  color: var(--neon-cyan);
  background: rgba(0, 210, 255, 0.12);
  border: 1px solid rgba(0, 210, 255, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 2px 8px rgba(0, 210, 255, 0.2);
}

.hud-dock-icon {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}

/* Floating Rest Timer Bar */
.hud-floating-timer {
  position: fixed;
  bottom: calc(96px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 420px;
  background: rgba(14, 21, 38, 0.92);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--neon-emerald);
  box-shadow: 0 10px 40px var(--neon-emerald-glow);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  display: none;
  align-items: center;
  justify-content: space-between;
  z-index: 45;
  animation: hudFade 0.25s ease;
}

.hud-floating-timer.active {
  display: flex;
}

.timer-digits {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 800;
  color: var(--neon-emerald);
  letter-spacing: 1px;
  direction: ltr;
  unicode-bidi: isolate;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: hudFade 0.2s ease;
  overscroll-behavior: contain;
}

.modal-overlay.active {
  display: flex;
}

.modal-sheet-hud {
  background: rgba(10, 15, 29, 0.96);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.9), var(--glass-specular);
  border-radius: 36px 36px 0 0;
  width: 100%;
  max-width: 460px;
  max-height: 85dvh;
  max-height: calc(100% - 24px);
  padding: 22px 22px calc(30px + var(--safe-bottom)) 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  animation: sheetRise 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

html.modal-open,
body.modal-open {
  overflow: hidden !important;
  touch-action: none;
}

.modal-handle-hud {
  width: 44px;
  height: 5px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-full);
  align-self: center;
  margin-bottom: 6px;
}

@keyframes sheetRise {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Toast: Positioned BELOW the header on mobile and clean corner on desktop */
.toast-container {
  position: fixed;
  top: calc(84px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

@media (min-width: 820px) {
  .toast-container {
    top: auto;
    bottom: 24px;
    left: 24px;
    transform: none;
    max-width: 340px;
  }
}

.toast {
  background: rgba(14, 21, 38, 0.94);
  backdrop-filter: blur(20px);
  border: 1px solid var(--neon-cyan);
  box-shadow: 0 10px 30px var(--neon-cyan-glow);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-white);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: hudFade 0.22s ease;
  pointer-events: auto;
}

.toast.pr {
  border-color: var(--neon-coral);
  box-shadow: 0 10px 30px var(--neon-coral-glow);
}

/* Small Screen Responsiveness (< 375px) */
@media (max-width: 375px) {
  .app-content {
    padding: 12px 10px 18px 10px;
  }

  .glass-panel {
    padding: 14px 12px;
  }

  .biometric-rings-row {
    gap: 6px;
  }

  .ring-svg-wrapper {
    width: 72px;
    height: 72px;
  }

  .ring-value-text {
    font-size: 11px;
  }
}

/* Accessibility: Prefers Reduced Motion (Targeted, Preserving Micro-Interactions) */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }
  .ecg-heart-icon,
  .screen-view,
  .modal-sheet-hud,
  .toast {
    animation: none !important;
  }
  .ring-progress,
  .hud-progress-fill {
    transition: none !important;
  }
}

/* Virtual Keyboard Clearance on Mobile */
@media (max-height: 480px) {
  .hud-glass-dock,
  .hud-floating-timer {
    display: none !important;
  }
}
