:root {
  --hero: #1d2d1d;
  --hero-2: #273a28;
  --page: #f6f8f7;
  --paper: #ffffff;
  --paper-soft: #eef4ef;
  --paper-warm: #fff6ef;
  --ink: #332e3a;
  --ink-soft: #6b6871;
  --line: #dde5de;
  --line-strong: #c8d6ca;
  --green: #4a7149;
  --green-soft: rgba(74, 113, 73, 0.10);
  --orange: #f48e4f;
  --mint: #dceee0;
  --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 .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;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ─── 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;
}
.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;
}

/* ─ 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;
}

/* ─ Key descriptors (inline cards) ─ */
.key-descriptors {
  display: grid;
  gap: 8px;
}
.kd-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px solid var(--line);
}
.kd-signal {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.kd-signal.favorable { background: var(--green); }
.kd-signal.mixed { background: var(--orange); }
.kd-signal.poor { background: #b65b31; }
.kd-body {
  flex: 1;
  min-width: 0;
}
.kd-title {
  font-size: 0.82rem;
  font-weight: 700;
}
.kd-value {
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.kd-explain {
  font-size: 0.78rem;
  color: var(--ink-soft);
  opacity: 0.8;
  margin-top: 2px;
}

/* ─ 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);
}

/* ─── 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;
  }
}
