/* ============================================================
   abacus.css  -  BrainyBeads Virtual Abacus
   Pure CSS: frame, rods, beads, animations, mode themes
   ============================================================ */

.abacus-page {
  min-height: 100vh;
  background: linear-gradient(180deg, #0b1030 0%, #141b4d 50%, #0a1740 100%);
  overflow-x: hidden;
  font-family: "Poppins", sans-serif;
}

.ambient-blob { position: absolute; border-radius: 50%; pointer-events: none; filter: blur(60px); }
.blob-indigo  { background: rgba(99,102,241,0.18); }
.blob-fuchsia { background: rgba(217,70,239,0.10); }
.blob-cyan    { background: rgba(34,211,238,0.09); }

/* TOOLBAR */
.toolbar-glass {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 1.25rem;
}
.toolbar-label {
  font-size: 0.6875rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(165,180,252,0.65); margin-bottom: 0.375rem;
}

.select-pill {
  appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff; border-radius: 9999px;
  padding: 0.45rem 2rem 0.45rem 0.9rem;
  font-size: 0.8125rem; font-weight: 600;
  font-family: "Poppins", sans-serif; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(165,180,252,0.6)'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.65rem center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.select-pill:focus { outline: none; border-color: rgba(167,139,250,0.6); box-shadow: 0 0 0 3px rgba(167,139,250,0.15); }
.select-pill option { background: #141b4d; color: #fff; }

.icon-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  border-radius: 9999px; padding: 0.48rem 1rem;
  font-size: 0.78rem; font-weight: 600;
  font-family: "Poppins", sans-serif;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85); cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,0.25); }
.icon-btn:active { transform: translateY(0); }
.icon-btn.amber { background: linear-gradient(135deg,#f59e0b,#d97706); border-color: transparent; color: #0b0f2e; box-shadow: 0 0 18px rgba(245,158,11,0.4); }
.icon-btn.amber:hover { filter: brightness(1.1); }
.icon-btn.indigo { background: linear-gradient(135deg,#6366f1,#7c3aed); border-color: transparent; color: #fff; box-shadow: 0 0 18px rgba(99,102,241,0.4); }
.icon-btn.indigo:hover { filter: brightness(1.1); }
.icon-btn.cyan { background: linear-gradient(135deg,#06b6d4,#0891b2); border-color: transparent; color: #fff; box-shadow: 0 0 18px rgba(6,182,212,0.4); }
.icon-btn.cyan:hover { filter: brightness(1.1); }

/* VALUE DISPLAY */
.value-display {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  backdrop-filter: blur(12px);
  border-radius: 1rem; padding: 0.6rem 1.4rem;
  display: inline-flex; align-items: baseline; gap: 0.5rem;
}
.value-label { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(165,180,252,0.6); }
.value-number {
  font-family: "Baloo 2", sans-serif; font-size: 2rem; font-weight: 800; line-height: 1;
  background: linear-gradient(135deg,#fbbf24,#f472b6,#818cf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  min-width: 4ch; text-align: right;
}

/* ABACUS FRAME */
.abacus-wrapper { display: flex; justify-content: center; align-items: center; padding: 2rem 1rem; }

.abacus-frame-outer {
  position: relative; border-radius: 1.1rem;
  box-shadow: 0 28px 60px rgba(0,0,0,0.80), 0 8px 20px rgba(0,0,0,0.60),
    inset 0 1px 0 rgba(255,255,255,0.1), inset 0 -2px 6px rgba(0,0,0,0.5),
    0 0 50px rgba(0,0,0,0.3);
  background: linear-gradient(165deg, #222222 0%, #151515 25%, #1c1c1c 55%, #050505 100%);
}
.abacus-frame-outer::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: repeating-linear-gradient(92deg,transparent,transparent 3px,rgba(255,255,255,0.015) 3px,rgba(255,255,255,0.015) 4px);
  pointer-events: none;
}

.abacus-frame-inner {
  margin: 14px; border-radius: 0.6rem;
  background: linear-gradient(180deg, #111111 0%, #050505 100%);
  box-shadow: inset 0 0 30px rgba(0,0,0,0.9), inset 0 1px 0 rgba(255,255,255,0.05);
  position: relative; overflow: visible;
}

/* DIVIDER */
.abacus-divider {
  position: absolute; left: 0; right: 0; height: 18px; z-index: 10;
  background: linear-gradient(180deg, #333333 0%, #222222 40%, #111111 100%);
  box-shadow: 0 3px 10px rgba(0,0,0,0.6), 0 -1px 3px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.08), inset 0 -1px 0 rgba(0,0,0,0.4);
}
.abacus-divider::before {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg,transparent,transparent 5px,rgba(255,255,255,0.02) 5px,rgba(255,255,255,0.02) 6px);
  pointer-events: none;
}

/* ROD COLUMNS */
.abacus-rods-container { display: flex; position: relative; width: 100%; height: 100%; contain: layout style; }
.rod-column { display: flex; flex-direction: column; align-items: center; position: relative; flex: 1; min-width: 0; }

/* STEEL ROD */
.rod-shaft {
  position: absolute; top: 0; bottom: 0; width: 5px; left: 50%; transform: translateX(-50%);
  z-index: 1; border-radius: 3px;
  background: linear-gradient(90deg,#4a5568 0%,#718096 20%,#e2e8f0 40%,#a0aec0 60%,#718096 80%,#4a5568 100%);
  box-shadow: 1px 0 3px rgba(0,0,0,0.4),-1px 0 2px rgba(255,255,255,0.08),inset 0 0 4px rgba(0,0,0,0.3);
}

/* BEAD SECTIONS */
.bead-section-upper { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; position: relative; z-index: 5; width: 100%; }
.bead-section-lower { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; z-index: 5; width: 100%; }

/* BEADS */
.bead {
  position: relative; border-radius: 2px; cursor: pointer; flex-shrink: 0;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  transition: transform 200ms ease-out, filter 0.2s ease, box-shadow 0.25s ease;
  z-index: 6; will-change: transform;
}
.bead::before {
  content: ""; position: absolute; top: 15%; left: 18%; width: 35%; height: 28%;
  background: radial-gradient(ellipse at center,rgba(255,255,255,0.75) 0%,rgba(255,255,255,0) 100%);
  border-radius: 50%; pointer-events: none;
}
.bead::after {
  content: ""; position: absolute; bottom: 12%; right: 15%; width: 22%; height: 16%;
  background: radial-gradient(ellipse at center,rgba(255,255,255,0.3) 0%,rgba(255,255,255,0) 100%);
  border-radius: 50%; pointer-events: none;
}
.bead:hover { filter: brightness(1.15); }
.bead:active { filter: brightness(1.25); }

/* ROD DOTS (BEAM MARKERS) */
.rod-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  z-index: 15;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}
.rod-dot::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
}
.rod-dot:hover {
  transform: translate(-50%, -50%) scale(1.2);
}
.rod-dot:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 3px;
}
.rod-dot.is-dragging {
  cursor: grabbing !important;
  transform: translate(-50%, -50%) scale(1.35);
  z-index: 20;
}
.rod-dot.dot-red {
  background: radial-gradient(circle at 35% 35%, #ff6b6b, #dc2626);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.85), inset 0 1px 2px rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.rod-dot.dot-red.is-dragging {
  box-shadow: 0 0 14px rgba(239, 68, 68, 1), 0 4px 10px rgba(0, 0, 0, 0.5);
}
.rod-dot.dot-white {
  background: radial-gradient(circle at 35% 35%, #ffffff, #e2e8f0);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.85), inset 0 1px 2px rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(200, 200, 200, 0.3);
}
.rod-dot.dot-white.is-dragging {
  box-shadow: 0 0 14px rgba(255, 255, 255, 1), 0 4px 10px rgba(0, 0, 0, 0.5);
}
.dot-units, .dot-thousands, .dot-millions, .dot-billions { background: #ffffff; color: #ffffff; }

.rod-label {
  position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%);
  font-size: 0.42rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  white-space: nowrap; color: rgba(165,180,252,0.45); pointer-events: none;
}

/* ---- JUNIOR ---- */

.mode-junior .bead.upper-type { background: radial-gradient(circle at 35% 35%,#ff8fa3,#e11d48); box-shadow: 0 4px 14px rgba(225,29,72,0.5),inset 0 -2px 5px rgba(0,0,0,0.3); }
.mode-junior .bead.lower-type[data-idx="0"] { background: radial-gradient(circle at 35% 35%,#fdba74,#ea580c); box-shadow: 0 4px 14px rgba(234,88,12,0.5),inset 0 -2px 5px rgba(0,0,0,0.3); }
.mode-junior .bead.lower-type[data-idx="1"] { background: radial-gradient(circle at 35% 35%,#fde047,#ca8a04); box-shadow: 0 4px 14px rgba(202,138,4,0.5),inset 0 -2px 5px rgba(0,0,0,0.3); }
.mode-junior .bead.lower-type[data-idx="2"] { background: radial-gradient(circle at 35% 35%,#86efac,#16a34a); box-shadow: 0 4px 14px rgba(22,163,74,0.5),inset 0 -2px 5px rgba(0,0,0,0.3); }
.mode-junior .bead.lower-type[data-idx="3"] { background: radial-gradient(circle at 35% 35%,#93c5fd,#2563eb); box-shadow: 0 4px 14px rgba(37,99,235,0.5),inset 0 -2px 5px rgba(0,0,0,0.3); }
.mode-junior .bead.active { filter: brightness(1.18) saturate(1.3); }

/* ---- INTERMEDIATE ---- */

.mode-intermediate .rod-shaft { background: linear-gradient(90deg, #374151 0%, #4B5563 20%, #9CA3AF 50%, #4B5563 80%, #374151 100%); }
.mode-intermediate .bead { background: oklch(70.4% 0.191 22.216); box-shadow: 0 4px 8px rgba(0,0,0,0.5), inset 0 -2px 4px rgba(0,0,0,0.3); }
.mode-intermediate .bead:hover { background: oklch(63.7% 0.237 25.331); filter: none; }
.mode-intermediate .bead.active { background: oklch(57.7% 0.245 27.325); box-shadow: 0 5px 12px rgba(0,0,0,0.5), inset 0 -2px 4px rgba(0,0,0,0.3); filter: none; }

/* ---- ADVANCED ---- */

.mode-advanced .rod-shaft { background: linear-gradient(90deg, #374151 0%, #4B5563 20%, #9CA3AF 50%, #4B5563 80%, #374151 100%); }
.mode-advanced .bead { background: radial-gradient(circle at 40% 30%, #A67556 0%, #8B5A3C 45%, #5E3923 100%); box-shadow: 0 4px 8px rgba(0,0,0,0.5), inset 0 -2px 4px rgba(0,0,0,0.3); }
.mode-advanced .bead.upper-type { background: radial-gradient(circle at 40% 30%, #B08264 0%, #8B5A3C 45%, #5E3923 100%); }
.mode-advanced .bead.active { filter: brightness(1.1); box-shadow: 0 5px 12px rgba(0,0,0,0.6), inset 0 -2px 4px rgba(0,0,0,0.3); }

/* ---- MASTER ---- */

.mode-master .rod-shaft { background: linear-gradient(90deg, #374151 0%, #4B5563 20%, #9CA3AF 50%, #4B5563 80%, #374151 100%); }
.mode-master .bead { background: radial-gradient(circle at 40% 30%, #8A5A39 0%, #6B4226 45%, #3D2211 100%); box-shadow: 0 4px 8px rgba(0,0,0,0.6), inset 0 -2px 4px rgba(0,0,0,0.4); }
.mode-master .bead.upper-type { background: radial-gradient(circle at 40% 30%, #9C6843 0%, #6B4226 45%, #3D2211 100%); }
.mode-master .bead.active { filter: brightness(1.15); box-shadow: 0 5px 12px rgba(0,0,0,0.7), inset 0 -2px 4px rgba(0,0,0,0.4); }


/* MODE BUTTONS */
.mode-btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.35rem 0.85rem; border-radius: 9999px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.55);
  cursor: pointer; transition: all 0.2s; font-family: "Poppins", sans-serif;
}
.mode-btn:hover { background: rgba(255,255,255,0.09); color: rgba(255,255,255,0.85); }
.mode-btn[data-mode="junior"].active       { border-color: rgba(167,139,250,0.55); background: rgba(167,139,250,0.12); color: #c4b5fd; }
.mode-btn[data-mode="intermediate"].active { border-color: rgba(34,211,238,0.55);  background: rgba(34,211,238,0.10);  color: #67e8f9; }
.mode-btn[data-mode="advanced"].active     { border-color: rgba(99,102,241,0.55);  background: rgba(99,102,241,0.12);  color: #a5b4fc; }
.mode-btn[data-mode="master"].active       { border-color: rgba(156,163,175,0.55); background: rgba(156,163,175,0.10); color: #e5e7eb; }

/* FOCUS */
.bead:focus-visible { outline: 2px solid rgba(251,191,36,0.9); outline-offset: 2px; }
.icon-btn:focus-visible,.mode-btn:focus-visible,.select-pill:focus-visible { outline: 2px solid rgba(167,139,250,0.8); outline-offset: 2px; }

.info-strip { font-size: 0.65rem; color: rgba(165,180,252,0.4); text-align: center; letter-spacing: 0.08em; }

@media (max-width: 640px) {
  .abacus-frame-outer { border-radius: 0.75rem; }
  .abacus-frame-inner { margin: 8px; }
  .value-number { font-size: 1.5rem; }
}

/* ============================================================
   WHITEBOARD MODAL
   ============================================================ */

/* Overlay */
#whiteboardModal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(7, 10, 31, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
#whiteboardModal.wb-hidden  { display: none; }
#whiteboardModal.wb-visible { opacity: 1; }

/* Panel */
#whiteboardPanel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: min(96vw, 1200px);
  height: min(88vh, 800px);
  border-radius: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 19, 56, 0.97);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255,255,255,0.05) inset;
  overflow: hidden;
  transform: translateY(12px);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
#whiteboardModal.wb-visible #whiteboardPanel { transform: translateY(0); }

/* Header bar */
#wbHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Toolbar group */
.wb-toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Tool buttons */
.wb-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 9999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: "Poppins", sans-serif;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.wb-tool-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.wb-tool-btn:active { transform: scale(0.96); }
.wb-tool-btn.wb-tool-active {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.5);
}

/* Danger (clear) button */
.wb-btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 9999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: "Poppins", sans-serif;
  border: 1px solid rgba(248, 113, 113, 0.3);
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.wb-btn-danger:hover { background: rgba(239,68,68,0.25); color: #fff; box-shadow: 0 0 14px rgba(239,68,68,0.3); }
.wb-btn-danger:active { transform: scale(0.96); }

/* Close button */
.wb-btn-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(165, 180, 252, 0.7);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.wb-btn-close:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* Color swatch picker */
#wbColorPicker {
  -webkit-appearance: none;
  appearance: none;
  width: 2rem;
  height: 2rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
}
#wbColorPicker::-webkit-color-swatch-wrapper { padding: 0; }
#wbColorPicker::-webkit-color-swatch { border: none; border-radius: 50%; }

/* Size slider */
#wbPenSize {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  border-radius: 9999px;
  background: rgba(255,255,255,0.15);
  outline: none;
  cursor: pointer;
}
#wbPenSize::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #818cf8;
  box-shadow: 0 0 6px rgba(129,140,248,0.6);
  cursor: pointer;
}

/* Canvas surface wrapper */
#wbSurface {
  flex: 1;
  overflow: hidden;
  background: #1a1f4e;
  position: relative;
}

#whiteboardCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none; /* prevent scroll while drawing */
}

/* Custom cursor dot */
#wbCursorDot {
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  border: 2px solid #fff;
  background: transparent;
  transform: translate(0, 0);
  z-index: 9999;
  display: none;
  transition: width 0.1s, height 0.1s;
}

/* Focus styles */
.wb-tool-btn:focus-visible,
.wb-btn-danger:focus-visible,
.wb-btn-close:focus-visible {
  outline: 2px solid rgba(167, 139, 250, 0.8);
  outline-offset: 2px;
}

/* Mobile tweaks */
@media (max-width: 640px) {
  #whiteboardPanel {
    height: min(90vh, 600px);
    border-radius: 1rem;
  }
  #wbHeader { padding: 0.65rem 0.85rem; gap: 0.4rem; }
  .wb-tool-btn, .wb-btn-danger { padding: 0.4rem 0.7rem; font-size: 0.72rem; }
  #wbPenSize { width: 60px; }
}

/* ============================================================
   TIMER MODAL
   ============================================================ */

/* Overlay */
#timerModal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(7, 10, 31, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
#timerModal.tm-hidden  { display: none; }
#timerModal.tm-visible { opacity: 1; }

/* Panel */
#timerPanel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  border-radius: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 19, 56, 0.97);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255,255,255,0.05) inset;
  overflow: hidden;
  transform: translateY(12px) scale(0.97);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
#timerModal.tm-visible #timerPanel {
  transform: translateY(0) scale(1);
}

/* Header */
#timerHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}

/* Tabs */
.tm-tabs {
  display: flex;
  gap: 0.25rem;
  background: rgba(255,255,255,0.05);
  border-radius: 9999px;
  padding: 0.25rem;
  border: 1px solid rgba(255,255,255,0.09);
}
.tm-tab {
  padding: 0.4rem 1.1rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: "Poppins", sans-serif;
  background: transparent;
  border: none;
  color: rgba(165,180,252,0.65);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.tm-tab:hover { color: #fff; }
.tm-tab.tm-tab-active {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff;
  box-shadow: 0 0 14px rgba(99,102,241,0.45);
}

/* Close button (reuses .wb-btn-close shape) */
.tm-btn-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 9999px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: rgba(165,180,252,0.7);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.tm-btn-close:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* Pane content */
.tm-pane {
  padding: 1.75rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

/* ── Big time display ── */
.tm-display {
  font-family: "Baloo 2", "Poppins", monospace;
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  background: linear-gradient(135deg, #a5b4fc, #c084fc, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  user-select: none;
}

/* ── Circular progress (countdown only) ── */
.tm-ring-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  flex-shrink: 0;
}
.tm-ring-wrap .tm-display {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}
.tm-ring-svg {
  width: 140px;
  height: 140px;
  transform: rotate(-90deg);
}
.tm-ring-track {
  fill: none;
  stroke: rgba(255,255,255,0.07);
  stroke-width: 7;
}
.tm-ring-progress {
  fill: none;
  stroke: #34d399;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 339.3; /* 2π×54 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s linear, stroke 0.4s ease;
}

/* ── Countdown inputs ── */
.tm-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tm-input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.tm-input-group label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(165,180,252,0.55);
}
.tm-input-group input[type="number"] {
  width: 3.8rem;
  padding: 0.5rem 0.4rem;
  text-align: center;
  font-family: "Baloo 2", monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: #e0e7ff;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 0.65rem;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.tm-input-group input[type="number"]::-webkit-inner-spin-button,
.tm-input-group input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
.tm-input-group input[type="number"]:focus {
  border-color: rgba(129,140,248,0.7);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}
.tm-input-group input[type="number"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.tm-colon {
  font-family: "Baloo 2", monospace;
  font-size: 1.8rem;
  font-weight: 700;
  color: rgba(165,180,252,0.4);
  margin-bottom: 1.2rem;
}

/* ── Control buttons ── */
.tm-controls {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: center;
}
.tm-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 9999px;
  padding: 0.55rem 1.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: "Poppins", sans-serif;
  border: none;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
}
.tm-btn:active { transform: scale(0.95); }
.tm-btn-primary {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff;
  box-shadow: 0 0 18px rgba(99,102,241,0.4);
}
.tm-btn-primary:hover { filter: brightness(1.12); }
.tm-btn-secondary {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.8);
}
.tm-btn-secondary:hover { background: rgba(255,255,255,0.14); color: #fff; }
.tm-btn-danger-soft {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(248,113,113,0.3);
  color: #fca5a5;
}
.tm-btn-danger-soft:hover { background: rgba(239,68,68,0.22); color: #fff; }
.tm-btn.tm-btn-disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Finished banner ── */
#cdFinishedBanner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.85rem;
  padding: 0.65rem 1rem;
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.3);
  color: #fca5a5;
  font-size: 0.82rem;
  font-weight: 600;
  animation: tm-pulse 1s ease-in-out infinite alternate;
}
@keyframes tm-pulse {
  from { box-shadow: 0 0 0 0 rgba(248,113,113,0); }
  to   { box-shadow: 0 0 18px 2px rgba(248,113,113,0.35); }
}

/* Focus rings */
.tm-tab:focus-visible,
.tm-btn:focus-visible,
.tm-btn-close:focus-visible {
  outline: 2px solid rgba(167,139,250,0.8);
  outline-offset: 2px;
}

/* Mobile */
@media (max-width: 480px) {
  #timerPanel { border-radius: 1.1rem; }
  .tm-display { font-size: 2.6rem; }
  .tm-pane { padding: 1.25rem 1rem 1.5rem; }
  .tm-btn { padding: 0.5rem 1rem; font-size: 0.76rem; }
  .tm-input-group input[type="number"] { width: 3.2rem; font-size: 1.35rem; }
}

/* ============================================================
   MINIATURE WATCH / TIMER WIDGET (CONTINUOUS MOVING DISPLAY)
   ============================================================ */

.icon-btn.teal {
  background: linear-gradient(135deg, #0d9488, #14b8a6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 18px rgba(20, 184, 166, 0.4);
}
.icon-btn.teal:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 22px rgba(20, 184, 166, 0.6);
}
.icon-btn.teal.active-glow {
  box-shadow: 0 0 22px rgba(20, 184, 166, 0.75), 0 0 5px rgba(255, 255, 255, 0.8);
}

.mini-timer-box {
  position: fixed;
  top: 90px;
  right: 20px;
  width: 224px;
  z-index: 120;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(11, 15, 46, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55), 0 0 18px rgba(56, 189, 248, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  user-select: none;
  touch-action: none;
  transition: box-shadow 0.2s ease, opacity 0.2s ease;
}

.mini-timer-box.mini-is-dragging {
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.8), 0 0 26px rgba(56, 189, 248, 0.45);
  opacity: 0.96;
  cursor: grabbing !important;
  transition: none;
}

.mini-timer-box.mini-hidden {
  display: none !important;
}

/* Header */
.mini-timer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 1rem 1rem 0 0;
  cursor: grab;
}

.mini-timer-handle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}

.mini-drag-icon {
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.7rem;
  flex-shrink: 0;
}

.mini-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: #64748b;
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}

.mini-live-dot.dot-running {
  background: #34d399;
  box-shadow: 0 0 8px #34d399;
  animation: mini-pulse 1.2s infinite ease-in-out;
}

.mini-live-dot.dot-paused {
  background: #fbbf24;
  box-shadow: 0 0 6px #fbbf24;
}

.mini-live-dot.dot-finished {
  background: #f87171;
  box-shadow: 0 0 10px #f87171;
  animation: mini-pulse 0.7s infinite;
}

.mini-live-dot.dot-clock {
  background: #38bdf8;
  box-shadow: 0 0 7px #38bdf8;
}

@keyframes mini-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

.mini-mode-label {
  font-family: 'Poppins', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-timer-tools {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.mini-tool-btn {
  width: 1.45rem;
  height: 1.45rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(203, 213, 225, 0.75);
  cursor: pointer;
  transition: all 0.15s ease;
}

.mini-tool-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  transform: scale(1.08);
}

/* Body */
.mini-timer-body {
  padding: 0.65rem 0.8rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mini-time-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.2rem;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  padding: 0.15rem 0;
  border-radius: 0.4rem;
  transition: background 0.15s;
}

.mini-time-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.mini-time-digits {
  font-family: 'Baloo 2', 'Poppins', monospace;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #a5b4fc, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: background 0.3s;
}

.mini-timer-box.is-running .mini-time-digits {
  background: linear-gradient(135deg, #6ee7b7, #38bdf8, #a7f3d0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mini-time-ms {
  font-family: 'Baloo 2', monospace;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  color: #93c5fd;
  opacity: 0.85;
}

/* Mini control buttons row */
.mini-ctrl-row {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
}

.mini-action-btn {
  flex: 1;
  height: 1.75rem;
  border-radius: 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.15s ease;
}

.mini-action-btn:active {
  transform: scale(0.95);
}

.mini-action-btn.mini-start {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.35);
  border-color: rgba(52, 211, 153, 0.4);
}
.mini-action-btn.mini-start:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.5);
}

.mini-action-btn.mini-pause {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.12);
}
.mini-action-btn.mini-pause:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.mini-action-btn.mini-reset {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(248, 113, 113, 0.25);
  color: #fca5a5;
}
.mini-action-btn.mini-reset:hover {
  background: rgba(239, 68, 68, 0.22);
  color: #ffffff;
}

.mini-action-btn:disabled,
.mini-action-btn.mini-disabled {
  opacity: 0.32;
  cursor: not-allowed;
  pointer-events: none;
}

/* Collapsed state */
.mini-timer-box.mini-collapsed {
  width: 175px;
}
.mini-timer-box.mini-collapsed .mini-timer-body {
  padding: 0.35rem 0.6rem 0.45rem;
}
.mini-timer-box.mini-collapsed .mini-time-digits {
  font-size: 1.25rem;
}
.mini-timer-box.mini-collapsed .mini-time-ms {
  font-size: 0.75rem;
}
.mini-timer-box.mini-collapsed .mini-ctrl-row {
  display: none;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .mini-timer-box {
    width: 200px;
    top: 75px;
    right: 12px;
  }
  .mini-time-digits {
    font-size: 1.45rem;
  }
}
