:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --primary: #4f6bff;
  --primary-ink: #fff;
  --danger: #e5484d;
  --ink: #1d2433;
  --muted: #6b7385;
  --line: #e3e7ef;
  --surface: #ffffff;
  --surface-2: #f4f6fb;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(20, 30, 60, .18), 0 2px 6px rgba(20, 30, 60, .08);
  /* Abgeleitete Akzent-Töne und Marken-Elemente (Themes überschreiben diese) */
  --primary-hover: #3f59e8;
  --primary-soft: #e6ebff;
  --primary-softer: #f0f3ff;
  --primary-line: #b9c4ff;
  --primary-rgb: 79, 107, 255;
  --brand-gradient: linear-gradient(135deg, #4f7cff 0%, #7b5cff 100%);
  --page-bg: #eef1f8;
  --line-strong: #c4cbe0;
  --font-display: var(--font);
  --heading: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--page-bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.boot { display: grid; place-items: center; gap: 12px; height: 100vh; color: var(--muted); align-content: center; }

/* ---------- Buttons & Inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink);
  transition: transform .06s, background .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #cf3a3f; }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn.active { outline: 2px solid var(--primary); }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 4px 7px; border-radius: 8px; color: var(--muted); font-size: 1rem; line-height: 1; }
.icon-btn:hover { background: rgba(0,0,0,.07); color: var(--ink); }
.link-btn { border: 0; background: none; color: var(--primary); cursor: pointer; padding: 4px; }
.input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.input:focus, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.input-sm { width: auto; padding: 4px 6px; font-size: .85rem; }
textarea.input { resize: vertical; }
.field { display: grid; gap: 5px; flex: 1; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.stack h4 { margin: 8px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.chip:hover, .chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(0,0,0,.12); cursor: pointer; padding: 0; }
.swatch.active { outline: 3px solid var(--primary); outline-offset: 2px; }
.color-input { width: 40px; height: 34px; border: 0; padding: 0; background: none; cursor: pointer; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: var(--brand-gradient);
}
.login-card { width: min(420px, 100%); background: #fff; border-radius: 20px; padding: 32px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.login-brand { display: flex; gap: 14px; align-items: center; }
.login-brand h1 { margin: 0; font-size: 1.8rem; }
.login-brand p { margin: 2px 0 0; color: var(--muted); }
.login-form { display: grid; gap: 14px; }
.form-error { background: #fdecec; color: #a3262b; padding: 10px 12px; border-radius: 10px; font-size: .92rem; }
.btn-iserv { background: #005f9e; border-color: #005f9e; color: #fff; padding: 12px; }
.btn-iserv:hover { background: #004f84; }
.iserv-mark { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: #fff; color: #005f9e; font-weight: 800; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Übersicht (Meine Decks) ---------- */
.overview { min-height: 100vh; background: var(--page-bg); }
.overview-top {
  position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px; background: rgba(255,255,255,.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.overview-brand { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; }
.overview-top .pill { box-shadow: none; background: var(--surface-2); }
.overview-content { max-width: 1280px; margin: 0 auto; padding: 28px 24px 48px; display: grid; gap: 14px; }
.overview-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.overview-head h1 { margin: 0 0 4px; font-size: 1.7rem; }
.overview-head p { margin: 0; }
.deck-search { width: 240px; }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; margin-top: 6px; }
.deck-card {
  display: flex; flex-direction: column; background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(20,30,60,.08), 0 4px 14px rgba(20,30,60,.06); transition: box-shadow .15s, transform .15s;
}
.deck-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.deck-open { border: 0; padding: 0; background: none; cursor: pointer; display: block; }
.deck-preview-wrap { aspect-ratio: 16 / 10; background: #1b1f2a; display: grid; place-items: center; overflow: hidden; }
.deck-preview { position: relative; max-height: 100%; overflow: hidden; }
.mini-widget {
  position: absolute; display: grid; place-items: center; overflow: hidden;
  background: rgba(255,255,255,.92); border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.18); font-size: 13px;
}
.deck-info { padding: 10px 10px 12px 14px; display: grid; gap: 2px; }
.deck-title-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 34px; }
.deck-name {
  border: 0; background: none; padding: 4px 6px; margin-left: -6px; border-radius: 8px; cursor: text;
  font-weight: 700; font-size: 1.02rem; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.deck-name:hover { background: var(--surface-2); }
.deck-name-input { padding: 5px 8px; font-weight: 700; }
.deck-meta { color: var(--muted); font-size: .82rem; }
.deck-new {
  border: 2px dashed var(--line-strong); background: transparent; box-shadow: none; cursor: pointer; min-height: 220px;
  align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-weight: 700;
}
.deck-new:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-softer); }
.deck-new-plus { font-size: 2.2rem; line-height: 1; }
.home-btn { display: grid; place-items: center; padding: 6px 9px; }

/* ---------- App-Shell ---------- */
.shell { position: fixed; inset: 0; overflow: hidden; }
.board { position: absolute; inset: 0; transition: background .3s; }
.widget-layer { position: absolute; inset: 0; }

/* Festes Seitenverhältnis: Folie wird mittig eingepasst, Rest als Rand (Letterbox) */
.shell.letterbox { background: #12151c; }
.board.fixed {
  inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(100vw, calc(100vh * var(--ar))); height: min(100vh, calc(100vw / var(--ar)));
  box-shadow: 0 0 0 1px rgba(255,255,255,.06);
}
.widget.enter { animation: slide-in .22s ease-out; }
@keyframes slide-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* Folien-Navigation */
.slide-nav {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px; padding: 5px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-radius: 999px; box-shadow: 0 2px 10px rgba(0,0,0,.12);
  transition: opacity .25s;
}
.nav-btn { border: 0; background: transparent; border-radius: 999px; min-width: 34px; height: 30px; font-size: 1.35rem; cursor: pointer; line-height: 1; }
.nav-btn:hover:not(:disabled) { background: var(--surface-2); }
.nav-btn:disabled { opacity: .3; cursor: default; }
.nav-counter { border: 0; background: var(--surface-2); border-radius: 999px; height: 30px; padding: 0 12px; font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums; }
.nav-counter:hover { background: var(--primary-soft); }
.nav-sep { width: 1px; align-self: stretch; background: var(--line); margin: 4px 3px; }
.chrome-hidden .slide-nav { opacity: .25; }
.chrome-hidden .slide-nav:hover { opacity: 1; }
.chrome-hidden .slide-nav .nav-sep, .chrome-hidden .slide-nav .nav-btn:last-child { display: none; }

/* Raster: Hilfslinien beim Ziehen, Vorschau-Rahmen, Einrast-Animation */
.grid-guides { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 0; }
.board.snapping .grid-guides { opacity: 1; }
.guide-cell { position: absolute; border: 2px dashed rgba(255,255,255,.55); border-radius: 12px; background: rgba(255,255,255,.07); }
.guide-cell.guide-side { background: rgba(255,255,255,.14); }
.snap-ghost {
  position: absolute; z-index: 99999; pointer-events: none; border-radius: var(--radius);
  background: rgba(var(--primary-rgb), .18); border: 3px solid rgba(255,255,255,.9); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .6);
  transition: left .08s, top .08s, width .08s, height .08s;
}
.widget.snap-anim { transition: left .18s ease-out, top .18s ease-out, width .18s ease-out, height .18s ease-out; }

/* Raster-Auswahl im Deck-Dialog */
.layout-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.layout-tile {
  display: grid; justify-items: center; gap: 6px; padding: 10px 8px; border: 2px solid var(--line);
  border-radius: 12px; background: #fff; cursor: pointer; font-size: .85rem;
}
.layout-tile:hover { border-color: var(--primary-line); }
.layout-tile.active { border-color: var(--primary); background: var(--primary-softer); }
.layout-sketch { position: relative; width: 96px; aspect-ratio: 16 / 10; border-radius: 6px; background: var(--brand-gradient); overflow: hidden; }
.layout-sketch i { position: absolute; box-sizing: border-box; border: 2px solid transparent; background-clip: padding-box; background-color: rgba(255,255,255,.75); border-radius: 4px; }
.layout-sketch i.side { background-color: rgba(255,230,150,.9); }
.layout-sketch.layout-free::after { content: "frei"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 700; }
@media (max-width: 700px) { .layout-grid, .aspect-grid { grid-template-columns: repeat(2, 1fr); } }

/* Format-Auswahl im Deck-Dialog */
.aspect-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.aspect-tile {
  display: grid; justify-items: center; gap: 4px; padding: 12px 8px; text-align: center;
  border: 2px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer;
}
.aspect-tile:hover { border-color: var(--primary-line); }
.aspect-tile.active { border-color: var(--primary); background: var(--primary-softer); }
.aspect-tile small { color: var(--muted); font-size: .75rem; }
.aspect-shape { display: block; height: 42px; width: auto; border-radius: 4px; background: var(--brand-gradient); }
.aspect-shape[data-flex="1"] { width: 56px; background: repeating-linear-gradient(135deg, #c7d0ff 0 6px, #e6eaff 6px 12px); border: 2px dashed #8796ff; }
.topbar {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 100000;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.topbar > * { pointer-events: auto; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }
.pill {
  border: 0; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,.12);
  max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pill:hover { background: #fff; }
.icon-pill { padding: 8px 11px; }
.save-status { font-size: .8rem; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.4); padding: 0 6px; }
.save-status[data-state="error"] { color: #ffd2d2; font-weight: 700; }

.dock {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 100000;
  display: flex; align-items: stretch; gap: 2px; padding: 6px; max-width: calc(100vw - 24px); overflow-x: auto;
  background: rgba(255,255,255,.95); backdrop-filter: blur(10px); border-radius: 18px; box-shadow: var(--shadow);
  transition: opacity .25s, transform .25s;
  scrollbar-width: thin;
}
.dock-btn {
  display: grid; justify-items: center; gap: 2px; min-width: 64px; padding: 6px 6px 4px;
  border: 0; background: transparent; border-radius: 12px; cursor: pointer;
}
.dock-btn:hover { background: var(--surface-2); }
.dock-btn:active { transform: scale(.95); }
.dock-icon { font-size: 1.55rem; line-height: 1.1; }
.dock-label { font-size: .68rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.dock-sep { width: 1px; background: var(--line); margin: 6px 4px; }

/* Einklappbare Widget-Leiste */
.dock-collapse .dock-icon { font-size: 1.3rem; line-height: 1.3; color: var(--muted); }
.dock-tab {
  position: absolute; left: 50%; bottom: 0; z-index: 100000; transform: translate(-50%, 110%);
  border: 0; cursor: pointer; padding: 7px 18px 9px; border-radius: 14px 14px 0 0;
  background: rgba(255,255,255,.95); backdrop-filter: blur(10px); box-shadow: 0 -2px 12px rgba(20,30,60,.18);
  font-weight: 700; font-size: .85rem; color: var(--ink); transition: transform .25s ease;
}
.dock-tab:hover { background: #fff; }
.dock-collapsed .dock { opacity: 0; transform: translate(-50%, 120%); pointer-events: none; }
.dock-collapsed .dock-tab { transform: translate(-50%, 0); }
.chrome-hidden .dock-tab { transform: translate(-50%, 110%); }

.chrome-hidden .dock { opacity: 0; transform: translate(-50%, 120%); pointer-events: none; }
.chrome-hidden .topbar-left { opacity: 0; pointer-events: none; }
.chrome-hidden .topbar-right > :not(:first-child) { display: none; }
.chrome-hidden .topbar-right { opacity: .35; }
.chrome-hidden .topbar-right:hover { opacity: 1; }
.chrome-hidden .widget-head { opacity: 0; }
.chrome-hidden .widget:hover .widget-head { opacity: 1; }

.popover {
  position: fixed; z-index: 200000; min-width: 220px; max-height: 70vh; overflow: auto;
  background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: grid;
}
.popover hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.popover-item { text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.popover-item:hover:not(:disabled) { background: var(--surface-2); }
.popover-item:disabled { color: var(--muted); cursor: default; font-size: .85rem; }
.popover-item.danger { color: var(--danger); }

/* ---------- Modal & Toast ---------- */
.modal { border: 0; border-radius: 18px; padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow); color: var(--ink); }
.modal.wide { width: min(860px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(15, 20, 35, .45); backdrop-filter: blur(2px); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 0; }
.modal h2 { margin: 0; font-size: 1.2rem; }
.modal-body { padding: 16px 20px; max-height: 70vh; overflow: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }
.settings { display: grid; gap: 14px; }
.toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 300000; display: grid; gap: 8px; }
.toast { background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); transition: opacity .4s, transform .4s; }
.toast-error { background: #b42318; }
.toast-success { background: #127a4a; }
.toast.out { opacity: 0; transform: translateY(-8px); }

.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.bg-tile { aspect-ratio: 16 / 10; border-radius: 10px; border: 2px solid rgba(0,0,0,.08); cursor: pointer; }
.bg-tile:hover { outline: 3px solid var(--primary); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.gallery-quota { grid-column: 1 / -1; }
.thumb-wrap { position: relative; }
.thumb { width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; background: #f3f3f3; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-del { position: absolute; top: 4px; right: 4px; border: 0; border-radius: 50%; width: 22px; height: 22px; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: .7rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 12px; display: grid; }
.stat b { font-size: 1.4rem; }
.stat span { color: var(--muted); font-size: .8rem; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.table .center { text-align: center; }
.badge { padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--surface-2); }
.badge-iserv { background: #dcecf8; color: #005f9e; }

/* ---------- Widget-Rahmen ---------- */
.widget {
  position: absolute; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  min-width: 120px; min-height: 80px;
}
.widget.dragging { box-shadow: 0 20px 50px rgba(20,30,60,.3); opacity: .96; }
.widget-head {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 4px 6px 4px 12px; cursor: grab; user-select: none; touch-action: none;
  font-size: .78rem; font-weight: 700; color: var(--muted); transition: opacity .2s;
}
.widget.dragging .widget-head { cursor: grabbing; }
/* Auf allen Folien angeheftete Widgets */
.pin-btn { filter: grayscale(1); opacity: .55; }
.pin-btn:hover { opacity: 1; filter: none; }
.pin-btn.active { filter: none; opacity: 1; background: var(--primary-soft); }
.widget.shared { box-shadow: var(--shadow), 0 0 0 2px rgba(var(--primary-rgb), .55); }
.widget-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.widget-actions { display: flex; flex-shrink: 0; }
.widget-body { position: relative; flex: 1; min-height: 0; container-type: size; display: flex; flex-direction: column; }
.widget-resize {
  position: absolute; right: 0; bottom: 0; width: 22px; height: 22px; cursor: nwse-resize; touch-action: none; z-index: 2;
  background: linear-gradient(135deg, transparent 55%, rgba(0,0,0,.18) 55%, rgba(0,0,0,.18) 62%, transparent 62%, transparent 72%, rgba(0,0,0,.18) 72%, rgba(0,0,0,.18) 79%, transparent 79%);
}
.controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.round { min-width: 46px; height: 46px; border-radius: 999px; padding: 0 12px; font-size: 1.05rem; }

.big-digits {
  font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: -.02em; line-height: 1;
  font-size: min(42cqh, 21cqw); border: 0; background: none; padding: 0; cursor: default; color: var(--ink);
}
button.big-digits { cursor: pointer; }

/* Timer / Stoppuhr */
.timer { position: relative; flex: 1; display: grid; place-items: center; align-content: center; gap: 6cqh; padding: 8px 12px 14px; }
/* Knöpfe schrumpfen mit, damit der Timer auch in ein kleines Seitenleistenfeld passt */
.timer .controls { flex-wrap: nowrap; gap: clamp(4px, 2cqw, 8px); }
.timer .round { min-width: clamp(28px, 24cqh, 46px); height: clamp(28px, 24cqh, 46px); padding: 0 clamp(6px, 3cqw, 12px); font-size: clamp(.8rem, 10cqh, 1.05rem); }
.timer .round .icon { width: clamp(14px, 11cqh, 20px); height: clamp(14px, 11cqh, 20px); }
.timer-progress { position: absolute; left: 0; bottom: 0; height: 6px; width: 100%; background: var(--primary); transform-origin: left; transition: transform .2s linear; }
.widget-body.warning .big-digits { color: #d97706; }
.widget-body.finished { animation: flash 1s ease-in-out 4; }
.widget-body.finished .big-digits { color: var(--danger); }
@keyframes flash { 50% { background: #ffe1e1; } }

/* Uhr */
.clock { flex: 1; display: grid; place-items: center; align-content: center; gap: 4cqh; padding: 8px; }
.clock-date { font-size: min(10cqh, 6cqw); color: var(--muted); font-weight: 600; text-align: center; }
.clock .analog { height: 72cqh; max-width: 90cqw; }
.clock.is-analog .clock-date { font-size: min(8cqh, 6cqw); }
.analog .face { fill: #fff; stroke: var(--ink); stroke-width: 2.5; }
.analog .mark { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.analog .hand { stroke: var(--ink); stroke-linecap: round; }
.analog .hour { stroke-width: 4.5; }
.analog .minute { stroke-width: 3; }
.analog .second { stroke: var(--danger); stroke-width: 1.2; }
.analog .pin { fill: var(--danger); }

/* Text */
.widget-text .widget-body { background: var(--note-bg, #fff6b3); }
.widget-text:has(.note-transparent) { background: transparent; box-shadow: none; }
.widget-text:has(.note-transparent) .widget-head { opacity: .0; }
.widget-text:has(.note-transparent):hover .widget-head { opacity: 1; background: rgba(255,255,255,.8); }
.note-transparent .note { color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.45); }
.note {
  flex: 1; width: 100%; border: 0; resize: none; background: transparent; outline: none;
  padding: 6px 16px 16px; font-size: calc(clamp(14px, 8cqmin, 64px) * var(--note-scale, 1)); line-height: 1.35;
}

/* Zufallsname */
.names { flex: 1; display: grid; place-items: center; align-content: center; gap: 4cqh; padding: 6px 8px 10px; text-align: center; min-height: 0; }
.name-display { font-size: min(30cqh, 14cqw); font-weight: 800; line-height: 1.1; word-break: break-word; }
.name-display.placeholder { color: var(--muted); font-size: min(12cqh, 8cqw); }
/* Buttons und Infozeile wachsen mit, damit das Widget auch in ein kleines Seitenleistenfeld passt */
.names .btn { padding: clamp(4px, 3.5cqh, 9px) clamp(8px, 5cqw, 16px); font-size: clamp(.8rem, 9cqh, 1rem); }
.names-info { font-size: clamp(.7rem, 8cqh, .85rem); }
@container (max-height: 130px) { .names-info { display: none; } }
@container (max-width: 200px) { .names .btn-primary span { display: none; } }
.name-display.pop { animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); color: var(--primary); }
@keyframes pop { 0% { transform: scale(.6); } 100% { transform: scale(1); } }

/* Gruppen */
.groups { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 4px 12px 12px; min-height: 0; }
.group-grid { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; align-content: start; }
.group-card { background: hsl(var(--hue) 80% 95%); border: 2px solid hsl(var(--hue) 60% 75%); border-radius: 12px; padding: 8px 12px; }
.group-card strong { color: hsl(var(--hue) 50% 35%); }
.group-card ul { margin: 4px 0 0; padding-left: 18px; }

/* Würfel */
.dice { flex: 1; display: grid; place-items: center; align-content: center; gap: 3cqh; padding: 8px; }
.dice-row { display: flex; gap: 6cqw; border: 0; background: none; cursor: pointer; padding: 0; }
.die {
  width: min(52cqh, 26cqw); aspect-ratio: 1; background: #fff; border: 3px solid var(--ink); border-radius: 18%;
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 12%; box-shadow: 0 4px 0 rgba(0,0,0,.15);
}
.die span { display: block; }
.die .pip { background: var(--ink); border-radius: 50%; margin: 12%; }
.dice-row.rolling .die { animation: shake .14s infinite; }
@keyframes shake { 25% { transform: rotate(8deg); } 75% { transform: rotate(-8deg); } }
.dice-sum { font-weight: 700; color: var(--muted); font-size: min(9cqh, 6cqw); }

/* Ampel */
.widget-traffic { background: #2a2f3a; }
.widget-traffic .widget-head { color: #b9c0cf; }
.widget-traffic .icon-btn { color: #b9c0cf; }
.traffic { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; align-items: center; padding: 6px; }
@container (orientation: landscape) { .traffic { flex-direction: row; } }
.light { width: min(28cqh, 80cqw); aspect-ratio: 1; border-radius: 50%; border: 0; cursor: pointer; opacity: .22; transition: opacity .2s, box-shadow .2s; }
@container (orientation: landscape) { .light { width: min(28cqw, 80cqh); } }
.light-red { background: #ff3b30; } .light-yellow { background: #ffcc00; } .light-green { background: #34c759; }
.light.on { opacity: 1; box-shadow: 0 0 30px currentColor; }
.light-red.on { box-shadow: 0 0 34px #ff3b30; } .light-yellow.on { box-shadow: 0 0 34px #ffcc00; } .light-green.on { box-shadow: 0 0 34px #34c759; }

/* Arbeitssymbole */
.symbol { flex: 1; display: grid; place-items: center; align-content: center; gap: 2cqh; border: 0; background: none; cursor: pointer; padding: 6px; }
.symbol-icon { font-size: min(52cqh, 50cqw); line-height: 1; }
.symbol-label { font-size: min(12cqh, 9cqw); font-weight: 800; }
.symbol-picker {
  position: absolute; inset: 0; background: rgba(255,255,255,.97); display: grid; padding: 8px; gap: 4px;
  grid-template-columns: repeat(auto-fill, minmax(min(60px, 30cqw), 1fr)); align-content: center;
}
.symbol-picker button { border: 0; background: var(--surface-2); border-radius: 10px; font-size: min(10cqh, 9cqw); aspect-ratio: 1; cursor: pointer; }
.symbol-picker button:hover { background: var(--primary-soft); }

/* Lautstärke */
.soundlevel { flex: 1; display: grid; align-content: center; gap: 4cqh; padding: 8px 18px 16px; justify-items: center; }
.meter { position: relative; width: 100%; height: min(26cqh, 80px); background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: #34c759; transition: width .08s linear, background .3s; border-radius: inherit; }
.meter-fill[data-level="mid"] { background: #ffcc00; }
.meter-fill[data-level="high"] { background: #ff3b30; }
.meter-mark { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--ink); opacity: .5; }
.meter-status { font-weight: 800; font-size: min(12cqh, 7cqw); }
.widget-body.too-loud { animation: flash .8s ease-in-out infinite; }

/* Umfrage */
.poll { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 4px 14px 12px; min-height: 0; }
.poll-question { font-weight: 800; font-size: clamp(14px, 8cqh, 34px); }
.poll-options { flex: 1; display: grid; gap: 6px; overflow: auto; align-content: start; }
.poll-option {
  position: relative; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer; text-align: left; overflow: hidden;
  background: var(--surface-2); font-size: clamp(13px, 6cqh, 26px); isolation: isolate;
}
.poll-option::before { content: ""; position: absolute; inset: 0; width: var(--pct); background: hsl(var(--hue) 85% 80%); z-index: -1; transition: width .3s; }
.poll-option:active { transform: scale(.99); }

/* QR */
.qr { flex: 1; display: grid; grid-template-rows: 1fr auto; place-items: center; padding: 4px 12px 12px; gap: 6px; min-height: 0; }
.qr-box { width: 100%; height: 100%; display: grid; place-items: center; min-height: 0; }
.qr-box svg { width: auto; height: 100%; max-width: 100%; aspect-ratio: 1; display: block; }
.qr-caption { font-weight: 700; font-size: clamp(11px, 6cqh, 22px); text-align: center; word-break: break-all; max-width: 100%; }

/* Zeichnen */
.draw { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.draw-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 0 10px 6px; }
.draw-tools .swatch { width: 24px; height: 24px; }
.draw-canvas { flex: 1; min-height: 0; width: 100%; background: #fff; object-fit: contain; touch-action: none; cursor: crosshair; border-top: 1px solid var(--line); }

/* Medien */
.media { flex: 1; display: grid; place-items: center; min-height: 0; background: #111; }
.media:has(button) { background: var(--surface-2); }
.media img, .media video { width: 100%; height: 100%; object-fit: contain; display: block; }
.media iframe { width: 100%; height: 100%; border: 0; }

@media (max-width: 700px) {
  .dock-label { display: none; }
  .dock-btn { min-width: 46px; }
  .pill { max-width: 160px; }
  .save-status { display: none; }
  .slide-nav { top: 46px; }
}

/* ---------- Icons (Lucide, lokales Sprite /vendor/icons.svg) ---------- */
.icon {
  width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -0.2em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: .9em; height: .9em; opacity: .6; }
.icon.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pill { display: inline-flex; align-items: center; gap: 7px; }
.pill-text { overflow: hidden; text-overflow: ellipsis; }
.icon-pill { padding: 9px 11px; }
.icon-pill .icon { width: 18px; height: 18px; }
.icon-btn { display: inline-grid; place-items: center; padding: 5px; }
.icon-btn .icon { width: 16px; height: 16px; }
.modal header .icon-btn .icon { width: 20px; height: 20px; }
.modal h2 { display: flex; align-items: center; gap: 8px; }
.modal h2 .icon { color: var(--primary); }
.nav-btn { display: inline-grid; place-items: center; }
.nav-btn .icon { width: 18px; height: 18px; }
.save-status { display: inline-flex; align-items: center; gap: 5px; }
.save-status .icon { width: 14px; height: 14px; stroke-width: 2.5; }

/* Widget-Leiste: farbige Icons in weichen Kacheln */
.dock-icon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: hsl(var(--dock-hue, 228) 90% 95%); color: hsl(var(--dock-hue, 228) 65% 48%);
  transition: transform .12s, background .12s;
}
.dock-icon .icon { width: 22px; height: 22px; }
.dock-btn:hover .dock-icon { transform: translateY(-2px); background: hsl(var(--dock-hue, 228) 90% 90%); }
.dock-btn:hover { background: transparent; }
.dock-collapse .dock-icon { background: var(--surface-2); color: var(--muted); }
.dock-tab { display: inline-flex; align-items: center; gap: 6px; }
.dock-tab .icon { width: 16px; height: 16px; }

/* Menüs */
.popover-item { display: flex; align-items: center; gap: 10px; }
.popover-item .icon { width: 17px; height: 17px; color: var(--muted); }
.popover-item.danger .icon { color: var(--danger); }
.icon-spacer { width: 17px; flex-shrink: 0; }

/* Widget-Kopf */
.widget-title { display: flex; align-items: center; gap: 6px; }
.widget-title .icon { width: 15px; height: 15px; }
.pin-btn { filter: none; opacity: .45; }
.pin-btn:hover { opacity: 1; }
.pin-btn.active { opacity: 1; color: var(--primary); background: var(--primary-soft); }
.pin-btn.active .icon { fill: currentColor; }

/* Knöpfe in Widgets */
.round .icon { width: 20px; height: 20px; }
.btn .icon { width: 17px; height: 17px; }
.btn-primary.round .icon { fill: currentColor; stroke-width: 1.5; }

/* Übersicht */
.deck-new-plus { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.deck-new-plus .icon { width: 28px; height: 28px; }
.deck-title-row .icon-btn .icon { width: 20px; height: 20px; }
.mini-widget { color: var(--primary); }
.mini-widget .icon { width: min(18px, 60%); height: min(18px, 60%); }

/* Überschriften nutzen die Display-Schrift des Themes */
h1, h2, h3, .modal h2, .overview-brand b { font-family: var(--font-display); color: var(--heading); }

/* ---------- Verwaltung (eigene Seite, #/admin/<bereich>) ---------- */
.admin-home { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.admin-crumb { color: var(--muted); font-size: 1rem; font-weight: 600; padding-left: 12px; border-left: 1px solid var(--line); }
.admin-layout {
  max-width: 1280px; margin: 0 auto; padding: 28px 24px 48px;
  display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start;
}
.admin-nav { position: sticky; top: 84px; display: grid; gap: 4px; }
.admin-nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink); text-decoration: none; font-weight: 600;
}
.admin-nav-link .icon { width: 18px; height: 18px; color: var(--muted); }
.admin-nav-link:hover { background: var(--surface-2); }
.admin-nav-link.active { background: var(--primary-soft); color: var(--primary); }
.admin-nav-link.active .icon { color: var(--primary); }
.admin-back { color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.admin-content { display: grid; gap: 18px; min-width: 0; }
.admin-content h1 { display: flex; align-items: center; gap: 10px; }
.admin-content h1 .icon { width: 26px; height: 26px; color: var(--primary); }
.admin-search { max-width: 360px; }
.admin .stats { grid-template-columns: repeat(3, 1fr); gap: 14px; }
.admin .stat { padding: 16px 18px; }
.admin .stat b { font-size: 1.8rem; }
.admin-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.admin-card .table th, .admin-card .table td { padding: 10px 14px; }
.admin-card .table tr:last-child td { border-bottom: 0; }
@media (max-width: 760px) {
  .admin-layout { grid-template-columns: 1fr; gap: 16px; padding: 16px 16px 40px; }
  .admin-nav { position: static; display: flex; flex-wrap: wrap; gap: 6px; }
  .admin-nav-link { padding: 8px 12px; }
  .admin-back { display: none; }
  .admin-crumb { display: none; }
  .admin .stats { grid-template-columns: repeat(2, 1fr); }
}

/* Erscheinungsbild */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.theme-tile {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer;
}
.theme-tile:hover { border-color: var(--primary-line); }
.theme-tile.active { border-color: var(--primary); background: var(--primary-softer); }
.theme-swatches { display: flex; flex-shrink: 0; }
.theme-swatches i { width: 22px; height: 40px; }
.theme-swatches i:first-child { border-radius: 8px 0 0 8px; }
.theme-swatches i:last-child { border-radius: 0 8px 8px 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.theme-text { display: grid; gap: 2px; }
.theme-text small { color: var(--muted); font-size: .78rem; }
.theme-check { position: absolute; top: 8px; right: 8px; color: var(--primary); width: 18px; height: 18px; stroke-width: 3; }

/* ---------- Verlaufsplan ---------- */
.plan { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 2px 12px 12px; min-height: 0; }
.plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.plan-title { font-family: var(--font-display); color: var(--heading); font-weight: 800; font-size: clamp(15px, 5.5cqmin, 30px); }
[data-theme="nwplus"] .plan-title { font-weight: 400; }
.plan-summary { color: var(--muted); font-size: clamp(11px, 3cqmin, 15px); font-variant-numeric: tabular-nums; }
.plan-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; overflow: auto; flex: 1; align-content: start; }
.plan-step {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 10px; isolation: isolate;
  border-radius: 10px; background: var(--surface-2); border: 1px solid transparent;
  font-size: clamp(13px, 4.2cqmin, 26px); transition: background .2s, opacity .2s;
}
.plan-step::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  width: var(--progress, 0%); background: rgba(var(--primary-rgb), .14); transition: width 1s linear;
}
.plan-step.active { background: var(--surface); border-color: var(--primary); box-shadow: 0 2px 10px rgba(var(--primary-rgb), .18); font-weight: 700; }
.plan-step.active .plan-time { background: var(--primary); color: var(--primary-ink); }
.plan-step.over { border-color: var(--danger); }
.plan-step.over::before { background: rgba(229, 72, 77, .14); }
.plan-step.past { opacity: .5; }
.plan-step.past .plan-label { text-decoration: line-through; text-decoration-thickness: 1px; }
[data-mode="checklist"] .plan-step { cursor: pointer; }
[data-mode="checklist"] .plan-step:hover { border-color: var(--primary-line); }
.plan-time {
  flex-shrink: 0; min-width: 3.4em; text-align: center; padding: 2px 6px; border-radius: 6px;
  font-variant-numeric: tabular-nums; font-size: .82em; font-weight: 700; background: var(--surface); color: var(--muted);
  display: inline-grid; place-items: center;
}
.plan-check { flex-shrink: 0; color: var(--primary); display: inline-grid; }
.plan-check .icon, .plan-time .icon { width: 1.1em; height: 1.1em; }
.plan-main { flex: 1; min-width: 0; display: grid; }
.plan-phase { font-size: .68em; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); font-weight: 700; }
.plan-label { overflow-wrap: anywhere; }
.plan-social {
  flex-shrink: 0; font-size: .7em; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
}
.plan-remaining {
  flex-shrink: 0; font-variant-numeric: tabular-nums; font-size: .8em; font-weight: 700; color: var(--primary);
}
.plan-step.over .plan-remaining { color: var(--danger); }
.plan-controls { display: flex; gap: 8px; justify-content: center; }
[data-theme="nwplus"] .plan-step { border-radius: 6px; }

/* Einstellungen: Tabellen-Editor */
.plan-editor { display: grid; gap: 6px; }
.plan-editor-head, .plan-editor-row { display: grid; grid-template-columns: 1.1fr 2fr 64px 1.1fr auto; gap: 6px; align-items: center; }
.plan-editor-head { font-size: .75rem; font-weight: 700; color: var(--muted); padding: 0 2px; }
.plan-editor-row .input-sm { width: 100%; padding: 6px 8px; }
.plan-editor-actions { display: flex; }
@media (max-width: 640px) {
  .plan-editor-head { display: none; }
  .plan-editor-row { grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
}