:root {
  color-scheme: light;
  --ink: #18312f;
  --muted: #5f716f;
  --paper: #f6f8f4;
  --panel: #ffffff;
  --line: #d8e1dd;
  --brand: #0f766e;
  --brand-dark: #0a544f;
  --brand-pale: #e3f3ef;
  --warning: #7a4a05;
  --warning-pale: #fff4d6;
  --shadow: 0 14px 40px rgba(35, 62, 57, 0.08);
  font-family: Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
}

button, input, select, textarea { font: inherit; }

a { color: var(--brand-dark); }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

.hero {
  padding: 54px 0 48px;
  color: white;
  background:
    radial-gradient(circle at 90% 15%, rgba(255, 255, 255, 0.18), transparent 24%),
    linear-gradient(130deg, #075f59, #16877c);
}

.eyebrow, .step {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.15;
}

.hero-copy {
  max-width: 720px;
  margin: 16px 0 0;
  font-size: 1.05rem;
  opacity: 0.92;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  padding-block: 28px 48px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
}

.search-panel, .results-panel { grid-column: 1; }
.consultation-panel { grid-column: 2; grid-row: 1 / span 2; align-self: start; position: sticky; top: 18px; }

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

.section-heading h2 { margin: 0; font-size: 1.35rem; }
.step { color: var(--brand); }

.search-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
}

.field { display: grid; gap: 7px; font-weight: 700; }
.field-wide { grid-column: 1 / -1; }
.field small, .muted { color: var(--muted); font-weight: 400; }

.choice-field {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.choice-field legend { margin-bottom: 7px; font-weight: 700; }

.choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }

.choice-chip { position: relative; cursor: pointer; }
.choice-chip input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.choice-chip span {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  border: 1px solid #b8c8c3;
  border-radius: 999px;
  background: white;
  padding: 7px 14px;
  font-weight: 700;
}
.choice-chip input:checked + span { border-color: var(--brand); color: white; background: var(--brand); }
.choice-chip input:focus-visible + span { outline: 3px solid rgba(15, 118, 110, 0.2); outline-offset: 2px; }

input, select, textarea {
  width: 100%;
  border: 1px solid #b8c8c3;
  border-radius: 10px;
  color: var(--ink);
  background: white;
  padding: 11px 12px;
}

input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.2);
  outline-offset: 2px;
  border-color: var(--brand);
}

textarea { resize: vertical; line-height: 1.5; }

.button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
}

.button:disabled { cursor: not-allowed; opacity: 0.45; }
.button-primary { color: white; background: var(--brand); }
.button-primary:hover:not(:disabled) { background: var(--brand-dark); }
.button-quiet { color: var(--brand-dark); background: var(--brand-pale); }
.button-full { width: 100%; margin-top: 12px; }

.data-status, .copy-status { min-height: 1.6em; margin: 16px 0 0; color: var(--muted); }
.data-status[data-state="error"] { color: #a12b2b; }

.safety-note {
  margin: 0 0 18px;
  border-left: 4px solid #e3ae43;
  background: var(--warning-pale);
  color: var(--warning);
  padding: 12px 14px;
}

.count-badge, .match-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--brand-pale);
  color: var(--brand-dark);
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
}

.match-badge.unknown { background: var(--warning-pale); color: var(--warning); }

.result-list { display: grid; gap: 14px; }

.drug-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.drug-image {
  width: 150px;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 10px;
  background: #eef2ef;
}

.image-placeholder {
  display: grid;
  place-items: center;
  width: 150px;
  aspect-ratio: 1;
  border-radius: 10px;
  color: var(--muted);
  background: #eef2ef;
  text-align: center;
  padding: 12px;
}

.drug-head { display: flex; justify-content: space-between; gap: 12px; }
.drug-head h3 { margin: 0; font-size: 1.12rem; }
.drug-en { margin: 2px 0 10px; color: var(--muted); font-size: 0.9rem; }

.facts {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 4px 10px;
  margin: 0 0 12px;
  font-size: 0.94rem;
}

.facts dt { color: var(--muted); font-weight: 700; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.missing-note { margin: 8px 0 12px; color: var(--warning); font-size: 0.9rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.card-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; }

.draft-items { display: grid; gap: 8px; margin-bottom: 14px; }
.draft-item { display: flex; gap: 8px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.draft-item span { font-weight: 700; }
.draft-item button { border: 0; color: #8a2525; background: transparent; cursor: pointer; }

.empty-state { color: var(--muted); text-align: center; padding: 28px 10px; }

.footer { padding: 28px 0 40px; color: var(--muted); border-top: 1px solid var(--line); }
.footer-grid { display: grid; grid-template-columns: 1fr auto; gap: 24px; }
.footer p { margin: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .search-panel, .results-panel, .consultation-panel { grid-column: 1; grid-row: auto; }
  .consultation-panel { position: static; }
}

@media (max-width: 640px) {
  .shell { width: min(100% - 20px, 1180px); }
  .hero { padding: 38px 0 34px; }
  .layout { padding-top: 18px; }
  .panel { padding: 18px; border-radius: 14px; }
  .search-form { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .drug-card { grid-template-columns: 1fr; }
  .drug-image, .image-placeholder { width: 100%; max-height: 230px; }
  .facts { grid-template-columns: 100px 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
}
