:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #607080;
  --line: #dce3e8;
  --paper: #ffffff;
  --wash: #f3f7f8;
  --accent: #006d77;
  --accent-dark: #00545c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  color: var(--ink);
  background: linear-gradient(145deg, #eef7f5 0%, var(--wash) 45%, #f7f4ed 100%);
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body.drawer-open { overflow: hidden; }
main { width: min(1500px, calc(100% - 48px)); margin: 2.5vh auto 36px; }
header { max-width: 680px; }
.eyebrow { color: var(--accent); font-size: .76rem; font-weight: 750; letter-spacing: .14em; }
h1 { margin: .15rem 0 .2rem; font-size: clamp(1.7rem, 3.5vw, 2.65rem); line-height: 1.08; letter-spacing: -.035em; }
header p { margin: 0 0 1rem; color: var(--muted); font-size: .98rem; }
form {
  position: relative;
  padding: 18px 20px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 18px;
  background: rgba(255,255,255,.78);
  box-shadow: 0 20px 60px rgba(28,57,62,.09);
  backdrop-filter: blur(12px);
}
label { display: block; margin-bottom: 8px; font-weight: 700; }
.search-row { display: flex; gap: 10px; }
input {
  min-width: 0;
  flex: 1;
  padding: 14px 16px;
  border: 1px solid #aab8c0;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 1.12rem;
}
input:focus { outline: 3px solid rgba(0,109,119,.18); border-color: var(--accent); }
button {
  padding: 14px 22px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--accent);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button:disabled { cursor: wait; opacity: .65; }
.message { min-height: 1.5em; margin-top: 8px; color: var(--muted); }
.filters { margin-top: 16px; display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.filters[hidden] { display: none; }
.filters label { margin: 0; color: var(--muted); font-size: .76rem; }
.filters select { width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid #aab8c0; border-radius: 8px; color: var(--ink); background: var(--paper); font: inherit; font-size: .86rem; }
.clear-filters { align-self: end; justify-self: start; padding: 9px 14px; color: var(--accent-dark); border: 1px solid #9bbfc0; background: #eef8f6; font-size: .86rem; }
.clear-filters:hover { color: #fff; background: var(--accent); }
.scroll-note { margin: 12px 2px 5px; color: var(--accent-dark); font-size: .83rem; font-weight: 700; }
.scroll-note[hidden] { display: none; }
.suggestions { position: relative; margin-top: 5px; max-height: min(67vh, 720px); overflow-y: scroll; border: 2px solid #b7c8cf; border-radius: 12px; background: var(--paper); box-shadow: inset 0 -18px 18px -20px rgba(23,33,43,.8), 0 16px 35px rgba(28,57,62,.12); scrollbar-color: var(--accent) #e4ecef; scrollbar-width: auto; }
.suggestions::-webkit-scrollbar { width: 14px; }
.suggestions::-webkit-scrollbar-track { background: #e4ecef; border-radius: 0 10px 10px 0; }
.suggestions::-webkit-scrollbar-thumb { min-height: 48px; border: 3px solid #e4ecef; border-radius: 10px; background: var(--accent); }
.suggestion-header, .suggestion { width: 100%; display: grid; grid-template-columns: minmax(125px, .7fr) minmax(180px, 1.1fr) minmax(200px, 1.35fr) minmax(160px, 1fr) minmax(120px, .75fr) minmax(130px, .8fr); gap: 16px; align-items: start; }
.suggestion-header { position: sticky; top: 0; z-index: 1; padding: 10px 14px; border-bottom: 1px solid #c8d3d9; color: var(--muted); background: #f5f8f8; font-size: .72rem; font-weight: 750; letter-spacing: .055em; text-transform: uppercase; }
.suggestion { padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; color: var(--ink); background: var(--paper); text-align: left; font-size: .93rem; font-weight: 400; }
.suggestion:last-child { border-bottom: 0; }
.suggestion:hover, .suggestion.active { color: var(--ink); background: #eaf5f3; }
.suggestion-ndc { color: var(--accent-dark); font-variant-numeric: tabular-nums; font-weight: 750; }
.suggestion-name { font-weight: 700; }
.suggestion-name small { display: block; margin-top: 3px; color: var(--muted); font-size: .78rem; font-weight: 400; }
.suggestion-ingredient { color: var(--muted); overflow-wrap: anywhere; white-space: normal; }
.suggestion-labeler, .suggestion-form, .suggestion-route { color: var(--muted); overflow-wrap: anywhere; }
mark { padding: .02em .12em; border-radius: 3px; color: inherit; background: #ffe08a; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.suggestion.active mark, .suggestion:hover mark { background: #ffd45c; }
#results { margin-top: 22px; display: grid; gap: 16px; }
.result {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 8px 30px rgba(28,57,62,.06);
}
.result h2 { margin: 0; font-size: 1.55rem; letter-spacing: -.02em; }
.generic { margin: 2px 0 20px; color: var(--muted); }
dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; margin: 0; }
dt { color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
dd { margin: 2px 0 0; overflow-wrap: anywhere; }
footer { padding: 24px 16px; color: var(--muted); text-align: center; font-size: .82rem; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(15, 28, 34, .48); backdrop-filter: blur(2px); }
.detail-drawer { position: fixed; inset: 0 0 0 auto; z-index: 21; width: min(680px, 94vw); overflow-y: auto; padding: 28px; border: 0; background: var(--paper); box-shadow: -18px 0 55px rgba(15, 28, 34, .24); }
.detail-drawer[hidden], .drawer-backdrop[hidden] { display: none; }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.drawer-header h2 { margin: .25rem 0 0; font-size: clamp(1.65rem, 4vw, 2.25rem); line-height: 1.15; }
.drawer-header p { margin: .35rem 0 0; color: var(--muted); }
.icon-button { flex: 0 0 auto; width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); color: var(--ink); background: var(--wash); font-size: 1.8rem; line-height: 1; }
.icon-button:hover { color: #fff; background: var(--accent); }
.drawer-content { padding: 24px 0; }
.drawer-content dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.copy-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.copy-button { padding: 8px 12px; color: var(--accent-dark); border: 1px solid #9bbfc0; background: #eef8f6; font-size: .84rem; }
.copy-button:hover { color: #fff; background: var(--accent); }
.drawer-error { padding: 18px; border-radius: 10px; color: #842029; background: #f8d7da; }
.orange-book-section { margin-top: 28px; padding-top: 24px; border-top: 2px solid var(--line); }
.orange-book-section h3 { margin: 0 0 6px; font-size: 1.28rem; }
.source-note { margin: 0 0 16px; color: var(--muted); font-size: .86rem; }
.source-note a { color: var(--accent-dark); font-weight: 700; }
.orange-book-match { margin-top: 14px; padding: 18px; border: 1px solid #bfd2d6; border-radius: 12px; background: #f7fbfa; }
.orange-book-title { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.confidence { padding: 3px 8px; border-radius: 999px; font-size: .72rem; font-weight: 750; text-transform: uppercase; }
.confidence.high { color: #155724; background: #d4edda; }
.confidence.medium { color: #664d03; background: #fff3cd; }
.confidence.low { color: #842029; background: #f8d7da; }
.equivalent-list { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.equivalent-list h4 { margin: 0; font-size: 1rem; }
.equivalent-list p, .equivalent-empty { margin: 5px 0 10px; color: var(--muted); font-size: .82rem; }
.equivalent-list ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.equivalent-list li { display: grid; padding: 10px; border-radius: 8px; background: var(--paper); }
.equivalent-list li span { color: var(--muted); font-size: .8rem; }
.drawer-navigation { position: sticky; bottom: -28px; display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin: 12px -28px -28px; padding: 16px 28px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .96); }
.drawer-navigation button:last-child { justify-self: end; }
.drawer-navigation span { color: var(--muted); font-size: .85rem; text-align: center; }
@media (max-width: 600px) {
  main { width: min(100% - 24px, 1500px); margin-top: 2vh; }
  .search-row { flex-direction: column; }
  .filters { grid-template-columns: 1fr; }
  .suggestion-header { display: none; }
  .suggestion { grid-template-columns: 1fr; gap: 2px; }
  .suggestions { max-height: 62vh; }
  dl { grid-template-columns: 1fr; }
  .detail-drawer { width: 100%; padding: 20px; }
  .drawer-content dl { grid-template-columns: 1fr; }
  .drawer-navigation { bottom: -20px; margin: 12px -20px -20px; padding: 14px 20px; }
  .drawer-navigation button { padding: 10px 12px; }
}
