:root {
  color-scheme: light;
  --bg: #eef2f1;
  --surface: #ffffff;
  --surface-2: #f5f8f7;
  --ink: #142126;
  --muted: #647178;
  --line: #d7e0dd;
  --green: #12644f;
  --green-2: #e8f4ef;
  --blue: #245f95;
  --amber: #b97a21;
  --red: #a93f37;
  --shadow: 0 14px 34px rgba(20, 33, 38, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 0 15px;
  font-weight: 760;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.98);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(36, 95, 149, 0.28);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

a {
  color: var(--green);
  font-weight: 720;
  text-decoration: none;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
}

.shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 34px;
}

.topbar,
.planner-layout,
.panel-head,
.results-head,
.results-actions,
.section-head,
.location-controls,
.toggle-row,
.site-footer,
.site-footer nav {
  display: flex;
}

.topbar {
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.title-block {
  max-width: 760px;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(32px, 4.6vw, 56px);
  line-height: 1.02;
  font-weight: 820;
  letter-spacing: 0;
}

h2 {
  font-size: 22px;
  line-height: 1.15;
  font-weight: 780;
  letter-spacing: 0;
}

h3 {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 760;
  letter-spacing: 0;
}

h4 {
  font-size: 17px;
  line-height: 1.2;
  font-weight: 780;
  letter-spacing: 0;
}

.lede {
  max-width: 690px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 820;
  letter-spacing: 0;
  text-transform: uppercase;
}

.stats-panel {
  min-width: 420px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 11px 12px;
}

.stat-value,
.stat-label {
  display: block;
}

.stat-value {
  font-size: 22px;
  line-height: 1.1;
  font-weight: 820;
}

.stat-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  text-transform: uppercase;
}

.planner-layout {
  align-items: flex-start;
  gap: 12px;
}

.planner-panel {
  flex: 0 0 min(450px, 42vw);
}

.results-panel {
  flex: 1 1 auto;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head,
.results-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 13px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.results-head > div:first-child {
  flex: 0 0 auto;
  min-width: max-content;
}

form {
  display: grid;
  gap: 14px;
  padding: 16px 18px 18px;
}

.form-section,
fieldset {
  display: grid;
  gap: 10px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 12px;
}

fieldset {
  min-width: 0;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.section-head {
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#geo-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
  text-align: right;
}

.location-controls {
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-location-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.quick-location {
  min-height: 34px;
  border: 1px solid #b7d2c6;
  background: var(--green-2);
  color: var(--green);
  padding: 0 11px;
  font-size: 13px;
  font-weight: 780;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.location-search {
  flex: 1 1 180px;
}

input:not([type="checkbox"]):not([type="range"]) {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 9px 11px;
  font-size: 15px;
  font-weight: 680;
}

input::placeholder {
  color: #95a0a5;
}

.grid {
  display: grid;
  gap: 10px;
}

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

.field-target-calories {
  grid-column: 1 / -1;
}

.macro-panel {
  gap: 12px;
}

.macro-rows {
  display: grid;
  gap: 12px;
}

.macro-row {
  gap: 8px;
}

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

.macro-label {
  color: var(--ink);
}

.macro-values {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-weight: 780;
}

.macro-chip {
  display: inline-flex;
  min-width: 58px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid #b7d2c6;
  border-radius: 999px;
  background: var(--green-2);
  color: var(--green);
  padding: 0 8px;
}

.macro-chip-button {
  font-weight: 780;
  line-height: 1;
}

.macro-chip-soft {
  border-color: #d8e0c8;
  background: #f6f6ea;
  color: #5f5d1f;
}

.macro-divider {
  color: #89959a;
}

.macro-row input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

.macro-edit-dialog,
.share-fallback-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(20, 33, 38, 0.22);
  color: var(--ink);
  padding: 0;
}

.share-fallback-dialog {
  width: min(560px, calc(100vw - 32px));
}

.macro-edit-dialog::backdrop,
.share-fallback-dialog::backdrop {
  background: rgba(20, 33, 38, 0.34);
}

.macro-edit-form,
.share-fallback-form {
  display: grid;
  gap: 0;
  padding: 0;
}

.macro-edit-head,
.share-fallback-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  padding: 16px 18px 13px;
}

.macro-edit-close,
.share-fallback-close {
  width: 34px;
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 0;
  line-height: 1;
}

.macro-edit-body,
.share-fallback-body {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
}

.share-fallback-body textarea {
  width: 100%;
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 11px;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  resize: vertical;
}

.macro-edit-help {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.macro-edit-error {
  color: var(--red);
  font-size: 13px;
  font-weight: 720;
  line-height: 1.4;
}

.macro-edit-error:empty {
  display: none;
}

.macro-edit-actions,
.share-fallback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.macro-edit-actions .primary-action,
.share-fallback-actions .primary-action {
  width: auto;
}

.clipboard-copy-probe {
  position: fixed;
  top: -1000px;
  left: -1000px;
}

.toggle-row {
  flex-wrap: wrap;
  gap: 8px;
}

.toggle-row label {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  padding: 6px 10px;
  color: var(--ink);
  white-space: nowrap;
}

.toggle-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--green);
}

.primary-action {
  width: 100%;
  background: var(--green);
  color: #ffffff;
}

.primary-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border-radius: 7px;
  background: var(--green);
  padding: 0 16px;
  color: #ffffff;
  font-weight: 760;
}

.primary-link:hover,
.primary-link:focus-visible {
  color: #ffffff;
  text-decoration: none;
}

.form-secondary-action {
  width: 100%;
}

.secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--green);
}

.secondary.needs-location {
  border-color: rgba(169, 63, 55, 0.45);
  background: #fff2f1;
  color: var(--red);
}

.results-actions {
  align-items: center;
  flex: 1 1 auto;
  justify-content: flex-end;
  flex-wrap: wrap;
  min-width: 0;
}

.action-status {
  min-width: 48px;
  color: var(--green);
  font-size: 12px;
  font-weight: 780;
  text-align: right;
}

#summary {
  flex: 1 1 320px;
  max-width: 520px;
  min-width: 220px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
  text-align: right;
}

.results-panel > .error,
.results-panel > .daily-totals,
.results-panel > .card-list,
.notes-block,
.catalog-search-panel {
  margin: 14px 18px;
}

.catalog-search-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 12px;
}

.catalog-search-head,
.catalog-search-controls {
  display: flex;
}

.catalog-search-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

#catalog-search-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  text-align: right;
  text-transform: uppercase;
}

.catalog-search-controls {
  align-items: flex-end;
  gap: 8px;
}

.catalog-search-field {
  flex: 1 1 220px;
}

.quick-catalog-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.quick-catalog {
  min-height: 34px;
  border: 1px solid #c8d4de;
  background: #edf4fb;
  color: var(--blue);
  padding: 0 11px;
  font-size: 13px;
  font-weight: 780;
}

.catalog-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.catalog-result {
  min-width: 0;
  border: 1px solid #dfe7e4;
  border-radius: 7px;
  background: #fbfcfc;
  padding: 10px;
}

.catalog-result-head {
  display: grid;
  gap: 3px;
}

.catalog-chain {
  color: var(--green);
  font-size: 12px;
  font-weight: 820;
  text-transform: uppercase;
}

.catalog-macros {
  margin-top: 7px;
  color: #314147;
  font-size: 13px;
  font-weight: 680;
}

.catalog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.catalog-tags span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 760;
}

.error {
  border: 1px solid rgba(169, 63, 55, 0.32);
  border-radius: var(--radius);
  background: #fff4f2;
  color: var(--red);
  padding: 10px 12px;
  font-weight: 680;
}

.daily-totals {
  border: 1px solid #bcd8cc;
  border-radius: var(--radius);
  background: var(--green-2);
  padding: 12px;
}

.daily-totals-heading {
  color: var(--green);
  font-size: 12px;
  font-weight: 820;
  text-transform: uppercase;
}

.daily-totals-macros {
  margin-top: 5px;
  font-size: 18px;
  font-weight: 800;
}

.daily-totals-price {
  display: inline-block;
  margin-top: 8px;
  border: 1px solid #b7d2c6;
  border-radius: 999px;
  background: #ffffff;
  color: var(--green);
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 780;
}

.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 10px;
}

.state-card {
  grid-column: 1 / -1;
  min-height: 128px;
  display: grid;
  align-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  padding: 18px;
}

.state-card h3 {
  color: var(--ink);
  font-size: 18px;
}

.state-card p {
  color: var(--muted);
  line-height: 1.45;
}

.state-card-active {
  border-color: #b7d2c6;
  background: var(--green-2);
}

.state-kicker {
  color: var(--green);
  font-size: 12px;
  font-weight: 820;
  text-transform: uppercase;
}

.state-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 3px;
}

.state-steps span {
  border: 1px solid #b7d2c6;
  border-radius: 999px;
  background: #ffffff;
  color: var(--green);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 780;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  overflow: hidden;
}

.card-header {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.location-meta,
.source-note,
.order-detail {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.meta-dot {
  margin: 0 4px;
}

.order-list {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.order-item {
  border: 1px solid #dfe7e4;
  border-radius: 7px;
  background: #fbfcfc;
  padding: 9px 10px;
}

.order-name {
  font-weight: 780;
}

.order-macros {
  margin-top: 4px;
  color: #314147;
  font-size: 13px;
  font-weight: 680;
}

.order-price {
  display: inline-block;
  margin-top: 7px;
  border: 1px solid #b7d2c6;
  border-radius: 999px;
  background: var(--green-2);
  color: var(--green);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 780;
}

.order-confidence {
  display: inline-block;
  margin-top: 7px;
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.order-detail {
  margin-top: 7px;
}

.source-details {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 7px;
}

.source-details summary {
  width: fit-content;
  color: var(--green);
  font-size: 12px;
  font-weight: 820;
  cursor: pointer;
}

.source-details summary:focus-visible {
  outline: 3px solid rgba(36, 95, 149, 0.28);
  outline-offset: 2px;
  border-radius: 5px;
}

.source-details-body {
  display: grid;
  gap: 6px;
  margin-top: 7px;
}

.source-details .source-note,
.source-details .order-detail {
  margin-top: 0;
}

.location-totals {
  margin: 0 10px 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.totals-macros,
.totals-price {
  font-size: 13px;
}

.totals-price {
  margin-top: 5px;
}

.notes-block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

li {
  margin-bottom: 5px;
}

.idle-copy {
  color: var(--muted);
}

.searching-copy {
  color: var(--blue);
  font-weight: 720;
}

.hidden {
  display: none;
}

.site-footer {
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.footer-notes {
  display: grid;
  gap: 4px;
  max-width: 760px;
  line-height: 1.45;
}

.osm-attribution {
  font-size: 12px;
}

.site-footer nav {
  flex: 0 0 auto;
  gap: 14px;
}

.document-shell {
  max-width: 840px;
}

.document-panel h1 {
  font-size: clamp(34px, 6vw, 56px);
}

.document-body {
  display: grid;
  gap: 14px;
  padding: 18px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.not-found-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  width: min(100vw - 32px, 760px);
  margin: 0 auto;
  padding: 32px 0;
}

.not-found-panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 28px;
}

.not-found-panel .lede {
  margin-bottom: 20px;
}

@media (max-width: 960px) {
  .topbar,
  .planner-layout {
    display: grid;
  }

  .planner-panel {
    flex-basis: auto;
  }

  .stats-panel {
    min-width: 0;
  }

  #summary {
    flex-basis: 100%;
    max-width: none;
    min-width: 0;
    text-align: left;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 24px, 1280px);
    padding-top: 18px;
  }

  h1 {
    font-size: 34px;
  }

  .stats-panel,
  .planner-grid {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .results-head {
    display: grid;
  }

  .location-controls {
    display: grid;
  }

  .catalog-search-controls {
    display: grid;
  }

  .quick-location {
    flex: 1 1 calc(50% - 7px);
  }

  .quick-catalog {
    flex: 1 1 calc(50% - 7px);
  }

  .toggle-row label {
    width: 100%;
    white-space: normal;
  }

  .results-actions {
    justify-content: flex-start;
  }

  .results-panel > .error,
  .results-panel > .daily-totals,
  .results-panel > .card-list,
  .notes-block,
  .catalog-search-panel {
    margin-right: 12px;
    margin-left: 12px;
  }

  .site-footer {
    display: grid;
  }

  .macro-edit-actions,
  .share-fallback-actions {
    display: grid;
    justify-content: stretch;
  }

  .macro-edit-actions .primary-action,
  .macro-edit-actions .secondary,
  .share-fallback-actions .primary-action,
  .share-fallback-actions .secondary {
    width: 100%;
  }

  .not-found-shell {
    width: min(100vw - 24px, 760px);
    padding: 18px 0;
  }

  .not-found-panel {
    padding: 20px;
  }
}
