/* Simulation Library hub — shares the Masterclass engine palette (engine/core/mc.css):
   black brand chrome, pale "lab" page, subject colours. Single light theme, like the sims. */
:root {
  --black: #050705;
  --ink: #101611;
  --ink-2: #3E4A40;
  --ink-3: #5F6B62;
  --page: #E9EEE7;
  --panel: #FFFFFF;
  --line: #D3DBD1;
  --line-soft: #E4EAE2;
  --accent: #17D006;
  --accent-ink: #0B6F02;
  --accent-soft: #E3F7DF;
  --brand: #5EE95C;
  --warn: #9A5200;
  --warn-soft: #FDF0DE;
  --physics: #2F7DF6;
  --chemistry: #E8662A;
  --biology: #1FA37A;
  --mathematics: #8B5CF6;
  --earth: #0E9AA7;
  --body: #C42A63;
  --astronomy: #3B4BB8;
  --radius: 12px;
  --font: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --math: 'Cambria Math', 'STIX Two Math', 'Times New Roman', serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page); color: var(--ink);
  font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ── header ─────────────────────────────────────────────── */
.top { background: var(--black); color: #fff; }
.top-inner {
  max-width: 1280px; margin: 0 auto; padding: 14px 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.logo { height: 40px; width: auto; display: block; }
.top h1 { margin: 0; font-size: 21px; font-weight: 800; line-height: 1.2; }
.top p { margin: 2px 0 0; font-size: 13px; color: #B9C6BB; }
.top-titles { flex: 1 1 260px; min-width: 0; }

/* ── toolbar ────────────────────────────────────────────── */
.toolbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--page) 94%, transparent);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.toolbar-inner { max-width: 1280px; margin: 0 auto; padding: 12px 16px; display: grid; gap: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search {
  flex: 1 1 280px; min-width: 0; height: 42px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
.select {
  height: 42px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
@media (min-width: 900px) { .chips { flex-wrap: wrap; overflow: visible; } }
.chip {
  flex: none; height: 34px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); font-weight: 700; font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 7px;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--ink-3)); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .n { font-weight: 600; opacity: .7; font-size: 12px; }

/* ── results ───────────────────────────────────────────── */
main { max-width: 1280px; margin: 0 auto; padding: 16px 16px 48px; }
.status { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--ink-3); font-size: 13.5px; margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 12px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 12px; border-top: 4px solid var(--c, var(--ink-3));
}
.card:hover { border-color: #b9c4b7; border-top-color: var(--c); }
.card h2 { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.25; }
.card h2 button {
  all: unset; cursor: pointer; text-wrap: balance;
}
.card h2 button::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.card h2 button:focus-visible::after { outline: 3px solid var(--accent); outline-offset: 2px; }
.meta { font-size: 12.5px; color: var(--ink-3); }
.desc { margin: 0; font-size: 13.5px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.badges { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; }
.badge { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--line-soft); color: var(--ink-2); }
.badge.ok { background: var(--accent-soft); color: var(--accent-ink); }
.badge.net { background: var(--warn-soft); color: var(--warn); }
.card-actions { display: flex; gap: 8px; position: relative; z-index: 1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 9px; font-weight: 800; font-size: 13.5px;
  text-decoration: none; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #000; }
.empty { padding: 48px 16px; text-align: center; color: var(--ink-3); }

/* ── detail dialog ─────────────────────────────────────── */
dialog.detail {
  width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 0; border-radius: 16px; background: var(--panel); color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}
dialog.detail::backdrop { background: rgba(5, 7, 5, .55); }
.d-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--line-soft); border-top: 5px solid var(--c, var(--ink-3)); position: sticky; top: 0; background: var(--panel); }
.d-head h2 { margin: 0 40px 4px 0; font-size: 21px; font-weight: 800; line-height: 1.2; }
.d-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 18px; line-height: 1; }
.d-body { padding: 16px 20px 8px; display: grid; gap: 14px; }
.d-body h3 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.d-body ul { margin: 0; padding-left: 18px; }
.d-body li + li { margin-top: 3px; }
.d-body p { margin: 0; }
.eq { font-family: var(--math); font-size: 16px; }
.note { background: var(--warn-soft); color: #5c3200; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.licence { background: var(--line-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--ink-2); }
.related { display: flex; gap: 6px; flex-wrap: wrap; }
.related button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.d-foot { padding: 14px 20px 18px; display: flex; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line-soft); }

footer { max-width: 1280px; margin: 0 auto; padding: 0 16px 32px; font-size: 12.5px; color: var(--ink-3); }

@media (max-width: 600px) {
  .top h1 { font-size: 18px; }
  .logo { height: 32px; }
  .select { flex: 1 1 140px; }
}
@media (prefers-reduced-motion: no-preference) {
  .card { transition: border-color .15s; }
}
