:root {
  --bg: #070b12;
  --panel: #0d1420;
  --text: #dfe7f1;
  --muted: #8a97a8;
  --line: #243044;
  --accent: #19c3ff;
  --warn: #ff4d4d;
  --c-medical: #ff8a1f;
  --c-cleaning: #3b82f6;
  --c-toxins: #5fd35f;
  --c-drugs: #b266ff;
  --c-pyro: #ff4d4d;
  --c-chemicals: #19c3ff;
  --c-botany: #9be34a;
  --c-food: #ffd24d;
  --c-drinks: #ff6fb1;
  --c-viro: #c9a7ff;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 "Segoe UI", system-ui, sans-serif;
}
.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: #0a111c;
}
.brand h1 { margin: 0; font-size: 1.5rem; letter-spacing: .04em; font-style: italic; }
.brand h1 span { color: var(--warn); }
.brand p { margin: 2px 0 0; color: var(--accent); font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; }
.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 14px; cursor: pointer; font: inherit;
}
.tab.active { color: var(--text); border-color: var(--accent); box-shadow: 0 0 10px rgba(25,195,255,.25); }
main { max-width: 1280px; margin: 0 auto; padding: 14px 16px 30px; }
.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#q {
  flex: 1 1 280px; min-width: 0; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit;
}
#q:focus, select:focus, .tab:focus-visible, .chip:focus-visible, .star:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.scale select { margin-left: 6px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.fav-only { color: var(--muted); display: flex; gap: 6px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.chip {
  --c: var(--accent);
  background: transparent; color: var(--text); border: 1px solid var(--c); border-radius: 999px;
  padding: 4px 12px; cursor: pointer; font: inherit; font-size: .85rem;
}
.chip.on { background: var(--c); color: #04070c; font-weight: 600; }
.count { color: var(--muted); margin: 8px 0; font-size: .85rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.card {
  --c: var(--accent);
  background: var(--panel); border: 1px solid var(--c); border-radius: 8px; padding: 10px 12px;
  box-shadow: inset 0 0 18px rgba(0,0,0,.35), 0 0 8px color-mix(in srgb, var(--c) 25%, transparent);
  display: grid; grid-template-columns: 74px 1fr; gap: 4px 12px;
}
.card h2 { grid-column: 1 / -1; margin: 0; font-size: 1rem; letter-spacing: .05em; text-transform: uppercase; color: var(--c); display: flex; justify-content: space-between; gap: 8px; }
.card.guide { border-style: dashed; }
.meta .badge { color: #ffd24d; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
.star { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 0 4px; line-height: 1; }
.star.on { color: #ffd24d; }
.beaker { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .75rem; color: var(--muted); }
.beaker svg { width: 56px; height: 82px; }
.ing { list-style: none; margin: 0; padding: 0; }
.ing li { display: flex; gap: 8px; align-items: baseline; }
.ing .u { min-width: 3.2em; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ing .tag { color: var(--muted); font-size: .8rem; }
.meta { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 6px; margin-top: 4px; font-size: .85rem; display: grid; gap: 3px; }
.meta .total { color: var(--c); letter-spacing: .02em; }
.meta .effect { color: var(--text); }
.meta .od { color: var(--warn); }
.meta .direct, .meta .temp { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }
.dispenser { margin-top: 26px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--panel); }
.dispenser h2 { margin: 0 0 8px; font-size: .95rem; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.disp-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.disp-list span { border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; text-align: center; font-size: .85rem; }
.basics { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.box { --c: var(--accent); background: var(--panel); border: 1px solid var(--c); border-radius: 8px; padding: 12px 14px; }
.box h2 { margin: 0 0 8px; font-size: .95rem; letter-spacing: .06em; text-transform: uppercase; color: var(--c); }
.box ul, .box ol { margin: 0; padding-left: 1.2em; }
.box li { margin: 3px 0; }
.box p { margin: 4px 0; }
.box.warn { --c: var(--warn); }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
[hidden] { display: none !important; }
@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .card { transition: transform .12s; }
  .card:hover { transform: translateY(-2px); }
}

/* ---------- detaljpanel ---------- */
.card h2 .card-actions { display: flex; align-items: center; gap: 4px; }
.card { cursor: pointer; }
.more {
  background: transparent; color: var(--c); border: 1px solid var(--c); border-radius: 999px; padding: 1px 9px;
  font: inherit; font-size: .72rem; letter-spacing: .03em; text-transform: none; cursor: pointer;
}
.more:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
dialog.detail {
  width: min(920px, 94vw); max-height: 90vh; padding: 0; border: 1px solid var(--accent); border-radius: 10px;
  background: var(--panel); color: var(--text); overflow: hidden;
}
dialog.detail[open] { display: flex; flex-direction: column; }
dialog.detail::backdrop { background: rgba(2, 5, 10, .72); }
.detail-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #c9d1d9; flex: none; }
.detail-titles { flex: 1; min-width: 0; }
.detail-titles h2 { margin: 0; font-size: 1.15rem; letter-spacing: .04em; text-transform: uppercase; }
.detail-sub { margin: 2px 0 0; color: var(--muted); font-size: .8rem; }
.detail-close { background: none; border: 0; color: var(--text); font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 6px; }
.detail-close:focus-visible, .detail-tabs button:focus-visible, .node:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.detail-tabs { display: flex; gap: 4px; padding: 8px 14px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.detail-tabs button {
  background: transparent; color: var(--muted); border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0;
  padding: 7px 14px; cursor: pointer; font: inherit; white-space: nowrap;
}
.detail-tabs button[aria-selected=true] { color: var(--text); border-color: var(--line); background: var(--bg); }
.detail-body { padding: 14px; overflow-y: auto; }
.pane h3 { margin: 16px 0 6px; font-size: .9rem; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.lead { margin: 0 0 8px; }
.banner { background: rgba(255, 210, 77, .1); border: 1px dashed #ffd24d; border-radius: 6px; padding: 8px 10px; color: #ffd24d; }
.facts { margin: 6px 0; padding-left: 1.2em; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.fx-list { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 4px; }
.fx { display: grid; grid-template-columns: 4.6em 1fr auto; gap: 8px; align-items: baseline; padding: 5px 8px; border-radius: 6px; border-left: 3px solid var(--line); background: rgba(255,255,255,.03); }
.fx-kind { font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.fx-when { color: var(--muted); font-size: .78rem; text-align: right; }
.fx-when.od { color: var(--warn); }
.fx-heal { border-left-color: #5fd35f; }
.fx-harm { border-left-color: var(--warn); }
.fx-status { border-left-color: #3b82f6; }
.fx-info { border-left-color: #8a97a8; }
div.fx-heal, div.fx-harm, div.fx-status, div.fx-info { padding-left: 6px; font-size: .85rem; }
.lore { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.lore h3 { margin-top: 0; }
.lore p { margin: 4px 0; }
.dose-label { display: block; margin-bottom: 4px; }
.dose-out { font-weight: 700; color: var(--accent); }
.dose-slider { width: 100%; }
.dose-track { position: relative; height: 26px; margin: 2px 0 10px; border-radius: 6px; background: rgba(255,255,255,.05); }
.dose-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 6px; background: linear-gradient(90deg, #5fd35f55, #ffd24d55); }
.dose-mark { position: absolute; top: 0; bottom: 0; border-left: 2px solid var(--muted); padding-left: 3px; font-size: .7rem; color: var(--muted); line-height: 26px; }
.dose-mark.od { border-left-color: var(--warn); color: var(--warn); }
.dose-summary { margin: 4px 0 8px; font-weight: 600; }
.dose-summary.over { color: var(--warn); }
.dose-list .fx.off { opacity: .4; }
.dose-list .fx.on { background: rgba(255,255,255,.09); }
.graph { width: 100%; height: auto; background: rgba(255,255,255,.02); border-radius: 8px; }
.graph .node rect { fill: var(--bg); stroke: var(--line); stroke-width: 1.5; }
.graph .node.chem { cursor: pointer; }
.graph .node.base rect { fill: rgba(255,255,255,.04); stroke: #556277; }
.graph .node.center rect { fill: #0f2236; stroke-width: 2.5; }
.graph text { fill: var(--text); font-size: 12px; pointer-events: none; }
.graph .edge { fill: none; stroke: #556277; stroke-width: 1.4; }
.graph .edge-label { fill: var(--muted); font-size: 10px; }
.sources a { color: var(--accent); }
.preview {
  position: fixed; z-index: 50; max-width: 300px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--accent);
  border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.5); font-size: .85rem; display: grid; gap: 2px; pointer-events: none;
}
@media (max-width: 560px) {
  dialog.detail { width: 100vw; max-height: 96vh; border-radius: 10px 10px 0 0; }
  .fx { grid-template-columns: 1fr; }
  .fx-when { text-align: left; }
}

/* smal skärm: kortrubriken (namn + knappar) ska radbrytas i stället för att trycka ut kortet */
.card { min-width: 0; }
.card h2 { flex-wrap: wrap; }
.card h2 > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.card-actions { flex: none; margin-left: auto; }

/* Tidslinje */
.timeline .axis { stroke: #556277; stroke-width: 1; }
.timeline .tl-curve { fill: none; stroke: var(--text); stroke-width: 2; }
.timeline .tl-axis, .timeline .tl-label { fill: var(--muted); font-size: 11px; }
.timeline .tl-od { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 4 3; }
.timeline .tl-od-text { fill: var(--warn); font-size: 11px; }
.timeline .tl-bar { fill: #556277; }
.timeline .tl-bar.fx-heal { fill: #5fd35f; }
.timeline .tl-bar.fx-harm { fill: var(--warn); }
.timeline .tl-bar.fx-status { fill: #3b82f6; }

/* Tier */
.chips.tiers { margin-top: .4rem; }
.tier-help { color: var(--muted); font-size: .8rem; margin: .3rem 0 .6rem; }
.tier { font-size: .65rem; font-weight: 700; border: 1px solid var(--c-medical); color: var(--c-medical); border-radius: 999px; padding: 0 .4rem; margin-left: .4rem; vertical-align: middle; }
