/* ============================================================
   ClassConnect — Classroom Workspace
   Design: glass cards, per-widget color identities, aurora
   background, floating dock toolbar.
   Developed by Murat & Gozde OKAL
============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  color-scheme: light;
  --brand: #4e81ad;
  --brand-light: #8fb4d9;
  --brand-dark: #3c6b94;
  --brand-text: #3c6b94;
  --navy: #16304a;
  --ink: #0d2338;
  --bar: rgba(13, 32, 51, .84);
  --panel: #ffffff;
  --panel2: #eef4f9;
  --text: #14283c;
  --muted: #4b647b;
  --border: #d7e3ee;
  --danger: #dc2626;
  --ok: #2e9956;
  --wc: var(--brand);                 /* per-widget accent color */
  --wc-fg: #ffffff;                   /* contrasting foreground on --wc fills */
  --accent: var(--brand);
  --accent2: var(--brand-dark);
  --glass: rgba(255, 255, 255, .86);
  --glass-strong: rgba(255, 255, 255, .96);
  --shadow: 0 18px 44px rgba(8, 28, 48, .28);
  --shadow-sm: 0 5px 16px rgba(8, 28, 48, .16);
  --rad: 18px;
  --rad-btn: 12px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent;
}
body.dark {
  color-scheme: dark;
  --brand-text: #8ec1f0;
  --panel: #1b3048;
  --panel2: #142639;
  --text: #eaf2fa;
  --muted: #9eb7ce;
  --border: #315375;
  --glass: rgba(20, 38, 58, .86);
  --glass-strong: rgba(20, 38, 58, .96);
  --shadow: 0 18px 44px rgba(0, 0, 0, .55);
  --shadow-sm: 0 5px 16px rgba(0, 0, 0, .4);
}
@supports not (scrollbar-color: auto) {
  *::-webkit-scrollbar { width: 8px; height: 8px; }
  *::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 40%, transparent); border-radius: 99px; }
  *::-webkit-scrollbar-track { background: transparent; }
}

html, body {
  width: 100%;
  font-family: "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
}
html.workspace-active, body.workspace-active {
  width: 100%; height: 100%;
  overflow: hidden;
}
:where(button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--wc, var(--brand));
  outline-offset: 2px;
}

/* ================= living background ================= */
#background {
  position: fixed; inset: 0; z-index: 0;
  background: linear-gradient(140deg, #7fa6cf, #2f5a85);
  transition: background .35s;
  overflow: hidden;
}
#background::before, #background::after {
  content: "";
  position: absolute;
  width: 58vmax; height: 58vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .32;
  pointer-events: none;
}
#background::before {
  background: radial-gradient(circle, #d8ecff 0%, transparent 65%);
  top: -22vmax; left: -14vmax;
  animation: drift1 26s ease-in-out infinite alternate;
}
#background::after {
  background: radial-gradient(circle, #0c2d4f 0%, transparent 65%);
  bottom: -24vmax; right: -14vmax;
  animation: drift2 34s ease-in-out infinite alternate;
}
@keyframes drift1 { from { transform: translate(0, 0) scale(1); } to { transform: translate(9vmax, 7vmax) scale(1.18); } }
@keyframes drift2 { from { transform: translate(0, 0) scale(1.12); } to { transform: translate(-8vmax, -6vmax) scale(.94); } }

#canvas { position: fixed; inset: 0; z-index: 1; }
body.has-focus #canvas { z-index: 8000; }
body.has-focus #topBar,
body.has-focus #topLeft,
body.has-focus #quickBar,
body.has-focus #toolbar,
body.has-focus #credit { opacity: 0; pointer-events: none; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; color: var(--text); }
svg { display: block; }

/* ================= per-widget color identities ================= */
.wt-text,         [data-type="text"]         { --wc: #4e81ad; }
.wt-clock,        [data-type="clock"]        { --wc: #2fa3a0; }
.wt-calendar,     [data-type="calendar"]     { --wc: #e0655f; }
.wt-timer,        [data-type="timer"]        { --wc: #b85b0a; }
.wt-stopwatch,    [data-type="stopwatch"]    { --wc: #a67608; }
.wt-traffic,      [data-type="traffic"]      { --wc: #368649; }
.wt-symbols,      [data-type="symbols"]      { --wc: #7652a0; }
.wt-picker,       [data-type="picker"]       { --wc: #c73c73; }
.wt-dice,         [data-type="dice"]         { --wc: #4a6cd1; }
.wt-sound,        [data-type="sound"]        { --wc: #268291; }
.wt-draw,         [data-type="draw"]         { --wc: #cf5224; }
.wt-qr,           [data-type="qr"]           { --wc: #476380; }
.wt-poll,         [data-type="poll"]         { --wc: #6b47c9; }
.wt-groups,       [data-type="groups"]       { --wc: #218571; }
.wt-media,        [data-type="media"]        { --wc: #c73e5c; }
.wt-schedule,     [data-type="schedule"]     { --wc: #2d76ad; }
.wt-agenda,       [data-type="agenda"]       { --wc: #368649; }
.wt-attendance,   [data-type="attendance"]   { --wc: #bd5d0c; }
.wt-scoreboard,   [data-type="scoreboard"]   { --wc: #a67608; }
.wt-weather,      [data-type="weather"]      { --wc: #2282b3; }
.wt-embed,        [data-type="embed"]        { --wc: #4e81ad; }
.wt-slideshow,    [data-type="slideshow"]    { --wc: #d14d47; }
.wt-presentation, [data-type="presentation"] { --wc: #5b46c7; }
.wt-webcam,       [data-type="webcam"]       { --wc: #0284c7; }
.wt-ambience,     [data-type="ambience"]     { --wc: #0d9488; }
.wt-stickers,     [data-type="stickers"]     { --wc: #b4690e; }
.wt-breathing,    [data-type="breathing"]    { --wc: #2a8776; }
.wt-sounds,       [data-type="sounds"]       { --wc: #ad6d0a; }
.wt-random,       [data-type="random"]       { --wc: #7652a0; }

/* ================= generic controls ================= */
.btn {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--rad-btn);
  padding: 7px 15px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: filter .15s, transform .12s, box-shadow .15s;
}
.btn:hover { filter: brightness(.96); box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(.96); }
.btn.primary {
  background: linear-gradient(180deg, var(--wc), color-mix(in srgb, var(--wc) 82%, #000));
  border-color: color-mix(in srgb, var(--wc) 75%, #000);
  color: var(--wc-fg, #fff);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .14);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 5px 16px color-mix(in srgb, var(--wc) 40%, transparent); }
.btn.is-selected {
  background: color-mix(in srgb, var(--brand) 16%, var(--panel2));
  border-color: var(--brand);
  color: var(--text);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 24%, transparent);
}
.btn.danger { color: var(--danger); }
.btn.danger-solid {
  background: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 82%, #000);
  color: #fff;
}
.btn.danger-solid:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 11px; font-size: 12.5px; min-height: 30px; }
.btn.nav { font-size: 22px; padding: 6px 14px; border-radius: 13px; min-height: 38px; min-width: 38px; }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; }

.inp {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--rad-btn);
  padding: 7px 11px;
  font-size: 14px;
}
.inp:focus { outline: 2px solid var(--wc); outline-offset: -1px; }
.grow { flex: 1; min-width: 0; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.chk { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--text); cursor: pointer; }
/* Settings checkbox rows: full-height touch targets */
.m-tab-panel .chk { min-height: 44px; gap: 10px; }
.m-tab-panel .chk input[type="checkbox"] { width: 22px; height: 22px; flex-shrink: 0; margin: 0; accent-color: var(--brand); }
.m-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.m-sec {
  margin: 18px 0 8px;
  font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .09em;
  color: var(--brand-text);
}
.m-sec:first-child { margin-top: 0; }

input[type="range"] { accent-color: var(--wc); }
/* WEB-11: brand-coloured, 20px checkboxes (widgets keep their own accent colour) */
input[type="checkbox"] { accent-color: var(--brand); width: 20px; height: 20px; flex-shrink: 0; cursor: pointer; }
body.dark input[type="checkbox"] { accent-color: var(--brand-light); }
.widget input[type="checkbox"] { accent-color: var(--wc); }

/* ================= widget windows (glass cards) ================= */
@keyframes widgetIn {
  0% { opacity: 0; transform: scale(.86) translateY(14px); }
  60% { opacity: 1; transform: scale(1.02) translateY(-2px); }
  100% { opacity: 1; transform: none; }
}
.widget {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--wc) 22%, var(--border));
  border-radius: var(--rad);
  box-shadow: var(--shadow);
  min-width: 160px;
  min-height: 110px;
  overflow: hidden;
  animation: widgetIn .28s cubic-bezier(.2, .9, .3, 1.2);
  --accent: var(--wc);
  --accent2: color-mix(in srgb, var(--wc) 80%, #000);
}
.widget::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--wc), color-mix(in srgb, var(--wc) 10%, transparent));
  z-index: 3;
  pointer-events: none;
}
.w-head {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 9px 6px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.w-head:active { cursor: grabbing; }
.widget.locked .w-head,
body.board-lock .w-head { cursor: default; }
.widget.locked .w-resize,
body.board-lock .w-resize { display: none !important; }
body.board-lock .w-head .w-close,
body.board-lock .w-head .w-ghost,
body.board-lock .w-head .w-more,
body.board-lock [data-a="reset"],
body.board-lock .poll-setup { opacity: .28; pointer-events: none; }
.w-icon {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--wc) 16%, transparent);
  color: var(--wc);
  border-radius: 9px;
  flex-shrink: 0;
}
.w-icon svg { width: 15px; height: 15px; }
.w-title {
  flex: 1; min-width: 0;
  font-size: 11.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .07em;
  color: color-mix(in srgb, var(--wc) 72%, var(--text));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
body.dark .w-title { color: color-mix(in srgb, var(--wc) 42%, var(--text)); }
.w-lock-badge { font-size: 11px; color: var(--wc); opacity: .9; flex-shrink: 0; }
.widget:not(.locked) .w-lock-badge { display: none; }
.w-btn {
  background: none; border: 0; color: var(--muted);
  width: 30px; height: 30px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s, transform .12s;
  flex-shrink: 0;
}
/* Narrow widgets move secondary chrome into ⋯ menu in two stages */
.widget.narrow .w-btn.w-focus { display: none; }
.widget.narrow-xs .w-btn.w-ghost { display: none; }
body.high-contrast .w-btn.w-ghost { opacity: .45 !important; background: none !important; color: var(--muted) !important; }
.w-btn svg { width: 14px; height: 14px; }
.w-btn:hover { background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--brand-text); transform: scale(1.08); }
.w-btn.w-close:hover { background: rgba(224, 82, 82, .18); color: var(--danger); }
.w-btn.w-ghost.on, .w-btn.w-lock.on { color: var(--brand-text); background: color-mix(in srgb, var(--brand) 18%, transparent); }
.w-body {
  flex: 1;
  position: relative;
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
}
.w-body.no-pad { padding: 0; }
.w-body.center-col, .cam-err.center-col { flex-direction: column; align-items: center; justify-content: safe center; gap: 10px; }
.w-resize {
  position: absolute; right: 0; bottom: 0;
  width: 24px; height: 24px;
  cursor: nwse-resize;
  touch-action: none;
  z-index: 4;
  background:
    linear-gradient(135deg, transparent 50%, var(--muted) 50%, var(--muted) 58%, transparent 58%,
      transparent 70%, var(--muted) 70%, var(--muted) 78%, transparent 78%) no-repeat;
  opacity: .55;
}
.w-resize:hover { opacity: 1; }
.w-footbar { display: flex; align-items: center; gap: 6px; justify-content: center; flex-wrap: wrap; padding-top: 6px; padding-right: 16px; }
body.dragging iframe { pointer-events: none; }
body.dragging { user-select: none; }

@keyframes alarmFlash {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 0 0 7px #ef4444, 0 0 38px rgba(239, 68, 68, .75); }
}
.widget.alarm { animation: alarmFlash .75s ease-in-out infinite; }
body[data-theme="focus"] .widget.alarm {
  animation: none !important;
  box-shadow: 0 0 0 5px #ef4444, var(--shadow) !important;
}
@media (prefers-reduced-motion: reduce) {
  .widget.alarm {
    animation: none !important;
    box-shadow: 0 0 0 5px #ef4444, var(--shadow) !important;
  }
}

/* ================= floating dock toolbar ================= */
#toolbar {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 5000;
  display: flex; align-items: flex-end; gap: 0;
  max-width: 97vw; overflow-x: auto; overflow-y: hidden;
  background: var(--bar);
  padding: 12px 10px 7px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 18px 44px rgba(4, 16, 28, .5);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  scrollbar-width: thin;
}
.tb-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 60px; padding: 5px 5px 6px;
  flex-shrink: 0;
  background: transparent; border: 0; border-radius: 14px;
  color: #cfe0ef;
  transition: transform .16s cubic-bezier(.2, .9, .3, 1.4), opacity .18s;
  cursor: pointer;
}
.tb-btn .ico {
  position: relative;
  width: 40px; height: 35px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--wc) 26%, rgba(255, 255, 255, .06));
  color: color-mix(in srgb, var(--wc) 35%, #fff);
  transition: box-shadow .16s, background .16s;
}
.tb-btn.is-open::after {
  content: "";
  position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%);
  width: 16px; height: 3px; border-radius: 99px;
  background: color-mix(in srgb, var(--wc) 65%, #fff);
  box-shadow: 0 0 8px var(--wc);
}
.tb-btn.is-open .ico {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--wc) 55%, #fff);
}
.tb-count {
  position: absolute; top: -3px; right: -4px;
  min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 999px;
  background: var(--wc); color: #fff;
  font-size: 9.5px; font-weight: 800; line-height: 15px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
  display: none;
}
.tb-btn.is-multi .tb-count { display: block; }
.tb-anno.on .ico {
  background: #dc2626 !important; color: #fff !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .85), 0 4px 14px rgba(220, 38, 38, .55) !important;
}
body.annotating #topBar { z-index: 8450; }
body.annotating #toolbar { z-index: 8450; }
body.annotating #toolbar .tb-btn:not(.tb-anno) { opacity: .42; pointer-events: none; }
.tb-btn .ico svg { width: 22px; height: 22px; }
.tb-btn .lbl { font-size: 11px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; opacity: .95; }
.tb-btn:hover { transform: translateY(-6px) scale(1.08); color: #fff; }
.tb-btn:hover .ico {
  background: color-mix(in srgb, var(--wc) 55%, rgba(255, 255, 255, .1));
  color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--wc) 50%, transparent);
}
.tb-btn:active { transform: translateY(-2px) scale(1.02); }
.tb-sep { width: 1px; align-self: stretch; background: rgba(198, 220, 238, .22); margin: 4px 6px; flex-shrink: 0; }

/* ================= sunny classroom (high contrast) ================= */
body.high-contrast {
  --brand-text: #0f3b66;
  --text: #051424;
  --muted: #16304a;
  --panel: #ffffff;
  --panel2: #ebf2fa;
  --border: #2c5b88;
  --glass: rgba(255, 255, 255, .98);
  --glass-strong: #ffffff;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
body.dark.high-contrast {
  --brand-text: #9cd0ff;
  --text: #ffffff;
  --muted: #cde2f7;
  --panel: #0a1624;
  --panel2: #12253b;
  --border: #72b8f5;
  --glass: rgba(10, 22, 36, .98);
  --glass-strong: #0a1624;
}
body.high-contrast .widget {
  border: 2px solid var(--border) !important;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .4) !important;
}
body.high-contrast .w-title {
  font-weight: 900 !important;
  color: var(--text) !important;
}
body.high-contrast .w-btn {
  color: var(--text) !important;
}
body.high-contrast #brand,
body.high-contrast .modal {
  border: 2px solid var(--border) !important;
}
body.high-contrast .c-time {
  background: none !important;
  -webkit-text-fill-color: var(--text) !important;
  color: var(--text) !important;
}

/* ================= top bar (brand + screens + quick bar) ================= */
#topBar {
  position: fixed; top: 14px; left: 14px; right: 14px; z-index: 5000;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  pointer-events: none;
}
#topLeft {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
  pointer-events: auto;
}
#brand {
  display: flex; align-items: center; gap: 9px;
  background: var(--glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px 13px 6px 9px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .5);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
body.dark #brand { border-color: rgba(255, 255, 255, .14); }
#brand img { height: 28px; width: auto; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.12; font-weight: 800; font-size: 14.5px; color: var(--navy); letter-spacing: .01em; }
body.dark .brand-txt { color: var(--text); }
.brand-txt small { font-size: 9px; font-weight: 700; color: var(--brand-text); text-transform: uppercase; letter-spacing: .08em; }
@media (max-width: 1180px) {
  .brand-txt small { display: none; }
}

#screensBar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  position: relative;
}
.scr-folder-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bar);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #c6d8e8;
  padding: 7px 11px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .15);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .15s ease;
  user-select: none;
}
.scr-folder-btn:hover {
  background: var(--brand);
  color: #fff;
  border-color: rgba(255, 255, 255, .3);
}
.scr-folder-btn.active-folder {
  background: color-mix(in srgb, var(--brand) 70%, var(--bar));
  color: #fff;
  border-color: var(--brand-light);
  box-shadow: 0 2px 10px rgba(78, 129, 173, .35);
}
.screens-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  position: relative;
  min-width: 0;
  flex: 1;
}
.screens-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 4px 10px;
  scroll-padding-inline: 12px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8px, #000 calc(100% - 8px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8px, #000 calc(100% - 8px), transparent);
}
.screens-tabs::-webkit-scrollbar { display: none; }
.scr-scroll {
  background: var(--bar);
  color: #c6d8e8;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  width: 22px;
  height: 32px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .12s;
  z-index: 2;
  user-select: none;
}
.scr-scroll.show { display: flex; }
.scr-scroll:hover { background: var(--brand); color: #fff; }
.scr-tab {
  display: flex; align-items: center; gap: 5px;
  background: var(--bar);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #c6d8e8;
  padding: 8px 13px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .1);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: transform .12s, background .15s;
}
.scr-tab:hover { color: #fff; transform: translateY(-2px); }
.scr-tab.active {
  background: linear-gradient(180deg, var(--brand), var(--brand-dark));
  color: #fff;
  border-color: rgba(255, 255, 255, .28);
  box-shadow: 0 6px 18px rgba(60, 107, 148, .5);
  padding: 7px 10px;
  gap: 3px;
}
.scr-b {
  background: none; border: 0; color: inherit; opacity: .8; font-size: 12px; padding: 1px 3px; border-radius: 5px;
  /* ≥32×32 hit area without making the tab taller (negative margin absorbs the extra height) */
  min-width: 32px; min-height: 32px; margin: -6px 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.scr-b:hover { opacity: 1; background: rgba(255, 255, 255, .25); }
.scr-add {
  background: var(--bar); color: #c6d8e8;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 12px;
  font-size: 17px; padding: 6px 14px;
  flex-shrink: 0;
  transition: transform .12s, background .15s;
}
.scr-add:hover { background: var(--brand); color: #fff; transform: translateY(-2px); }

/* ================= top-right quick bar ================= */
#quickBar { display: flex; gap: 6px; flex-shrink: 0; pointer-events: auto; }
.q-btn {
  background: var(--bar);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #dcebf7;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 12px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background .15s, transform .12s;
}
.q-btn svg { width: 18px; height: 18px; }
.q-btn:hover { background: var(--brand); color: #fff; transform: translateY(-3px); }

/* ================= credit ================= */
#credit {
  position: fixed; bottom: 8px; right: 14px; z-index: 4400;
  background: var(--bar);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #bfd4e6;
  font-size: 10.5px;
  padding: 5px 11px;
  border-radius: 999px;
  letter-spacing: .02em;
  pointer-events: none;
  opacity: .75;
}
#credit b { color: #fff; font-weight: 700; }
@media (max-width: 1460px) {
  body:not(.bars-hidden) #credit { display: none; }
}

/* ================= modal & toast ================= */
#modalRoot { position: fixed; inset: 0; z-index: 9000; display: flex; align-items: center; justify-content: center; overscroll-behavior: contain; }
#modalRoot.hidden { display: none; }
.modal-back { position: absolute; inset: 0; background: rgba(6, 18, 30, .55); backdrop-filter: blur(4px); }
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
.modal {
  position: relative;
  width: 92vw; max-width: 640px; max-height: 86vh;
  display: flex; flex-direction: column;
  background: var(--glass-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: modalIn .2s cubic-bezier(.2, .9, .3, 1.2);
  overscroll-behavior: contain;
}
body.dark .modal { border-color: rgba(255, 255, 255, .14); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 19px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; font-weight: 800; color: var(--navy); }
body.dark .modal-head h3 { color: var(--text); }
.modal-body { padding: 16px 19px; overflow-y: auto; }
.modal-body.has-tabs {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  flex: 1;
}
.m-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 19px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel2) 70%, transparent);
  flex-shrink: 0;
  overflow-x: auto;
}
.m-tab {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background .14s, color .14s, border-color .14s, box-shadow .14s;
}
.m-tab:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--text); }
.m-tab.on {
  background: var(--panel);
  color: var(--brand-text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.m-tab-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 19px 28px;
}
.m-btn-ico {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--brand-text);
  flex-shrink: 0;
}
.m-btn-ico svg { width: 17px; height: 17px; }
body.high-contrast input[type="checkbox"] {
  outline: 1.5px solid var(--border);
  outline-offset: -1px;
  border-radius: 4px;
}
body.high-contrast input[type="checkbox"]:checked { outline: none; }
body.high-contrast .m-tab.on {
  border-color: var(--brand);
  box-shadow: 0 0 0 1.5px var(--brand);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch {
  position: relative;
  width: 56px; height: 42px;
  border: 2px solid rgba(255, 255, 255, .6);
  outline: 1px solid var(--border);
  border-radius: 12px;
  transition: transform .14s, box-shadow .14s;
}
.swatch:hover { transform: scale(1.12) rotate(-2deg); box-shadow: var(--shadow-sm); }
.swatch.on {
  border-color: #fff;
  outline: 2.5px solid var(--brand);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 40%, transparent);
}
.swatch.on::after {
  content: "✓";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 900; color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .85), 0 0 1px rgba(0, 0, 0, .95);
}
.swatch-pat-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.swatch-pat-lbl { font-size: 10.5px; color: var(--muted); font-weight: 600; text-align: center; }
.swatch.pick { display: flex; align-items: center; justify-content: center; font-size: 17px; cursor: pointer; background: var(--panel2); position: relative; }
.swatch.pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.list-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--panel2);
}
.ta-names { width: 100%; min-height: 130px; resize: vertical; line-height: 1.5; }
.ta-names[rows] { min-height: calc(8 * 1.5em + 16px); }

#toastRoot { position: fixed; top: 66px; right: 16px; z-index: 9500; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
body.annotating #toastRoot { top: 118px; }
body.has-modal #toastRoot { top: auto; bottom: 18px; right: 18px; left: auto; transform: none; align-items: flex-end; }
@media (max-width: 640px) {
  #toastRoot { top: 64px; right: auto; left: 50%; transform: translateX(-50%); align-items: center; }
  body.has-modal #toastRoot { top: auto; bottom: 18px; left: 50%; right: auto; transform: translateX(-50%); align-items: center; }
}
.toast {
  background: var(--ink); color: #eef4fa;
  padding: 10px 19px; border-radius: 14px;
  font-size: 14px; box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, .14);
  opacity: 0; transform: translateY(-8px);
  transition: opacity .3s, transform .3s;
  max-width: min(440px, 88vw);
  pointer-events: auto;
}
.toast.show { opacity: 1; transform: none; }

/* ================= widget: text ================= */
.text-tools {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 9px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.text-tools button {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text);
  padding: 3px 8px; font-size: 13px;
}
.text-tools button:not(.dot) { min-height: 36px; min-width: 36px; }
.text-tools .dot { width: 28px; height: 28px; }
.text-tools button:hover { background: color-mix(in srgb, var(--wc) 12%, transparent); }
/* EDU-5: formatting bar only while the note is hovered or being edited
   (focus-within keeps it reachable from the keyboard and on touch screens). */
.wt-text:not(:focus-within):not(:hover) .text-tools { display: none; }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border) !important; padding: 0 !important; }
.dot.sel, .dot:hover { border-color: var(--wc) !important; transform: scale(1.12); }
.text-edit { flex: 1; padding: 12px 14px; outline: none; overflow-y: auto; line-height: 1.38; }
.text-edit ul, .text-edit ol { padding-left: 24px; margin: 6px 0; }
.text-edit li { margin-bottom: 3px; }
.text-edit mark,
.text-edit [style*="background-color"] { background: #fef08a !important; color: #111827 !important; padding: 1px 4px; border-radius: 4px; }
.text-edit[data-empty]::before { content: "Type here…"; color: var(--muted); }

/* ================= widget: clock ================= */
.clock-wrap { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 0; }
.clock-wrap[data-mode="digital"] .clock-analog { display: none; }
.clock-wrap[data-mode="analog"] .clock-digital { display: none; }
.clock-digital { text-align: center; }
.c-time {
  font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.05;
  color: var(--text);
}
.c-date { color: var(--muted); font-size: clamp(13px, 1.5vw, 17px); margin-top: 6px; font-weight: 700; }
.clock-analog { width: auto; height: auto; max-width: 100%; max-height: 100%; aspect-ratio: 1; color: var(--text); }

/* ================= widget: calendar ================= */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.cal-title { font-weight: 800; font-size: 15px; }
.cal-grid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; align-content: start; }
.cal-dow { text-align: center; font-size: 10.5px; color: var(--wc); font-weight: 800; padding: 1px 0; text-transform: uppercase; }
.cal-cell { text-align: center; font-size: 13px; padding: 3px 0; border-radius: 8px; font-weight: 600; }
.cal-cell.today {
  background: var(--wc);
  color: var(--wc-fg, #fff); font-weight: 800;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--wc) 45%, transparent);
}
.cal-foot { text-align: center; margin-top: 6px; }

/* ================= widget: timer / stopwatch ================= */
.tm-disp { font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; text-align: center; }
.tm-disp.warn { color: #d97706; }
.tm-disp.crit { color: #dc2626; }
.tm-bar {
  width: 90%; height: 14px;
  background: color-mix(in srgb, var(--text) 12%, var(--panel2));
  border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden;
}
.tm-fill {
  height: 100%;
  background: linear-gradient(90deg, color-mix(in srgb, var(--wc) 75%, #fff), var(--wc));
  border-radius: 8px;
  transition: width .2s linear;
}
.tm-row { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; max-width: 100%; }
.wt-timer .tm-row .btn { flex-shrink: 1; min-width: 0; }
.wt-timer .w-body { padding-bottom: 14px; }
/* Persistent "time's up" banner — removed when the teacher taps the widget */
.wt-timer.alarm .w-body::before {
  content: "⏰ Time’s up — tap to dismiss";
  position: absolute; left: 50%; top: 6px; transform: translateX(-50%);
  z-index: 2; white-space: nowrap; max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis;
  padding: 4px 12px; border-radius: 999px;
  background: #dc2626; color: #fff; font-size: 13px; font-weight: 800;
  pointer-events: none;
}
.sw-laps { width: 92%; max-height: 70px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 2px; }
.sw-lap { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--border); font-variant-numeric: tabular-nums; }

/* ================= widget: traffic light ================= */
.tl {
  flex: 1; min-height: 0; height: auto; max-height: 100%; max-width: 100%; aspect-ratio: 0.44;
  background: linear-gradient(180deg, #223850, #12253a);
  border-radius: 24px; padding: clamp(6px, 2vh, 14px);
  display: flex; flex-direction: column;
  justify-content: space-evenly; align-items: center; gap: 6px;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, .5), 0 6px 16px rgba(8, 28, 48, .3);
}
.lamp {
  flex: none; width: auto; height: 29%; max-width: 100%; aspect-ratio: 1 / 1; border-radius: 50%;
  background: #2e415a; cursor: pointer;
  border: 2px solid rgba(255, 255, 255, .1);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255, 255, 255, .38); font-size: 18px; font-weight: 800;
  padding: 0;
  transition: background .2s, box-shadow .25s, transform .12s, color .2s;
}
.lamp:hover { transform: scale(1.05); }
.lamp.on { color: #0b1826; }
.lamp.red.on { background: radial-gradient(circle at 35% 30%, #ff9b9b, #e23b3b); box-shadow: 0 0 32px #ef4444; color: #fff; }
.lamp.yellow.on { background: radial-gradient(circle at 35% 30%, #fff0a8, #eab308); box-shadow: 0 0 32px #facc15; }
.lamp.green.on { background: radial-gradient(circle at 35% 30%, #86efac, #1fae54); box-shadow: 0 0 32px #22c55e; color: #052e16; }
.tl-lbl { font-size: 12.5px; font-weight: 800; color: var(--text); letter-spacing: .03em; text-align: center; }

/* ================= widget: work symbols ================= */
.sym-main { display: flex; align-items: center; gap: 8px; flex: 1; width: 100%; justify-content: space-between; min-height: 0; }
.sym-mid { text-align: center; flex: 1; }
.sym-emoji { font-size: clamp(40px, 16vmin, 96px); line-height: 1.1; filter: drop-shadow(0 6px 12px rgba(8, 28, 48, .25)); }
.sym-title { font-size: 22px; font-weight: 800; margin-top: 4px; }
.sym-desc { color: var(--muted); font-size: 14.5px; font-weight: 600; margin-top: 3px; }
.sym-dots { display: flex; gap: 8px; }
.sym-dots button { width: 14px; height: 14px; border-radius: 50%; border: 0; padding: 0; background: var(--border); transition: background .15s, transform .15s; cursor: pointer; }
.sym-dots button.on { background: var(--wc); transform: scale(1.25); }

/* ================= widget: name picker / random ================= */
.src-wrap { width: 100%; }
.src-row { display: flex; gap: 6px; width: 100%; }
.src-row .src-sel { flex: 1; min-width: 0; }
.picker-rest { flex: 1; width: 100%; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 7px; overflow-y: auto; }
.picker-name { font-weight: 800; text-align: center; min-height: 1.15em; line-height: 1.15; word-break: break-word; flex-shrink: 0; }
.picker-name.pop, .rnd-disp.pop { animation: pop .5s ease; color: var(--wc) !important; }
@keyframes pop { 0% { transform: scale(.7); } 55% { transform: scale(1.22); } 100% { transform: scale(1); } }
.rnd-disp { font-weight: 800; }
.rnd-min, .rnd-max { width: 68px; }

/* ================= widget: dice ================= */
.dice-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; align-items: center; flex: 1; cursor: pointer; }
.die {
  width: clamp(54px, 13vmin, 108px); height: clamp(54px, 13vmin, 108px);
  background: linear-gradient(150deg, #ffffff, #e8eef5);
  border: 1px solid rgba(20, 40, 60, .2);
  border-radius: 16px;
  box-shadow: inset -3px -3px 8px rgba(90, 125, 224, .12), 0 6px 14px rgba(8, 28, 48, .22);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 13%; gap: 1px;
  transition: transform .12s;
}
.die:active { transform: scale(.93); }
.die i { width: 78%; aspect-ratio: 1; border-radius: 50%; background: var(--ink); align-self: center; justify-self: center; opacity: 0; }
.die[data-v="1"] .c5,
.die[data-v="2"] .c1, .die[data-v="2"] .c9,
.die[data-v="3"] .c1, .die[data-v="3"] .c5, .die[data-v="3"] .c9,
.die[data-v="4"] .c1, .die[data-v="4"] .c3, .die[data-v="4"] .c7, .die[data-v="4"] .c9,
.die[data-v="5"] .c1, .die[data-v="5"] .c3, .die[data-v="5"] .c5, .die[data-v="5"] .c7, .die[data-v="5"] .c9,
.die[data-v="6"] .c1, .die[data-v="6"] .c3, .die[data-v="6"] .c4, .die[data-v="6"] .c6, .die[data-v="6"] .c7, .die[data-v="6"] .c9
{ opacity: 1; }
@keyframes diceShake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg) translateY(-2px); } 75% { transform: rotate(8deg) translateY(2px); } }
.dice-row.shake .die { animation: diceShake .2s linear infinite; }
.dice-info { font-size: 14.5px; color: var(--text); min-width: 84px; text-align: center; font-weight: 800; }

/* ================= widget: sound meter ================= */
.snd-meter {
  position: relative; width: 100%; min-height: 44px; flex: 1; max-height: 76px;
  background: var(--panel2);
  border: 1.5px solid var(--border);
  border-radius: 12px; overflow: hidden; margin-bottom: 6px;
}
.snd-fill { height: 100%; width: 0; transition: width .06s linear; border-radius: 10px; }
.snd-fill.green { background: linear-gradient(90deg, #4ade80, #22b45e); }
.snd-fill.orange { background: linear-gradient(90deg, #fbbf24, #ea9906); }
.snd-fill.red { background: linear-gradient(90deg, #f87171, #dc2f2f); }
.snd-th { position: absolute; top: 0; bottom: 0; width: 4px; background: var(--danger); box-shadow: 0 0 6px rgba(224, 82, 82, .95); }
.snd-status { text-align: center; margin-bottom: 4px; font-weight: 700; font-size: 13.5px; }
.snd-ctl { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 8px; }
.snd-ctl label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.snd-ctl input[type="range"] { flex: 1; }

/* ================= widget: draw ================= */
.draw-tools {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 9px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.draw-tools .tool { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 3px 8px; font-size: 14px; color: var(--text); }
.draw-tools .tool.sel { background: var(--wc); border-color: var(--wc); color: #fff; }
.draw-size { width: 64px; }
.draw-wrap { flex: 1; position: relative; min-height: 0; background: #ffffff; border-top: 1px solid var(--border); }
.draw-cv { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }

/* ================= widget: qr ================= */
.qr-row { display: flex; gap: 6px; margin-bottom: 8px; }
.qr-out { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 6px; }
.qr-cv { border-radius: 10px; max-width: 100%; max-height: calc(100% - 28px); box-shadow: var(--shadow-sm); }
.qr-cap { text-align: center; word-break: break-all; }

/* ================= widget: poll ================= */
.poll-setup { display: flex; flex-direction: column; gap: 8px; height: 100%; min-height: 0; }
.poll-q { width: 100%; }
.poll-opts { flex: 1; overflow-y: auto; min-height: 0; }
.poll-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.poll-vote { display: flex; flex-direction: column; height: 100%; gap: 8px; min-height: 0; }
.poll-title { text-align: center; font-size: 19px; font-weight: 800; }
.poll-btns { flex: 1; display: flex; flex-direction: column; gap: 7px; overflow-y: auto; min-height: 0; }
.poll-opt {
  position: relative; display: flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--border); border-radius: 13px;
  background: var(--panel); color: var(--text);
  padding: 11px 15px; font-size: 16.5px; font-weight: 700; overflow: hidden;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.poll-opt:hover { border-color: var(--wc); box-shadow: var(--shadow-sm); }
.poll-opt:active { transform: scale(.98); }
.poll-opt.voted { animation: pop .35s ease; border-color: var(--wc); }
.poll-bar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 11px 0 0 11px; transition: width .35s ease; }
.poll-lab { position: relative; flex: 1; text-align: left; }
.poll-count { position: relative; font-weight: 800; font-size: 16px; color: var(--text) !important; background: color-mix(in srgb, var(--panel) 80%, transparent); padding: 2px 7px; border-radius: 8px; }

/* ================= widget: groups ================= */
.grp-controls { margin-bottom: 8px; }
.grp-mode { max-width: 175px; }
.grp-n { width: 64px; }
.grp-out {
  flex: 1; overflow-y: auto; min-height: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 8px; align-content: start;
}
.grp-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--gc, var(--wc));
  border-radius: 12px;
  background: var(--panel2);
  padding: 9px 12px;
}
.grp-card h4 { font-size: 13px; color: var(--gc, var(--wc)); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; }
.grp-card ul { list-style: none; }
.grp-card li { font-size: 15.5px; padding: 2px 0; font-weight: 600; }

/* ================= widget: media / embed / slideshow ================= */
.media-form { height: 100%; gap: 10px; padding: 12px; }
.media-view { position: relative; width: 100%; height: 100%; background: #0a1622; }
.media-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.media-img { width: 100%; height: 100%; object-fit: contain; }
.media-change { position: absolute; top: 8px; right: 8px; z-index: 5; background: rgba(8, 20, 32, .85) !important; color: #fff !important; border-color: rgba(255, 255, 255, .25) !important; }
.media-open { position: absolute; top: 8px; right: 48px; z-index: 5; background: rgba(8, 20, 32, .85) !important; color: #fff !important; border-color: rgba(255, 255, 255, .25) !important; }
.media-ytfb {
  position: relative;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: #0a1622;
  border: 0; padding: 0; cursor: pointer;
}
.media-ytfb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .72; }
.media-play {
  position: relative;
  width: 76px; height: 54px;
  display: flex; align-items: center; justify-content: center;
  background: #e02020; color: #fff;
  border-radius: 15px;
  font-size: 24px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
  transition: transform .13s;
}
.media-ytfb:hover .media-play { transform: scale(1.1); }
.media-ytnote {
  position: absolute; bottom: 10px; left: 8px; right: 8px;
  color: #fff; font-size: 12px; line-height: 1.4;
  text-shadow: 0 1px 5px rgba(0, 0, 0, .9);
  opacity: .92;
}
.emb-ctl {
  position: absolute; top: 8px; right: 8px; z-index: 10;
  display: flex; gap: 5px;
  background: rgba(8, 20, 32, .82);
  backdrop-filter: blur(8px);
  padding: 4px; border-radius: 10px;
}
.emb-ctl .btn { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .22); }
.pres-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.scale-presets .theme-card { cursor: pointer; transition: transform .12s, border-color .12s; }
.scale-presets .theme-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.ss-ctl {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 5px;
  background: rgba(8, 20, 32, .84);
  backdrop-filter: blur(6px);
  border-radius: 12px; padding: 4px 8px;
  z-index: 6;
}
.ss-ctl .btn { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .22); }
.ss-count { color: #eef6ff; font-size: 12.5px; min-width: 44px; text-align: center; font-weight: 700; }

/* ================= widget: schedule ================= */
.sch-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }
.sch-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 11px;
  border-radius: 10px;
  background: var(--panel2);
  border: 1.5px solid transparent;
}
.sch-row.now {
  background: color-mix(in srgb, var(--wc) 22%, var(--panel));
  border-color: var(--wc);
  border-left-width: 5px;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--wc) 28%, transparent);
}
.sch-time { font-variant-numeric: tabular-nums; font-size: 13.5px; color: var(--muted); white-space: nowrap; font-weight: 700; }
.sch-sub { flex: 1; font-size: 16px; font-weight: 800; }
.sch-now-badge { font-size: 10px; font-weight: 900; padding: 2px 6px; border-radius: 6px; background: var(--wc); color: #fff; letter-spacing: .04em; }
.sch-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); animation: pulse 1.6s infinite; flex-shrink: 0; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.sch-edit-row { display: flex; gap: 4px; align-items: center; }
.sch-t { width: 64px; font-size: 13px; padding: 5px 6px; }

/* ================= widget: agenda ================= */
.ag-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ag-progress { font-size: 13.5px; font-weight: 800; color: var(--wc); min-width: 36px; }
.ag-bar { flex: 1; height: 9px; background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.ag-fill { height: 100%; background: linear-gradient(90deg, var(--wc), var(--ok)); transition: width .3s; }
.ag-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }
.ag-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; border-radius: 10px;
  background: var(--panel2); cursor: pointer;
  border: 1px solid transparent;
  transition: border-color .12s, transform .1s;
}
.ag-item:hover { border-color: var(--border); }
.ag-item:active { transform: scale(.99); }
.ag-check {
  width: 22px; height: 22px; flex-shrink: 0;
  border: 2px solid var(--border); border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff;
  transition: background .15s, border-color .15s;
}
.ag-item.done .ag-check { background: var(--ok); border-color: var(--ok); }
.ag-text { flex: 1; font-size: 16px; font-weight: 600; }
.ag-item.done .ag-text { text-decoration: line-through; color: var(--muted); }
.ag-del { background: none; border: 0; color: var(--muted); font-size: 14px; min-width: 28px; min-height: 28px; padding: 3px 6px; border-radius: 6px; opacity: .7; }
@media (hover: hover) and (pointer: fine) {
  .ag-del { opacity: .25; }
  .ag-item:hover .ag-del { opacity: .85; }
}
.ag-del:hover { color: var(--danger); background: rgba(224, 82, 82, .14); opacity: 1 !important; }

/* ================= widget: attendance ================= */
.att-grid {
  flex: 1; overflow-y: auto; min-height: 0;
  display: flex; flex-wrap: wrap; gap: 6px;
  align-content: start;
  margin: 8px 0;
}
.att-chip {
  border: 1.5px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 13px;
  font-size: 14.5px; font-weight: 700;
  transition: background .15s, border-color .15s, transform .1s;
}
.att-chip:active { transform: scale(.95); }
.att-chip.p { background: rgba(46, 153, 86, .18); border-color: var(--ok); }
.att-chip.p::after { content: " ✔"; color: var(--ok); }
.att-chip.l { background: rgba(217, 119, 6, .18); border-color: #d97706; }
.att-chip.l::after { content: " ⏰"; }
.att-chip.a { background: rgba(220, 38, 38, .15); border-color: var(--danger); text-decoration: line-through; }
.att-chip.a::after { content: " ✕"; color: var(--danger); text-decoration: none; display: inline-block; }
.att-stat { font-size: 13px; color: var(--muted); font-weight: 700; }
.att-stat.p { color: var(--ok); font-weight: 800; }
.att-stat.l { color: #d97706; font-weight: 800; }
.att-stat.a { color: var(--danger); font-weight: 800; }

/* ================= widget: scoreboard ================= */
.sb-row { flex: 1; display: flex; gap: 8px; min-height: 0; overflow-x: auto; }
.sb-team {
  position: relative;
  flex: 1; min-width: 88px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  border-radius: 15px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tc) 14%, var(--panel2)), var(--panel2));
  border: 1px solid color-mix(in srgb, var(--tc) 35%, var(--border));
  border-top: 4px solid var(--tc);
  padding: 8px 4px;
}
.sb-crown { position: absolute; top: 4px; right: 6px; font-size: 16px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.25)); }
.sb-name {
  width: 92%; text-align: center;
  background: none; border: 0; outline: none;
  font-size: 14px; font-weight: 800; color: var(--text);
  text-transform: uppercase; letter-spacing: .04em;
}
.sb-name:focus { color: var(--brand-text); }
.sb-score { font-size: clamp(28px, 6.5vmin, 60px); font-weight: 800; color: var(--tc); line-height: 1; text-shadow: 0 2px 8px color-mix(in srgb, var(--tc) 30%, transparent); }
.sb-score.bump { animation: pop .4s ease; }
.sb-btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.sb-b {
  min-width: 34px; height: 32px; padding: 0 6px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel);
  font-size: 14.5px; font-weight: 800; color: var(--text);
  transition: filter .12s, transform .1s;
}
.sb-b.plus { background: var(--tc); border-color: var(--tc); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.sb-b:hover { filter: brightness(1.08); }
.sb-b:active { transform: scale(.92); }

/* ================= widget: weather ================= */
.wx-main { display: flex; align-items: center; gap: 10px; }
.wx-emoji { font-size: clamp(34px, 9vmin, 64px); filter: drop-shadow(0 5px 10px rgba(8, 28, 48, .25)); }
.wx-temp { font-size: clamp(30px, 8vmin, 56px); font-weight: 800; }
.wx-desc { font-size: 16px; font-weight: 700; text-align: center; }
.wx-minmax { font-size: 14px; color: var(--muted); font-weight: 600; }

/* ================= widget: breathing ================= */
.br-stage {
  position: relative; flex: 1; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 0; gap: 4px; overflow: hidden;
}
.br-circle {
  width: min(36%, 118px); aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #b7e8dc, var(--wc));
  box-shadow: 0 0 36px color-mix(in srgb, var(--wc) 55%, transparent);
  transition: transform 4s ease-in-out;
  margin-bottom: 10px;
}
.br-circle.hold { animation: holdPulse 2s ease-in-out infinite; }
@keyframes holdPulse {
  0%, 100% { filter: brightness(1); box-shadow: 0 0 36px color-mix(in srgb, var(--wc) 55%, transparent); }
  50% { filter: brightness(1.12); box-shadow: 0 0 48px color-mix(in srgb, var(--wc) 85%, transparent); }
}
.br-label { font-size: 18px; font-weight: 800; z-index: 2; }
.br-count { font-size: 15px; color: var(--muted); min-height: 1.2em; font-variant-numeric: tabular-nums; font-weight: 800; z-index: 2; }

/* ================= widget: sounds ================= */
.snd-grid {
  flex: 1;
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  align-content: stretch;
}
.snd-fx {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--panel2); color: var(--text);
  font-size: 22px;
  transition: transform .12s, border-color .12s, box-shadow .15s;
}
.snd-fx span { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.snd-fx:hover { border-color: var(--wc); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.snd-fx.hit { transform: scale(.92); border-color: var(--wc); background: color-mix(in srgb, var(--wc) 14%, transparent); }
.snd-vol { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; }
.snd-vol input { flex: 1; }

/* ================= new widget color identities ================= */
.wt-lesson,    [data-type="lesson"]    { --wc: #6d5bd0; }
.wt-jobs,      [data-type="jobs"]      { --wc: #b37317; }
.wt-countdown, [data-type="countdown"] { --wc: #d94f70; }

/* ================= ghost mode (transparent / floating card, adaptive readability) ================= */
.widget.ghost {
  background: rgba(255, 255, 255, .14);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px dashed color-mix(in srgb, var(--wc) 34%, rgba(15, 23, 42, .22));
  box-shadow: none;
}
.widget.ghost::before { opacity: .28; height: 2px; }
body.bg-dark .widget.ghost {
  background: rgba(8, 20, 34, .22);
  border-color: rgba(255, 255, 255, .3);
  --text: #f8fafc;
  --muted: #d2e2f2;
  --panel: rgba(12, 28, 46, .82);
  --panel2: rgba(15, 34, 56, .64);
  --border: rgba(255, 255, 255, .24);
}
body.bg-dark .widget.ghost .w-body { text-shadow: 0 1px 3px rgba(0, 0, 0, .65); }
body.bg-dark .widget.ghost .w-icon {
  background: color-mix(in srgb, var(--wc) 32%, rgba(255, 255, 255, .22));
  color: color-mix(in srgb, var(--wc) 32%, #f8fafc);
}
body.bg-dark .widget.ghost .w-title {
  color: color-mix(in srgb, var(--wc) 28%, #f8fafc);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
}
body.bg-dark .widget.ghost .w-ghost.on {
  color: color-mix(in srgb, var(--wc) 32%, #f8fafc);
  background: rgba(255, 255, 255, .18);
}
body.bg-light .widget.ghost .w-body { text-shadow: 0 1px 2px rgba(255, 255, 255, .55); }
body.dark:not(.bg-dark) .widget.ghost {
  background: rgba(14, 28, 46, .34);
  border-color: rgba(20, 40, 60, .35);
}
body.dark.bg-dark .widget.ghost {
  background: rgba(10, 24, 40, .24);
  border-color: rgba(255, 255, 255, .26);
}
@media (hover: hover) and (pointer: fine) {
  .widget.ghost .w-head .w-icon,
  .widget.ghost .w-head .w-title { opacity: .72; transition: opacity .18s ease; }
  .widget.ghost:hover .w-head .w-icon,
  .widget.ghost:hover .w-head .w-title,
  .widget.ghost:focus-within .w-head .w-icon,
  .widget.ghost:focus-within .w-head .w-title { opacity: 1; }
}
.w-ghost.on { color: var(--wc); background: color-mix(in srgb, var(--wc) 18%, transparent); }
/* Sunny Classroom forces pre-existing transparent cards solid with readable tokens */
body.high-contrast .widget.ghost,
body.high-contrast.bg-dark .widget.ghost {
  background: var(--glass-strong) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  --text: #051424;
  --muted: #16304a;
  --panel: #ffffff;
  --panel2: #ebf2fa;
  --border: #2c5b88;
}
body.dark.high-contrast .widget.ghost,
body.dark.high-contrast.bg-dark .widget.ghost {
  --text: #ffffff;
  --muted: #cde2f7;
  --panel: #0a1624;
  --panel2: #12253b;
  --border: #72b8f5;
}
body.high-contrast .widget.ghost::before { opacity: 1; height: 3px; }
body.high-contrast .widget.ghost .w-body { text-shadow: none !important; }
body.high-contrast .widget.ghost .w-head .w-icon,
body.high-contrast .widget.ghost .w-head .w-title { opacity: 1 !important; }

/* ================= focus mode ================= */
.focus-back {
  position: absolute; inset: 0;
  background: rgba(6, 18, 30, .58);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 7900;
  cursor: pointer;
}
.widget.focus {
  left: 3% !important; top: 4% !important;
  width: 94% !important; height: 92% !important;
  z-index: 8000 !important;
  animation: modalIn .22s ease-out;
}
.widget.focus .w-resize { display: none; }
.widget.focus .w-head { cursor: default; }

/* ================= eyes on teacher curtain overlay ================= */
#curtainOverlay {
  position: fixed; inset: 0; z-index: 9200;
  background: radial-gradient(circle at center, #16304a 0%, #091522 100%);
  color: #f1f5f9;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 32px;
  cursor: pointer;
  animation: modalIn .2s ease-out;
}
.curtain-box { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 680px; }
.curtain-emoji { font-size: clamp(56px, 8vw, 88px); line-height: 1; }
.curtain-title { font-size: clamp(32px, 5vw, 60px); font-weight: 800; letter-spacing: -.015em; }
.curtain-sub { font-size: clamp(16px, 2.2vw, 24px); opacity: .85; line-height: 1.4; }
.curtain-clock {
  margin-top: 8px;
  font-size: clamp(22px, 3vw, 36px); font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 6px 20px; border-radius: 14px;
  background: rgba(255, 255, 255, .1);
}
.curtain-tip { margin-top: 10px; font-size: 14px; opacity: .65; }

/* ================= alignment guides ================= */
.guide {
  position: absolute; display: none;
  z-index: 7500; pointer-events: none;
  background: #ff5c8a;
  box-shadow: 0 0 6px rgba(255, 92, 138, .8);
}
.guide-v { top: 0; bottom: 0; width: 1.5px; }
.guide-h { left: 0; right: 0; height: 1.5px; }

/* ================= widget ⋯ menu ================= */
.w-menu {
  position: absolute; top: 40px; right: 8px;
  z-index: 60;
  background: var(--glass-strong);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: var(--shadow);
  padding: 5px;
  min-width: 170px;
  animation: modalIn .14s ease-out;
}
.w-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: 0;
  padding: 9px 13px; border-radius: 9px;
  font-size: 13.5px; font-weight: 600; color: var(--text);
}
.w-menu button:hover { background: color-mix(in srgb, var(--wc) 14%, transparent); }

/* ================= toast action button ================= */
.toast { display: flex; align-items: center; gap: 14px; }
.toast-act {
  background: var(--brand); color: #fff;
  border: 0; border-radius: 9px;
  padding: 5px 14px;
  font-size: 13px; font-weight: 800;
  cursor: pointer;
}
.toast-act:hover { filter: brightness(1.15); }

/* ================= confetti canvas ================= */
.fx-canvas { position: fixed; inset: 0; z-index: 9800; pointer-events: none; }

/* ================= empty screen hint ================= */
.empty-hint {
  position: absolute; left: 50%; top: 46%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text);
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 26px 32px;
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  pointer-events: auto;
  z-index: 2;
  max-width: min(440px, 90vw);
}
.empty-hint svg { width: 155px; margin: 0 auto 6px; opacity: .88; color: var(--brand-text); }
.empty-hint h3 { font-size: 19px; font-weight: 800; }
.empty-hint p { font-size: 13.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.empty-acts { display: flex; gap: 10px; justify-content: center; margin-top: 15px; flex-wrap: wrap; }
.empty-tour-row { margin-top: 10px; }
.btn.subtle-link {
  background: transparent;
  border-color: transparent;
  color: var(--brand-text);
  font-size: 12.5px;
  padding: 4px 10px;
}
.btn.subtle-link:hover {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  box-shadow: none;
}

/* ================= widget gallery ================= */
.gal-top { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.gal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 8px;
  margin-bottom: 4px;
}
.gal-card {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  cursor: pointer;
  transition: border-color .13s, box-shadow .13s, transform .1s;
}
.gal-card:hover { border-color: var(--wc); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.gal-card:active { transform: scale(.98); }
.gal-ico {
  width: 38px; height: 38px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 11px;
  background: color-mix(in srgb, var(--wc) 15%, transparent);
  color: var(--wc);
}
.gal-ico svg { width: 20px; height: 20px; }
.gal-txt { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.gal-txt b { font-size: 13.5px; }
.gal-txt small { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.gal-pin {
  background: none; border: 0;
  font-size: 18px; color: var(--border);
  padding: 4px 6px;
  transition: color .12s, transform .12s;
}
.gal-pin:hover { transform: scale(1.25); color: #f0b429; }
.gal-pin.on { color: #f0b429; }
.gal-open {
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--wc) 16%, transparent);
  color: var(--wc); flex-shrink: 0;
}
.gal-none { text-align: center; padding: 34px 10px; color: var(--muted); }
.gal-none span { font-size: 32px; display: block; margin-bottom: 6px; }

/* ================= screen templates ================= */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.tpl-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 18px 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: var(--panel2);
  color: var(--text);
  transition: border-color .13s, box-shadow .13s, transform .12s;
}
.tpl-card:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); transform: translateY(-3px); }
.tpl-card .tpl-emoji { font-size: 28px; }
.tpl-card b { font-size: 14px; }
.tpl-card .hint { text-align: center; }
.tpl-del {
  position: absolute; top: 7px; right: 9px;
  font-size: 13px; opacity: .65; cursor: pointer; padding: 2px 5px;
}
.tpl-del:hover { opacity: 1; color: var(--danger); }
.tpl-cur {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.danger-box {
  padding: 12px 14px;
  border: 1.5px solid color-mix(in srgb, var(--danger) 42%, var(--border));
  border-radius: 14px;
  background: color-mix(in srgb, var(--danger) 7%, var(--panel));
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

/* ================= themes (settings cards + look variants) ================= */
.theme-row { display: flex; gap: 8px; }
.theme-card {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 13px 8px;
  border: 1.5px solid var(--border);
  border-radius: 15px;
  background: var(--panel2);
  color: var(--text);
}
.theme-card span { font-size: 23px; }
.theme-card b { font-size: 13px; }
.theme-card small { font-size: 10.5px; color: var(--muted); text-align: center; line-height: 1.3; }
.theme-card.on { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }

/* ================= PLAYFUL / JOYFUL THEME (Early Years & Elementary) ================= */
body[data-theme="playful"] {
  --rad: 26px;
  --rad-btn: 18px;
  font-family: "Quicksand", "Nunito", "Comic Neue", "SF Pro Rounded", "Segoe UI Variable Display", system-ui, -apple-system, sans-serif;
  letter-spacing: 0.2px;
}
body[data-theme="playful"] #background {
  filter: saturate(1.22) contrast(1.03);
}
body[data-theme="playful"] .widget:not(.ghost) {
  border-radius: 26px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  box-shadow: 0 16px 36px rgba(217, 59, 104, 0.14), 0 6px 18px rgba(78, 129, 173, 0.14), 0 2px 6px rgba(0, 0, 0, 0.04);
  animation-duration: 0.35s;
}
body[data-theme="playful"] .widget:not(.ghost):hover {
  box-shadow: 0 20px 44px rgba(217, 59, 104, 0.20), 0 8px 22px rgba(78, 129, 173, 0.18);
}
body[data-theme="playful"] .w-head { padding: 10px 12px 8px; }
body[data-theme="playful"] .w-icon {
  border-radius: 50%;
  transform: scale(1.08);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}
body[data-theme="playful"] .w-title { font-weight: 800; font-size: 13.5px; }
body[data-theme="playful"] .btn {
  border-radius: 999px;
  font-weight: 700;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, background 0.15s ease;
}
body[data-theme="playful"] .btn:hover { transform: translateY(-2px) scale(1.03); }
body[data-theme="playful"] .btn:active { transform: translateY(1px) scale(0.96); }
body[data-theme="playful"] .btn.primary {
  background: linear-gradient(135deg, #c92d5e, #d9521e);
  border: none;
  color: #fff;
  box-shadow: 0 4px 14px rgba(201, 45, 94, 0.36);
}
body[data-theme="playful"] .btn.primary:hover {
  background: linear-gradient(135deg, #b52452, #c74614);
  box-shadow: 0 6px 18px rgba(201, 45, 94, 0.45);
}
body[data-theme="playful"] #toolbar {
  border-radius: 34px;
  padding: 12px 14px 8px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 20px 50px rgba(8, 28, 48, 0.35);
}
body[data-theme="playful"] .tb-btn { border-radius: 20px; }
body[data-theme="playful"] .tb-btn:hover { transform: translateY(-7px) scale(1.12) rotate(2deg); }
body[data-theme="playful"] .q-btn {
  border-radius: 50%;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
body[data-theme="playful"] .q-btn:hover { transform: scale(1.15) rotate(-4deg); }
body[data-theme="playful"] .scr-tab,
body[data-theme="playful"] .scr-folder-btn {
  border-radius: 999px;
  font-weight: 700;
}
body[data-theme="playful"] .scr-tab.active {
  box-shadow: 0 4px 14px rgba(201, 45, 94, 0.38);
}
body[data-theme="playful"] .inp { border-radius: 14px; font-weight: 600; }
body[data-theme="playful"].dark .widget:not(.ghost) {
  border: 1.5px solid rgba(255, 107, 139, 0.38);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(255, 107, 139, 0.16);
}

/* ================= FOCUS / MINIMAL THEME (Exams & Quiet Study) ================= */
body[data-theme="focus"] {
  --rad: 10px;
  --rad-btn: 6px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.1px;
}
body[data-theme="focus"] #background { filter: saturate(0.65) brightness(0.95); }
body[data-theme="focus"] #background::before,
body[data-theme="focus"] #background::after { opacity: 0.05; }
body[data-theme="focus"] .widget:not(.alarm):not(.ghost) {
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  animation: none;
}
body[data-theme="focus"] .tb-btn:hover { transform: translateY(-2px); }
body[data-theme="focus"] .btn { border-radius: 6px; font-weight: 600; }

/* ================= reduced effects (older computers) ================= */
body.lowfx #background::before, body.lowfx #background::after { display: none; }
body.lowfx .widget, body.lowfx .modal, body.lowfx #toolbar,
body.lowfx .q-btn, body.lowfx .scr-tab, body.lowfx #brand, body.lowfx .w-menu {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body.lowfx .widget:not(.alarm):not(.ghost) { background: var(--glass-strong); animation: none; }
body.lowfx .widget.ghost { background: rgba(255, 255, 255, .26); border-color: rgba(15, 23, 42, .24); }
body.lowfx.bg-dark .widget.ghost,
body.lowfx.dark .widget.ghost { background: rgba(10, 24, 40, .34); border-color: rgba(255, 255, 255, .28); }
body.lowfx .modal { background: var(--panel); }
body.lowfx .tb-btn, body.lowfx .q-btn, body.lowfx .scr-tab { transition: none; }
body.lowfx .tb-btn:hover { transform: none; }

/* ================= screen switch fade ================= */
@keyframes screenFade { from { opacity: .25; } to { opacity: 1; } }
#canvas.fade { animation: screenFade .26s ease-out; }

/* ================= widget: timer visual circle ================= */
.tm-circle {
  display: none;
  flex: 1; width: 100%; min-height: 0;
  align-items: center; justify-content: center;
}
.w-body[data-view="circle"] .tm-circle { display: flex; }
.w-body[data-view="circle"] .tm-disp,
.w-body[data-view="circle"] .tm-bar { display: none; }
.tm-circle svg { width: auto; height: auto; max-width: 100%; max-height: 100%; aspect-ratio: 1; }
.tc-bg { fill: none; stroke: color-mix(in srgb, var(--text) 16%, transparent); stroke-width: 9; }
.tc-fg {
  fill: none; stroke: var(--wc);
  stroke-width: 9; stroke-linecap: round;
  stroke-dasharray: 276.46;
  transition: stroke-dashoffset .2s linear, stroke .25s ease;
}
.tc-fg.warn { stroke: #d97706; }
.tc-fg.crit { stroke: #dc2626; }
.tc-txt { fill: var(--text); font-size: 14px; font-weight: 800; text-anchor: middle; dominant-baseline: middle; font-variant-numeric: tabular-nums; }

/* ================= widget: lesson ================= */
.ls-form { display: flex; flex-direction: column; gap: 7px; }
.ls-obj-ta { min-height: 76px; resize: vertical; line-height: 1.45; }
.ls-view { flex: 1; overflow-y: auto; font-size: var(--ls-fs, 16px); }
.ls-subject { font-size: 1.55em; font-weight: 800; color: var(--wc); line-height: 1.15; }
.ls-topic { font-size: 1.05em; font-weight: 700; color: var(--text); margin: 3px 0 10px; opacity: .88; }
.ls-label {
  font-size: 0.72em; font-weight: 800;
  text-transform: uppercase; letter-spacing: .09em;
  color: var(--wc);
  margin-bottom: 4px;
}
.ls-obj { list-style: none; margin-bottom: 10px; }
.ls-obj li { padding: 3px 0 3px 20px; position: relative; font-size: 1em; line-height: 1.38; font-weight: 500; }
.ls-obj li::before { content: "▸"; position: absolute; left: 3px; color: var(--wc); font-weight: 800; }
.ls-extra {
  font-size: 0.9em;
  padding: 7px 11px;
  background: var(--panel2);
  border-radius: 10px;
  margin-top: 6px;
}

/* ================= widget: class jobs ================= */
.jobs-list {
  flex: 1; overflow-y: auto; min-height: 0;
  display: flex; flex-direction: column; gap: 5px;
  margin: 8px 0;
}
.job-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px;
  background: var(--panel2);
  border-radius: 10px;
}
.job-name { font-size: 14.5px; font-weight: 700; }
.job-who { font-size: 14.5px; color: var(--muted); }
.job-who.on { color: var(--wc); font-weight: 800; }

/* ================= widget: countdown ================= */
.cd-big { font-weight: 800; color: var(--wc); line-height: 1; text-align: center; }
.cd-sub { font-size: 15px; color: var(--text); font-weight: 700; }
.cd-title-v { font-size: 18px; font-weight: 800; text-align: center; }

/* ================= annotation layer ================= */
.anno-cv {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 8400;
  touch-action: none;
  cursor: crosshair;
}
.anno-bar {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 8500;
  display: flex; align-items: center; gap: 3px;
  max-width: 96vw; overflow-x: auto;
  background: var(--glass-strong);
  backdrop-filter: blur(16px) saturate(1.25);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 16px;
  padding: 7px 9px;
  box-shadow: var(--shadow);
}
body.dark .anno-bar { border-color: rgba(255, 255, 255, .14); }
.an-b {
  width: 38px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; border-radius: 10px;
  color: var(--muted);
  flex-shrink: 0;
  transition: background .12s, color .12s, transform .1s;
}
.an-b svg { width: 19px; height: 19px; }
.an-b:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--text); }
.an-b:active { transform: scale(.92); }
.an-b.on { background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--brand-text); box-shadow: inset 0 0 0 1.5px var(--brand); }
.an-b.an-close { color: var(--danger); }
.an-b.an-close:hover { background: rgba(224, 82, 82, .14); }
.an-sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.an-colors { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; flex-shrink: 0; }
.an-c {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .65);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
  padding: 0; cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  position: relative;
}
.an-c:hover { transform: scale(1.2); }
.an-c.on { box-shadow: 0 0 0 2.5px var(--panel), 0 0 0 4.5px var(--brand); }
.an-rainbow {
  background: conic-gradient(#e02020, #f0c02e, #22a04a, #2d6ae0, #8b5cf6, #e02020);
  display: block;
}
.an-rainbow input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.an-sizes { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.an-s {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; border-radius: 9px;
  cursor: pointer;
}
.an-s i { display: block; border-radius: 50%; background: var(--text); }
.an-s:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.an-s.on { background: color-mix(in srgb, var(--brand) 18%, transparent); box-shadow: inset 0 0 0 1.5px var(--brand); }
.anno-bubble {
  position: fixed; top: 64px; right: 16px;
  z-index: 8500;
  width: 46px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--brand), var(--brand-dark));
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .12s;
}
.anno-bubble svg { width: 20px; height: 20px; }
.anno-bubble:hover { transform: scale(1.1); }
body.lowfx .anno-bar { backdrop-filter: none; background: var(--panel); }
@media (any-pointer: coarse) {
  .an-b { width: 44px; height: 42px; }
  .an-c { width: 24px; height: 24px; }
}

/* ================= secondary widget chrome (never hide functional tools) ================= */
@media (hover: hover) and (pointer: fine) {
  .w-head .w-btn { opacity: .65; transition: opacity .18s ease, background .15s; }
  .widget:hover .w-head .w-btn,
  .widget:focus-within .w-head .w-btn,
  .widget.focus .w-head .w-btn { opacity: 1; }
  .w-resize { opacity: .35; transition: opacity .18s ease; }
  .widget:hover .w-resize { opacity: .85; }
}

/* ================= auto-hide bars (dock + quick bar) ================= */
#toolbar, #quickBar {
  transition: transform .32s cubic-bezier(.4, 0, .2, 1), opacity .32s ease,
    background .15s;
}
body.bars-hidden #toolbar {
  transform: translate(-50%, calc(100% + 30px));
  opacity: 0;
  pointer-events: none;
}
body.bars-hidden #quickBar {
  transform: translateY(calc(-100% - 30px));
  opacity: 0;
  pointer-events: none;
}
#dockHandle {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 148px; height: 26px;
  border: 0; border-radius: 12px 12px 0 0;
  background: var(--bar);
  opacity: 0; pointer-events: none;
  transition: opacity .3s, height .15s;
  z-index: 5001;
  cursor: pointer;
  padding: 0;
}
#dockHandle::after {
  content: "";
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  width: 52px; height: 5px; border-radius: 3px;
  background: rgba(255, 255, 255, .65);
}
body.bars-hidden #dockHandle { opacity: 1; pointer-events: auto; }
#dockHandle:hover { height: 32px; }
.tb-pin .ico { background: rgba(255, 255, 255, .08); color: #c6d8e8; }
.tb-pin.off .ico {
  background: color-mix(in srgb, var(--brand) 50%, transparent);
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 45%, transparent);
}
.q-btn.on {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .35);
}
.q-btn.q-help {
  background: color-mix(in srgb, var(--brand) 28%, var(--bar));
  border-color: rgba(255, 255, 255, .24);
}
body.tour-active #toolbar {
  transform: translateX(-50%) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}
body.tour-active #quickBar {
  transform: none !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}
body.tour-active #dockHandle { opacity: 0 !important; pointer-events: none !important; }

/* ================= interactive spotlight guide ================= */
#tourSpot {
  position: fixed;
  z-index: 8850;
  pointer-events: none;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(6, 16, 28, .56), 0 0 0 3px #60a5fa, 0 0 28px rgba(96, 165, 250, .55);
  transition: left .26s cubic-bezier(.22, 1, .36, 1), top .26s cubic-bezier(.22, 1, .36, 1),
    width .26s cubic-bezier(.22, 1, .36, 1), height .26s cubic-bezier(.22, 1, .36, 1),
    border-radius .2s ease, opacity .18s ease;
}
#tourSpot.hidden { display: none; }
#tourSpot.no-rect {
  left: 50% !important; top: 50% !important; width: 0 !important; height: 0 !important;
  box-shadow: 0 0 0 9999px rgba(6, 16, 28, .48);
}

dialog.tour-pop {
  position: fixed;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, .48);
  border-radius: 20px;
  padding: 16px 18px 15px;
  width: min(370px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background: var(--glass-strong);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  color: var(--text);
  box-shadow: 0 22px 56px rgba(4, 14, 26, .45);
  z-index: 9400;
  inset: auto;
}
dialog.tour-pop:is(:popover-open, .\:popover-open, .is-open) {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: modalIn .2s cubic-bezier(.2, .9, .3, 1.2);
}
dialog.tour-pop::backdrop { background: transparent; }
body.dark dialog.tour-pop { border-color: rgba(255, 255, 255, .18); }
body.high-contrast dialog.tour-pop { border: 2px solid var(--border); box-shadow: 0 18px 46px rgba(0, 0, 0, .55); }
.tour-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tour-step-pill {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--brand-text);
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  padding: 3px 9px;
  border-radius: 999px;
}
.tour-pop h3 {
  font-size: 16.5px;
  font-weight: 800;
  line-height: 1.28;
  color: var(--navy);
}
body.dark .tour-pop h3 { color: var(--text); }
.tour-pop p {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
}
.tour-try {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  background: color-mix(in srgb, var(--brand) 12%, var(--panel2));
  color: var(--brand-text);
  border: 1px dashed color-mix(in srgb, var(--brand) 42%, var(--border));
  transition: all .18s ease;
}
.tour-try.done {
  background: rgba(22, 163, 74, .14);
  color: #15803d;
  border-style: solid;
  border-color: rgba(22, 163, 74, .45);
}
body.dark .tour-try {
  background: rgba(59, 130, 246, .16);
  border-color: color-mix(in srgb, var(--brand-light, #7ab0e0) 58%, transparent);
  color: #dbeafe;
}
body.dark .tour-try.done { color: #86efac; background: rgba(22, 163, 74, .2); border-color: rgba(134, 239, 172, .45); }
.tour-kbs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 2px;
}
.tour-kb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--panel2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text);
}
.tour-kb kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--brand-text);
  white-space: nowrap;
}
.tour-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.tour-dots { display: flex; align-items: center; gap: 5px; }
.tour-dot {
  width: 7px; height: 7px;
  border-radius: 999px;
  background: var(--border);
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: width .18s ease, background .18s ease;
}
.tour-dot.on { width: 18px; background: var(--brand); }
.tour-acts { display: flex; align-items: center; gap: 6px; }
body.lowfx #tourSpot, body.lowfx dialog.tour-pop { transition: none; animation: none; backdrop-filter: none; }
body.lowfx #toolbar, body.lowfx #quickBar { transition: none; }

/* ================= touch-friendly sizing (smartboards) ================= */
@media (any-pointer: coarse) {
  .w-btn { min-width: 44px; min-height: 44px; font-size: 16px; }
  .w-resize { width: 38px; height: 38px; }
  .scr-b { font-size: 14px; padding: 6px 8px; }
  .scr-scroll { width: 38px; height: 40px; }
  .btn.small { padding: 8px 14px; font-size: 13.5px; min-height: 44px; }
  .sb-b { min-width: 44px; height: 44px; }
  .q-btn { width: 44px; height: 44px; }
  .tb-btn .ico { width: 44px; height: 42px; }
  .cam-ctl .btn { min-height: 44px; }
  .att-chip { padding: 10px 16px; }
}


/* ================= scale-with-widget (focus / fullscreen) =================
   Group maker, Name picker and Agenda size their text from the widget body,
   like the timer does, so a focused/maximised widget is readable from the back. */
.wt-groups > .w-body,
.wt-picker > .w-body,
.wt-agenda > .w-body { container-type: size; }
.wt-groups .grp-out { grid-template-columns: repeat(auto-fill, minmax(clamp(145px, 24cqw, 420px), 1fr)); }
.wt-groups .grp-card h4 { font-size: clamp(13px, 2.6cqmin, 34px); }
.wt-groups .grp-card li { font-size: clamp(15.5px, 3.6cqmin, 48px); }
.wt-groups .grp-card { padding: clamp(9px, 1.6cqmin, 22px) clamp(12px, 2cqmin, 28px); }
.wt-picker .picker-go { font-size: clamp(14px, 3.4cqmin, 40px); min-height: clamp(38px, 8cqmin, 96px); padding-inline: clamp(14px, 2.6cqmin, 36px); }
.wt-picker .picker-reset { font-size: clamp(14px, 3.4cqmin, 40px); min-height: clamp(38px, 8cqmin, 96px); min-width: clamp(38px, 8cqmin, 96px); }
.wt-picker .picker-rest .chk { font-size: clamp(12px, 2.4cqmin, 26px); }
.wt-agenda .ag-text { font-size: clamp(16px, 3.8cqmin, 54px); }
.wt-agenda .ag-check { width: clamp(22px, 4.4cqmin, 60px); height: clamp(22px, 4.4cqmin, 60px); font-size: clamp(13px, 2.8cqmin, 38px); }
.wt-agenda .ag-item { padding: clamp(8px, 1.6cqmin, 22px) clamp(11px, 2cqmin, 28px); }
.wt-agenda .ag-progress { font-size: clamp(13.5px, 2.8cqmin, 36px); }

/* ================= attendance: "Counts only" ================= */
.att-grid.att-compact { flex-direction: column; flex-wrap: nowrap; align-items: stretch; justify-content: center; }
.att-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.att-total {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 6px; border-radius: 12px;
  background: var(--panel2); border: 1.5px solid var(--border);
}
.att-total b { font-size: clamp(28px, 6vmin, 64px); line-height: 1; font-variant-numeric: tabular-nums; }
.att-total span { font-size: 13px; font-weight: 700; color: var(--muted); }
.att-total.p { border-color: var(--ok); }
.att-total.a { border-color: var(--danger); }
.att-total.l { border-color: #d97706; }
.att-compact-note { text-align: center; margin-top: 8px; }

/* ================= demo on phones ================= */
@media (max-width: 600px) {
  body.cc-demo .cc-plan-banner:not(.is-compact)::after {
    content: "Best on a laptop or classroom display";
    flex-basis: 100%;
    font-size: 12px; font-weight: 600; opacity: .8;
  }
}

/* ================= EDU-8: Group maker in focus (fullscreen): centred cards ================= */
.widget.focus.wt-groups .grp-out {
  grid-template-columns: repeat(auto-fit, minmax(clamp(160px, 24cqw, 420px), 1fr));
  align-content: center;
  justify-content: center;
}
.grp-hint { grid-column: 1 / -1; text-align: center; margin: auto; }

/* ================= EDU-7: poll hint ================= */
.poll-hint { text-align: center; font-size: 12px; margin-top: -4px; }

/* ================= screens bar line icons (WEB-10) ================= */
.scr-ico { width: 15px; height: 15px; flex-shrink: 0; }
.scr-folder-btn .scr-ico { width: 16px; height: 16px; }
