:root {
  --ink: #153844;
  --muted: #58727b;
  --line: #d9e5e7;
  --canvas: #f4f8f8;
  --surface: #ffffff;
  --teal: #0d5666;
  --aqua: #10a7b8;
  --orange: #d76b33;
  --violet: #7357c9;
  --shadow: 0 18px 42px rgba(21, 56, 68, 0.09);
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #e7f4f5 0, var(--canvas) 28rem);
  font-family: Tahoma, Arial, "Vazirmatn", sans-serif;
  font-size: 16px;
  line-height: 1.75;
}

button, input { font: inherit; }

button { cursor: pointer; }

.shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 52px 0 38px;
}

.masthead {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: start;
  margin: 0 0 30px;
}

.brand-mark {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  color: #fff;
  background: var(--teal);
  border-radius: 20px 20px 6px 20px;
  direction: ltr;
  font: 700 1.45rem/1 Arial, sans-serif;
  box-shadow: 8px 8px 0 #a9dfe4;
}

.eyebrow, .section-label {
  margin: 0;
  color: var(--aqua);
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.015em;
}

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

h1 {
  margin-bottom: 5px;
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.18;
}

h2 { margin-bottom: 4px; font-size: clamp(1.25rem, 3vw, 1.55rem); line-height: 1.35; }
h3 { margin-bottom: 4px; font-size: 1.18rem; line-height: 1.48; }
.intro, .search-copy p { margin-bottom: 0; color: var(--muted); }

.search-panel, .interaction-card, .safety-note, .live-panel {
  background: var(--surface);
  border: 1px solid rgba(217, 229, 231, 0.95);
  box-shadow: var(--shadow);
}

.search-panel {
  position: relative;
  z-index: 2;
  padding: 28px;
  border-radius: 24px;
}

.search-copy { margin-bottom: 18px; }

.search-box {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 17px;
  border: 2px solid #c8dde1;
  border-radius: 15px;
  background: #fbfdfd;
  color: var(--aqua);
}

.search-box:focus-within { border-color: var(--aqua); box-shadow: 0 0 0 4px rgba(16, 167, 184, 0.13); }

.search-box input {
  width: 100%;
  padding: 15px 0;
  color: var(--ink);
  border: 0;
  outline: 0;
  background: transparent;
}

.drug-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.drug-results:empty { display: none; }

.search-status {
  min-height: 1.35rem;
  margin: 9px 3px -4px;
  color: var(--muted);
  font-size: 0.79rem;
}

.search-status:empty { min-height: 0; margin: 0; }

.drug-button {
  min-height: 72px;
  padding: 12px 14px;
  text-align: right;
  color: var(--ink);
  background: #f4fafb;
  border: 1px solid #d5e7e9;
  border-radius: 12px;
}

.drug-button:hover, .drug-button:focus-visible { color: #fff; background: var(--teal); border-color: var(--teal); outline: 0; }
.drug-button span { display: block; color: inherit; font-size: 0.78rem; opacity: 0.7; }

.drug-button .result-kind {
  display: inline-block;
  margin-bottom: 3px;
  color: var(--aqua);
  font-size: 0.7rem;
  font-weight: 700;
  opacity: 1;
}

.drug-button:hover .result-kind, .drug-button:focus-visible .result-kind { color: #d5fbff; }

.live-panel {
  margin: 0 0 34px;
  padding: 25px;
  border-radius: 20px;
}

.live-panel[hidden] { display: none; }

.live-heading {
  display: flex;
  gap: 20px;
  align-items: start;
  justify-content: space-between;
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line);
}

.live-heading h2 { margin-bottom: 3px; }
.live-meta { margin: 0; color: var(--muted); font-size: 0.88rem; }

.loading-line {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 20px 0 0;
  color: var(--muted);
}

.loading-dot {
  width: 12px;
  height: 12px;
  border: 2px solid #b8d6da;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.machine-note {
  margin: 18px 0 12px;
  padding: 11px 13px;
  color: #655018;
  background: #fff9dc;
  border: 1px solid #efe0a2;
  border-radius: 11px;
  font-size: 0.82rem;
}

.label-passages { display: grid; gap: 11px; }

.label-passage {
  padding: 16px;
  background: #f7fbfb;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.label-passage h3 { margin-bottom: 8px; font-size: 0.98rem; }
.label-passage p { margin-bottom: 10px; }

.source-language {
  padding-top: 9px;
  border-top: 1px dashed #c8dcdf;
  direction: ltr;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: left;
}

.source-language summary { cursor: pointer; color: var(--teal); font-weight: 700; }
.source-language p { margin: 8px 0 0; }

.label-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.label-source {
  display: inline-flex;
  padding: 6px 10px;
  color: var(--teal);
  background: #edf7f8;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  text-decoration: none;
}

.live-empty {
  margin: 18px 0 0;
  color: var(--muted);
}

.safety-note {
  margin: 22px 0 38px;
  padding: 15px 18px;
  color: #71391d;
  background: #fff5eb;
  border-color: #f2d0b9;
  border-right: 5px solid var(--orange);
  border-radius: 13px;
  box-shadow: none;
}

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

.filters { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-start; }

.filter {
  padding: 7px 11px;
  color: var(--teal);
  background: transparent;
  border: 1px solid #b9d5d9;
  border-radius: 99px;
  font-size: 0.84rem;
}

.filter.active, .filter:hover, .filter:focus-visible { color: #fff; background: var(--teal); border-color: var(--teal); outline: 0; }

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

.interaction-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
}

.interaction-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  content: "";
  background: var(--card-color, var(--aqua));
}

.card-summary {
  display: flex;
  gap: 18px;
  align-items: start;
  justify-content: space-between;
  width: 100%;
  padding: 22px 25px 20px;
  text-align: right;
  color: inherit;
  background: var(--surface);
  border: 0;
}

.card-summary:hover { background: #fbfefe; }
.card-summary:focus-visible { outline: 3px solid rgba(16, 167, 184, 0.35); outline-offset: -3px; }
.card-summary h3 { margin-bottom: 2px; }
.card-summary p { margin: 0; color: var(--muted); font-size: 0.93rem; }

.badge {
  display: inline-block;
  flex: 0 0 auto;
  padding: 4px 10px;
  color: var(--card-color, var(--teal));
  background: color-mix(in srgb, var(--card-color, var(--teal)) 10%, white);
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 700;
  white-space: nowrap;
}

.card-detail {
  display: none;
  padding: 0 25px 24px;
  border-top: 1px solid var(--line);
}

.interaction-card.open .card-detail { display: block; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
  margin: 20px 0 16px;
}

.detail-block { min-width: 0; }
.detail-block strong { display: block; margin-bottom: 2px; color: var(--teal); font-size: 0.85rem; }
.detail-block p { margin: 0; }

.aliases { margin: 14px 0; color: var(--muted); font-size: 0.87rem; }
.aliases strong { color: var(--teal); }

.source-link {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--teal);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.empty {
  padding: 30px;
  color: var(--muted);
  text-align: center;
  background: #fff;
  border: 1px dashed #b9d5d9;
  border-radius: 18px;
}

footer {
  display: grid;
  gap: 6px;
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 25px 0 38px;
  color: #58727b;
  font-size: 0.82rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 680px) {
  .shell { width: min(100% - 24px, 1040px); padding-top: 28px; }
  .masthead { gap: 14px; }
  .brand-mark { width: 50px; height: 50px; border-radius: 16px 16px 5px 16px; }
  .search-panel { padding: 20px 16px; border-radius: 18px; }
  .drug-results { grid-template-columns: 1fr; }
  .live-panel { padding: 19px 16px; border-radius: 18px; }
  .live-heading { display: block; }
  .live-heading > .source-link { margin-top: 10px; }
  .toolbar, .card-summary { display: block; }
  .toolbar { margin-bottom: 16px; }
  .filters { margin-top: 12px; }
  .card-summary { padding: 17px 18px 14px; }
  .badge { margin-top: 8px; }
  .card-detail { padding: 0 18px 18px; }
  .detail-grid { grid-template-columns: 1fr; gap: 13px; margin-top: 16px; }
  h1 { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
  .loading-dot { animation: none; }
}
