:root {
  --bg: #0f0d12;
  --panel: #17141c;
  --panel-2: #1f1b26;
  --line: #2e2836;
  --line-2: #3d3547;
  --text: #ece6f0;
  --muted: #9a90a6;
  --dim: #6f667a;
  --accent: #e8a33d;
  --accent-ink: #1a1206;
  --ok: #5cc28a;
  --warn: #e6b450;
  --bad: #e5645a;
  --info: #6ea8e8;
  --r-common: #c9c3cf;
  --r-magic: #6ea8e8;
  --r-rare: #e6c24f;
  --r-legendary: #f08a3c;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: .01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.boot { padding: 40px; color: var(--muted); }

/* Anmeldung */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth form { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: grid; gap: 14px; }
.auth .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.auth p { margin: 0; color: var(--muted); }
.flame { width: 26px; height: 26px; border-radius: 6px; background: radial-gradient(circle at 50% 60%, #ffd27a, var(--accent) 45%, #8a4b12 80%); box-shadow: 0 0 18px rgba(232,163,61,.35); flex: none; }

/* Layout */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: rgba(15,13,18,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.top .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; white-space: nowrap; }
.top nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.top nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.top nav a.on, .top nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.top .me { color: var(--muted); white-space: nowrap; display: flex; gap: 8px; align-items: center; }
main { max-width: 1280px; margin: 0 auto; padding: 20px; }
.crumbs { color: var(--muted); margin-bottom: 12px; font-size: 13px; }
.crumbs a { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack { display: grid; gap: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card > h3 { margin-bottom: 12px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* Kennzahlen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }

/* Formulare */
label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; align-content: start; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; padding: 7px 9px; min-width: 0; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(232,163,61,.5); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=number] { font-variant-numeric: tabular-nums; }
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; line-height: 1.4; }
textarea.json { min-height: 420px; white-space: pre; tab-size: 2; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; }
.fields.wide { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.field-changed input, .field-changed select { border-color: var(--accent); background: rgba(232,163,61,.06); }
.hint { font-size: 11px; color: var(--dim); }

button, .btn { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 7px 12px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
button:hover { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); border-color: rgba(229,100,90,.45); }
button.danger:hover { background: rgba(229,100,90,.1); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 5px 8px; }
button.ghost:hover { color: var(--text); background: var(--panel-2); }
button.sm { padding: 4px 8px; font-size: 12px; }
.err { color: var(--bad); min-height: 1em; }

/* Tabellen */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--panel-2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.015); }
tr.click { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td input[type=number] { width: 110px; padding: 4px 6px; }

/* Abzeichen */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: rgba(92,194,138,.4); }
.badge.bad { color: var(--bad); border-color: rgba(229,100,90,.45); }
.badge.warn { color: var(--warn); border-color: rgba(230,180,80,.45); }
.badge.info { color: var(--info); border-color: rgba(110,168,232,.4); }
.r-common { color: var(--r-common); }
.r-magic { color: var(--r-magic); }
.r-rare { color: var(--r-rare); }
.r-legendary { color: var(--r-legendary); }

/* Slots */
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; }
.slot { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; align-content: start; }
.slot.empty { border-style: dashed; color: var(--dim); }
.slot .num { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.slot .name { font-size: 18px; font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-slots { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-slot { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.mini-slot.empty { color: var(--dim); border-style: dashed; background: transparent; }

/* Editor */
.ed-head { position: sticky; top: 53px; z-index: 10; background: var(--bg); padding: 10px 0 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.check { border-radius: var(--radius); padding: 10px 12px; border: 1px solid; font-size: 13px; }
.check.ok { border-color: rgba(92,194,138,.35); background: rgba(92,194,138,.06); }
.check.bad { border-color: rgba(229,100,90,.45); background: rgba(229,100,90,.08); }
.check pre { margin: 6px 0 0; white-space: pre-wrap; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.dirty-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 14px 0 16px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 9px 12px; color: var(--muted); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--text); }
.tabs .count { font-size: 11px; color: var(--dim); }
details.obj { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
details.obj summary { cursor: pointer; padding: 8px 12px; display: flex; gap: 8px; align-items: center; }
details.obj summary::marker { color: var(--dim); }
details.obj > div { padding: 0 12px 12px; display: grid; gap: 8px; }
details.obj textarea { min-height: 160px; }
.items td .iname { font-weight: 500; }
.eq-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.eq-slot { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "lbl acts" "it it"; gap: 2px 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); min-width: 0; }
.eq-slot .lbl { grid-area: lbl; color: var(--muted); font-size: 12px; }
.eq-slot .acts { grid-area: acts; display: flex; gap: 2px; }
.eq-slot .it { grid-area: it; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eq-slot.empty .it { color: var(--dim); }
.tal-node { display: grid; grid-template-columns: 1fr 90px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.tal-node:last-child { border-bottom: 0; }
.tal-node .d { font-size: 12px; color: var(--muted); }
.tal-node.on .n { color: var(--accent); }
.spell-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; }
.spell-list label { display: flex; flex-direction: row; gap: 8px; align-items: flex-start; color: var(--text); font-size: 13px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); cursor: pointer; }
.spell-list label .muted { font-size: 12px; }
.aff-row { display: grid; grid-template-columns: 1fr 100px auto; gap: 6px; align-items: center; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
pre.stack { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; color: var(--muted); margin: 6px 0 0; max-height: 220px; overflow: auto; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(5,4,7,.72); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; width: 100%; max-width: 720px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal.wide { max-width: 1000px; }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal header h2 { flex: 1; }
.modal .body { padding: 16px 18px; overflow: auto; display: grid; gap: 14px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* Hinweise */
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); border-radius: 6px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }
.empty-state { padding: 28px; text-align: center; color: var(--dim); }

@media (max-width: 700px) {
  .top { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  .top nav { order: 3; flex-basis: 100%; }
  main { padding: 16px; }
  .ed-head { top: 92px; }
}
