:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a; --text: #e6e8ec; --muted: #8b93a3;
  --accent: #ffb020; --accent-ink: #1a1200; --ok: #3ecf8e; --warn: #ffb020; --err: #ff5d5d; --info: #5aa9ff;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --radius: 8px;
  color-scheme: dark;
}
:root.light {
  --bg: #f4f5f7; --panel: #ffffff; --panel2: #f0f1f4; --line: #dfe2e8; --text: #1b1e24; --muted: #687083;
  --accent: #e08c00; --accent-ink: #fff; color-scheme: light;
}
* { 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: inherit; }
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--err); }
button.ghost { background: none; border-color: transparent; }
button:disabled { opacity: .45; cursor: default; }
input, select { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { color: var(--muted); font-size: 12px; display: grid; gap: 4px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }

.top { display: flex; align-items: center; gap: 24px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; text-decoration: none; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.brand small { color: var(--muted); font-weight: 400; font-size: 12px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
nav { display: flex; gap: 4px; flex: 1; }
nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 6px; }
nav a.active, nav a:hover { color: var(--text); background: var(--panel2); }
main { padding: 20px; max-width: 1600px; margin: 0 auto; }

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card p { margin: 0 0 12px; color: var(--muted); }

.phead { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.phead input.title { font-size: 20px; font-weight: 700; background: none; border-color: transparent; padding: 2px 4px; margin-left: -4px; }
.phead input.title:hover { border-color: var(--line); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--muted); }
.chip b { color: var(--text); }
.chip.err { border-color: var(--err); color: var(--err); }
.chip.err b { color: var(--err); }
.chip.warn { border-color: var(--warn); color: var(--warn); }
.chip.warn b { color: var(--warn); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { text-decoration: none; padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-color: var(--accent); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar input[type=search] { min-width: 220px; }
.selbar { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px 4px 12px; }

table { border-collapse: collapse; width: 100%; }
.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 290px); }
th { position: sticky; top: 0; background: var(--panel2); text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; z-index: 1; }
td { padding: 4px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.sel td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
tr.removed td { opacity: .45; text-decoration: line-through; }
tr.flash td { animation: flash 1.2s; }
@keyframes flash { from { background: color-mix(in srgb, var(--accent) 45%, transparent); } }
td.edit input { width: 82px; padding: 2px 6px; font-family: var(--mono); background: transparent; border-color: transparent; }
td.edit input:hover { border-color: var(--line); }
td.edit input:focus { background: var(--bg); }
td.edit input.bad { border-color: var(--err); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); }
.badge.changed { border-color: var(--info); color: var(--info); }
.badge.err { border-color: var(--err); color: var(--err); }
.badge.ok { border-color: var(--ok); color: var(--ok); }
.badge.warn { border-color: var(--warn); color: var(--warn); }

/* Universen */
.unis { display: grid; gap: 16px; }
.uni { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.uni h3 { margin: 0 0 8px; font-size: 13px; display: flex; gap: 12px; align-items: baseline; }
.band { display: grid; grid-template-columns: repeat(32, 1fr); gap: 2px; }
.cell { height: 22px; border-radius: 3px; background: var(--panel2); font: 9px/22px var(--mono); color: var(--muted); text-align: center; overflow: hidden; position: relative; cursor: default; }
.cell.used { color: #000; cursor: pointer; font-weight: 600; }
.cell.start { box-shadow: inset 2px 0 0 rgba(0,0,0,.55); }
.cell.clash { background: var(--err) !important; color: #fff; }
.cell.hl { outline: 2px solid var(--text); z-index: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.issues li { border-left: 3px solid var(--err); padding: 4px 10px; background: var(--panel2); border-radius: 0 6px 6px 0; cursor: pointer; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 20; padding: 20px; }
.modal.hidden { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(860px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 20px; }
.modal-box h2 { font-size: 17px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; position: sticky; bottom: -20px; background: var(--panel); padding: 12px 0 0; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.diff { display: grid; gap: 12px; }
.diff details { background: var(--panel2); border-radius: 6px; padding: 8px 12px; }
.diff summary { cursor: pointer; font-weight: 600; }
.diff ul { margin: 8px 0 0; padding-left: 18px; max-height: 220px; overflow: auto; color: var(--muted); }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--text); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; z-index: 30; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.toast.err { border-color: var(--err); }
.toast.hidden { display: none; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.plist td, .plist th { cursor: default; }
.plist tr { cursor: pointer; }
.plist tr:hover td { background: var(--panel2); }

/* Druckansicht */
.print { background: #fff; color: #000; padding: 0; }
.print h1 { font-size: 18px; }
.print table { font-size: 11px; margin-bottom: 18px; }
.print th { position: static; background: #eee; color: #000; }
.print td, .print th { border: 1px solid #bbb; padding: 3px 6px; }
@media print {
  .top, .noprint { display: none !important; }
  body, main { background: #fff; padding: 0; }
  .print h2 { break-after: avoid; }
  .print table { break-inside: auto; }
  .print tr { break-inside: avoid; }
}
.form input, .form select { width: 100%; min-width: 0; }
