:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-alt: #eef3f9;
  --ink: #162033;
  --muted: #65728a;
  --line: #d9e2ef;
  --accent: #2463eb;
  --accent-dark: #1746ad;
  --lower: #2c7bb6;
  --leaky: #f2b34d;
  --high: #d94b43;
  --very-high: #7f1d1d;
  --unscored: #748197;
  --shadow: 0 14px 36px rgba(28, 45, 78, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
a { color: var(--accent-dark); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.65; }

.hero { background: radial-gradient(circle at 80% 5%, rgba(63, 113, 230, 0.5), transparent 30%), linear-gradient(135deg, #0d1730, #1b315d); color: #fff; }
.hero-inner { max-width: 1240px; margin: 0 auto; padding: 64px 28px 58px; }
.hero h1 { margin: 5px 0 12px; font-size: clamp(2.4rem, 6vw, 4.4rem); letter-spacing: -0.045em; line-height: 1; }
.hero-copy { max-width: 820px; margin: 0; color: #d9e5ff; font-size: 1.16rem; }
.eyebrow { margin: 0; color: #b9ccfa; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.eyebrow.dark { color: var(--accent-dark); }
.hero-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border: 1px solid transparent; border-radius: 10px; padding: 9px 15px; text-decoration: none; font-weight: 750; }
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.button.light { background: #fff; color: #17213a; }
.button.ghost { border-color: rgba(255, 255, 255, 0.28); color: #fff; }

main { max-width: 1360px; margin: 0 auto; }
.section { margin: 28px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: -24px; position: relative; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-card span { display: block; color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.stat-card strong { display: block; margin: 7px 0 2px; font-size: clamp(1.55rem, 3vw, 2.25rem); line-height: 1; }
.stat-card strong.model-name { font-size: 1.05rem; line-height: 1.25; word-break: break-word; }
.stat-card small { color: var(--muted); }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 18px; }
.section-heading h2 { margin: 3px 0 0; font-size: clamp(1.7rem, 3vw, 2.45rem); letter-spacing: -0.025em; }
.section-heading > p { max-width: 660px; margin: 0; color: var(--muted); }
.lookup-section, .prose-section { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 24px; box-shadow: var(--shadow); }
.notice, .warning-box, .live-warning { border-radius: 12px; padding: 12px 14px; }
.notice { background: #eef5ff; border: 1px solid #c9dcff; }
.notice[data-kind="error"] { background: #fff0f0; border-color: #f0b8b8; }

.search-panel { background: var(--surface-alt); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.search-panel > label, .filter-grid label { color: var(--muted); font-size: 0.82rem; font-weight: 760; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; margin-top: 7px; }
.search-row input, select { width: 100%; min-height: 44px; border: 1px solid #c7d3e4; border-radius: 10px; background: #fff; color: var(--ink); padding: 9px 12px; }
.search-row input:focus, select:focus { outline: 3px solid rgba(36, 99, 235, 0.16); border-color: var(--accent); }
.example-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 11px; color: var(--muted); font-size: 0.82rem; }
.example-row button { border: 1px solid #c7d3e4; border-radius: 999px; background: #fff; padding: 4px 9px; color: var(--ink); }
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.filter-grid select { display: block; margin-top: 5px; }

.fallback { display: flex; align-items: center; justify-content: space-between; gap: 20px; background: #fff8e8; border: 1px solid #efd18a; border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.fallback p { margin: 3px 0 0; color: #695529; }

.lookup-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(330px, 0.85fr); gap: 16px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.panel-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 14px 15px; border-bottom: 1px solid var(--line); }
.panel-heading h3 { margin: 0; font-size: 1rem; }
.panel-heading span { color: var(--muted); font-size: 0.79rem; text-align: right; }
#chembl-status[data-kind="error"] { color: #a22727; }
#chembl-status[data-kind="warning"] { color: #7b5b15; }
#chembl-status[data-kind="success"] { color: #17633c; }
.table-wrap { max-height: 560px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { padding: 9px 10px; border-bottom: 1px solid #e9eef5; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; background: #13213c; color: #fff; white-space: nowrap; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: #f4f7fc; }
tbody tr.selected { background: #e8f0ff; }
.small { font-size: 0.72rem; }
.muted { color: var(--muted); }
.table-footnote { margin: 0; padding: 10px 14px; color: var(--muted); font-size: 0.75rem; border-top: 1px solid var(--line); }

.badge { display: inline-block; border-radius: 999px; padding: 3px 8px; color: #fff; font-size: 0.72rem; font-weight: 800; text-transform: lowercase; white-space: nowrap; }
.badge-lower { background: var(--lower); }
.badge-leaky { background: var(--leaky); color: #34240c; }
.badge-high { background: var(--high); }
.badge-very_high { background: var(--very-high); }
.badge-unscored { background: var(--unscored); }

.chembl-area { border-top: 8px solid var(--bg); }
.chembl-results { display: grid; gap: 8px; padding: 12px; }
.chembl-result { display: grid; grid-template-columns: minmax(0, 1fr) minmax(190px, auto); gap: 12px; align-items: center; width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); padding: 11px; text-align: left; }
.chembl-result:hover { border-color: #9db9ee; background: #f6f9ff; }
.chembl-result small { display: block; margin-top: 3px; color: var(--muted); }
.chembl-score { text-align: right; }
.chembl-score strong { margin-left: 7px; }

.detail-panel { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; padding: 17px; }
.detail-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.detail-heading h2 { margin: 0; font-size: 1.35rem; line-height: 1.2; }
.detail-heading p { margin: 4px 0 0; color: var(--muted); font-size: 0.82rem; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.detail-cell { background: #f6f8fc; border: 1px solid var(--line); border-radius: 10px; padding: 9px; }
.detail-label { color: var(--muted); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.055em; text-transform: uppercase; }
.detail-value { margin-top: 3px; font-size: 0.88rem; overflow-wrap: anywhere; }
.detail-section { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.detail-section h3 { margin: 0 0 5px; font-size: 0.83rem; text-transform: uppercase; letter-spacing: 0.045em; }
.detail-section p { margin: 0; color: #46536a; font-size: 0.88rem; }
.live-warning { margin-top: 13px; background: #fff4e7; border: 1px solid #ebc28e; color: #694817; font-size: 0.82rem; }
.empty-state { padding: 22px; color: var(--muted); text-align: center; }

.prose-section { max-width: 1120px; margin-left: auto; margin-right: auto; }
.prose-section p { color: #46536a; }
.formula { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #f7f9fc; padding: 15px; font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; white-space: nowrap; }
.method-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.method-grid article { border: 1px solid var(--line); border-radius: 12px; padding: 13px; }
.method-grid h3 { margin: 0; }
.method-grid p { margin: 4px 0 0; font-size: 0.85rem; }
.warning-box { margin-top: 16px; background: #fff2f2; border: 1px solid #edbcbc; color: #6d2929; }
.steps { margin: 0; padding-left: 23px; }
.steps li { margin: 9px 0; color: #46536a; }
.download-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.download-grid a { display: block; border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-decoration: none; }
.download-grid a:hover { border-color: #9db9ee; background: #f7f9ff; }
.download-grid strong, .download-grid span { display: block; }
.download-grid span { margin-top: 4px; color: var(--muted); font-size: 0.83rem; }

footer { margin-top: 42px; background: #111d35; color: #cad7ee; padding: 25px; text-align: center; }
footer a { color: #fff; }

@media (max-width: 1050px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lookup-grid { grid-template-columns: 1fr; }
  .detail-panel { position: static; max-height: none; }
  .method-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .section { margin: 16px; }
  .hero-inner { padding: 48px 19px; }
  .stats { grid-template-columns: 1fr; margin-top: 16px; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: 8px; }
  .search-row, .filter-grid { grid-template-columns: 1fr; }
  .fallback { display: block; }
  .fallback .button { margin-top: 12px; width: 100%; }
  .chembl-result { grid-template-columns: 1fr; }
  .chembl-score { text-align: left; }
  .detail-grid, .method-grid, .download-grid { grid-template-columns: 1fr; }
  .formula { font-size: 0.92rem; }
}
