:root {
  --ds-void: #07080f;
  --ds-surface: #101030;
  --ds-surface-raised: #181848;
  --ds-border: #242478;
  --ds-text: #fce4fc;
  --ds-muted: #c0ccd8;
  --ds-accent: #60d8fc;
  --ds-accent-2: #6c60fc;
  --ds-accent-3: #7848fc;
  --ds-highlight: #f060fc;
  --ds-success: #69e6a6;
  --ds-warning: #ffd166;
  --ds-danger: #ff8fa3;
  --ds-radius: 8px;
  --ds-content: 1280px;
  --ds-shadow: 0 10px 24px rgb(0 0 0 / 24%);
  --ds-space-1: 0.25rem;
  --ds-space-2: 0.5rem;
  --ds-space-3: 0.75rem;
  --ds-space-4: 1rem;
  --ds-space-5: 1.5rem;
  --ds-space-6: 2rem;
}

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

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 85% 5%, rgb(108 96 252 / 12%), transparent 25rem),
    var(--ds-void);
  color: var(--ds-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
}

a {
  color: var(--ds-accent);
  text-underline-offset: 0.2em;
}

a:hover {
  color: #a1e9ff;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--ds-accent);
  outline-offset: 3px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--ds-text);
  font-weight: 700;
  line-height: 1.15;
}

h1 {
  max-width: 22ch;
  margin-bottom: 0.5rem;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  letter-spacing: -0.025em;
}

h3 {
  font-size: 1.1rem;
}

.app-container {
  width: min(var(--ds-content), calc(100% - clamp(1.25rem, 4vw, 3rem)));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 1rem;
  transform: translateY(-200%);
  border-radius: var(--ds-radius);
  background: var(--ds-accent);
  color: var(--ds-void);
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--ds-border);
  background: rgb(16 16 48 / 92%);
  backdrop-filter: blur(16px);
}

.site-nav {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-2);
  color: var(--ds-text);
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
}

.brand:hover {
  color: var(--ds-text);
}

.brand-mark {
  width: 38px;
  height: 30px;
  object-fit: cover;
  border-radius: 50%;
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-form {
  display: inline-flex;
  margin: 0;
}

.nav-action {
  min-height: auto;
  padding: 0.5rem 0.7rem;
  border: 0;
  background: transparent;
  color: var(--ds-muted);
  font-weight: 600;
}

.nav-action:hover {
  color: var(--ds-accent);
}

.desktop-nav a,
.desktop-nav span,
.mobile-nav-panel a,
.mobile-nav-panel span {
  display: block;
  padding: 0.5rem 0.7rem;
  border-radius: var(--ds-radius);
  color: var(--ds-muted);
  font-weight: 600;
  text-decoration: none;
}

.desktop-nav a:hover,
.mobile-nav-panel a:hover,
.desktop-nav a[aria-current="page"],
.mobile-nav-panel a[aria-current="page"] {
  background: rgb(96 216 252 / 10%);
  color: var(--ds-accent);
}

[aria-disabled="true"] {
  opacity: 0.58;
}

.mobile-nav {
  display: none;
  position: relative;
}

.mobile-nav summary {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  color: var(--ds-text);
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.mobile-nav summary::-webkit-details-marker {
  display: none;
}

.mobile-nav summary::after {
  margin-left: 0.5rem;
  color: var(--ds-accent);
  content: "+";
}

.mobile-nav[open] summary::after {
  content: "−";
}

.mobile-nav-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: min(16rem, calc(100vw - 2rem));
  padding: 0.5rem;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  background: var(--ds-surface-raised);
  box-shadow: var(--ds-shadow);
}

.main-content {
  min-height: calc(100vh - 128px);
  padding-block: clamp(1.25rem, 3vw, 2.25rem);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(16rem, 0.65fr);
  align-items: center;
  gap: clamp(1.5rem, 5vw, 4rem);
  min-height: 50vh;
}

.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--ds-accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lead {
  max-width: 62ch;
  margin-bottom: 1rem;
  color: var(--ds-muted);
  font-size: clamp(0.95rem, 1.5vw, 1.08rem);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button,
button,
input[type="submit"] {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: var(--ds-space-2) var(--ds-space-3);
  border: 1px solid transparent;
  border-radius: var(--ds-radius);
  font-weight: 750;
  text-decoration: none;
}

.button-primary,
button[type="submit"],
input[type="submit"] {
  border-color: var(--ds-accent);
  background: var(--ds-accent);
  color: var(--ds-void);
}

.button-primary:hover,
button[type="submit"]:hover,
input[type="submit"]:hover {
  background: #9be8ff;
  color: var(--ds-void);
}

.button-secondary {
  border-color: var(--ds-border);
  background: var(--ds-surface);
  color: var(--ds-text);
}

.button-secondary:hover {
  border-color: var(--ds-accent);
  color: var(--ds-accent);
}

.hero-orbit {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--ds-border);
  border-radius: 50%;
  background: var(--ds-surface);
  box-shadow: 0 0 70px rgb(96 216 252 / 12%);
}

.hero-orbit img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.section-stack {
  padding-block: 0;
}

.hero + .section-stack {
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--ds-space-4);
  margin-bottom: var(--ds-space-4);
}

.split-heading > :first-child {
  min-width: 0;
}

.panel {
  margin-bottom: var(--ds-space-5);
  padding: clamp(0.85rem, 2vw, 1.25rem);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  background: var(--ds-surface);
}

.panel h2 {
  margin-bottom: 0.75rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--ds-space-2);
  margin-bottom: var(--ds-space-4);
}

.metric-grid div {
  min-width: 0;
  padding: 0.65rem var(--ds-space-3);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  background: var(--ds-surface-raised);
}

.metric-grid dt {
  color: var(--ds-muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.metric-grid dd {
  margin: 0.15rem 0 0;
  font-size: 1rem;
  font-weight: 750;
}

.table-shell {
  margin-top: 0.75rem;
  overflow-x: auto;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
}

.table-shell table {
  width: 100%;
  min-width: 48rem;
  border-collapse: collapse;
}

.table-shell th,
.table-shell td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--ds-border);
  text-align: left;
  white-space: nowrap;
}

.table-shell thead {
  background: var(--ds-surface-raised);
  color: var(--ds-muted);
}

.table-shell tbody tr:last-child > * {
  border-bottom: 0;
}

.search-form {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--ds-border);
}

.section-nav a {
  padding: 0.35rem 0.65rem;
  border-radius: var(--ds-radius);
  color: var(--ds-muted);
  font-weight: 700;
  text-decoration: none;
}

.section-nav a:hover,
.section-nav a[aria-current="page"] {
  background: rgb(96 216 252 / 10%);
  color: var(--ds-accent);
}

.date-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.date-navigation > div {
  display: grid;
  text-align: center;
}

.date-picker {
  display: flex;
  max-width: 25rem;
  align-items: end;
  gap: var(--ds-space-2);
  margin: 0 auto var(--ds-space-4);
}

.date-picker label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.date-picker input {
  flex: 1 1 auto;
}

.compact-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--ds-space-4);
  margin-bottom: var(--ds-space-3);
}

.metric-detail,
.metric-balance {
  display: block;
  margin-top: var(--ds-space-1);
  font-size: 0.75rem;
}

.metric-detail {
  color: var(--ds-muted);
}

.metric-balance {
  color: var(--ds-success);
}

.metric-over {
  border-color: var(--ds-warning) !important;
}

.metric-over .metric-balance {
  color: var(--ds-warning);
}

.missing-target-note {
  margin: -0.25rem 0 var(--ds-space-4);
  color: var(--ds-muted);
  font-size: 0.85rem;
}

.meal-card {
  margin-bottom: 0;
}

.weekly-summary h2 {
  margin-bottom: 0.25rem;
}

.weekly-summary .table-shell {
  margin-top: 0.5rem;
}

.weekly-summary table {
  min-width: 50rem;
  table-layout: fixed;
}

.weekly-summary th,
.weekly-summary td {
  text-align: right;
}

.weekly-summary th:first-child {
  width: 7rem;
  text-align: left;
}

.weekly-summary thead th:not(:first-child) {
  text-align: center;
}

.weekly-summary thead a {
  display: block;
  text-decoration: none;
}

.weekly-summary thead span {
  color: var(--ds-muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.weekly-summary [aria-current="date"] {
  background: rgb(96 216 252 / 10%);
  box-shadow: inset 0 3px var(--ds-accent);
}

.meal-items {
  display: grid;
  gap: 0;
  padding: 0;
  list-style: none;
}

.meal-items li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.3rem;
  border-bottom: 1px solid var(--ds-border);
}

.meal-items li span:last-child,
.meal-total,
.item-heading p {
  color: var(--ds-muted);
}

.meal-item-forms {
  display: grid;
  gap: 0.75rem;
}

.meal-item-form {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(8rem, 1fr) auto;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
}

.meal-item-form legend {
  grid-column: 1 / -1;
  padding-inline: 0.25rem;
  color: var(--ds-muted);
  font-weight: 700;
}

.delete-field {
  align-self: center;
}

@media (max-width: 640px) {
  .date-navigation {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .date-navigation > div {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .compact-section-heading {
    align-items: start;
    flex-direction: column;
    gap: var(--ds-space-1);
  }

  .meal-items li {
    gap: 0.5rem;
    font-size: 0.82rem;
  }

  .meal-items li span:last-child {
    text-align: right;
  }

  .meal-item-form {
    grid-template-columns: 1fr;
  }
}

.search-form .form-field {
  flex: 1 1 18rem;
}

.checkbox-field {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.card-list {
  display: grid;
  gap: 0.75rem;
}

.food-card {
  margin-bottom: 0;
}

.food-card-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.food-card-list .metric-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.food-card h2,
.food-card .split-heading {
  margin-bottom: 0.4rem;
}

.food-metrics {
  margin-bottom: 0;
}

.status-badge,
.feature-state {
  display: inline-block;
  color: var(--ds-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.range-picker {
  display: flex;
  max-width: 28rem;
  align-items: end;
  gap: var(--ds-space-2);
  margin-bottom: var(--ds-space-4);
}

.range-picker label {
  align-self: center;
  font-weight: 700;
}

.range-picker select {
  flex: 1 1 auto;
}

.trend-panel {
  overflow: hidden;
}

.weight-chart {
  display: block;
  width: 100%;
  max-height: 22rem;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  background: var(--ds-surface-raised);
}

.chart-axis {
  stroke: var(--ds-muted);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--ds-accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
}

.chart-point {
  fill: var(--ds-surface-raised);
  stroke: var(--ds-accent);
  stroke-width: 4;
}

@media (max-width: 480px) {
  .range-picker {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .range-picker label {
    grid-column: 1 / -1;
  }
}

.status-badge {
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--ds-border);
  border-radius: 999px;
  white-space: nowrap;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.feature-card {
  min-width: 0;
  padding: clamp(1rem, 2vw, 1.5rem);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  background: var(--ds-surface);
}

.feature-card p {
  color: var(--ds-muted);
}

.feature-number {
  display: block;
  margin-bottom: 1.25rem;
  color: var(--ds-accent);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82rem;
}

.privacy-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: clamp(1rem, 4vw, 3rem);
  padding: clamp(1rem, 3vw, 2rem);
  border-left: 4px solid var(--ds-accent);
  border-radius: var(--ds-radius);
  background: var(--ds-surface-raised);
}

.privacy-panel > p {
  margin: 0;
  color: var(--ds-muted);
  font-size: 1rem;
}

.message-stack {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.app-message {
  display: flex;
  align-items: start;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  background: var(--ds-surface);
}

.message-marker {
  width: 0.7rem;
  height: 0.7rem;
  flex: 0 0 auto;
  margin-top: 0.45rem;
  border-radius: 50%;
  background: var(--ds-accent);
}

.app-message-success .message-marker {
  background: var(--ds-success);
}

.app-message-warning .message-marker {
  background: var(--ds-warning);
}

.app-message-error .message-marker {
  background: var(--ds-danger);
}

label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--ds-text);
  font-weight: 700;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]),
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  background: var(--ds-surface);
  color: var(--ds-text);
}

textarea {
  min-height: 6rem;
}

.helptext {
  display: block;
  margin-top: 0.35rem;
  color: var(--ds-muted);
  font-size: 0.8rem;
}

.errorlist {
  margin: 0.35rem 0;
  padding-left: 1.25rem;
  color: var(--ds-danger);
}

.pagination-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.page-link,
.page-position {
  padding: 0.5rem 0.75rem;
  border-radius: var(--ds-radius);
}

.page-link {
  border: 1px solid var(--ds-border);
  text-decoration: none;
}

.page-link.is-disabled {
  color: var(--ds-muted);
}

.empty-state,
.error-state {
  max-width: 42rem;
  margin-inline: auto;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  background: var(--ds-surface);
  text-align: center;
}

.empty-state p,
.error-state p:not(.error-code) {
  color: var(--ds-muted);
}

.empty-state-mark {
  display: block;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0 auto 0.75rem;
  border: 3px solid var(--ds-accent);
  border-radius: 50%;
}

.error-code {
  margin-bottom: 0.5rem;
  color: var(--ds-highlight);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.site-footer {
  border-top: 1px solid var(--ds-border);
  background: var(--ds-surface);
}

.profile-layout,
.form-page {
  display: grid;
  gap: 1rem;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2rem);
}

.profile-header h1,
.form-heading h1 {
  max-width: none;
  font-size: clamp(1.75rem, 3vw, 2.35rem);
}

.profile-avatar {
  display: grid;
  width: clamp(5rem, 12vw, 7rem);
  aspect-ratio: 1;
  flex: 0 0 auto;
  overflow: hidden;
  place-items: center;
  border: 1px solid var(--ds-border);
  border-radius: 50%;
  background: var(--ds-surface-raised);
  color: var(--ds-accent);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-intro .button {
  margin-top: 0.5rem;
}

.profile-section,
.preference-summary,
.app-form {
  padding: clamp(1rem, 2vw, 1.35rem);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  background: var(--ds-surface);
}

.profile-section h2,
.preference-summary h2 {
  margin-bottom: 0.65rem;
  font-size: 1.25rem;
}

.profile-bio {
  max-width: 70ch;
  margin-bottom: 0;
  color: var(--ds-muted);
}

.preference-summary {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 1.25rem;
}

.preference-summary dl {
  display: grid;
  gap: 0.65rem;
  margin: 0;
}

.preference-summary dl > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--ds-border);
}

.preference-summary dt {
  color: var(--ds-muted);
  font-weight: 500;
}

.preference-summary dd {
  margin: 0;
  text-align: right;
}

.form-heading {
  max-width: 52rem;
}

.auth-page {
  max-width: 36rem;
  margin-inline: auto;
}

.registration-page strong {
  color: var(--ds-text);
  overflow-wrap: anywhere;
}

.centered-actions {
  justify-content: center;
}

.app-form {
  display: grid;
  max-width: 52rem;
  gap: 0.9rem;
}

.form-field {
  min-width: 0;
}

.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea {
  border-color: var(--ds-danger);
}

.field-errors .errorlist {
  margin-top: 0.5rem;
}

.current-upload {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
  color: var(--ds-muted);
}

.clear-upload {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.clear-upload label {
  margin: 0;
  font-weight: 500;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}

.footer-content p {
  margin: 0;
}

.text-muted {
  color: var(--ds-muted) !important;
}

@media (max-width: 760px) {
  .desktop-nav {
    display: none;
  }

  .mobile-nav {
    display: block;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .hero-orbit {
    width: min(20rem, 78vw);
    grid-row: 1;
    margin-inline: auto;
  }

  .feature-grid,
  .privacy-panel,
  .preference-summary {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .food-card-list {
    grid-template-columns: 1fr;
  }

  .profile-header {
    align-items: start;
    flex-direction: column;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .footer-content {
    align-items: start;
    flex-direction: column;
    justify-content: center;
    padding-block: 1.25rem;
  }
}

@media (max-width: 420px) {
  .brand span {
    font-size: 1rem;
  }

  .brand-mark {
    width: 36px;
    height: 28px;
  }

  .hero-actions,
  .hero-actions .button {
    width: 100%;
  }

  .pagination-nav {
    align-items: stretch;
    flex-direction: column;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
