:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #222722;
  --muted: #677064;
  --line: #dfe4dc;
  --accent: #1f6f62;
  --accent-strong: #15554b;
  --accent-soft: #e6f2ee;
  --sale: #1f6f43;
  --sale-soft: #e3f3e8;
  --unknown: #8a650f;
  --unknown-soft: #fff3cd;
  --ended: #9b2f2f;
  --ended-soft: #fde7e7;
  --pediatric: #2f5f8f;
  --pediatric-soft: #e5f0fb;
  --missing: #8d2d3d;
  --missing-soft: #fbe8ec;
  --extra: #365f91;
  --extra-soft: #e6eef8;
  --shadow: 0 18px 45px rgba(32, 38, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
  line-height: 1.6;
}

button,
input {
  font: inherit;
}

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

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

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

h1 {
  margin-bottom: 4px;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  line-height: 1.25;
}

.app-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.6vw, 1.12rem);
  font-weight: 700;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.12rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
}

.search-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-panel {
  padding: 20px;
  margin-bottom: 18px;
}

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

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.filter-toggles {
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
  justify-items: start;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

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

.search-box {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 700;
}

.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  color: var(--ink);
  background: #fff;
}

.search-box input:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.candidate-summary {
  min-height: 24px;
  color: var(--muted);
  font-size: 0.92rem;
}

.legend-note {
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.candidate-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  max-height: 340px;
  overflow: auto;
  padding-right: 4px;
}

.candidate-button {
  width: 100%;
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.candidate-button:hover,
.candidate-button:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.candidate-button.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.candidate-name {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef0ed;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.pill.status-on-sale {
  background: var(--sale-soft);
  color: var(--sale);
}

.pill.status-unconfirmed {
  background: var(--unknown-soft);
  color: var(--unknown);
}

.pill.status-discontinued {
  background: var(--ended-soft);
  color: var(--ended);
}

.pill.age-pediatric {
  background: var(--pediatric-soft);
  color: var(--pediatric);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr);
  gap: 18px;
  align-items: start;
}

.detail-panel {
  padding: 20px;
  min-height: 220px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #fafbf9;
}

.product-title {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.product-heading,
.result-title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 12px;
}

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

.article-link {
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.article-link:hover,
.article-link:focus {
  color: var(--accent-strong);
}

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

.meta-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fafbf9;
}

.meta-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.meta-value {
  display: block;
  margin-top: 4px;
  font-weight: 800;
}

.ingredient-group {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.ingredient-list,
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ingredient-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.ingredient-name {
  font-weight: 800;
}

.ingredient-dose {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.comparison-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.result-section {
  margin-top: 18px;
}

.result-section:first-of-type {
  margin-top: 0;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-top: 10px;
  background: #fff;
}

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

.score {
  display: inline-block;
  flex: 0 0 auto;
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.diff-block {
  margin-top: 12px;
}

.variation-block {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.variation-list {
  display: grid;
  gap: 8px;
}

.variation-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.38fr) minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fafbf9;
}

.variation-name {
  color: var(--accent-strong);
  font-weight: 800;
}

.variation-values {
  display: grid;
  gap: 6px;
}

.variation-values div {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px;
}

.variation-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.replacement-list {
  display: grid;
  gap: 8px;
}

.replacement-row {
  display: grid;
  grid-template-columns: minmax(96px, 0.34fr) minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fafbf9;
  font-size: 0.9rem;
}

.replacement-category {
  color: var(--accent-strong);
  font-weight: 800;
}

.replacement-arrow {
  color: var(--muted);
  font-weight: 800;
}

.chip {
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef0ed;
  color: var(--ink);
  font-size: 0.83rem;
  font-weight: 700;
}

.chip.common {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.chip.missing {
  background: var(--missing-soft);
  color: var(--missing);
}

.chip.extra {
  background: var(--extra-soft);
  color: var(--extra);
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fafbf9;
  color: var(--muted);
}

@media (max-width: 860px) {
  .app-header,
  .panel-heading,
  .result-header {
    display: block;
  }

  .status {
    margin-top: 10px;
    text-align: left;
  }

  .filter-toggles {
    margin-top: 14px;
  }

  .score {
    margin-top: 8px;
  }

  .detail-grid,
  .meta-card {
    grid-template-columns: 1fr;
  }

  .variation-row,
  .variation-values div,
  .replacement-row {
    grid-template-columns: 1fr;
  }

  .replacement-arrow {
    display: none;
  }
}
