@font-face {
  font-family: Inter;
  src: url(/fonts/inter-latin.woff2) format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ink: #0f1115;
  --ink-2: #4b5260;
  --ink-3: #6b7280;
  --line: #e6e8ec;
  --line-strong: #d3d6dc;
  --surface: #ffffff;
  --page: #fafafb;
  --hover: #f3f4f6;
  --accent: #00a87e;
  --map: #0b0d12;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(15 17 21 / .08), 0 8px 24px rgb(15 17 21 / .14);
  --topbar: 60px;
  color: var(--ink);
  background: var(--page);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-feature-settings: 'cv11', 'ss03';
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; font-size: 16px; letter-spacing: -.02em; }
.brand img { display: block; border-radius: 6px; }

/* Shared controls */
.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: #eef0f3; gap: 2px; }
.segmented > button, .segmented > a {
  border: 0; background: transparent; color: var(--ink-2); padding: 6px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500; white-space: nowrap; transition: background .12s, color .12s;
}
.segmented > button:hover, .segmented > a[href]:hover { color: var(--ink); }
.segmented [aria-selected=true], .segmented [aria-current=page] {
  background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(15 17 21 / .12);
}
.segmented.small { display: flex; margin-top: 10px; padding: 2px; }
.segmented.small > button { flex: 1; padding: 3px 6px; font-size: 12px; border-radius: 6px; }
.segmented [aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(15 17 21 / .12); }
.label-short { display: none; }

.text-button { border: 0; background: transparent; color: var(--ink-2); padding: 6px 10px; border-radius: 8px; font-weight: 500; font-size: 13px; }
.text-button:hover { background: var(--hover); color: var(--ink); }
.text-button.small { padding: 3px 8px; font-size: 12px; }
.text-link { color: var(--accent); font-weight: 500; }
.text-link:hover { text-decoration: underline; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); }
.icon-button:hover { background: var(--hover); color: var(--ink); }
.icon-button svg, .chevron { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.vendor-logo { display: block; height: calc(var(--logo-size, 24px) * var(--logo-scale, 1)); max-width: 100%; object-fit: contain; object-position: left center; }
.muted { color: var(--ink-3); }

/* Landing */
.landing-bar { display: flex; align-items: center; justify-content: space-between; max-width: 1320px; margin: 0 auto; padding: 22px 32px; }
.byline { color: var(--ink-3); font-size: 13px; }
.byline:hover { color: var(--ink); }
.landing-main { max-width: 1320px; margin: 0 auto; padding: 28px 32px 72px; }
.hero h1 { margin: 0; font-size: clamp(28px, 3.6vw, 42px); line-height: 1.1; letter-spacing: -.03em; font-weight: 600; }
.hero p { margin: 12px 0 32px; color: var(--ink-3); font-size: 15px; font-variant-numeric: tabular-nums; }
.view-note { margin: 14px 0 24px; color: var(--ink-3); font-size: 13px; }
.space-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px 24px; }
.space-card { display: block; }
.space-thumb { aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius); background: var(--map); margin-bottom: 14px; }
.space-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .35s cubic-bezier(.2, .7, .2, 1); }
.space-card[href]:hover .space-thumb img { transform: scale(1.035); }
.space-logo { display: flex; align-items: center; height: 42px; margin-bottom: 6px; }
.space-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.space-count { font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.space-meta { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.space-card.unavailable { opacity: .45; }
.load-error { color: var(--ink-2); }

/* Map shell */
.map-page { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: var(--map); }
.topbar {
  flex: none; height: var(--topbar); display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 20;
}
.topbar .segmented { margin-left: auto; }
.picker { position: relative; min-width: 0; }
.picker-button {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px 0 12px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; font-weight: 500;
}
.picker-button:hover { background: var(--hover); }
.picker-button { --logo-size: 18px; }
.picker-button .vendor-logo { max-width: 92px; flex: none; }
.picker-button .chevron { color: var(--ink-3); flex: none; }
.picker-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.picker-count { font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.picker-menu {
  position: absolute; top: calc(100% + 6px); left: 0; width: 400px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 90px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px;
}
.picker-item { display: flex; align-items: center; gap: 14px; padding: 9px 10px; border-radius: 8px; }
.picker-item[href]:hover, .picker-item:focus-visible { background: var(--hover); outline: none; }
.picker-item[aria-current] { background: #effaf6; }
.picker-item[aria-disabled] { opacity: .45; }
.logo-box { --logo-size: 20px; flex: none; width: 96px; height: 34px; display: flex; align-items: center; }
.picker-text { display: flex; flex-direction: column; min-width: 0; }
.picker-sub { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }

.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--map); }
.stage:fullscreen { height: 100dvh; }
.map-host, .scatter-canvas, .scatter-ink, .density-tiles, .density-ink { position: absolute; inset: 0; width: 100%; height: 100%; }
.scatter-canvas { touch-action: none; cursor: crosshair; outline: none; }
.scatter-ink, .density-ink { pointer-events: none; }
.density-tiles { cursor: crosshair; outline: none; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.clean .card, .clean .minimap { display: none; }

/* Molecule card */
.inspector { position: absolute; top: 16px; right: 16px; width: 360px; max-width: calc(100% - 32px); z-index: 6; padding: 14px 16px; }
.inspector-empty { display: none; margin: 0; color: var(--ink-3); font-size: 13px; }
.inspector.empty { width: auto; }
.inspector.empty .inspector-empty { display: block; }
.inspector.empty .inspector-body { display: none; }
.inspector-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-height: 40px; }
.inspector-titles { display: flex; flex-direction: column; min-width: 0; }
.inspector-titles strong { font-weight: 600; font-size: 15px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.inspector-titles span { color: var(--ink-3); font-size: 12px; }
.inspector-head .icon-button { margin: -6px -8px 0 0; flex: none; }
.inspector { max-height: calc(100% - 32px); overflow: auto; }
.inspector.untitled .inspector-titles { display: none; }
.inspector.untitled .inspector-head { min-height: 0; position: absolute; top: 14px; right: 16px; z-index: 1; }
.inspector.untitled .mol-drawing { margin-top: 0; }
.mol-parts-row { margin: -2px 0 8px -8px; }
.mol-parts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.mol-part { aspect-ratio: 200 / 130; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mol-part svg { display: block; width: 100%; height: 100%; }
.inspector.pinned { box-shadow: 0 0 0 1.5px var(--accent), var(--shadow); }
.mol-drawing { aspect-ratio: 400 / 238; margin: 6px 0 8px; transition: opacity .12s; }
.mol-drawing svg { display: block; width: 100%; height: 100%; }
.mol-unavailable { margin: 0; padding-top: 40px; text-align: center; color: var(--ink-3); }
.inspector.pending .mol-drawing { opacity: .4; }
.mol-facts { display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; margin: 0 0 10px; }
.mol-facts:empty { display: none; }
.mol-facts dt { color: var(--ink-3); font-size: 11px; }
.mol-facts dd { margin: 0; font-weight: 500; font-size: 13px; font-variant-numeric: tabular-nums; }
.smiles-row { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.smiles-row code { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 11.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2); }
.smiles-row .text-button, .share-row .text-button { flex: none; margin-right: -6px; }
.share-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Legend */
.legend { position: absolute; left: 16px; bottom: 16px; width: 248px; padding: 12px 14px; z-index: 5; font-size: 12px; }
.legend-top { display: flex; align-items: center; justify-content: space-between; min-height: 24px; }
.legend-top strong { font-weight: 600; font-size: 13px; }
.legend-top .text-button { margin-right: -6px; }
.legend-body { margin: 8px 0; }
.legend-foot { display: flex; justify-content: space-between; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.swatches { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--ink-2); }
.swatch { display: inline-flex; align-items: center; gap: 6px; }
.swatch::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--swatch); }
.colorbar { height: 8px; border-radius: 4px; background: linear-gradient(90deg, #440154, #482878, #31688e, #21918c, #35b779, #90d743, #fde725); }
.colorbar.property { background: linear-gradient(90deg, #0d0887, #5302a3, #8b0aa5, #b83289, #db5c68, #f48849, #febc2a, #f0f921); }
.color-by { margin-bottom: 10px; }
.scale { display: flex; justify-content: space-between; margin-top: 4px; color: var(--ink-3); font-size: 11px; }
.display-panel { display: grid; gap: 12px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.display-panel .text-button { justify-self: start; margin-left: -8px; }
.control { display: grid; gap: 4px; }
.control-label { display: flex; justify-content: space-between; color: var(--ink-2); }
.control output { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.control input[type=range] { width: 100%; height: 16px; margin: 0; accent-color: var(--ink); }
.control select { width: 100%; padding: 5px 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; }

/* Toolbar */
.toolbar-stack { position: absolute; right: 16px; bottom: 16px; z-index: 5; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; }
.toolbar-stack > * { pointer-events: auto; }
.toolbar { display: flex; padding: 4px; gap: 2px; }
.minimap { position: absolute; right: 0; bottom: calc(100% + 10px); width: 168px; height: 168px; border-radius: 10px; overflow: hidden; background: #440154; box-shadow: var(--shadow); visibility: hidden; opacity: 0; transition: opacity .2s; }
.minimap.visible { visibility: visible; opacity: 1; }
.status {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 7; max-width: min(420px, 80%);
  padding: 10px 16px; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); color: var(--ink-2); font-size: 13px; text-align: center;
}

/* About */
.sheet {
  position: fixed; inset: 0 0 0 auto; margin: 0; height: 100dvh; max-height: none; width: 460px; max-width: 100vw; padding: 28px;
  border: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); overflow: auto; font-size: 13.5px; line-height: 1.55;
}
.sheet::backdrop { background: rgb(15 17 21 / .25); }
.sheet[open] { animation: slide-in .2s cubic-bezier(.2, .7, .2, 1); }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
.sheet-close { position: absolute; top: 18px; right: 18px; }
.about-brand { --logo-size: 26px; display: flex; align-items: center; height: 46px; margin-bottom: 10px; }
.sheet h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; font-weight: 600; }
.sheet h3 { margin: 22px 0 4px; font-size: 13.5px; font-weight: 600; }
.sheet p { margin: 4px 0 10px; color: var(--ink-2); }
.sheet p.muted { color: var(--ink-3); }
.citation { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.citation h3 { margin: 0 0 4px; font-size: 13.5px; font-weight: 600; }
.citation p { margin: 0 0 8px; color: var(--ink-2); font-size: 13.5px; }
.citation .text-button { margin-left: -8px; }
.landing-citation { margin-top: 48px; max-width: 720px; }
.recall { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.recall th { text-align: left; font-weight: 500; color: var(--ink-3); }
.recall th, .recall td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }

@media (max-width: 1100px) {
  .space-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .label-long { display: none; }
  .label-short { display: inline; }
}
@media (max-width: 800px) {
  .space-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 16px; }
  .landing-bar, .landing-main { padding-left: 16px; padding-right: 16px; }
  .landing-main { padding-top: 8px; }
  .topbar { height: auto; flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px 10px; }
  .picker { order: 2; flex-basis: 100%; }
  .picker-button { width: 100%; }
  .picker-name { margin-right: auto; }
  .topbar .brand { order: 1; }
  #about-open { order: 1; margin-left: auto; }
  .topbar .segmented { order: 3; margin: 0; flex-basis: 100%; }
  .topbar .segmented > a { flex: 1; text-align: center; }
  .inspector { top: 10px; right: 10px; width: calc(100% - 20px); max-width: none; padding: 10px 12px; }
  .inspector.empty { width: auto; }
  .mol-drawing { aspect-ratio: 16 / 7; }
  .legend { left: 10px; bottom: 10px; width: 224px; }
  .toolbar-stack { right: 10px; bottom: 10px; }
  .toolbar { flex-direction: column; }
  .minimap { display: none; }
}
@media (max-width: 480px) {
  .space-grid { grid-template-columns: 1fr; }
  .sheet { padding: 22px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
