:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --line: #e3e3de;
  --accent: #2f6b4f;
  --accent-soft: #e6f0ea;
  --danger: #b42318;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 15px; margin: 0 0 6px; }
code { background: #eee; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.hint { color: var(--muted); margin: 0 0 14px; line-height: 1.45; }
.error { color: var(--danger); min-height: 1.2em; }

button, .button {
  font: inherit; cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  padding: 7px 14px; border-radius: 8px; text-decoration: none; display: inline-block;
}
button:hover, .button:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.danger { background: transparent; color: var(--danger); border-color: #f2c4bf; }
button.small { padding: 4px 9px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
input, select {
  font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text);
}
input[type=color] { padding: 2px; width: 42px; height: 34px; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
label > input, label > select { color: var(--text); font-size: 14px; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 650; letter-spacing: -.01em; }
.tabs { display: flex; gap: 4px; }
.tabs button { background: transparent; color: var(--muted); border: none; padding: 8px 12px; }
.tabs button.active { color: var(--text); background: var(--bg); }
.topbar-right { margin-left: auto; display: flex; gap: 8px; }

/* Layout */
.view { display: grid; grid-template-columns: 280px 1fr; min-height: calc(100vh - 56px); }
.view.single { display: block; padding: 24px; }
.sidebar { border-right: 1px solid var(--line); background: var(--panel); padding: 18px; overflow-y: auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; max-width: 1100px; margin: 0 auto; }
.panel.narrow { max-width: 620px; }
.center-card { max-width: 380px; margin: 12vh auto; background: var(--panel); padding: 28px; border-radius: var(--radius); border: 1px solid var(--line); }
.center-card form { display: flex; flex-direction: column; gap: 12px; }

/* Listen */
.item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.item-list li button {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  background: transparent; color: var(--text); border: 1px solid transparent; padding: 6px 8px;
}
.item-list li button:hover { background: var(--bg); }
.item-list li button.active { background: var(--accent-soft); border-color: #c9dfd2; }
.thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: #eee; flex-shrink: 0; }
.item-meta { display: flex; flex-direction: column; min-width: 0; }
.item-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta small { color: var(--muted); }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 99px; background: #eee; color: var(--muted); }
.badge.ok { background: var(--accent-soft); color: var(--accent); }

/* Rahmen-Editor */
.editor { padding: 22px; overflow: auto; }
.editor .empty { color: var(--muted); margin-top: 20vh; text-align: center; }
.editor-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.editor-head h1 { margin: 0; }
.editor-head .spacer { flex: 1; }
.dirty-note { color: #b54708; font-size: 13px; }
.editor-body { display: grid; grid-template-columns: minmax(320px, 640px) 300px; gap: 22px; align-items: start; }
.canvas-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.canvas { position: relative; user-select: none; touch-action: none; border-radius: 6px; overflow: hidden; background: repeating-conic-gradient(#f0f0ee 0% 25%, #fafaf9 0% 50%) 50% / 20px 20px; }
.canvas img { display: block; width: 100%; height: auto; pointer-events: none; }
.canvas .no-image { padding: 120px 20px; text-align: center; color: var(--muted); }
.slot {
  position: absolute; border: 2px solid var(--slot-color, #3b82f6); background: color-mix(in srgb, var(--slot-color, #3b82f6) 22%, transparent);
  border-radius: 6px; cursor: move; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px; text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.slot.circle { border-radius: 50%; }
.slot.selected { outline: 2px dashed #111; outline-offset: 2px; }
.slot .handle {
  position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px; background: #fff;
  border: 2px solid #111; border-radius: 3px; cursor: nwse-resize;
}
.canvas-tools { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.canvas-tools .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }

.side { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card h3 { margin: 0; font-size: 14px; }
.radio-row { display: flex; flex-direction: column; gap: 6px; }
.radio-row label { flex-direction: row; align-items: flex-start; gap: 8px; color: var(--text); font-size: 14px; cursor: pointer; }
.radio-row small { color: var(--muted); display: block; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.slot-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.slot-list li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.slot-list li.selected { background: var(--accent-soft); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.warn { color: #b54708; font-size: 13px; }

/* Tasten-Tabelle */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.check, th.check { text-align: center; }
.type-head { display: inline-flex; align-items: center; gap: 6px; }
.key-cell { display: flex; align-items: center; gap: 10px; }
.variants { color: var(--muted); font-size: 12px; }

/* Slot-Typen */
.type-list { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
.type-list li { display: flex; gap: 8px; align-items: center; }
.type-list li input[type=text] { flex: 1; }
.inline-form { display: flex; gap: 8px; }
.inline-form input[name=name] { flex: 1; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1c1c1a; color: #fff;
  padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 50;
}
.toast.error { background: var(--danger); }

@media (max-width: 1000px) {
  .view { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
  .editor-body { grid-template-columns: 1fr; }
}
