/* ==========================================================================
   TED Live – Designsystem
   ========================================================================== */
:root {
  --font-sans: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Georgia", "Times New Roman", serif;
  --font-rounded: "Nunito", "Varela Round", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Consolas", "SFMono-Regular", monospace;
  --font: var(--font-sans);

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --surface-3: #e6eaf2;
  --border: #e2e6ef;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f6df5;
  --primary-2: #3b57e0;
  --primary-soft: rgba(79, 109, 245, .12);
  --primary-contrast: #ffffff;
  --accent: #22d3ee;
  --success: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, .12);
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
.theme-dark {
  --bg: #0b1020;
  --surface: #121a2e;
  --surface-2: #182238;
  --surface-3: #1f2b45;
  --border: #243252;
  --text: #eef2ff;
  --muted: #8b97b8;
  --primary-soft: rgba(79, 109, 245, .2);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -16px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; letter-spacing: -.01em; font-weight: 700; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd { font-family: var(--font-mono); font-size: .9em; }
kbd { background: var(--surface-3); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
::selection { background: var(--primary); color: #fff; }

/* Icons ------------------------------------------------------------------ */
.i { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.i.sm { width: 15px; height: 15px; } .i.lg { width: 24px; height: 24px; } .i.xl { width: 40px; height: 40px; }

/* Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .92rem;
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s, box-shadow .15s, opacity .15s;
  white-space: nowrap; user-select: none; text-decoration: none !important; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); border-color: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); box-shadow: 0 6px 16px -8px var(--primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #1a1200; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn.soft:hover { background: var(--primary); color: #fff; }
.btn.danger-soft { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn.danger-soft:hover { background: var(--danger); color: #fff; }
.btn.sm { padding: 6px 10px; font-size: .82rem; border-radius: var(--radius-xs); }
.btn.lg { padding: 13px 22px; font-size: 1.05rem; border-radius: var(--radius); }
.btn.icon { padding: 8px; width: 36px; height: 36px; }
.btn.icon.sm { width: 30px; height: 30px; padding: 5px; }
.btn.block { width: 100%; }
.btn.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.btngroup { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.btngroup .btn { border: 0; border-radius: 0; border-right: 1px solid var(--border); }
.btngroup .btn:last-child { border-right: 0; }

/* Forms ------------------------------------------------------------------ */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label, .field { display: flex; flex-direction: column; gap: 6px; font-size: .86rem; font-weight: 600; color: var(--muted); }
.form label > small { font-weight: 400; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px; outline: none; width: 100%;
  transition: border-color .15s, box-shadow .15s; font-weight: 500;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; min-height: 80px; }
input[type="color"] { padding: 2px; width: 44px; height: 36px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--primary); }
select { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.code-input { font-family: var(--font-mono); font-size: 1.8rem; letter-spacing: .3em; text-align: center; text-transform: uppercase; padding: 14px; }
.inline-check { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; cursor: pointer; }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; color: var(--text); font-size: .9rem; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 22px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); position: relative; transition: background .2s; flex: 0 0 auto; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* Cards / surfaces ------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card.pad-sm { padding: 14px; }
.card.flat { box-shadow: none; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title h2, .card-title h3 { margin: 0; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; background: var(--surface-3); color: var(--muted); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.success { background: rgba(22,163,74,.15); color: var(--success); }
.badge.warn { background: rgba(245,158,11,.18); color: #b45309; }
.theme-dark .badge.warn { color: #fbbf24; }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .82rem; font-weight: 600; }
.chip .x { cursor: pointer; opacity: .6; } .chip .x:hover { opacity: 1; color: var(--danger); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); font-size: .9rem; margin-bottom: 12px; }
.alert.danger { background: var(--danger-soft); border-color: rgba(239,68,68,.35); color: var(--danger); }
.alert.success { background: rgba(22,163,74,.12); border-color: rgba(22,163,74,.35); color: var(--success); }
.alert.warn { background: rgba(245,158,11,.14); border-color: rgba(245,158,11,.4); }
.alert.info { background: var(--primary-soft); border-color: rgba(79,109,245,.35); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .i { width: 42px; height: 42px; opacity: .5; margin-bottom: 8px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.table tr:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Toast */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-lg); animation: toastin .25s var(--ease); display: flex; gap: 8px; align-items: center; }
.toast.danger { background: var(--danger); color: #fff; } .toast.success { background: var(--success); color: #fff; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Modal */
.overlay { position: fixed; inset: 0; background: rgba(2, 6, 23, .55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 900; padding: 20px; animation: fadein .15s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; animation: modalin .2s var(--ease); }
.modal.wide { width: min(860px, 100%); }
@keyframes modalin { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }

/* Skeleton / spinner */
.spinner { width: 22px; height: 22px; border: 3px solid var(--surface-3); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth / centred layouts ------------------------------------------------ */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, var(--primary-soft), transparent 60%), radial-gradient(800px 500px at 110% 110%, rgba(34,211,238,.12), transparent 60%), var(--bg); }
.auth-card { width: min(440px, 100%); padding: 32px; }
.auth-card.center { text-align: center; }
.auth-card .form { text-align: left; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; margin-bottom: 18px; letter-spacing: -.02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--primary), var(--accent)); box-shadow: 0 6px 14px -6px var(--primary); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 9px; border-radius: 3px; background: rgba(255,255,255,.9); clip-path: polygon(0 60%, 33% 60%, 33% 20%, 66% 20%, 66% 45%, 100% 45%, 100% 100%, 0 100%); }
.steps { display: flex; gap: 8px; margin-bottom: 18px; }
.step { font-size: .78rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.step.on { background: var(--primary-soft); color: var(--primary); }

/* Admin layout ----------------------------------------------------------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 4px 8px; margin-bottom: 10px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 600; text-decoration: none !important; transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.sidebar .spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-top: 1px solid var(--border); margin-top: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; flex: 0 0 auto; }
.main { padding: 26px 32px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.topbar-mobile { display: none; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 18px; }
.survey-card { display: flex; flex-direction: column; gap: 14px; cursor: pointer; transition: transform .15s var(--ease), box-shadow .15s; position: relative; overflow: hidden; padding: 22px 22px 18px 26px; min-height: 230px; }
.survey-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--sc, var(--primary)); }
.survey-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.survey-card h3 { margin: 0; font-size: 1.25rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.survey-card .meta { display: flex; gap: 14px; color: var(--muted); font-size: .84rem; flex-wrap: wrap; }
.survey-card .meta span { display: inline-flex; align-items: center; gap: 5px; }
.survey-card .kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.survey-card .kpi { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; }
.survey-card .kpi b { display: block; font-size: 1.25rem; line-height: 1.1; letter-spacing: -.02em; }
.survey-card .kpi span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.survey-card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.search { position: relative; }
.search input { padding-left: 36px; min-width: 240px; }
.search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.lobby.solo { grid-template-columns: 1fr; text-align: center; }
.code-pill { font-family: var(--font-mono); font-weight: 700; letter-spacing: .12em; background: var(--surface-2); border: 1px dashed var(--border); padding: 3px 10px; border-radius: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 1.5rem; line-height: 1.1; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }

/* Editor layout */
.editor { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
.editor .side { position: sticky; top: 20px; }
.qlist { display: flex; flex-direction: column; gap: 10px; }
.qitem { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.qitem:hover { border-color: var(--primary); }
.qitem.active { border-color: var(--primary); background: var(--primary-soft); }
.qitem .handle { cursor: grab; color: var(--muted); }
.qitem .num { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-3); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; flex: 0 0 auto; }
.qitem .qt { font-weight: 600; }
.qitem .qtype { font-size: .75rem; color: var(--muted); }
.qitem.dragging { opacity: .4; }
.qitem.drop-before { box-shadow: 0 -3px 0 0 var(--primary); }
.qitem.drop-after { box-shadow: 0 3px 0 0 var(--primary); }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.type-tile { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 12px; cursor: pointer; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 600; font-size: .85rem; transition: all .15s; }
.type-tile:hover, .type-tile.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.type-tile .i { width: 26px; height: 26px; }
.opt-row { display: flex; gap: 8px; align-items: center; }
.opt-row .num { width: 26px; text-align: center; color: var(--muted); font-weight: 700; font-size: .8rem; }
.lang-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.lang-tabs button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; text-transform: uppercase; color: var(--muted); }
.lang-tabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.lang-tabs button.missing { border-style: dashed; }
.chart-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.chart-picker button { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-xs); padding: 6px 8px; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .8rem; font-weight: 600; }
.chart-picker button.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="text"] { width: 110px; font-family: var(--font-mono); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.swatch.active { border-color: var(--text); }
.preview-frame { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

/* Regie (Live-Steuerung) */
.control { display: grid; grid-template-columns: 1fr 420px; gap: 20px; align-items: start; }
.ctrl-q { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.ctrl-q.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.ctrl-q.open { border-color: var(--success); }
.ctrl-q .qt { font-weight: 600; }
.ctrl-q .st { font-size: .75rem; color: var(--muted); }
.ctrl-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.bigbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bigbtns .btn { padding: 14px; font-size: 1rem; }
.live-preview { border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; background: #000; border: 1px solid var(--border); }
.live-preview iframe { width: 100%; height: 100%; border: 0; pointer-events: none; }
.qr-box { background: #fff; padding: 12px; border-radius: 12px; display: inline-block; }
.qr-box svg { display: block; width: 180px; height: 180px; }

/* Results (admin) */
.result-card .chart-host { min-height: 260px; }
.result-card .chart-host svg { width: 100%; height: auto; display: block; }

/* Responsive ------------------------------------------------------------- */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s var(--ease); z-index: 800; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .topbar-mobile { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 700; }
  .main { padding: 16px; }
  .editor, .control { grid-template-columns: 1fr; }
  .editor .side { position: static; }
  .row2, .row3 { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Teilnehmer-Seite (vote.php) – nutzt das Umfrage-Design über --p-* Variablen
   ========================================================================== */
.vote-body {
  --p-primary: #4f6df5; --p-accent: #22d3ee; --p-bg: #0f172a; --p-bg2: #1e293b; --p-text: #f8fafc;
  --p-surface: rgba(255,255,255,.07); --p-border: rgba(255,255,255,.14); --p-muted: rgba(255,255,255,.62);
  --p-radius: 16px;
  background: linear-gradient(160deg, var(--p-bg), var(--p-bg2)); color: var(--p-text); min-height: 100vh; min-height: 100dvh;
  font-family: var(--font);
}
.vote-body.light { --p-surface: rgba(0,0,0,.05); --p-border: rgba(0,0,0,.12); --p-muted: rgba(0,0,0,.55); }
.vote-body.r-sm { --p-radius: 8px; } .vote-body.r-lg { --p-radius: 26px; }
.vote-wrap { max-width: 560px; margin: 0 auto; padding: 18px 16px 40px; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.vote-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.vote-head .title { font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.vote-head img.logo { max-height: 42px; max-width: 150px; object-fit: contain; }
.vote-lang select { background-color: var(--p-surface); color: var(--p-text); border: 1px solid var(--p-border); border-radius: 999px; padding: 6px 30px 6px 12px; font-size: .85rem; font-weight: 700; width: auto;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; }
.vote-lang select option { color: #000; }
.vote-main { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.vcard { background: var(--p-surface); border: 1px solid var(--p-border); border-radius: var(--p-radius); padding: 22px; backdrop-filter: blur(8px); animation: vin .3s var(--ease); }
@keyframes vin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.vcard h1 { font-size: 1.45rem; margin-bottom: 8px; }
.vcard h2 { font-size: 1.3rem; }
.vcard .desc { color: var(--p-muted); margin-bottom: 14px; }
.vote-progress { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--p-muted); margin-bottom: 8px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; }
.vote-progress > span { white-space: nowrap; }
.vote-progress .bar { height: 4px; background: var(--p-border); border-radius: 4px; margin-top: 8px; overflow: hidden; width: 100%; }
.vote-progress .bar i { display: block; height: 100%; background: var(--p-primary); border-radius: 4px; transition: width .4s var(--ease); }
.v-input { background: var(--p-surface); border: 1px solid var(--p-border); color: var(--p-text); border-radius: calc(var(--p-radius) * .7); padding: 14px 16px; font-size: 1.05rem; }
.v-input::placeholder { color: var(--p-muted); }
.v-input:focus { border-color: var(--p-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--p-primary) 30%, transparent); }
.v-btn { width: 100%; padding: 15px 18px; border-radius: calc(var(--p-radius) * .8); border: 0; font: inherit; font-weight: 800; font-size: 1.05rem; cursor: pointer; background: var(--p-primary); color: #fff; box-shadow: 0 10px 24px -10px var(--p-primary); transition: transform .1s, filter .15s, opacity .15s; display: inline-flex; gap: 8px; align-items: center; justify-content: center; }
.v-btn:hover { filter: brightness(1.08); } .v-btn:active { transform: translateY(1px); } .v-btn:disabled { opacity: .5; cursor: not-allowed; }
.v-btn.secondary { background: var(--p-surface); border: 1px solid var(--p-border); color: var(--p-text); box-shadow: none; }
.options { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: calc(var(--p-radius) * .75); border: 2px solid var(--p-border); background: var(--p-surface); cursor: pointer; transition: border-color .15s, background .15s, transform .1s; font-weight: 600; font-size: 1.02rem; user-select: none; -webkit-tap-highlight-color: transparent; }
.opt:active { transform: scale(.99); }
.opt .mark { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--p-border); flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; transition: all .15s; }
.opt.multi .mark { border-radius: 7px; }
.opt.selected { border-color: var(--p-primary); background: color-mix(in srgb, var(--p-primary) 18%, transparent); }
.opt.selected .mark { background: var(--p-primary); border-color: var(--p-primary); }
.opt.selected .mark::after { content: ""; width: 7px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }
.opt .oc { width: 10px; height: 10px; border-radius: 50%; margin-left: auto; flex: 0 0 auto; }
.scale { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.scale button { flex: 1 1 44px; min-width: 44px; height: 54px; border-radius: 12px; border: 2px solid var(--p-border); background: var(--p-surface); color: var(--p-text); font: inherit; font-weight: 800; font-size: 1.15rem; cursor: pointer; transition: all .15s; }
.scale button.selected, .scale button:hover { border-color: var(--p-primary); background: var(--p-primary); color: #fff; }
.scale-labels { display: flex; justify-content: space-between; color: var(--p-muted); font-size: .82rem; margin-top: 8px; }
.words { display: flex; flex-direction: column; gap: 8px; }
.sent-box { text-align: center; padding: 28px 10px; }
.sent-box .check { width: 64px; height: 64px; border-radius: 50%; background: var(--p-primary); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px; animation: pop .35s var(--ease); }
.sent-box .check .i { width: 32px; height: 32px; stroke: #fff; stroke-width: 3; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.vote-results { margin-top: 6px; }
.vote-results .rrow { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.vote-results .rlabel { display: flex; justify-content: space-between; font-weight: 600; font-size: .95rem; }
.vote-results .rbar { height: 10px; background: var(--p-border); border-radius: 6px; overflow: hidden; }
.vote-results .rbar i { display: block; height: 100%; background: var(--p-primary); border-radius: 6px; transition: width .6s var(--ease); }
.vote-foot { text-align: center; color: var(--p-muted); font-size: .78rem; margin-top: 22px; }
.waiting { text-align: center; padding: 30px 10px; }
.waiting .pulse { width: 80px; height: 80px; border-radius: 50%; margin: 0 auto 16px; background: color-mix(in srgb, var(--p-primary) 25%, transparent); position: relative; display: flex; align-items: center; justify-content: center; }
.waiting .pulse::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--p-primary); animation: ring 1.8s ease-out infinite; }
.waiting .pulse .i { width: 34px; height: 34px; stroke: var(--p-primary); }
@keyframes ring { 0% { transform: scale(.8); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
.offline-bar { position: fixed; top: 0; left: 0; right: 0; background: var(--danger); color: #fff; text-align: center; font-size: .82rem; font-weight: 700; padding: 6px; z-index: 50; }
.v-error { color: #fecaca; background: rgba(239,68,68,.2); border: 1px solid rgba(239,68,68,.4); padding: 10px 12px; border-radius: 10px; font-size: .9rem; margin-bottom: 12px; }
.vote-body.light .v-error { color: #b91c1c; }

/* ==========================================================================
   Präsentation (present.php)
   ========================================================================== */
.present-body {
  --p-primary: #4f6df5; --p-accent: #22d3ee; --p-bg: #0f172a; --p-bg2: #1e293b; --p-text: #f8fafc;
  --p-surface: rgba(255,255,255,.06); --p-border: rgba(255,255,255,.12); --p-muted: rgba(255,255,255,.6); --p-radius: 18px;
  background: linear-gradient(160deg, var(--p-bg), var(--p-bg2)); color: var(--p-text); height: 100vh; overflow: hidden; font-family: var(--font); cursor: default;
}
.present-body.light { --p-surface: rgba(0,0,0,.05); --p-border: rgba(0,0,0,.1); --p-muted: rgba(0,0,0,.55); }
.present-body.r-sm { --p-radius: 8px; } .present-body.r-lg { --p-radius: 30px; }
.present-body.hide-cursor { cursor: none; }
.stage { position: relative; height: 100vh; display: grid; grid-template-rows: auto 1fr auto; padding: 2.2vh 3vw; gap: 1.5vh; }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 6vh; }
.stage-head .title { font-weight: 800; font-size: clamp(16px, 2.2vh, 30px); letter-spacing: -.01em; opacity: .9; }
.stage-head img.logo { max-height: 7vh; max-width: 22vw; object-fit: contain; }
.stage-head.logo-right { flex-direction: row-reverse; }
.stage-main { position: relative; min-height: 0; display: grid; grid-template-columns: 1fr; align-content: stretch; }
.slide { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 2vh; animation: slidein .45s var(--ease); min-height: 0; }
@keyframes slidein { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.slide .qtitle { font-size: clamp(22px, 4.2vh, 62px); font-weight: 800; line-height: 1.15; letter-spacing: -.02em; margin: 0; }
.slide .qdesc { color: var(--p-muted); font-size: clamp(14px, 2.2vh, 28px); margin: 0; }
.slide .qno { font-size: clamp(12px, 1.6vh, 20px); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--p-accent); }
.chart-area { flex: 1; min-height: 0; position: relative; }
.chart-area svg { width: 100%; height: 100%; display: block; }
.chart-area .nodata { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--p-muted); font-size: clamp(16px, 3vh, 34px); font-weight: 600; }
.stage-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; min-height: 4vh; color: var(--p-muted); font-size: clamp(12px, 1.7vh, 20px); }
.stage-foot .join { display: flex; align-items: center; gap: 1.2vw; }
.stage-foot .join .code { font-family: var(--font-mono); font-weight: 800; letter-spacing: .18em; color: var(--p-text); font-size: clamp(14px, 2.4vh, 30px); }
.stage-foot .join .url { font-weight: 600; }
.stage-foot .qr { background: #fff; padding: .6vh; border-radius: 1vh; width: 11vh; height: 11vh; flex: 0 0 auto; }
.stage-foot .qr svg { width: 100%; height: 100%; display: block; }
.stage-foot .counter { display: flex; align-items: center; gap: .6vw; font-weight: 700; color: var(--p-text); }
.stage-foot .counter b { font-size: clamp(16px, 3vh, 40px); }
.stage-foot .counter .i { width: 2.6vh; height: 2.6vh; }
.status-pill { display: inline-flex; align-items: center; gap: .5vw; padding: .4vh 1.2vh; border-radius: 999px; background: var(--p-surface); border: 1px solid var(--p-border); font-weight: 700; font-size: clamp(11px, 1.6vh, 18px); }
.status-pill.open { color: #4ade80; border-color: rgba(74,222,128,.5); }
.status-pill.open::before { content: ""; width: 1vh; height: 1vh; border-radius: 50%; background: #4ade80; animation: pulse 1.2s infinite; }
.status-pill.closed { color: var(--p-muted); }
.lobby { display: grid; grid-template-columns: 1.2fr 1fr; align-items: center; gap: 4vw; height: 100%; }
.lobby .big { font-size: clamp(28px, 6vh, 90px); font-weight: 900; letter-spacing: -.03em; line-height: 1.05; }
.lobby .text { font-size: clamp(16px, 2.6vh, 34px); color: var(--p-muted); margin-top: 2vh; }
.lobby .joinbox { background: var(--p-surface); border: 1px solid var(--p-border); border-radius: var(--p-radius); padding: 3vh; display: flex; flex-direction: column; align-items: center; gap: 2vh; text-align: center; }
.lobby .joinbox .qrbig { background: #fff; padding: 1.4vh; border-radius: 1.6vh; width: min(34vh, 34vw); height: min(34vh, 34vw); }
.lobby .joinbox .qrbig svg { width: 100%; height: 100%; display: block; }
.lobby .joinbox .url { font-size: clamp(14px, 2.4vh, 30px); font-weight: 700; word-break: break-all; }
.lobby .joinbox .code { font-family: var(--font-mono); font-size: clamp(28px, 6vh, 80px); font-weight: 900; letter-spacing: .2em; color: var(--p-primary); }
.lobby .joinbox .hint { color: var(--p-muted); font-size: clamp(12px, 1.8vh, 22px); }
.end-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; gap: 2vh; }
.end-screen .big { font-size: clamp(32px, 8vh, 110px); font-weight: 900; letter-spacing: -.03em; }
.end-screen .text { font-size: clamp(16px, 2.8vh, 36px); color: var(--p-muted); }
.qr-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.75); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 2vh; z-index: 20; animation: fadein .2s; }
.qr-overlay .qrbig { background: #fff; padding: 2vh; border-radius: 2vh; width: min(60vh, 80vw); height: min(60vh, 80vw); }
.qr-overlay .qrbig svg { width: 100%; height: 100%; }
.qr-overlay .url { font-size: clamp(16px, 3vh, 40px); font-weight: 800; color: #fff; }
.present-help { position: absolute; bottom: 2vh; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.7); color: #fff; padding: 1vh 2vh; border-radius: 999px; font-size: clamp(11px, 1.6vh, 16px); display: flex; gap: 1.6vh; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 30; }
.present-body.show-help .present-help { opacity: 1; }
.present-help kbd { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.2); color: #fff; }
.present-toolbar { position: absolute; top: 1.5vh; right: 1.5vw; display: flex; gap: .6vh; opacity: 0; transition: opacity .25s; z-index: 30; }
.present-body:not(.hide-cursor) .present-toolbar:hover, .present-body.show-help .present-toolbar { opacity: 1; }
.present-toolbar button { background: rgba(0,0,0,.55); color: #fff; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; padding: .8vh 1.4vh; cursor: pointer; font: inherit; font-size: clamp(11px, 1.5vh, 15px); font-weight: 700; display: inline-flex; gap: .6vh; align-items: center; backdrop-filter: blur(6px); }
.present-toolbar button:hover { background: rgba(0,0,0,.8); }
.present-toolbar .i { width: 1.8vh; height: 1.8vh; }
.stage-foot .footer-text { font-size: clamp(11px, 1.5vh, 18px); opacity: .8; }
.present-body.embed .present-toolbar, .present-body.embed .present-help { display: none; }

/* Hintergrundbild (Teilnehmer + Präsentation) */
.bg-layer { position: fixed; inset: -2vh; z-index: 0; background-size: cover; background-position: center; background-repeat: no-repeat; pointer-events: none; }
.vote-body.has-bg { background: var(--p-bg); }
.present-body.has-bg { background: var(--p-bg); }
.vote-body.has-bg .vote-wrap, .present-body.has-bg .stage { position: relative; z-index: 1; }
.has-bg .vcard { background: color-mix(in srgb, var(--p-bg) 55%, transparent); }

/* Countdown */
.countdown { display: inline-flex; align-items: center; gap: .8vh; font-weight: 800; color: var(--p-text); }
.countdown svg { width: 6vh; height: 6vh; transform: rotate(-90deg); }
.countdown svg circle { fill: none; stroke-width: 4; }
.countdown svg .track { stroke: var(--p-border); }
.countdown svg .bar { stroke: var(--p-accent); stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.countdown .num { font-size: clamp(16px, 3.4vh, 44px); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: center; }
.countdown.urgent .num { color: #f87171; animation: pulse .6s infinite; }
.countdown.urgent svg .bar { stroke: #f87171; }
.stage-head .countdown { margin-left: auto; margin-right: 2vw; }
.vote-countdown { display: flex; align-items: center; gap: 8px; font-weight: 800; font-variant-numeric: tabular-nums; }
.vote-countdown .bar { flex: 1; height: 6px; border-radius: 4px; background: var(--p-border); overflow: hidden; }
.vote-countdown .bar i { display: block; height: 100%; background: var(--p-accent); border-radius: 4px; transition: width .25s linear; }
.vote-countdown.urgent { color: #f87171; }
.vote-countdown.urgent .bar i { background: #f87171; }

/* Design-Reiter kompakt */
.design-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; align-items: start; }
.design-form .span2 { grid-column: 1 / -1; }
.design-form .field, .design-form label { gap: 4px; font-size: .8rem; }
.design-form input, .design-form select { padding: 6px 10px; font-size: .9rem; }
.design-form input[type="color"] { width: 34px; height: 30px; padding: 1px; }
.design-form .color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.design-form .color-row { gap: 6px; }
.design-form .color-row input[type="text"] { width: 84px; padding: 4px 8px; font-size: .8rem; }
.design-form .color-row .lbl { font-size: .78rem; color: var(--muted); }
.design-form .switches { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.design-form .switch { font-size: .82rem; }
.design-form .switch .track { width: 34px; height: 20px; }
.design-form .switch .track::after { width: 14px; height: 14px; }
.design-form .switch input:checked + .track::after { transform: translateX(14px); }
.design-form .presets { display: flex; flex-wrap: wrap; gap: 5px; }
.design-form .presets .btn { padding: 3px 9px; font-size: .75rem; gap: 5px; }
.design-form .section { grid-column: 1 / -1; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; margin-top: 2px; }
.design-form .section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.design-form .thumb { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); background-size: cover; background-position: center; border: 1px solid var(--border); background-color: var(--surface-2); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .8rem; }
.design-form .range { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); }
.design-form .range input[type="range"] { flex: 1; padding: 0; accent-color: var(--primary); }
.design-form .range b { min-width: 3ch; text-align: right; color: var(--text); }
@media (max-width: 640px) { .design-form, .design-form .color-grid, .design-form .switches { grid-template-columns: 1fr; } }
@media (max-width: 800px), (max-aspect-ratio: 1/1) {
  .lobby { grid-template-columns: 1fr; text-align: center; }
  .lobby .joinbox .qrbig { width: min(30vh, 60vw); height: min(30vh, 60vw); }
}
@media print {
  body { background: #fff !important; color: #000 !important; }
  .sidebar, .topbar-mobile, .toasts, .btn { display: none !important; }
}
