* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: pan-x pan-y;
}
:root {
  --bg: #f5f5f5;
  --bg-dark: #000000;
  --sidebar-bg: rgba(246, 246, 246, 0.8);
  --sidebar-border: rgba(0, 0, 0, 0.1);
  --glass: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(0, 0, 0, 0.06);
  --glass-solid: rgba(255, 255, 255, 0.85);
  --text: #1d1d1f;
  --text2: #3a3a3c;
  --text3: #86868b;
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --yellow: #ffcc00;
  --teal: #30b0c7;
  --indigo: #5856d6;
  --toolbar-h: 52px;
  --sidebar-w: 220px;
  --selection: rgba(0, 122, 255, 0.12);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --stripe: rgba(0, 0, 0, 0.015);
}
html,
body {
  height: 100%;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Text",
    "Helvetica Neue",
    sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* === Mac App Layout === */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--toolbar-h) 1fr;
  height: 100%;
  overflow: hidden;
}

/* Toolbar */
.toolbar {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: linear-gradient(180deg, #d8dde4 0%, #b8bfc8 50%, #a8b0ba 100%);
  border-bottom: 1px solid #8a929c;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  -webkit-app-region: drag;
  z-index: 20;
}
.toolbar h1 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.toolbar-subtitle {
  font-size: 11px;
  color: var(--text3);
  margin-left: 2px;
}
.toolbar-spacer {
  flex: 1;
}
.toolbar-date {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  -webkit-app-region: no-drag;
}
.btn-gen {
  -webkit-app-region: no-drag;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid #b0b0b0;
  background: linear-gradient(180deg, #fafafa 0%, #e8e8e8 50%, #d4d4d4 100%);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: default;
  font-family: inherit;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: all 0.1s;
  line-height: 1.4;
}
.btn-gen:hover {
  background: linear-gradient(180deg, #fff 0%, #efefef 50%, #dcdcdc 100%);
}
.btn-gen:active {
  background: linear-gradient(180deg, #d0d0d0 0%, #e0e0e0 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}
.btn-gen-primary {
  -webkit-app-region: no-drag;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid #b0b0b0;
  background: linear-gradient(180deg, #fafafa 0%, #e8e8e8 50%, #d4d4d4 100%);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: default;
  font-family: inherit;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: all 0.1s;
  line-height: 1.4;
}
.btn-gen-primary:hover {
  background: linear-gradient(180deg, #fff 0%, #efefef 50%, #dcdcdc 100%);
}
.btn-gen-primary:active {
  background: linear-gradient(180deg, #d0d0d0 0%, #e0e0e0 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}
.btn-settings {
  -webkit-app-region: no-drag;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid #b0b0b0;
  background: linear-gradient(180deg, #fafafa 0%, #e8e8e8 50%, #d4d4d4 100%);
  color: var(--text3);
  font-size: 13px;
  cursor: default;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: all 0.1s;
}
.btn-settings:hover {
  background: linear-gradient(180deg, #fff 0%, #efefef 50%, #dcdcdc 100%);
  color: var(--text2);
}
.btn-settings:active {
  background: linear-gradient(180deg, #d0d0d0 0%, #e0e0e0 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}
.btn-settings-mobile {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid #b0b0b0;
  background: linear-gradient(180deg, #fafafa 0%, #e8e8e8 50%, #d4d4d4 100%);
  color: var(--text3);
  font-size: 15px;
  cursor: default;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  padding-bottom: 1px;
}
.btn-settings-mobile:active {
  background: linear-gradient(180deg, #d0d0d0 0%, #e0e0e0 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}
.mobile-header-title {
  flex: 1;
  text-align: center;
}

/* Sidebar */
.sidebar {
  grid-column: 1;
  grid-row: 2;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 0.5px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 12px 10px;
  user-select: none;
}
.sidebar-section {
  margin-bottom: 16px;
}
.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  padding: 4px 10px 6px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 400;
  cursor: default;
  font-family: inherit;
  width: 100%;
  text-align: left;
  transition: background 0.1s;
  line-height: 1.4;
}
.sidebar-item:hover {
  background: rgba(0, 0, 0, 0.04);
}
.sidebar-item.active {
  background: var(--selection);
  color: var(--blue);
  font-weight: 600;
}
.sidebar-icon {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
}
.sidebar-icon::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.05) 100%);
  border-radius: 5px 5px 0 0;
  pointer-events: none;
}
.sidebar-day-indicator {
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Main content area */
.main {
  grid-column: 2;
  grid-row: 1 / -1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: calc(var(--toolbar-h) + 20px) 28px 28px;
  background:
    repeating-linear-gradient(
      90deg,
      var(--bg) 0px,
      var(--bg) 7px,
      var(--stripe) 7px,
      var(--stripe) 10px
    ),
    var(--bg);
}

/* Content sections */
.section-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

/* Cards */
.card {
  background: var(--glass-solid);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 10px;
  box-shadow: none;
  margin-bottom: 12px;
}

/* Two-column layout for plan and summary views */
@media (min-width: 768px) {
  .plan-columns {
    display: flex;
    gap: 16px;
    align-items: flex-start;
  }
  .plan-col-left {
    width: 320px;
    flex-shrink: 0;
    position: sticky;
  }
  .plan-col-right {
    flex: 1;
    min-width: 0;
  }
}

/* Macro card */
.macro-card {
  padding: 16px 18px;
}
.macro-label {
  font-size: 13px;
  color: var(--text3);
  font-weight: 600;
  margin-bottom: 10px;
  text-transform: uppercase;
}
.macro-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.macro-row span:first-child {
  font-size: 11px;
  color: var(--text3);
  width: 56px;
  font-weight: 600;
  flex-shrink: 0;
}
.macro-bar {
  flex: 1;
  height: 8px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  overflow: hidden;
}
.macro-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.macro-val {
  font-size: 11px;
  color: var(--text3);
  min-width: 62px;
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.macro-val.over {
  color: var(--red);
  font-weight: 700;
}

/* Meal slot */
.meal-slot {
  padding: 0;
}
.meal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
}
.meal-title {
  font-size: 13px;
  color: var(--text3);
  font-weight: 600;
  text-transform: uppercase;
}
.btn-add {
  padding: 3px 12px;
  border-radius: 5px;
  border: 1px solid #1a6dcc;
  background: linear-gradient(180deg, #4a9be8 0%, #2b7de9 50%, #1a6dcc 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  cursor: default;
  font-family: inherit;
  transition: all 0.1s;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  text-shadow: 0 -0.5px 0 rgba(0, 0, 0, 0.2);
}
.btn-add:hover {
  background: linear-gradient(180deg, #5aa5ed 0%, #3388f0 50%, #2078d8 100%);
}
.btn-add:active {
  background: linear-gradient(180deg, #1a6dcc 0%, #2b7de9 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}
.meal-empty {
  color: var(--text3);
  font-size: 12px;
  text-align: center;
  padding: 16px 0;
  opacity: 0.5;
}
.meal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
}
.meal-item + .meal-item {
  border-top: 0.5px solid rgba(0, 0, 0, 0.05);
}
.src-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.item-info {
  flex: 1;
  min-width: 0;
}
.item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-macros {
  font-size: 10px;
  color: var(--text3);
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}
.btn-rm {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid #c0302a;
  background: linear-gradient(180deg, #f27a6a 0%, #e5453a 50%, #c0302a 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.1s;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-shadow: 0 -0.5px 0 rgba(0, 0, 0, 0.2);
}
.btn-rm:hover {
  background: linear-gradient(180deg, #f58a7c 0%, #ea5548 50%, #cc3a33 100%);
  color: #fff;
}
.btn-rm:active {
  background: linear-gradient(180deg, #c0302a 0%, #e5453a 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Summary view */
.summary-card {
  padding: 16px 18px;
}
.breakdown-list {
  overflow: hidden;
}
.breakdown-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: default;
  font-family: inherit;
  transition: background 0.1s;
}
.breakdown-row:hover {
  background: rgba(0, 0, 0, 0.03);
}
.breakdown-row + .breakdown-row {
  border-top: 0.5px solid rgba(0, 0, 0, 0.05);
}
.breakdown-day {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  width: 18px;
}
.breakdown-bar {
  flex: 1;
  height: 6px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 3px;
  overflow: hidden;
}
.breakdown-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}
.breakdown-val {
  font-size: 11px;
  color: var(--text3);
  min-width: 86px;
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.source-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.source-row .src-dot {
  width: 8px;
  height: 8px;
}
.source-label {
  font-size: 13px;
  color: var(--text2);
  flex: 1;
  font-weight: 500;
}
.source-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.source-unit {
  font-size: 10px;
  color: var(--text3);
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
}
.overlay.open {
  display: flex;
  align-items: center;
  justify-content: center;
}
.overlay-bg {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Sheet - now a centered modal on desktop */
.sheet {
  position: relative;
  z-index: 1;
  width: 400px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(50px) saturate(200%);
  -webkit-backdrop-filter: blur(50px) saturate(200%);
  border-radius: 12px;
  border: 0.5px solid rgba(0, 0, 0, 0.1);
  padding: 24px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.2),
    0 0 0 0.5px rgba(0, 0, 0, 0.05);
  animation: modalIn 0.2s cubic-bezier(0.32, 0.72, 0, 1);
}
.sheet-handle {
  display: none;
}
@keyframes modalIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.sheet h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 20px;
}
.freq-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.freq-label {
  font-size: 13px;
  color: var(--text2);
}
.freq-val {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}
/* iOS 6 style range slider */
.sheet input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  margin-bottom: 4px;
  background: transparent;
  cursor: default;
}
.sheet input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, transparent 40%),
    linear-gradient(to right, #1b6ef3 0%, #4ca0fe var(--fill), #b0b0b0 var(--fill), #d8d8d8 100%);
  border: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.35),
    inset 0 0 2px rgba(0, 0, 0, 0.1),
    0 1px 0 rgba(255, 255, 255, 0.7);
}
.sheet input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 30px;
  height: 20px;
  margin-top: -7px;
  border-radius: 10px;
  background:
    radial-gradient(
      ellipse 70% 50% at 50% 25%,
      rgba(255, 255, 255, 0.9) 0%,
      rgba(255, 255, 255, 0) 100%
    ),
    linear-gradient(180deg, #fdfdfd 0%, #f0f0f0 20%, #d8d8d8 50%, #c0c0c0 80%, #cfcfcf 100%);
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 1px rgba(0, 0, 0, 0.05);
}
.sheet input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, transparent 40%),
    linear-gradient(to right, #1b6ef3 0%, #4ca0fe var(--fill), #b0b0b0 var(--fill), #d8d8d8 100%);
  border: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.35),
    inset 0 0 2px rgba(0, 0, 0, 0.1),
    0 1px 0 rgba(255, 255, 255, 0.7);
}
.sheet input[type="range"]::-moz-range-thumb {
  width: 30px;
  height: 20px;
  border-radius: 10px;
  background:
    radial-gradient(
      ellipse 70% 50% at 50% 25%,
      rgba(255, 255, 255, 0.9) 0%,
      rgba(255, 255, 255, 0) 100%
    ),
    linear-gradient(180deg, #fdfdfd 0%, #f0f0f0 20%, #d8d8d8 50%, #c0c0c0 80%, #cfcfcf 100%);
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 1px rgba(0, 0, 0, 0.05);
}
.freq-hints {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text3);
  margin-bottom: 16px;
}
.targets-section {
  margin-bottom: 16px;
}
.target-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.target-label {
  font-size: 12px;
  color: var(--text2);
  width: 64px;
  font-weight: 600;
  flex-shrink: 0;
}
.target-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.target-input {
  width: 70px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  background: linear-gradient(180deg, #e8e8e8 0%, #fff 30%, #fff 100%);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  color: var(--text);
  -moz-appearance: textfield;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.15),
    inset 0 0 1px rgba(0, 0, 0, 0.05),
    0 1px 0 rgba(255, 255, 255, 0.7);
}
.target-input::-webkit-inner-spin-button,
.target-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.target-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.15),
    0 0 0 2px rgba(0, 122, 255, 0.15);
}
.target-step-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid #b0b0b0;
  background: linear-gradient(180deg, #fafafa 0%, #e8e8e8 50%, #d4d4d4 100%);
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  cursor: default;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.target-step-btn:hover {
  background: linear-gradient(180deg, #fff 0%, #efefef 50%, #dcdcdc 100%);
}
.target-step-btn:active {
  background: linear-gradient(180deg, #d0d0d0 0%, #e0e0e0 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}
.target-unit {
  font-size: 11px;
  color: var(--text3);
  width: 28px;
  flex-shrink: 0;
}
.target-reset-btn {
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #b0b0b0;
  background: linear-gradient(180deg, #fafafa 0%, #e8e8e8 50%, #d4d4d4 100%);
  color: var(--text3);
  font-size: 11px;
  font-weight: 500;
  cursor: default;
  font-family: inherit;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.target-reset-btn:hover {
  background: linear-gradient(180deg, #fff 0%, #efefef 50%, #dcdcdc 100%);
  color: var(--blue);
}
.target-reset-btn:active {
  background: linear-gradient(180deg, #d0d0d0 0%, #e0e0e0 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}
.size-section {
  margin-bottom: 16px;
}
.size-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.size-meal-label {
  font-size: 12px;
  color: var(--text2);
  width: 36px;
  font-weight: 600;
  flex-shrink: 0;
}
.size-btns {
  display: flex;
  gap: 4px;
  flex: 1;
}
.size-btn {
  flex: 1;
  padding: 5px 0;
  border-radius: 6px;
  border: 0.5px solid rgba(0, 0, 0, 0.15);
  background: linear-gradient(180deg, #fafafa 0%, #e8e8e8 50%, #d4d4d4 100%);
  color: var(--text2);
  font-size: 11px;
  font-weight: 500;
  cursor: default;
  font-family: inherit;
  transition: all 0.1s;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.size-btn:hover {
  background: linear-gradient(180deg, #fff 0%, #efefef 50%, #dcdcdc 100%);
}
.size-btn.active {
  background: linear-gradient(180deg, #c8d8ec 0%, #d6e4f4 100%);
  color: var(--blue);
  font-weight: 600;
  border-color: rgba(0, 122, 255, 0.3);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}
.sheet-btns {
  display: flex;
  gap: 10px;
}
.btn-clear {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #b0b0b0;
  background: linear-gradient(180deg, #fafafa 0%, #e8e8e8 50%, #d4d4d4 100%);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: default;
  font-family: inherit;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.btn-clear:hover {
  background: linear-gradient(180deg, #fff 0%, #efefef 50%, #dcdcdc 100%);
}
.btn-clear:active {
  background: linear-gradient(180deg, #d0d0d0 0%, #e0e0e0 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}
.btn-generate {
  flex: 2;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #1a6dcc;
  background: linear-gradient(180deg, #4a9be8 0%, #2b7de9 50%, #1a6dcc 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: default;
  font-family: inherit;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  text-shadow: 0 -0.5px 0 rgba(0, 0, 0, 0.2);
}
.btn-generate:hover {
  background: linear-gradient(180deg, #5aa5ed 0%, #3388f0 50%, #2078d8 100%);
}
.btn-generate:active {
  background: linear-gradient(180deg, #1a6dcc 0%, #2b7de9 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Picker - reuses .sheet styling */
.picker {
  display: flex;
  flex-direction: column;
  width: 480px;
  max-width: 90vw;
  height: 70vh;
  max-height: 700px;
  padding: 0;
  overflow: hidden;
}
.picker-header {
  padding: 12px 0;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
}
.picker-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 0 16px;
}
.btn-back {
  background: linear-gradient(180deg, #fafafa 0%, #e8e8e8 50%, #d4d4d4 100%);
  border: 1px solid #b0b0b0;
  border-radius: 6px;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: default;
  padding: 6px 10px;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 2px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: all 0.1s;
}
.btn-back:hover {
  background: linear-gradient(180deg, #fff 0%, #efefef 50%, #dcdcdc 100%);
  text-decoration: none;
}
.btn-back:active {
  background: linear-gradient(180deg, #d0d0d0 0%, #e0e0e0 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}
.picker-search {
  flex: 1;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  background: linear-gradient(180deg, #e8e8e8 0%, #fff 30%, #fff 100%);
  font-size: 13px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.15),
    inset 0 0 1px rgba(0, 0, 0, 0.05),
    0 1px 0 rgba(255, 255, 255, 0.7);
}
.picker-search:focus {
  border-color: var(--blue);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.15),
    0 0 0 2px rgba(0, 122, 255, 0.15);
}
.picker-filters {
  display: flex;
  gap: 4px;
  padding: 0 16px 4px;
  overflow-x: auto;
}
.filter-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 0.5px solid rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  background: linear-gradient(180deg, #fafafa 0%, #e8e8e8 50%, #d4d4d4 100%);
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  cursor: default;
  font-family: inherit;
  transition: all 0.1s;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.filter-btn.active {
  background: linear-gradient(180deg, #c8d8ec 0%, #d6e4f4 100%);
  color: var(--blue);
  font-weight: 600;
  border-color: rgba(0, 122, 255, 0.3);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}
.filter-btn:hover:not(.active) {
  background: linear-gradient(180deg, #fff 0%, #efefef 50%, #dcdcdc 100%);
}
.picker-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0 20px;
}
.picker-count {
  font-size: 10px;
  color: var(--text3);
  font-weight: 600;
  margin-bottom: 6px;
  padding: 0 16px;
  text-transform: uppercase;
}
.picker-items {
  overflow: hidden;
}
.picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: none;
  background: var(--glass-solid);
  width: 100%;
  text-align: left;
  cursor: default;
  font-family: inherit;
  transition: background 0.1s;
}
.picker-item + .picker-item {
  border-top: 0.5px solid rgba(0, 0, 0, 0.05);
}
.picker-item:hover {
  background: rgba(0, 122, 255, 0.04);
}
.picker-item:active {
  background: rgba(0, 122, 255, 0.08);
}
.pi-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pi-macros {
  font-size: 10px;
  color: var(--text3);
  margin-top: 1px;
}
.pi-fat {
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.fat-low {
  color: var(--green);
}
.fat-mid {
  color: var(--orange);
}
.fat-high {
  color: var(--red);
}

/* Data view full-screen layout */
.main.main-data {
  padding: var(--toolbar-h) 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.data-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}
.data-toolbar-count {
  font-size: 13px;
  color: var(--text3);
  font-weight: 500;
  white-space: nowrap;
  margin-left: auto;
  width: 60px;
  text-align: right;
  flex-shrink: 0;
}
.data-toolbar-search {
  flex: 1;
  max-width: 260px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  background: linear-gradient(180deg, #e8e8e8 0%, #fff 30%, #fff 100%);
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.15),
    inset 0 0 1px rgba(0, 0, 0, 0.05),
    0 1px 0 rgba(255, 255, 255, 0.7);
}
.data-toolbar-search:focus {
  border-color: var(--blue);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.15),
    0 0 0 2px rgba(0, 122, 255, 0.15);
}

.data-disclaimer {
  font-size: 11px;
  color: var(--text3);
  padding: 4px 12px 0;
}

/* Data table */
.data-table-wrap {
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}
.data-table th {
  position: sticky;
  top: 0;
  background: var(--glass-solid);
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  cursor: default;
  user-select: none;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
}
.data-table th.th-active {
  color: var(--blue);
}
.data-table td {
  padding: 6px 12px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.04);
  color: var(--text);
}
.data-table td.td-name {
  font-weight: 500;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table tbody tr:last-child td {
  border-bottom: none;
}
.data-table tbody tr:hover td {
  background: rgba(0, 122, 255, 0.03);
}

/* Mobile data sort bar */
.data-sort-bar {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  overflow-x: auto;
  background: linear-gradient(180deg, #c8cdd4 0%, #b8bfc8 100%);
  border-bottom: 1px solid #8a929c;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}
.data-sort-btn {
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: linear-gradient(180deg, #fafafa 0%, #e8e8e8 50%, #d4d4d4 100%);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text2);
  white-space: nowrap;
  cursor: default;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.data-sort-btn.data-sort-active {
  background: linear-gradient(180deg, #0055bb 0%, #0062d0 40%, #007aff 100%);
  color: #fff;
  font-weight: 600;
  border-color: #004a9e;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.35),
    inset 0 1px 1px rgba(0, 0, 0, 0.2),
    0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Mobile data card list */
.data-card-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 calc(56px + var(--safe-b));
}
.data-card {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.5);
}
.data-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.data-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.data-card-source {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
  flex-shrink: 0;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.data-card-macros {
  display: flex;
  gap: 3px;
}
.data-card-macro {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 0 4px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.15) 100%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.data-card-macro-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.data-card-macro-lbl {
  font-size: 9px;
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.data-card-cat {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* === Dark mode === */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --sidebar-bg: rgba(18, 18, 18, 0.9);
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --glass: rgba(28, 28, 30, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-solid: rgba(22, 22, 24, 0.85);
    --text: #f5f5f7;
    --text2: #c7c7cc;
    --text3: #86868b;
    --selection: rgba(0, 122, 255, 0.2);
    --stripe: rgba(255, 255, 255, 0.015);
  }
  .toolbar {
    background: linear-gradient(180deg, #3a3d42 0%, #28292e 50%, #1e1f23 100%);
    border-bottom-color: #111;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .mobile-header {
    background: linear-gradient(180deg, #3a3d42 0%, #28292e 50%, #1e1f23 100%);
    border-bottom-color: #111;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .mobile-tab-bar {
    background: linear-gradient(180deg, #3a3d42 0%, #28292e 50%, #1e1f23 100%);
    border-top-color: #111;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .btn-gen {
    background: linear-gradient(180deg, #3a3a3c 0%, #2a2a2c 50%, #1c1c1e 100%);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text);
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.5),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .btn-gen:hover {
    background: linear-gradient(180deg, #444 0%, #333 50%, #262628 100%);
  }
  .btn-gen:active {
    background: linear-gradient(180deg, #1a1a1c 0%, #2a2a2c 100%);
  }
  .btn-settings {
    background: linear-gradient(180deg, #3a3a3c 0%, #2a2a2c 50%, #1c1c1e 100%);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text3);
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.5),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .btn-settings:hover {
    background: linear-gradient(180deg, #444 0%, #333 50%, #262628 100%);
    color: var(--text2);
  }
  .btn-settings:active {
    background: linear-gradient(180deg, #1a1a1c 0%, #2a2a2c 100%);
  }
  .btn-gen-primary {
    background: linear-gradient(180deg, #3a3a3c 0%, #2a2a2c 50%, #1c1c1e 100%);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text);
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.5),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .btn-gen-primary:hover {
    background: linear-gradient(180deg, #444 0%, #333 50%, #262628 100%);
  }
  .btn-gen-primary:active {
    background: linear-gradient(180deg, #1a1a1c 0%, #2a2a2c 100%);
  }
  .btn-settings-mobile {
    background: linear-gradient(180deg, #3a3a3c 0%, #2a2a2c 50%, #1c1c1e 100%);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text3);
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.5),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .btn-settings-mobile:active {
    background: linear-gradient(180deg, #1a1a1c 0%, #2a2a2c 100%);
  }
  .btn-back {
    background: linear-gradient(180deg, #3a3a3c 0%, #2a2a2c 50%, #1c1c1e 100%);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text2);
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.5),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .btn-back:hover {
    background: linear-gradient(180deg, #444 0%, #333 50%, #262628 100%);
  }
  .btn-back:active {
    background: linear-gradient(180deg, #1a1a1c 0%, #2a2a2c 100%);
  }
  .card {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: none;
  }
  .macro-bar {
    background: rgba(255, 255, 255, 0.06);
  }
  .meal-item + .meal-item {
    border-top-color: rgba(255, 255, 255, 0.06);
  }
  .btn-add {
    background: linear-gradient(180deg, #4490d0 0%, #2570d4 50%, #1560b8 100%);
    border-color: #1254a0;
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }
  .btn-rm {
    background: linear-gradient(180deg, #d4564a 0%, #c0302a 50%, #a02520 100%);
    border-color: #8a1f1a;
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }
  .btn-rm:hover {
    background: linear-gradient(180deg, #de6458 0%, #cc3a33 50%, #aa2a24 100%);
  }
  .btn-rm:active {
    background: linear-gradient(180deg, #a02520 0%, #c0302a 100%);
  }
  .meal-header {
    border-bottom-color: rgba(255, 255, 255, 0.06);
  }
  .picker-header {
    border-bottom-color: rgba(255, 255, 255, 0.06);
  }
  .picker {
    background: var(--bg);
  }
  .picker-search {
    background: linear-gradient(180deg, #1a1a1c 0%, #2a2a2c 30%, #2a2a2c 100%);
    border-color: rgba(0, 0, 0, 0.5);
    color: var(--text);
    box-shadow:
      inset 0 1px 3px rgba(0, 0, 0, 0.4),
      0 1px 0 rgba(255, 255, 255, 0.06);
  }
  .picker-search:focus {
    border-color: var(--blue);
  }
  .filter-btn {
    background: linear-gradient(180deg, #4a4a4c 0%, #3a3a3c 50%, #2c2c2e 100%);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text3);
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .filter-btn:hover:not(.active) {
    background: linear-gradient(180deg, #525254 0%, #424244 50%, #343436 100%);
  }
  .filter-btn.active {
    background: linear-gradient(180deg, #1a3a5c 0%, #243f5e 100%);
    border-color: rgba(0, 122, 255, 0.4);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
  }
  .picker-item {
    background: var(--glass-solid);
  }
  .picker-item + .picker-item {
    border-top-color: rgba(255, 255, 255, 0.06);
  }
  .picker-item:hover {
    background: rgba(0, 122, 255, 0.08);
  }
  .sheet {
    background: rgba(22, 22, 24, 0.95);
    border-color: rgba(255, 255, 255, 0.08);
  }
  .sheet input[type="range"]::-webkit-slider-runnable-track {
    background:
      linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, transparent 40%),
      linear-gradient(to right, #0a4fcc 0%, #2979ff var(--fill), #1a1a1c var(--fill), #323234 100%);
    border: 1px solid rgba(0, 0, 0, 0.7);
    box-shadow:
      inset 0 2px 4px rgba(0, 0, 0, 0.6),
      inset 0 0 2px rgba(0, 0, 0, 0.3),
      0 1px 0 rgba(255, 255, 255, 0.06);
  }
  .sheet input[type="range"]::-webkit-slider-thumb {
    background:
      radial-gradient(
        ellipse 70% 50% at 50% 25%,
        rgba(255, 255, 255, 0.5) 0%,
        rgba(255, 255, 255, 0) 100%
      ),
      linear-gradient(180deg, #e0e0e0 0%, #c8c8c8 20%, #a8a8a8 50%, #909090 80%, #a0a0a0 100%);
    border: 1px solid rgba(0, 0, 0, 0.6);
    box-shadow:
      0 3px 6px rgba(0, 0, 0, 0.6),
      0 1px 2px rgba(0, 0, 0, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.7),
      inset 0 -1px 1px rgba(0, 0, 0, 0.1);
  }
  .sheet input[type="range"]::-moz-range-track {
    background:
      linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, transparent 40%),
      linear-gradient(to right, #0a4fcc 0%, #2979ff var(--fill), #1a1a1c var(--fill), #323234 100%);
    border: 1px solid rgba(0, 0, 0, 0.7);
    box-shadow:
      inset 0 2px 4px rgba(0, 0, 0, 0.6),
      inset 0 0 2px rgba(0, 0, 0, 0.3),
      0 1px 0 rgba(255, 255, 255, 0.06);
  }
  .sheet input[type="range"]::-moz-range-thumb {
    background:
      radial-gradient(
        ellipse 70% 50% at 50% 25%,
        rgba(255, 255, 255, 0.5) 0%,
        rgba(255, 255, 255, 0) 100%
      ),
      linear-gradient(180deg, #e0e0e0 0%, #c8c8c8 20%, #a8a8a8 50%, #909090 80%, #a0a0a0 100%);
    border: 1px solid rgba(0, 0, 0, 0.6);
    box-shadow:
      0 3px 6px rgba(0, 0, 0, 0.6),
      0 1px 2px rgba(0, 0, 0, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.7),
      inset 0 -1px 1px rgba(0, 0, 0, 0.1);
  }
  .target-input {
    background: linear-gradient(180deg, #1a1a1c 0%, #2a2a2c 30%, #2a2a2c 100%);
    border-color: rgba(0, 0, 0, 0.5);
    color: var(--text);
    box-shadow:
      inset 0 1px 3px rgba(0, 0, 0, 0.4),
      0 1px 0 rgba(255, 255, 255, 0.06);
  }
  .target-step-btn {
    background: linear-gradient(180deg, #4a4a4c 0%, #3a3a3c 50%, #2c2c2e 100%);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text3);
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .target-step-btn:hover {
    background: linear-gradient(180deg, #525254 0%, #424244 50%, #343436 100%);
  }
  .target-step-btn:active {
    background: linear-gradient(180deg, #1a1a1c 0%, #2a2a2c 100%);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
  }
  .target-reset-btn {
    background: linear-gradient(180deg, #4a4a4c 0%, #3a3a3c 50%, #2c2c2e 100%);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text3);
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .target-reset-btn:hover {
    background: linear-gradient(180deg, #525254 0%, #424244 50%, #343436 100%);
  }
  .btn-clear {
    background: linear-gradient(180deg, #3a3a3c 0%, #2a2a2c 50%, #1c1c1e 100%);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text2);
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.5),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .btn-clear:hover {
    background: linear-gradient(180deg, #444 0%, #333 50%, #262628 100%);
  }
  .size-btn {
    background: linear-gradient(180deg, #4a4a4c 0%, #3a3a3c 50%, #2c2c2e 100%);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text3);
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .size-btn:hover {
    background: linear-gradient(180deg, #525254 0%, #424244 50%, #343436 100%);
  }
  .size-btn.active {
    background: linear-gradient(180deg, #1a3a5c 0%, #243f5e 100%);
    border-color: rgba(0, 122, 255, 0.4);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
  }
  .overlay-bg {
    background: rgba(0, 0, 0, 0.5);
  }
  .breakdown-row + .breakdown-row {
    border-top-color: rgba(255, 255, 255, 0.06);
  }
  .breakdown-row:hover {
    background: rgba(255, 255, 255, 0.04);
  }
  .data-toolbar {
    border-bottom-color: rgba(255, 255, 255, 0.06);
  }
  .data-toolbar-search {
    background: linear-gradient(180deg, #1a1a1c 0%, #2a2a2c 30%, #2a2a2c 100%);
    border-color: rgba(0, 0, 0, 0.5);
    color: var(--text);
    box-shadow:
      inset 0 1px 3px rgba(0, 0, 0, 0.4),
      0 1px 0 rgba(255, 255, 255, 0.06);
  }
  .data-toolbar-search:focus {
    border-color: var(--blue);
  }
  .data-table th {
    background: rgba(22, 22, 24, 0.95);
    border-bottom-color: rgba(255, 255, 255, 0.06);
  }
  .data-table td {
    border-bottom-color: rgba(255, 255, 255, 0.04);
    color: var(--text);
  }
  .data-table tbody tr:hover td {
    background: rgba(0, 122, 255, 0.06);
  }
  .data-sort-bar {
    background: linear-gradient(180deg, #35383d 0%, #26282d 50%, #1c1d22 100%);
    border-bottom-color: #111;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.06),
      0 1px 2px rgba(0, 0, 0, 0.3);
  }
  .data-sort-btn {
    background: linear-gradient(180deg, #4a4a4c 0%, #3a3a3c 50%, #2c2c2e 100%);
    border-color: rgba(0, 0, 0, 0.35);
    color: #9a9ea4;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .data-sort-btn.data-sort-active {
    background: linear-gradient(180deg, #004499 0%, #0055bb 40%, #0070ee 100%);
    color: #fff;
    border-color: #003377;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
    box-shadow:
      inset 0 2px 4px rgba(0, 0, 0, 0.4),
      inset 0 1px 1px rgba(0, 0, 0, 0.25),
      0 1px 0 rgba(255, 255, 255, 0.05);
  }
  .data-card {
    border-bottom-color: rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.03);
  }
  .data-card-source {
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
  }
  .data-card-macro {
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.08) 0%,
      rgba(255, 255, 255, 0.02) 100%
    );
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }
  .data-card-macro-lbl {
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
  }
  .data-card-cat {
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
  }
  .sidebar-item:hover {
    background: rgba(255, 255, 255, 0.06);
  }
  .picker-items {
  }
}

/* === Mobile responsive === */
@media (max-width: 767px) {
  :root {
    --toolbar-h: 0px;
    --sidebar-w: 0px;
  }
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  .toolbar {
    display: none;
  }
  .sidebar {
    display: none;
  }
  .main {
    grid-column: 1;
    grid-row: 1 / -1;
    padding: calc(max(env(safe-area-inset-top), 8px) + 48px) 16px calc(56px + var(--safe-b));
  }
  .main.main-plan {
    padding-top: 0;
  }
  .main.main-data {
    padding: calc(max(env(safe-area-inset-top), 8px) + 48px) 0 0;
  }
  .main.main-data .data-toolbar {
    padding: 10px 16px;
  }
  .main.main-data .data-toolbar-search {
    max-width: none;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 15px;
  }
  .main.main-data .data-toolbar-count {
    font-size: 14px;
  }
  .main.main-data .data-disclaimer {
    padding: 4px 16px 0;
  }
  .data-sort-bar {
    padding: 8px 16px;
    gap: 6px;
  }
  .data-sort-btn {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
  }
  .data-card {
    padding: 12px 16px;
  }
  .data-card-macros {
    gap: 4px;
  }
  .data-card-macro {
    padding: 6px 0 5px;
    border-radius: 8px;
  }
  /* Show mobile header */
  .mobile-header {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: max(env(safe-area-inset-top), 8px) 16px 8px;
    background: linear-gradient(180deg, #d8dde4 0%, #b8bfc8 50%, #a8b0ba 100%);
    border-bottom: 1px solid #8a929c;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
    z-index: 20;
  }
  .mobile-header .toolbar-date {
    font-size: 17px;
    font-weight: 700;
  }
  .mobile-header h1 {
    font-size: 17px;
    font-weight: 700;
  }
  .mobile-header p {
    font-size: 10px;
    color: var(--text3);
    margin-top: 1px;
  }
  /* Mobile day tabs */
  .mobile-day-tabs {
    display: flex;
    gap: 3px;
    padding: 6px 8px;
    padding-top: calc(max(env(safe-area-inset-top), 8px) + 48px + 6px);
    margin: 0 -16px 12px;
    background: linear-gradient(180deg, #c8cdd4 0%, #b0b7c0 50%, #a0a8b2 100%);
    border-bottom: 1px solid #8a929c;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.4),
      0 1px 2px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    position: sticky;
    top: env(safe-area-inset-top);
    z-index: 10;
  }
  .day-tab {
    flex: 1;
    padding: 6px 0 5px;
    border-radius: 5px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.3) 0%,
      rgba(255, 255, 255, 0.05) 100%
    );
    color: #4a5060;
    font-size: 13px;
    font-weight: 600;
    cursor: default;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-family: inherit;
    transition: all 0.15s;
    min-width: 0;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.4),
      0 1px 1px rgba(0, 0, 0, 0.08);
  }
  .day-tab.active {
    background: linear-gradient(180deg, #0055bb 0%, #0062d0 40%, #007aff 100%);
    color: #fff;
    font-weight: 700;
    border-color: #004a9e;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3);
    box-shadow:
      inset 0 2px 4px rgba(0, 0, 0, 0.35),
      inset 0 1px 1px rgba(0, 0, 0, 0.2),
      0 1px 0 rgba(255, 255, 255, 0.1);
  }
  .day-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.2);
  }
  /* Mobile bottom tab bar */
  .mobile-tab-bar {
    grid-column: 1;
    grid-row: 3;
    display: flex;
    padding: 6px 8px calc(6px + var(--safe-b));
    background: linear-gradient(180deg, #d8dde4 0%, #b8bfc8 50%, #a8b0ba 100%);
    border-top: 1px solid #8a929c;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
    z-index: 20;
  }
  .tab-btn {
    flex: 1;
    padding: 6px 0;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #6a7078;
    font-size: 10px;
    font-weight: 500;
    cursor: default;
    font-family: inherit;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  }
  .tab-btn i {
    font-size: 22px;
    filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.4));
    -webkit-text-stroke: 0.5px rgba(0, 0, 0, 0.1);
  }
  .tab-btn.active {
    color: #fff;
    font-weight: 600;
    text-shadow: none;
  }
  .tab-btn.active i {
    background: linear-gradient(180deg, #7cc0ff 0%, #007aff 60%, #0055cc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.3));
    -webkit-text-stroke: 0;
  }
  .section-title {
    font-size: 15px;
    margin-bottom: 16px;
  }
  .card {
    border-radius: 12px;
  }
  /* Meal slots */
  .meal-header {
    padding: 12px 16px;
  }
  .meal-item {
    gap: 12px;
    padding: 10px 16px;
  }
  .meal-empty {
    padding: 20px 0;
    font-size: 13px;
  }
  .item-macros {
    font-size: 11px;
    margin-top: 2px;
  }
  /* Macro card */
  .macro-card {
    padding: 16px;
  }
  .macro-row {
    gap: 12px;
    margin-bottom: 10px;
  }
  /* Summary */
  .summary-card {
    padding: 16px;
  }
  .breakdown-row {
    gap: 12px;
    padding: 12px 16px;
  }
  .source-row {
    gap: 12px;
    margin-bottom: 8px;
  }
  /* Modal goes to bottom sheet on mobile */
  .overlay.open {
    align-items: flex-end;
    justify-content: center;
  }
  .sheet {
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 14px 14px 0 0;
    padding: 20px 20px calc(20px + var(--safe-b));
    animation: sheetUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  }
  @keyframes sheetUp {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }
  .sheet h3 {
    margin-bottom: 20px;
  }
  .sheet-handle {
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(128, 128, 128, 0.3);
    border-radius: 2px;
    margin: 0 auto 16px;
  }
  .sheet-btns {
    gap: 12px;
  }
  /* Picker sheet */
  .picker {
    max-width: 100%;
    width: 100%;
    height: 85vh;
    max-height: 85vh;
    padding: 0;
  }
  .picker .sheet-handle {
    margin: 8px auto 0;
  }
  .picker-header {
    padding: 12px 0;
  }
  .picker-top {
    gap: 10px;
    margin-bottom: 12px;
    padding: 0 16px;
  }
  .picker-filters {
    gap: 6px;
    padding: 0 16px 6px;
  }
  .picker-list {
    padding: 12px 0 20px;
  }
  .picker-count {
    margin-bottom: 8px;
    padding: 0 16px;
  }
  .picker-item {
    gap: 12px;
    padding: 10px 16px;
  }
  /* Settings sheet */
  .targets-section {
    margin-bottom: 20px;
  }
  .target-row {
    gap: 12px;
    margin-bottom: 8px;
  }
  .target-input-wrap {
    gap: 6px;
  }
  .freq-row {
    margin-bottom: 10px;
  }
  .freq-hints {
    margin-bottom: 20px;
  }
  .size-section {
    margin-bottom: 20px;
  }
  .size-btns {
    gap: 6px;
  }
  /* Buttons */
  .btn-gen-primary {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
  }
  .btn-settings-mobile {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    font-size: 17px;
  }
  .btn-add {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
  }
  .btn-add:active {
    opacity: 1;
  }
  .btn-rm {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 14px;
  }
  .btn-back {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
  }
  .filter-btn {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
  }
  .target-input {
    width: 80px;
    padding: 8px 6px;
    border-radius: 8px;
    font-size: 14px;
  }
  .picker-search {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 15px;
  }
  .target-step-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    font-size: 16px;
  }
  .target-reset-btn {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
  }
  .size-btn {
    padding: 8px 0;
    border-radius: 8px;
    font-size: 13px;
  }
  .btn-clear,
  .btn-generate {
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
  }

  /* Hide scrollbars on mobile */
  * {
    scrollbar-width: none;
  }
  *::-webkit-scrollbar {
    display: none;
  }
}

/* Mobile dark mode */
@media (max-width: 767px) and (prefers-color-scheme: dark) {
  .mobile-header {
    background: linear-gradient(180deg, #3a3d42 0%, #28292e 50%, #1e1f23 100%);
    border-bottom-color: #111;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .mobile-day-tabs {
    background: linear-gradient(180deg, #35383d 0%, #26282d 50%, #1c1d22 100%);
    border-bottom-color: #111;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.06),
      0 1px 2px rgba(0, 0, 0, 0.3);
  }
  .day-tab {
    border-color: rgba(0, 0, 0, 0.35);
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.08) 0%,
      rgba(255, 255, 255, 0.02) 100%
    );
    color: #9a9ea4;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.06),
      0 1px 1px rgba(0, 0, 0, 0.2);
  }
  .day-tab.active {
    background: linear-gradient(180deg, #004499 0%, #0055bb 40%, #0070ee 100%);
    color: #fff;
    border-color: #003377;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
    box-shadow:
      inset 0 2px 4px rgba(0, 0, 0, 0.4),
      inset 0 1px 1px rgba(0, 0, 0, 0.25),
      0 1px 0 rgba(255, 255, 255, 0.05);
  }
  .mobile-tab-bar {
    background: linear-gradient(180deg, #3a3d42 0%, #28292e 50%, #1e1f23 100%);
    border-top-color: #111;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  .tab-btn {
    color: #8a8e94;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
  }
  .tab-btn i {
    filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.5));
    -webkit-text-stroke: 0.5px rgba(255, 255, 255, 0.05);
  }
  .tab-btn.active {
    color: #fff;
    text-shadow: none;
  }
  .tab-btn.active i {
    background: linear-gradient(180deg, #8ecfff 0%, #2890ff 60%, #0060dd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.3));
  }
}

/* Hide desktop-only elements on mobile */
@media (max-width: 767px) {
  .desktop-only {
    display: none !important;
  }
}
/* Hide mobile-only elements on desktop */
@media (min-width: 768px) {
  .mobile-only {
    display: none !important;
  }
}

/* Hover states for pointer devices */
@media (hover: hover) {
  .btn-gen-primary:hover {
    box-shadow:
      0 2px 8px rgba(0, 0, 0, 0.15),
      inset 0 1px 0 rgba(255, 255, 255, 0.6);
  }
}

/* Wider desktops */
@media (min-width: 1200px) {
  :root {
    --sidebar-w: 240px;
  }
  .main {
    padding: calc(var(--toolbar-h) + 24px) 40px 32px;
  }
}
