:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-soft: #fbfaf6;
  --surface-strong: #eef7f0;
  --ink: #121b17;
  --muted: #68736d;
  --line: #e3ded2;
  --accent: #1f7a55;
  --accent-dark: #15593d;
  --accent-soft: #dcefe5;
  --gold: #c8872b;
  --rust: #9f573d;
  --shadow: 0 26px 80px rgba(18, 27, 23, 0.14);
  --shadow-soft: 0 16px 44px rgba(18, 27, 23, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(200, 135, 43, 0.16), transparent 36%),
    linear-gradient(150deg, #fffdf8 0%, var(--bg) 50%, #e9f3ed 100%);
  color: var(--ink);
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(21, 89, 61, 0.18);
  border-radius: 8px;
  background: linear-gradient(145deg, #ffffff, #dff0e6);
  color: var(--accent-dark);
  box-shadow: 0 10px 28px rgba(21, 89, 61, 0.15);
}

.topbar__meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(227, 222, 210, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  font-size: 0.88rem;
  backdrop-filter: blur(14px);
}

.debug-toggle {
  min-height: 28px;
  border: 1px solid rgba(21, 89, 61, 0.16);
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 850;
}

.hero {
  position: relative;
  display: grid;
  min-height: 380px;
  align-items: end;
  padding: 56px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(18, 27, 23, 0.9), rgba(18, 27, 23, 0.58) 46%, rgba(18, 27, 23, 0.12)),
    url("https://images.unsplash.com/photo-1548199973-03cce0bbc87b?auto=format&fit=crop&w=1600&q=80")
      center 42% / cover;
  box-shadow: var(--shadow);
}

.hero::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, transparent 52%, rgba(0, 0, 0, 0.22));
  pointer-events: none;
}

.hero__content {
  position: relative;
  z-index: 1;
  max-width: 680px;
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #baf0cd;
}

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

h1 {
  margin-bottom: 18px;
  font-size: clamp(3.5rem, 12vw, 7.5rem);
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero__copy {
  max-width: 560px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.2rem;
  line-height: 1.6;
}

.hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.hero__stats span {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  color: rgba(255, 255, 255, 0.94);
  font-size: 0.9rem;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(340px, 0.82fr);
  gap: 24px;
  align-items: start;
  margin-top: 24px;
}

.app-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.app-version {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.82;
}

.intake-panel,
.result-panel {
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px);
}

.intake-panel {
  padding: 34px;
}

.result-panel {
  position: sticky;
  top: 24px;
  min-height: 460px;
  padding: 34px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(250, 247, 238, 0.78)),
    rgba(255, 255, 255, 0.76);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.panel-badge,
.confidence-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  white-space: nowrap;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.panel-badge {
  padding: 0 11px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.confidence-pill {
  padding: 0 12px;
  background: #fff0d6;
  color: #81531b;
}

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

.form-grid--wide {
  margin-top: 0;
}

.form-section-label {
  margin: 26px 0 14px;
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
}

.panel-heading + .form-section-label {
  margin-top: 0;
}

.field {
  display: grid;
  gap: 9px;
}

.field--full {
  grid-column: 1 / -1;
}

.field span {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  outline: none;
  padding: 0 16px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input::placeholder {
  color: #a1a79f;
}

input:focus,
select:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(47, 125, 87, 0.16);
}

.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

.input-with-unit:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(47, 125, 87, 0.16);
}

.input-with-unit input {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.input-with-unit span {
  padding: 0 16px;
  color: var(--muted);
  font-weight: 700;
}

.primary-button {
  display: flex;
  width: 100%;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  padding: 0 18px 0 20px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 16px 34px rgba(31, 122, 85, 0.24);
  transition:
    box-shadow 160ms ease,
    transform 160ms ease,
    filter 160ms ease;
}

.disclaimer {
  margin-top: 24px;
  padding: 14px 16px;
  border: 1px solid rgba(200, 135, 43, 0.24);
  border-radius: 8px;
  background: #fff8eb;
  color: #6f532c;
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.55;
}

.primary-button:hover {
  filter: saturate(1.08);
  box-shadow: 0 20px 38px rgba(31, 122, 85, 0.3);
  transform: translateY(-1px);
}

.cta-trust-line {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

.result-feedback {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.5;
}

.result-feedback--error {
  border: 1px solid rgba(159, 87, 61, 0.22);
  background: #fff4ef;
  color: var(--rust);
}

.empty-state,
.recommendation {
  display: grid;
  min-height: 396px;
  align-content: center;
}

.empty-state {
  gap: 24px;
}

.empty-state p,
#food-summary,
.rationale-copy,
.next-step p {
  color: var(--muted);
  line-height: 1.6;
}

.rationale-copy {
  margin-bottom: 0;
  padding: 14px 16px;
  border: 1px solid rgba(31, 122, 85, 0.14);
  border-radius: 8px;
  background: rgba(220, 239, 229, 0.46);
}

.assumptions-copy {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.secondary-factors {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(227, 222, 210, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.secondary-factors .eyebrow {
  margin-bottom: 12px;
  color: #81531b;
}

#secondary-factor-list {
  display: grid;
  gap: 10px;
}

.secondary-factor {
  display: grid;
  gap: 5px;
  padding-left: 12px;
  border-left: 3px solid rgba(200, 135, 43, 0.52);
}

.secondary-factor strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.secondary-factor p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.is-hidden {
  display: none;
}

.result-orb {
  display: grid;
  width: 74px;
  height: 74px;
  place-items: center;
  border: 1px solid rgba(31, 122, 85, 0.12);
  border-radius: 8px;
  background: linear-gradient(145deg, #f7fffa, #dcefe5);
  box-shadow: 0 18px 44px rgba(31, 122, 85, 0.16);
}

.result-orb span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 900;
}

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

.recommendation__header .eyebrow {
  margin-bottom: 0;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 26px 0;
}

.detail-item {
  display: grid;
  gap: 7px;
  align-items: start;
  min-height: 112px;
  padding: 16px;
  border: 1px solid rgba(227, 222, 210, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.detail-item strong {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.detail-item span {
  color: var(--ink);
  font-weight: 750;
  line-height: 1.45;
}

.next-step {
  padding: 18px 20px;
  border: 1px solid rgba(200, 135, 43, 0.22);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: linear-gradient(135deg, #fff8eb, #ffffff);
}

.food-matches {
  margin: 26px 0;
  padding: 18px;
  border: 1px solid rgba(227, 222, 210, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.food-matches__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.food-matches__heading .eyebrow {
  margin-bottom: 0;
}

.food-matches__heading span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.food-card-list {
  display: grid;
  gap: 12px;
}

.food-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(227, 222, 210, 0.9);
  border-radius: 8px;
  background: #ffffff;
}

.food-card strong {
  color: var(--accent-dark);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.food-card h3 {
  margin: 4px 0 0;
  font-size: 1rem;
  line-height: 1.2;
}

.food-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.food-card dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.food-card dl div {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.food-card dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.food-card dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 750;
}

.next-step strong {
  display: block;
  margin-bottom: 6px;
}

.next-step p {
  margin-bottom: 0;
}

.missing-info {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(200, 135, 43, 0.22);
}

.missing-info strong {
  margin-bottom: 8px;
  color: #81531b;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.missing-info ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.missing-info li {
  padding: 7px 10px;
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.debug-panel {
  margin-top: 24px;
  padding: 28px;
  border: 1px solid rgba(18, 27, 23, 0.14);
  border-radius: 8px;
  background: rgba(18, 27, 23, 0.92);
  color: #f8fbf7;
  box-shadow: var(--shadow);
}

.debug-panel .eyebrow {
  color: #baf0cd;
}

.debug-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.debug-panel__header h2 {
  margin-bottom: 0;
}

.debug-panel__header span {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
  font-weight: 800;
}

.debug-controls {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.debug-controls .field span {
  color: rgba(255, 255, 255, 0.82);
}

.debug-catalog-status {
  min-height: 58px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.74);
  font-weight: 800;
}

.debug-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.2fr);
  gap: 18px;
}

.sample-list {
  display: grid;
  gap: 10px;
}

.sample-card {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
  cursor: pointer;
  text-align: left;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.sample-card:hover {
  border-color: rgba(186, 240, 205, 0.42);
  background: rgba(255, 255, 255, 0.11);
  transform: translateY(-1px);
}

.sample-card strong {
  font-size: 0.95rem;
}

.sample-card span {
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.82rem;
  line-height: 1.4;
}

.debug-output {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.debug-summary {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid rgba(186, 240, 205, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.debug-summary p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.72);
}

.debug-summary div {
  display: grid;
  gap: 4px;
}

.debug-summary strong {
  color: #baf0cd;
  font-size: 0.76rem;
  text-transform: uppercase;
}

.debug-summary span {
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.5;
}

#debug-breakdown {
  min-height: 420px;
  max-height: 620px;
  overflow: auto;
  margin: 0;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: #0d1411;
  color: #dff7e8;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

@media (max-width: 840px) {
  .app-shell {
    width: min(100% - 24px, 680px);
    padding: 16px 0 32px;
  }

  .hero {
    min-height: 360px;
    padding: 32px 24px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }

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

  .debug-grid {
    grid-template-columns: 1fr;
  }

  .debug-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .topbar__meta {
    width: 100%;
    justify-content: space-between;
  }

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

  .field--full {
    grid-column: auto;
  }

  .intake-panel,
  .result-panel {
    padding: 24px;
  }

  .detail-item {
    grid-template-columns: 1fr;
    gap: 6px;
  }

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

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

  .debug-panel {
    padding: 22px;
  }

  .debug-panel__header {
    flex-direction: column;
  }
}
