/* ============================================
   SIDE-PANEL.CSS - Side Panel & Tab System
   KlassKit Hub
   ============================================ */

/* ============================================
   1. SIDE PANEL CONTAINER
   ============================================ */

#side-panel {
  box-shadow: 4px 0 0 var(--border-primary);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark #side-panel {
  box-shadow: 4px 0 0 rgba(0, 0, 0, 0.5);
}

#game-modal.hidden #side-panel,
body.focus-mode #side-panel,
#side-panel.collapsed {
  transform: translateX(-100%);
  box-shadow: none !important;
}

#side-panel.collapsed {
  pointer-events: none;
}

/* ============================================
   2. SIDE PANEL BUTTONS (Common Styles)
   ============================================ */

.side-panel-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;

  width: 3.5rem;
  height: 3.5rem;

  background: var(--bg-tertiary);
  color: var(--text-secondary);

  border: 3px solid transparent;
  border-radius: 1rem;

  cursor: pointer;
  user-select: none;

  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Prevent text selection */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.side-panel-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--border-secondary);
  transform: translateX(4px) scale(1.05);
  box-shadow: 2px 2px 0 var(--border-primary);
}

.dark .side-panel-btn:hover {
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.side-panel-btn:active {
  transform: translateX(2px) scale(1);
  box-shadow: none;
}

.side-panel-btn:focus-visible {
  outline: 3px solid var(--color-blue);
  outline-offset: 2px;
}

/* ============================================
   3. HOME BUTTON
   ============================================ */

.side-panel-home {
  background: var(--color-pink);
  color: white;
  border-color: var(--border-primary);
  box-shadow: 2px 2px 0 var(--border-primary);
}

.side-panel-home:hover {
  background: var(--color-orange);
  transform: translateX(4px) scale(1.1);
}

.dark .side-panel-home {
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}

/* ============================================
   4. TAB ICON BUTTONS
   ============================================ */

.side-panel-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;

  width: 3.5rem;
  height: 3.5rem;

  background: var(--bg-tertiary);

  border: 3px solid var(--border-secondary);
  border-radius: 1rem;

  cursor: pointer;
  user-select: none;

  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Animation on creation */
  animation: slide-in-left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.side-panel-tab:hover {
  transform: translateX(4px) scale(1.05);
  border-color: var(--border-primary);
  box-shadow: 2px 2px 0 var(--border-primary);
}

.dark .side-panel-tab:hover {
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.dark .side-panel-tab {
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
}

.side-panel-tab:focus-visible {
  outline: 3px solid var(--color-blue);
  outline-offset: 2px;
}

/* Active tab */
.side-panel-tab.active {
  border-color: var(--border-primary);
  border-width: 4px;
  box-shadow: 4px 4px 0 var(--border-primary);
  transform: translateX(8px) scale(1.1);
}

.dark .side-panel-tab.active {
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.8);
}

/* Pinned tab */
.side-panel-tab.pinned {
  border-color: var(--color-orange);
  border-width: 3px;
  border-style: dashed;
}

.side-panel-tab.pinned.active {
  border-style: solid;
}

.side-panel-tab.pinned::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  width: 12px;
  height: 12px;
  background-color: var(--color-orange);
  border: 2px solid var(--border-primary);
  border-radius: 50%;
  z-index: 10;
}

/* Tab icon */
.side-panel-tab-icon {
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  color: white;
}

/* Tab color backgrounds */
.side-panel-tab[data-color="text-pink"] {
  background: var(--color-pink);
}

.side-panel-tab[data-color="text-orange"] {
  background: var(--color-orange);
}

.side-panel-tab[data-color="text-green"] {
  background: var(--color-green);
}

.side-panel-tab[data-color="text-blue"] {
  background: var(--color-blue);
}

.side-panel-tab[data-color="text-red-500"] {
  background: #ef4444;
}

.side-panel-tab[data-color="text-slate-500"] {
  background: #64748b;
}

/* ============================================
   5. TAB CLOSE BUTTON
   ============================================ */

.side-panel-tab-close {
  position: absolute;
  top: -6px;
  right: -6px;

  display: none;
  align-items: center;
  justify-content: center;

  width: 1.25rem;
  height: 1.25rem;

  background: var(--color-pink);
  color: white;

  border: 2px solid var(--border-primary);
  border-radius: 50%;

  cursor: pointer;
  z-index: 20;
  pointer-events: auto;

  transition: all 0.15s;
}

.side-panel-tab:not(.pinned):hover .side-panel-tab-close,
.side-panel-tab:not(.pinned):focus-within .side-panel-tab-close {
  display: flex;
  pointer-events: auto;
}

.side-panel-tab-close:hover {
  background: #ef4444;
  transform: scale(1.2) rotate(90deg);
}

.side-panel-tab-close i,
.side-panel-tab-close svg {
  width: 0.75rem;
  height: 0.75rem;
}

/* ============================================
   6. LOADING STATE
   ============================================ */

.side-panel-tab.loading .side-panel-tab-icon {
  animation: spin 1s linear infinite;
}

/* ============================================
   7. TAB ICONS SCROLLBAR
   ============================================ */

#side-panel-tabs {
  scrollbar-width: thin;
  scrollbar-color: var(--border-secondary) transparent;
}

#side-panel-tabs::-webkit-scrollbar {
  width: 4px;
}

#side-panel-tabs::-webkit-scrollbar-track {
  background: transparent;
}

#side-panel-tabs::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: 2px;
}

#side-panel-tabs::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ============================================
   8. TRASH BUTTON (Danger Style)
   ============================================ */

.side-panel-danger {
  background: #fee2e2;
  color: #ef4444;
  border-color: #ef4444;
}

.dark .side-panel-danger {
  background: #7f1d1d;
  color: #fca5a5;
  border-color: #991b1b;
}

.side-panel-danger:hover {
  background: #ef4444;
  color: white;
  border-color: #dc2626;
  transform: translateX(4px) scale(1.1);
}

.side-panel-danger:active {
  background: #dc2626;
}

/* ============================================
   9. MAIN CONTENT AREA
   ============================================ */

#tab-content-area {
  position: relative;
  width: calc(100% - 5rem);
  height: 100vh;
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.focus-mode #tab-content-area,
#tab-content-area.expanded {
  width: 100%;
  margin-left: 0;
}

/* Split-Screen Mode Layout */
#tab-content-area.split-mode {
  display: flex;
  flex-direction: row;
}

/* ============================================
   10. TAB PANELS
   ============================================ */

.tab-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

  opacity: 0;
  pointer-events: none;

  transition: opacity 0.3s ease, width 0.3s ease, transform 0.3s ease;
}

.tab-panel.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}

/* Split-Screen Active Panes */
#tab-content-area.split-mode .tab-panel.split-left {
  position: relative;
  width: 50%;
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
  border-right: 4px solid var(--border-primary);
}

#tab-content-area.split-mode .tab-panel.split-right {
  position: relative;
  width: 50%;
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}

/* Focus indicator for split panes (which one receives the next navigation) */
#tab-content-area.split-mode .tab-panel.split-left.split-focused,
#tab-content-area.split-mode .tab-panel.split-right.split-focused {
  border: 4px solid var(--color-blue);
  box-sizing: border-box;
}

.tab-panel iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

/* Loading spinner for each tab */
.tab-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;

  color: white;
  font-family: 'Fredoka', sans-serif;
  z-index: 10;
}

.dark .tab-loading {
  color: var(--text-primary);
}

.tab-loading .spinner {
  width: 5rem;
  height: 5rem;
  border: 5px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--color-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.tab-loading .loading-text {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tab-panel.loaded .tab-loading {
  display: none;
}

/* ============================================
   11. HOME VIEW
   ============================================ */

#home-view-panel {
  background: var(--bg-primary);
}

#home-view-panel iframe {
  background: var(--bg-primary);
}

#home-view-panel:not(.active) {
  display: none;
}

/* ============================================
   12. EMPTY STATE
   ============================================ */

.side-panel-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;

  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  font-family: 'Fredoka', sans-serif;

  animation: fade-in 0.3s ease;
}

.dark .side-panel-empty {
  color: rgba(248, 250, 252, 0.5);
}

.side-panel-empty.hidden {
  display: none;
}

.side-panel-empty i,
.side-panel-empty svg {
  width: 6rem;
  height: 6rem;
  opacity: 0.3;
}

.side-panel-empty .empty-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.side-panel-empty .empty-text {
  font-size: 1rem;
  opacity: 0.8;
}

/* ============================================
   13. FOCUS MODE BUTTONS
   ============================================ */

.exit-focus-btn {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 65;

  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;

  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-xl);
  color: var(--text-primary);

  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark .exit-focus-btn {
  background: rgb(var(--surface-card-rgb) / 0.4);
  border-color: rgba(255, 255, 255, 0.1);
  color: white;
}

body.focus-mode .exit-focus-btn {
  opacity: 0.5;
  pointer-events: auto;
  transform: translateY(0);
}

body.focus-mode .exit-focus-btn:hover {
  opacity: 1;
  background: white;
  color: var(--color-blue);
  border-color: var(--color-blue);
  box-shadow: 4px 4px 0 var(--color-blue);
  transform: translateY(-2px);
}

.dark body.focus-mode .exit-focus-btn:hover {
  background: var(--bg-secondary);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.8);
}

.side-panel-toggle-btn {
  position: absolute;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 65;

  display: none; /* Hidden on desktop by default */
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;

  background: var(--color-blue);
  color: white;

  border: 3px solid var(--border-primary);
  border-radius: var(--radius-xl);
  box-shadow: 4px 4px 0 var(--border-primary);

  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.side-panel-toggle-btn:hover {
  transform: translateY(-2px);
  box-shadow: 6px 6px 0 var(--border-primary);
}

.side-panel-toggle-btn:active {
  transform: translateY(2px);
  box-shadow: 2px 2px 0 var(--border-primary);
}

.dark .side-panel-toggle-btn {
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.8);
}

body.focus-mode .side-panel-toggle-btn {
  display: none;
}

/* JavaScript-based Floating Tooltip will replace this */

/* ============================================
   14. RESPONSIVE DESIGN
   ============================================ */

#side-panel-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

@media (max-width: 767px) {
  .side-panel-toggle-btn {
    display: flex; /* Show toggle button on mobile */
  }

  #side-panel-backdrop {
    display: block;
  }

  #side-panel-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  #side-panel.open ~ #tab-content-area .side-panel-toggle-btn {
    left: 5.5rem;
  }

  #side-panel {
    width: 4.5rem;
    transform: translateX(-100%);
    border-right: none;
    box-shadow: none;
  }

  #side-panel.open {
    transform: translateX(0);
    border-right: 4px solid var(--border-primary);
    box-shadow: 4px 0 0 var(--border-primary);
  }

  .side-panel-btn,
  .side-panel-tab {
    width: 3rem;
    height: 3rem;
  }

  .side-panel-tab-icon {
    width: 1.75rem;
    height: 1.75rem;
  }

  #tab-content-area {
    width: 100% !important;
    margin-left: 0 !important;
  }

  #tab-content-area.split-mode {
    flex-direction: column;
  }

  #tab-content-area.split-mode .tab-panel.split-left,
  #tab-content-area.split-mode .tab-panel.split-right {
    width: 100%;
    height: 50%;
    border-right: none;
  }

  #tab-content-area.split-mode .tab-panel.split-left {
    border-bottom: 4px solid var(--border-primary);
  }
}

@media (hover: none), (max-width: 767px) {
  .side-panel-tab.active:not(.pinned) .side-panel-tab-close {
    display: flex;
    pointer-events: auto;
  }
}

/* ============================================
   16. PRINT STYLES
   ============================================ */

@media print {
  #side-panel {
    display: none;
  }

  #tab-content-area {
    margin-left: 0;
    width: 100%;
  }

  .tab-panel:not(.active) {
    display: none;
  }
}

/* ============================================
   17. ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {

  .side-panel-tab,
  .side-panel-btn,
  .tab-panel {
    animation: none;
    transition: none;
  }
}

/* ============================================
   18. DRAG AND DROP
   ============================================ */

.side-panel-tab.dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

.side-panel-tab.drag-over {
  border-top: 3px solid var(--color-blue);
  margin-top: 3px;
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
}

/* Prevent interaction issues while touch dragging */
body.touch-dragging {
  user-select: none !important;
  -webkit-user-select: none !important;
  touch-action: none !important;
}

/* Touch drag ghost */
.touch-drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 3rem;
  height: 3rem;

  background: var(--color-blue);
  color: white;

  border: 3px solid var(--border-primary);
  border-radius: var(--radius-xl);
  box-shadow: 6px 6px 0 var(--border-primary);

  opacity: 0.9;
  transform: scale(1.1);
  transition: transform 0.1s ease;

  animation: pop-in 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dark .touch-drag-ghost {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.6);
}

.touch-drag-ghost i,
.touch-drag-ghost svg {
  width: 1.5rem;
  height: 1.5rem;
}

/* ============================================
   19. TAB GROUPS (Sidebar pill sections)
   ============================================ */

.tab-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: 0.2rem 0;
  padding: 0.25rem 0.2rem 0.35rem;
  background: color-mix(in srgb, var(--group-color, var(--color-blue)) 8%, transparent);
  border: 2px solid color-mix(in srgb, var(--group-color, var(--color-blue)) 38%, transparent);
  border-radius: 0.9rem;
  overflow: visible;
  transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.dark .tab-group {
  background: color-mix(in srgb, var(--group-color, var(--color-blue)) 12%, rgb(var(--surface-card-rgb) / 0.4));
  border-color: color-mix(in srgb, var(--group-color, var(--color-blue)) 45%, transparent);
}

.tab-group.has-active {
  border-color: var(--group-color, var(--color-blue));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--group-color, var(--color-blue)) 20%, transparent);
}

.tab-group.drag-over {
  border-color: var(--group-color, var(--color-blue));
  background: color-mix(in srgb, var(--group-color, var(--color-blue)) 18%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--group-color, var(--color-blue)) 25%, transparent);
}

.tab-group.dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

/* --- Group Header (2-row compact stack for 80px sidebar) --- */
.tab-group-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  width: 100%;
  padding: 0.3rem 0.25rem;
  background: transparent;
  border: none;
  border-radius: 0.65rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  font-family: 'Nunito', sans-serif;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  position: relative;
  text-align: center;
  user-select: none;
}

.dark .tab-group-header {
  color: var(--text-secondary);
}

.tab-group-header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  width: 100%;
}

.tab-group-header:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.04);
}

.dark .tab-group-header:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.tab-group-header:focus-visible {
  outline: 2px solid var(--color-blue);
  outline-offset: 2px;
}

/* Color dot */
.tab-group-color-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Group name label */
.tab-group-name {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  line-height: 1.15;
}

/* Chevron */
.tab-group-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.65;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.tab-group-header:hover .tab-group-chevron {
  opacity: 1;
}

.tab-group.collapsed .tab-group-chevron {
  transform: rotate(-90deg);
}

.tab-group-chevron i,
.tab-group-chevron svg {
  width: 0.75rem;
  height: 0.75rem;
  flex-shrink: 0;
}

/* Count badge */
.tab-group-count {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1rem;
  height: 0.95rem;
  padding: 0 0.25rem;
  background: var(--group-color, #1ea7fd);
  color: white;
  border-radius: 999px;
  font-size: 0.55rem;
  font-weight: 900;
  flex-shrink: 0;
}

/* --- Group Tabs Container --- */
.tab-group-tabs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.35rem 0 0.1rem;
  background: transparent;
}

.tab-group.collapsed .tab-group-tabs {
  display: none;
}

/* Tabs inside a group */
.tab-group-tabs .side-panel-tab {
  width: 3rem;
  height: 3rem;
  border-radius: 0.875rem;
  border-width: 2px;
  margin: 0;
  box-shadow: 2px 2px 0 rgba(30, 41, 59, 0.25);
}

.dark .tab-group-tabs .side-panel-tab {
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
}

.tab-group-tabs .side-panel-tab:hover {
  transform: translateX(3px) scale(1.05);
  box-shadow: 2px 2px 0 var(--border-primary);
}

.dark .tab-group-tabs .side-panel-tab:hover {
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
}

.tab-group-tabs .side-panel-tab.active {
  transform: translateX(5px) scale(1.08);
  border-width: 3px;
  box-shadow: 3px 3px 0 var(--border-primary);
}

.dark .tab-group-tabs .side-panel-tab.active {
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.75);
}

/* Ungrouped drop zone */
.tab-ungrouped-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 1.5rem;
  margin-top: 0.25rem;
  border: 2px dashed transparent;
  border-radius: 0.65rem;
  transition: all 0.2s ease;
  color: var(--text-tertiary);
  opacity: 0.5;
}

body.tab-dragging-grouped .tab-ungrouped-dropzone,
.tab-ungrouped-dropzone.drag-over {
  opacity: 1;
  border-color: var(--color-blue);
  background: rgba(30, 167, 253, 0.12);
  color: var(--color-blue);
  min-height: 2.25rem;
}

/* New group button in side panel */
.tab-new-group-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 2rem;
  margin-top: 0.25rem;
  border-radius: 0.75rem;
  border: 2px dashed var(--border-secondary);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.tab-new-group-btn:hover {
  border-style: solid;
  border-color: var(--color-blue);
  color: var(--color-blue);
  background: rgba(30, 167, 253, 0.08);
}

.tab-new-group-btn:focus-visible {
  outline: 2px solid var(--color-blue);
  outline-offset: 2px;
}

/* ============================================
   20. CONTEXT MENUS
   ============================================ */

#tab-context-menu,
#tab-group-submenu {
  font-family: 'Nunito', sans-serif;
}

#tab-context-menu button,
#tab-group-submenu button {
  outline: none;
}

#tab-context-menu button:focus-visible,
#tab-group-submenu button:focus-visible {
  outline: 2px solid var(--color-blue);
  outline-offset: 2px;
}

/* ============================================
   21. RESPONSIVE GROUPS
   ============================================ */

@media (max-width: 767px) {
  .tab-group {
    width: 100%;
    margin: 0.15rem 0;
    padding: 0.2rem 0.15rem 0.3rem;
  }

  .tab-group-header {
    font-size: 0.52rem;
    padding: 0.2rem 0.15rem;
    gap: 0.15rem;
  }

  .tab-group-chevron i,
  .tab-group-chevron svg {
    width: 0.65rem;
    height: 0.65rem;
  }

  .tab-group-tabs {
    padding: 0.25rem 0 0.05rem;
    gap: 0.25rem;
  }

  .tab-group-tabs .side-panel-tab {
    width: 2.65rem;
    height: 2.65rem;
    border-radius: 0.75rem;
  }

  .tab-new-group-btn {
    width: 2.65rem;
    height: 1.75rem;
  }
}

/* ============================================
   22. UNIVERSAL FLOATING COUNTDOWN TIMER
   ============================================ */

.universal-timer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;

  min-width: 9rem;
  padding: 0.6rem 0.8rem 0.7rem;

  background: var(--bg-secondary);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);

  border: 3px solid var(--border-primary);
  border-radius: 1.25rem;
  box-shadow: 4px 4px 0 var(--border-primary);

  font-family: 'Nunito', sans-serif;
  user-select: none;
  cursor: default;
  touch-action: none;

  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Kill ALL transitions while dragging so position updates are instant */
.universal-timer.timer-dragging {
  transition: none !important;
  will-change: left, top;
  cursor: grabbing;
}

.dark .universal-timer {
  background: rgb(var(--surface-card-rgb) / 0.9);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
}

.universal-timer.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

.universal-timer.running {
  border-color: var(--color-green);
  box-shadow: 4px 4px 0 var(--color-green);
}

.dark .universal-timer.running {
  box-shadow: 4px 4px 0 rgba(0, 208, 99, 0.5);
}

/* Finished / alarm state */
.universal-timer.timer-finished {
  border-color: var(--color-pink);
  box-shadow: 4px 4px 0 var(--color-pink);
  animation: timer-alarm-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes timer-alarm-pulse {
  0% {
    transform: scale(1);
    box-shadow: 4px 4px 0 var(--color-pink);
  }
  100% {
    transform: scale(1.06);
    box-shadow: 4px 4px 12px var(--color-pink), 0 0 20px rgba(255, 71, 133, 0.3);
  }
}

/* --- Exit Button --- */
.timer-exit-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 10;
  
  display: flex;
  align-items: center;
  justify-content: center;
  
  width: 1.25rem;
  height: 1.25rem;
  
  background: transparent;
  color: var(--text-tertiary);
  border: none;
  border-radius: 0.35rem;
  
  cursor: pointer;
  transition: all 0.15s ease;
}

.timer-exit-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  transform: scale(1.1);
}

/* --- Drag Handle --- */
.timer-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  width: 100%;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--border-secondary);
  cursor: grab;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  touch-action: none;
}

.timer-drag-handle:active {
  cursor: grabbing;
}

/* --- Circular Progress Ring --- */
.timer-ring-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-ring-bg {
  fill: none;
  stroke: var(--border-secondary);
  stroke-width: 5;
}

.dark .timer-ring-bg {
  stroke: rgba(71, 85, 105, 0.4);
}

.timer-ring-fg {
  fill: none;
  stroke: var(--color-blue);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.15s linear, stroke 0.3s ease;
}

.universal-timer.running .timer-ring-fg {
  stroke: var(--color-green);
}

.universal-timer.timer-finished .timer-ring-fg {
  stroke: var(--color-pink);
}

/* --- Display (inside ring) --- */
.timer-display {
  font-family: 'Nunito', sans-serif;
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1;
  color: var(--text-primary);
  text-align: center;
  min-width: 3.5rem;
  z-index: 2;
}

.universal-timer.timer-finished .timer-display {
  color: var(--color-pink);
}

/* --- Preset Duration Buttons --- */
.timer-presets {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: center;
}

.timer-preset-btn {
  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0.2rem 0.45rem;
  min-width: 1.8rem;

  background: var(--bg-tertiary);
  color: var(--text-secondary);

  border: 2px solid var(--border-secondary);
  border-radius: 0.5rem;

  font-family: 'Nunito', sans-serif;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;

  cursor: pointer;
  transition: all 0.15s ease;
}

.timer-preset-btn:hover {
  background: var(--color-blue);
  color: white;
  border-color: var(--color-blue);
  transform: translateY(-1px);
  box-shadow: 1px 1px 0 var(--color-blue);
}

.timer-preset-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

.timer-preset-btn.active {
  background: var(--color-blue);
  color: white;
  border-color: var(--color-blue);
  box-shadow: 1px 1px 0 var(--color-blue);
}

/* --- Custom Time Input --- */
.timer-custom-input {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding-top: 0.3rem;
  border-top: 2px solid var(--border-secondary);
}

.timer-custom-input.hidden {
  display: none;
}

.timer-custom-fields {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.timer-custom-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.timer-custom-field input {
  width: 2.5rem;
  padding: 0.2rem 0.1rem;
  text-align: center;
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 900;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 2px solid var(--border-secondary);
  border-radius: 0.5rem;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}

.timer-custom-field input::-webkit-inner-spin-button,
.timer-custom-field input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.timer-custom-field input:focus {
  border-color: var(--color-blue);
  box-shadow: 0 0 0 2px rgba(30, 167, 253, 0.2);
}

.timer-custom-field label {
  font-size: 0.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.timer-custom-sep {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--text-tertiary);
  padding-bottom: 0.8rem;
}

.timer-set-btn {
  background: var(--color-green) !important;
  color: white !important;
  border-color: var(--color-green) !important;
  padding: 0.2rem 0.8rem !important;
}

.timer-set-btn:hover {
  box-shadow: 2px 2px 0 var(--color-green) !important;
}

/* --- Timer Controls --- */
.timer-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.timer-btn {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 1.8rem;
  height: 1.8rem;

  background: var(--bg-tertiary);
  color: var(--text-secondary);

  border: 2px solid var(--border-secondary);
  border-radius: 0.5rem;

  cursor: pointer;
  transition: all 0.15s ease;
}

.timer-btn:hover {
  background: var(--bg-primary);
  border-color: var(--border-primary);
  transform: translateY(-1px);
  box-shadow: 2px 2px 0 var(--border-primary);
}

.timer-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

.timer-play:hover {
  background: var(--color-green);
  color: white;
  border-color: var(--color-green);
  box-shadow: 2px 2px 0 var(--color-green);
}

.timer-pause:hover {
  background: var(--color-orange);
  color: white;
  border-color: var(--color-orange);
  box-shadow: 2px 2px 0 var(--color-orange);
}

.timer-reset:hover {
  background: var(--color-blue);
  color: white;
  border-color: var(--color-blue);
  box-shadow: 2px 2px 0 var(--color-blue);
}

/* --- Add Time Buttons --- */
.timer-add-time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.timer-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  border: 2px solid var(--border-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.6rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}

.timer-add-btn:hover {
  background: var(--color-green);
  color: white;
  border-color: var(--color-green);
  box-shadow: 1px 1px 0 var(--color-green);
  transform: translateY(-1px);
}

.timer-add-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* --- Responsive Timer --- */
@media (max-width: 767px) {
  .universal-timer {
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    min-width: 7.5rem;
    padding: 0.4rem 0.6rem;
  }

  .timer-ring-wrap {
    width: 68px;
    height: 68px;
  }

  .timer-display {
    font-size: 1.1rem;
  }

  .timer-btn {
    width: 1.6rem;
    height: 1.6rem;
  }

  .timer-preset-btn {
    font-size: 0.55rem;
    padding: 0.15rem 0.35rem;
  }
}