/* =============================================
   VARIABLES & RESET
   ============================================= */
:root {
  --midnight: #0b1120;
  --midnight-2: #111827;
  --midnight-3: #1e2d45;
  --blue-light: #4da8da;
  --blue-lighter: #7fc4f0;
  --blue-glow: rgba(77, 168, 218, 0.3);
  --orange: #f0a050;
  --orange-glow: rgba(240, 160, 80, 0.25);
  --gray-light: rgba(245, 248, 255, 0.07);
  --gray-border: rgba(200, 220, 255, 0.12);
  --gray-border-hover: rgba(200, 220, 255, 0.25);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.55);
  --text-dim: rgba(255, 255, 255, 0.35);

  /* Rating palette – cool (bad) → neutral → warm (good) */
  --rating-n3: #2a0a3c;
  --rating-n2: #4a1060;
  --rating-n1: #7b3fa0;
  --rating-0:  rgba(255,255,255,0.22);
  --rating-p1: #1a6ea0;
  --rating-p2: #2ca8d4;
  --rating-p3: #68deff;

  /* Allergy palette – blue (0 = none) → purple (3 = worst) */
  --allergy-0: #1a6ea0;
  --allergy-1: #5a5fa8;
  --allergy-2: #7b5ba0;
  --allergy-3: #8b4fa8;

  --header-h: 60px;
  --nav-h: 72px;
  --radius: 18px;
  --radius-sm: 10px;
  --blur: blur(22px);
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--midnight);
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* =============================================
   BACKGROUND BLOBS
   ============================================= */
.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}
.blob-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #1a3a6e 0%, transparent 70%);
  top: -150px; left: -150px;
}
.blob-2 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, #0e4a7a 0%, transparent 70%);
  bottom: 80px; right: -100px;
}
.blob-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #2d1a5e 0%, transparent 70%);
  top: 40%; left: 40%;
}

/* =============================================
   GLASS UTILITY
   ============================================= */
.glass {
  background: rgba(18, 28, 52, 0.55);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--gray-border);
}

/* =============================================
   APP SHELL
   ============================================= */
#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  z-index: 1;
}

/* =============================================
   HEADER
   ============================================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-top: none;
  border-left: none;
  border-right: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.header-content {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: max(20px, env(safe-area-inset-top)) 20px 16px;
  min-height: calc(var(--header-h) + max(0px, env(safe-area-inset-top)));
  height: auto;
}
.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 30%, var(--blue-lighter));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
  margin: 0;
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1.1;
}
.app-username {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: inherit;
  background: inherit;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

/* =============================================
   SELECT
   ============================================= */
.glass-select {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  height: 36px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0 10px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234da8da' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 22px;
}
.glass-select option { background: #1e2d45; }

.logout-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  margin-left: 10px;
}

.logout-button:hover {
  background: rgba(255,255,255,0.15);
  border-color: var(--gray-border-hover);
}

.logout-button .material-symbols-rounded {
  font-size: 20px;
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 16px calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
  scroll-behavior: smooth;
}
/* Thin scrollbar */
.main-content::-webkit-scrollbar { width: 4px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: rgba(77,168,218,0.3); border-radius: 4px; }

/* =============================================
   TABS
   ============================================= */
.tab-section { display: none; }
.tab-section.active { display: block; }

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blue-lighter);
  margin-top: 20px;
  margin-bottom: 12px;
  padding-left: 4px;
}

/* Rating filter bar – hidden above fold, revealed by scrolling up */
.rating-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
}
.rating-filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.rating-filter-bar .glass-select {
  flex: 1;
}

/* =============================================
   YEAR GRID
   ============================================= */
.year-grid-wrapper {
  border-radius: var(--radius);
  padding: 14px;
  position: relative;
}

.weekday-labels {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}
.weekday-labels span {
  text-align: center;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.year-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.week-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  position: relative;
}

.month-marker {
  position: absolute;
  left: 0;
  top: -10px;
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--blue-lighter);
  opacity: 0.7;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

.day-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  position: relative;
}
.day-cell:hover {
  transform: scale(1.3);
  z-index: 10;
  box-shadow: 0 0 8px rgba(77, 168, 218, 0.6);
}
.day-cell.empty { cursor: default; background: transparent !important; }
.day-cell.future { opacity: 0.35; cursor: default; }
.day-cell.today { box-shadow: 0 0 0 2px var(--orange), 0 0 10px var(--orange-glow); }

.day-cell[data-rating="-3"] { background: var(--rating-n3); }
.day-cell[data-rating="-2"] { background: var(--rating-n2); }
.day-cell[data-rating="-1"] { background: var(--rating-n1); }
.day-cell[data-rating="0"]  { background: var(--rating-0); border: 1px solid rgba(255,255,255,0.22); }
.day-cell[data-rating="1"]  { background: var(--rating-p1); }
.day-cell[data-rating="2"]  { background: var(--rating-p2); }
.day-cell[data-rating="3"]  { background: var(--rating-p3); }
.day-cell.unrated { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06); }

/* Legend */
.grid-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}
.legend-label { font-size: 0.6rem; color: var(--text-muted); }
.legend-scale { display: flex; gap: 3px; }
.legend-cell { width: 14px; height: 14px; border-radius: 3px; }

/* =============================================
   TOOLTIP
   ============================================= */
.day-tooltip {
  position: fixed;
  z-index: 200;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  min-width: 180px;
  pointer-events: none;
}
.day-tooltip.pinned { pointer-events: all; }
.day-tooltip.hidden { display: none; }

.tooltip-date {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--blue-lighter);
  margin-bottom: 8px;
}
.tooltip-ratings { display: flex; flex-direction: column; gap: 4px; }
.tooltip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
}
.tooltip-icon { font-size: 0.85rem; }
.tooltip-key { color: var(--text-muted); flex: 1; }
.tooltip-value {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  min-width: 24px;
  text-align: right;
}
.btn-small {
  margin-top: 10px;
  width: 100%;
  padding: 14px 10px;
  border-radius: 8px;
  border: 1px solid var(--blue-light);
  background: rgba(77, 168, 218, 0.12);
  color: var(--blue-lighter);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition);
}
.btn-small:hover { background: rgba(77, 168, 218, 0.25); }

/* =============================================
   RATE FORM
   ============================================= */
.rate-card {
  border-radius: var(--radius);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.optional { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: 0.6; }

.glass-input {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  resize: vertical;
}
.glass-input:focus {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px var(--blue-glow);
}
input[type="date"].glass-input {
  display: block;
  overflow: hidden;
}
input[type="date"].glass-input::-webkit-calendar-picker-indicator {
  filter: invert(0.7) brightness(1.5) sepia(1) hue-rotate(170deg);
  cursor: pointer;
  flex-shrink: 0;
}

/* Sliders */
.slider-group { display: flex; flex-direction: column; gap: 18px; }
.slider-item { display: flex; flex-direction: column; gap: 8px; }
.category-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue-lighter);
  margin-top: 4px;
}
.slider-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.slider-icon { font-size: 1.1rem; }
.slider-label { font-size: 0.85rem; font-weight: 500; flex: 1; }
.slider-value {
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 28px;
  text-align: right;
  color: var(--blue-lighter);
  transition: color var(--transition);
}
.slider-value.neg { color: #c080e0; }
.slider-value.pos { color: var(--blue-lighter); }
.slider-value.allergic { color: #c080e0; }        /* 1-3: same purple as neg */
.slider-value.allergic-0 { color: var(--blue-lighter); } /* 0: same blue as pos */

.slider-track-wrapper { display: flex; flex-direction: column; gap: 4px; }

.rating-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 6px;
  background: linear-gradient(to right, var(--rating-n3), var(--rating-n2), var(--rating-n1), #444, var(--rating-p1), var(--rating-p2), var(--rating-p3));
  outline: none;
  cursor: pointer;
}
.allergy-slider {
  background: linear-gradient(to right, var(--allergy-0), var(--allergy-1), var(--allergy-2), var(--allergy-3));
}
.rating-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  border: 2px solid var(--blue-light);
  cursor: pointer;
  transition: transform var(--transition);
}
.rating-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.rating-slider::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--blue-light);
  cursor: pointer;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 2px;
}
.slider-ticks span {
  font-size: 0.6rem;
  color: var(--text-dim);
  text-align: center;
  width: 14px;
}

/* Switches */
.switch-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.switch-label {
  font-size: 0.85rem;
  color: var(--text);
}
.ios-switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.ios-switch {
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.2);
  position: relative;
  transition: background 0.25s ease, border-color 0.25s ease;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}
.ios-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,0.35);
  transition: transform 0.25s cubic-bezier(.4, 0, .2, 1);
}
.ios-switch-input:checked + .ios-switch {
  background: #34c759;
  border-color: #34c759;
}
.ios-switch-input:checked + .ios-switch::after {
  transform: translateX(20px);
}

/* Inline date row – looks like a switch-row */
.date-row {
  cursor: pointer;
}
.date-input {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  text-align: right;
  padding: 0;
  min-width: 0;
  max-width: 160px;
  outline: none;
  cursor: pointer;
  /* prevent iOS from showing a blue underline */
  -webkit-tap-highlight-color: transparent;
}
.date-input::-webkit-calendar-picker-indicator {
  filter: invert(0.7) brightness(1.5) sepia(1) hue-rotate(170deg);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 4px;
}

/* Login */
body.login-page {
  overflow: auto;
  min-height: 100vh;
  min-height: 100dvh;
}
.login-shell {
  min-height: 100vh;        /* baseline */
  min-height: 100dvh;       /* dynamic viewport – accounts for Safari toolbar */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  position: relative;
  z-index: 2;
}
.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius);
  padding: 24px;
}
.login-header h1 {
  font-size: 1.8rem;
  line-height: 1.2;
  margin-bottom: 8px;
}
.login-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 18px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-button {
  margin-top: 2px;
}
.error-message {
  background: rgba(220, 80, 80, 0.12);
  border: 1px solid rgba(220, 80, 80, 0.35);
  color: #f4a7a7;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.84rem;
  margin-bottom: 14px;
}
.demo-info {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--gray-border);
  color: var(--text-muted);
  font-size: 0.78rem;
}
.demo-info strong {
  display: block;
  color: var(--blue-lighter);
  margin-bottom: 6px;
}
.demo-info p {
  margin: 0 0 3px;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, #1a6ea0, #2ca8d4);
  color: white;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 20px rgba(44, 168, 212, 0.35);
}
.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(44, 168, 212, 0.5);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary .material-symbols-rounded { font-size: 1.1rem; }

.btn-danger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  border: none;
  background: rgba(220, 80, 80, 0.18);
  border: 1px solid rgba(220, 80, 80, 0.35);
  color: #f4a7a7;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), background var(--transition);
  width: 100%;
}
.btn-danger:hover { background: rgba(220, 80, 80, 0.3); }
.btn-danger .material-symbols-rounded { font-size: 1.1rem; }

.save-status {
  text-align: center;
  font-size: 0.82rem;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.save-status.success {
  background: rgba(100, 220, 150, 0.12);
  border: 1px solid rgba(100, 220, 150, 0.3);
  color: #80e8a8;
}
.save-status.error {
  background: rgba(220, 80, 80, 0.12);
  border: 1px solid rgba(220, 80, 80, 0.3);
  color: #f08080;
}
.hidden { display: none !important; }

/* =============================================
   STATISTICS
   ============================================= */
.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stats-loading {
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.stat-card {
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-card-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blue-lighter);
  margin-bottom: 14px;
}

/* KPI row */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.kpi-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
}
.kpi-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
}
.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.kpi-value.positive { color: var(--rating-p3); }
.kpi-value.negative { color: #c080e0; }
.kpi-icon { font-size: 1rem; }

/* Best/worst items */
.highlight-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.highlight-item {
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.highlight-tag {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.highlight-tag.best { color: var(--rating-p3); }
.highlight-tag.worst { color: #c080e0; }
.highlight-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.highlight-score {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Distribution bar */
.dist-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 80px;
  padding: 0 4px;
}
.dist-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}
.dist-bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.4s ease;
}
.dist-bar-label {
  font-size: 0.6rem;
  color: var(--text-muted);
}
.dist-bar-count {
  font-size: 0.58rem;
  color: var(--text-dim);
}

/* Weekday chart */
.weekday-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.weekday-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.weekday-name {
  font-size: 0.72rem;
  color: var(--text-muted);
  width: 32px;
  flex-shrink: 0;
}
.weekday-bar-bg {
  flex: 1;
  height: 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  overflow: hidden;
}
.weekday-bar-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--rating-p1), var(--rating-p3));
  transition: width 0.5s ease;
}
.weekday-bar-fill.neg {
  background: linear-gradient(90deg, var(--rating-n2), var(--rating-n1));
}
.weekday-score {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  width: 32px;
  text-align: right;
}

/* Streak badge */
.streak-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.streak-item {
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.streak-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.streak-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.streak-sub { font-size: 0.65rem; color: var(--text-dim); }

/* =============================================
   BOTTOM NAV
   ============================================= */
.bottom-nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  /*
   * height = --nav-h + safe-area, padding-bottom = 4px + safe-area
   * → content-box = height - 4px - padding-bottom = --nav-h - 4px - 4px = 64px (constant!)
   * Buttons stay centered in the same 64px interactive area; glass background
   * simply extends further down to cover the home-indicator / browser chrome.
   */
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom, 0px));
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  border-bottom: none;
  border-left: none;
  border-right: none;
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 100;
  align-items: center;
  box-sizing: border-box;
}
.nav-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  transition: color var(--transition), background var(--transition);
  min-height: 44px;
  line-height: 1;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn .material-symbols-rounded { font-size: 1.5rem; transition: transform var(--transition); line-height: 1; }
.nav-label { font-size: 0.65rem; font-weight: 600; letter-spacing: 0.04em; }
.nav-btn.active {
  color: var(--blue-lighter);
  background: rgba(77, 168, 218, 0.12);
}
.nav-btn.active .material-symbols-rounded { transform: none; }
.nav-btn:focus {
  outline: none;
}

/* =============================================
   RESPONSIVE – wider screens
   ============================================= */
@media (min-width: 541px) {
  #app { box-shadow: 0 0 60px rgba(0,0,0,0.5); }
  body { background: #060c18; }
}

/* =============================================
   MOBILE OPTIMIZATIONS – iPhone and Mobile
   ============================================= */
@media (max-width: 768px) {
  /* Ensure full height on mobile */
  html, body {
    height: 100vh;
    height: 100dvh;
  }

  #app {
    height: 100vh;
    height: 100dvh;
  }

  /* Better touch targets for mobile */
  .nav-btn {
    padding: 12px 24px;
    min-width: 60px;
  }

  .logout-button {
    width: 44px;
    height: 44px;
  }

  .glass-select {
    min-width: 70px;
    height: 44px;
  }

  /* Adjust header for smaller screens */
  .app-title {
    font-size: 1.1rem;
  }

  /* iOS specific optimizations */
  @supports (-webkit-touch-callout: none) {
    .header-content {
      padding-top: max(20px, env(safe-area-inset-top, 44px));
    }
  }
}

/* PWA Mode Optimizations */
.pwa-mode {
  /* Additional PWA-specific styles if needed */
}

.pwa-mode.ios-device .header-content {
  padding-top: max(20px, env(safe-area-inset-top, 44px)) !important;
}

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tab-section.active { animation: fadeIn 0.22s ease; }
