:root {
  color-scheme: light;
  --ink: #1f2a32;
  --muted: #64727a;
  --surface: #ffffff;
  --surface-soft: #f6f8f4;
  --paper: #fbfcf9;
  --line: #d7dfd9;
  --line-strong: #bdc9c1;
  --sage: #4f7762;
  --sage-dark: #315742;
  --coral: #c9604f;
  --coral-soft: #fff0eb;
  --blue: #346b84;
  --amber: #ad762f;
  --danger: #a84242;
  --shadow: 0 16px 40px rgba(34, 48, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Yu Gothic", "Meiryo", sans-serif;
  line-height: 1.6;
  background:
    linear-gradient(180deg, rgba(246, 248, 244, 0) 0, var(--paper) 420px),
    var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.app-hero {
  position: relative;
  min-height: 300px;
  overflow: hidden;
  border-bottom: 1px solid rgba(49, 87, 66, 0.16);
}

.hero-image,
.hero-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-image {
  object-fit: cover;
}

.hero-shade {
  background:
    linear-gradient(90deg, rgba(251, 252, 249, 0.96) 0%, rgba(251, 252, 249, 0.86) 33%, rgba(251, 252, 249, 0.22) 74%),
    linear-gradient(180deg, rgba(251, 252, 249, 0) 62%, var(--paper) 100%);
}

.hero-content {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 54px 0 44px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--sage-dark);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 620px;
  margin-bottom: 10px;
  font-size: clamp(2.35rem, 6vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 520px;
  margin-bottom: 22px;
  color: #3d4a4f;
  font-size: 1.05rem;
}

.hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-metrics span {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid rgba(79, 119, 98, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  backdrop-filter: blur(8px);
}

.hero-metrics strong {
  color: var(--sage-dark);
  font-size: 1.05rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 0.92fr) minmax(420px, 1.08fr);
  gap: 18px;
  width: min(1180px, calc(100% - 32px));
  margin: 22px auto 0;
  align-items: start;
}

.tool-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.search-panel,
.compare-panel {
  padding: 18px;
}

.panel-heading,
.subheading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2,
.subheading h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: 0;
}

.panel-heading h2 {
  font-size: 1.42rem;
}

.subheading h3 {
  font-size: 1rem;
}

.count-badge,
.soft-note {
  display: inline-flex;
  min-width: 48px;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 500;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.field input {
  min-height: 42px;
  padding: 9px 11px;
}

.field textarea {
  min-height: 150px;
  resize: vertical;
  padding: 10px 11px;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(52, 107, 132, 0.14);
}

.compact-field {
  width: min(210px, 44vw);
  margin-bottom: 0;
}

.compact-field input {
  min-height: 36px;
  padding: 7px 10px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 12px;
}

.filter-button,
.primary-button,
.secondary-button,
.ghost-button,
.chip-button,
.icon-button {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  transition:
    transform 120ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.filter-button {
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.filter-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.chip-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--sage);
}

.filter-button.is-active {
  border-color: var(--sage-dark);
  background: var(--sage-dark);
  color: #fff;
}

.attention-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
}

.filter-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.check-row {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.check-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--sage-dark);
}

.check-row.concern-low input {
  accent-color: var(--sage-dark);
}

.check-row.concern-medium input {
  accent-color: var(--amber);
}

.check-row.concern-high input {
  accent-color: var(--danger);
}

.ingredient-grid {
  display: grid;
  gap: 10px;
  max-height: 760px;
  overflow: auto;
  padding-right: 2px;
}

.ingredient-card,
.product-card,
.candidate-row,
.common-row,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ingredient-card {
  padding: 13px;
}

.ingredient-card.is-concern-low {
  border-color: rgba(79, 119, 98, 0.22);
  background: linear-gradient(180deg, #fff, #f7fbf5);
}

.ingredient-card.is-concern-medium {
  border-color: rgba(173, 118, 47, 0.38);
  background: linear-gradient(180deg, #fff, #fff8e7);
}

.ingredient-card.is-concern-high {
  border-color: rgba(168, 66, 66, 0.44);
  background: linear-gradient(180deg, #fff, #fff1ec);
}

.ingredient-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.ingredient-top h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.ingredient-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.category-pill,
.tag,
.concern-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.category-pill {
  background: #eef5f1;
  color: var(--sage-dark);
}

.concern-tag {
  border: 1px solid rgba(58, 104, 79, 0.2);
  background: #f7fbf5;
  color: var(--sage-dark);
}

.concern-tag.is-medium {
  border-color: var(--amber);
  background: var(--amber);
  color: #fff;
}

.concern-tag.is-high {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.tag {
  background: #eef4f7;
  color: var(--blue);
}

.ingredient-card p,
.common-row p {
  margin-bottom: 9px;
  color: #3e4b51;
  font-size: 0.9rem;
}

.meta-list {
  display: grid;
  gap: 6px;
  margin: 0;
}

.meta-list div {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 8px;
}

.meta-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.meta-list dd {
  margin: 0;
  color: #324047;
  font-size: 0.84rem;
}

.product-form {
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  padding-bottom: 16px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.primary-button,
.secondary-button,
.ghost-button {
  padding: 8px 12px;
  font-weight: 800;
}

.primary-button {
  border-color: var(--sage-dark);
  background: var(--sage-dark);
  color: #fff;
}

.primary-button:hover {
  transform: translateY(-1px);
  background: #244935;
}

.secondary-button {
  background: #fff;
  color: var(--blue);
}

.ghost-button {
  min-height: 32px;
  padding: 6px 10px;
  color: var(--danger);
}

.form-status {
  min-height: 24px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.form-status.is-error {
  color: var(--danger);
}

.paste-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: -2px 0 10px;
}

.ingredient-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  margin: 0 0 12px;
}

.preview-chip {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.preview-chip.is-matched {
  border-color: rgba(79, 119, 98, 0.24);
  background: #f4faf6;
  color: var(--sage-dark);
}

.preview-chip.is-unknown {
  border-color: rgba(52, 107, 132, 0.25);
  background: #f3f8fa;
  color: var(--blue);
}

.preview-chip.is-attention {
  border-color: rgba(201, 96, 79, 0.32);
  background: var(--coral-soft);
  color: var(--danger);
}

.candidate-box,
.common-box {
  margin-bottom: 17px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.candidate-results,
.common-results {
  display: grid;
  gap: 9px;
}

.common-section-label {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.candidate-row,
.common-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
}

.candidate-row {
  border-color: rgba(173, 118, 47, 0.28);
  background: linear-gradient(180deg, #fff, #fffaf1);
}

.candidate-row.is-low-signal {
  border-color: var(--line);
  background: #fff;
}

.candidate-row h4,
.common-row h4 {
  margin: 0 0 5px;
  font-size: 0.98rem;
  line-height: 1.25;
}

.candidate-row p,
.common-row p {
  margin-bottom: 0;
}

.common-tags,
.candidate-tags,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: start;
}

.score-pill {
  display: inline-flex;
  min-width: 50px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff3d7;
  color: var(--amber);
  font-size: 0.8rem;
  font-weight: 900;
  white-space: nowrap;
}

.common-count {
  color: var(--amber);
  font-weight: 800;
  white-space: nowrap;
}

.product-list-heading {
  margin-bottom: 10px;
}

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

.product-card {
  padding: 12px;
}

.product-card.is-reacted {
  border-color: rgba(168, 66, 66, 0.46);
  background: linear-gradient(180deg, #fff, #fff7f5);
}

.product-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  margin-bottom: 9px;
}

.product-head h4 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.product-source-link {
  display: inline-flex;
  margin-left: 8px;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.product-source-link:hover {
  text-decoration: underline;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  color: var(--danger);
  font-size: 1.2rem;
}

.react-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.react-toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--danger);
}

.chip-row {
  margin-top: 8px;
}

.chip-button {
  min-height: 28px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.chip-button.is-matched {
  background: #f4faf6;
  color: var(--sage-dark);
}

.chip-button.is-attention {
  background: var(--coral-soft);
  color: var(--danger);
  border-color: rgba(201, 96, 79, 0.32);
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.app-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 22px auto 34px;
  color: var(--muted);
  font-size: 0.84rem;
}

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

  .ingredient-grid {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .app-hero {
    min-height: 270px;
  }

  .hero-content,
  .app-shell,
  .app-footer {
    width: min(100% - 22px, 1180px);
  }

  .hero-content {
    padding-top: 38px;
  }

  .hero-shade {
    background:
      linear-gradient(90deg, rgba(251, 252, 249, 0.97), rgba(251, 252, 249, 0.74)),
      linear-gradient(180deg, rgba(251, 252, 249, 0) 62%, var(--paper) 100%);
  }

  h1 {
    font-size: 2.45rem;
  }

  .hero-copy {
    font-size: 0.98rem;
  }

  .search-panel,
  .compare-panel {
    padding: 14px;
  }

  .subheading {
    display: grid;
  }

  .compact-field {
    width: 100%;
  }

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

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

  .ingredient-top {
    display: grid;
  }

  .ingredient-tags {
    justify-content: flex-start;
  }
}
