:root {
  --bg: #17181c; --panel: #202127; --panel2: #292b33; --line: #363944; --text: #e6e7eb; --muted: #9296a3;
  --accent: #ffb454; --danger: #ff6b6b; --ok: #6fd08c;
  --c-start: #4caf7d; --c-scene: #4f8fe8; --c-choice: #e0a030; --c-condition: #a779e0; --c-end: #e06c75;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); } .bad { color: var(--danger); } .ok { color: var(--ok); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.grow { flex: 1; } .sep { width: 1px; height: 22px; background: var(--line); }
.row { display: flex; gap: 6px; align-items: center; } .row.end { margin-top: 16px; justify-content: space-between; }
.row > input[type=text] { flex: 1; min-width: 0; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--panel2); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #565a69; background: #30333d; }
.btn:focus-visible, .pal:focus-visible, .issue:focus-visible, .card-main:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1b1c20; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; } .btn.ghost:hover { background: var(--panel2); }
.btn.danger { color: var(--danger); } .btn.small { padding: 4px 8px; }
.btn:disabled { opacity: .35; cursor: default; }
.btn b { background: var(--danger); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; }
input[type=text], select, textarea { width: 100%; padding: 7px 9px; background: #15161a; border: 1px solid var(--line); border-radius: 6px; }
input[type=text]:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent); }
textarea { resize: vertical; min-height: 34px; }

/* Projektübersicht */
#home { max-width: 1100px; margin: 0 auto; padding: 56px 24px; }
.home-head h1 { font-size: 34px; } .home-head p { color: var(--muted); margin: 6px 0 22px; font-size: 16px; }
.home-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cards { margin-top: 34px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.card-main { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 3px; padding-bottom: 10px; }
.card-main img, .card-ph { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #111; display: grid; place-items: center; font-size: 40px; color: #3a3d48; }
.card-main strong { padding: 10px 14px 0; font-size: 16px; } .card-main span { padding: 0 14px; font-size: 12px; }
.card .btn { align-self: flex-end; margin: 0 8px 8px; }

/* Editor-Layout */
#app { height: 100%; display: grid; grid-template: 48px minmax(0, 1fr) / 250px minmax(0, 1fr) 320px; }
#bar { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
#projName { width: 220px; background: transparent; border-color: transparent; font-weight: 600; font-size: 15px; }
#projName:hover { border-color: var(--line); }
#saveState { font-size: 12px; margin-right: 6px; }
#left, #right { background: var(--panel); overflow: hidden auto; padding: 12px; min-width: 0; }
#left { border-right: 1px solid var(--line); } #right { border-left: 1px solid var(--line); }
#left h2, #right h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 0 8px; }
#left h2:first-child { margin-top: 0; }
#inspector h2 { font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0 0 2px; }
#inspector h3 { font-size: 13px; margin: 14px 0 6px; }
#inspector > p.muted { font-size: 12.5px; margin-bottom: 10px; }

#palette { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.pal { min-width: 0; font-size: 12.5px; display: flex; align-items: center; gap: 5px; padding: 7px 6px; border: 1px solid var(--line); border-left-width: 3px; border-radius: 6px; background: var(--panel2); cursor: pointer; text-align: left; }
.pal:hover { background: #30333d; } .pal i { font-style: normal; }
.pal.t-start { border-left-color: var(--c-start); } .pal.t-scene { border-left-color: var(--c-scene); } .pal.t-choice { border-left-color: var(--c-choice); }
.pal.t-condition { border-left-color: var(--c-condition); } .pal.t-end { border-left-color: var(--c-end); }

.drop { display: flex; flex-direction: column; gap: 2px; align-items: center; text-align: center; padding: 16px 8px; border: 1.5px dashed #4a4e5c; border-radius: 10px; cursor: pointer; }
.drop span { font-size: 11.5px; color: var(--muted); }
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(255,180,84,.07); }
#assets { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.asset { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 4px; border-radius: 7px; background: var(--panel2); cursor: grab; position: relative; }
p.asset { display: block; background: none; cursor: default; font-size: 12.5px; }
.asset span { overflow: hidden; font-size: 12.5px; line-height: 1.3; word-break: break-all; } .asset small { display: block; color: var(--muted); font-size: 11px; }
.a-thumb, .a-ph { width: 56px; height: 36px; object-fit: cover; border-radius: 4px; background: #111; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.a-del { all: unset; cursor: pointer; padding: 4px 7px; color: var(--muted); border-radius: 5px; } .a-del:hover, .a-del:focus-visible { color: var(--danger); background: #15161a; }
.asset progress { grid-column: 1 / -1; width: 100%; height: 5px; }

/* Arbeitsfläche */
#canvas { position: relative; overflow: hidden; outline: 0; touch-action: none; cursor: grab; background-color: var(--bg);
  background-image: radial-gradient(#2e3038 1.2px, transparent 1.2px); background-size: 24px 24px; }
#canvas:active { cursor: grabbing; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
#canvasHint { position: absolute; left: 12px; bottom: 8px; font-size: 11.5px; pointer-events: none; opacity: .8; }
.edge { fill: none; stroke: #7d8291; stroke-width: 2.2; }
.edge.t-choice { stroke: var(--c-choice); } .edge.t-condition { stroke: var(--c-condition); } .edge.t-start { stroke: var(--c-start); } .edge.t-scene { stroke: var(--c-scene); }
.edge.sel { stroke: #fff; stroke-width: 3.2; } .edge.tmp { stroke: var(--accent); stroke-dasharray: 6 5; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }

.node { position: absolute; width: 230px; background: var(--panel2); border: 1px solid #454856; border-radius: 9px; box-shadow: 0 4px 14px rgba(0,0,0,.35); cursor: move; user-select: none; }
.node.sel { border-color: #fff; box-shadow: 0 0 0 1px #fff, 0 6px 20px rgba(0,0,0,.5); }
.node.target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.n-head { display: flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 8px 8px 0 0; font-weight: 600; font-size: 13px; }
.n-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.n-warn { color: #ffd166; cursor: help; }
.t-start .n-head { background: var(--c-start); color: #0c1f15; } .t-scene .n-head { background: var(--c-scene); color: #fff; }
.t-choice .n-head { background: var(--c-choice); color: #2a1c00; } .t-condition .n-head { background: var(--c-condition); color: #fff; } .t-end .n-head { background: var(--c-end); color: #fff; }
h2.t-start { color: var(--c-start) !important; } h2.t-scene { color: var(--c-scene) !important; } h2.t-choice { color: var(--c-choice) !important; } h2.t-condition { color: var(--c-condition) !important; } h2.t-end { color: var(--c-end) !important; }
.n-body { padding: 6px 0 4px; }
.n-thumb { display: block; width: calc(100% - 16px); margin: 2px 8px 6px; aspect-ratio: 16/9; object-fit: cover; border-radius: 5px; background: #111; pointer-events: none; }
.n-thumb.none, .i-thumb.none { display: grid; place-items: center; color: #5b5f6d; font-size: 12px; border: 1px dashed #454856; background: none; }
.n-tags { display: flex; gap: 4px; padding: 0 8px 4px; } .n-tags span { font-size: 10.5px; padding: 1px 6px; border-radius: 8px; background: #3a3d49; color: #c9ccd6; }
.n-text { padding: 2px 10px 6px; font-size: 12px; color: #c3c6d0; line-height: 1.35; }
.n-row { position: relative; display: flex; justify-content: flex-end; padding: 4px 16px 4px 10px; font-size: 12px; color: #c9ccd6; }
.port { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #9aa0b0; border: 2px solid var(--panel2); }
.port.in { left: -8px; top: 9px; }
.port.out { right: -8px; top: 50%; margin-top: -7px; cursor: crosshair; background: #c9ccd6; }
.port.out:hover { background: var(--accent); transform: scale(1.3); }
.port.out.open { background: var(--danger); box-shadow: 0 0 0 3px rgba(255,107,107,.25); }

/* Inspector */
.field { display: block; margin: 10px 0; } .field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: 8px 0; cursor: pointer; }
.i-thumb { display: block; width: 100%; aspect-ratio: 16/9; object-fit: contain; background: #111; border-radius: 6px; }
.opt { padding: 8px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 8px; background: #1b1c21; }
.opt details { margin-top: 6px; font-size: 12px; } .opt summary { cursor: pointer; color: var(--muted); } .opt details .row { margin-top: 6px; }
.opt details select { width: 64px; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 14px; font-size: 12.5px; cursor: pointer; }
.chip:has(input:checked) { border-color: var(--accent); background: rgba(255,180,84,.12); }
.warnbox { margin-top: 12px; padding: 8px 10px; border-radius: 7px; background: rgba(255,209,102,.1); color: #ffd166; font-size: 12.5px; }
#issueCount { background: var(--danger); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; } #issueCount:empty { display: none; }
#issues { display: flex; flex-direction: column; gap: 4px; } #issues p { font-size: 12.5px; }
.issue { all: unset; cursor: pointer; display: block; padding: 6px 8px; border-radius: 6px; background: #1b1c21; font-size: 12px; color: #c9ccd6; line-height: 1.35; }
.issue b { display: block; color: #ffd166; font-weight: 600; } .issue:hover { background: #24262d; }

/* Menüs, Dialoge */
#ctx { position: fixed; z-index: 50; min-width: 190px; padding: 5px; border-radius: 9px; background: #2b2d36; border: 1px solid #454856; box-shadow: 0 10px 30px rgba(0,0,0,.5); display: flex; flex-direction: column; }
#ctx span { padding: 5px 10px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
#ctx button { all: unset; cursor: pointer; padding: 7px 10px; border-radius: 6px; display: flex; gap: 9px; } #ctx button:hover, #ctx button:focus-visible { background: #3a3d49; }
#ctx i { font-style: normal; width: 16px; text-align: center; }
#modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.65); display: grid; place-items: center; padding: 20px; }
.m-box { width: min(520px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.m-box.wide { width: min(1200px, 100%); height: 88vh; } .m-box.full { width: 100%; height: 100%; }
.m-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px 9px 16px; border-bottom: 1px solid var(--line); } .m-head strong { flex: 1; }
.m-body { padding: 16px; overflow: auto; flex: 1; min-height: 0; } .m-box.full .m-body { padding: 0; display: flex; }
.m-body iframe { flex: 1; width: 100%; height: 100%; border: 0; background: #000; }
.progress progress, .export input { width: 100%; } .progress p { margin-top: 8px; color: var(--muted); } .export p { margin-bottom: 12px; }
.tr-wrap { overflow: auto; margin-top: 12px; }
table.tr { border-collapse: collapse; width: 100%; } .tr th { text-align: left; font-size: 12px; color: var(--muted); padding: 6px 8px; position: sticky; top: 0; background: var(--panel); }
.tr td { padding: 5px 8px; border-top: 1px solid var(--line); vertical-align: top; min-width: 180px; white-space: pre-wrap; } .tr td:first-child { min-width: 110px; font-size: 12px; }
.tr td.miss textarea { border-color: var(--danger); } .tr td.stale textarea { border-color: #ffd166; }
#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 70; max-width: 80vw; padding: 10px 16px; border-radius: 9px; background: #33363f; box-shadow: 0 8px 26px rgba(0,0,0,.5); }
#toast.bad { background: #6e2a2f; }
@media (max-width: 980px) { #app { grid-template-columns: 180px 1fr 260px; } #canvasHint { display: none; } }

/* Anmeldung */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 30%, #262a38, var(--bg) 70%); }
.auth-card { width: min(400px, 100%); padding: 30px 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.auth-card h1 { font-size: 26px; } .auth-card > p.muted { margin: 6px 0 18px; }
.auth-card code { background: #15161a; padding: 1px 5px; border-radius: 4px; }
.auth-error { margin: 0 0 14px; padding: 9px 12px; border-radius: 8px; background: rgba(255,107,107,.13); color: #ff9c9c; word-break: break-word; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 14px; background: #15161a; border-radius: 9px; }
.auth-tabs button { all: unset; cursor: pointer; text-align: center; padding: 7px; border-radius: 6px; color: var(--muted); }
.auth-tabs button[aria-selected=true] { background: var(--panel2); color: var(--text); font-weight: 600; }
.auth-tabs button:focus-visible { outline: 2px solid var(--accent); }
input[type=email], input[type=password] { width: 100%; padding: 9px 10px; background: #15161a; border: 1px solid var(--line); border-radius: 6px; }
input[type=email]:focus, input[type=password]:focus { outline: 0; border-color: var(--accent); }
.auth-card input[type=text] { padding: 9px 10px; }
.btn.wide { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; }
.auth-or { display: flex; align-items: center; gap: 10px; margin: 16px 0 8px; color: var(--muted); font-size: 12px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.social b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 13px; }
.social b.g { background: #fff; color: #4285f4; } .social b.f { background: #1877f2; color: #fff; }
.home-user { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-bottom: 8px; }
.home-h { margin-top: 38px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.home-h + .cards { margin-top: 14px; }
a.card-main { text-decoration: none; color: inherit; }
