.kbsp-theme-toggle {
  position: fixed;
  right: 11px;
  bottom: 14px;
  z-index: 69;
  display: flex;
  align-items: center;
  gap: 0;
  width: 44px;
  min-height: 44px;
  overflow: hidden;
  padding: 7px 12px;
  border: 1px solid rgb(71 85 105 / 25%);
  border-radius: 999px;
  background: rgb(248 250 252 / 78%);
  color: rgb(30 41 59 / 75%);
  box-shadow: 0 4px 14px rgb(15 23 42 / 8%);
  font: 700 12px "DejaVu Sans", "Trebuchet MS", sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: width .2s ease, gap .2s ease, background .2s ease, color .2s ease, box-shadow .2s ease;
}
.kbsp-theme-toggle.with-feedback { bottom: 60px; }
.kbsp-theme-toggle:focus-visible { width:148px; gap:7px; outline:2px solid var(--accent, var(--brand, #1f5f59)); outline-offset:2px; background:#fff; color:#334155; }
.kbsp-theme-icon { flex:0 0 18px; font-size:18px; line-height:1; text-align:center; }
.kbsp-theme-label { opacity:0; transition:opacity .15s ease; }
.kbsp-theme-toggle:focus-visible .kbsp-theme-label { opacity:1; }
@media (hover:hover) {
  .kbsp-theme-toggle:hover { width:148px; gap:7px; background:#fff; color:#334155; box-shadow:0 7px 20px rgb(15 23 42 / 16%); }
  .kbsp-theme-toggle:hover .kbsp-theme-label { opacity:1; }
}

html[data-theme="dark"] {
  --bg:#0b1220;
  --panel:#172033;
  --card:#172033;
  --ink:#e8eef8;
  --muted:#aab7ca;
  --stroke:#3a465a;
  --accent:#5eead4;
  --brand:#5eead4;
  --brand-dark:#2dd4bf;
  --danger:#f87171;
}
html[data-theme="dark"] body {
  color:var(--ink);
  background:radial-gradient(900px 500px at 15% -10%,#17324a 0,transparent 60%),radial-gradient(900px 500px at 85% 10%,#31234f 0,transparent 60%),var(--bg);
  background-attachment:fixed;
  background-repeat:no-repeat;
}
html[data-theme="dark"] header { border-color:var(--stroke); background:rgb(17 26 43 / 90%); }
html[data-theme="dark"] .brand-title span,
html[data-theme="dark"] .admin-badge span,
html[data-theme="dark"] .kbsp-brand-title span { text-shadow:0 1px #0b1220,0 -1px #0b1220,1px 0 #0b1220,-1px 0 #0b1220; }
html[data-theme="dark"] .date-phrase { color:#d8e2ef; }
html[data-theme="dark"] .flip-colon,
html[data-theme="dark"] .flip-clock .colon { color:#cbd5e1; }
html[data-theme="dark"] .magnet-weekday { border-color:#31556b; background:#163247; color:#bae6fd; }
html[data-theme="dark"] .magnet-num { border-color:#70561f; background:#3b3018; color:#fde68a; }
html[data-theme="dark"] .magnet-month { border-color:#28644f; background:#183b31; color:#a7f3d0; }
html[data-theme="dark"] .panel,
html[data-theme="dark"] .card,
html[data-theme="dark"] .staff-panel,
html[data-theme="dark"] .menu-row,
html[data-theme="dark"] .change,
html[data-theme="dark"] .item,
html[data-theme="dark"] .event,
html[data-theme="dark"] .detail-card,
html[data-theme="dark"] .metric { border-color:var(--stroke); background:var(--card); box-shadow:0 12px 32px rgb(0 0 0 / 28%); }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .button,
html[data-theme="dark"] .back-link,
html[data-theme="dark"] .card-link,
html[data-theme="dark"] .sign-out,
html[data-theme="dark"] .tab,
html[data-theme="dark"] .copy,
html[data-theme="dark"] .row-action { border-color:var(--stroke); background:#202b3e; color:var(--ink); }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color:#8190a5; }
html[data-theme="dark"] .button.primary,
html[data-theme="dark"] button.primary,
html[data-theme="dark"] .tab.active,
html[data-theme="dark"] .card-link.primary,
html[data-theme="dark"] .auth-submit { border-color:#0d9488; background:#0f766e; color:#fff; }
html[data-theme="dark"] .modal,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .info-card,
html[data-theme="dark"] .edit-popover { border-color:var(--stroke); background:#172033; color:var(--ink); box-shadow:0 24px 60px rgb(0 0 0 / 52%); }
html[data-theme="dark"] .modal-backdrop,
html[data-theme="dark"] .auth-modal,
html[data-theme="dark"] .info-modal { background:rgb(2 6 15 / 72%); }
html[data-theme="dark"] .auth-error,
html[data-theme="dark"] .error { color:#fca5a5; }
html[data-theme="dark"] table { background:#111a2b; color:var(--ink); }
html[data-theme="dark"] th { background:#1d293c; color:#cbd5e1; }
html[data-theme="dark"] th,
html[data-theme="dark"] td { border-color:var(--stroke); }
html[data-theme="dark"] .context { background:#111a2b; color:var(--muted); }
html[data-theme="dark"] .planned { background:#293548; color:#cbd5e1; }
html[data-theme="dark"] .privacy,
html[data-theme="dark"] .equation,
html[data-theme="dark"] .hint { border-color:#2f766d; background:#123c3a; color:#b9f8eb; }
html[data-theme="dark"] .equation.warning,
html[data-theme="dark"] .item.urgent { border-color:#c26926; background:#3a2b1f; color:#fed7aa; }
html[data-theme="dark"] .review { border-color:#8b6528; background:#33291b; }
html[data-theme="dark"] .bar { background:#303b4d; }
html[data-theme="dark"] .info-button,
html[data-theme="dark"] #infoBtn { border-color:#3b65a0; background:#172e52; color:#93c5fd; }
html[data-theme="dark"] .new-staff-form { border-color:#2f766d; background:#12302d; }
html[data-theme="dark"] .context { background:#111a2b; }
html[data-theme="dark"] .state { background:#14532d; color:#bbf7d0; }
html[data-theme="dark"] .inactive .state { background:#334155; color:#cbd5e1; }
html[data-theme="dark"] .revert,
html[data-theme="dark"] .row-action { color:#fdba74; }
html[data-theme="dark"] .email-state { color:#fdba74; }
.status[data-error="true"] { color:#b91c1c; }
html[data-theme="dark"] .status[data-error="true"] { color:#fca5a5; }

html[data-theme="dark"] .kbsp-feedback-button { border-color:rgb(251 191 36 / 25%); background:rgb(49 46 40 / 82%); color:rgb(253 230 138 / 75%); }
html[data-theme="dark"] .kbsp-feedback-button:hover,
html[data-theme="dark"] .kbsp-feedback-button:focus-visible { background:#3a3021; color:#fde68a; }
html[data-theme="dark"] .kbsp-feedback-card,
html[data-theme="dark"] .kbsp-links-card { background:#172033; color:var(--ink); }
html[data-theme="dark"] .kbsp-feedback-card p,
html[data-theme="dark"] .kbsp-feedback-card label,
html[data-theme="dark"] .kbsp-links-note { color:var(--muted); }
html[data-theme="dark"] .kbsp-feedback-card select,
html[data-theme="dark"] .kbsp-feedback-card textarea { border-color:var(--stroke); background:#202b3e; color:var(--ink); }
html[data-theme="dark"] .kbsp-feedback-urgent { border-color:#9a5a24; background:#3a2b1f; color:#fed7aa; }
html[data-theme="dark"] .kbsp-feedback-urgent small { color:#fed7aa; }
html[data-theme="dark"] .kbsp-feedback-status { color:#e2e8f0 !important; }
html[data-theme="dark"] .kbsp-link-item { border-color:var(--stroke); border-left-color:#2dd4bf; background:#202b3e; color:var(--ink); }
html[data-theme="dark"] .kbsp-link-item:hover { background:#123c3a; }
html[data-theme="dark"] .kbsp-link-main span { color:var(--muted); }
html[data-theme="dark"] .kbsp-link-copy { border-color:var(--stroke); color:#aab7ca; }
html[data-theme="dark"] .kbsp-links-empty,
html[data-theme="dark"] .kbsp-links-close { border-color:var(--stroke); background:#202b3e; color:var(--ink); }
html[data-theme="dark"] .kbsp-theme-toggle { border-color:rgb(148 163 184 / 28%); background:rgb(30 41 59 / 84%); color:#facc15; }
html[data-theme="dark"] .kbsp-theme-toggle:focus-visible { background:#263348; color:#fde68a; }
@media (hover:hover) { html[data-theme="dark"] .kbsp-theme-toggle:hover { background:#263348; color:#fde68a; } }

/* Timetable admin and planning */
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .calendar-toggle,
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .calendar-panel,
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .calendar-nav,
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .filter select,
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .toggle-btn,
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .print-btn,
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .email-btn,
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .infos-btn,
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .staff-btn { border-color:var(--stroke); background:#202b3e; color:var(--ink); }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .calendar-toggle svg { stroke:var(--ink); }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .calendar-day { background:#253146; color:var(--ink); }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .calendar-day.selected { border-color:#e2e8f0; background:#334155; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .calendar-day.today { background:#1e3a5f; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .calendar-day.has-change { background:#713f12; color:#fef3c7; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .table-wrap { background:#111a2b; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] thead th,
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .corner-header { background:#1d293c; color:#cbd5e1; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] thead tr.header-periods th { background:#172235; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] tbody th { background:#1a2638; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] tbody tr:nth-child(even) td { background:#131e30; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .entry { color:#172033; border-color:rgb(15 23 42 / 20%); }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .entry-line { color:#1f2937; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .class-notes-highlight { background:#713f12; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .now-day { background:#664d12; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .now-period { background:#4d3c17; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .now-cell { background:rgb(245 158 11 / 16%); }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .notes-list { background:#111a2b; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .note-item,
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .email-item { border-color:var(--stroke); background:#202b3e; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .note-item.reply { background:#2b281d; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .note-text { color:var(--ink); }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .pause-row th,
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .pause-row td,
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .pause-column { background:#312416; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .pause-header { background:#422e13; color:#fdba74; }
html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .pause-override-text { background:#f8fafc; color:#111827; }

html[data-theme="dark"][data-theme-page="admin_timetable_planning"] .planning-actions,
html[data-theme="dark"][data-theme-page="admin_pause_supervision"] .head-actions { border-color:var(--stroke); background:rgb(17 26 43 / 90%); }
html[data-theme="dark"][data-theme-page="admin_timetable_planning"] .planning-info { border-color:#3b65a0 !important; background:#172e52 !important; color:#bfdbfe !important; }
html[data-theme="dark"][data-theme-page="admin_timetable_planning"] .entry { color:#172033; }
html[data-theme="dark"][data-theme-page="admin_timetable_planning"] .entry-line { color:#1f2937; }
html[data-theme="dark"][data-theme-page="admin_timetable_planning"] tbody tr:nth-child(even) td { background:#131e30; }

/* Pause supervision */
html[data-theme="dark"][data-theme-page="admin_pause_supervision"] table { background:#111a2b; }
html[data-theme="dark"][data-theme-page="admin_pause_supervision"] .duty { border-color:#64748b; }
html[data-theme="dark"][data-theme-page="admin_pause_supervision"] .duty.first,
html[data-theme="dark"][data-theme-page="admin_pause_supervision"] .toilet-note { background:#facc15; color:#111827; }
html[data-theme="dark"][data-theme-page="admin_pause_supervision"] .duty button:hover { background:#173653; }
html[data-theme="dark"][data-theme-page="admin_pause_supervision"] .weekly-replacement { background:#14532d !important; color:#bbf7d0 !important; }
html[data-theme="dark"][data-theme-page="admin_pause_supervision"] .weekly-new { color:#86efac; }

/* Dashboard */
html[data-theme="dark"][data-theme-page="dashboard_today"] .topbar,
html[data-theme="dark"][data-theme-page="dashboard_today"] .left-head,
html[data-theme="dark"][data-theme-page="dashboard_today"] .ticker-shell,
html[data-theme="dark"][data-theme-page="dashboard_today"] .frame-wrap,
html[data-theme="dark"][data-theme-page="dashboard_today"] iframe { border-color:var(--stroke); background:#111a2b; }
html[data-theme="dark"][data-theme-page="dashboard_today"] .ticker-item { border-color:var(--stroke); background:#202b3e; }
html[data-theme="dark"][data-theme-page="dashboard_today"] .ticker-item.upcoming { background:#312416; }
html[data-theme="dark"][data-theme-page="dashboard_today"] .section h2,
html[data-theme="dark"][data-theme-page="dashboard_today"] .ticker-item { color:#e2e8f0; }
html[data-theme="dark"][data-theme-page="dashboard_today"] .ticker-item.upcoming,
html[data-theme="dark"][data-theme-page="dashboard_today"] .ticker-empty { color:#bac6d6; }
html[data-theme="dark"][data-theme-page="dashboard_today"] .maintenance-card { border-color:var(--stroke); background:#172033; color:var(--ink); }
html[data-theme="dark"][data-theme-page="dashboard_today"] .maintenance-card h1 { color:#5eead4; }
html[data-theme="dark"][data-theme-page="dashboard_today"] .maintenance-card p { color:#cbd5e1; }
html[data-theme="dark"][data-theme-page="dashboard_today"] .maintenance-kicker { background:#312416; color:#fdba74; }

html[data-theme="dark"][data-theme-page="public_overview"] .change strong { color:#5eead4; }

/* System console is dark-first; provide its light counterpart. */
html[data-theme="light"][data-theme-page="system_console"] { --night:#f6f1ea; --panel:#fffdf8; --panel-2:#fff; --ink:#1f2937; --muted:#64748b; --line:#d6cbbf; --mint:#15803d; --cyan:#0e7490; --yellow:#a16207; --pink:#be185d; --violet:#6d28d9; --orange:#c2410c; }
html[data-theme="light"][data-theme-page="system_console"] body { background:radial-gradient(900px 500px at 15% -10%,#fff3e3 0,transparent 60%),radial-gradient(900px 500px at 85% 10%,#e6f4ff 0,transparent 60%),var(--night); }
html[data-theme="light"][data-theme-page="system_console"] header { background:rgb(255 253 248 / 90%); }
html[data-theme="light"][data-theme-page="system_console"] .metric,
html[data-theme="light"][data-theme-page="system_console"] .panel { background:linear-gradient(145deg,#fff,#fffaf5); box-shadow:0 14px 38px rgb(31 41 55 / 10%); }
html[data-theme="light"][data-theme-page="system_console"] .toolbar input,
html[data-theme="light"][data-theme-page="system_console"] .toolbar select,
html[data-theme="light"][data-theme-page="system_console"] .auth-card { background:#fff; color:var(--ink); }
html[data-theme="light"][data-theme-page="system_console"] table { background:#fff; }
html[data-theme="light"][data-theme-page="system_console"] th { background:#f3eee8; color:#475569; }

@media print {
  .kbsp-theme-toggle,
  .kbsp-feedback-button,
  .kbsp-feedback-modal,
  .kbsp-links-modal { display:none !important; }
  html[data-theme="dark"] { color-scheme:light; --bg:#fff; --panel:#fff; --card:#fff; --ink:#1f2937; --muted:#6b7280; --stroke:#d6cbbf; }
  html[data-theme="dark"] body,
  html[data-theme="dark"] header,
  html[data-theme="dark"] .panel,
  html[data-theme="dark"] .card,
  html[data-theme="dark"] .staff-panel,
  html[data-theme="dark"] table,
  html[data-theme="dark"] .context { background:#fff !important; color:#1f2937 !important; box-shadow:none !important; }
  html[data-theme="dark"] th { background:#faf7f3 !important; color:#374151 !important; }
  html[data-theme="dark"] input,
  html[data-theme="dark"] select,
  html[data-theme="dark"] textarea { background:#fff !important; color:#111827 !important; }
  html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] tbody tr:nth-child(even) td,
  html[data-theme="dark"][data-theme-page="admin_timetable_planning"] tbody tr:nth-child(even) td { background:#fdfbf7 !important; }
  html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .pause-row th,
  html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .pause-row td,
  html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .pause-column { background:#fff7ed !important; color:#1f2937 !important; }
  html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .class-header.class-notes-highlight,
  html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] tbody th.class-notes-highlight { background:#fff3cd !important; color:#1f2937 !important; }
  html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .now-day { background:#fff0b5 !important; color:#1f2937 !important; }
  html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .now-period { background:#fff6cf !important; color:#1f2937 !important; }
  html[data-theme="dark"][data-theme-page="stundenplan_grid_admin"] .pause-header { background:#fef3c7 !important; color:#7c2d12 !important; }
  html[data-theme="dark"][data-theme-page="admin_pause_supervision"] table,
  html[data-theme="dark"][data-theme-page="admin_pause_supervision"] .context { background:#fff !important; color:#1f2937 !important; }
  html[data-theme="dark"][data-theme-page="admin_pause_supervision"] .duty.first,
  html[data-theme="dark"][data-theme-page="admin_pause_supervision"] .toilet-note { background:#fff500 !important; color:#111 !important; }
  html[data-theme="dark"][data-theme-page="admin_pause_supervision"] .weekly-replacement { background:#d8f3e8 !important; color:#166534 !important; }
  html[data-theme="dark"][data-theme-page="admin_pause_supervision"] .weekly-new { color:#166534 !important; }
}
