:root {
  --bg: #14181d;
  --bg-2: #1b2027;
  --panel: rgba(24, 29, 36, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #e9edf1;
  --muted: #9aa5b1;
  --accent: #4fd1c5;
  --accent-ink: #0d2a28;
  --bone: #e8dcc4;
  --muscle: #c4554a;
  --nerve: #f2c230;
  --origin: #e5484d;
  --insertion: #3d7be0;
  --good: #46c37b;
  --bad: #e5604d;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; }
#scene {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none;
  background: radial-gradient(ellipse at 50% 35%, #232a33 0%, #14181d 70%);
}

/* ---------- Seitenleiste ---------- */
.panel {
  position: absolute; top: 12px; left: 12px; bottom: 12px; width: 320px;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 16px; padding: 14px 14px 10px;
  overflow-y: auto; z-index: 10; scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 2px 10px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: 0.2px; }
.brand .sub { margin: 0; color: var(--muted); font-size: 12px; }
.logo {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background:
    radial-gradient(circle at 50% 28%, var(--bone) 0 18%, transparent 19%),
    linear-gradient(var(--nerve), var(--nerve)) 50% 60% / 2px 52% no-repeat,
    linear-gradient(var(--bone), var(--bone)) 50% 62% / 26% 40% no-repeat,
    var(--bg-2);
  border: 1px solid var(--line-2);
}
.logo.big { width: 54px; height: 54px; border-radius: 14px; margin: 0 auto 8px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; background: var(--bg-2); border-radius: 10px; margin-bottom: 6px; }
.tab { border: 0; background: transparent; padding: 7px 0; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--accent); color: var(--accent-ink); }

.block { padding: 10px 2px; border-top: 1px solid var(--line); }
.block h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 0 0 8px; font-weight: 600; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Suche */
.search { position: relative; }
.search input {
  width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg-2); outline: none;
}
.search input:focus { border-color: var(--accent); }
.results {
  list-style: none; margin: 6px 0 0; padding: 4px; max-height: 280px; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px;
}
.results li { padding: 7px 8px; border-radius: 7px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.results li:hover, .results li.active { background: rgba(79, 209, 197, 0.12); }
.results .la { font-weight: 600; }
.results .de { color: var(--muted); font-size: 12px; }
.results .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.results .empty { color: var(--muted); cursor: default; }

/* Schichten */
.layer { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; background: rgba(255,255,255,0.02); }
.layer-head { display: flex; align-items: center; gap: 10px; }
.layer-head .swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.layer-head label { font-weight: 600; flex: 1; cursor: pointer; }
.layer.off .layer-body { display: none; }
.layer-body { margin-top: 8px; display: grid; gap: 6px; }
.cats { display: flex; flex-wrap: wrap; gap: 5px; }
.cat {
  border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: 3px 9px;
  font-size: 12px; cursor: pointer; color: var(--muted);
}
.cat.on { color: var(--text); background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.25); }
.opacity { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.opacity input { flex: 1; accent-color: var(--accent); }

/* Schalter */
.switch { position: relative; width: 34px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #3a434e; border-radius: 999px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Regionen */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: 5px 11px; cursor: pointer; font-size: 13px;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.side-row { margin-top: 10px; justify-content: space-between; }
.seg { display: inline-flex; background: var(--bg-2); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 7px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button.on { background: rgba(255,255,255,0.12); color: var(--text); }

.btn {
  border: 1px solid var(--line-2); background: var(--bg-2); padding: 7px 12px; border-radius: 9px; cursor: pointer; font-weight: 500;
}
.btn:hover { border-color: rgba(255,255,255,0.3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.ghost { background: transparent; font-size: 13px; padding: 6px 10px; }
.btn.small { padding: 5px 9px; font-size: 12px; }
.icon-btn { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 16px; padding: 4px 6px; border-radius: 8px; }
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.credits { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); line-height: 1.5; }

/* ---------- Info-Karte ---------- */
.info, .quiz {
  position: absolute; top: 12px; right: 12px; width: 360px; max-height: calc(100% - 24px); overflow-y: auto;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 16px; padding: 16px; z-index: 10; scrollbar-width: thin;
}
.info .close { position: absolute; top: 10px; right: 10px; }
.info .kicker { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; padding-right: 28px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,0.08); color: var(--muted); }
.tag.layer-bones { color: #1d1a12; background: var(--bone); }
.tag.layer-muscles { color: #fff; background: var(--muscle); }
.tag.layer-nerves { color: #2a2205; background: var(--nerve); }
.tag.layer-joints { color: #06222e; background: #6fb3d2; }
.info h3 { margin: 0; font-size: 20px; line-height: 1.25; font-style: italic; }
.info .de-name { font-size: 15px; margin: 4px 0 0; }
.info .en-name { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.info .group { margin-top: 10px; font-size: 13px; color: var(--muted); }
.info .group button { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; text-align: left; }
.card { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.card h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
dl.facts { margin: 0; display: grid; gap: 8px; }
dl.facts dt { font-size: 12px; color: var(--accent); font-weight: 600; }
dl.facts dd { margin: 1px 0 0; }
.merke { background: rgba(242, 194, 48, 0.1); border-left: 3px solid var(--nerve); padding: 8px 10px; border-radius: 6px; margin-top: 10px; }
.attach-legend { display: flex; gap: 14px; font-size: 12px; margin: 8px 0 4px; }
.attach-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.linklist { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 3px; }
.linklist li { font-size: 13px; }
.linklist button { border: 0; background: none; padding: 0; color: var(--text); cursor: pointer; text-align: left; font: inherit; }
.linklist button:hover { color: var(--accent); }
.linklist .de { color: var(--muted); font-size: 12px; }
details.desc summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.desc p { color: #c9d1d9; font-size: 13px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- Quiz ---------- */
.quiz h3 { margin: 0 0 4px; font-size: 17px; }
.quiz .score { display: flex; gap: 14px; margin: 6px 0 12px; font-size: 13px; color: var(--muted); }
.quiz .score b { color: var(--text); }
.quiz .q { font-size: 15px; margin: 6px 0 12px; }
.quiz .target { font-size: 18px; }
.quiz .target .la { display: block; font-style: italic; font-weight: 600; }
.quiz .target .de { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; }
.quiz .options { display: grid; gap: 8px; }
.quiz .opt {
  text-align: left; border: 1px solid var(--line-2); background: var(--bg-2); border-radius: 10px; padding: 9px 12px; cursor: pointer;
}
.quiz .opt:hover:not(:disabled) { border-color: var(--accent); }
.quiz .opt .la { font-style: italic; font-weight: 600; display: block; }
.quiz .opt .de { color: var(--muted); font-size: 12px; }
.quiz .opt.right { border-color: var(--good); background: rgba(70, 195, 123, 0.15); }
.quiz .opt.wrong { border-color: var(--bad); background: rgba(229, 96, 77, 0.15); }
.quiz .feedback { margin-top: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.quiz .feedback.good { background: rgba(70, 195, 123, 0.15); }
.quiz .feedback.bad { background: rgba(229, 96, 77, 0.15); }
.quiz .settings { display: grid; gap: 10px; margin: 10px 0 14px; }
.quiz .settings .row { justify-content: space-between; }
.quiz .pool { font-size: 12px; color: var(--muted); }

/* ---------- Sonstiges ---------- */
.tooltip {
  position: absolute; pointer-events: none; z-index: 20; padding: 5px 9px; border-radius: 8px;
  background: rgba(10, 12, 15, 0.9); border: 1px solid var(--line-2); font-size: 12px; white-space: nowrap; transform: translate(12px, 12px);
}
.tooltip i { font-weight: 600; }
.tooltip span { color: var(--muted); }
.toast {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  background: rgba(10, 12, 15, 0.92); border: 1px solid var(--line-2); padding: 8px 14px; border-radius: 10px; font-size: 13px;
}
.loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 50; background: var(--bg); transition: opacity .4s; }
.loading.done { opacity: 0; pointer-events: none; }
.loading-card { text-align: center; width: min(320px, 80vw); }
.bar { height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.bar div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.fab {
  position: absolute; left: 12px; top: 12px; z-index: 9; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--panel); font-size: 20px; cursor: pointer;
}
.only-mobile { display: none; }

@media (max-width: 820px) {
  .only-mobile { display: inline-block; }
  .brand .icon-btn { margin-left: auto; }
  .panel { top: 0; left: 0; bottom: 0; width: min(340px, 88vw); border-radius: 0 16px 16px 0; transform: translateX(-105%); transition: transform .2s; }
  .panel.open { transform: none; }
  .info, .quiz {
    top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 45vh; border-radius: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .tooltip { display: none; }
}
