:root {
  --ink: #202421;
  --muted: #697068;
  --line: #d8ddd4;
  --panel: #f7f8f3;
  --paper: #fffdf7;
  --accent: #2f7d62;
  --accent-dark: #245f4a;
  --warn: #b86534;
  --blue: #3e6f9e;
  --gold: #b88a27;
  --rose: #a85c69;
  --shadow: 0 18px 42px rgba(42, 48, 38, 0.13);
  font-family:
    "Yu Gothic UI", "Yu Gothic", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(72, 117, 91, 0.09), transparent 32%),
    repeating-linear-gradient(0deg, rgba(32, 36, 33, 0.025) 0 1px, transparent 1px 36px),
    #eef1e9;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.side-panel {
  padding: 28px 22px;
  background: #263029;
  color: #f7f4e9;
  border-right: 1px solid #1c241f;
}

.brand {
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.lab,
.eyebrow {
  display: block;
  color: #adc9b7;
  font-size: 12px;
  letter-spacing: 0;
  font-weight: 700;
}

.brand h1 {
  margin: 8px 0;
  font-size: 34px;
  line-height: 1.15;
}

.brand p {
  margin: 0;
  color: #d5dbc9;
  line-height: 1.7;
}

.control-group {
  padding: 20px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

.control-group h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

label {
  display: block;
  margin: 0 0 12px;
  color: #dce4d3;
  font-size: 13px;
}

input,
select {
  width: 100%;
  margin-top: 7px;
  padding: 10px 11px;
  color: #18201b;
  background: #fbfaf2;
  border: 1px solid #c5d0be;
  border-radius: 6px;
}

.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.check-grid label {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  margin: 0;
  padding: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
}

.check-grid input {
  width: auto;
  margin: 0;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented button,
.primary-action,
.swap-button,
.mini-action,
.icon-button,
.lock-button {
  border: 0;
  border-radius: 6px;
}

.segmented button {
  min-height: 36px;
  color: #e6eadf;
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.segmented button.active {
  color: #172019;
  background: #cde7d0;
}

.action-stack {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.primary-action,
.secondary-action {
  width: 100%;
  min-height: 44px;
  font-weight: 800;
}

.primary-action {
  color: #172019;
  background: #f1c96d;
}

.secondary-action {
  color: #f7f4e9;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
}

main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.status-band,
.workspace {
  max-width: 1280px;
  margin: 0 auto;
}

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

.topbar h2 {
  margin: 4px 0 0;
  font-size: 30px;
}

.source-note {
  color: var(--muted);
  font-size: 13px;
}

.status-band {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) 1.2fr;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 18px;
}

.status-copy,
.metric-strip,
.nutrient-board,
.weekly-plan,
.deficit-list,
.swap-list,
.shopping-list {
  background: rgba(255, 253, 247, 0.88);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.status-copy {
  padding: 18px;
  border-radius: 8px;
}

.status-copy p {
  margin: 12px 0 0;
  line-height: 1.7;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  color: #f9fbf6;
  background: var(--accent);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
}

.metric {
  min-height: 92px;
  padding: 16px;
  background: #fffdf7;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 24px;
}

.nutrient-board {
  max-width: 1280px;
  margin: 0 auto 22px;
  padding: 18px;
  border-radius: 8px;
}

.nutrient-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.nutrient-item {
  min-width: 0;
}

.nutrient-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.bar {
  height: 10px;
  overflow: hidden;
  background: #e8e9df;
  border-radius: 999px;
}

.fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: inherit;
}

.fill.warn {
  background: var(--warn);
}

.fill.low {
  background: var(--gold);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.75fr);
  gap: 22px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 10px;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.section-heading.compact {
  margin-top: 18px;
}

.mini-action {
  min-height: 32px;
  padding: 0 12px;
  color: #fff;
  background: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.weekly-plan {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
}

.day-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 118px;
  gap: 14px;
  align-items: center;
  min-height: 96px;
  padding: 14px;
  background: #fffdf7;
}

.day-row.selected {
  background: #edf7ed;
  outline: 2px solid #7dbb91;
  outline-offset: -2px;
}

.day-label {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

.day-label span,
.day-label em {
  display: block;
}

.day-label em {
  width: fit-content;
  margin-top: 8px;
  padding: 4px 7px;
  color: #fff;
  background: var(--warn);
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
}

.meal-title {
  min-width: 0;
}

.meal-title h3 {
  margin: 0 0 6px;
  font-size: 17px;
  line-height: 1.35;
}

.meal-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.mini-nutrients {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  color: #3d443e;
  font-size: 12px;
}

.icon-button,
.lock-button {
  min-height: 34px;
  padding: 0 10px;
}

.icon-button {
  color: #fff;
  background: var(--accent-dark);
}

.row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.lock-button {
  color: #213127;
  background: #dfe6d9;
  border: 1px solid #cbd6c6;
}

.lock-button.locked {
  color: #fff;
  background: var(--warn);
  border-color: var(--warn);
}

.deficit-list,
.swap-list,
.shopping-list {
  overflow: hidden;
  border-radius: 8px;
}

.deficit-item,
.swap-item,
.shopping-item {
  padding: 14px;
  background: #fffdf7;
  border-bottom: 1px solid var(--line);
}

.deficit-context {
  background: #eef6ee;
}

.deficit-item:last-child,
.swap-item:last-child,
.shopping-item:last-child {
  border-bottom: 0;
}

.deficit-item strong,
.swap-item strong,
.shopping-item strong {
  display: block;
  margin-bottom: 6px;
}

.deficit-item p,
.swap-item p,
.shopping-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.mini-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 10px;
}

.mini-tabs button {
  min-height: 34px;
  color: #2a352d;
  background: #e7ece3;
  border: 1px solid #cfd8c9;
  border-radius: 6px;
  font-weight: 800;
}

.mini-tabs button.active {
  color: #fff;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.shopping-list {
  max-height: 460px;
  overflow: auto;
}

.shopping-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.shopping-item input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
}

.shopping-item.checked {
  color: #7c8479;
  background: #f0f2eb;
}

.shopping-item.checked strong,
.shopping-item.checked p {
  text-decoration: line-through;
}

.shopping-item strong {
  overflow-wrap: anywhere;
}

.shopping-weight {
  color: var(--accent-dark);
  font-weight: 900;
  white-space: nowrap;
}

.shopping-subhead {
  padding: 9px 14px;
  color: #5f675e;
  background: #edf0e8;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 900;
}

.swap-reason {
  margin-top: 7px !important;
  color: #496654 !important;
}

.swap-button {
  margin-top: 10px;
  min-height: 34px;
  padding: 0 12px;
  color: #172019;
  background: #dbe9dc;
  font-weight: 800;
}

.mobile-jump {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-right: 0;
  }

  .mobile-jump {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: -6px 0 14px;
    padding: 8px 0;
    background: rgba(238, 241, 233, 0.94);
    backdrop-filter: blur(10px);
  }

  .mobile-jump a {
    min-height: 38px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--accent-dark);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 800;
    font-size: 13px;
  }

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

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

  .shopping-list {
    max-height: none;
  }
}

@media (max-width: 620px) {
  main {
    padding: 18px 14px;
  }

  .side-panel {
    padding: 22px 16px;
  }

  .brand h1 {
    font-size: 30px;
  }

  .status-band {
    gap: 10px;
  }

  .day-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .row-actions {
    grid-template-columns: 1fr 1fr;
  }

  .shopping-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .shopping-weight {
    grid-column: 2;
  }

  .topbar,
  .section-heading {
    display: block;
  }

  .source-note,
  .section-heading p {
    margin-top: 8px;
  }

  .nutrient-grid,
  .metric-strip {
    grid-template-columns: 1fr;
  }

  .day-row {
    grid-template-columns: 1fr;
  }

  .mini-nutrients {
    grid-template-columns: repeat(4, 1fr);
  }
}


.copy-fallback {
  width: calc(100% - 28px);
  min-height: 180px;
  margin: 14px;
  padding: 12px;
  color: #1d261f;
  background: #fbfaf2;
  border: 1px solid #b9c8b7;
  border-radius: 6px;
  font: 13px/1.6 Consolas, "Yu Gothic", monospace;
  resize: vertical;
}
