:root {
  --bg: #0b0d12;
  --bg2: #10131a;
  --panel: #151922;
  --panel2: #1b202b;
  --line: #252b38;
  --text: #e8eaf0;
  --muted: #8b93a7;
  --accent: #f0a23b;
  --accent2: #ff7a45;
  --ok: #4cc38a;
  --bad: #e5484d;
  --run: #4c8dff;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif; }
h2 { margin: 0; font-size: 18px; }
h3 { margin: 10px 0 2px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Bedienelemente */
button, select, input { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; outline: none; transition: border-color 0.15s, background 0.15s; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(240 162 59 / 0.15); }
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #1a1205; border: 0; font-weight: 650; width: 100%; padding: 10px; margin-top: 6px; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--line); }
button:disabled, select:disabled { opacity: 0.4; cursor: default; }
button.on { border-color: var(--accent); color: var(--accent); }
label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 12px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; }

/* Marke */
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.brand b { color: var(--accent); }
.brand.big { font-size: 26px; justify-content: center; }
.logo { width: 26px; height: 26px; border-radius: 8px; background: conic-gradient(from 200deg, var(--accent), var(--accent2), #b84cff, var(--run), var(--accent)); box-shadow: 0 0 18px rgb(240 162 59 / 0.35); position: relative; }
.logo::after { content: ''; position: absolute; inset: 7px; border-radius: 3px; background: var(--bg); transform: rotate(45deg); }
.brand.big .logo { width: 36px; height: 36px; border-radius: 10px; }
.brand.big .logo::after { inset: 10px; }
.logo.xl { width: 64px; height: 64px; border-radius: 18px; opacity: 0.8; }
.logo.xl::after { inset: 18px; border-radius: 6px; }

/* Sperrseite: Laden und Anmelden */
.gate { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 20% -10%, rgb(240 162 59 / 0.12), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgb(76 141 255 / 0.12), transparent 60%), var(--bg); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
#login-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; padding: 32px 28px; box-shadow: 0 30px 80px rgb(0 0 0 / 0.45); }
#login-form > p.muted { text-align: center; margin: -4px 0 6px; }
#login-form input { width: 100%; padding: 10px 12px; }
.pw { position: relative; display: block; }
.pw input { padding-right: 44px; }
.pw button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); padding: 4px 8px; }
.msg { margin: 0; min-height: 1.4em; color: var(--bad); text-align: center; font-size: 13px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Werkstatt */
#shell { height: 100%; display: flex; flex-direction: column; }
#top { display: flex; gap: 18px; align-items: center; padding: 10px 16px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.chip { font-size: 12px; color: var(--muted); background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
main { flex: 1; display: grid; grid-template-columns: 210px 300px 1fr 340px; grid-template-rows: minmax(0, 1fr); min-height: 0; }
.panel { min-width: 0; padding: 14px; overflow: auto; background: var(--bg2); display: flex; flex-direction: column; gap: 8px; }
#left { border-right: 1px solid var(--line); }
#right { border-left: 1px solid var(--line); }
.count { background: var(--panel2); border-radius: 999px; padding: 0 7px; font-size: 10px; color: var(--text); }
.list { list-style: none; margin: 0; padding: 0; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.list li { padding: 7px 9px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; border: 1px solid transparent; }
.list li.muted { cursor: default; }
.list li:not(.muted):hover { background: var(--panel); }
.list li.sel { background: var(--panel2); border-color: rgb(240 162 59 / 0.5); }
.list li .tag { color: var(--muted); font-size: 11px; white-space: nowrap; }
/* Navigation wie die Seitenleiste der Forge */
#nav { padding: 8px 0; gap: 0; border-right: 1px solid var(--line); }
.nav-head { padding: 12px 14px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em; color: #5d6578; }
.nav-row { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 0; padding: 6px 14px; font-size: 13px; color: var(--muted); }
.nav-row.d1 { padding-left: 28px; }
.nav-row:hover:not(:disabled) { color: var(--text); border-color: transparent; background: var(--panel); }
.nav-row.on { background: rgb(240 162 59 / 0.1); color: #f6c27a; }
.nav-row.zero { color: #5d6578; }
.nav-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-row .n { font-size: 10px; color: #5d6578; }
#nav-select { display: none; width: 100%; }

/* Objekte als Karten wie im Katalog der Forge */
.toolbar { display: flex; gap: 6px; }
.toolbar input { flex: 1; min-width: 0; }
.toolbar select { width: auto; max-width: 42%; }
#obj-count { margin: 2px 2px 0; }
.hint-box { margin: 0; padding: 8px 10px; border: 1px solid rgb(240 162 59 / 0.35); background: rgb(240 162 59 / 0.08); color: #f6c27a; border-radius: 8px; }
/* links: nur die Objektliste scrollt (füllt den Platz), Aufträge darunter einklappbar mit eigener Höhe */
#left { overflow: hidden; }
#left > * { flex-shrink: 0; }
#left > #objects { flex: 1 1 auto; min-height: 140px; }
#objects { display: flex; flex-direction: column; gap: 6px; overflow: auto; padding-right: 2px; }
#jobs-box > summary { cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); padding: 6px 0; }
#jobs-box #jobs { max-height: 26vh; overflow: auto; margin-top: 6px; }
#nav-toggle { flex: 0 0 auto; padding: 4px 9px; }
body.nav-closed main { grid-template-columns: 300px 1fr 340px; }
body.nav-closed #nav { display: none; }
body.nav-closed #nav-select { display: block; }
#objects > * { flex-shrink: 0; }
#objects > p { margin: 6px 2px; }
.card.obj { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); }
.card.obj:hover:not(:disabled) { border-color: rgb(240 162 59 / 0.6); }
.card.obj.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.card.obj .top { display: flex; align-items: flex-start; gap: 9px; }
.card.obj .kind { flex: 0 0 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--accent); background: rgb(240 162 59 / 0.12); }
.card.obj .kind.k-hostile { color: #ff8a7a; background: rgb(229 72 77 / 0.14); }
.card.obj .kind.k-character { color: #8fb8ff; background: rgb(76 141 255 / 0.14); }
.card.obj .kind.k-weapon, .card.obj .kind.k-attachment { color: #d0a6ff; background: rgb(184 76 255 / 0.14); }
.card.obj .txt { flex: 1; min-width: 0; }
.card.obj .name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.obj .sub { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st { flex-shrink: 0; font-size: 10px; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; color: var(--muted); }
.st-concept { color: #7dd3fc; border-color: #0c4a6e; }
.st-modeled { color: #c4b5fd; border-color: #4c1d95; }
.st-remeshed, .st-rigged { color: #fcd34d; border-color: #78350f; }
.st-animated { color: #bef264; border-color: #365314; }
.st-approved { color: #6ee7b7; border-color: #065f46; }
.st-rejected { color: #f87171; border-color: #7f1d1d; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; padding-left: 35px; }
.b { font-size: 10px; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; color: var(--muted); }
.b.mute { color: #5d6578; }
.b.sky { color: #7dd3fc; border-color: #0c4a6e; }
.b.amber { color: #f6c27a; border-color: rgb(240 162 59 / 0.4); }
.upload { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; }
.upload summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.upload input { width: 100%; margin-top: 8px; }

#stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
#viewer { flex: 1; min-height: 0; position: relative; }
#viewer canvas { display: block; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; pointer-events: none; }
.empty p { margin: 0; }
.empty .logo { margin-bottom: 14px; }
#viewer-bar, #clips { display: flex; gap: 6px; padding: 8px 12px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); background: var(--bg2); flex-shrink: 0; }
#clips { max-height: 112px; overflow: auto; }
#clips button { font-size: 12px; padding: 4px 10px; border-radius: 999px; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; border-left: 0; }

#obj-meta { margin: 0; }
#steps { display: flex; flex-direction: column; gap: 8px; }
.empty-steps { margin: 0; padding: 12px; text-align: center; border: 1px dashed var(--line); border-radius: 8px; }
.step { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.step header { display: flex; align-items: center; }
.step header button { padding: 2px 8px; }
.step .hint { color: var(--muted); font-size: 12px; }
.step .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.step .grid > label { min-width: 0; }
.step input, .step select { width: 100%; min-width: 0; padding: 5px 8px; }
.step input[type='checkbox'] { width: auto; align-self: flex-start; }
.row { display: flex; gap: 6px; }
.row select { flex: 1; min-width: 0; }
.row button { white-space: nowrap; }
.card.inset { padding: 12px; margin-top: 6px; border-radius: var(--radius); }
.card.inset h3 { margin-top: 0; }
pre { background: #07090d; border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 30vh; overflow: auto; white-space: pre-wrap; font-size: 11px; margin: 6px 0 0; }
.badge { font-size: 10px; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--text); letter-spacing: 0.04em; }
.badge.queued, .badge.preparing, .badge.running { background: var(--run); color: #fff; }
.badge.succeeded { background: var(--ok); color: #04130b; }
.badge.failed { background: var(--bad); color: #fff; }

@media (max-width: 1300px) {
  main { grid-template-columns: 300px 1fr 340px; }
  #nav { display: none; }
  #nav-select { display: block; }
}
@media (max-width: 1000px) {
  main { grid-template-columns: 1fr; }
  #viewer { min-height: 50vh; }
  #left, #right { border: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 560px) {
  #top { flex-wrap: wrap; gap: 10px; }
  #who { display: none; }
}

/* Bewegungsbibliothek */
dialog#lib { width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
dialog#lib::backdrop { background: rgb(0 0 0 / 0.6); }
.lib-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.lib-head h2 { margin: 0 10px 0 0; font-size: 16px; }
.lib-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 12px 16px 16px; }
.lib-grid section { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.lib-grid textarea { width: 100%; box-sizing: border-box; font: 12px/1.4 ui-monospace, monospace; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.lib-list { display: flex; flex-direction: column; gap: 4px; max-height: 46vh; overflow: auto; }
.lib-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; }
.lib-row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-row .a { font-size: 11px; color: var(--accent); }
.lib-row input.act { width: 90px; padding: 3px 6px; font-size: 12px; }
.lib-row button { padding: 3px 9px; font-size: 12px; }
.lib-pick { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow: auto; }
.lib-pick label { flex-direction: row; align-items: center; gap: 6px; }
@media (max-width: 760px) { .lib-grid { grid-template-columns: 1fr; } }
.lib-grid details ol { margin: 4px 0 8px; padding-left: 20px; }
.lib-grid details li { margin: 3px 0; }
.lib-grid details a { color: var(--accent); }
kbd { font: 11px ui-monospace, monospace; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel2); }

/* Bibliothek: Reiter, Katalog, Grundpakete, Wunschliste */
dialog#lib { height: min(860px, calc(100vh - 32px)); display: flex; flex-direction: column; }
dialog#lib:not([open]) { display: none; }
.lib-tabs { display: flex; gap: 4px; padding: 10px 16px 0; flex-wrap: wrap; }
.lib-tabs button.on { border-color: var(--accent); color: var(--accent); }
.lib-tabs .badge:empty { display: none; }
.lib-token { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 16px 0; }
.lib-token label.inline { flex: 1; min-width: 260px; }
.lib-token label.inline input { flex: 1; }
.lib-token details { flex-basis: 100%; }
.lib-task { padding: 6px 16px 0; min-height: 1em; }
.lib-task:empty { display: none; }
.lib-pane { flex: 1; min-height: 0; overflow: auto; padding: 10px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.lib-pane[hidden] { display: none; }
.lib-pane .lib-grid { padding: 0; }
.cat-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cat-bar input[type='search'] { flex: 1; min-width: 180px; }
.cat-grid { display: grid; grid-template-columns: 220px 1fr; gap: 12px; min-height: 0; flex: 1; }
.cat-nav { display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.cat-rows { max-height: none; }
.cat-row { cursor: pointer; flex-direction: row; color: var(--text); font-size: 13px; }
.cat-row img, .cat-row .thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--bg2); flex: none; }
.cat-row.gone { opacity: 0.55; }
.cat-row .t { white-space: normal; }
.cat-foot { display: flex; align-items: center; gap: 8px; padding-top: 8px; position: sticky; bottom: 0; background: var(--panel); }
.b.ok { color: var(--ok); border-color: var(--ok); }
.bad { color: var(--bad); }
.figs { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 10px; }
.fig { display: flex; flex-direction: column; gap: 6px; padding: 8px; }
.fig img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #111; border-radius: 6px; }
.fig .row { display: flex; gap: 6px; flex-wrap: wrap; }
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.pack header { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.pack header > div { flex: 1 1 200px; }
.pack header button { white-space: nowrap; }
.pack table { width: 100%; border-collapse: collapse; }
.pack td { padding: 2px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.pack td:first-child { width: 1%; white-space: nowrap; }
.pack td:nth-child(2) { width: 1%; text-align: center; }
#wish-run:not(:disabled) { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #1a1205; border: 0; font-weight: 650; }
@media (max-width: 760px) { .cat-grid { grid-template-columns: 1fr; } .cat-nav { flex-direction: row; flex-wrap: wrap; } }

/* Stichworte als Chips (Objekte und Archiv) */
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chips:empty { display: none; }
.chip-btn { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel2); color: var(--muted); }
.chip-btn.on { border-color: var(--accent); color: var(--accent); background: rgb(240 162 59 / 0.1); }
.b.tag { color: #a5b4fc; border-color: #312e81; cursor: pointer; }
#obj-state { flex: 1; min-width: 0; }
#left > #filter { width: 100%; }
.warn-text { color: #f6c27a; }
.badge.warn { background: rgb(240 162 59 / 0.25); color: #f6c27a; }
.nav-row.warn .n { color: #f6c27a; }
textarea { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; resize: vertical; width: 100%; }
textarea:focus { border-color: var(--accent); outline: none; }
.primary-inline { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #1a1205; border: 0; font-weight: 650; }

/* Bewegungsübernahme: Hinweis rechts, Auswahl im Rezept */
#move-hint { display: flex; flex-direction: column; gap: 6px; }
#move-hint .row button { flex: 0 0 auto; }
.uploads { display: flex; flex-direction: column; gap: 6px; }
.mini-flow { margin: 0; padding-left: 18px; color: var(--muted); }
.mini-flow li { margin: 1px 0; }
.uploads .pick .row { margin: 6px 0; }
.uploads .pick .row input { flex: 1; min-width: 0; }
.uploads .lib-pick { max-height: 220px; }
.uploads .lib-pick .nav-head { padding: 6px 2px 2px; }
.uploads .lib-pick label { color: var(--text); font-size: 12px; }
.chosen { display: flex; flex-direction: column; gap: 3px; }
.chosen-row { display: flex; align-items: center; gap: 6px; padding: 3px 6px; background: var(--panel2); border-radius: 6px; font-size: 12px; }
.chosen-row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chosen-row .arrow { color: var(--muted); }
.chosen-row code { color: var(--accent); }
.chosen-row button { padding: 0 6px; }

/* Archiv: Filter | Liste | Steckbrief */
.howto { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--panel2); }
.howto summary { cursor: pointer; font-weight: 600; }
.howto a { color: var(--accent); }
.flow { list-style: none; counter-reset: step; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin: 10px 0 6px; padding: 0; }
.flow li { counter-increment: step; display: flex; flex-direction: column; gap: 3px; padding: 8px 10px 8px 34px; position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--muted); }
.flow li::before { content: counter(step); position: absolute; left: 9px; top: 8px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #1a1205; background: var(--accent); }
.flow li b:first-child { color: var(--text); font-size: 13px; }
.arch { display: grid; grid-template-columns: 200px minmax(0, 1fr) 300px; gap: 12px; min-height: 0; flex: 1; }
.arch-facets { display: flex; flex-direction: column; gap: 0; overflow: auto; border-right: 1px solid var(--line); padding-right: 6px; }
.arch-facets .nav-head { padding: 10px 6px 3px; }
.arch-facets .nav-row { padding: 4px 6px; }
.arch-facets .chips { padding: 2px 4px; }
.arch-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; }
.arch-list { display: flex; flex-direction: column; gap: 4px; overflow: auto; flex: 1; min-height: 120px; }
.arch-list .nav-head { padding: 8px 2px 2px; }
.arch-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 7px 10px; background: var(--panel2); border-radius: 8px; flex-shrink: 0; }
.arch-card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.arch-card .l1 { display: flex; gap: 8px; align-items: baseline; }
.arch-card .l1 .t { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arch-card .l1 code { color: var(--accent); font-size: 12px; }
.arch-card .l2 { display: flex; flex-wrap: wrap; gap: 4px; }
.arch-card .l3 { color: var(--muted); }
.arch-detail { display: flex; flex-direction: column; gap: 8px; overflow: auto; border-left: 1px solid var(--line); padding-left: 12px; }
.arch-detail h3 { margin-top: 0; }
.arch-detail input, .arch-detail select { width: 100%; min-width: 0; }
.arch-detail .row input { flex: 1; }
.arch-detail .row { align-items: center; flex-wrap: wrap; }
.arch-detail .hint-box { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-link { color: var(--accent); text-decoration: none; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; color: var(--muted); }
.facts dt { color: #5d6578; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.detail-empty p { margin: 0 0 6px; }
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; margin-top: 8px; }
.upload-grid input { width: 100%; min-width: 0; }
.mx-direct { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; }
.mx-direct form { margin: 8px 0 4px; }
.mx-direct form input { flex: 1; }

/* Urheber & Nachweise */
.credits { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.credit header { display: flex; align-items: center; gap: 8px; }
.credit.missing { border-color: rgb(240 162 59 / 0.5); }
.credit .titles { margin-top: 6px; line-height: 1.7; }
.credit a { color: var(--accent); text-decoration: none; }
.credit a:hover { text-decoration: underline; }

@media (max-width: 980px) {
  .arch { grid-template-columns: 1fr; }
  .arch-facets { border-right: 0; max-height: 180px; }
  .arch-detail { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 8px; }
}
.step .grid > label:has(.uploads) { grid-column: 1 / -1; }
#left .toolbar select { flex: 1; width: 0; max-width: none; }

.clip-prev { margin: 0 0 10px; }
.clip-prev canvas { display: block; width: 100%; height: auto; border-radius: 6px; cursor: grab; }
.clip-prev p { margin: 4px 0 0; }
.warn { color: #f0a020; }

/* Bibliothek als Leiste rechts (nicht modal): links bleibt die Figur mit Vorschau und Probe sichtbar */
dialog#lib { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(1150px, 66vw); height: 100vh; max-height: 100vh; max-width: 100vw; border-radius: 0; border-width: 0 0 0 1px; box-shadow: -12px 0 32px rgb(0 0 0 / 0.45); z-index: 50; }
body.lib-open main { grid-template-columns: minmax(0, 1fr) min(1150px, 66vw); }
body.lib-open #nav, body.lib-open #left, body.lib-open #right { display: none; }
.lib-token[hidden] { display: none; }
.lib-pane[data-pane="library"] { overflow: hidden; }
.arch { grid-template-columns: 170px minmax(0, 1fr) 340px; }
.arch-facets, .arch-detail { min-height: 0; overflow: auto; }
.arch-main { overflow: hidden; }
@media (max-width: 1000px) {
  dialog#lib { width: 100vw; }
  body.lib-open main { grid-template-columns: 1fr; }
  .arch { grid-template-columns: 1fr; }
  .lib-pane[data-pane="library"] { overflow: auto; }
}

.chip-btn.gone { text-decoration: line-through; color: var(--bad); border-color: var(--bad); }
#have-clips .chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

.ident { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: -4px 0 0; }
.ident-item { padding: 0; border: 0; background: none; color: var(--text); font-size: 11px; cursor: pointer; }
button.ident-item:hover { text-decoration: underline; }
.ident-item.main code { color: var(--accent); }
.ident-item.muted, span.ident-item { color: var(--muted); cursor: default; }

/* Robotik-Werkstatt: ersetzt rechts die Rezepte, solange sie offen ist (das 3D-Fenster bleibt frei) */
#right.shop-on > :not(#shop, #obj-name, #obj-ident) { display: none !important; }
#shop { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-left: 3px solid var(--run); border-radius: var(--radius); background: var(--panel); }
#shop header { display: flex; align-items: center; }
#shop p { margin: 0; }
#shop .shop-row { display: flex; align-items: center; gap: 8px; }
#shop .shop-row select { padding: 3px 6px; font-size: 12px; }
#shop .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
#shop .shop-actions { display: flex; gap: 8px; margin-top: 6px; }
#shop .primary-sm { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #1a1205; border: 0; font-weight: 650; }
#shop input[type='range'] { width: 100%; padding: 0; }
.bad-text { color: var(--bad); }
.step .grid > .plan-field { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.step .grid > .plan-field > span { flex: 1 1 100%; }
#shop-clips button { font-size: 12px; padding: 3px 10px; border-radius: 999px; }
#shop-sliders { display: flex; flex-direction: column; gap: 4px; }
#shop-sliders b { color: var(--text); font-weight: 600; }

/* Arena: Kämpfer links, Bühne rechts */
dialog#arena { width: calc(100vw - 32px); height: calc(100vh - 32px); max-width: none; max-height: none; padding: 0; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; }
dialog#arena:not([open]) { display: none; }
dialog#arena::backdrop { background: rgb(0 0 0 / 0.7); }
.arena-body { flex: 1; display: grid; grid-template-columns: minmax(300px, 380px) 1fr; min-height: 0; }
.arena-side { overflow-y: auto; padding: 10px 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.arena-side h3 { margin: 6px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted, #8a8f98); }
.arena-fighter .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.arena-fighter .nums label { display: flex; flex-direction: column; gap: 2px; }
.arena-fighter .nums input { width: 100%; min-width: 0; }
.arena-fighter { border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.arena-fighter.team-A { border-left-color: #3b82f6; }
.arena-fighter.team-B { border-left-color: #ef4444; }
.arena-fighter select { max-width: 100%; }
.arena-stage { position: relative; min-height: 0; }
.arena-stage canvas { display: block; }
.arena-banner { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); padding: 8px 18px; border-radius: 10px; background: rgb(0 0 0 / 0.65); font-size: 22px; font-weight: 700; letter-spacing: .04em; }
.arena-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.arena-table td, .arena-table th { padding: 2px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.arena-table td:first-child, .arena-table th:first-child { text-align: left; }
.arena-table tr.team-A td:first-child { color: #93c5fd; }
.arena-table tr.team-B td:first-child { color: #fca5a5; }
@media (max-width: 800px) { .arena-body { grid-template-columns: 1fr; grid-template-rows: auto 60vh; } }
/* Clip-Werkbank (Arena) */
#arena-bench { border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.bench-rows { display: flex; flex-direction: column; gap: 4px; max-height: 46vh; overflow-y: auto; }
.bench-row { border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.bench-row .row { gap: 3px; flex-wrap: nowrap; align-items: center; }
.bench-row input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 12px; }
.bench-row.off .bench-from { text-decoration: line-through; opacity: .6; }
.bench-row.bad input { border-color: #ef4444; }
.bench-from { font-family: ui-monospace, monospace; font-size: 11px; max-width: 34%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bench-hint { font-size: 12px; padding: 6px; border-radius: 6px; background: rgb(234 179 8 / 0.12); border: 1px solid rgb(234 179 8 / 0.4); }
button.tiny { padding: 1px 5px; font-size: 11px; min-width: 0; }
.err { color: #f87171; }
/* Vorschau vor dem Hochladen */
dialog.upload-preview { width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 12px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
dialog.upload-preview::backdrop { background: rgb(0 0 0 / 0.7); }
.upload-preview .up-body { display: grid; grid-template-columns: 1fr 280px; gap: 12px; margin: 8px 0; }
.upload-preview .up-view { min-width: 0; }
.upload-preview .up-view canvas { display: block; width: 100% !important; height: auto !important; border-radius: 8px; }
.upload-preview .up-clips { display: flex; flex-direction: column; gap: 3px; max-height: 40vh; overflow-y: auto; }
.upload-preview .up-clips button { text-align: left; }
.upload-preview .up-tabs { flex-wrap: wrap; gap: 4px; }
@media (max-width: 700px) { .upload-preview .up-body { grid-template-columns: 1fr; } }
/* Biomechanik-Ampel (clip-check.js) */
.bio-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.bio-ok { background: #22c55e; }
.bio-warn { background: #eab308; }
.bio-bad { background: #ef4444; }
.ok { color: #4ade80; }
/* Bewegungsdatenbank (Reiter „Abläufe“, Steckbrief „Passt danach“) */
.mo-grid { display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: 12px; align-items: start; }
.mo-chain li { padding: 3px 4px; border-radius: 6px; }
.mo-chain li.on { background: rgb(234 179 8 / 0.15); }
.mo-row { position: relative; display: block; width: 100%; text-align: left; margin: 2px 0; padding: 4px 6px; overflow: hidden; }
.mo-bar { position: absolute; left: 0; top: 0; bottom: 0; background: rgb(34 197 94 / 0.14); pointer-events: none; }
@media (max-width: 800px) { .mo-grid { grid-template-columns: 1fr; } }
/* Dojo: Werte in Gruppen, Taktik-Regler, Angriffe, Gedanken über den Köpfen */
.dojo-group summary { cursor: pointer; color: var(--muted, #8a8f98); }
.dojo-slider { display: grid; grid-template-columns: 7.5em 1fr 2.5em; align-items: center; gap: 6px; }
.dojo-slider b { text-align: right; font-weight: 600; }
#arena-moves { border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.dojo-moves { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; }
.dojo-move { border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.dojo-move.off { opacity: .5; }
.dojo-move .nums { grid-template-columns: repeat(2, 1fr); }
#arena-minds { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.mind { position: absolute; transform: translate(-50%, -100%); padding: 2px 7px; border-radius: 8px; background: rgb(0 0 0 / 0.6); font-size: 11px; white-space: nowrap; border-left: 3px solid #3b82f6; }
.mind.team-B { border-left-color: #ef4444; }
.arena-mind-toggle { position: absolute; right: 10px; bottom: 8px; background: rgb(0 0 0 / 0.5); padding: 2px 8px; border-radius: 8px; }

/* Anleitung */
dialog#help { width: min(1100px, calc(100vw - 32px)); height: min(880px, calc(100vh - 32px)); padding: 0; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; }
dialog#help:not([open]) { display: none; }
dialog#help::backdrop { background: rgb(0 0 0 / 0.6); }
#help-find { max-width: 220px; }
.help-body { display: flex; flex: 1; min-height: 0; }
#help-toc { width: 250px; flex: none; overflow: auto; padding: 10px 8px; border-right: 1px solid var(--line); font-size: 13px; }
#help-toc a { display: block; padding: 4px 8px; border-radius: 6px; color: var(--text); text-decoration: none; }
#help-toc a:hover, #help-toc a.on { background: rgb(255 255 255 / 0.07); }
#help-toc a.sub { padding-left: 20px; opacity: 0.8; }
#help-text { flex: 1; overflow: auto; padding: 8px 22px 40px; line-height: 1.55; font-size: 14px; }
#help-text h2 { margin-top: 26px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 18px; }
#help-text h2:first-child { border-top: 0; }
#help-text h3 { font-size: 15px; }
#help-text table { border-collapse: collapse; margin: 8px 0 14px; font-size: 13px; }
#help-text th, #help-text td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
#help-text pre { overflow: auto; padding: 10px; background: rgb(0 0 0 / 0.3); border-radius: 8px; font-size: 12px; }
#help-text code { font-size: 12.5px; }
#help-text .hit { outline: 2px solid var(--accent, #4c8dff); outline-offset: 4px; border-radius: 4px; }
.help-q { display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; margin-left: 6px; border-radius: 50%; font-size: 12px; font-weight: 700; vertical-align: middle; }
@media (max-width: 720px) {
  dialog#help { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
  #help-toc { display: none; }
}

dialog.pick-machines { width: min(640px, calc(100vw - 32px)); }
.pick-list { max-height: 55vh; overflow: auto; display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.pick-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; flex-wrap: wrap; }
.pick-row:hover { background: rgb(255 255 255 / 0.04); }
.pick-row label { display: flex; flex-direction: row; gap: 8px; align-items: center; margin: 0; text-align: left; }
.pick-row > label:first-child { flex: 1; min-width: 160px; }
.pick-row input[type='checkbox'] { width: auto; margin: 0; flex: none; }
