/* ==========================================================================
   家味轻食 · Daily Table — Apple-Style Minimal & Fluid Interface
   Crafted strictly with apple-design principles:
   - Translucent chrome & scroll-edge fade
   - Optical typography (size-specific tracking & leading)
   - Pointer-down immediate press response (no lag)
   - Generous negative space, low text density, progressive disclosure sheets
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-system);
  font-optical-sizing: auto;
  color: var(--ink-primary);
  background: var(--bg-canvas);
  line-height: 1.5;
  overflow-x: clip;
  transition: background-color 260ms ease, color 260ms ease;
}

.app-shell {
  transition: transform 340ms cubic-bezier(0.22, 1, 0.36, 1), opacity 300ms ease;
  transform-origin: center top;
}

/* Subtle iOS depth push-back when a modal sheet is open (apple-design §12) */
body.has-sheet-open .app-shell {
  transform: scale(0.986);
}

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

.is-hidden {
  display: none !important;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2.5px solid var(--apple-blue);
  outline-offset: 2px;
}

button, input, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Unified SF-style crisp SVG stroke icons */
.icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.icon-sm { width: 15px; height: 15px; }
.icon-xs { width: 13px; height: 13px; }

/* ==========================================================================
   Pointer-Down Instant Feedback Buttons (apple-design §1)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border: none;
  border-radius: var(--r-pill);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: transform 95ms ease-out, background-color 140ms ease, color 140ms ease, opacity 140ms ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.965);
}

.btn-primary {
  background: var(--apple-blue);
  color: #FFFFFF;
}
.btn-primary:hover {
  background: var(--apple-blue-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--ink-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 0 0 0.5px var(--hairline-strong);
}
.btn-secondary:hover {
  background: var(--bg-surface-secondary);
}

.btn-quiet {
  background: var(--bg-fill-subtle);
  color: var(--ink-primary);
}
.btn-quiet:hover {
  background: var(--bg-fill-hover);
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 0.8125rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--bg-fill-subtle);
  color: var(--ink-secondary);
  transition: transform 95ms ease-out, background-color 140ms ease, color 140ms ease;
}
.icon-btn:hover {
  background: var(--bg-fill-hover);
  color: var(--ink-primary);
}
.icon-btn:active {
  transform: scale(0.94);
}

.text-btn {
  background: none;
  border: none;
  padding: 4px 8px;
  border-radius: var(--r-xs);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--apple-blue);
  transition: background-color 140ms ease, transform 90ms ease-out;
}
.text-btn:hover {
  background: var(--apple-blue-soft);
}
.text-btn:active {
  transform: scale(0.96);
}

/* ==========================================================================
   Translucent Floating Top Bar (apple-design §12 — Scroll edge fade, no hard border)
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--glass-chrome);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}

/* Subtle soft scroll-edge fade instead of a heavy 1px rule */
.app-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--header-fade) 15%, var(--header-fade) 85%, transparent);
  pointer-events: none;
}

.header-inner {
  max-width: 1220px;
  margin: 0 auto;
  height: 60px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--brand-bg);
  color: var(--brand-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 240ms ease, color 240ms ease;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
}

/* Apple Segmented Control with Spring Sliding Thumb */
.segmented {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--bg-seg-track);
  user-select: none;
}

.seg-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  border-radius: var(--r-pill);
  background: var(--bg-thumb);
  box-shadow: var(--shadow-thumb);
  pointer-events: none;
  opacity: 0;
  z-index: 0;
}

.seg-item {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  height: 30px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink-secondary);
  transition: color 140ms ease;
  white-space: nowrap;
}

.seg-item:hover {
  color: var(--ink-primary);
}

.seg-item.is-active {
  color: var(--ink-primary);
  font-weight: 600;
}

.segmented--compact .seg-item {
  height: 28px;
  padding: 0 11px;
  font-size: 0.78rem;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* Gout Guard Pill */
.gout-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--apple-green-soft);
  color: var(--apple-green);
  font-size: 0.78rem;
  font-weight: 600;
  transition: transform 95ms ease-out, background-color 160ms ease, color 160ms ease;
}
.gout-pill:active {
  transform: scale(0.96);
}
.gout-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--apple-green-vivid);
}

.gout-pill[aria-pressed="true"] {
  background: var(--apple-red-soft);
  color: var(--apple-red);
}
.gout-pill[aria-pressed="true"] .dot {
  background: var(--apple-red-vivid);
}

.prefs-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--bg-fill-subtle);
  color: var(--ink-primary);
  font-size: 0.78rem;
  font-weight: 500;
  transition: transform 95ms ease-out, background-color 140ms ease;
}
.prefs-btn:hover { background: var(--bg-fill-hover); }
.prefs-btn:active { transform: scale(0.96); }

.count-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--apple-blue);
  color: #FFFFFF;
  font-size: 0.68rem;
  font-weight: 600;
}

/* ==========================================================================
   Main Content Canvas
   ========================================================================== */
.app-main {
  max-width: 1220px;
  margin: 0 auto;
  padding: 28px 24px 72px;
}

.view-section {
  display: none;
}
.view-section.is-active {
  display: block;
  animation: gentleReveal 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* ==========================================================================
   Top Day Hero — Clean, Minimal, Spacious
   ========================================================================== */
.day-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.day-hero-left {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.date-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.display-title {
  margin: 0;
  font-size: clamp(1.75rem, 2.5vw, 2.15rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em; /* apple-design §15: tighten large display text */
  color: var(--ink-primary);
}

.date-meta {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-secondary);
  letter-spacing: -0.01em;
}

/* Minimal Apple Calendar Weekday Circles */
.weekday-strip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.day-dot-btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: transform 95ms ease-out, background-color 140ms ease, color 140ms ease;
}

.day-dot-btn:hover {
  background: var(--bg-fill-subtle);
  color: var(--ink-primary);
}
.day-dot-btn:active {
  transform: scale(0.92);
}

.day-dot-btn.is-active {
  background: var(--day-active-bg);
  color: var(--day-active-ink);
  font-weight: 600;
}

.day-dot-btn.is-today::after {
  content: "";
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--apple-blue);
}
.day-dot-btn.is-active.is-today::after {
  background: var(--day-active-ink);
}

.day-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Subtle Acute Gout Strip (1 concise line only) */
.acute-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  margin-bottom: 20px;
  border-radius: var(--r-md);
  background: var(--apple-red-soft);
  color: var(--apple-red);
  font-size: 0.84rem;
  font-weight: 500;
}

/* ==========================================================================
   Two-Column Calm Workspace
   ========================================================================== */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(340px, 0.92fr);
  gap: 28px;
  align-items: start;
}

.meal-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.meal-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 4px 10px;
}

.meal-group-title {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em; /* apple-design §15: slight positive tracking on small labels */
  color: var(--ink-secondary);
}

.meal-group-hint {
  font-size: 0.78rem;
  color: var(--ink-tertiary);
}

.meal-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ==========================================================================
   Clean Apple Squircle Meal Card (Low Text, High Clarity)
   ========================================================================== */
.meal-card {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
  transition: transform 140ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 200ms ease;
  cursor: pointer;
}

.meal-card:hover {
  box-shadow: var(--shadow-card-hover);
}

.meal-card:active {
  transform: scale(0.992);
}

.meal-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.meal-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.role-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.role-tag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.role-tag--daughter { color: var(--apple-orange); }
.role-tag--daughter::before { background: var(--apple-orange-vivid); }

.role-tag--couple-b { color: var(--apple-blue); }
.role-tag--couple-b::before { background: var(--apple-blue); }

.role-tag--couple-l { color: var(--apple-green); }
.role-tag--couple-l::before { background: var(--apple-green-vivid); }

.purine-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--apple-green-soft);
  color: var(--apple-green);
}

.purine-chip--mid {
  background: var(--apple-orange-soft);
  color: var(--apple-orange);
}

.card-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--bg-fill-subtle);
  color: var(--ink-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  transition: transform 90ms ease-out, background-color 140ms ease, color 140ms ease;
}

.card-action-btn:hover {
  background: var(--bg-fill-hover);
  color: var(--ink-primary);
}
.card-action-btn:active {
  transform: scale(0.94);
}

.card-action-btn--fav.is-fav {
  color: var(--apple-red);
  background: var(--apple-red-soft);
}
.card-action-btn--fav.is-fav svg {
  fill: var(--apple-red);
}

/* Dish Title — Crisp, Concise, Spacious */
.meal-name {
  margin: 0 0 12px;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: -0.015em;
  color: var(--ink-primary);
}

/* Compact Scannable Bottom Row (Zero Paragraphs!) */
.meal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.meal-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--ink-secondary);
}

.stat-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.stat-item strong {
  color: var(--ink-primary);
  font-weight: 600;
}

.stat-sep {
  color: var(--hairline-strong);
}

.detail-cue {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--apple-blue);
}

/* ==========================================================================
   Unified Apple Health-Style Daily Metrics Card (Compact 3-Col)
   ========================================================================== */
.health-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.health-cell {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.health-cell + .health-cell::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 0.5px;
  background: var(--hairline-strong);
}

.health-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-secondary);
}

.health-num {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--ink-primary);
}

.health-num small {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-secondary);
  margin-left: 2px;
}

.health-sub {
  font-size: 0.76rem;
  color: var(--ink-secondary);
}

.water-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.water-track {
  height: 5px;
  border-radius: var(--r-pill);
  background: var(--bg-fill-subtle);
  overflow: hidden;
}

.water-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--r-pill);
  background: var(--apple-blue);
  transition: width 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.water-plus {
  border: none;
  border-radius: var(--r-pill);
  height: 24px;
  padding: 0 9px;
  background: var(--apple-blue-soft);
  color: var(--apple-blue);
  font-size: 0.74rem;
  font-weight: 600;
  transition: transform 90ms ease-out, background-color 140ms ease;
}
.water-plus:hover { background: rgba(0, 113, 227, 0.16); }
.water-plus:active { transform: scale(0.94); }

/* ==========================================================================
   Right Sticky Shopping List (Apple Reminders Aesthetic, Viewport-Safe)
   ========================================================================== */
.shopping-aside {
  position: sticky;
  top: 76px;
  z-index: var(--z-sticky);
}

.shopping-card {
  background: var(--bg-surface);
  border-radius: var(--r-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  max-height: calc(100dvh - 180px);
  min-height: 540px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shopping-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.shopping-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.shopping-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.shopping-count {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-secondary);
}

.shopping-scope-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.shopping-scope-wrap .segmented {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.shopping-scope-wrap .seg-item {
  padding: 0 4px;
  text-align: center;
}

/* Reminders-Style Scrollable List */
.reminders-list {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  padding-right: 2px;
}

.reminders-list::-webkit-scrollbar {
  width: 5px;
}
.reminders-list::-webkit-scrollbar-thumb {
  background: var(--hairline-strong);
  border-radius: 99px;
}

.rem-group {
  margin-bottom: 12px;
}
.rem-group:last-child {
  margin-bottom: 0;
}

.rem-group-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink-tertiary);
  margin: 0 0 4px 2px;
}

.rem-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 6px;
  border-bottom: 0.5px solid var(--hairline);
  transition: opacity 160ms ease;
}

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

.rem-row.is-owned {
  opacity: 0.42;
}

.rem-row.is-owned .rem-name {
  text-decoration: line-through;
}

.rem-check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

/* Apple Reminders Signature Circular Checkbox */
.rem-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 1.5px solid var(--hairline-strong);
  background: transparent;
  display: grid;
  place-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, transform 90ms ease-out;
}

.rem-checkbox:hover {
  border-color: var(--apple-blue);
}
.rem-checkbox:active {
  transform: scale(0.9);
}

.rem-checkbox:checked {
  border-color: var(--apple-green-vivid);
  background: var(--apple-green-vivid);
}

.rem-checkbox:checked::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #FFFFFF;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg) translate(-0.5px, -1px);
}

.rem-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-primary);
  overflow-wrap: anywhere;
}

.rem-qty {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-secondary);
  white-space: nowrap;
}

.rem-del {
  background: none;
  border: none;
  padding: 2px;
  color: var(--ink-tertiary);
  border-radius: 50%;
  display: inline-flex;
}
.rem-del:hover {
  color: var(--apple-red);
}

/* Inline Minimal Controls & Quick Add */
.shopping-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--ink-secondary);
}

.mini-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.mini-toggle input {
  width: 14px;
  height: 14px;
  accent-color: var(--apple-blue);
}

.quick-add-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 12px;
  border-radius: var(--r-pill);
  background: var(--bg-fill-subtle);
}

.quick-add-form input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 0.84rem;
  outline: none;
}

.quick-add-form input::placeholder {
  color: var(--ink-tertiary);
}

/* Copyable Plain-Text Footer */
.copy-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 0.5px solid var(--hairline-strong);
}

.copy-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.copy-textarea {
  width: 100%;
  min-height: 76px;
  max-height: 148px;
  resize: vertical;
  padding: 9px 12px;
  border: 0.5px solid var(--hairline-strong);
  border-radius: var(--r-sm);
  background: var(--bg-surface-secondary);
  color: var(--ink-primary);
  font-family: var(--font-system);
  font-size: 0.78rem;
  line-height: 1.5;
}

.btn-copy-primary {
  width: 100%;
  height: 42px;
  font-size: 0.9rem;
  font-weight: 600;
}

.btn-copy-primary.is-copied,
.btn-copy-primary.is-copied:hover {
  background: var(--apple-green);
}

/* ==========================================================================
   VIEW 2: Weekly Plan (Quiet Grid, Ultra-Concise)
   ========================================================================== */
.view-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 14px;
}

.week-card {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: transform 140ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 180ms ease;
}

.week-card:hover {
  box-shadow: var(--shadow-card-hover);
}
.week-card:active {
  transform: scale(0.985);
}

.week-card.is-selected {
  box-shadow: 0 0 0 2px var(--apple-blue), var(--shadow-card);
}

.week-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.week-day-label {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.week-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.week-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.84rem;
  line-height: 1.4;
}

.week-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  transform: translateY(-1px);
}

.week-row-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-tertiary);
  flex-shrink: 0;
}

.week-row-name {
  color: var(--ink-primary);
  font-weight: 500;
}

/* ==========================================================================
   VIEW 3: Purine Traffic Light (Authentic Apple macOS Traffic Lights)
   ========================================================================== */
.guide-heading-wrap {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

/* Signature macOS 3-Orb Traffic Light Cluster */
.apple-tl-cluster {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: var(--r-pill);
  background: var(--tl-capsule-bg);
  border: 0.5px solid var(--tl-capsule-border);
}

.tl-orb {
  position: relative;
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Specular top highlight inside each Apple jewel lamp */
.tl-orb::after {
  content: "";
  position: absolute;
  top: 1.5px;
  left: 2.2px;
  width: 4px;
  height: 2.5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.tl-orb--red {
  background: radial-gradient(circle at 35% 30%, #FF8A84 0%, var(--tl-red) 55%, #E0443E 100%);
  box-shadow: 0 0 0 0.5px var(--tl-red-ring), 0 0 8px var(--tl-red-glow);
}

.tl-orb--yellow {
  background: radial-gradient(circle at 35% 30%, #FFE082 0%, var(--tl-yellow) 55%, #DEA123 100%);
  box-shadow: 0 0 0 0.5px var(--tl-yellow-ring), 0 0 8px var(--tl-yellow-glow);
}

.tl-orb--green {
  background: radial-gradient(circle at 35% 30%, #6CE87E 0%, var(--tl-green) 55%, #1AAB29 100%);
  box-shadow: 0 0 0 0.5px var(--tl-green-ring), 0 0 8px var(--tl-green-glow);
}

.tl-orb--off {
  background: var(--tl-off);
  box-shadow: inset 0 0.5px 1px rgba(0, 0, 0, 0.14);
}
.tl-orb--off::after {
  display: none;
}

.tl-orb--sm {
  width: 9px;
  height: 9px;
}
.tl-orb--sm::after {
  top: 1px;
  left: 2px;
  width: 3px;
  height: 2px;
}

/* Segmented Filter Tab with Traffic Light Dot */
.seg-light-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.guide-principles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.principle-pill {
  padding: 6px 13px;
  border-radius: var(--r-pill);
  background: var(--bg-surface);
  box-shadow: var(--shadow-card);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-primary);
}

.guide-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.spotlight-input {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 380px;
}

.spotlight-input .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-tertiary);
  pointer-events: none;
}

.spotlight-input input {
  width: 100%;
  height: 40px;
  padding: 0 16px 0 40px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--bg-surface);
  box-shadow: var(--shadow-card);
  font-size: 0.875rem;
}

.spotlight-input input::placeholder {
  color: var(--ink-tertiary);
}

.purine-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 12px;
}

.purine-item {
  background: var(--bg-surface);
  border-radius: var(--r-md);
  padding: 15px 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: transform 150ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 180ms ease;
}

.purine-item:hover {
  box-shadow: var(--shadow-card-hover);
}

.purine-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.purine-item-name {
  margin: 0;
  font-size: 0.93rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Mini Apple Hardware 3-Lamp Capsule on Each Food Card */
.tl-signal {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px 4px 7px;
  border-radius: var(--r-pill);
  background: var(--tl-capsule-bg);
  border: 0.5px solid var(--tl-capsule-border);
  flex-shrink: 0;
}

.tl-signal-lamps {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tl-signal-text {
  font-size: 0.72rem;
  font-weight: 600;
  margin-left: 2px;
}
.tl-signal--low  .tl-signal-text { color: var(--apple-green); }
.tl-signal--mid  .tl-signal-text { color: var(--apple-orange); }
.tl-signal--high .tl-signal-text { color: var(--apple-red); }

.purine-item-meta {
  font-size: 0.76rem;
  color: var(--ink-tertiary);
}

.purine-item-tip {
  margin: 0;
  font-size: 0.81rem;
  color: var(--ink-secondary);
  line-height: 1.48;
}

/* ==========================================================================
   Premium Frosted Apple Glass Sheet (apple-design §12: Materials & Depth)
   ========================================================================== */
.sheet-backdrop {
  --sheet-progress: 1;
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  background: rgba(var(--scrim-rgb), calc(var(--scrim-max) * var(--sheet-progress)));
  backdrop-filter: blur(calc(14px * var(--sheet-progress))) saturate(145%);
  -webkit-backdrop-filter: blur(calc(14px * var(--sheet-progress))) saturate(145%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 24px 16px 20px;
}

.apple-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 84dvh;
  background: var(--glass-sheet-bg);
  backdrop-filter: saturate(210%) blur(44px);
  -webkit-backdrop-filter: saturate(210%) blur(44px);
  border-radius: var(--r-xl);
  border: 1px solid var(--glass-sheet-border);
  box-shadow: var(--shadow-sheet), var(--glass-sheet-rim);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  will-change: transform, opacity;
}

.sheet-grab-area {
  padding: 11px 20px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.sheet-grab-area:active {
  cursor: grabbing;
}

.sheet-grabber {
  width: 38px;
  height: 4.5px;
  border-radius: var(--r-pill);
  background: var(--grabber-bg);
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 24px 14px;
}

.sheet-title {
  margin: 4px 0 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--ink-primary);
}

.sheet-body {
  padding: 0 24px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Inner Frosted Glass Wells */
.sheet-block {
  background: var(--glass-block-bg);
  border-radius: var(--r-md);
  padding: 14px 16px;
  border: 0.5px solid var(--glass-block-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.sheet-block-label {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-tertiary);
  margin-bottom: 8px;
}

.portion-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.portion-col {
  padding: 12px;
  border-radius: var(--r-sm);
  background: var(--glass-block-inner);
  border: 0.5px solid var(--hairline);
}

.portion-col-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.portion-col p {
  margin: 0 0 4px;
  font-size: 0.8rem;
  color: var(--ink-secondary);
  line-height: 1.45;
}

.sheet-ing-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sheet-ing-pill {
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--bg-fill-subtle);
  border: 0.5px solid var(--hairline);
  font-size: 0.8rem;
  color: var(--ink-primary);
}

.sheet-gout-note {
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--apple-green-soft);
  border: 0.5px solid rgba(40, 200, 64, 0.22);
  color: var(--apple-green);
  font-size: 0.84rem;
  line-height: 1.5;
}

.sheet-steps {
  margin: 0;
  font-size: 0.875rem;
  color: var(--ink-primary);
  line-height: 1.65;
}

.sheet-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 24px 18px;
  border-top: 0.5px solid var(--hairline);
  background: var(--glass-footer-bg);
  backdrop-filter: blur(12px);
}

/* Dislikes Chips */
.chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toggle-chip {
  height: 32px;
  padding: 0 13px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--bg-fill-subtle);
  color: var(--ink-primary);
  font-size: 0.82rem;
  font-weight: 500;
  transition: transform 90ms ease-out, background-color 140ms ease, color 140ms ease;
}
.toggle-chip:active { transform: scale(0.95); }
.toggle-chip.is-selected {
  background: var(--apple-red-soft);
  color: var(--apple-red);
  font-weight: 600;
}

/* ==========================================================================
   Dynamic Island-Inspired Floating Toast
   ========================================================================== */
.toast-region {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  background: var(--toast-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 0.5px solid rgba(255, 255, 255, 0.14);
  color: var(--toast-ink);
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.24);
  animation: gentleReveal 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.toast--success .icon {
  color: var(--apple-green-vivid);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1040px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
  .shopping-aside {
    position: static;
  }
  .shopping-card {
    max-height: none;
  }
  .reminders-list {
    max-height: 300px;
  }
}

@media (max-width: 720px) {
  .header-inner {
    height: auto;
    padding: 10px 16px;
    grid-template-columns: 1fr auto;
  }
  .main-nav {
    grid-column: 1 / -1;
    justify-self: center;
    width: 100%;
    justify-content: space-between;
  }
  .main-nav .seg-item {
    flex: 1;
    text-align: center;
  }
  .app-main {
    padding: 18px 16px 56px;
  }
  .health-bar,
  .portion-compare {
    grid-template-columns: 1fr;
  }
  .health-cell + .health-cell::before {
    top: 0;
    left: 16px;
    right: 16px;
    bottom: auto;
    width: auto;
    height: 0.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  body.has-sheet-open .app-shell {
    transform: none;
  }
}
