:root {
  --bg: #f4f6f8;
  --bg-alt: #eef2f5;
  --bg-mid: #f8fafb;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --ink: #17202a;
  --muted: #66717d;
  --accent: #008767;
  --accent-strong: #006c53;
  --accent-soft: #eff7f4;
  --button-bg: #ffffff;
  --glow-a: rgba(0, 135, 103, 0.08);
  --glow-b: rgba(23, 32, 42, 0.05);
  --line: #d9e0e6;
  --success: #008767;
  --track-green: #008767;
  --track-yellow: #e4bc43;
  --track-red: #d35b45;
  --danger: #9f2f2f;
  --danger-bg: #fff1f1;
  --card: #ffffff;
  --soft-surface: #f5f7f9;
  --shadow: 0 14px 34px rgba(23, 32, 42, 0.07);
  --radius-lg: 14px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

body[data-theme="coastal"] {
  --bg: #cfeaf2;
  --bg-mid: #eefcff;
  --bg-alt: #3d92b4;
  --panel: rgba(239, 252, 255, 0.95);
  --panel-strong: #e1f7ff;
  --ink: #082635;
  --muted: #31596a;
  --accent: #0077a3;
  --accent-strong: #004b68;
  --accent-soft: #8bd6ec;
  --button-bg: #f2fdff;
  --glow-a: rgba(0, 119, 163, 0.28);
  --glow-b: rgba(37, 172, 186, 0.2);
  --line: rgba(16, 46, 61, 0.17);
}

body[data-theme="sage"] {
  --bg: #d4e4bb;
  --bg-mid: #fbffe8;
  --bg-alt: #789b4b;
  --panel: rgba(250, 255, 235, 0.95);
  --panel-strong: #eef8d5;
  --ink: #18250f;
  --muted: #465a2d;
  --accent: #537c2b;
  --accent-strong: #315116;
  --accent-soft: #badb82;
  --button-bg: #fbfff2;
  --glow-a: rgba(83, 124, 43, 0.28);
  --glow-b: rgba(179, 139, 43, 0.18);
  --line: rgba(38, 53, 28, 0.17);
}

body[data-theme="berry"] {
  --bg: #f1d2e1;
  --bg-mid: #fff0f6;
  --bg-alt: #9b3f77;
  --panel: rgba(255, 243, 249, 0.95);
  --panel-strong: #ffe4f0;
  --ink: #251020;
  --muted: #5f4157;
  --accent: #b31970;
  --accent-strong: #76104a;
  --accent-soft: #f2a7cd;
  --button-bg: #fff6fb;
  --glow-a: rgba(179, 25, 112, 0.28);
  --glow-b: rgba(102, 59, 153, 0.18);
  --line: rgba(50, 23, 43, 0.17);
}

body[data-theme="sunrise"] {
  --bg: #ffd0c3;
  --bg-mid: #fff4e7;
  --bg-alt: #ff8d7a;
  --panel: rgba(255, 246, 237, 0.95);
  --panel-strong: #ffe2d3;
  --ink: #2d1215;
  --muted: #633f41;
  --accent: #f04f58;
  --accent-strong: #a52632;
  --accent-soft: #ffb2a0;
  --button-bg: #fff7f0;
  --glow-a: rgba(240, 79, 88, 0.31);
  --glow-b: rgba(255, 151, 71, 0.27);
  --line: rgba(63, 30, 33, 0.17);
}

body[data-theme="slate"] {
  --bg: #c9d1dc;
  --bg-mid: #f4f7fb;
  --bg-alt: #596a82;
  --panel: rgba(246, 249, 253, 0.95);
  --panel-strong: #e9eef6;
  --ink: #111b26;
  --muted: #3e4d5f;
  --accent: #405a78;
  --accent-strong: #24364e;
  --accent-soft: #b8c5d8;
  --button-bg: #fbfdff;
  --glow-a: rgba(64, 90, 120, 0.28);
  --glow-b: rgba(32, 41, 56, 0.16);
  --line: rgba(26, 36, 48, 0.17);
}

body[data-theme="mocha"] {
  --bg: #c5aa96;
  --bg-mid: #ead5c5;
  --bg-alt: #4b3329;
  --panel: rgba(247, 231, 219, 0.95);
  --panel-strong: #e2c4af;
  --ink: #19100d;
  --muted: #4f3d33;
  --accent: #6b3b2b;
  --accent-strong: #3c2118;
  --accent-soft: #be8b6d;
  --button-bg: #f8eadf;
  --glow-a: rgba(73, 45, 35, 0.34);
  --glow-b: rgba(123, 77, 52, 0.24);
  --line: rgba(36, 25, 21, 0.2);
}

body[data-theme="fresh"] {
  --bg: #c4f0dc;
  --bg-mid: #effff7;
  --bg-alt: #28a883;
  --panel: rgba(241, 255, 248, 0.95);
  --panel-strong: #dcf9ec;
  --ink: #0b2a22;
  --muted: #365f51;
  --accent: #008767;
  --accent-strong: #005943;
  --accent-soft: #85e0c0;
  --button-bg: #f6fffb;
  --glow-a: rgba(0, 135, 103, 0.28);
  --glow-b: rgba(66, 183, 116, 0.22);
  --line: rgba(20, 53, 44, 0.17);
}

body[data-theme] {
  --bg: #f4f6f8;
  --bg-alt: #eef2f5;
  --bg-mid: #f8fafb;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --ink: #17202a;
  --muted: #66717d;
  --accent: #008767;
  --accent-strong: #006c53;
  --accent-soft: #eff7f4;
  --button-bg: #ffffff;
  --glow-a: rgba(0, 135, 103, 0.08);
  --glow-b: rgba(23, 32, 42, 0.05);
  --line: #d9e0e6;
  --success: #008767;
  --track-green: #008767;
  --track-yellow: #e4bc43;
  --track-red: #d35b45;
  --danger: #9f2f2f;
  --danger-bg: #fff1f1;
  --card: #ffffff;
  --soft-surface: #f5f7f9;
  --shadow: 0 14px 34px rgba(23, 32, 42, 0.07);
  --radius-lg: 14px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

button,
input,
select {
  font: inherit;
  max-width: 100%;
  min-width: 0;
}

body,
input,
select,
button {
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

.app-shell {
  width: calc(100vw - 32px);
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero,
.panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

.hero {
  position: relative;
  background: var(--card);
  padding: 24px;
  margin-bottom: 24px;
}

.hero h1 {
  max-width: 760px;
}

.hero-main {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  flex-wrap: wrap;
}

.brand-block {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.brand-block h1 {
  font-size: clamp(1.85rem, 4vw, 2.35rem);
}

.header-week {
  flex: 0 1 260px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.75rem;
  color: var(--accent-strong);
  font-weight: 800;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: inherit;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 2.6rem);
  line-height: 1.05;
}

h2 {
  font-size: clamp(1.75rem, 4vw, 1.9rem);
}

.hero-copy,
.muted,
.save-status {
  color: var(--muted);
  font-weight: 600;
}

.hero-copy {
  max-width: 720px;
  line-height: 1.6;
  margin: 14px 0 20px;
  font-size: 1rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.hero-actions,
.app-tools,
.view-nav,
.section-heading,
.library-controls,
.metric-grid,
.metric-flags,
.row-actions,
.day-tabs,
.meal-entry,
.recipe-row {
  display: flex;
  gap: 12px;
}

.hero-actions {
  align-items: end;
  flex-wrap: wrap;
}

.app-tools {
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 16px;
  min-width: 0;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.save-status {
  min-height: 1.2em;
  margin: 0;
}

.offline-status {
  max-width: 100%;
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(211, 91, 69, 0.35);
  background: rgba(211, 91, 69, 0.12);
  color: var(--track-red);
  font-weight: 800;
}

.save-status[data-status="success"] {
  color: var(--success);
}

.save-status[data-status="error"] {
  color: var(--track-red);
}

.library-controls {
  margin-bottom: 16px;
}

.view-nav,
.section-actions,
.home-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.view-nav {
  position: relative;
  display: block;
  margin-top: 18px;
}

.nav-desktop,
.nav-mobile {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.nav-mobile {
  display: none;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.1;
  box-shadow: none;
}

.nav-tab.active {
  border-color: rgba(0, 135, 103, 0.28);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.nav-tab:hover {
  background: var(--soft-surface);
}

.nav-tab.active:hover {
  background: var(--accent-soft);
}

.nav-icon {
  display: inline-flex;
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  color: currentColor;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-more-panel {
  display: none;
}

.settings-panel {
  position: absolute;
  top: calc(100% - 12px);
  right: 24px;
  z-index: 35;
  display: grid;
  gap: 14px;
  width: min(420px, calc(100vw - 32px));
  max-height: min(760px, calc(100dvh - 24px));
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 56px rgba(23, 32, 42, 0.16);
}

.settings-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  padding-bottom: 4px;
}

.settings-panel-header h2 {
  font-size: 1.45rem;
}

.settings-mobile-links,
.settings-group,
.settings-actions,
.appearance-options,
.about-row {
  min-width: 0;
}

.settings-mobile-links {
  display: none;
  gap: 8px;
}

.settings-group {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--soft-surface);
}

.settings-group h3 {
  margin: 0;
  font-size: 0.86rem;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 850;
  letter-spacing: 0.08em;
}

.settings-actions,
.appearance-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.appearance-options button {
  flex: 1 1 92px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--button-bg);
  color: var(--ink);
}

.appearance-options button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(0, 135, 103, 0.18);
}

.about-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-weight: 750;
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  min-width: 0;
}

.home-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 8px;
  min-width: 0;
  min-height: 168px;
  text-align: left;
  padding: 20px 20px 18px;
  border-radius: var(--radius-md);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.home-card h3 {
  font-size: 1.18rem;
  line-height: 1.2;
}

.home-card p {
  margin: 0;
}

.home-card strong {
  display: block;
  align-self: end;
  margin-top: 4px;
  font-size: 1.45rem;
  font-family: inherit;
  color: var(--accent-strong);
  font-weight: 850;
  line-height: 1.05;
}

.week-picker {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.week-picker span,
.field label,
.metric-block label {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--muted);
}

select,
input[type="text"],
input[type="number"],
input[type="search"] {
  width: 100%;
  min-height: 47px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 650;
}

input[list] {
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7L9 11L13 7' stroke='%230B2A22' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 18px 18px;
}

.food-picker-trigger {
  width: 100%;
  min-height: 47px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 42px 12px 14px;
  color: var(--ink);
  font-weight: 650;
  position: relative;
}

.food-picker-trigger::after {
  content: "";
  position: absolute;
  right: 15px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7L9 11L13 7' stroke='%230B2A22' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
}

.food-picker-trigger span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.food-picker-trigger.is-placeholder {
  color: var(--muted);
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(0, 135, 103, 0.28);
  outline-offset: 2px;
}

button {
  border: 0;
  border-radius: 11px;
  min-height: 44px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.ghost-button,
.chip-button {
  background: var(--button-bg);
  border: 1px solid var(--line);
  color: var(--ink);
}

.chip-button.active,
.primary-button {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(0, 135, 103, 0.18);
}

.layout {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.panel {
  background: var(--bg);
  border-color: #dce3e8;
  box-shadow: none;
  padding: 26px;
}

.section-heading {
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.food-form-panel {
  margin-bottom: 18px;
}

.summary-grid,
.snapshot-grid,
.meal-grid,
.stats-grid {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 18px;
}

.snapshot-grid {
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
}

.summary-card,
.snapshot-card,
.meal-card,
.metrics-card,
.recipe-summary,
.food-card {
  min-width: 0;
  max-width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.summary-card,
.snapshot-card,
.recipe-summary,
.food-card {
  padding: 18px;
}

.summary-card,
.snapshot-card {
  display: grid;
  align-content: start;
  gap: 8px;
}

.summary-card p,
.snapshot-card p {
  margin: 0;
}

.summary-card strong,
.snapshot-card strong,
.meal-total,
.recipe-summary strong {
  display: block;
  font-size: 1.55rem;
  margin-top: 2px;
  font-family: inherit;
  color: var(--ink);
  line-height: 1.08;
}

.meal-total,
.summary-card strong,
.snapshot-card strong,
.recipe-summary strong {
  color: var(--ink);
  font-weight: 850;
}

.meal-tag {
  color: var(--ink);
  font-weight: 800;
}

.day-tabs {
  flex-wrap: wrap;
}

.day-editor-grid {
  display: grid;
  gap: 18px;
}

.meal-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.meal-card,
.metrics-card {
  padding: 18px;
}

.meal-card h3,
.metrics-card h3 {
  margin-bottom: 6px;
  font-size: 1.18rem;
  line-height: 1.2;
}

.tracking-card {
  position: relative;
  overflow: hidden;
}

.tracking-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: transparent;
}

.tracking-green {
  background: var(--card);
  border-color: rgba(0, 135, 103, 0.28);
}

.tracking-green::before {
  background: var(--track-green);
}

.tracking-yellow {
  background: var(--card);
  border-color: rgba(204, 160, 38, 0.34);
}

.tracking-yellow::before {
  background: var(--track-yellow);
}

.tracking-red {
  background: var(--card);
  border-color: rgba(190, 68, 68, 0.3);
}

.tracking-red::before {
  background: var(--track-red);
}

.tracking-neutral::before {
  background: rgba(29, 36, 48, 0.14);
}

.tracking-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(0, 135, 103, 0.16);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.meal-list,
.recipe-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  min-width: 0;
}

.meal-entry,
.recipe-row {
  align-items: center;
  min-width: 0;
  max-width: 100%;
}

.meal-entry-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
}

.meal-entry-tag-card {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
}

.meal-entry-tag-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.meal-entry-tag-top strong {
  font-size: 1rem;
  font-family: inherit;
  font-weight: 750;
}

.meal-entry-tags,
.tag-card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  align-items: center;
}

.meal-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--soft-surface);
  border: 1px solid #e2e8ed;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
}

.meal-entry-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.meal-entry-heading strong {
  font-size: 1rem;
  font-family: inherit;
  font-weight: 750;
}

.meal-entry-calories {
  color: var(--accent-strong);
  font-weight: 850;
}

.meal-entry-fields {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.entry-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.entry-field span {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.meal-entry-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.meal-entry > input:first-child,
.recipe-row-field:first-child {
  flex: 1.8;
}

.meal-entry > input,
.recipe-row-field {
  flex: 1;
}

.recipe-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) minmax(120px, 0.8fr) minmax(82px, auto) minmax(82px, auto) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
}

.recipe-row-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.recipe-row-field span {
  font-size: 0.75rem;
  font-weight: 750;
  color: var(--muted);
}

.recipe-row-field input {
  text-align: left;
  width: 100%;
}

.inline-stat {
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--soft-surface);
  border: 1px solid #e2e8ed;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
}

.row-remove-button {
  white-space: nowrap;
}

.recipe-remove-button {
  flex: 0 0 auto;
  min-width: 82px;
  min-height: 44px;
  padding: 0 14px;
  align-self: center;
  font-size: 0.84rem;
  line-height: 1;
}

.row-actions {
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

.row-actions > button {
  flex: 0 1 auto;
}

.text-button {
  background: transparent;
  color: var(--accent-strong);
  padding-inline: 0;
}

.metric-grid {
  flex-wrap: wrap;
}

.metric-block {
  flex: 1 1 130px;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.combo-metric {
  flex-basis: 220px;
}

.inline-control-pair {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(92px, auto);
  gap: 8px;
}

.height-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.checkin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.compact-stats {
  margin-top: 10px;
}

.water-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  background: var(--soft-surface);
  border: 1px solid var(--line);
}

.water-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.water-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(120px, 0.8fr) auto;
  gap: 10px;
  align-items: end;
}

.metric-flags {
  flex-wrap: wrap;
  margin-top: 12px;
}

.habit-toolbar,
.habit-list {
  gap: 12px;
}

.habit-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.habit-toolbar {
  display: grid;
}

.habit-toolbar {
  margin-top: 12px;
}

.habit-toolbar.bottom {
  justify-content: start;
  margin-bottom: 12px;
}

.habit-row {
  display: inline-flex;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
}

.habit-check {
  background: transparent;
  border: 0;
  padding: 0 4px 0 2px;
}

.compact-habit {
  width: auto;
  flex: 0 1 auto;
  min-width: 0;
}

.habit-inline-input {
  flex: 1 1 auto;
  min-width: 180px;
}

.habit-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.habit-delete-button,
.small-action-button {
  padding: 7px 12px;
  font-size: 0.82rem;
}

.flag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.habit-check.flag {
  padding: 7px 8px;
  border: 0;
  background: transparent;
}

.habit-check input[type="checkbox"] {
  appearance: none;
  display: inline-grid;
  place-content: center;
  width: 18px;
  height: 18px;
  margin: 0;
  border-radius: 6px;
  border: 2px solid var(--accent);
  background: var(--button-bg);
  cursor: pointer;
}

.habit-check input[type="checkbox"]::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: scale(0);
  transition: transform 120ms ease;
  background: #fff;
}

.habit-check input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent-strong);
}

.habit-check input[type="checkbox"]:checked::before {
  transform: scale(1);
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 18px;
}

.stat-box {
  padding: 14px;
  border-radius: 12px;
  background: var(--soft-surface);
  border: 1px solid #e5eaee;
}

.stat-box strong {
  display: block;
  margin-top: 6px;
  font-size: 1.25rem;
  font-family: inherit;
  color: var(--ink);
  font-weight: 800;
}

.recipe-layout {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.calculator-layout,
.meal-split-grid {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.calculator-layout > .summary-grid {
  align-items: stretch;
}

.calculator-layout > .summary-grid .summary-card {
  min-height: 128px;
}

.calculator-layout > .summary-grid .summary-card:nth-child(4) {
  border-color: rgba(0, 135, 103, 0.28);
  background: #f4fbf8;
}

.calculator-layout > .summary-grid .summary-card:nth-child(4) strong {
  color: var(--accent-strong);
  font-size: 1.9rem;
}

.meal-split-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.split-balance {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.split-balance span {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-strong);
  font-weight: 800;
  padding: 9px 12px;
}

.split-balance strong {
  color: var(--ink);
  font-weight: 850;
}

.split-balance.is-over-target span:last-child {
  background: var(--danger-bg);
  border-color: #f0c7c7;
  color: var(--danger);
}

.food-form-card {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.food-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  min-width: 0;
}

.food-calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.72fr);
  gap: 12px;
  align-items: end;
  min-width: 0;
}

.calculated-food-value {
  min-height: 73px;
  justify-content: end;
}

.calculated-food-value strong {
  display: flex;
  align-items: center;
  min-height: 47px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid rgba(0, 135, 103, 0.16);
  color: var(--accent-strong);
  font-weight: 850;
}

.calculation-note {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.4;
}

.food-modal-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) minmax(110px, 0.55fr) minmax(210px, 0.9fr);
  gap: 14px;
  align-items: end;
  min-width: 0;
}

.food-type-field select {
  min-width: 92px;
}

.calorie-value-pill,
.calorie-edit-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 7px 8px 7px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(0, 135, 103, 0.16);
}

.calorie-value-pill strong {
  white-space: nowrap;
  color: var(--accent-strong);
  font-weight: 850;
}

.calorie-edit-pill input {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 10px;
}

.modal-bottom-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.modal-main-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-delete-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.lookup-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.lookup-row {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.lookup-search {
  flex: 1 1 260px;
}

.lookup-results {
  display: grid;
  gap: 10px;
}

.selected-lookup {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
}

.lookup-result {
  display: grid;
  gap: 4px;
  min-width: 0;
  text-align: left;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
}

.lookup-result small {
  color: var(--muted);
}

.lookup-result span {
  color: var(--accent-strong);
  font-weight: 850;
}

.danger-button {
  background: var(--danger-bg);
  border-color: #f0c7c7;
  color: var(--danger);
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 32, 42, 0.42);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 22px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 28px 60px rgba(23, 32, 42, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #edf1f4;
}

.food-picker-card {
  width: min(680px, calc(100% - 24px));
  max-height: min(760px, calc(100dvh - 24px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  overflow: hidden;
}

.food-picker-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.food-picker-header .food-picker-search { flex: 1; width: 0; }
.food-picker-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid var(--line);
}
.food-picker-actions button { min-height: 44px; flex-shrink: 0; }
.food-picker-card { box-sizing: border-box; }


.food-picker-search {
  min-width: 0;
}

.food-picker-count {
  margin: 0;
  font-weight: 800;
}

.food-picker-results {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: start;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 4px 4px 4px 0;
}

.food-picker-option {
  display: grid;
  gap: 4px;
  min-height: 66px;
  height: auto;
  align-content: center;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  line-height: 1.25;
  white-space: normal;
  overflow: visible;
}

.food-picker-option:hover,
.lookup-result:hover,
.home-card:hover,
.food-card:hover {
  border-color: rgba(0, 135, 103, 0.32);
}

.food-picker-option strong,
.food-picker-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.food-picker-option span {
  color: var(--accent-strong);
  font-weight: 850;
}

.food-picker-empty {
  margin: 0;
  padding: 14px;
}

.form-error {
  color: #a33b2f;
  font-weight: 700;
  margin: 0;
}

.form-success {
  color: var(--success);
  font-weight: 700;
  margin: 0;
}

.recipe-summary {
  display: grid;
  grid-template-columns: minmax(220px, 1.35fr) repeat(3, minmax(150px, 0.75fr));
  gap: 14px;
  align-items: end;
}

.recipe-summary > div {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.recipe-summary p {
  margin: 0;
}

.recipe-summary strong {
  color: var(--accent-strong);
  font-size: 1.7rem;
}

.recipe-layout .row-actions {
  justify-content: flex-start;
  gap: 10px;
}

.recipe-layout .row-actions [data-recipe-action="save-cps"] {
  border-color: rgba(0, 135, 103, 0.24);
  color: var(--accent-strong);
}

.recipe-layout .row-actions [data-recipe-action="clear"] {
  background: var(--danger-bg);
  border-color: #f0c7c7;
  color: var(--danger);
}

.food-library {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  min-width: 0;
}

.food-card p {
  margin: 0;
}

.food-card strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.25;
  color: var(--ink);
  font-weight: 800;
}

.food-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 15px;
  min-height: 108px;
}

.food-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  width: 100%;
  min-width: 0;
  flex-wrap: wrap;
}

.edit-food-button {
  flex: 0 0 auto;
  padding: 8px 12px;
  font-size: 0.82rem;
  line-height: 1;
}

.pill {
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  margin-top: 0;
}

body[data-current-view="daily"] {
  background: #f4f6f8;
  color: #17202a;
}

#daily-section.panel {
  --daily-green: #008767;
  --daily-green-dark: #006c53;
  --daily-ink: #17202a;
  --daily-muted: #66717d;
  --daily-line: #d9e0e6;
  --daily-soft: #f5f7f9;
  background: #f4f6f8;
  border-color: #dce3e8;
  border-radius: 14px;
  box-shadow: none;
  backdrop-filter: none;
  color: var(--daily-ink);
}

#daily-checkin-section.panel {
  --daily-green: #008767;
  --daily-green-dark: #006c53;
  --daily-ink: #17202a;
  --daily-muted: #66717d;
  --daily-line: #d9e0e6;
  --daily-soft: #f5f7f9;
  background: #f4f6f8;
  border-color: #dce3e8;
  border-radius: 14px;
  box-shadow: none;
  backdrop-filter: none;
  color: var(--daily-ink);
}

#daily-section,
#daily-checkin-section,
#daily-section button,
#daily-checkin-section button,
#daily-section input,
#daily-checkin-section input,
#daily-section select,
#daily-checkin-section select {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#daily-section h2,
#daily-section h3,
#daily-section h4,
#daily-section strong,
#daily-checkin-section h2,
#daily-checkin-section h3,
#daily-checkin-section h4,
#daily-checkin-section strong {
  font-family: inherit;
  letter-spacing: 0;
}

#daily-section .section-heading {
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}

#daily-section .section-heading h2 {
  font-size: clamp(1.75rem, 4vw, 1.9rem);
  font-weight: 800;
  color: var(--daily-ink);
}

#daily-section .eyebrow {
  color: var(--daily-green-dark);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.11em;
}

#daily-checkin-section .eyebrow {
  color: var(--daily-green-dark);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.11em;
}

#daily-section .muted,
#daily-checkin-section .muted {
  color: var(--daily-muted);
  font-size: 0.88rem;
  font-weight: 600;
}

#daily-section .day-tabs {
  gap: 8px;
}

#daily-section button {
  border-radius: 11px;
  min-height: 44px;
  box-shadow: none;
}

#daily-checkin-section button {
  border-radius: 11px;
  min-height: 44px;
  box-shadow: none;
}

#daily-section button:hover,
#daily-checkin-section button:hover {
  transform: translateY(-1px);
}

#daily-section .primary-button,
#daily-section .chip-button.active,
#daily-checkin-section .primary-button {
  background: var(--daily-green);
  color: #fff;
  border-color: var(--daily-green);
  box-shadow: 0 10px 20px rgba(0, 135, 103, 0.18);
}

#daily-section .ghost-button,
#daily-section .chip-button,
#daily-checkin-section .ghost-button {
  background: #fff;
  color: var(--daily-ink);
  border: 1px solid var(--daily-line);
}

#daily-section .row-remove-button,
#daily-section .habit-delete-button,
#daily-checkin-section .row-remove-button,
#daily-checkin-section .habit-delete-button {
  background: #fff1f1;
  color: #9f2f2f;
  border-color: #f0c7c7;
}

#daily-section .entry-field span,
#daily-section .metric-block label,
#daily-checkin-section .entry-field span,
#daily-checkin-section .metric-block label {
  color: #4c5964;
  font-size: 0.8rem;
  font-weight: 800;
}

#daily-section input[type="text"],
#daily-section input[type="number"],
#daily-section input[type="search"],
#daily-section select,
#daily-section .food-picker-trigger,
#daily-checkin-section input[type="text"],
#daily-checkin-section input[type="number"],
#daily-checkin-section input[type="search"],
#daily-checkin-section select {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--daily-line);
  border-radius: 10px;
  color: var(--daily-ink);
  font-size: 0.96rem;
  font-weight: 650;
  padding: 12px 14px;
}

#daily-section .food-picker-trigger {
  padding-right: 42px;
}

#daily-section input:focus,
#daily-section select:focus,
#daily-section button:focus,
#daily-section .food-picker-trigger:focus,
#daily-checkin-section input:focus,
#daily-checkin-section select:focus,
#daily-checkin-section button:focus {
  outline: 2px solid rgba(0, 135, 103, 0.28);
  outline-offset: 2px;
}

.daily-screen {
  gap: 18px;
}

.daily-checkin-screen {
  display: grid;
  gap: 18px;
}

.daily-checkin-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  padding: 20px;
}

.daily-checkin-hero h2 {
  color: var(--daily-ink);
  font-size: clamp(1.75rem, 4vw, 1.9rem);
  font-weight: 800;
}

.checkin-hero-actions,
.checkin-settings-actions,
.water-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.toggle-list {
  display: grid;
  gap: 10px;
}

.toggle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--daily-line);
  border-radius: 12px;
  background: #fff;
  color: var(--daily-ink);
  font-weight: 800;
}

.toggle-row input {
  inline-size: 44px;
  block-size: 24px;
  accent-color: var(--daily-green);
}

.toggle-row strong {
  min-width: 34px;
  font-size: 0.78rem;
  text-align: right;
}

.checkin-subsettings {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--daily-line);
}

.water-target-field {
  max-width: 360px;
}

.unit-label {
  align-self: center;
  color: var(--daily-muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.water-status-card,
.empty-checkin-card {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  padding: 14px;
  border: 1px solid var(--daily-line);
  border-radius: 12px;
  background: var(--daily-soft);
  color: var(--daily-ink);
}

.water-status-card.on-track {
  border-color: rgba(0, 135, 103, 0.32);
  background: #ecf8f4;
}

.water-status-card.behind,
.water-status-card.needs-action {
  border-color: #f0d2a1;
  background: #fff8eb;
}

.daily-summary-hero,
#daily-section .daily-meal-card,
#daily-section .daily-checkin-card,
#daily-checkin-section .daily-checkin-hero,
#daily-checkin-section .daily-checkin-card {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--daily-line);
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(23, 32, 42, 0.07);
}

.daily-summary-hero {
  display: grid;
  gap: 18px;
  padding: 22px;
}

#daily-section .tracking-card {
  overflow: hidden;
}

#daily-section .tracking-card::before {
  width: 4px;
}

#daily-section .tracking-green,
#daily-section .tracking-yellow,
#daily-section .tracking-red {
  background: #fff;
}

#daily-section .tracking-green {
  border-color: rgba(0, 135, 103, 0.28);
}

#daily-section .tracking-green::before {
  background: var(--daily-green);
}

#daily-section .tracking-yellow {
  border-color: rgba(204, 160, 38, 0.34);
}

#daily-section .tracking-red {
  border-color: rgba(190, 68, 68, 0.3);
}

.daily-summary-top,
.daily-meal-header,
.daily-meal-subline,
.daily-summary-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.daily-summary-top h3 {
  font-size: 1.22rem;
  font-weight: 750;
}

#daily-section .tracking-badge {
  flex: 0 0 auto;
  margin-top: 0;
  border-radius: 999px;
  background: #eff7f4;
  border-color: rgba(0, 135, 103, 0.16);
  color: var(--daily-green-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.daily-remaining {
  display: grid;
  gap: 2px;
}

.daily-remaining strong {
  color: var(--daily-ink);
  font-size: clamp(2rem, 8vw, 2.7rem);
  font-weight: 850;
  line-height: 1;
}

.daily-remaining span {
  color: var(--daily-muted);
  font-size: 0.96rem;
  font-weight: 700;
}

.daily-summary-meta {
  align-items: center;
  color: var(--daily-muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.daily-summary-meta span {
  min-width: 0;
}

.daily-summary-meta strong {
  color: var(--daily-ink);
  font-size: 1.15rem;
  font-weight: 850;
}

.daily-progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf1;
}

.daily-progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--daily-green), #20a87d);
}

.daily-summary-mini {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

#daily-section .stats-grid {
  gap: 10px;
}

#daily-checkin-section .stats-grid {
  gap: 10px;
}

#daily-section .stat-box,
#daily-checkin-section .stat-box {
  min-width: 0;
  padding: 13px;
  border-radius: 12px;
  background: var(--daily-soft);
  border: 1px solid #e5eaee;
}

#daily-section .stat-box strong,
#daily-checkin-section .stat-box strong {
  color: var(--daily-ink);
  font-size: 1.22rem;
  font-weight: 800;
}

#daily-section .daily-meal-card,
#daily-section .daily-checkin-card,
#daily-checkin-section .daily-checkin-card {
  padding: 18px;
}

.daily-meal-header {
  align-items: center;
}

.daily-meal-header h3 {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--daily-ink);
}

.daily-meal-total {
  display: grid;
  gap: 0;
  flex: 0 0 auto;
  text-align: right;
  color: var(--daily-muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.daily-meal-total strong {
  color: var(--daily-ink);
  font-size: 1.85rem;
  font-weight: 850;
  line-height: 1;
}

.daily-meal-subline {
  align-items: center;
  margin-top: 12px;
  color: var(--daily-muted);
  font-size: 0.9rem;
  font-weight: 700;
}

#daily-section .meal-list {
  gap: 12px;
  margin-top: 16px;
}

#daily-section .meal-entry-card,
#daily-section .meal-entry-tag-card {
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--daily-line);
  box-shadow: none;
}

#daily-section .meal-entry-heading strong,
#daily-section .meal-entry-tag-top strong {
  color: var(--daily-ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 750;
}

#daily-section .meal-entry-calories {
  color: var(--daily-green-dark);
  font-weight: 850;
}

#daily-section .meal-tag,
#daily-section .inline-stat {
  border-radius: 999px;
  background: var(--daily-soft);
  border: 1px solid #e2e8ed;
  color: var(--daily-ink);
  font-size: 0.86rem;
  font-weight: 800;
}

#daily-section .inline-stat {
  border-radius: 10px;
}

#daily-section .row-actions {
  align-items: center;
  color: var(--daily-muted);
}

#daily-section .checkin-header,
#daily-checkin-section .checkin-header {
  margin-top: 0;
}

#daily-section .water-panel,
#daily-checkin-section .water-panel {
  border-radius: 12px;
  background: var(--daily-soft);
  border-color: #e3e8ed;
}

#daily-section .habit-row,
#daily-checkin-section .habit-row {
  border-radius: 12px;
  background: #fff;
  border-color: var(--daily-line);
}

#daily-section .flag {
  border-radius: 12px;
}

#daily-section .habit-check input[type="checkbox"] {
  border-color: var(--daily-green);
  background: #fff;
}

#daily-section .habit-check input[type="checkbox"]:checked {
  background: var(--daily-green);
  border-color: var(--daily-green-dark);
}

@media (max-width: 760px) {
  .app-shell {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    padding-top: 18px;
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .hero,
  .panel {
    padding: 18px;
  }

  .hero {
    margin-bottom: 18px;
  }

  .hero-main {
    align-items: start;
  }

  .header-week {
    flex-basis: 100%;
  }

  .hero-copy {
    margin-bottom: 16px;
  }

  .app-tools,
  .hero-actions {
    gap: 8px;
  }

  .view-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -12px 28px rgba(23, 32, 42, 0.1);
    backdrop-filter: blur(14px);
  }

  .nav-desktop {
    display: none;
  }

  .nav-mobile {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    width: min(520px, 100%);
    margin: 0 auto;
  }

  .nav-mobile .nav-tab {
    flex-direction: column;
    gap: 4px;
    width: 100%;
    min-height: 58px;
    padding: 7px 4px 6px;
    border-color: transparent;
    background: transparent;
    color: #52606d;
    font-size: 0.72rem;
    font-weight: 800;
    box-shadow: none;
  }

  .nav-mobile .nav-tab.active {
    border-color: rgba(0, 135, 103, 0.18);
    background: var(--accent-soft);
    color: var(--accent-strong);
    box-shadow: inset 0 2px 0 var(--accent);
  }

  .nav-mobile .nav-icon {
    width: 21px;
    height: 21px;
    flex-basis: 21px;
  }

  .nav-more-panel {
    position: absolute;
    right: 10px;
    bottom: calc(100% + 8px);
    display: grid;
    width: min(270px, calc(100vw - 20px));
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 18px 42px rgba(23, 32, 42, 0.16);
  }

  .nav-more-panel.hidden {
    display: none !important;
  }

  .nav-more-panel .nav-tab {
    justify-content: flex-start;
    width: 100%;
    min-height: 50px;
    padding: 10px 12px;
    color: var(--ink);
    font-size: 0.9rem;
    text-align: left;
  }

  .nav-more-panel .nav-tab.active {
    color: var(--accent-strong);
  }

  .settings-panel {
    position: fixed;
    top: auto;
    left: 10px;
    right: 10px;
    bottom: calc(84px + env(safe-area-inset-bottom));
    width: auto;
    max-height: min(620px, calc(100dvh - 116px));
    padding: 14px;
    border-radius: 14px;
  }

  .settings-mobile-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .appearance-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .home-grid {
    gap: 12px;
  }

  .home-card {
    min-height: 132px;
    padding: 16px;
  }

  .home-card strong {
    font-size: 1.32rem;
  }

  .home-grid,
  .summary-grid,
  .snapshot-grid,
  .meal-grid,
  .stats-grid,
  .recipe-summary,
  .food-library,
  .food-form-grid,
  .food-calc-grid,
  .meal-split-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .meal-entry {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .recipe-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
  }

  .lookup-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .food-modal-grid {
    grid-template-columns: 1fr;
  }

  .modal-bottom-actions,
  .modal-main-actions,
  .modal-delete-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    gap: 8px;
  }

  .water-row {
    grid-template-columns: 1fr;
  }

  .inline-control-pair {
    grid-template-columns: 1fr;
  }

  .section-actions {
    width: 100%;
    gap: 8px;
  }

  .section-actions > *,
  .app-tools > * {
    max-width: 100%;
  }

  .habit-row {
    flex-direction: row;
    align-items: center;
  }

  .meal-entry-fields {
    grid-template-columns: 1fr;
  }

  .recipe-row-field:first-child {
    grid-column: 1 / -1;
  }

  .meal-entry > * {
    grid-column: 1 / -1;
  }

  .tag-card-actions {
    width: 100%;
    gap: 8px;
  }

  .tag-card-actions > button {
    flex: 1 1 112px;
  }

  .summary-card,
  .snapshot-card,
  .recipe-summary,
  .food-card,
  .food-form-card {
    padding: 16px;
  }

  .summary-card strong,
  .snapshot-card strong,
  .recipe-summary strong {
    font-size: 1.42rem;
  }

  .calculator-layout > .summary-grid .summary-card:nth-child(4) strong {
    font-size: 1.62rem;
  }

  .recipe-amount-field {
    grid-column: 1 / -1;
  }

  .recipe-remove-button {
    grid-column: 3;
    justify-self: end;
    align-self: stretch;
  }

  .recipe-layout .row-actions > button,
  .food-form-card .row-actions > button {
    flex: 1 1 145px;
  }

  .food-library {
    gap: 10px;
  }

  .food-card {
    min-height: 0;
  }

  .modal-card {
    width: min(720px, calc(100% - 20px));
    max-height: calc(100dvh - 20px);
    padding: 18px;
  }

  .food-picker-card {
    width: calc(100% - 20px);
  }

  .meal-entry-fields > input:first-child {
    grid-column: 1 / -1;
  }

  #daily-section.panel,
  #daily-checkin-section.panel {
    padding: 18px;
    border-radius: 14px;
  }

  #daily-section .section-heading {
    gap: 14px;
  }

  .daily-checkin-hero {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

  .checkin-hero-actions,
  .checkin-settings-actions,
  .water-quick-actions {
    justify-content: stretch;
  }

  .checkin-hero-actions button,
  .checkin-settings-actions button,
  .water-quick-actions button {
    flex: 1 1 120px;
  }

  .toggle-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .toggle-row strong {
    grid-column: 1 / -1;
    text-align: left;
  }

  #daily-section .section-actions {
    align-items: stretch;
  }

  #daily-section .day-tabs,
  #daily-section .section-actions,
  #daily-section .section-actions > button {
    width: 100%;
  }

  #daily-section .day-tabs .chip-button {
    flex: 1 1 calc(33.333% - 8px);
    padding-inline: 10px;
  }

  .daily-summary-hero,
  #daily-section .daily-meal-card,
  #daily-section .daily-checkin-card,
  #daily-checkin-section .daily-checkin-card {
    padding: 16px;
  }

  .daily-summary-top,
  .daily-summary-meta,
  .daily-meal-header,
  .daily-meal-subline {
    flex-wrap: wrap;
  }

  .daily-summary-mini {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  #daily-section .daily-summary-mini .stat-box {
    padding: 10px 8px;
  }

  #daily-section .daily-summary-mini .stat-box strong {
    font-size: 1rem;
  }

  .daily-meal-total {
    margin-left: auto;
  }
}

body[data-appearance="dark"] {
  color-scheme: dark;
  --bg: #10161d;
  --bg-alt: #151d26;
  --bg-mid: #121a22;
  --panel: #151d26;
  --panel-strong: #1b2530;
  --ink: #f4f7f8;
  --muted: #a9b5bf;
  --accent: #13b98b;
  --accent-strong: #59dfb8;
  --accent-soft: rgba(19, 185, 139, 0.14);
  --button-bg: #1a242e;
  --glow-a: rgba(19, 185, 139, 0.16);
  --glow-b: rgba(255, 255, 255, 0.04);
  --line: #2b3743;
  --success: #4fd2aa;
  --track-green: #13b98b;
  --track-yellow: #f0c75d;
  --track-red: #ff806c;
  --danger: #ff9386;
  --danger-bg: rgba(159, 47, 47, 0.18);
  --card: #18212b;
  --soft-surface: #121a22;
  --shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
}

body[data-appearance="dark"],
body[data-appearance="dark"][data-current-view="daily"],
body[data-appearance="dark"][data-current-view="daily-checkin"] {
  background: var(--bg);
  color: var(--ink);
}

body[data-appearance="dark"] .hero,
body[data-appearance="dark"] .panel,
body[data-appearance="dark"] .settings-panel,
body[data-appearance="dark"] .summary-card,
body[data-appearance="dark"] .snapshot-card,
body[data-appearance="dark"] .meal-card,
body[data-appearance="dark"] .metrics-card,
body[data-appearance="dark"] .recipe-summary,
body[data-appearance="dark"] .food-card,
body[data-appearance="dark"] .meal-entry-card,
body[data-appearance="dark"] .meal-entry-tag-card,
body[data-appearance="dark"] .recipe-row,
body[data-appearance="dark"] .food-form-card,
body[data-appearance="dark"] .modal-card,
body[data-appearance="dark"] .selected-lookup,
body[data-appearance="dark"] .lookup-result,
body[data-appearance="dark"] .food-picker-option {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
}

body[data-appearance="dark"] .panel,
body[data-appearance="dark"] #daily-section.panel,
body[data-appearance="dark"] #daily-checkin-section.panel {
  background: var(--bg);
  border-color: var(--line);
}

body[data-appearance="dark"] .settings-group,
body[data-appearance="dark"] .stat-box,
body[data-appearance="dark"] .calorie-value-pill,
body[data-appearance="dark"] .tag-card,
body[data-appearance="dark"] .recipe-total-chip,
body[data-appearance="dark"] #daily-section .stat-box,
body[data-appearance="dark"] #daily-section .daily-empty-note,
body[data-appearance="dark"] #daily-section .metric-block,
body[data-appearance="dark"] #daily-section .habit-row,
body[data-appearance="dark"] #daily-checkin-section .stat-box,
body[data-appearance="dark"] #daily-checkin-section .metric-block,
body[data-appearance="dark"] #daily-checkin-section .habit-row,
body[data-appearance="dark"] .toggle-row,
body[data-appearance="dark"] .water-status-card,
body[data-appearance="dark"] .empty-checkin-card {
  background: var(--soft-surface);
  border-color: var(--line);
  color: var(--ink);
}

body[data-appearance="dark"] h1,
body[data-appearance="dark"] h2,
body[data-appearance="dark"] h3,
body[data-appearance="dark"] h4,
body[data-appearance="dark"] strong,
body[data-appearance="dark"] .meal-total,
body[data-appearance="dark"] .meal-tag,
body[data-appearance="dark"] .food-card strong,
body[data-appearance="dark"] .summary-card strong,
body[data-appearance="dark"] .snapshot-card strong,
body[data-appearance="dark"] .daily-remaining strong,
body[data-appearance="dark"] .daily-meal-total {
  color: var(--ink);
}

body[data-appearance="dark"] .muted,
body[data-appearance="dark"] .hero-copy,
body[data-appearance="dark"] .save-status,
body[data-appearance="dark"] .settings-note,
body[data-appearance="dark"] .about-row,
body[data-appearance="dark"] .week-picker span,
body[data-appearance="dark"] .field label,
body[data-appearance="dark"] .metric-block label,
body[data-appearance="dark"] .lookup-result small,
body[data-appearance="dark"] #daily-section .muted,
body[data-appearance="dark"] #daily-section .entry-field span,
body[data-appearance="dark"] #daily-section .metric-block label,
body[data-appearance="dark"] #daily-checkin-section .muted,
body[data-appearance="dark"] #daily-checkin-section .entry-field span,
body[data-appearance="dark"] #daily-checkin-section .metric-block label,
body[data-appearance="dark"] .unit-label,
body[data-appearance="dark"] .daily-remaining span,
body[data-appearance="dark"] .daily-summary-meta,
body[data-appearance="dark"] .daily-meal-subline,
body[data-appearance="dark"] .daily-food-meta,
body[data-appearance="dark"] .daily-food-grams {
  color: var(--muted);
}

body[data-appearance="dark"] .water-status-card.on-track {
  background: rgba(0, 135, 103, 0.16);
  border-color: rgba(0, 135, 103, 0.38);
}

body[data-appearance="dark"] .water-status-card.behind,
body[data-appearance="dark"] .water-status-card.needs-action {
  background: rgba(255, 190, 87, 0.12);
  border-color: rgba(255, 190, 87, 0.32);
}

body[data-appearance="dark"] .eyebrow,
body[data-appearance="dark"] .home-card strong,
body[data-appearance="dark"] .recipe-summary strong,
body[data-appearance="dark"] .tracking-badge,
body[data-appearance="dark"] .pill,
body[data-appearance="dark"] .lookup-result span,
body[data-appearance="dark"] .food-picker-option span,
body[data-appearance="dark"] #daily-section .eyebrow,
body[data-appearance="dark"] #daily-section .tracking-badge,
body[data-appearance="dark"] #daily-checkin-section .eyebrow {
  color: var(--accent-strong);
}

body[data-appearance="dark"] .tracking-badge,
body[data-appearance="dark"] .pill,
body[data-appearance="dark"] #daily-section .tracking-badge {
  background: var(--accent-soft);
  border-color: rgba(19, 185, 139, 0.26);
}

body[data-appearance="dark"] select,
body[data-appearance="dark"] input[type="text"],
body[data-appearance="dark"] input[type="number"],
body[data-appearance="dark"] input[type="search"],
body[data-appearance="dark"] textarea,
body[data-appearance="dark"] .food-picker-trigger,
body[data-appearance="dark"] #daily-section input[type="text"],
body[data-appearance="dark"] #daily-section input[type="number"],
body[data-appearance="dark"] #daily-section input[type="search"],
body[data-appearance="dark"] #daily-section select,
body[data-appearance="dark"] #daily-section .food-picker-trigger,
body[data-appearance="dark"] #daily-checkin-section input[type="text"],
body[data-appearance="dark"] #daily-checkin-section input[type="number"],
body[data-appearance="dark"] #daily-checkin-section input[type="search"],
body[data-appearance="dark"] #daily-checkin-section select {
  background: #111922;
  border-color: #344351;
  color: var(--ink);
}

body[data-appearance="dark"] input::placeholder {
  color: #7f8e9b;
}

body[data-appearance="dark"] input[list],
body[data-appearance="dark"] .food-picker-trigger::after {
  background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7L9 11L13 7' stroke='%23F4F7F8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

body[data-appearance="dark"] .ghost-button,
body[data-appearance="dark"] .chip-button,
body[data-appearance="dark"] .nav-tab,
body[data-appearance="dark"] .appearance-options button,
body[data-appearance="dark"] #daily-section .ghost-button,
body[data-appearance="dark"] #daily-section .chip-button,
body[data-appearance="dark"] #daily-checkin-section .ghost-button {
  background: var(--button-bg);
  border-color: var(--line);
  color: var(--ink);
}

body[data-appearance="dark"] .primary-button,
body[data-appearance="dark"] .chip-button.active,
body[data-appearance="dark"] .nav-tab.active,
body[data-appearance="dark"] .appearance-options button.active,
body[data-appearance="dark"] #daily-section .primary-button,
body[data-appearance="dark"] #daily-section .chip-button.active,
body[data-appearance="dark"] #daily-checkin-section .primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #07110e;
  box-shadow: 0 10px 24px rgba(19, 185, 139, 0.2);
}

body[data-appearance="dark"] .nav-tab.active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  box-shadow: inset 0 -2px 0 var(--accent);
}

body[data-appearance="dark"] .danger-button,
body[data-appearance="dark"] .row-remove-button,
body[data-appearance="dark"] .recipe-remove-button,
body[data-appearance="dark"] .habit-delete-button,
body[data-appearance="dark"] #daily-section .row-remove-button,
body[data-appearance="dark"] #daily-section .habit-delete-button,
body[data-appearance="dark"] #daily-checkin-section .row-remove-button,
body[data-appearance="dark"] #daily-checkin-section .habit-delete-button {
  background: var(--danger-bg);
  border-color: rgba(255, 128, 108, 0.28);
  color: var(--danger);
}

body[data-appearance="dark"] .modal-backdrop {
  background: rgba(2, 6, 10, 0.72);
}

body[data-appearance="dark"] .modal-header {
  border-bottom-color: var(--line);
}

body[data-appearance="dark"] .daily-summary-hero,
body[data-appearance="dark"] #daily-section .daily-meal-card,
body[data-appearance="dark"] #daily-section .daily-checkin-card,
body[data-appearance="dark"] #daily-checkin-section .daily-checkin-hero,
body[data-appearance="dark"] #daily-checkin-section .daily-checkin-card,
body[data-appearance="dark"] #daily-section .tracking-green,
body[data-appearance="dark"] #daily-section .tracking-yellow,
body[data-appearance="dark"] #daily-section .tracking-red {
  background: var(--card);
  border-color: var(--line);
}

body[data-appearance="dark"] .daily-progress-track {
  background: #2b3743;
}

body[data-appearance="dark"] .daily-progress-fill {
  background: linear-gradient(90deg, var(--accent), #5cdfba);
}

body[data-appearance="dark"] .offline-status {
  background: rgba(255, 128, 108, 0.14);
  border-color: rgba(255, 128, 108, 0.32);
  color: var(--danger);
}

@media (max-width: 760px) {
  body[data-appearance="dark"] .view-nav {
    background: rgba(18, 26, 34, 0.96);
    border-top-color: var(--line);
    box-shadow: 0 -14px 34px rgba(0, 0, 0, 0.32);
  }

  body[data-appearance="dark"] .nav-mobile .nav-tab {
    background: transparent;
    border-color: transparent;
    color: #a9b5bf;
  }

  body[data-appearance="dark"] .nav-mobile .nav-tab.active {
    background: var(--accent-soft);
    border-color: rgba(19, 185, 139, 0.22);
    color: var(--accent-strong);
  }
}

/* Flat meal food rows and running total, shared across appearances. */
body #daily-section .meal-entry-card,
body #daily-section .meal-entry-tag-card {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 12px 0;
  gap: 8px;
  box-shadow: none;
}
body #daily-section .meal-list > * + * {
  border-top: 1px solid var(--daily-line);
}
body #daily-section .meal-tag {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 400;
}
#daily-section .meal-entry-tag-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}
#daily-section .meal-entry-tag-top strong { overflow-wrap: anywhere; }
#daily-section .meal-entry-tag-card .tag-card-actions { justify-content: flex-end; }
#daily-section .meal-entry-tag-card .tag-card-actions button {
  min-height: 44px;
  padding: 6px 10px;
  font-size: .85rem;
}
.meal-running-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--daily-line, var(--line));
  margin-top: 8px;
  padding-top: 12px;
  font-size: 1rem;
  font-weight: 650;
  color: var(--daily-ink, var(--ink));
}
.meal-running-total strong { white-space: nowrap; font-weight: 750; }
body[data-appearance="dark"] #daily-section .meal-running-total {
  color: var(--ink);
  border-color: var(--line);
}
body[data-appearance="dark"] #daily-section .meal-list > * + * { border-color: var(--line); }
body[data-appearance="dark"] #daily-section .meal-entry-heading strong,
body[data-appearance="dark"] #daily-section .meal-entry-tag-top strong { color: var(--ink); }
body[data-appearance="dark"] #daily-section .meal-entry-calories { color: #62dfc4; }
#daily-section .meal-entry-tag-card .tag-card-actions button { flex: 0 0 auto; width: auto; }

.water-entry-control { margin: 16px 0; min-width: 0; }
.water-entry-control h4 { margin: 0 0 12px; }
.water-entry-control > label { display: block; margin-bottom: 6px; }
.water-input-actions { display: flex; align-items: stretch; gap: 10px; max-width: 360px; }
.water-input-actions input { flex: 1 1 0; min-width: 0; width: 100%; }
.water-input-actions button { flex: 0 0 auto; min-height: 44px; }
.water-running-total { margin-top: 12px; }
.water-running-total strong { font-size: 1rem; }
.water-running-total p { margin: 6px 0 0; }

/* Daily amount and actions share one compact line. */
#daily-section .meal-compact-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
#daily-section .meal-amount-control { display: flex; align-items: center; gap: 5px; min-width: 0; font-size: .85rem; }
#daily-section .meal-amount-control input { width: 68px; min-width: 0; height: 34px; min-height: 34px; padding: 5px; }
#daily-section .meal-compact-line .tag-card-actions { flex-wrap: nowrap; gap: 6px; flex-shrink: 0; }
#daily-section .meal-compact-line .tag-card-actions button,
#daily-section [data-add-meal] { width: auto; flex: 0 0 auto; height: 34px; min-height: 34px; padding: 5px 9px; font-size: .8rem; line-height: 1.2; }
#daily-section .meal-entry-fields { display: block; }
#daily-section .meal-entry-stats[hidden] { display: none; }
#daily-section .meal-entry-heading strong { overflow-wrap: anywhere; min-width: 0; }
#daily-section .meal-entry-heading { display: grid; grid-template-columns: minmax(0,1fr) auto; }
#daily-section .meal-compact-line .meal-entry-tags { min-width: 0; }
#daily-section .meal-compact-line .meal-tag { overflow-wrap: anywhere; font-size: .85rem; }
@media (max-width: 340px) { #daily-section .meal-compact-line { flex-wrap: wrap; } }
#daily-section .meal-compact-line .tag-card-actions { width: auto; }
#daily-section .meal-compact-line .meal-tag { white-space: nowrap; overflow-wrap: normal; }
#daily-section .meal-amount-control { flex: 0 1 auto; }
#daily-section .meal-amount-control span { white-space: nowrap; }

.more-destinations { display: grid; gap: 12px; }
.more-destination { display: flex; align-items: center; gap: 16px; width: 100%; padding: 18px; text-align: left; border: 1px solid var(--line); border-radius: 14px; background: var(--soft-surface); color: var(--ink); }
.more-destination-icon { flex: 0 0 40px; color: var(--accent-strong); }
.more-destination-icon svg { width: 36px; height: 36px; fill: currentColor; }
.more-destination strong { display: block; font-size: 1.05rem; }
.more-destination small { display: block; margin-top: 5px; font-size: .85rem; font-weight: 400; }
#more-menu h2 { margin: 0 0 18px; }
.more-destination-icon .nav-icon { width: 36px; height: 36px; }
/* Keep Meal Creator datalist decoration independent of theme background shorthands. */
#recipe-section input[list] {
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 18px 18px;
}
#recipe-section input[list]::-webkit-calendar-picker-indicator { opacity: 0; }
#recipe-section input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
#recipe-section input[type="number"]::-webkit-inner-spin-button,
#recipe-section input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
#recipe-section .recipe-row-field input { min-width: 0; text-overflow: ellipsis; }
/* Daily Check-In dark contrast: keep section tokens aligned with the active theme. */
body[data-appearance="dark"] #daily-checkin-section.panel {
  --daily-ink: var(--ink);
  --daily-muted: var(--muted);
  --daily-line: var(--line);
  --daily-soft: var(--soft-surface);
  color: var(--ink);
}
body[data-appearance="dark"] #daily-checkin-section input::placeholder {
  color: var(--muted);
  opacity: 1;
}
body[data-appearance="dark"] #daily-checkin-section :is(input, select, button):disabled {
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  background-color: var(--soft-surface);
  opacity: 1;
}

.meal-remaining, .meal-day-remaining { margin-top: 6px; }
@media (max-width: 760px) {
  .nav-mobile { display: block; }
  .nav-expand { display: block; width: 100%; min-height: 30px; padding: 4px; background: transparent; color: var(--ink); font-size: .8rem; }
  .nav-primary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 4px; }
  .nav-extra { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .2s ease; }
  .nav-extra-grid { min-height: 0; overflow: hidden; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 0 6px; }
  .nav-mobile.expanded .nav-extra { grid-template-rows: 1fr; }
  .nav-extra .nav-tab { margin-top: 8px; min-height: 62px; white-space: normal; }
  .nav-mobile .nav-label { white-space: normal; }
  .app-shell { padding-bottom: 130px; }
  .daily-summary-hero .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .daily-summary-hero .stat-box:last-child { grid-column: 1/-1; }
}
@media (prefers-reduced-motion: reduce) { .nav-extra { transition: none; } }

/* Weekly values are a compact readable list, sourced from saved daily entries. */
#week-snapshot { display: grid; grid-template-columns: 1fr; gap: 10px; }
.weekly-day-row { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); }
.weekly-day-title { display: flex; justify-content: space-between; gap: 10px; }
.weekly-day-values { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin: 12px 0 0; }
.weekly-day-values dt { color: var(--muted); font-size: .8rem; }
.weekly-day-values dd { margin: 4px 0 0; font-weight: 750; overflow-wrap: anywhere; font-size: .95rem; }
.daily-summary-meta { flex-direction: column; align-items: stretch; }
.daily-summary-meta > span { display: flex; justify-content: space-between; gap: 12px; }
@media (max-width: 760px) {
  .app-shell { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; padding-bottom: calc(var(--tracker-nav-height, 120px) + 8px); }
  .app-shell > .hero { flex: 0 0 auto; margin-bottom: 10px; }
  .app-shell > .layout { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; display: block; overscroll-behavior-y: contain; scroll-padding: 12px; }
  .app-shell > .layout > .panel { margin-bottom: 16px; }
  .view-nav { max-height: 45dvh; overflow-y: auto; }
  .settings-panel { bottom: calc(var(--tracker-nav-height, 120px) + 10px); max-height: calc(100dvh - var(--tracker-nav-height, 120px) - 30px); }
}

.compact-screen-title { display: none; }
.hero.compact-header { padding: 10px 14px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.hero.compact-header .brand-block { display: none; }
.hero.compact-header .compact-screen-title { display: block; margin: 0; font-size: 1.15rem; color: var(--ink); }
.hero.compact-header .hero-main { flex-wrap: nowrap; align-items: center; gap: 12px; }
.hero.compact-header .header-week { flex: 0 1 160px; min-width: 0; }
.hero.compact-header .header-week select { min-height: 38px; padding: 6px 10px; }
@media (max-width:760px) {
  .nav-primary, .nav-extra-grid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 4px; }
  .nav-mobile .nav-tab { padding: 6px 2px; min-height: 56px; gap: 4px; }
  .nav-mobile .nav-label { font-size: 10.5px; white-space: nowrap; letter-spacing: 0; }
  .nav-mobile .nav-icon { width: 24px; height: 24px; }
  .nav-extra .nav-tab { margin-top: 4px; min-height: 56px; }
}

.meal-daily-balance { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 6px; color: var(--daily-ink, var(--ink)); font-size: .95rem; }
.meal-daily-balance strong { font-weight: 800; white-space: nowrap; }
body[data-appearance="dark"] #daily-section .meal-daily-balance { color: var(--ink); }

#daily-section .meal-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 10px; padding: 3px 1px 8px; }
#daily-section .meal-toggle { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; min-height: 68px; padding: 10px 7px; border: 1px solid var(--line); color: var(--ink); background: var(--card); }
#daily-section .meal-toggle span { font-size: .875rem; font-weight: 650; }
#daily-section .meal-toggle strong { font-size: .875rem; white-space: nowrap; }
#daily-section .meal-toggle[aria-expanded="true"] { outline: 2px solid var(--accent-strong); outline-offset: -2px; }
#daily-section .meal-toggle.tracking-green { border-color: var(--track-green); }
#daily-section .meal-toggle.tracking-yellow { border-color: var(--track-yellow); }
#daily-section .meal-toggle.tracking-red { border-color: var(--track-red); }
#daily-section .meal-panels { grid-template-columns: minmax(0, 1fr); }
#daily-section .meal-panel[hidden] { display: none; }

#daily-section .meals-heading { margin: 0 0 -8px; font-size: 1rem; font-weight: 700; }

/* One flat Check-In page; settings retain their own layout. */
body[data-current-view="daily-checkin"] #compact-screen-title { display: none; }
#daily-checkin-section .checkin-flat { max-width: 760px; margin-inline: auto; gap: 20px; }
#daily-checkin-section .checkin-flat .daily-checkin-hero { padding: 0; background: transparent; border: 0; box-shadow: none; }
#daily-checkin-section .checkin-flat .daily-checkin-hero h2 { font-size: 1.3rem; margin: 0; }
#daily-checkin-section .checkin-selected-day { margin: 5px 0 0; color: var(--daily-muted); font-weight: 600; }
body #daily-checkin-section .checkin-flat :is(.daily-checkin-hero, .daily-checkin-card, .metric-block, .stat-box, .habit-row, .water-entry-control) { background: transparent; border: 0; box-shadow: none; border-radius: 0; }
#daily-checkin-section .checkin-flat .daily-checkin-card { padding: 0; display: grid; gap: 22px; }
#daily-checkin-section .checkin-flat :is(.metric-grid, .checkin-habits, .checkin-week-summary) { border-top: 1px solid var(--line); padding-top: 18px; }
#daily-checkin-section .checkin-flat :is(.water-entry-control, .metric-block, .stat-box) { padding: 0; }
#daily-checkin-section .checkin-flat h3 { font-size: 1rem; margin: 0 0 12px; }
#daily-checkin-section .checkin-flat .habit-row { padding: 10px 0; display: flex; align-items: center; gap: 8px; min-width: 0; }
#daily-checkin-section .checkin-flat .habit-row + .habit-row { border-top: 1px solid var(--line); }
#daily-checkin-section .checkin-flat .habit-check { flex: 1; min-width: 0; padding: 0; background: transparent; border: 0; }
#daily-checkin-section .checkin-flat .habit-check span { overflow-wrap: anywhere; }
#daily-checkin-section .checkin-flat .habit-actions { flex: 0 0 auto; display: flex; gap: 6px; }
#daily-checkin-section .checkin-flat .habit-row button { min-height: 40px; width: auto; padding: 7px 10px; font-size: .8rem; }
#daily-checkin-section .checkin-flat .habit-inline-input { flex: 1; width: 0; min-width: 0; }

#daily-checkin-section .checkin-flat .habit-list { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; max-width: 560px; gap: 0; }
#daily-checkin-section .checkin-flat .habit-row { width: 100%; box-sizing: border-box; }

/* Bound the navigation before guarding against horizontal overscroll. */
@media (max-width: 760px) {
  html, body { max-width: 100%; overflow-x: hidden; overscroll-behavior-x: none; }
  .app-shell { width: calc(100% - 20px); max-width: calc(100% - 20px); min-width: 0; touch-action: pan-y pinch-zoom; }
  .view-nav { box-sizing: border-box; width: 100%; max-width: 100%; min-width: 0; overflow-x: hidden; overscroll-behavior-x: none; touch-action: pan-y pinch-zoom; padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right)); }
  .nav-mobile, .nav-primary, .nav-extra, .nav-extra-grid, .nav-mobile .nav-tab { min-width: 0; max-width: 100%; box-sizing: border-box; }
  .nav-mobile .nav-label { min-width: 0; max-width: 100%; font-size: clamp(9.5px, 2.8vw, 10.5px); }
  .nav-expand { width: min(200px, 100%); min-height: 40px; margin: 0 auto 6px; padding: 8px 14px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); font-size: .8rem; font-weight: 700; text-align: center; }
  .nav-expand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
}

@media (max-width: 360px) {
  .view-nav { padding-inline: max(6px, env(safe-area-inset-left)) max(6px, env(safe-area-inset-right)); }
  .nav-mobile .nav-tab { padding-inline: 0; }
  .nav-mobile .nav-label { font-size: 9.5px; letter-spacing: -.15px; overflow: visible; text-overflow: clip; }
}

@media (max-width: 760px) {
  .nav-panel[hidden] { display: none; }
  .nav-panel { min-width: 0; max-width: 100%; padding-bottom: 6px; }
  .nav-expand { margin-bottom: 0; }
  .view-nav:not(:has(.nav-mobile.expanded)) { padding-block: 6px calc(6px + env(safe-area-inset-bottom)); background: transparent; border-top: 0; box-shadow: none; backdrop-filter: none; }
}

@media (max-width: 760px) { .nav-expand:hover, .nav-expand:active { transform: none; } }

#water-dialog { width: min(420px, calc(100% - 24px)); max-width: calc(100% - 24px); max-height: calc(100dvh - 32px); margin: auto; padding: 20px; overflow-y: auto; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--ink); box-shadow: 0 18px 60px rgba(0,0,0,.25); }
#water-dialog::backdrop { background: rgba(0,0,0,.4); }
.water-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.water-dialog-header h2 { margin: 0; font-size: 1.2rem; }
#water-dialog button { min-height: 44px; }
#water-dialog .water-entry-control { padding: 0; border: 0; background: transparent; }
#water-dialog .water-entry-control h4 { display: none; }
#water-dialog .water-input-actions { min-width: 0; }
#water-dialog input { min-width: 0; color: var(--ink); background: var(--panel); border: 1px solid var(--line); }

body[data-current-view="home"] .hero { padding: 16px; margin-bottom: 12px; }
body[data-current-view="home"] .brand-block .eyebrow { margin: 0; }
#home-section .home-card[data-view-target="daily"] { grid-template-rows: auto 1fr auto; background: var(--accent-soft); border-color: var(--accent); }
#home-section .home-card[data-view-target="daily"] .muted { color: var(--ink); font-size: 1.05rem; font-weight: 650; }

#daily-section .daily-back-top { width: auto; min-height: 40px; padding: 7px 12px; font-size: .8rem; flex: 0 0 auto; }

.hero.weekly-header { padding: 0; margin-bottom: 12px; }
.hero.weekly-header .hero-main { display: none; }
.weekly-heading { display: grid; gap: 10px; margin-bottom: 20px; }
.weekly-heading h2 { margin: 0; font-size: 1.25rem; color: var(--ink); }
#weekly-week-picker { max-width: 240px; }
#weekly-week-picker .header-week { width: 100%; margin: 0; }
#weekly-section { max-width: 100%; }
#weekly-section :is(.summary-card, .snapshot-card, .weekly-day-row) { background: transparent; border: 0; border-radius: 0; box-shadow: none; padding: 10px 0; min-width: 0; }
#weekly-section > :is(.summary-grid, .snapshot-grid) { gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
#weekly-section #week-snapshot { gap: 0; }
#weekly-section .weekly-day-row + .weekly-day-row { border-top: 1px solid var(--line); }
.weekly-day-title { align-items: center; gap: 12px; }
.weekly-day-status { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: 0 0 12px; margin-left: auto; }
.weekly-day-status.status-green { background: var(--track-green); }
.weekly-day-status.status-yellow { background: var(--track-yellow); }
.weekly-day-status.status-red { background: var(--track-red); }
@media (max-width:760px) { .hero.weekly-header { margin-bottom: 0; } }
#weekly-section > .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#weekly-section .summary-card strong { font-size: 1.15rem; }
@media (min-width: 1000px) { #weekly-section > .summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

#daily-checkin-section select.checkin-selected-day { width: 160px; max-width: 100%; min-height: 42px; margin-top: 10px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); }
#daily-checkin-section .checkin-flat .daily-checkin-card > .metric-grid:first-child { border-top: 0; padding-top: 0; }
#daily-checkin-section .checkin-flat .metric-grid + .water-entry-control { border-top: 1px solid var(--line); padding-top: 18px; }

#daily-section [data-meal-entry-form] [type="submit"][hidden] { display: none !important; }

/* The launcher covers the app without unmounting or scrolling its current view. */
body.welcome-visible .app-shell { visibility: hidden; }
#welcome-dialog {
  box-sizing: border-box; width: 100%; max-width: 100%; height: 100dvh;
  max-height: 100dvh; margin: 0; padding: max(24px, env(safe-area-inset-top)) 20px;
  border: 0; border-radius: 0; color: var(--ink); background: var(--panel);
  overflow-y: auto; overflow-x: hidden;
}
#welcome-dialog[open] { display: grid; place-items: center; }
.welcome-content { width: 100%; max-width: 480px; text-align: center; margin: auto; }
.welcome-content h1 { margin: 0 0 12px; font-size: clamp(2rem, 7vw, 3rem); letter-spacing: .08em; }
.welcome-content > p { color: var(--muted); margin: 0 0 36px; }
.welcome-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.welcome-actions button {
  min-width: 0; min-height: 128px; padding: 20px 8px; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--accent-soft);
  color: var(--ink); font: inherit; font-size: .8rem; font-weight: 750;
}
.welcome-actions .nav-icon { width: 28px; height: 28px; color: var(--accent-strong); }
.welcome-actions svg { width: 100%; height: 100%; fill: currentColor; }
.welcome-actions button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.welcome-actions button:hover { border-color: var(--accent); }

@media (max-width: 760px) {
  .view-nav { bottom: var(--tracker-viewport-bottom, 0px); }
  .nav-expand { min-height: 44px; }
  .app-shell {
    padding-bottom: calc(var(--tracker-nav-height, 56px) + var(--tracker-viewport-bottom, 0px) + 8px);
  }
}

/* Food List only: one title and matching action/search controls. */
body[data-current-view="food"] .hero-main { display: none; }
body[data-current-view="food"] .hero.compact-header { padding: 0; margin-bottom: 0; }
#food-section .food-list-title { margin: 0 0 16px; }
.food-list-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
#food-section .food-list-controls > :is(button, input) {
  box-sizing: border-box; width: 100%; min-width: 0; height: 48px;
  margin: 0; padding: 10px 12px; border-radius: 10px;
  font-family: inherit; font-size: .8rem; font-weight: 750; line-height: 1.2;
}
#food-section #food-search { background: var(--panel); color: var(--ink); border: 1px solid var(--muted); }
#food-section #food-search::placeholder { color: var(--ink); opacity: 1; }
#food-section .food-form-panel:empty { display: none; }
#food-section #food-count { margin: 12px 0; }

.welcome-setup { margin-bottom: 24px; }
.welcome-setup p { color: var(--muted); margin: 0 0 16px; }
.welcome-setup button { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; }
.welcome-setup .nav-icon { width: 24px; height: 24px; }
.welcome-setup svg { width: 100%; height: 100%; fill: currentColor; }

.weekly-context { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.weekly-context #weekly-week-picker { min-width: 0; }
.weekly-trend-label { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-size: .85rem; font-weight: 650; white-space: nowrap; }
.weekly-trend-label .weekly-day-status { margin-left: 0; }
