/* ============================================================
   SOMA — Revolut-inspired Design System
   ============================================================ */

/* --- CSS Custom Properties (Dark Mode Default) -------------- */
:root {
  /* Dark mode palette */
  --bg: #0e0e11;
  --surface: #1a1a1f;
  --surface-hover: #222228;
  --surface-raised: #222228;
  --text-primary: #ffffff;
  --text-secondary: #888888;
  --text-tertiary: #555555;
  --divider: #1a1a1f;

  /* Progress bar */
  --track: #1f1f25;
  --progress-fill: #ffffff;

  /* Functional colors */
  --positive: #00c853;
  --positive-soft: rgba(0, 200, 83, 0.12);
  --warning: #ffab00;
  --warning-soft: rgba(255, 171, 0, 0.12);
  --negative: #ff1744;
  --negative-soft: rgba(255, 23, 68, 0.12);

  --accent: #FF007A;
  --accent-soft: rgba(255, 0, 122, 0.12);
  --green: #00b894;
  --green-soft: rgba(0, 184, 148, 0.12);
  --red: #e17055;
  --red-soft: rgba(225, 112, 85, 0.12);
  --yellow: #fdcb6e;
  --yellow-soft: rgba(253, 203, 110, 0.12);
  --blue: #74b9ff;
  --blue-soft: rgba(116, 185, 255, 0.12);

  /* Sleep stage colors */
  --sleep-deep: #5b21b6;
  --sleep-rem: #8b5cf6;
  --sleep-light: #c4b5fd;
  --sleep-awake: var(--red);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);

  /* Radius */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 100px;

  /* Bottom nav height */
  --nav-height: 56px;

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

/* --- Light Mode -------------------------------------------- */
[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f7f7f7;
  --surface-hover: #eeeeee;
  --surface-raised: #eeeeee;
  --text-primary: #1a1a2e;
  --text-secondary: #999999;
  --text-tertiary: #cccccc;
  --divider: #f0f0f0;
  --track: #e5e5e5;
  --progress-fill: #1a1a2e;
  --accent-soft: rgba(108, 92, 231, 0.08);
  --green-soft: rgba(0, 184, 148, 0.08);
  --red-soft: rgba(225, 112, 85, 0.08);
  --yellow-soft: rgba(253, 203, 110, 0.1);
  --blue-soft: rgba(116, 185, 255, 0.1);
  --positive-soft: rgba(0, 200, 83, 0.08);
  --warning-soft: rgba(255, 171, 0, 0.08);
  --negative-soft: rgba(255, 23, 68, 0.08);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #ffffff;
    --surface: #f7f7f7;
    --surface-hover: #eeeeee;
    --surface-raised: #eeeeee;
    --text-primary: #1a1a2e;
    --text-secondary: #999999;
    --text-tertiary: #cccccc;
    --divider: #f0f0f0;
    --track: #e5e5e5;
    --progress-fill: #1a1a2e;
    --accent-soft: rgba(108, 92, 231, 0.08);
    --green-soft: rgba(0, 184, 148, 0.08);
    --red-soft: rgba(225, 112, 85, 0.08);
    --yellow-soft: rgba(253, 203, 110, 0.1);
    --blue-soft: rgba(116, 185, 255, 0.1);
    --positive-soft: rgba(0, 200, 83, 0.08);
    --warning-soft: rgba(255, 171, 0, 0.08);
    --negative-soft: rgba(255, 23, 68, 0.08);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  }
}

/* --- Reset & Base ------------------------------------------ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--text-primary);
  height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100%;
  background: var(--bg);
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
  padding-top: var(--safe-top);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; background: none; border: none; outline: none; }
ul, ol { list-style: none; }

/* --- Typography -------------------------------------------- */
.hero-number {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1;
}

.hero-number-lg {
  font-size: 52px;
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1;
}

.section-number {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.section-number-lg {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.2;
}

.body-text {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.secondary-text {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.3;
}

.label-text {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  line-height: 1;
}

.label-text-sm {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  line-height: 1;
}

/* --- Layout ------------------------------------------------ */
.page {
  padding: 20px;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 8px;
  min-height: 44px;
}

.page-header h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.page-header-btn {
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
  padding: 4px 0;
}

.page-header-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.section-gap {
  height: 24px;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

/* --- App Logo ---------------------------------------------- */
.app-logo {
  width: 22px;
  height: 22px;
  opacity: 0.5;
  filter: grayscale(1);
  vertical-align: middle;
}

[data-theme="light"] .app-logo {
  filter: grayscale(1) invert(1);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .app-logo {
    filter: grayscale(1) invert(1);
  }
}

/* --- Sections (flat, no background — Revolut style) -------- */
.section {
  padding: 0;
}

/* --- Cards / Surfaces -------------------------------------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px;
}

.card + .card {
  margin-top: 10px;
}

/* --- Progress Bars ----------------------------------------- */
.progress-bar {
  height: 4px;
  background: var(--track);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--progress-fill);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 100%;
}

.progress-bar-fill.accent { background: var(--accent); }
.progress-bar-fill.green { background: var(--green); }
.progress-bar-fill.red { background: var(--red); }
.progress-bar-fill.yellow { background: var(--yellow); }
.progress-bar-fill.blue { background: var(--blue); }
.progress-bar-fill.positive { background: var(--positive); }
.progress-bar-fill.negative { background: var(--negative); }
.progress-bar-fill.warning { background: var(--warning); }

.progress-bar-thin {
  height: 3px;
}

/* --- Pill Buttons ------------------------------------------ */
.pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.pill.active {
  background: var(--text-primary);
  color: var(--bg);
}

.pill:hover:not(.active) {
  background: var(--surface-hover);
}

/* --- Segmented Control ------------------------------------- */
.segmented-control {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.segmented-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  transition: all 0.2s ease;
}

.segmented-btn.active {
  background: var(--surface-raised);
  color: var(--text-primary);
}

/* --- Metric Grid (Home) ------------------------------------ */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px;
}

.metric-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
}

.metric-unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 2px;
}

.metric-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* --- Meal / Transaction List ------------------------------- */
.meal-list {
  display: flex;
  flex-direction: column;
}

.meal-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: opacity 0.15s;
}

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

.meal-item:active {
  opacity: 0.6;
}

.meal-item.empty {
  opacity: 0.4;
}

.meal-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--surface);
}

.meal-icon.breakfast { background: var(--yellow-soft); }
.meal-icon.lunch { background: var(--green-soft); }
.meal-icon.dinner { background: var(--accent-soft); }
.meal-icon.snack { background: var(--red-soft); }

.meal-info {
  flex: 1;
  min-width: 0;
}

.meal-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal-amount {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: -0.3px;
}

.meal-amount-secondary {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: right;
  margin-top: 2px;
}

.meal-add {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 18px;
  flex-shrink: 0;
}

/* --- Meal Entry Rows (individual logged items) -------------- */
.meal-slot-group {
  border-bottom: 1px solid var(--divider);
  padding-bottom: 8px;
  margin-bottom: 0;
}

.meal-slot-group:last-child {
  border-bottom: none;
}

.meal-entry-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 4px 52px; /* indent under icon */
}

.meal-entry-name {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal-entry-cal {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.meal-entry-delete {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.meal-entry-delete:active {
  color: var(--negative);
  background: var(--red-soft, rgba(255,50,50,0.1));
}

/* --- Macro Row --------------------------------------------- */
.macro-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2px;
}

.macro-col {
  text-align: center;
  padding: 12px 4px;
}

.macro-col .label-text-sm {
  margin-bottom: 8px;
  display: block;
}

.macro-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
}

.macro-target {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
  font-weight: 400;
}

.macro-progress {
  margin-top: 8px;
}

/* --- Holdings / Asset List --------------------------------- */
.holding-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider);
}

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

.holding-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.holding-info {
  flex: 1;
  min-width: 0;
}

.holding-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.holding-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.holding-value {
  text-align: right;
}

.holding-amount {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.holding-change {
  font-size: 11px;
  margin-top: 2px;
}

/* --- Search Input ------------------------------------------ */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 0 10px;
  height: 44px;
  gap: 6px;
}

.search-wrapper svg {
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.search-wrapper input {
  flex: 1;
  height: 100%;
  font-size: 15px;
  font-weight: 500;
  background: transparent;
}

.search-wrapper input::placeholder {
  color: var(--text-tertiary);
}

.search-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text-secondary);
  transition: background 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.search-action-btn svg { width: 18px; height: 18px; }

.search-action-btn:hover {
  background: var(--surface-hover);
}

/* --- Food Item (search result / recent) -------------------- */
.food-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: opacity 0.15s;
}

.food-item:last-child { border-bottom: none; }
.food-item:active { opacity: 0.6; }

.food-item-info {
  flex: 1;
  min-width: 0;
}

.food-item-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.food-item-brand {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.food-item-macros {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 3px;
}

.food-item-cal {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* --- Modal / Overlay --------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 8px 20px calc(20px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-backdrop.open .modal-sheet {
  transform: translateY(0);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--text-tertiary);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header .modal-title {
  margin-bottom: 0;
  flex: 1;
  text-align: center;
}

.modal-cancel {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  min-width: 52px;
  text-align: left;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}

/* --- Primary Button ---------------------------------------- */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--text-primary);
  color: var(--bg);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-primary:active {
  opacity: 0.85;
  transform: scale(0.985);
}

.btn-primary:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  transition: opacity 0.15s;
}

.btn-secondary:active {
  opacity: 0.7;
}

/* --- FAB --------------------------------------------------- */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 40;
  transition: transform 0.15s, opacity 0.15s;
}

.fab:active {
  transform: scale(0.92);
  opacity: 0.9;
}

.fab svg {
  width: 24px;
  height: 24px;
}

/* --- Input Fields ------------------------------------------ */
.input-field {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  width: 100%;
  color: var(--text-primary);
}

.input-field::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

.input-field:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.input-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  display: block;
}

/* --- Settings List ----------------------------------------- */
.settings-group {
  background: var(--surface);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.settings-group + .settings-group {
  margin-top: 24px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  min-height: 48px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background 0.15s;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row:active {
  background: var(--surface-hover);
}

.settings-row-label {
  font-size: 15px;
  font-weight: 500;
}

.settings-row-value {
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-row-value svg {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
}

.select-styled {
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  appearance: none;
  text-align: right;
  padding-right: 2px;
  cursor: pointer;
}

/* --- Settings Panel: Section Labels ------------------------ */
.sp-section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--text-tertiary);
  margin: 24px 0 8px;
  padding-left: 2px;
}

/* --- Settings Panel: Pill Groups --------------------------- */
.sp-pill-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sp-pill {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1.5px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
}

.sp-pill.sp-pill-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.sp-pill.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.sp-pill:active {
  transform: scale(0.95);
}

/* --- Settings Panel: Inline Edits -------------------------- */
.sp-inline-edit {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sp-inline-input {
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  width: 90px;
  text-align: right;
  outline: none;
  -moz-appearance: textfield;
}

.sp-inline-input::-webkit-outer-spin-button,
.sp-inline-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.sp-chevron {
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: transform 0.2s;
}

/* --- Settings Panel: Allergy Tags -------------------------- */
.sp-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
}

.sp-empty-label {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 4px 0;
}

.sp-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--surface-raised);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  animation: sp-tag-in 0.2s ease;
}

@keyframes sp-tag-in {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.sp-tag-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  transition: color 0.15s;
}

.sp-tag-remove:hover {
  color: var(--negative);
}

.sp-allergy-input-row {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

.sp-allergy-field {
  flex: 1;
  background: var(--surface);
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
}

.sp-allergy-field::placeholder {
  color: var(--text-tertiary);
}

.sp-allergy-field:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.sp-allergy-add {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.sp-allergy-add:active {
  transform: scale(0.9);
  background: var(--accent);
  color: #fff;
}

/* --- Integration Status Dots ------------------------------- */
.integration-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.connected {
  background: var(--positive);
}

.status-dot.disconnected {
  background: var(--text-tertiary);
}

/* --- Toggle Switch ----------------------------------------- */
.toggle {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--track);
  border-radius: 14px;
  transition: background 0.25s;
  cursor: pointer;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle input:checked + .toggle-slider {
  background: var(--positive);
}

.toggle input:checked + .toggle-slider::after {
  transform: translateX(20px);
}

/* --- Serving Modal ----------------------------------------- */
.serving-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  text-align: center;
  padding: 16px 0;
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.serving-preview-item .value {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.serving-preview-item .unit {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* --- Quick Add -------------------------------------------- */
.quick-add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quick-add-grid .input-field {
  text-align: center;
  padding: 12px;
}

.quick-add-grid .input-label {
  text-align: center;
}

.quick-add-field {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- Weight Input ------------------------------------------ */
.weight-input-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px 0;
}

.weight-input-group .adjust-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 300;
  color: var(--text-primary);
  transition: background 0.15s;
}

.weight-input-group .adjust-btn:active {
  background: var(--surface-hover);
}

.weight-input-group input {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -2px;
  text-align: center;
  width: 160px;
  background: transparent;
}

/* Chrome/Safari number input spinner hide */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
}

/* --- Camera / Barcode Overlay ------------------------------ */
.camera-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: none;
}

.camera-overlay.open {
  display: flex;
  flex-direction: column;
}

.camera-overlay video {
  width: 100%;
  flex: 1;
  object-fit: cover;
}

.camera-overlay-controls {
  padding: 16px 20px calc(16px + var(--safe-bottom));
  display: flex;
  justify-content: center;
}

.camera-close-btn {
  padding: 12px 32px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-pill);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

/* --- Photo Results ----------------------------------------- */
.photo-results {
  padding: 8px 0;
}

.photo-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}

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

.photo-item-check {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.photo-item-check.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.photo-item-info { flex: 1; }

.photo-item-name {
  font-size: 15px;
  font-weight: 600;
}

.photo-item-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* --- Meal Tray --------------------------------------------- */
.meal-tray {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--divider);
  padding: 12px 0 calc(12px + var(--safe-bottom));
  margin-top: 20px;
  z-index: 5;
}

.meal-tray-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.meal-tray-total {
  font-size: 15px;
  font-weight: 700;
}

.tray-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
}

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

.tray-item-info {
  flex: 1;
  min-width: 0;
}

.tray-item-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tray-item-detail {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.tray-item-remove {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
}

.tray-item-remove:active {
  background: var(--negative-soft);
  color: var(--negative);
}

.meal-tray-macros {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 8px 0;
}

/* --- Tray Actions Row -------------------------------------- */
.tray-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --- Saved Meals ------------------------------------------- */
.saved-meal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: opacity 0.15s;
}
.saved-meal-item:last-child { border-bottom: none; }
.saved-meal-item:active { opacity: 0.6; }

.saved-meal-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.saved-meal-info {
  flex: 1;
  min-width: 0;
}

.saved-meal-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-meal-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.saved-meal-delete {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.saved-meal-item:hover .saved-meal-delete,
.saved-meal-item:active .saved-meal-delete {
  opacity: 1;
}
.saved-meal-delete:active {
  background: var(--negative-soft);
  color: var(--negative);
}

/* Long-press shows delete on mobile */
@media (hover: none) {
  .saved-meal-delete { opacity: 0.5; }
}

/* --- Date Navigator ---------------------------------------- */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 0;
}

.date-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.date-nav-btn:active {
  background: var(--surface);
}

.date-nav-label {
  font-size: 15px;
  font-weight: 600;
  min-width: 140px;
  text-align: center;
}

/* --- Sleep Stages Bar -------------------------------------- */
.sleep-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--track);
}

.sleep-bar-deep {
  background: var(--sleep-deep);
}

.sleep-bar-rem {
  background: var(--sleep-rem);
}

.sleep-bar-light {
  background: var(--sleep-light);
}

.sleep-bar-awake {
  background: var(--sleep-awake);
}

/* --- Workout Item ------------------------------------------ */
.workout-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}

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

.workout-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.workout-info {
  flex: 1;
  min-width: 0;
}

.workout-name {
  font-size: 15px;
  font-weight: 600;
}

.workout-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.workout-stat {
  text-align: right;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* --- Workout Planner: Type Grid -------------------------------- */
.workout-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.workout-type-btn {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  border: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.workout-type-btn:active {
  transform: scale(0.96);
  background: var(--surface-hover);
}

.workout-type-btn .icon {
  font-size: 28px;
  display: block;
}

.workout-type-btn .label {
  font-size: 11px;
  margin-top: 6px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- Workout Planner: Exercise Cards --------------------------- */
.exercise-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.exercise-card-small {
  padding: 10px 16px;
}

.exercise-card-active {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
}

.exercise-card-done {
  opacity: 0.5;
}

.exercise-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- Workout Planner: Set Tracker ------------------------------ */
.set-rows {
  margin-top: 8px;
}

.set-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
}

.set-row:last-child {
  border-bottom: none;
}

.set-row-header {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--divider);
  padding-bottom: 4px;
}

.set-row-completed {
  opacity: 0.6;
}

.set-label {
  width: 36px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}

.set-input {
  width: 64px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  -webkit-appearance: none;
}

.set-input:focus {
  border-color: var(--accent);
  outline: none;
}

.set-input:disabled {
  opacity: 0.4;
}

.set-input-label {
  flex: 1;
  text-align: center;
}

.set-check-label {
  width: 48px;
}

.set-complete-btn {
  background: var(--positive);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.set-complete-btn:active {
  opacity: 0.8;
}

/* --- Workout Planner: Rest Timer ------------------------------- */
.rest-timer {
  text-align: center;
  padding: 24px;
  margin-bottom: 16px;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
}

.rest-timer-value {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -2px;
  color: var(--accent);
}

.rest-timer-label {
  color: var(--text-secondary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

/* --- Workout Planner: Summary ---------------------------------- */
.workout-summary {
  padding: 16px 0;
}

.workout-summary .workout-stat {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
  text-align: left;
  font-size: 15px;
}

.workout-summary .workout-stat:last-child {
  border-bottom: none;
}

/* --- Workout Planner: Rating ----------------------------------- */
.workout-rating {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.rating-star {
  font-size: 32px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

/* --- Workout Planner: Equipment Grid --------------------------- */
.workout-equipment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
}

.workout-equip-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 6px 0;
  color: var(--text-primary);
  cursor: pointer;
}

.workout-equip-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* --- Workout Library Browser -------------------------------- */
.workout-library-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.workout-library-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.workout-library-card:active {
  background: var(--surface-hover);
}

.workout-type-category {
  margin-bottom: 8px;
}

.workout-type-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius-md);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.workout-type-category-header:active {
  background: var(--surface-hover);
}

.workout-chevron {
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.workout-type-workouts {
  padding: 8px 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.workout-variant-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  padding: 8px 4px 4px;
  font-weight: 600;
}

/* --- Sparkline Container ----------------------------------- */
.sparkline-container {
  width: 100%;
  position: relative;
}

.sparkline-container canvas {
  width: 100%;
  display: block;
}

/* --- Trend Charts ------------------------------------------ */
.trend-chart {
  width: 100%;
  height: 100px;
  position: relative;
}

.trend-chart-tall {
  height: 120px;
}

.trend-chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.trend-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.trend-chart-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.trend-chart-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

/* --- Badge ------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge.positive { color: var(--positive); }
.badge.negative { color: var(--negative); }
.badge.warning { color: var(--warning); }
.badge.neutral { color: var(--text-secondary); }

/* --- Skeleton Loading -------------------------------------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-line {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 7px;
}

.skeleton-line.wide { width: 80%; }
.skeleton-line.medium { width: 50%; }
.skeleton-line.short { width: 30%; }
.skeleton-hero { height: 48px; width: 140px; border-radius: 8px; display: inline-block; }

/* --- Bottom Navigation ------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  border-top: 1px solid var(--divider);
  display: flex;
  align-items: center;
  z-index: 50;
}

.nav-scroll {
  display: flex;
  align-items: center;
  overflow-x: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0 4px;
}
.nav-scroll::-webkit-scrollbar { display: none; }

/* SOMA branded button — replaces mic icon */
.nav-soma-btn {
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0 12px 0 4px;
  transition: transform 0.15s, background 0.15s, color 0.15s;
}
.nav-soma-text {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
}
.nav-soma-btn:active {
  transform: scale(0.93);
  background: var(--accent);
  color: white;
}
.nav-soma-btn.listening {
  background: var(--accent);
  color: white;
  animation: soma-pulse 1.5s ease infinite;
}
@keyframes soma-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 0, 122, 0.3); }
  50% { box-shadow: 0 0 0 10px rgba(255, 0, 122, 0); }
}

.nav-marketplace {
  opacity: 0.5;
}
.nav-marketplace:hover, .nav-marketplace.active {
  opacity: 1;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  color: var(--text-tertiary);
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-item span {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.nav-item.active {
  color: var(--text-primary);
}

/* --- Nav Logo (inline SVG atom) ------------------------------ */
.nav-logo-svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* --- Quick Log (Home) -------------------------------------- */
.quick-log-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.quick-log-tile {
  background: transparent;
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.quick-log-tile:active {
  background: var(--surface-hover);
  transform: scale(0.97);
}

.quick-log-tile .tile-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.quick-log-tile .tile-value {
  font-size: 22px;
  line-height: 1;
}

.quick-log-tile .tile-value.empty {
  color: var(--text-tertiary);
  font-size: 16px;
}

/* --- Stat Block -------------------------------------------- */
.stat-block {
  margin-bottom: 4px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.stat-hero {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1;
}

.stat-unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 4px;
  letter-spacing: 0;
}

.stat-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* --- Integration Status ------------------------------------ */
.integration-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.connected { background: var(--positive); }
.status-dot.disconnected { background: var(--text-tertiary); }

/* --- Fade Animations --------------------------------------- */
.fade-in {
  animation: fade-in 0.3s ease;
}

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

/* --- Toast ------------------------------------------------- */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: var(--bg);
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  white-space: nowrap;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Loading Spinner --------------------------------------- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-tertiary);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* --- Utility ----------------------------------------------- */
.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.text-warning { color: var(--warning); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-accent { color: var(--accent); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-2 { margin-top: 2px; }
.mt-4 { margin-top: 4px; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mt-28 { margin-top: 28px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* --- Plan Page --------------------------------------------- */
.flow-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 20px;
}

.flow-card-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.flow-card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.flow-actions {
  display: flex;
  gap: 10px;
}

.flow-actions .btn-primary,
.flow-actions .btn-secondary {
  flex: 1;
  height: 44px;
  font-size: 14px;
}

.day-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 10px;
}

.day-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.day-card-date {
  font-size: 14px;
  font-weight: 700;
}

.day-card-cals {
  font-size: 12px;
  color: var(--text-secondary);
}

.day-meal {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}

.day-meal:last-child {
  border-bottom: none;
}

.day-meal-slot {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  width: 56px;
  flex-shrink: 0;
}

.day-meal-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-meal-cals {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.day-meal-action {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  cursor: pointer;
}

.budget-bar {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.budget-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.budget-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
}

.budget-value {
  font-size: 13px;
  font-weight: 700;
}

.generate-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
}

.generate-btn-icon {
  font-size: 48px;
  opacity: 0.6;
}

.generate-btn-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* --- Responsive -------------------------------------------- */
@media (min-width: 481px) {
  .page {
    padding: 24px;
  }
}

/* --- Swipe Page Indicator Dots ----------------------------- */
.swipe-dots {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 4px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  z-index: 45;
  pointer-events: none;
}

.swipe-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-tertiary);
  opacity: 0.4;
  transition: opacity 0.2s, transform 0.2s;
}

.swipe-dot.active {
  opacity: 1;
  background: var(--text-primary);
  transform: scale(1.3);
}

/* --- Day View Overlay (pull down) -------------------------- */
.day-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.day-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.day-overlay-inner {
  width: 100%;
  max-width: 480px;
  padding: calc(var(--safe-top) + 20px) 20px 40px;
  transform: translateY(-30px);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.day-overlay.open .day-overlay-inner {
  transform: translateY(0);
}

/* Close handle */
.day-close-handle {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin: 0 auto 28px;
  cursor: pointer;
}

/* Time display */
.day-time {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -3px;
  text-align: center;
  line-height: 1;
  color: #fff;
}

.day-date {
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 6px;
}

/* Weather block */
.day-weather {
  margin-top: 28px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
}

.day-weather-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.day-weather-temp {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  color: #fff;
}

.day-weather-cond {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 2px;
}

.day-weather-hilo {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 4px;
}

.day-sun-row {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.day-sun-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

.day-sun-icon {
  font-size: 14px;
}

/* Schedule block */
.day-section {
  margin-top: 20px;
}

.day-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 8px;
}

.day-schedule-empty {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.4);
}

/* Snapshot stats */
.day-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.day-stat-card {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
}

.day-stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 4px;
}

.day-stat-value {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

/* Activity log */
.day-activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.day-activity-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.day-activity-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-activity-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  white-space: nowrap;
}

.day-activity-empty {
  padding: 12px 14px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
}

/* Quick Note input in day view */
.day-note-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}

.day-note-input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: #fff;
  outline: none;
  font-family: inherit;
}

.day-note-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.day-note-input:focus {
  border-color: var(--accent);
}

.day-note-btn {
  padding: 10px 16px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.day-note-btn:disabled {
  opacity: 0.5;
}

/* Close button */
.day-close-btn {
  display: block;
  margin: 28px auto 0;
  padding: 10px 28px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.day-close-btn:active {
  background: rgba(255, 255, 255, 0.15);
}

/* --- Quick Actions Panel (pull up) ------------------------- */
.quick-panel {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.quick-panel.open {
  opacity: 1;
  pointer-events: auto;
}

.quick-panel-sheet {
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  padding: 8px 20px calc(24px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.quick-panel.open .quick-panel-sheet {
  transform: translateY(0);
}

.quick-panel-handle {
  width: 36px;
  height: 4px;
  background: var(--text-tertiary);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.quick-panel-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.quick-panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.quick-panel-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 8px;
  background: var(--surface);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  border: none;
  color: var(--text-primary);
}

.quick-panel-tile:active {
  background: var(--surface-hover);
  transform: scale(0.96);
}

.quick-panel-tile-icon {
  font-size: 24px;
  line-height: 1;
}

.quick-panel-tile-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
}

.quick-panel-cancel {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.quick-panel-cancel:active {
  background: var(--surface-hover);
}

/* --- Settings Panel (swipe up) ----------------------------- */
.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.settings-panel.open {
  opacity: 1;
  pointer-events: auto;
}

.settings-panel-sheet {
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 20px calc(24px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.settings-panel.open .settings-panel-sheet {
  transform: translateY(0);
}

.settings-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 4px;
}

/* --- Expense Tracking ------------------------------------- */
.expense-month-btn {
  background: var(--surface);
  border: none;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 600;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.expense-month-btn:active {
  background: var(--surface-hover);
}

.expense-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  margin-left: -6px;
  margin-right: -6px;
  transition: background 0.15s;
}
.expense-bar:active {
  background: var(--surface-hover);
}

/* Drilldown modal */
.drilldown-tx-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  max-height: 55vh;
  -webkit-overflow-scrolling: touch;
}
.drilldown-tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}
.drilldown-tx-item:last-child {
  border-bottom: none;
}
.drilldown-tx-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drilldown-tx-date {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.drilldown-tx-amount {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.drilldown-recat-btn {
  background: var(--surface);
  border: 1px solid var(--divider);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.drilldown-recat-btn:active {
  background: var(--surface-hover);
}

.expense-bar-label {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-bar-amount {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}

.expense-bar-fill-track {
  height: 6px;
  background: var(--track);
  border-radius: 3px;
  flex: 1;
  min-width: 60px;
  overflow: hidden;
}

.expense-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.4s ease;
}

.transaction-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}

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

.transaction-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.transaction-info {
  flex: 1;
  min-width: 0;
}

.transaction-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transaction-date {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* --- Health: Sleep Hero ------------------------------------ */
.health-sleep-hero {
  background: none;
  padding: 16px 0;
  border-radius: 0;
}

.health-sleep-hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

/* --- Health: Expandable Cards ------------------------------ */
.health-expand-card {
  background: none;
  padding: 16px 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
}

.health-expand-card.expanded .health-expand-body {
  /* body max-height managed by JS */
}

.health-expand-header {
  /* layout set inline for flexibility */
}

.health-expand-body {
  /* overflow + transition set inline */
}

/* Touch feedback on header */
.health-expand-header:active,
.health-sleep-hero-header:active {
  opacity: 0.75;
}

.transaction-amount {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.transaction-amount.negative {
  color: var(--negative);
}

.transaction-amount.positive {
  color: var(--positive);
}

/* --- See More Button --------------------------------------- */
.see-more-btn {
  display: block;
  width: 100%;
  padding: 12px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  text-align: center;
  background: none;
  border: none;
  border-top: 1px solid var(--divider);
  cursor: pointer;
  margin-top: 4px;
}

.see-more-btn:active {
  opacity: 0.6;
}

/* --- Skeleton Loading Improvements ------------------------- */
.skeleton-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-row {
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-number {
  height: 36px;
  width: 100px;
  border-radius: 8px;
  display: inline-block;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

/* --- Grocery List ----------------------------------------- */
.grocery-category-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 12px 0 6px;
}

.grocery-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}

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

.grocery-check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s;
}

.grocery-check.checked {
  background: var(--positive);
  border-color: var(--positive);
}

.grocery-item-info {
  flex: 1;
}

.grocery-item-name {
  font-size: 14px;
  font-weight: 500;
}

.grocery-item-qty {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.grocery-item.checked-item .grocery-item-name {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

/* --- Nearby Badge ----------------------------------------- */
.grocery-nearby-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: var(--positive);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 2px 5px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

/* --- Recipe Detail Modal ----------------------------------- */
.recipe-detail-macros {
  display: flex;
  justify-content: space-around;
  padding: 16px 0;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--divider);
}

.recipe-macro-item {
  text-align: center;
}

.recipe-macro-value {
  font-size: 20px;
  font-weight: 700;
}

.recipe-macro-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.recipe-rating {
  text-align: center;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 16px;
}

.star-rating {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.star-btn {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.star-btn.active {
  color: var(--yellow);
}

.star-btn:active {
  transform: scale(1.2);
}

.recipe-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 12px 0 8px;
}

.recipe-ingredients-list {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 8px;
}

.recipe-ing-category {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-top: 8px;
  margin-bottom: 4px;
}

.recipe-ing-category:first-child {
  margin-top: 0;
}

.recipe-ing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--divider);
}

.recipe-ing-row:last-child {
  border-bottom: none;
}

.recipe-ing-name {
  font-size: 14px;
  flex: 1;
}

.recipe-ing-qty {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  margin-left: 12px;
}

.recipe-instructions {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 8px;
}

.recipe-step {
  font-size: 14px;
  line-height: 1.5;
  padding: 8px 0;
  padding-left: 24px;
  position: relative;
  border-bottom: 1px solid var(--divider);
  counter-increment: step;
}

.recipe-step:last-child {
  border-bottom: none;
}

.recipe-step::before {
  content: counter(step);
  position: absolute;
  left: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  top: 10px;
}

.recipe-instructions {
  counter-reset: step;
}

.recipe-actions {
  display: flex;
  gap: 10px;
  padding: 20px 0;
}

.recipe-actions .btn-primary,
.recipe-actions .btn-secondary {
  flex: 1;
  height: 48px;
  font-size: 14px;
}

/* --- Tasks ------------------------------------------------- */
.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}
.task-item:last-child {
  border-bottom: none;
}
.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--text-tertiary);
}
.task-item.overdue .task-title {
  color: var(--negative);
}
.task-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--text-tertiary);
  background: none;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.task-item.completed .task-check {
  border-color: var(--positive);
  color: var(--positive);
  background: rgba(0, 200, 83, 0.1);
}
.task-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-due {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.task-delete {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.task-info {
  flex: 1;
  min-width: 0;
}

/* --- No scrollbar on iOS overscroll ------------------------ */
@supports (-webkit-touch-callout: none) {
  body {
    -webkit-overflow-scrolling: touch;
  }
}

/* --- Workout Tab: Activity Categories ---------------------- */
.activity-categories {
  display: flex;
  flex-direction: column;
}

.activity-category {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.activity-category:last-child {
  border-bottom: none;
}

.activity-category:active {
  opacity: 0.6;
}

.activity-category-icon {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: var(--surface);
  flex-shrink: 0;
  color: var(--text-primary);
}

.activity-category-info {
  flex: 1;
  min-width: 0;
}

.activity-category-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.activity-category-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.activity-category-arrow {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* --- Workout Tab: Sub-view Header (back + title) ----------- */
.workout-sub-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.workout-back-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

.workout-back-btn:active {
  opacity: 0.6;
}

.workout-sub-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* --- Workout Tab: Muscle Group Grid (redesigned) ----------- */
.muscle-group-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.muscle-btn {
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

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

.muscle-btn.active {
  background: var(--text-primary);
  color: var(--bg);
  border-color: var(--text-primary);
}

.muscle-btn .muscle-count {
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 400;
}

.muscle-btn.active .muscle-count {
  color: var(--bg);
  opacity: 0.7;
}

/* --- Workout Tab: Preset Grid (Quick Start) ---------------- */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preset-btn {
  background: var(--surface);
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.preset-btn:active {
  background: var(--surface-hover);
}

.preset-btn .preset-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-top: 2px;
  display: block;
}

/* --- Workout Tab: Cardio/Flex/Mind Option Rows ------------- */
.routine-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.routine-option:last-child {
  border-bottom: none;
}

.routine-option:active {
  opacity: 0.6;
}

.routine-option-info {
  flex: 1;
  min-width: 0;
}

.routine-option-name {
  font-size: 15px;
  font-weight: 600;
}

.routine-option-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.routine-option-meta {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

/* --- Workout Tab: Duration Selector ------------------------ */
.duration-selector {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.duration-pill {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  -webkit-tap-highlight-color: transparent;
}

.duration-pill.active {
  background: var(--text-primary);
  color: var(--bg);
}

/* --- Workout Tab: Recent Workouts Collapsed Section -------- */
.recent-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.recent-section-header:active {
  opacity: 0.7;
}

.recent-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.recent-chevron {
  transition: transform 0.25s ease;
  color: var(--text-tertiary);
}

.recent-chevron.open {
  transform: rotate(90deg);
}

/* --- Workout Tab: Timed Routine Step Cards ------------------ */
.timed-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}

.timed-step:last-child {
  border-bottom: none;
}

.timed-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.timed-step-info {
  flex: 1;
  min-width: 0;
}

.timed-step-name {
  font-size: 14px;
  font-weight: 600;
}

.timed-step-notes {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.timed-step-duration {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* --- Workout Tab: Breathing Timer UI ----------------------- */
.breathing-timer {
  text-align: center;
  padding: 32px 20px;
}

.breathing-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 3px solid var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  transition: all 1s ease;
}

.breathing-circle.inhale {
  transform: scale(1.15);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.breathing-circle.hold {
  border-color: var(--positive);
  background: var(--positive-soft);
}

.breathing-circle.exhale {
  transform: scale(0.85);
  border-color: var(--blue);
  background: var(--blue-soft);
}

.breathing-instruction {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.breathing-count {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1;
  margin-top: 4px;
}

.breathing-cycle-count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 16px;
}

/* --- Cardio Activity Log Form ----------------------------- */
.cardio-log-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
}

.cardio-type-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cardio-type-pills .pill {
  padding: 6px 12px;
  font-size: 12px;
}

/* ============================================================
   Premium Features — Focus Timer, Sleep Debt, Weather Drilldown,
   Recovery Status, Coaching Nudges
   ============================================================ */

/* --- Focus Timer ------------------------------------------- */
.focus-timer-ring {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.focus-timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.focus-btn {
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

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

.focus-btn.active {
  background: var(--negative);
}

/* --- Weather Drilldown ------------------------------------- */
.weather-drilldown {
  padding: 0 16px;
  transition: max-height 0.3s ease;
}

.weather-drilldown.open {
  padding-top: 12px;
}

.weather-hourly-scroll {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.weather-hourly-scroll::-webkit-scrollbar {
  display: none;
}

.weather-hour-item {
  flex-shrink: 0;
  width: 56px;
  padding: 8px 4px;
  text-align: center;
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.weather-hour-item.weather-hour-current {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}

.weather-hour-time {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
}

.weather-hour-icon {
  font-size: 16px;
  line-height: 1;
}

.weather-hour-temp {
  font-size: 13px;
  font-weight: 700;
}

.weather-hour-detail {
  font-size: 9px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.weather-hour-detail.precip {
  color: var(--blue);
  font-weight: 600;
}

/* --- Recovery Status --------------------------------------- */
#recovery-section .progress-bar {
  height: 6px;
}

/* --- Coaching Nudges --------------------------------------- */
#coaching-section {
  padding: 0;
  background: none;
}

#coaching-nudges:empty + #coaching-section {
  display: none;
}

.coaching-nudge {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.coaching-nudge:last-child {
  margin-bottom: 0;
}

.coaching-nudge-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.coaching-nudge-icon {
  font-size: 16px;
  line-height: 1;
}

.coaching-nudge-title {
  font-size: 13px;
  font-weight: 700;
}

.coaching-nudge-message {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* --- SOMA Voice Button --- */
.soma-mic {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.soma-mic:active {
  background: var(--accent-soft);
}
.soma-mic.listening {
  background: var(--accent);
  color: white;
  animation: mic-pulse 1.5s ease infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 0, 122, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(255, 0, 122, 0); }
}

/* --- SOMA Toast --- */
.soma-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid var(--divider);
  z-index: 9999;
  animation: toast-in 0.3s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
