:root {
  --hero: #16313a;
  --hero-2: #1d4350;
  --page: #f4f8f8;
  --paper: #ffffff;
  --paper-soft: #e9f3f3;
  --paper-warm: #fff6ec;
  --ink: #2c3138;
  --ink-soft: #687178;
  --line: #d8e6e6;
  --line-strong: #bdd6d6;
  --green: #1f8a8a;
  --green-soft: rgba(31, 138, 138, 0.10);
  --orange: #e7972f;
  --mint: #d2ebec;
  --shadow: 0 8px 32px rgba(27, 34, 29, 0.08);
  --shadow-soft: 0 4px 16px rgba(27, 34, 29, 0.06);
  --radius: 16px;
  --radius-sm: 12px;
  --bar-h: 56px;
}

* { box-sizing: border-box; }
html { overflow-x: hidden; }

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--page);
  font-family: "Quicksand", "Segoe UI", sans-serif;
  line-height: 1.55;
  padding-top: var(--bar-h);
}

a, button, input { font: inherit; }
h1, h2, h3, strong { overflow-wrap: anywhere; }

/* ─── App bar ─── */
.app-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--bar-h);
  padding: 0 16px;
  background: var(--hero);
  color: #f7f6f1;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}

.app-bar-title {
  font-family: "Poppins", sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  flex: 1;
}

.app-bar-badge {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255,255,255,0.15);
  font-size: 0.78rem;
  font-weight: 700;
}

.menu-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 8px 6px;
  background: transparent;
  border: 0;
  box-shadow: none;
  cursor: pointer;
}
.menu-btn span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: #f7f6f1;
  transition: transform 200ms, opacity 200ms;
}
.menu-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn.open span:nth-child(2) { opacity: 0; }
.menu-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ─── Menu drawer ─── */
.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms;
}
.menu-overlay.open { opacity: 1; pointer-events: auto; }

.menu-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 210;
  width: min(340px, 85vw);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  transform: translateX(-100%);
  transition: transform 280ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.menu-drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}
.drawer-header h2,
.drawer-brand {
  margin: 0;
  font-family: "Poppins", sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
}
.drawer-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--ink);
  font-size: 1.5rem;
  cursor: pointer;
}

/* ─ Drawer nav ─ */
.drawer-nav {
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.drawer-nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--line);
  box-shadow: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.drawer-nav-btn:active {
  background: var(--page);
}
.drawer-nav-btn.active {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(74, 113, 73, 0.22);
  font-weight: 700;
}
.drawer-nav-icon {
  font-size: 1.15rem;
  width: 22px;
  text-align: center;
}

.scan-card {
  width: 100%;
  min-width: 0;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-soft);
  transition: border-color 120ms, background 120ms;
}
.scan-card.selected {
  border-color: var(--green);
  background: var(--paper-soft);
}

.scan-card-main {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  box-shadow: none;
  cursor: pointer;
}

.scan-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}
.scan-top strong { font-size: 0.95rem; }
.scan-top p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.scan-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.scan-meta span { overflow-wrap: anywhere; word-break: break-word; }

.scan-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.scan-refresh {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(74, 113, 73, 0.14);
  box-shadow: none;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.empty-card {
  padding: 16px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ─ Settings section in drawer ─ */
.drawer-settings {
  padding: 0 12px 8px;
}
.settings-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--page);
  border: 1px solid var(--line);
  box-shadow: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.settings-toggle .toggle-chevron {
  font-size: 0.65rem;
  color: var(--ink-soft);
  transition: transform 200ms;
}
.settings-toggle.open .toggle-chevron {
  transform: rotate(180deg);
}
.settings-content {
  display: none;
  padding: 8px 0 0;
}
.settings-content.open {
  display: block;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
}
.setting-label {
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.lang-switcher {
  display: flex;
  gap: 4px;
}
.lang-btn {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--page);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  box-shadow: none;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.lang-btn.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.drawer-footer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
}

.drawer-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.drawer-stat {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--page);
}
.drawer-stat-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.drawer-stat strong {
  display: block;
  font-size: 0.85rem;
}

.drawer-link {
  display: block;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--green-soft);
  color: var(--green);
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.88rem;
}

/* ─── Main content ─── */
.main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 12px 40px;
}

/* ─── Search section ─── */
.search-section {
  padding: 16px 0 8px;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-row {
  display: flex;
  gap: 8px;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 2px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 500;
  transition: border-color 150ms;
}
.search-input:focus {
  outline: none;
  border-color: var(--green);
}
.search-input::placeholder {
  color: var(--ink-soft);
}

.search-btn {
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 0;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  white-space: nowrap;
  transition: opacity 150ms;
}
.search-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* (force-refresh removed from UI) */

/* ─── Status / Progress ─── */
.hidden { display: none !important; }

.status-section {
  margin: 12px 0;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  transition: opacity 400ms ease;
}
.status-section.fade-out {
  opacity: 0;
}
.status-section.loading {
  border-color: rgba(244, 142, 79, 0.4);
  background: linear-gradient(135deg, #fff8f3 0%, #fff 100%);
}
.status-section.success {
  border-color: rgba(74, 113, 73, 0.3);
  background: linear-gradient(135deg, #f3f9f4 0%, #fff 100%);
}
.status-section.error,
.status-section.not-found {
  border-color: rgba(199, 85, 41, 0.3);
  background: linear-gradient(135deg, #fff5f0 0%, #fff 100%);
}

.progress-ring-wrap {
  display: none;
}
.status-section.loading .progress-ring-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.progress-ring {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-text {
  text-align: center;
}
.status-text strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 2px;
}
.status-text span {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.progress-steps {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  transition: color 200ms, opacity 200ms;
}
.progress-step.active { color: var(--ink); font-weight: 600; }
.progress-step.done { color: var(--green); }
.progress-step.waiting {
  color: var(--orange);
}
.progress-step .step-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.7rem;
  flex-shrink: 0;
}
.progress-step .step-icon {
  background: var(--line);
  color: var(--ink-soft);
}
.progress-step.active .step-icon {
  background: var(--orange);
  color: #fff;
  animation: pulse 1s ease infinite;
}
.progress-step.done .step-icon {
  background: var(--green);
  color: #fff;
}
.progress-step.waiting .step-icon {
  background: var(--orange);
  color: #fff;
  animation: pulse 1s ease infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.progress-meta {
  margin-top: 10px;
  padding: 12px 12px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(244, 142, 79, 0.18);
}

.progress-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.progress-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(74, 113, 73, 0.08);
  color: var(--hero);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.progress-elapsed {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.progress-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 48px 16px;
}
.empty-icon {
  font-size: 3rem;
  margin-bottom: 8px;
  opacity: 0.4;
}
.empty-state h2 {
  margin: 0 0 8px;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
}
.empty-state p {
  color: var(--ink-soft);
  font-size: 0.9rem;
  max-width: 320px;
  margin: 0 auto 16px;
}
.empty-sources {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.source-tag {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 700;
}

/* ─── Detail panel ─── */
.detail-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 24px;
}

/* ─ Score hero card ─ */
.score-hero {
  padding: 20px;
  border-radius: var(--radius);
  color: #f7f6f1;
  text-align: center;
  box-shadow: var(--shadow);
}
.score-hero.tone-good {
  background: linear-gradient(135deg, #3a6839 0%, #4a7149 50%, #5a8a59 100%);
}
.score-hero.tone-mixed {
  background: linear-gradient(135deg, #8a6530 0%, #a67b3d 50%, #c08e4a 100%);
}
.score-hero.tone-poor {
  background: linear-gradient(135deg, #7a3d2a 0%, #9a4d35 50%, #b05a3d 100%);
}
.score-hero .score-number {
  font-family: "Poppins", sans-serif;
  font-weight: 800;
  font-size: 3.2rem;
  line-height: 1;
}
.score-hero .score-of {
  font-size: 0.85rem;
  opacity: 0.7;
}
.score-hero .score-verdict {
  margin-top: 6px;
  font-size: 1.05rem;
  font-weight: 700;
}
.score-hero .score-name {
  margin-top: 10px;
  font-size: 0.85rem;
  opacity: 0.8;
}
.score-hero .score-classification {
  font-size: 0.78rem;
  opacity: 0.6;
  margin-top: 2px;
}

/* ─ Quick stats row ─ */
.quick-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.detail-actions {
  display: flex;
  gap: 10px;
  margin: 14px 0 0;
}

.detail-action-btn {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(74, 113, 73, 0.18);
  background: var(--green);
  color: #fff;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: none;
  cursor: pointer;
}

.detail-action-btn.secondary {
  background: var(--paper);
  color: var(--green);
}

.detail-action-btn:disabled {
  opacity: 0.72;
  cursor: default;
}
.quick-stat {
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px solid var(--line);
  text-align: center;
}
.quick-stat .qs-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 2px;
}
.quick-stat .qs-value {
  font-weight: 700;
  font-size: 0.9rem;
}

/* ─ Interpretation card ─ */
.interp-card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--paper-warm);
  border: 1px solid rgba(244, 142, 79, 0.18);
}
.interp-card h3 {
  margin: 0 0 6px;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
}
.interp-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.6;
}

/* ─ Practical notes inside interp ─ */
.practical-notes {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(244, 142, 79, 0.15);
}
.practical-note {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.5;
}
.practical-note::before {
  content: "\2022 ";
  color: var(--orange);
}

/* ─ Dosage form card ─ */
.dosage-card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
}
.dosage-card h3 {
  margin: 0 0 4px;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
}
.dosage-baseline {
  margin: 0 0 10px;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.dosage-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dosage-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--page);
}
.dosage-label {
  font-size: 0.85rem;
  font-weight: 500;
}

/* ─ Search context / practical forms ─ */
.search-context-banner,
.forms-card {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper);
}

.search-context-banner {
  background: linear-gradient(135deg, #fff7ef 0%, #fff 100%);
  border-color: rgba(244, 142, 79, 0.28);
}

.search-context-head,
.form-option-head,
.search-context-actions,
.form-option-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.search-context-banner p,
.forms-note,
.form-option-card p {
  margin: 10px 0 0;
  color: var(--ink-soft);
}

.search-context-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.search-context-field {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(244, 142, 79, 0.18);
}

.search-context-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.search-context-value {
  display: block;
  font-weight: 700;
}

.search-context-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

.context-action-btn,
.form-query-btn {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(74, 113, 73, 0.18);
  background: var(--green);
  color: #fff;
  box-shadow: none;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.context-action-btn.secondary {
  background: var(--page);
  color: var(--ink);
  border-color: var(--line);
}

.forms-card h3 {
  margin: 0;
  font-family: "Poppins", sans-serif;
  font-size: 1rem;
}

.forms-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.form-option-card {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--page);
  border: 1px solid var(--line);
}

.form-option-head strong {
  font-size: 0.92rem;
}

.form-option-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

/* ─ Section header (collapsible) ─ */
.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
}
.section-toggle .toggle-chevron {
  font-size: 0.7rem;
  color: var(--ink-soft);
  transition: transform 200ms;
}
.section-toggle.open .toggle-chevron {
  transform: rotate(180deg);
}
.section-content {
  display: none;
  margin-top: 8px;
}
.section-content.open {
  display: block;
}

/* ─ Tiered property list ─ */
.property-tiers-card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
}

.property-tiers-card h3 {
  margin: 0 0 12px;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
}

.property-tier-block + .property-tier-block {
  margin-top: 14px;
}

.property-tier-label {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(74, 113, 73, 0.08);
  color: var(--hero);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.property-tier-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.property-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--page);
  border: 1px solid var(--line);
}

.property-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.property-item-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.property-item-title-wrap strong {
  font-size: 0.88rem;
}

.property-item-value {
  text-align: right;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink);
}

.property-item p {
  margin: 6px 0 0;
  font-size: 0.79rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.property-tiers-card .section-toggle {
  margin-top: 14px;
}

.property-tier-block-supporting {
  margin-top: 0;
}

/* ─ Identity card ─ */
.identity-card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--paper-soft);
  border: 1px solid var(--line);
}
.identity-card h3 {
  margin: 0 0 10px;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
}
.id-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.id-field {
  min-width: 0;
}
.id-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 2px;
}
.id-value {
  font-weight: 600;
  font-size: 0.85rem;
  word-break: break-word;
}
.alt-names {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.alt-chip {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(74, 113, 73, 0.08);
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 600;
}

/* ─ Full descriptors ─ */
.descriptor-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.descriptor {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px solid var(--line);
}
.descriptor-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}
.descriptor-head strong { font-size: 0.88rem; }
.descriptor p {
  margin: 4px 0 0;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
.descriptor small {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* ─ Source table ─ */
.table-shell {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper);
}
.metric-table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.metric-table th,
.metric-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.metric-table th {
  color: #fff;
  background: var(--ink);
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
}
.metric-table tbody tr:nth-child(even) {
  background: var(--page);
}

/* ─ Notes ─ */
.notes-card {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--paper-soft);
  border: 1px solid var(--line);
}
.notes-card h3 {
  margin: 0 0 8px;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
}
.notes-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* ─ Method ─ */
.method-card {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
}
.method-card h3 {
  margin: 0 0 8px;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
}
.method-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 0.82rem;
}
.method-sub {
  margin-top: 10px;
}
.method-sub strong {
  font-size: 0.82rem;
}

/* ─ Pills / signals ─ */
.pill, .signal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.pill.good, .signal.favorable, .quality-good {
  background: rgba(74, 113, 73, 0.12);
  color: var(--green);
}
.pill.mixed, .signal.mixed, .quality-mixed {
  background: rgba(244, 142, 79, 0.12);
  color: #c86e34;
}
.pill.poor, .signal.poor, .quality-poor {
  background: rgba(199, 85, 41, 0.12);
  color: #b65b31;
}

/* ─ Suggestion chips (not-found) ─ */
.suggestion-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.suggestion-chip {
  max-width: 100%;
  padding: 8px 14px;
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(74, 113, 73, 0.14);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: none;
  cursor: pointer;
}

/* ─ Meta badge ─ */
.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.65);
  font-size: 0.75rem;
  color: var(--ink-soft);
  font-weight: 600;
}

/* ─── Desktop widening ─── */
@media (min-width: 768px) {
  :root {
    --bar-h: 60px;
    --radius: 20px;
    --radius-sm: 14px;
  }

  .main {
    max-width: 720px;
    padding: 0 24px 60px;
  }

  .search-section { padding: 24px 0 12px; }

  .search-input { font-size: 1.05rem; padding: 14px 16px; }
  .search-btn { padding: 14px 28px; font-size: 1rem; }

  .score-hero { padding: 28px; }
  .score-hero .score-number { font-size: 4rem; }

  .detail-panel { gap: 16px; }

  .id-grid { grid-template-columns: 1fr 1fr 1fr; }

  .quick-stats { gap: 10px; }
}

/* ─── Library panel ─── */
.library-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 24px;
}

.library-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.library-header h2 {
  margin: 0;
  font-family: "Poppins", sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
}


.library-sorts {
  display: flex;
  gap: 6px;
}
.sort-btn {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--page);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  box-shadow: none;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.sort-btn.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.library-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.library-card {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: border-color 120ms, box-shadow 120ms;
}
.library-card:active {
  border-color: var(--green);
  box-shadow: var(--shadow);
}

.library-card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}
.library-card-name {
  font-weight: 700;
  font-size: 0.95rem;
}
.library-card-formula {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 2px;
}
.library-card-verdict {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.library-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.quality-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

/* ─── History panel ─── */
.history-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 24px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.history-header h2 {
  margin: 0;
  font-family: "Poppins", sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
}

.history-clear {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--page);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  box-shadow: none;
  cursor: pointer;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms;
}
.history-item:active {
  border-color: var(--green);
}

.history-item-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.history-query {
  font-weight: 700;
  font-size: 0.92rem;
}
.history-time {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

/* ─── About panel ─── */
.about-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 24px;
}

.about-hero,
.about-card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-soft);
}

.about-hero {
  padding: 18px;
  background:
    radial-gradient(circle at top right, rgba(244, 142, 79, 0.18), transparent 32%),
    linear-gradient(135deg, #f6fbf6 0%, #fff7ef 100%);
}

.about-hero h2,
.about-card h3 {
  margin: 0;
  font-family: "Poppins", sans-serif;
}

.about-hero h2 {
  font-size: 1.45rem;
  line-height: 1.15;
  margin-top: 10px;
}

.about-subtitle {
  margin: 8px 0 0;
  color: var(--green);
  font-weight: 700;
}

.about-body {
  margin: 10px 0 0;
}

.about-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(29, 45, 29, 0.08);
  color: var(--hero);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.about-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.about-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(74, 113, 73, 0.14);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.about-card {
  padding: 16px;
}

.about-card h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.about-card p {
  margin: 0;
}

.about-card p + p,
.about-card p + .about-list,
.about-card p + .about-steps,
.about-card p + .about-callout,
.about-card p + .about-ref-grid {
  margin-top: 10px;
}

.about-card-warning {
  background: linear-gradient(180deg, #fffaf5 0%, #ffffff 100%);
}

.about-card-beta {
  background: linear-gradient(180deg, #f4faf4 0%, #ffffff 100%);
}

.about-callout {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--paper-soft);
  border-left: 4px solid var(--green);
  font-weight: 600;
}

.about-steps,
.about-list {
  margin: 10px 0 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.about-steps li,
.about-list li {
  padding-left: 2px;
}

.about-section-intro {
  color: var(--ink-soft);
}

.about-ref-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.about-ref-card {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--page);
  border: 1px solid var(--line);
}

.about-ref-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

.about-ref-card p {
  margin: 0 0 8px;
  font-size: 0.88rem;
}

.about-ref-card small {
  color: var(--ink-soft);
  line-height: 1.4;
}

.about-study-section {
  margin-top: 14px;
}

.about-study-section h4 {
  margin: 0 0 10px;
  font-family: "Poppins", sans-serif;
  font-size: 0.98rem;
}

.about-study-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.about-study-card {
  padding: 14px;
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(246, 251, 246, 0.9) 0%, rgba(255, 255, 255, 0.98) 100%);
  border: 1px solid var(--line);
}

.about-study-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.about-study-head strong {
  font-size: 0.95rem;
}

.about-study-journal,
.about-study-type {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.about-study-card p + .about-study-list,
.about-study-type + p {
  margin-top: 8px;
}

.about-study-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.86rem;
}

/* ─── No data indicator ─── */
.no-data {
  font-style: italic;
  opacity: 0.6;
}
.kd-signal.unknown {
  background: var(--line-strong);
}

/* Full desktop: wider container, could add side catalog later */
@media (min-width: 1100px) {
  .main {
    max-width: 800px;
  }
}

/* ─── HowToTake components ─── */
.htt-hero {
  background: linear-gradient(135deg, var(--hero), var(--hero-2));
  color: #eaf6f6;
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.htt-hero .htt-kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: #8fd3d3;
  font-weight: 700;
}
.htt-hero h2 {
  margin: 6px 0 2px;
  font-family: "Poppins", sans-serif;
  font-size: 1.7rem;
  overflow-wrap: anywhere;
}
.htt-hero .htt-sub { color: rgba(234,246,246,0.75); font-size: 0.9rem; }
.htt-modepill {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.htt-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-soft);
}
.htt-card h3 {
  margin: 0 0 12px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.htt-intake {
  border-left: 4px solid var(--orange);
  background: var(--paper-warm);
}
.htt-intake .htt-headline {
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: 6px;
}
.htt-intake p { margin: 0; color: var(--ink); font-size: 0.95rem; }
.htt-fasting {
  display: inline-flex; gap: 6px; align-items: center;
  margin-top: 10px; padding: 4px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700;
}
.htt-fasting.fine { background: rgba(31,138,138,0.14); color: #157272; }
.htt-fasting.mixed { background: rgba(231,151,47,0.18); color: #a86a13; }
.htt-fasting.poor { background: rgba(196,80,40,0.14); color: #b4441c; }

.htt-sol-grid { display: grid; gap: 10px; }
.htt-sol-row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 10px; align-items: center;
}
.htt-sol-name { font-weight: 700; font-size: 0.9rem; }
.htt-bar { height: 10px; border-radius: 999px; background: var(--paper-soft); overflow: hidden; }
.htt-bar > span { display: block; height: 100%; border-radius: 999px; }
.htt-bar.high > span { width: 100%; background: var(--green); }
.htt-bar.moderate > span { width: 62%; background: var(--orange); }
.htt-bar.low > span { width: 26%; background: #c9603a; }
.htt-bar.unknown > span { width: 8%; background: var(--line-strong); }
.htt-rating { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); }
.htt-basis { font-size: 0.7rem; color: var(--ink-soft); font-style: italic; }
.htt-sol-note { font-size: 0.78rem; color: var(--ink-soft); margin-top: 2px; grid-column: 2 / -1; }

.htt-extract {
  background: linear-gradient(135deg, rgba(31,138,138,0.10), rgba(231,151,47,0.08));
  border: 1px solid var(--line);
}
.htt-extract .htt-extract-type {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: var(--green); color: #fff; font-weight: 700; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px;
}

.htt-active {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px; align-items: center;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.htt-active:last-child { border-bottom: 0; }
.htt-active:hover { background: var(--paper-soft); }
.htt-active-name { font-size: 0.9rem; overflow-wrap: anywhere; }
.htt-lean { font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; }
.htt-lean.lipophilic { background: rgba(231,151,47,0.18); color: #a86a13; }
.htt-lean.polar { background: rgba(31,138,138,0.16); color: #157272; }
.htt-lean.intermediate { background: var(--paper-soft); color: var(--ink-soft); }
.htt-lean.unknown { background: var(--paper-soft); color: var(--ink-soft); }
.htt-active-meta { font-size: 0.72rem; color: var(--ink-soft); white-space: nowrap; }

.htt-disclaimer {
  font-size: 0.76rem; color: var(--ink-soft);
  text-align: center; padding: 14px 8px 4px; line-height: 1.5;
}
.htt-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.htt-chip {
  font-size: 0.74rem; padding: 3px 9px; border-radius: 999px;
  background: var(--paper-soft); color: var(--ink-soft);
}

.htt-active.curated { background: rgba(231,151,47,0.06); }
.htt-marker {
  font-size: 0.66rem; font-weight: 800; color: #a86a13;
  background: rgba(231,151,47,0.18); padding: 1px 6px; border-radius: 999px;
  letter-spacing: 0.03em; white-space: nowrap;
}
.htt-active-class { font-size: 0.7rem; color: var(--ink-soft); }

.htt-active-sol { display: flex; gap: 5px; margin-top: 5px; }
.htt-mini {
  font-size: 0.66rem; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  letter-spacing: 0.02em;
}
.htt-mini.high { background: rgba(31,138,138,0.18); color: #157272; }
.htt-mini.moderate { background: rgba(231,151,47,0.16); color: #a86a13; }
.htt-mini.low { background: var(--paper-soft); color: var(--ink-soft); }
.htt-mini.unknown { background: var(--paper-soft); color: var(--ink-soft); }
