:root {
  color-scheme: dark;
  --bg: #121619;
  --panel: #1b2126;
  --soft: #242c32;
  --line: #303a41;
  --text: #eef1ef;
  --muted: #a1adae;
  --accent: #f5c451;
  --accent-bg: #332d1c;
  --danger: #ff8686;
  --danger-bg: #382324;
  --radius: 18px;
  font:
    16px/1.6 'Inter',
    'Segoe UI',
    system-ui,
    sans-serif;
}
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f4f6f5;
  --panel: #fff;
  --soft: #edf1ee;
  --line: #d8e0da;
  --text: #202b27;
  --muted: #586b61;
  --accent: #775500;
  --accent-bg: #fff0bd;
  --danger: #b72c36;
  --danger-bg: #fff0f0;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  letter-spacing: -0.015em;
}
a {
  color: inherit;
  text-decoration: none;
}
button,
input {
  font: inherit;
  color: inherit;
}
button,
a,
input {
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
[hidden] {
  display: none !important;
}
.shell {
  width: min(100% - 2.5rem, 850px);
  margin: auto;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 0 2.5rem;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.brand > span {
  font-size: 1.65rem;
  font-weight: 750;
  letter-spacing: -0.07em;
}
.brand-dot {
  color: var(--accent);
}
.profile {
  font-size: 0.875rem;
  color: var(--muted);
  max-width: 50%;
  overflow-wrap: anywhere;
}
.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  font-weight: 650;
  color: var(--muted);
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: clamp(2.3rem, 7vw, 3.5rem);
  font-weight: 620;
  line-height: 1.13;
  letter-spacing: -0.055em;
  margin-bottom: 1rem;
}
h1 span {
  color: var(--accent);
}
h2 {
  font-size: 1.1rem;
  line-height: 1.4;
  letter-spacing: -0.025em;
  margin-bottom: 0.75rem;
}
h3 {
  font-size: 1rem;
  line-height: 1.45;
  margin-bottom: 0.5rem;
}
.muted {
  color: var(--muted);
  font-size: 0.875rem;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.25rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #f5c451;
  color: #20231e;
  font-weight: 650;
  font-size: 0.95rem;
  min-height: 48px;
}
.button:hover {
  background: #ffda7e;
}
.button.secondary {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}
.button.secondary:hover {
  background: var(--soft);
}
.plain-button {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 0.65rem;
  font-size: 0.875rem;
}
.plain-button:hover {
  color: var(--text);
}
.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.icon-button:hover {
  background: var(--soft);
}
.title-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin: 1rem 0 1.5rem;
}
.title-row h1 {
  margin: 0 0 0.5rem;
}
.title-row p {
  margin-bottom: 0;
}
.tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 1.75rem;
}
.tabs button {
  flex: 1;
  border: 0;
  background: none;
  padding: 0.6rem;
  color: var(--muted);
  border-radius: 8px;
  font-size: 0.95rem;
}
.tabs button.active {
  background: var(--soft);
  color: var(--text);
  font-weight: 600;
}
.date-nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}
.date-nav input {
  flex: 1;
  min-width: 0;
}
input {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.6rem 0.7rem;
  font-size: 0.875rem;
  min-height: 42px;
}
.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}
.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  background: var(--soft);
  font-size: 0.8rem;
  white-space: nowrap;
}
.calorie-card {
  border-top-color: var(--accent);
}
.calorie-number {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  margin: 1.1rem 0 1.5rem;
}
.calorie-number strong {
  font-size: clamp(3.5rem, 10vw, 5rem);
  font-weight: 550;
  letter-spacing: -0.07em;
  line-height: 1;
}
.calorie-number > span {
  font-size: 1rem;
  color: var(--muted);
}
progress {
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 8px;
  appearance: none;
  overflow: hidden;
  background: var(--soft);
  accent-color: var(--accent);
}
progress::-webkit-progress-bar {
  background: var(--soft);
}
progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 8px;
}
progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 8px;
}
.calorie-card > p {
  margin: 1rem 0 0;
}
.macros {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.75rem;
}
.macro {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.macro > span:first-child {
  font-size: 0.875rem;
}
.macro strong {
  font-size: 2rem;
  font-weight: 550;
  letter-spacing: -0.05em;
  margin: 0.4rem 0 0;
  overflow-wrap: anywhere;
}
.macro progress {
  margin-top: 1rem;
}
.is-danger {
  border-color: var(--danger);
  background: var(--danger-bg);
}
.is-danger strong {
  color: var(--danger);
}
.is-danger progress {
  accent-color: var(--danger);
}
.is-danger progress::-webkit-progress-value {
  background: var(--danger);
}
.is-danger progress::-moz-progress-bar {
  background: var(--danger);
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.75rem 0 1rem;
}
.section-heading h2 {
  margin-bottom: 0;
}
.section-heading input {
  max-width: 55%;
}
.empty {
  text-align: center;
  padding: 2.5rem 1.25rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty-icon {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 1rem;
  color: var(--accent);
}
.empty p {
  font-size: 0.875rem;
  color: var(--muted);
  max-width: 350px;
  margin: 0 auto;
}
.meal {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
  margin-bottom: 0.8rem;
}
.meal img {
  width: 112px;
  height: 100%;
  min-height: 140px;
  object-fit: cover;
  background: var(--soft);
}
.meal-content {
  padding: 1.2rem;
}
.meal-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.meal-energy {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0.75rem 0 0.25rem;
  color: var(--accent);
}
.meal-macros {
  font-size: 0.875rem;
  color: var(--muted);
}
.meal details {
  margin-top: 0.75rem;
}
.meal summary {
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--muted);
}
.meal ul {
  font-size: 0.875rem;
  padding-left: 1.2rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.meal ul:last-child {
  margin-bottom: 0;
}
.notice {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  font-size: 0.875rem;
  margin: 1rem 0;
}
.notice.error {
  border-color: var(--danger);
  color: var(--danger);
}
.job-line {
  margin-top: 0.5rem;
}
.footnote {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.8;
  margin: 1rem 0 0;
}
.training-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
}
.training-row:first-child {
  border: 0;
  padding-top: 0;
}
.training-row:last-child {
  padding-bottom: 0;
}
.training-row span:last-child {
  color: var(--muted);
  font-size: 0.875rem;
}
.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
  text-align: left;
  margin: 0.65rem 0;
  padding: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.history-row strong {
  font-size: 1rem;
}
.history-row small {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 0.2rem;
}
.history-row:hover {
  border-color: var(--accent);
}
.goals-card h2 {
  font-size: 2rem;
  line-height: 1.2;
  margin: 1rem 0;
}
.goal-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}
.goal-row strong {
  font-weight: 550;
  color: var(--accent);
}
.goals-card .button {
  margin: 1.5rem 0 1rem;
}
.goals-card > p:last-child {
  margin-bottom: 0;
}
.app-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
  margin-top: 2rem;
}
.brand-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 2.5rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}
.brand-footer > span {
  font-size: 0.8rem;
}
.login {
  text-align: center;
  max-width: 600px;
  margin: 1rem auto 2rem;
}
.login h1 {
  margin: 1.2rem 0;
}
.intro {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.8;
}
.login > .button {
  margin: 0.35rem;
  min-width: 200px;
}
.privacy-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 1.25rem;
}
.login-illustration {
  position: relative;
  width: 280px;
  height: 230px;
  margin: 1.5rem auto 1rem;
  display: grid;
  place-items: center;
}
.plate {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 22px;
  transform: rotate(-12deg);
  box-shadow: 0 18px 40px #00000012;
}
.plate-inner {
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-bg);
}
.plate-inner span {
  font-size: 2.5rem;
  letter-spacing: -0.08em;
  font-weight: 650;
  color: var(--accent);
}
.orbit-label {
  position: absolute;
  font-size: 0.875rem;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.label-food {
  left: 0;
  top: 35px;
  transform: rotate(-8deg);
}
.label-day {
  right: 0;
  bottom: 25px;
  transform: rotate(7deg);
}
@media (min-width: 760px) {
  #view-today {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5rem;
  }
  #view-today > * {
    grid-column: 1/-1;
  }
  .calorie-card {
    grid-column: 1 !important;
  }
  .macros {
    grid-column: 2 !important;
    margin: 0;
    align-content: stretch;
    gap: 0.5rem;
  }
  .macro {
    justify-content: center;
    padding: 0.85rem;
  }
  .macro strong {
    font-size: 1.8rem;
  }
  .date-nav {
    max-width: 430px;
  }
  .login {
    margin-top: 2rem;
  }
}
@media (max-width: 400px) {
  .shell {
    width: calc(100% - 1.5rem);
  }
  .card {
    padding: 1.15rem;
  }
  .macro {
    padding: 0.8rem;
  }
  .macro strong {
    font-size: 1.7rem;
  }
  .meal {
    grid-template-columns: 80px minmax(0, 1fr);
    padding: 0;
  }
  .meal img {
    width: 80px;
    min-height: 150px;
  }
  .meal-content {
    padding: 1rem;
  }
  .app-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .brand-footer > span {
    max-width: 75%;
    text-align: right;
  }
  .date-nav {
    gap: 0.35rem;
  }
  .date-nav .plain-button {
    padding: 0.3rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

.action-form {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}
.action-form label {
  display: grid;
  gap: 0.4rem;
}
.action-form input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.8rem;
  border: 1px solid currentColor;
  border-radius: 0.7rem;
  background: transparent;
  color: inherit;
  font: inherit;
}
button:disabled {
  opacity: 0.6;
  cursor: wait;
}
dialog {
  max-width: min(90vw, 440px);
  color: inherit;
  background: var(--bg, #18201a);
}
dialog::backdrop {
  background: #0009;
}
.tabs {
  overflow-x: auto;
}
.tabs button {
  flex-shrink: 0;
}
.action-form select,
.action-form textarea {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
.action-form textarea {
  min-height: 110px;
  resize: vertical;
}
.favorite-photo {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius);
}
dialog {
  max-height: 90dvh;
  overflow-y: auto;
}

/* Card actions have a visible boundary; explanatory text keeps the muted style. */
.meal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.action-button,
.stepper-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  background: var(--soft);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
}
.action-button:hover,
.stepper-button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.action-button.danger {
  color: var(--danger);
  background: var(--danger-bg);
}
.plain-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--text);
  min-height: 44px;
}
.portion-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.portion-label {
  margin-right: auto;
  font-size: 0.875rem;
  font-weight: 600;
}
.stepper-button {
  width: 44px;
  padding: 0;
  font-size: 1.5rem;
}
.portion-value {
  min-width: 2.5ch;
  font-size: 1.1rem;
  font-weight: 650;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.portion-status {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.8rem;
}
.portion-status:empty {
  display: none;
}
.notice > .action-button,
#favorites-list .action-button {
  margin: 0.35rem 0.5rem 0.35rem 0;
}
@media (max-width: 480px) {
  .meal-actions {
    grid-template-columns: 1fr;
  }
}

.progress-chart {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 1rem;
}
.chart-text {
  fill: var(--muted);
  font: 22px sans-serif;
}
.chart-over {
  fill: var(--danger);
}
.chart-within {
  fill: var(--accent);
}
.chart-unknown {
  fill: var(--muted);
}
.chart-empty {
  stroke: var(--line);
  stroke-width: 3;
}
.chart-goal {
  stroke: var(--text);
  stroke-width: 2;
}
.progress-chart [role='button'] {
  cursor: pointer;
}
.progress-chart [role='button']:focus {
  outline: 2px solid var(--accent);
}
.measurement-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
}
.measurement-dot {
  fill: var(--accent);
}
.measurement-fields,
.measurement-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.measurement-fields input {
  min-width: 0;
}
.measurement-charts {
  margin-top: 1rem;
}
.measurement-value {
  font-size: 1.7rem;
}
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
}
.checkbox-label input {
  width: auto;
}
.history-row.is-danger {
  color: var(--danger);
  background: var(--danger-bg);
}
#measurement-history .card {
  margin-top: 1rem;
}
#measurement-history .action-button {
  margin-right: 0.5rem;
}
@media (max-width: 540px) {
  .measurement-charts {
    grid-template-columns: 1fr;
  }
}
.recipe-card {
  margin-top: 1rem;
}
.recipe-ingredient {
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}
.recipe-card > .action-button {
  margin: 0.4rem 0.4rem 0.4rem 0;
}
.recipe-ingredients {
  margin: 1rem 0;
}
.product-source {
  display: block;
  color: var(--accent);
  margin: 0.8rem 0;
  font-size: 0.85rem;
  text-decoration: underline;
}
.recipe-card input {
  min-width: 0;
}
.source-credits {
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
  padding: 1rem;
}
.source-credits a {
  color: var(--muted);
  text-decoration: underline;
}

/* A text/voice/recipe entry has no image cell. This also overrides the mobile grid. */
.meal.meal-without-photo {
  grid-template-columns: minmax(0, 1fr);
}
.meal-content {
  min-width: 0;
  overflow-wrap: anywhere;
}
.recipe-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.8rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.recipe-card > p,
.recipe-card > h3,
.recipe-card > .action-button,
.recipe-card > .recipe-ingredients {
  margin: 0;
}
.recipe-card > .action-button {
  width: 100%;
}
.recipe-card > .action-form:empty {
  display: none;
}
.recipe-ingredient,
.recipe-card .action-form,
.recipe-card .notice {
  min-width: 0;
}
