:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --ink: #172026;
  --muted: #62717d;
  --line: #dde7e5;
  --teal: #0f766e;
  --green: #168047;
  --blue: #2563eb;
  --amber: #b76b00;
  --red: #b42318;
  --chip: #eef6f4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #eaf7f3 0, #f8faf9 300px, var(--bg) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.stack-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

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

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

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
  letter-spacing: 0;
}

.lead,
.section-head p {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.55;
}

.home-link,
.ghost-button,
.search-form button,
.mini-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 7px;
  background: #ffffff;
  color: #0b5f58;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.home-link,
.ghost-button {
  padding: 0 13px;
}

.tool-panel,
.analysis-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 28px rgba(25, 55, 70, 0.07);
}

.tool-panel {
  padding: 18px;
}

.analysis-panel {
  overflow: hidden;
}

.analysis-panel .section-head {
  padding: 18px 18px 0;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.private-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 999px;
  padding: 6px 10px;
  background: #edf8f5;
  color: #0b5f58;
  font-size: 12px;
  font-weight: 900;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
}

.search-form input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 13px;
  background: #fff;
  color: var(--ink);
}

.search-form button {
  border-color: transparent;
  background: #0f766e;
  color: #fff;
}

.status-line {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.ai-button {
  border-color: transparent;
  background: #0f766e;
  color: #fff;
}

.ai-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ai-status {
  margin-top: 0;
  padding: 8px 18px 0;
}

.search-results {
  display: grid;
  gap: 8px;
}

.search-results:not(:empty) {
  margin-top: 8px;
}

.result-item,
.selected-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.result-item img,
.selected-card img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.product-title {
  margin: 0 0 4px;
  font-weight: 900;
  line-height: 1.28;
}

.product-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mini-button {
  padding: 0 11px;
  background: #e8f6f2;
}

.mini-button.remove {
  border-color: rgba(180, 35, 24, 0.22);
  background: #fff5f3;
  color: var(--red);
}

.selected-products {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.analysis-output {
  padding: 18px;
}

.empty-state {
  min-height: 140px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 850;
  text-align: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.summary-card strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
}

.ai-note {
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
  background: #f3f7ff;
  color: #1f3f7a;
  line-height: 1.55;
  font-weight: 750;
}

.ai-note ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.ai-note li {
  margin: 4px 0;
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 11px 14px;
  background: #f7faf9;
}

.group-title strong {
  font-size: 14px;
}

.group-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.nutrient-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.72fr) minmax(0, 1.28fr) minmax(150px, 0.58fr);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.nutrient-main,
.nutrient-products,
.nutrient-status {
  padding: 13px 14px;
}

.nutrient-main,
.nutrient-products {
  border-right: 1px solid var(--line);
}

.nutrient-main strong {
  display: block;
  line-height: 1.28;
}

.nutrient-main small,
.nutrient-products small,
.nutrient-status small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.product-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.product-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: #f9fbfb;
  color: #2b3a42;
  font-size: 12px;
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 950;
}

.status-upper {
  background: #fff0ed;
  color: var(--red);
}

.status-recommended {
  background: #fff7e8;
  color: var(--amber);
}

.status-duplicate {
  background: #edf4ff;
  color: #1d4ed8;
}

.status-review {
  background: #f0f4f8;
  color: #52616d;
}

.status-no-reference {
  background: #f0f4f8;
  color: #52616d;
}

.status-amount-unknown {
  background: #fff7e8;
  color: var(--amber);
}

.status-no-upper {
  background: #eef7ff;
  color: #2563eb;
}

.status-ok {
  background: #edf8f0;
  color: var(--green);
}

@media (max-width: 760px) {
  .stack-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 16px;
  }

  .stack-header,
  .section-head {
    display: grid;
  }

  .home-link,
  .ghost-button {
    width: max-content;
  }

  .search-form,
  .summary-grid,
  .nutrient-row {
    grid-template-columns: 1fr;
  }

  .result-item,
  .selected-card {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .result-item .mini-button,
  .selected-card .mini-button {
    grid-column: 1 / -1;
  }

  .nutrient-main,
  .nutrient-products {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
