:root {
  --red: #ff4136; --red-d: #c42b22;
  --yellow: #ffcc29; --yellow-d: #d9a313;
  --blue: #1f8bff; --blue-d: #0a5fbf;
  --green: #2ecc40; --green-d: #1f9e30;
  --bg: #ecebe6; --ink: #1b1b24; --muted: #8a8780; --surface: #fff; --surface-d: #cfccc3;
  --radius: 18px;
  font-family: "Baloo 2", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--ink); font-family: "Baloo 2", system-ui, sans-serif; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--surface); box-shadow: 0 3px 0 var(--surface-d);
}
.brand { font-size: 26px; font-weight: 800; font-style: italic; color: var(--red); }
.brand span { color: var(--ink); font-style: normal; }
.save-state { font-size: 15px; font-weight: 700; color: var(--muted); min-height: 20px; }
.save-state.saved { color: var(--green-d); }

#app { max-width: 1560px; margin: 0 auto; padding: 28px 32px 80px; }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.dark-toggle { width: 40px; height: 40px; border-radius: 12px; background: var(--bg); color: var(--ink); font-size: 20px; box-shadow: 0 3px 0 var(--surface-d); }

/* Buttons */
button { font-family: inherit; cursor: pointer; border: none; }
.btn {
  font-weight: 800; font-size: 17px; color: #fff; background: var(--red);
  padding: 12px 22px; border-radius: 14px; box-shadow: 0 5px 0 var(--red-d); transition: transform .1s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--red-d); }
.btn.secondary { background: var(--surface); color: var(--ink); box-shadow: 0 5px 0 var(--surface-d); }
.btn.blue { background: var(--blue); box-shadow: 0 5px 0 var(--blue-d); }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; padding: 8px 12px; }
.btn.small { font-size: 14px; padding: 8px 14px; box-shadow-width: 3px; }

/* Dashboard */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.page-head h1 { font-size: 34px; font-weight: 800; }
.quiz-card {
  display: flex; align-items: center; gap: 16px; background: var(--surface); border-radius: var(--radius);
  padding: 18px 22px; margin-bottom: 14px; box-shadow: 0 5px 0 var(--surface-d);
}
.quiz-card .info { flex: 1; }
.quiz-card .title { font-size: 22px; font-weight: 800; }
.quiz-card .meta { font-size: 14px; color: var(--muted); font-weight: 600; }
.quiz-card .actions { display: flex; gap: 8px; }
.empty { text-align: center; color: var(--muted); font-weight: 600; padding: 50px 0; font-size: 18px; }

.newquiz { background: var(--surface); border-radius: var(--radius); padding: 20px; margin-bottom: 22px; box-shadow: 0 5px 0 var(--surface-d); display: flex; gap: 12px; }
.newquiz.hidden { display: none; }

/* Inputs */
input[type=text], input[type=email], input[type=password], textarea, input[type=number] {
  font-family: inherit; font-size: 17px; color: var(--ink); background: var(--bg);
  border: 2px solid transparent; border-radius: 12px; padding: 11px 14px; width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--blue); }
textarea { resize: vertical; min-height: 60px; }
label { font-size: 14px; font-weight: 700; color: var(--muted); }

/* Editor */
.editor-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.quiz-title-input { font-size: 28px; font-weight: 800; background: transparent; border: none; flex: 1; padding: 6px 4px; }
.quiz-title-input:focus { border-bottom: 2px solid var(--blue); }

/* Zwei-Spalten-Layout */
.editor-cols { display: grid; grid-template-columns: 1fr 2fr; gap: 22px; align-items: start; }
.col-left { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 16px; }

.settings-box { background: var(--surface); border-radius: var(--radius); box-shadow: 0 5px 0 var(--surface-d); overflow: hidden; }
.settings-title { font-weight: 800; font-size: 16px; padding: 14px 18px 6px; }
.settings-body { padding: 0 18px 10px; }

.q-form { background: var(--surface); border-radius: var(--radius); box-shadow: 0 5px 0 var(--surface-d); padding: 18px; }
.q-form.placeholder { color: var(--muted); font-weight: 600; text-align: center; padding: 46px 22px; line-height: 1.4; }
.qf-head { font-size: 18px; font-weight: 800; color: var(--red); margin-bottom: 14px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 0; border-bottom: 1px solid rgba(0,0,0,.07); }
.settings-row:last-child { border-bottom: none; }
.settings-row label { flex: 1; line-height: 1.3; }
.hint-sub { font-weight: 600; font-size: 12px; color: var(--muted); }
.settings-row input[type=number] { width: 90px; flex-shrink: 0; text-align: center; }
.st-toggle { width: 60px; height: 32px; border-radius: 20px; background: var(--surface-d); position: relative; flex-shrink: 0; }
.st-toggle.on { background: var(--green); }
.st-knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.3); transition: left .15s; }
.st-toggle.on .st-knob { left: 31px; }

.q-field { margin-bottom: 12px; }
.q-field > label { display: block; margin-bottom: 4px; }
.q-form textarea { min-height: 56px; }

/* Kachel-Grid (rechte Spalte) */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tile {
  background: var(--surface); border-radius: 14px; box-shadow: 0 4px 0 var(--surface-d);
  padding: 12px 14px; cursor: pointer; min-height: 112px; display: flex; flex-direction: column; gap: 8px;
  transition: transform .08s; user-select: none;
}
.tile:hover { transform: translateY(-2px); }
.tile.active { outline: 3px solid var(--blue); outline-offset: 1px; }
.tile.dragging { opacity: .4; }
.tile-top { display: flex; align-items: center; gap: 8px; }
.tile-num { font-weight: 800; font-size: 16px; color: var(--red); }
.tile-valid { font-weight: 800; font-size: 16px; }
.tile-valid.ok { color: var(--green-d); }
.tile-valid.bad { color: var(--red); }
.tile-del { margin-left: auto; background: transparent; font-size: 16px; opacity: .55; }
.tile-del:hover { opacity: 1; }
.tile-text {
  font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.3;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.tile-add {
  border: 3px dashed var(--surface-d); background: transparent; color: var(--muted);
  font-size: 38px; font-weight: 800; box-shadow: none; align-items: center; justify-content: center;
}
.tile-add:hover { border-color: var(--red); color: var(--red); transform: none; }

.answers-edit { display: flex; flex-direction: column; gap: 10px; }
.answer-row { display: flex; align-items: center; gap: 12px; }
.answer-row .dot { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; }
.answer-row .dot.red { background: var(--red); }
.answer-row .dot.yellow { background: var(--yellow); }
.answer-row .dot.blue { background: var(--blue); }
.answer-row .correct-pick { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.answer-row.is-correct .correct-pick { color: var(--green-d); }
.answer-row input[type=radio] { width: 20px; height: 20px; accent-color: var(--green); }

/* Media */
.media-box { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.media-preview { max-height: 120px; max-width: 220px; border-radius: 12px; box-shadow: 0 3px 0 var(--surface-d); }
.media-preview audio { width: 240px; }
.media-tag { font-size: 13px; color: var(--muted); font-weight: 700; }

/* Hintergrundbild-Auswahl */
.bg-control { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.bg-thumb { height: 56px; max-width: 110px; object-fit: cover; border-radius: 10px; box-shadow: 0 3px 0 var(--surface-d); }

.add-q { width: 100%; background: var(--surface); color: var(--ink); border: 3px dashed var(--surface-d); border-radius: var(--radius); padding: 18px; font-size: 18px; font-weight: 800; }
.add-q:hover { color: var(--red); border-color: var(--red); }
.danger { color: var(--red); }

/* ----------------------------------------------------- Dark Mode */
html[data-theme="dark"] {
  --bg: #15161c; --ink: #f3f3f8; --muted: #9a9aab; --surface: #232530; --surface-d: #0d0e15;
}
html[data-theme="dark"] .settings-row { border-bottom-color: rgba(255,255,255,.08); }
html[data-theme="dark"] .tile-add { border-color: #3a3c4a; }
html[data-theme="dark"] input::placeholder, html[data-theme="dark"] textarea::placeholder { color: #6b6b78; }

/* ----------------------------------------------------- Login / Auth */
.auth-card {
  max-width: 420px; margin: 9vh auto 0; background: var(--surface);
  border-radius: var(--radius); padding: 32px; box-shadow: 0 8px 0 var(--surface-d);
}
.auth-title { font-size: 30px; font-weight: 800; font-style: italic; color: var(--red); text-align: center; margin-bottom: 20px; }
.auth-title span { color: var(--ink); font-style: normal; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tab { flex: 1; background: var(--bg); color: var(--muted); font-weight: 800; font-size: 15px; padding: 10px; border-radius: 12px; }
.auth-tab.active { background: var(--blue); color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-error { color: var(--red); font-weight: 700; font-size: 14px; min-height: 18px; }
.auth-submit { margin-top: 4px; width: 100%; }

.head-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { font-weight: 800; color: var(--muted); white-space: nowrap; }
