/* ==========================================================================
   Base Styles & Reset
   ========================================================================== */
      /* STOP ICONS FROM STEALING CLICKS INSIDE BUTTONS */
button i, 
.apply-comm-btn i, 
.action-btn i {
    pointer-events: none;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden; 
}

body {
  background: var(--canvas, #355c7d);
  display: flex;
  justify-content: center;
  align-items: center;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  font-family: var(--font-sans, 'Poppins', Arial, sans-serif);
  transition: background-color 0.4s ease;
}

/* ==========================================================================
   Permanent Brand Logo (Top Left): the "Clockface Online" wordmark over the canvas.
   Mark, badge and phone layout live in css/cfo-chrome.css.
   ========================================================================== */
.top-brand {
  position: absolute;
  top: calc(25px + env(safe-area-inset-top, 0px));
  left: calc(30px + env(safe-area-inset-left, 0px));
  font-family: var(--font-sans);
  font-size: 22px;
  line-height: 30px;
  font-weight: 700;
  color: var(--on-glass);
  text-decoration: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  z-index: 90;
  transition: opacity var(--dur-base) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.top-brand:hover {
  transform: scale(1.03);
}
.top-brand.brand-hidden {
  opacity: 0;
  pointer-events: none;
}
.top-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}
.top-brand.has-custom-brand {
  align-items: center;
}
.top-brand:focus-visible {
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Clock Display
   ========================================================================== */
.clock {
  color: #FFFFFF;
  font-size: 14vw;
  font-family: sans-serif;
  display: flex;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  pointer-events: none;
  text-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

/* ==========================================================================
   Glass chrome (GlassBar): the top bar and the bottom app dock float over the canvas
   in --glass with --on-glass icons. body.cfo-canvas-light adds --glass-dim (cfo-chrome.css).
   ========================================================================== */
/* ==========================================================================
   Top Header Bar: Theme, Fullscreen, Admin, Feedback, Account
   ========================================================================== */
.top-header-bar {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-float);
  color: var(--on-glass);
  z-index: 100;
  transition: opacity var(--dur-base) var(--ease);
}

.top-header-bar.inactive-fade,
.bottom-app-dock.inactive-fade {
  opacity: 0;
  pointer-events: none;
}

.top-header-bar a {
  color: var(--on-glass);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-fast) var(--ease);
}

.top-header-bar a:hover {
  background: var(--glass);
}

/* Ensure any badge (Frill notification or profile counter) is absolute and doesn't shift icon spacing */
.top-header-bar a [class*="frill"],
.top-header-bar a .frill-badge,
.top-header-bar a [data-frill-badge],
.top-header-bar a .frill__badge {
  position: absolute !important;
  top: 2px !important;
  right: 0 !important;
  margin: 0 !important;
}

/* Hover and keyboard label: a floating paper tooltip below the icon (no layout shift) */
.top-header-bar a .nav-label {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 50%;
  transform: translate(-50%, -4px);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-float);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 120;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), visibility var(--dur-fast) var(--ease);
}

.top-header-bar a:focus-visible .nav-label {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
@media (hover: hover) {
  .top-header-bar a:hover .nav-label {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
  }
}

/* ==========================================================================
   Bottom Floating App Dock (GlassBar dock for the mini apps)
   ========================================================================== */
.bottom-app-dock {
  position: fixed;
  bottom: calc(25px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-float);
  color: var(--on-glass);
  z-index: 100;
  max-width: 95vw;
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}

.bottom-app-dock.dock-hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateX(-50%) translateY(20px) !important;
}

.bottom-app-dock a {
  color: var(--on-glass);
  font-size: 20px;
  cursor: grab;
  width: 44px;
  height: 44px;
  min-width: 44px;
  max-width: 44px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
  flex-shrink: 0;
  padding: 0;
  margin: 0;
  user-select: none;
}

.bottom-app-dock a:active {
  cursor: grabbing;
}

.bottom-app-dock a.dock-dragging {
  opacity: var(--disabled);
  cursor: grabbing;
}

.bottom-app-dock a.dock-drag-over {
  outline: 2px dashed var(--on-glass);
  outline-offset: -2px;
  background: var(--glass-border);
}

.dock-manager-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: grab;
  user-select: none;
  transition: transform var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}

.dock-manager-item:active {
  cursor: grabbing;
}

.dock-manager-item.pref-dragging {
  opacity: var(--disabled);
  background: var(--accent-tint);
  border-style: dashed;
  border-color: var(--accent);
  cursor: grabbing;
}

.dock-manager-item.pref-drag-over {
  border-color: var(--accent);
  background: var(--accent-tile);
}

.bottom-app-dock a i,
.top-header-bar a i {
  color: inherit;
}

.bottom-app-dock a:hover {
  transform: translateY(-2px);
  background: var(--glass);
}

.dock-divider {
  width: 1px;
  height: 24px;
  background: var(--glass-border);
  margin: 0 var(--space-1);
  flex-shrink: 0;
}

/* "All apps" launcher: a normal dock item */
.bottom-app-dock a.dock-store-btn {
  color: var(--on-glass);
  background: transparent;
  border: 0;
}

.bottom-app-dock a.dock-store-btn:hover {
  background: var(--glass);
  color: var(--on-glass);
  transform: translateY(-2px);
  box-shadow: none;
}

.theme-mode-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent; border-radius: var(--radius-pill);
}

.theme-mode-btn:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.theme-mode-btn.active {
  background: var(--accent) !important;
  color: var(--on-primary) !important;
  box-shadow: var(--shadow-sm);
}

/* Hover and keyboard label: a floating paper tooltip above the icon, without pushing sibling icons */
.bottom-app-dock a .nav-label {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 16px;
  height: auto;
  min-height: auto;
  max-height: none;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--text-primary);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  box-shadow: var(--shadow-float);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), visibility var(--dur-fast) var(--ease);
  z-index: 120;
  box-sizing: border-box;
}

.bottom-app-dock a:focus-visible .nav-label {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
@media (hover: hover) {
  .bottom-app-dock a:hover .nav-label {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
  }
}

/* Focus timer live pill on the dock (#navFocusActiveBadge): paper chip under the icon.
   updateTimerDisplay() writes its text and toggles inline display block/none. */
.bottom-app-dock .nav-focus-timer-pill {
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  line-height: 14px;
  margin: 0;
  pointer-events: none;
}

.bottom-app-dock a.has-active-timer i {
  font-size: 16px;
  transform: translateY(-7px);
}

/* Open tool: a subtle fill plus a dot, no glow and no tan text */
.bottom-app-dock a.active-glow,
.top-header-bar a.active-glow:not(.nav-avatar-link) {
  color: var(--on-glass);
  background: var(--glass-border);
}

.top-header-bar a.nav-avatar-link.active-glow {
  background: transparent !important;
}

.bottom-app-dock a.active-glow i,
.top-header-bar a.active-glow i {
  filter: none;
}

.bottom-app-dock a.active-glow::before {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: var(--radius-pill);
  background: var(--on-glass);
}

.bottom-app-dock a.active-glow.has-active-timer::before {
  display: none;
}

/* Focus timer pill (shared base, also used outside the dock) */
.nav-focus-timer-pill {
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--surface);
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  line-height: 14px;
  transition: opacity var(--dur-fast) var(--ease);
}

.bottom-app-dock a.has-active-timer .nav-label {
  display: none !important;
}

@media (max-width: 768px) {
  .top-header-bar {
    top: calc(15px + env(safe-area-inset-top, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    padding: 2px var(--space-2);
    gap: 2px;
  }
  .bottom-app-dock {
    bottom: calc(15px + env(safe-area-inset-bottom, 0px));
    padding: var(--space-1) var(--space-2);
    gap: var(--space-1);
    max-width: 96vw;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .bottom-app-dock::-webkit-scrollbar {
    display: none;
  }
  .bottom-app-dock a:hover {
    transform: none;
  }
}

.nav-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.full-nav a, .full-nav span {
  color: #fff;
  text-decoration: none;
  font-size: 15px;
}

.nav-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: nowrap; /* This forces the close button to stay in the same row! */
}

.nav-actions a {
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(0,0,0,0.2);
  transition: background 0.2s;
}

.nav-actions a:hover {
  background: rgba(0,0,0,0.4);
}

.nav-actions a.active {
  background: #cebfaf;
  color: #fff;
}

#theNavbar {
    position: fixed;
    top: 20px;       /* Keeps it lined up horizontally with your little pill */
    left: 50%;       /* Moves the left edge to the exact center of the screen */
    transform: translateX(-50%) translateY(-10px); /* Pulls it back to perfectly center the whole bar */
    
    /* Reset these just in case your old CSS had it pinned to the bottom */
    bottom: auto;
    right: auto;
    
    /* Optional: Ensures it doesn't touch the screen edges on smaller devices */
    width: max-content; 
    max-width: 90vw;   
    
    /* Set default hidden state */
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Prevents clicking invisible buttons */
    transition: all 0.3s ease;
}

/* The class we will trigger with JavaScript */
#theNavbar.show-nav {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0); /* Slides perfectly into place */
}

/* ==========================================================================
   Settings Side Drawer
   ========================================================================== */
/* Fix Z-Index for Settings Drawer */
.drawer {
  position: fixed;
  top: 0;
  right: -400px;
  width: 380px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface);
  box-shadow: var(--shadow-modal);
  z-index: 1010; /* BUMPED: Now beats the 1005 modals! */
  transition: right var(--dur-base) var(--ease), visibility 0s linear var(--dur-base);
  display: flex;
  flex-direction: column;
}

/* Make dividers actually visible */
/* Fixed Divider Visibility */
.nav-divider {
    display: block !important;
    width: 2px !important;
    min-width: 2px !important;
    height: 28px !important;
    background-color: rgba(255, 255, 255, 0.4) !important;
    /* THE FIX: A subtle dark shadow makes it pop on light backgrounds! */
    box-shadow: 1px 0 3px rgba(0, 0, 0, 0.3) !important; 
    margin: 0 10px;
    align-self: center;
    flex-shrink: 0;
}

.drawer.open {
  right: 0;
}

.drawer-header {
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-header h2 {
  margin: 0; font-size: 22px; line-height: 30px;
  font-weight: 700; color: var(--ink);
}

.close-drawer {
  font: inherit; font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer; border: 0; padding: 0; flex-shrink: 0;
  background: var(--surface-subtle);
  border-radius: var(--radius-pill);
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.close-drawer:hover { background: var(--surface-hover); color: var(--text-primary); }

.drawer-content {
  padding: var(--space-2) var(--space-6) var(--space-6);
  overflow-y: auto;
  flex-grow: 1;
}

.settings-group { margin-bottom: 30px; }
.settings-group label { display: block; font-size: 11px; line-height: 16px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: var(--space-3); }

.divider { border: 0; border-top: 1px solid var(--border); margin: 30px 0; }
.row-flex { display: flex; gap: 20px; }
.half-width { flex: 1; }

/* ==========================================================================
   Tactile UI Controls
   ========================================================================== */
.segmented-control { display: flex; background: var(--surface-subtle); border-radius: var(--radius-md); padding: 4px; }
.seg-btn { flex: 1; border: none; background: transparent; padding: 8px 0; border-radius: var(--radius-pill); cursor: pointer; font-family: var(--font-sans); font-weight: 600; color: var(--text-secondary); transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.seg-btn.active { background: var(--accent); color: var(--on-primary); box-shadow: var(--shadow-sm); }

.color-swatches { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.swatch { position: relative; flex-shrink: 0; width: 36px; height: 36px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; box-shadow: none; font: inherit; transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }
.swatch:hover { border-color: var(--border-control); box-shadow: var(--shadow-sm); }

.custom-picker { position: relative; display: flex; align-items: center; justify-content: center; background: var(--surface-subtle); color: var(--text-secondary); }
.custom-picker input[type="color"] { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; cursor: pointer; }

.slider-container { display: flex; align-items: center; gap: 15px; }
input[type=range] { flex-grow: 1; -webkit-appearance: none; appearance: none; height: 6px; background: var(--border); border-radius: 3px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-control); cursor: pointer; transition: transform var(--dur-fast) var(--ease); }
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); }

.action-btn { background: var(--surface-subtle); border: none; padding: 10px 15px; min-height: 44px; border-radius: var(--radius-pill); cursor: pointer; font-family: var(--font-sans); font-weight: 600; color: var(--text-primary); transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); display: inline-flex; align-items: center; gap: 8px; }
.action-btn:hover { background: var(--surface-hover); }
.small-btn { padding: 6px 12px; }

/* Disabled button state */
.disabled-btn { background: var(--surface-subtle); color: var(--text-secondary); cursor: not-allowed; opacity: var(--disabled); }
.disabled-btn:hover { background: var(--surface-subtle); }

/* Font Grid with Scrollbar */
.font-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-top: 15px; }
.scrollable-grid { max-height: 250px; overflow-y: auto; padding-right: 5px; }
.scrollable-grid::-webkit-scrollbar { width: 6px; }
.scrollable-grid::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

.font-btn { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); min-height: 44px; padding: 10px 12px; border-radius: var(--radius-md); cursor: pointer; font-size: 16px; transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.font-btn:hover { border-color: var(--border-control); background: var(--surface-hover); }

.image-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); margin-bottom: 15px; }
.image { width: 100%; height: 60px; object-fit: cover; border-radius: var(--radius-sm); cursor: pointer; transition: opacity var(--dur-fast) var(--ease); }
.image:hover { opacity: 0.85; }

.flex-actions { display: flex; gap: var(--space-2); }
.upgrade-notice { font-size: 12px; line-height: 16px; color: var(--text-secondary); background: var(--surface-subtle); border: 1px solid var(--border); padding: 10px 12px; border-radius: var(--radius-md); }
.drawer-footer {
    padding: var(--space-4) var(--space-6);
    background: var(--surface-subtle);
    border-top: 1px solid var(--border);
    text-align: center;
    flex-shrink: 0;
}
.drawer-footer a { color: var(--text-secondary); text-decoration: none; }
.drawer-footer a:hover { color: var(--text-primary); }



/* ==========================================================================
   Animations & Fixes
   ========================================================================== */
.fade { animation: colorchange 240s linear infinite alternate; }
@keyframes colorchange { 0% {background: #92a0dd;} 20% {background: #98c9e9;} 40% {background: #e39bdb;} 60% {background: #62ccca;} 80% {background: #fcad6c;} 100% {background: #fa8089;} }

/* Bottom-Right Snackbar (inverse toast) */
#snackbar {
  visibility: hidden;
  opacity: 0;
  transform: translateY(8px);
  background-color: var(--ink);
  color: var(--surface);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-5);
  position: fixed;
  z-index: 1000;
  top: auto !important;
  bottom: 30px !important;
  right: 30px !important;
  font-size: 14px; line-height: 20px; font-weight: 500;
  font-family: var(--font-sans);
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease), visibility 0s linear var(--dur-base);
}

#snackbar.show {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease), visibility 0s linear 0s;
}

/* Disabled Swatch State */
.disabled-swatch {
  opacity: var(--disabled);
  cursor: not-allowed;
}
.disabled-swatch:hover {
  box-shadow: none; /* Locked items do not lift on hover */
}

/* Swatch Wrappers & Labels */
.swatch-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1); /* Space between the swatch and the text */
}

.swatch-label {
  font-size: 11px;
  line-height: 16px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Custom Input Fields */
.full-width { width: 100%; justify-content: center; }

.custom-input {
  flex-grow: 1;
  padding: 10px 12px;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  min-height: 44px; background: var(--surface-subtle); color: var(--text-primary);
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.custom-input:focus { border-color: var(--accent-ink); } .custom-input::placeholder { color: var(--text-tertiary); opacity: 1; }

/* Current Font Badge */
.current-font-badge {
  font-size: 10px; line-height: 14px;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid var(--border);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Aesthetic Presets */
.preset-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2);
}

.preset-btn {
  width: calc(50% - 4px); /* Two columns without using 1fr */
  position: relative; overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px 5px;
  min-height: 44px;
  font-size: 16px;
  cursor: pointer;
  transition: box-shadow var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  text-align: center;
  text-shadow: none;
}

.preset-btn:hover { box-shadow: var(--shadow-sm); }

.closeSmall { cursor: pointer; color: var(--surface); opacity: 0.8; transition: opacity var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease); font-size: 16px; }
.closeSmall:hover { opacity: 1; }


/* ==========================================================================
   Modal & Hover State Designs
   ========================================================================== */
.community-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--scrim); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    z-index: 9999; display: flex; align-items: center; justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--dur-base) var(--ease), visibility var(--dur-base) var(--ease);
}

.community-modal-overlay.show-modal {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.community-modal-content {
    background: var(--surface); color: var(--text-primary); width: 90%; max-width: 700px;
    border-radius: var(--radius-xl); padding: 25px; box-shadow: var(--shadow-modal);
    max-height: 85vh; display: flex; flex-direction: column;
    transform: scale(0.95);
    transition: transform var(--dur-base) var(--ease);
}

.community-modal-overlay.show-modal .community-modal-content {
    transform: scale(1);
}

.community-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 15px;
    flex-shrink: 0; /* Ensures header never shrinks on mobile */
}
.community-header .close-modal {
    cursor: pointer; font-size: 20px; color: var(--text-secondary); transition: color var(--dur-fast) var(--ease);
}
.community-header .close-modal:hover { color: var(--text-primary); }

.community-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-3); overflow-y: auto; padding-right: 5px;
    flex-grow: 1;
    min-height: 0; /* Critical for scrollbar to appear in flex container */
}

.community-card {
    position: relative;
    height: 175px; /* Tall enough for the hover actions */
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;
    cursor: pointer;
    transition: box-shadow var(--dur-fast) var(--ease);
}
.community-card:hover { box-shadow: var(--shadow-sm); }

.community-card-info {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: opacity var(--dur-base) var(--ease);
}

.community-hover-state {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--scrim); display: flex; flex-direction: column;
    align-items: center; justify-content: center; opacity: 0;
    transition: opacity var(--dur-base) var(--ease);
}

/* Community Hover Avatars */
.community-avatar-container { margin-bottom: 6px; display: flex; justify-content: center; }

.community-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--on-glass);
    box-shadow: none;
}

.community-avatar-placeholder {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--on-primary);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 16px;
    border: 2px solid var(--on-glass);
    box-shadow: none;
}

.community-card:hover .community-hover-state,
.community-card:focus-within .community-hover-state { opacity: 1; }
.community-card:hover .community-card-info,
.community-card:focus-within .community-card-info { opacity: 0.2; }

/* UNIFIED HOVER TEXT & BUTTONS FOR ALL TABS (the hover state is a dark scrim, so text is on-glass) */
.community-hover-state .hover-title {
    color: var(--on-glass);
    font-size: 12px;
    line-height: 16px;
    margin-bottom: 8px;
    font-weight: 600;
    text-align: center;
    padding: 0 5px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.community-hover-state .hover-actions {
    display: flex;
    gap: var(--space-1);
    justify-content: center;
}

.community-hover-state .hover-actions button,
.apply-comm-btn {
    background: var(--primary); color: var(--on-primary); border: none; padding: 5px 12px !important;
    border-radius: var(--radius-pill); font-family: var(--font-sans); font-weight: 600; cursor: pointer; font-size: 12px !important;
}
.community-hover-state .hover-actions button:hover,
.apply-comm-btn:hover { box-shadow: var(--shadow-sm); }

/* Theme Library Tabs */
.theme-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
    flex-shrink: 0; /* Ensures tabs never shrink on mobile */
}

.theme-tab-btn {
    background: transparent;
    border: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 12px;
    cursor: pointer;
    border-radius: var(--radius-pill);
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.theme-tab-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.theme-tab-btn.active {
    background: var(--accent);
    color: var(--on-primary);
}

/* Tab Panes */
.theme-tab-pane {
    display: none; /* Hide all by default */
    animation: fadeInTab var(--dur-base) var(--ease);
}

.theme-tab-pane.active-pane {
    display: flex; /* Show active tab */
    flex-direction: column;
    flex-grow: 1;
    min-height: 0; /* Critical for scrollbar to appear in flex container */
}

/* Ensure the "Surprise Me" footer never gets crushed */
/* Ensure the "Surprise Me" footer never gets crushed */
.theme-tab-pane .community-grid + div {
    flex-shrink: 0;
}

@keyframes fadeInTab {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Bulletproof Drawer Grid (Forces 2 Columns & limits items)
   ========================================================================== */
#drawerSavedStylesGrid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
}

/* Use nth-of-type to completely ignore invisible <link> tags! */
#drawerSavedStylesGrid > div:nth-of-type(n+3) {
    display: none !important;
}

/* ==========================================================================
   Mobile Responsiveness Fixes
   ========================================================================== */
@media (max-width: 600px) {
    .community-modal-content {
        width: 95%;
        padding: 15px; 
        max-height: 90vh;
    }
    
    #littleNavbar {
        top: auto;
        bottom: calc(25px + env(safe-area-inset-bottom, 0px));
        left: 50%; /* Center it perfectly */
        right: auto;
        transform: translateX(-50%);
        width: max-content; /* Shrink-wrap the icons so it stays centered */
        max-width: calc(100vw - 32px);
        padding: var(--space-1) var(--space-2);
        gap: 4px;
        justify-content: center;
        overflow: visible; /* No horizontal scroll: extra apps live in All apps */
    }

    /* Five apps plus All apps fit a 375px phone; a running focus timer always stays */
    #littleNavbar a[data-app-id]:nth-of-type(n+6):not(.has-active-timer) {
        display: none;
    }

    #littleNavbar a {
        font-size: 20px;
        flex-shrink: 0; /* CRITICAL: Prevents icons from squishing to fit the screen */
    }

    #littleNavbar .nav-divider {
        margin: 0 2px !important; /* Shrink the gap around dividers */
    }
    
    .top-brand {
        top: calc(25px + env(safe-area-inset-top, 0px));
        left: calc(16px + env(safe-area-inset-left, 0px));
    }

    .theme-tabs {
        flex-wrap: wrap; 
        justify-content: center;
        gap: 5px;
    }
    
    .theme-tab-btn {
        font-size: 13px;
        padding: 6px 10px;
    }
    
    .community-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
    }
} /* <-- ONLY ONE CLOSING BRACKET HERE */

/* ==========================================================================
   Hide Fullscreen Button on Mobile, Tablet & Smart TV
   ========================================================================== */
/* ==========================================================================
   Hide Fullscreen Button on Mobile, Tablet & Smart TV
   ========================================================================== */
@media (max-width: 1024px), /* Catches standard phones and tablets */
       (pointer: coarse),   /* Catches large touchscreens like iPad Pro */
       (hover: none) {      /* Catches devices without a mouse, like Smart TVs */
    
    #navFullscreen {
        display: none !important;
    }
}
/* ==========================================================================
   Settings Drawer Accordions
   ========================================================================== */
.accordion-item {
    border-bottom: 1px solid var(--border);
}

.accordion-header {
    width: 100%;
    min-height: 44px;
    text-align: left;
    padding: 18px 0;
    background: none;
    border: none;
    font-family: var(--font-sans);
    font-weight: 600; font-size: 15px; line-height: 22px;
    color: var(--ink);
    display: flex; align-items: center;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background-color var(--dur-fast) var(--ease);
}

.accordion-header:hover { background: var(--surface-hover); }

.accordion-header .acc-icon {
    width: 24px;
    font-size: 16px;
    color: var(--accent-ink);
    margin-right: 10px;
}

.accordion-header .chevron {
    margin-left: auto;
    color: var(--text-secondary);
    font-size: 12px;
    transition: transform var(--dur-base) var(--ease);
}

.accordion-content {
    display: none;
    padding-bottom: 20px;
    animation: fadeInTab var(--dur-base) var(--ease);
}

/* Active State */
.accordion-item.active .accordion-header .chevron {
    transform: rotate(180deg);
}

.accordion-item.active .accordion-content {
    display: block;
}

/* Remove default margins from settings groups when inside accordions */
.accordion-content .settings-group:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   Smart TV & Desktop Keyboard Accessibility
   ========================================================================== */
/* Only shows the outline if they are using a keyboard or TV remote to navigate */
:focus-visible {
    outline: 2px solid var(--focus) !important;
    outline-offset: 2px;


}

/* Hide the ring only for mouse focus; browsers without :focus-visible keep their default outline */
:focus:not(:focus-visible) {
    outline: none; 
}

/* ==========================================================================
   Draggable Spotify Window
   ========================================================================== */
.draggable-window {
    position: fixed;
    top: 90px;
    right: 25px;
    width: 380px;
    height: 520px;
    max-height: 85vh;
    background: rgba(25, 20, 20, 0.65);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-xl);
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    z-index: 1005;
    display: none;
    flex-direction: column;
    overflow: hidden;
    resize: both;
    min-width: 300px;
    min-height: 250px;
    max-width: 95vw;
}

.window-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

.draggable-window.show-window { 
    display: flex !important; 
}
/* ADD THIS TO style.css right below .draggable-window.show-window */
.community-modal-overlay.show-modal {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    display: flex !important; /* Forces it to display flex when active */
}

/* Add this new block for the gear icon */
.action-icon {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    transition: color 0.2s;
}

.action-icon:hover {
    color: var(--text-primary);
}

.window-header {
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: grab;
    user-select: none;
}

.window-header:active {
    cursor: grabbing;
}

.close-window {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 16px;
    transition: color 0.2s;
}

.close-window:hover {
    color: var(--text-primary);
}



/* Offsets the timer window slightly lower and more to the left by default */
.timer-offset {
    top: 120px;
    right: 400px;
    width: 320px; 
}

/* ==========================================================================
   Timer Modal Aesthetics (Focus Centre presets; tokens, rebrand P6)
   ========================================================================== */
.preset-timer-btn {
    position: relative;
    min-height: 32px !important;
    background: transparent !important;
    color: var(--text-secondary) !important;
    border: none !important;
    border-radius: var(--radius-pill) !important;
    padding: 0 12px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease) !important;
}

.preset-timer-btn:hover {
    background: var(--surface-hover) !important;
    color: var(--text-primary) !important;
}

.preset-timer-btn.active-preset {
    background: var(--accent) !important;
    color: var(--on-primary) !important;
    box-shadow: var(--shadow-sm) !important;
}

/* Hide standard number arrows on the custom input */
#customTimerInput::-webkit-outer-spin-button,
#customTimerInput::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ==========================================================================
   Ambient Mixer Aesthetics
   ========================================================================== */
.mixer-track {
    display: flex;
    align-items: center;
    margin-bottom: 18px;
    gap: 15px;
}

.mixer-track label {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    width: 90px; /* Keeps all sliders perfectly aligned */
    display: flex;
    gap: 8px;
    align-items: center;
}

.mixer-track input[type=range] {
    flex-grow: 1;
}
/* ==========================================================================
   Leaderboard Aesthetics
   ========================================================================== */
.leaderboard-row {
    display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
    min-height: 52px; box-sizing: border-box;
    background: var(--surface-subtle); padding: 8px 12px; border: 1px solid transparent; border-radius: var(--radius-md);
    color: var(--text-primary); text-align: left;
    transition: background-color var(--dur-fast) var(--ease);
}
.leaderboard-row:hover { background: var(--surface-hover); }
.leaderboard-row.is-me {
    background: var(--primary-tint);
    border: 1px solid var(--primary-line);
}
.rank-badge {
    width: 24px; height: 24px; flex-shrink: 0; background: var(--surface-hover); color: var(--text-primary); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.rank-1 { background: var(--gold); color: var(--on-primary); }
.rank-2 { background: var(--medal-silver); color: var(--surface); }
.rank-3 { background: var(--medal-bronze); color: var(--surface); }

/* REUSABLE FOCUS TABS */
.focus-tab-pane {
    display: none;
    animation: fadeInTab 0.3s ease;
}
/* Text inside the Focus Centre and Challenge panes follows the window's tokens. */
.focus-tab-pane, .challenge-sub-pane {
    color: var(--text-primary);
}




.challenge-sub-pane {
    display: none;
    animation: fadeInTab 0.3s ease;
}

/* Specific styling for the leaderboard rows to make them legible */
.leaderboard-row span {
    font-size: 14px;
    font-weight: 500;
}

/* The score column takes its colour from its own markup. */
.leaderboard-row span:last-child {
    font-weight: 600;
}


/* Forest stats wrapper: the stat tiles carry their own wells. */
.forest-stats {
    background: transparent;
    padding: 0;
    border-radius: var(--radius-lg);
    width: 100%;
    text-align: center;
}

.focus-tab-pane.active-pane {
    display: flex;
}
/* Widen the Focus Modal and prevent squishing */
/* Widen the Focus Modal and prevent squishing */
#focusModal.focus-window-large {
    width: 380px;
    height: 520px;
    max-height: 85vh;
    display: none;
    flex-direction: column;
}

.focus-content-scroll {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.focus-main-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Visibility fix for tabs */
.focus-tab-pane {
    display: none; /* JavaScript overrides this */
    flex-direction: column;
    width: 100%;
    align-items: center;
    padding-top: 4px;
}

.focus-tab-pane.active-pane {
    display: flex !important;
}

/* Timer Styling */
.big-timer-text {
    font-size: 72px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 20px;
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.preset-container {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    width: 100%;
}

.custom-input-group {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-bottom: 15px;
}

.tree-hint {
    font-size: 12px;
    color: var(--primary-ink);
    background: var(--primary-tint);
    padding: 8px 15px;
    border-radius: var(--radius-pill);
    margin-bottom: 20px;
}

.timer-controls {
    display: flex;
    gap: 10px;
    width: 100%;
}

.start-focus-btn {
    flex-grow: 2;
    background: var(--primary) !important;
    color: var(--on-primary) !important;
    font-weight: 600;
}

/* Forest Icon Styling */
.tree-icon-main {
    font-size: 80px;
    color: var(--primary-ink);
    margin-bottom: 15px;
}

.leaderboard-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* NEW: Allow the leaderboard to scroll independently if it gets too long */
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 5px; /* Adds a tiny bit of breathing room for the scrollbar */
}

/* Scrollbar inside the leaderboard list */
.leaderboard-list::-webkit-scrollbar { width: 6px; }
.leaderboard-list::-webkit-scrollbar-thumb { background: var(--border-control); border-radius: 3px; }

/* iOS Style Toggle Switch */
.theme-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}
.theme-switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.theme-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--surface-hover); box-shadow: inset 0 0 0 1px var(--border-control);
  transition: background-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.theme-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: var(--border-control);
  transition: transform var(--dur-base) var(--ease), background-color var(--dur-base) var(--ease);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .theme-slider {
  background-color: var(--primary); box-shadow: none;
}
input:focus-visible + .theme-slider {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
input:checked + .theme-slider:before {
  transform: translateX(18px); background-color: var(--on-primary);
}
.theme-slider.round {
  border-radius: var(--radius-pill);
}
.theme-slider.round:before {
  border-radius: 50%;
}
/* ==========================================================================
   PREMIUM LIVE BACKGROUNDS (CSS)
   ========================================================================== */

/* 1. The smooth fade-in animation */
@keyframes smoothBgFade {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* 2. Apply it to all Canvas backgrounds */
#liveBgCanvas {
    position: fixed;
    top: 0; 
    left: 0;
    width: 100vw; 
    height: 100vh;
    z-index: -1;
    pointer-events: none;
    animation: smoothBgFade 0.5s ease-out; /* Smooth fade in */
}

.live-bg-aurora {
    background-color: #010a17 !important;
    position: relative;
    overflow: hidden;
}

/* 3. Apply it to the Aurora background (Notice the comma separating the two animations!) */
.live-bg-aurora::before {
    content: "";
    position: absolute;
    top: -50%; 
    left: -50%;
    width: 200%;
    height: 200%;
    z-index: 0;
    pointer-events: none;
    
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(0, 255, 178, 0.4) 0%, transparent 40%),  
        radial-gradient(circle at 80% 80%, rgba(106, 5, 255, 0.3) 0%, transparent 50%),   
        radial-gradient(circle at 50% 10%, rgba(0, 162, 255, 0.25) 0%, transparent 60%), 
        radial-gradient(circle at 90% 10%, rgba(255, 105, 180, 0.1) 0%, transparent 30%) !important; 
        
    background-size: 200% 200% !important;
    
    /* ADDED smoothBgFade here: */
    animation: smoothBgFade 0.6s ease-out, aurora-shift 15s ease-in-out infinite alternate !important; 
}

/* 3. The Movement Keyframes */
@keyframes aurora-shift {
    0% { background-position: 0% 50%; opacity: 0.5; }
    50% { background-position: 100% 50%; opacity: 1; }
    100% { background-position: 0% 50%; opacity: 0.5; }
}

/* 4. Fix for Community Cards & Swatches */
/* We need to ensure the text stays visible above the pseudo-element glow! */
.community-card.live-bg-aurora .community-card-info,
.swatch.live-bg-aurora {
    position: relative;
    z-index: 2;
}
/* Hide Google reCAPTCHA Floating Badge */
.grecaptcha-badge {
    visibility: hidden !important;
    opacity: 0 !important;
}
/* ==========================================================================
   Auth Modal Sliding Switch
   ========================================================================== */
.auth-toggle-container {
    position: relative;
    display: flex;
    background: #f0f0f0;
    border-radius: 30px;
    padding: 4px;
    margin: 0 auto 20px auto;
    width: 85%;
}

.auth-toggle-slider {
    position: absolute;
    top: 4px; 
    left: 4px; 
    bottom: 4px;
    width: calc(50% - 4px);
    background: #fff;
    border-radius: 26px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* When the container has this class, slide the pill to the right */
.auth-toggle-container.register-active .auth-toggle-slider {
    transform: translateX(100%);
}

.auth-toggle-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 0;
    font-size: 13px;
    font-weight: bold;
    color: #888;
    cursor: pointer;
    position: relative;
    z-index: 1;
    transition: color 0.3s;
    font-family: 'Poppins', sans-serif;

}

.auth-toggle-btn.active {
    color: #333;
}

/* ==========================================================================
   DARK MODE OVERRIDES (Applies to Settings Drawer & Modals)
   ========================================================================== */
body.dark-mode .drawer,
body.dark-mode .community-modal-content,
body.dark-mode .account-menu-popover {
    background-color: var(--surface) !important;
    border-color: var(--border) !important;
}

body.dark-mode .drawer-header,
body.dark-mode .community-header,
body.dark-mode .accordion-item,
body.dark-mode .theme-tabs,
body.dark-mode .modal-divider {
    border-color: var(--border) !important;
}

body.dark-mode .drawer-header h2,
body.dark-mode .community-header h2,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode .accordion-header {
    color: var(--ink) !important;
}

/* FIXED: Give the drawer close button its box, but keep the modal close button transparent */
body.dark-mode .close-drawer {
    background: var(--surface-subtle) !important;
    color: var(--text-secondary) !important;
}
body.dark-mode .close-modal {
    background: transparent !important;
    color: var(--text-secondary) !important;
}

body.dark-mode .close-drawer:hover,
body.dark-mode .close-modal:hover {
    color: var(--text-primary) !important;
}
body.dark-mode .close-drawer:hover {
    background: var(--surface-hover) !important;
}

/* FIXED: Force the drawer footer buttons (Share/Tour/Feedback) to override their inline white backgrounds */
body.dark-mode .drawer-footer .action-btn {
    background: var(--surface-subtle) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}
body.dark-mode .drawer-footer .action-btn:hover {
    background: var(--surface-hover) !important;
}

body.dark-mode .custom-input {
    background: var(--surface-subtle) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-control) !important;
}

/* FIXED: Font buttons now have white text */
body.dark-mode .font-btn {
    background: var(--surface-subtle) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

/* FIXED: Removed the hardcoded dark backgrounds from community cards 
   and preset buttons so their original colors/images shine through! */
body.dark-mode .preset-btn,
body.dark-mode .community-card {
    border-color: var(--border) !important;
}

body.dark-mode .theme-tab-btn {
    color: var(--text-secondary);
}
body.dark-mode .theme-tab-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}
body.dark-mode .theme-tab-btn.active {
    background: var(--accent);
    color: var(--on-primary);
}

/* FIXED: Removed !important from background & color so inline accented buttons keep their pop! */
body.dark-mode .action-btn {
    background: var(--surface-subtle);
    color: var(--text-primary);
    border-color: var(--border) !important;
}
body.dark-mode .action-btn:hover {
    background: var(--surface-hover);
}
body.dark-mode .action-btn.active {
    background: var(--accent) !important;
    color: var(--on-primary) !important;
}

/* FIXED: Make the 'A' font size icons visible in dark mode */
body.dark-mode .slider-container i.fa-font {
    color: var(--text-secondary) !important;
}

/* Modals & Dropdowns Specific Fixes */
body.dark-mode .upgrade-notice,
body.dark-mode .community-toggle-bar,
body.dark-mode .pref-panel {
    background: var(--surface-subtle) !important;
    border-color: var(--border) !important;
}

/* Apple's brand mark follows the text colour so it stays visible on the panel in both themes (Connected Accounts) */
.provider-icon-apple {
    color: var(--ink);
}

/* Connected Accounts provider name labels (Google/Apple) */
.provider-label {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}

/* Subscription & Billing tab (My Account modal). renderManageSubView() in index.js builds
   this content from the msub-* classes; every value is a token, so one set of rules covers
   both themes. The body.dark-mode scope and !important stay because older cached markup
   still carries inline light colours. Layout lives in css/cfo-account.css. */
body.dark-mode .msub-card {
    background: var(--surface) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}
body.dark-mode .msub-heading {
    color: var(--ink) !important;
}
body.dark-mode .msub-subtext {
    color: var(--text-secondary) !important;
}
body.dark-mode .msub-danger-text {
    color: var(--danger) !important;
}
body.dark-mode .msub-translucent-card {
    background: var(--surface-subtle) !important;
    border-color: var(--border) !important;
}
body.dark-mode .msub-warn-box {
    background: var(--danger-tint) !important;
    border-color: var(--danger-line) !important;
}
body.dark-mode .msub-warn-title {
    color: var(--danger) !important;
}
body.dark-mode .msub-warn-text {
    color: var(--text-primary) !important;
}
body.dark-mode .msub-term-btn {
    background: var(--surface) !important;
    border-color: var(--border) !important;
}
body.dark-mode .msub-divider {
    border-top-color: var(--border) !important;
}
body.dark-mode #manageSubCurrencySelector {
    background: var(--surface-subtle) !important;
    border-color: var(--border-control) !important;
    color: var(--text-primary) !important;
}
body.dark-mode #manageSubSubtitle,
body.dark-mode #manageSubLoading {
    color: var(--text-secondary) !important;
}

/* Preferences, Security, and Settings Panels (Light & Dark) */
.pref-panel {
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

/* Security Tab & 2FA Components (Light & Dark) */
.totp-setup-box {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.totp-secret-badge {
    font-family: monospace;
    color: var(--ink);
    letter-spacing: 1px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    user-select: all;
    display: inline-block;
}
.pref-method-label {
    background: var(--surface);
    border: 1px solid var(--border-control);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.pref-method-label input { accent-color: var(--primary); }
.pref-method-label.pref-active {
    border-color: var(--accent) !important;
    background: var(--surface) !important;
    box-shadow: 0 0 0 1px var(--accent);
}
.btn-disconnect {
    background: var(--danger-tint);
    color: var(--danger);
    border: 1px solid var(--danger-line);
}
.danger-zone-panel {
    background: var(--danger-tint) !important;
    border: 1px solid var(--danger-line) !important;
}
body.dark-mode .setup-hint {
    color: var(--text-secondary) !important;
}

/* Active Sessions & Device Manager */
.session-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.session-card.session-current {
    background: var(--surface);
    border-color: var(--primary-line);
    box-shadow: inset 3px 0 0 var(--primary);
}
.session-icon-box {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--surface-subtle);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.session-card.session-current .session-icon-box {
    background: var(--primary-tint);
    color: var(--primary-ink);
}
.session-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.session-subtext {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.session-this-device-badge {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--primary-tint);
    color: var(--primary-ink);
    font-size: 10px;
    line-height: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.session-current-label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-ink);
    white-space: nowrap;
}
.session-current-label i, .session-current-label svg { font-size: 8px; }
.btn-revoke-session {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: 36px;
    background: var(--surface-subtle);
    border: 1px solid transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 0 var(--space-3);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
    white-space: nowrap;
}
.btn-revoke-session:hover {
    background: var(--danger-tint);
    border-color: var(--danger-line);
    color: var(--danger);
}

/* Custom Settings Drawer Elements for Dark Mode */
body.dark-mode .settings-group label {
    color: var(--text-secondary) !important;
}
body.dark-mode .segmented-control {
    background: var(--surface-subtle) !important;
}
body.dark-mode .seg-btn {
    color: var(--text-secondary) !important;
}
body.dark-mode .seg-btn.active {
    background: var(--accent) !important;
    color: var(--on-primary) !important;
}
body.dark-mode .current-font-badge {
    background: var(--surface-hover) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}
body.dark-mode .custom-picker {
    background: var(--surface-subtle) !important;
    color: var(--text-primary) !important;
}

/* Make scrollbars elegant globally for tab panes */
.theme-tab-pane::-webkit-scrollbar { width: 6px; }
.theme-tab-pane::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }
/* ==========================================================================
   DRAWER FOOTER (tokens; light and dark follow the theme)
   ========================================================================== */
.drawer-footer .action-btn { font-size: 13px; padding: 0 var(--space-2); justify-content: center; }
.drawer-footer .action-btn i { margin-right: 0; }















































/* ==========================================================================
   ACCOUNT MENU POPOVER (Light Mode Default)
   ========================================================================== */
   
   /* ==========================================================================
   ACCOUNT MENU POPOVER (Light Mode Default)
   ========================================================================== */
.account-menu-popover { 
    position: fixed; 
    width: 280px; 
    background: rgba(255, 255, 255, 0.95); 
    backdrop-filter: blur(20px); 
    -webkit-backdrop-filter: blur(20px); 
    border: 1px solid rgba(0, 0, 0, 0.1); 
    border-radius: 20px; 
    box-shadow: 0 15px 35px rgba(0,0,0,0.15); 
    z-index: 1050; 
    padding: 15px; 
    opacity: 0; 
    visibility: hidden; 
    pointer-events: none; 
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); 
    display: flex; 
    flex-direction: column; 
    gap: 15px; 
    /* FIXED: Mobile Scrolling Enabled */
    max-height: 80vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Custom neat scrollbar for the popover */
.account-menu-popover::-webkit-scrollbar { width: 4px; }
.account-menu-popover::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }
body.dark-mode .account-menu-popover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); }

.account-menu-popover.show-popover { 
    opacity: 1 !important; 
    visibility: visible !important; 
    pointer-events: auto !important; 
}

@media (min-width: 601px) {
    .account-menu-popover { top: 80px; right: 20px; transform: translateY(-20px) scale(0.95); transform-origin: top right; }
    .account-menu-popover.show-popover { transform: translateY(0) scale(1); }
}

@media (max-width: 600px) {
    .account-menu-popover { bottom: 85px; left: 50%; transform: translateX(-50%) translateY(20px) scale(0.95); transform-origin: bottom center; }
    .account-menu-popover.show-popover { transform: translateX(-50%) translateY(0) scale(1); }
}

/* Nav Avatar Link styling */
.nav-avatar-link { display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.nav-avatar-circle { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; border: 2px solid transparent; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.nav-avatar-link:hover .nav-avatar-circle, .nav-avatar-link.active-glow .nav-avatar-circle { border-color: #cebfaf; transform: scale(1.1); }
.nav-avatar-circle img { width: 100%; height: 100%; object-fit: cover; }
.nav-avatar-circle div { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; font-size: 12px; font-family: 'Poppins', sans-serif; }

@media (max-width: 600px) {
    .nav-avatar-circle { width: 24px; height: 24px; margin-bottom: 2px; }
    .nav-avatar-circle div { font-size: 10px; }
}

/* FIXED: Hoverable Avatar Header */
.acc-menu-header { 
    display: flex; align-items: center; gap: 12px; padding: 10px; border-bottom: 1px solid rgba(0,0,0,0.05); 
    border-radius: 12px; cursor: pointer; transition: background 0.2s; margin: -5px -5px 0 -5px;
}
.acc-menu-header:hover { background: rgba(0,0,0,0.04); }
body.dark-mode .acc-menu-header:hover { background: rgba(255,255,255,0.05); }

.acc-menu-avatar img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(0,0,0,0.1); }
.acc-menu-avatar div { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; color: white; font-size: 18px; border: 2px solid rgba(0,0,0,0.1); }
.acc-menu-info { display: flex; flex-direction: column; }
.acc-menu-name { color: #333; font-weight: 700; font-size: 15px; font-family: 'Poppins', sans-serif; text-decoration: none; }
.acc-menu-role { color: #888; font-size: 11px; text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; margin-top: 2px; }

.account-menu-popover.show-popover { 
    opacity: 1 !important; 
    visibility: visible !important; 
    pointer-events: auto !important; 
}

@media (min-width: 601px) {
    .account-menu-popover { top: 80px; right: 20px; transform: translateY(-20px) scale(0.95); transform-origin: top right; }
    .account-menu-popover.show-popover { transform: translateY(0) scale(1); }
}

@media (max-width: 600px) {
    .account-menu-popover { bottom: 85px; left: 50%; transform: translateX(-50%) translateY(20px) scale(0.95); transform-origin: bottom center; }
    .account-menu-popover.show-popover { transform: translateX(-50%) translateY(0) scale(1); }
}

/* Nav Avatar Link styling */
.nav-avatar-link { display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.nav-avatar-circle { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; border: 2px solid transparent; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.nav-avatar-link:hover .nav-avatar-circle, .nav-avatar-link.active-glow .nav-avatar-circle { border-color: #cebfaf; transform: scale(1.1); }
.nav-avatar-circle img { width: 100%; height: 100%; object-fit: cover; }
.nav-avatar-circle div { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; font-size: 12px; font-family: 'Poppins', sans-serif; }

@media (max-width: 600px) {
    .nav-avatar-circle { width: 24px; height: 24px; margin-bottom: 2px; }
    .nav-avatar-circle div { font-size: 10px; }
}

.acc-menu-avatar img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(0,0,0,0.1); }
.acc-menu-avatar div { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; color: white; font-size: 18px; border: 2px solid rgba(0,0,0,0.1); }
.acc-menu-info { display: flex; flex-direction: column; }
.acc-menu-name { color: #333; font-weight: 700; font-size: 15px; font-family: 'Poppins', sans-serif; }
.acc-menu-role { color: #888; font-size: 11px; text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; margin-top: 2px; }

.acc-stats-row { display: flex; gap: 8px; margin-bottom: 15px; border-bottom: 1px solid rgba(0,0,0,0.05); padding-bottom: 15px; }
.acc-stat-box { background: #f9f9f9; border: 1px solid #eee; border-radius: 8px; padding: 8px; flex: 1; text-align: center; }
.acc-stat-label { font-size: 9px; color: #888; text-transform: uppercase; font-weight: bold; letter-spacing: 0.5px; }
.acc-stat-value { font-size: 13px; color: #333; font-weight: 600; margin-top: 3px; }

.acc-admin-box { background: #fdfdfd; border-radius: 8px; padding: 10px; margin-bottom: 15px; border: 1px dashed rgba(0, 0, 0, 0.15); }
.acc-admin-title { font-size: 10px; color: #888; text-transform: uppercase; font-weight: bold; margin-bottom: 8px; }
.acc-admin-title i { color: #cebfaf; }
.acc-admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.acc-admin-grid button { background: #f0f0f0; color: #555; border: none; padding: 8px 6px; border-radius: 4px; font-size: 11px; font-weight: bold; cursor: pointer; transition: 0.2s; }
.acc-admin-grid button.active { background: #cebfaf; color: #fff; }
.acc-admin-grid button:hover:not(.active) { background: #e0e0e0; }

.acc-theme-toggle { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding: 0 12px 12px 12px; border-bottom: 1px solid rgba(0,0,0,0.05); }
.acc-theme-toggle span { font-size: 13px; color: #555; font-family: 'Poppins', sans-serif; font-weight: 500; }
.acc-theme-toggle i { width: 18px; text-align: center; color: #cebfaf; margin-right: 6px; }
.acc-theme-toggle .theme-switch { transform: scale(0.85); transform-origin: right; margin: 0; }

.acc-menu-links { display: flex; flex-direction: column; gap: 4px; }
.acc-menu-links a { color: #555; text-decoration: none; font-size: 13px; font-family: 'Poppins', sans-serif; padding: 10px 12px; border-radius: 8px; transition: 0.2s; display: flex; align-items: center; gap: 10px; font-weight: 500; }
.acc-menu-links a:hover { background: rgba(0,0,0,0.04); color: #000; }
.acc-menu-links a i { width: 18px; text-align: center; color: #cebfaf; }
.acc-menu-links a.logout-link { color: #d9534f; margin-top: 5px; }
.acc-menu-links a.logout-link i { color: #d9534f; }

.acc-menu-referral { background: #fdfdfd; border-radius: 12px; padding: 15px; border: 1px solid #eee; margin-bottom: 15px; }
.acc-menu-referral p { font-size: 11px; color: #666; line-height: 1.4; margin: 0 0 12px 0; }
.acc-ref-count { font-size: 14px; font-weight: bold; color: #333; }
.acc-progress-bg { width: 100%; background: rgba(0,0,0,0.05); height: 6px; border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.acc-menu-btn { width: 100%; background: #cebfaf; color: #fff; border: none; padding: 10px; border-radius: 8px; font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 600; cursor: pointer; transition: 0.2s; display: block; text-align: center; text-decoration: none; }
.acc-menu-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* ==========================================================================
   DARK MODE OVERRIDES
   ========================================================================== */

/* Drawer footer: dark values come from the tokens (body.dark-mode), see .drawer-footer above */






/* Account Menu Overrides */
body.dark-mode .account-menu-popover { background: rgba(25, 20, 20, 0.95); border-color: rgba(255,255,255,0.1); box-shadow: 0 20px 40px rgba(0,0,0,0.4); }
body.dark-mode .acc-menu-avatar img { border-color: rgba(255,255,255,0.2); }
body.dark-mode .acc-menu-avatar div { border-color: rgba(255,255,255,0.2); }
body.dark-mode .acc-menu-name { color: #fff; }
body.dark-mode .acc-menu-role { color: #aaa; }
body.dark-mode .acc-menu-header, body.dark-mode .acc-stats-row, body.dark-mode .acc-theme-toggle { border-color: rgba(255,255,255,0.1); }
body.dark-mode .acc-stat-box { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }
body.dark-mode .acc-stat-label { color: #aaa; }
body.dark-mode .acc-stat-value { color: #fff; }
body.dark-mode .acc-admin-box { background: rgba(0,0,0,0.4); border-color: rgba(230, 194, 122, 0.5); }
body.dark-mode .acc-admin-title { color: #e6c27a; }
body.dark-mode .acc-admin-grid button { background: rgba(255,255,255,0.1); color: #fff; }
body.dark-mode .acc-admin-grid button.active { background: #e6c27a; color: #000; }
body.dark-mode .acc-admin-grid button:hover:not(.active) { background: rgba(255,255,255,0.2); }
body.dark-mode .acc-theme-toggle span { color: #ccc; }
body.dark-mode .acc-menu-links a { color: #ccc; }
body.dark-mode .acc-menu-links a:hover { background: rgba(255,255,255,0.1); color: #fff; }
body.dark-mode .acc-menu-referral { background: rgba(0,0,0,0.3); border-color: rgba(255,255,255,0.05); }
body.dark-mode .acc-menu-referral p { color: #aaa; }
body.dark-mode .acc-ref-count { color: #fff; }
body.dark-mode .acc-progress-bg { background: rgba(255,255,255,0.1); }
body.dark-mode .acc-menu-divider { background: rgba(255,255,255,0.1) !important; }
/* ==========================================================================
   SAVE/PUBLISH THEME BOX (Light & Dark Styles)
   ========================================================================== */
/* Light Mode Base */
.save-theme-box { background: #fdfdfd; }
.publish-label { color: #666; }

/* Dark Mode Overrides */
body.dark-mode .save-theme-box {
    background: #222 !important;
    border-color: #333 !important;
}
body.dark-mode .publish-label {
    color: #aaa !important;
}
body.dark-mode .save-theme-box .custom-input {
    background: #1a1a1a !important;
    border-color: #444 !important;
    color: #fff !important;
}
/* ==========================================================================
   UPGRADE MODAL (tokens: one rule set serves light and dark; P3 overrides live in css/cfo-commerce.css)
   ========================================================================== */
/* .upg-title/.upg-subtitle/.upg-features-box are shared with the universal modal, whose inline colours these still beat. */
.upg-title,
#universalModalTitle { color: var(--ink) !important; font-weight: 700; }
.upg-subtitle,
#universalModalDesc { color: var(--text-secondary) !important; }
.upg-toggle-bg { background: var(--surface-subtle); }
.upg-toggle-btn { background: transparent; color: var(--text-secondary); }
.upg-toggle-btn.active { background: var(--accent); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.upg-price { color: var(--ink); }
.upg-price-sub { color: var(--text-secondary); }
.upg-features-box { background: var(--surface-subtle) !important; border: 1px solid var(--border) !important; border-radius: var(--radius-lg); }
.upg-feature-item { color: var(--text-primary); }

/* The universal modal's feature rows are written by JS with inline greys meant for a white card. */
body.dark-mode #universalModalFeatureList div,
body.dark-mode #universalModalFeatureList span {
    color: var(--text-primary) !important;
}
.community-hover-state .hover-actions {
        flex-wrap: wrap; /* Allows buttons to drop to the next line safely */
    }
    .community-hover-state .hover-actions button, .apply-comm-btn {
        padding: 5px 8px !important; /* Smaller padding */
        font-size: 10px !important;
    }
    .community-card {
        height: 195px !important; /* Expand card height on mobile to fit the wrapped buttons */
    }
 /* STOP ICONS & TEXT FROM STEALING CLICKS INSIDE BUTTONS */
.apply-comm-btn *, 
.action-btn *, 
.preset-btn * {
    pointer-events: none !important;
}
/* ==========================================================================
   Smooth Digital & Analogue Clock Engine
   ========================================================================== */
/* Stop icons & text from stealing clicks inside buttons */
.apply-comm-btn *, 
.action-btn *, 
.preset-btn * {
    pointer-events: none !important;
}

/* Smooth Digital Transition */
.clock-smooth span { display: inline-block; animation: popUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popUp { 0% { transform: translateY(15px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }

/* True Per-Digit Odometer Scrolling */
#clock { 
    font-variant-numeric: tabular-nums; 
    line-height: 1; 
} 

.smooth-time-transition {
    display: flex;
    align-items: baseline; 
    justify-content: center;
    white-space: pre; 
}

.digit-static {
    display: inline-block;
}

.digit-scroll { 
    position: relative;
    display: inline-block;
    height: 1.2em;
    vertical-align: bottom; 
    overflow: hidden; 
}

.digit-num {
    width: 1ch; 
    text-align: center;
}

.digit-new {
    display: inline-block;
    animation: slideIn 0.3s ease-out forwards; 
}

.digit-old { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%;
    animation: slideOut 0.3s ease-out forwards; 
}

@keyframes slideIn { 
    0% { transform: translateY(100%); } 
    100% { transform: translateY(0); } 
}
@keyframes slideOut { 
    0% { transform: translateY(0); } 
    100% { transform: translateY(-100%); } 
}

/* Analogue Clock Engine */
.analogue-face { 
    width: 1em; 
    height: 1em; 
    border: 0.05em solid currentColor; 
    border-radius: 50%; 
    position: relative; 
    margin: 0 auto;
    display: block; 
    box-sizing: border-box; 
}
.clock-hand { position: absolute; bottom: 50%; left: 50%; transform-origin: bottom center; background: currentColor; border-radius: 10px; }
.hand-hour { width: 0.04em; height: 0.25em; margin-left: -0.02em; }
.hand-min { width: 0.02em; height: 0.35em; margin-left: -0.01em; }
.hand-sec { width: 0.01em; height: 0.4em; margin-left: -0.005em; background: #d9534f; }
.clock-number { position: absolute; transform: translate(-50%, -50%); font-size: 0.13em; font-weight: 600; line-height: 1; }
/* ==========================================================================
   THEME INFO MODAL (both themes: every value is a token)
   ========================================================================== */
#infoModalUsername { color: var(--ink); }
#infoModalDate { color: var(--text-tertiary); }

#themeInfoModal .pref-panel {
    background: var(--surface-subtle);
    border-color: var(--border);
}

#infoModalPrefsList { color: var(--text-primary); }

#infoModalPrefsList li {
    border-bottom-color: var(--border);
}

/* Setting names are labels: secondary text, not the tan accent */
#infoModalPrefsList li strong {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Setting values stay in the body text colour so they are readable */
#infoModalPrefsList li span {
    color: var(--text-primary);
}

#infoModalAvatar {
    background: var(--surface-subtle);
    box-shadow: var(--shadow-sm);
}
/* ==========================================================================
   Smooth Digital & Analogue Clock Engine
   ========================================================================== */
/* Stop icons & text from stealing clicks inside buttons */
.apply-comm-btn *, 
.action-btn *, 
.preset-btn * {
    pointer-events: none !important;
}

/* Smooth Digital Transition */
.clock-smooth span { display: inline-block; animation: popUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popUp { 0% { transform: translateY(15px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }

/* True Per-Digit Odometer Scrolling */
#clock { 
    font-variant-numeric: tabular-nums; 
    line-height: 1; 
} 

.smooth-time-transition {
    display: flex;
    align-items: baseline; 
    justify-content: center;
    white-space: pre; 
}

.digit-static {
    display: inline-block;
}

.digit-scroll { 
    position: relative;
    display: inline-block;
    height: 1.2em;
    vertical-align: bottom; 
    overflow: hidden; 
}

.digit-num {
    width: 1ch; 
    text-align: center;
}

.digit-new {
    display: inline-block;
    animation: slideIn 0.3s ease-out forwards; 
}

.digit-old { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%;
    animation: slideOut 0.3s ease-out forwards; 
}

@keyframes slideIn { 
    0% { transform: translateY(100%); } 
    100% { transform: translateY(0); } 
}
@keyframes slideOut { 
    0% { transform: translateY(0); } 
    100% { transform: translateY(-100%); } 
}

/* Analogue Clock Engine */
.analogue-face { 
    width: 1em; 
    height: 1em; 
    border: 0.05em solid currentColor; 
    border-radius: 50%; 
    position: relative; 
    margin: 0 auto;
    display: block; 
    box-sizing: border-box; 
}
.clock-hand { position: absolute; bottom: 50%; left: 50%; transform-origin: bottom center; background: currentColor; border-radius: 10px; }
.hand-hour { width: 0.04em; height: 0.25em; margin-left: -0.02em; }
.hand-min { width: 0.02em; height: 0.35em; margin-left: -0.01em; }
.hand-sec { width: 0.01em; height: 0.4em; margin-left: -0.005em; background: #d9534f; }
/* --- NOTIFICATIONS MODAL STYLES (both themes: every value is a token) --- */
.notif-modal-header {
    padding: var(--space-4) var(--space-4) var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    background: var(--surface);
    color: var(--ink);
}
.notif-item {
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: var(--space-4);
    align-items: flex-start;
    color: var(--text-primary);
    background: var(--surface);
}
.notif-item.announcement {
    background: var(--gold-tint);
}
.notif-time {
    color: var(--text-tertiary);
    font-size: 12px;
    line-height: 16px;
    margin-top: 6px;
}

.notif-skeleton-item {
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: var(--space-4);
    align-items: center;
    background: var(--surface);
}
.notif-skeleton-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface-hover);
    animation: notifShimmer 1.4s infinite ease-in-out;
    flex-shrink: 0;
}
.notif-skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: var(--surface-hover);
    animation: notifShimmer 1.4s infinite ease-in-out;
}
@keyframes notifShimmer {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 0.95; }
}

/* --- COMMUNITY HUB SKELETON STYLES (tokens, so they show on paper and in dark) --- */
.hub-skeleton-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.hub-skeleton-card {
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.hub-skeleton-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-hover);
    animation: hubShimmer 1.3s infinite ease-in-out;
    flex-shrink: 0;
}
.hub-skeleton-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.hub-skeleton-line {
    height: 11px;
    border-radius: var(--radius-sm);
    background: var(--surface-hover);
    animation: hubShimmer 1.3s infinite ease-in-out;
}
@keyframes hubShimmer {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 0.85; }
}













/* --- DAILY CHALLENGE SKELETON STYLES (tokens) --- */
.challenge-skeleton-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 5px 0;
}
.challenge-skeleton-q {
    height: 18px;
    width: 75%;
    margin: 5px auto 15px auto;
    border-radius: var(--radius-md);
    background: var(--surface-hover);
    animation: hubShimmer 1.3s infinite ease-in-out;
}
.challenge-skeleton-btn {
    height: 44px;
    border-radius: var(--radius-pill);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    animation: hubShimmer 1.3s infinite ease-in-out;
    width: 100%;
}
.challenge-skeleton-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--surface-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    border: 1px solid var(--border);
}
.challenge-skeleton-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface-hover);
    animation: hubShimmer 1.3s infinite ease-in-out;
    flex-shrink: 0;
}
/* --- ADMIN ANNOUNCEMENTS LIST --- */
.admin-announce-item {
    background: #f8f9fa; 
    border: 1px solid #eee; 
    padding: 10px; 
    border-radius: 8px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    color: #333;
}
.admin-announce-meta { font-size: 10px; margin-bottom: 4px; color: #888; }
.admin-announce-msg { font-size: 12px; line-height: 1.3; }

/* Dark Mode Overrides */
body.dark-mode .admin-announce-item {
    background: rgba(0,0,0,0.2); 
    border: 1px solid rgba(255,255,255,0.1); 
    color: #eee;
}
body.dark-mode .admin-announce-meta { color: #aaa; }
/* --- REFERRAL BOX STYLES --- */
.referral-box {
    background: rgba(109, 179, 136, 0.1);
    border: 1px solid rgba(109, 179, 136, 0.3);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
}
.referral-box-text {
    font-size: 11px;
    color: #555;
    margin: 0 0 12px 0;
    line-height: 1.4;
}
.referral-input {
    flex: 1;
    margin: 0;
    padding: 8px 12px;
    font-size: 11px;
    border: 1px solid rgba(109, 179, 136, 0.3);
    border-radius: 8px;
    background: #fff;
    color: #333;
}

/* Dark Mode Overrides */
body.dark-mode .referral-box {
    background: rgba(109, 179, 136, 0.05);
    border: 1px solid rgba(109, 179, 136, 0.2);
}
body.dark-mode .referral-box-text {
    color: #aaa;
}
body.dark-mode .referral-input {
    background: rgba(0, 0, 0, 0.2);
    color: #eee;
    border: 1px solid rgba(109, 179, 136, 0.2);
}
/* Focus intent input: TextField (tokens, rebrand P6) */
.task-intent-input {
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    background: var(--surface-subtle);
    border: 1px solid var(--border-control);
    color: var(--text-primary);
    padding: 0 var(--space-3);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.task-intent-input:hover {
    border-color: var(--text-secondary);
}
.task-intent-input:focus {
    background: var(--surface);
}
.task-intent-input::placeholder { color: var(--text-tertiary); opacity: 1; }

/* Quick Task Tags (Chip) */
.quick-task-tag {
    background: var(--surface);
    border: 1px solid var(--border-control);
    color: var(--text-primary);
    font-size: 13px;
    padding: 0 var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease);
}
.quick-task-tag:hover {
    background: var(--surface-hover);
    border-color: var(--border-control);
    color: var(--text-primary);
}

/* Tree Garden Grid Slots */
.tree-garden-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px 2px;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tree-garden-item:hover {
    transform: scale(1.1);
    background: rgba(109, 179, 136, 0.15);
    border-color: rgba(109, 179, 136, 0.3);
}

/* Universal Prompt Modal Dark Mode */
body.dark-mode #universalPromptModal .community-modal-content {
    background: #141414 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
}
body.dark-mode #promptModalTitle {
    color: #ffffff !important;
}
body.dark-mode #promptModalMessage {
    color: #b0b0b0 !important;
}
body.dark-mode #promptModalCancelBtn {
    background: #222222 !important;
    color: #e0e0e0 !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}

/* Info Hover Tooltip */
.info-tooltip-container {
    position: relative;
    cursor: help;
}
.info-tooltip-text {
    visibility: hidden; 
    width: 220px; 
    max-width: 260px;
    background-color: var(--ink); 
    color: var(--surface); 
    text-align: center;
    border-radius: var(--radius-md); 
    padding: 8px 12px; 
    position: absolute; 
    bottom: calc(100% + 10px); 
    left: 50%;
    transform: translateX(-50%); 
    opacity: 0; 
    transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), visibility var(--dur-fast) var(--ease);
    font-family: var(--font-sans);
    font-size: 12px; 
    line-height: 16px; 
    box-shadow: var(--shadow-float);
    border: 0; 
    font-weight: 500; 
    letter-spacing: normal;
    text-transform: none !important; 
    z-index: 99999 !important;
    pointer-events: none;
    white-space: normal;
}
/* The arrow is a single triangle in the tooltip colour (the old stroke layer is kept transparent) */
.info-tooltip-text::before {
    content: ""; 
    position: absolute; 
    top: 100%; 
    left: 50%; 
    margin-left: -6px; 
    border-width: 6px; 
    border-style: solid; 
    border-color: transparent;
}
/* CSS Triangle pointing DOWN to trigger element */
.info-tooltip-text::after {
    content: ""; 
    position: absolute; 
    top: 100%; 
    left: 50%; 
    margin-left: -5px; 
    border-width: 5px; 
    border-style: solid; 
    border-color: var(--ink) transparent transparent transparent;
}
/* Shown on hover and also on keyboard focus (focus inside the trigger, or the trigger itself when it is focusable) */
.info-tooltip-container:hover .info-tooltip-text,
.info-tooltip-container:focus .info-tooltip-text,
.info-tooltip-container:focus-within .info-tooltip-text { 
    visibility: visible; 
    opacity: 1; 
    transform: translateX(-50%) translateY(-2px); 
}

/* Right-anchored tooltip so it never clips past modal boundaries */
.info-tooltip-text.tooltip-right {
    left: auto;
    right: 0;
    transform: none;
}
.info-tooltip-text.tooltip-right::before {
    left: auto;
    right: 28px;
    margin-left: 0;
}
.info-tooltip-text.tooltip-right::after {
    left: auto;
    right: 29px;
    margin-left: 0;
}
.info-tooltip-container:hover .info-tooltip-text.tooltip-right,
.info-tooltip-container:focus .info-tooltip-text.tooltip-right,
.info-tooltip-container:focus-within .info-tooltip-text.tooltip-right {
    visibility: visible;
    opacity: 1;
    transform: translateY(-2px);
}

/* Tooltip positioned BELOW its trigger (e.g. status dots) - arrow flips to point up at the trigger */
.info-tooltip-text.tooltip-below::before {
    top: auto;
    bottom: 100%;
    border-color: transparent;
}
.info-tooltip-text.tooltip-below::after {
    top: auto;
    bottom: 100%;
    border-color: transparent transparent var(--ink) transparent;
}

/* Task Intent Input & Strict Mode row, height-matched at 44px (tokens, rebrand P6) */
.task-intent-input {
    height: 44px !important;
    box-sizing: border-box;
    padding: 0 var(--space-3) !important;
    font-size: 14px !important;
    border-radius: var(--radius-md) !important;
    background: var(--surface-subtle) !important;
    border: 1px solid var(--border-control) !important;
    color: var(--text-primary) !important;
    text-align: left;
    margin: 0;
}
.task-intent-input:focus {
    background: var(--surface) !important;
}

.strict-mode-pill {
    height: 44px !important;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    padding: 0 12px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color var(--dur-fast) var(--ease);
}
.strict-mode-pill:hover {
    background: var(--surface-hover);
    border-color: var(--border-control);
}

/* Compact Strict Switch within 32px container */
.strict-switch-compact {
    position: relative;
    display: inline-block;
    width: 30px;
    height: 16px;
    margin: 0;
}
.strict-switch-compact input {
    opacity: 0;
    width: 0;
    height: 0;
}
.strict-switch-compact .strict-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.15);
    transition: .3s;
    border-radius: 16px;
}
.strict-switch-compact .strict-slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.strict-switch-compact input:checked + .strict-slider {
    background-color: var(--danger);
}
.strict-switch-compact input:checked + .strict-slider:before {
    transform: translateX(14px);
}

/* Aesthetic Toggle Slider (Unchanged) */
.strict-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.strict-switch input { opacity: 0; width: 0; height: 0; }
.strict-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.15); transition: .4s; border-radius: 24px; }
.strict-slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.strict-switch input:checked + .strict-slider { background-color: var(--danger); }
.strict-switch input:checked + .strict-slider:before { transform: translateX(20px); }



/* Mobile Responsive Modal Resizer 
.focus-window-large {
    width: 90%;
    max-width: 450px;
    height: 85vh !important;  Forces it to use 85% of the screen height 
    max-height: 750px;
    display: flex;
    flex-direction: column;
} */
.focus-content-scroll {
    flex: 1;
    overflow-y: auto;
}
@media screen and (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px !important;
    min-width: 0 !important; /* The magic fix for flexbox overflow */
    max-width: 100% !important; 
    box-sizing: border-box !important; /* Ensures padding doesn't add extra width */
  }
}
/* ==========================================================================
   ADMIN PANELS - DARK MODE OVERRIDES
   ========================================================================== */
/* 1. Master Modal Backgrounds & Headers */
body.dark-mode #masterAdminModal .community-modal-content,
body.dark-mode #adminEditUserModal .community-modal-content { 
    background: #141414 !important; 
    border: 1px solid rgba(255, 255, 255, 0.12) !important; 
    color: #e2e8f0 !important;
}

body.dark-mode #masterAdminModal .community-modal-content > div:first-child,
body.dark-mode #adminEditUserModal .community-modal-content > div:first-child { 
    background: #1a1a1a !important; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important; 
}

body.dark-mode #masterAdminModal h2, 
body.dark-mode #masterAdminModal h3, 
body.dark-mode #masterAdminModal h4 { color: #f8fafc !important; }

/* 2. Top Navigation Tabs Bar */
body.dark-mode #masterAdminModal .community-modal-content > div:nth-child(2) {
    background: #101010 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}
body.dark-mode .admin-tab-btn { color: #888 !important; background: transparent !important; }
body.dark-mode .admin-tab-btn.active { 
    color: #6db388 !important; 
    border-bottom-color: #6db388 !important; 
    background: #141414 !important; 
}

/* 3. Main Content Wrapper */
body.dark-mode #masterAdminModal .community-modal-content > div:last-child { 
    background: #141414 !important; 
}

/* 4. Stat & Analytics Cards in Overview Tab */
body.dark-mode #adminTab_overview > div { background: transparent !important; }
body.dark-mode #adminTab_overview div[style*="background: #fff"],
body.dark-mode #adminTab_overview div[style*="background:#fff"],
body.dark-mode #adminTab_overview div[style*="background: rgb(255, 255, 255)"] {
    background: #1a1a1a !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    box-shadow: none !important;
    color: #f0f0f0 !important;
}

body.dark-mode #statTotalUsers, 
body.dark-mode #statPlusUsers, 
body.dark-mode #statPublicThemes, 
body.dark-mode #statTotalTrees, 
body.dark-mode #statTotalChallenges,
body.dark-mode #statTodayMins,
body.dark-mode #statWeekMins { 
    color: #ffffff !important; 
}

/* 5. Live Feeds (Active Users, Most Engaged, Top Countries) */
body.dark-mode #adminTab_overview > div:nth-child(3) > div { 
    background: #1a1a1a !important; 
    border-color: rgba(255, 255, 255, 0.08) !important; 
}
body.dark-mode #adminTab_overview > div:nth-child(3) > div > div:first-child { 
    background: #121212 !important; 
    border-bottom-color: rgba(255, 255, 255, 0.08) !important; 
}
body.dark-mode #adminTab_overview div[style*="background: #f8f9fa"],
body.dark-mode #adminTab_overview div[style*="background:#f8f9fa"] {
    background: #121212 !important;
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}
body.dark-mode #statActiveUsersList,
body.dark-mode #statTopEngagedList,
body.dark-mode #statTopCountriesList {
    background: #141414 !important;
}
body.dark-mode #statActiveUsersList > div,
body.dark-mode #statTopEngagedList > div,
body.dark-mode #statTopCountriesList > div { 
    border-color: rgba(255, 255, 255, 0.06) !important; 
    color: #e0e0e0 !important;
}
body.dark-mode #statActiveUsersList > div:hover,
body.dark-mode #statTopEngagedList > div:hover,
body.dark-mode #statTopCountriesList > div:hover { 
    background: rgba(255, 255, 255, 0.05) !important; 
}
body.dark-mode #statActiveUsersList div, 
body.dark-mode #statTopEngagedList div[style*="color: #1a3c5e"],
body.dark-mode #statTopEngagedList div[style*="color:#1a3c5e"],
body.dark-mode #statActiveUsersList div[style*="color: #1a3c5e"],
body.dark-mode #statActiveUsersList div[style*="color:#1a3c5e"],
body.dark-mode #statTopCountriesList span { 
    color: #f0f0f0 !important; 
}
body.dark-mode #statActiveUsersList button[style*="color: #1a3c5e"],
body.dark-mode #statTopEngagedList button[style*="color: #1a3c5e"] {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #93c5fd !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
}

/* 6. Users Tab (Search Controls & Table Grid) */
body.dark-mode #adminTab_users .custom-input,
body.dark-mode #adminTab_emails .custom-input { 
    background: #1a1a1a !important; 
    border-color: rgba(255, 255, 255, 0.15) !important; 
    color: #ffffff !important; 
}
body.dark-mode #adminTab_users select option,
body.dark-mode #adminTab_emails select option,
body.dark-mode #adminTab_emails select optgroup {
    background: #1a1a1a !important;
    color: #ffffff !important;
}
body.dark-mode #adminTab_users div[style*="background: #fff"],
body.dark-mode #adminTab_users div[style*="background:#fff"] { 
    background: #1a1a1a !important; 
    border-color: rgba(255, 255, 255, 0.08) !important; 
}
body.dark-mode #adminTab_users div[style*="background: #e2e8f0"] { 
    background: #121212 !important; 
    border-bottom-color: rgba(255, 255, 255, 0.08) !important; 
    color: #aaa !important; 
}
body.dark-mode #adminUsersList {
    background: #141414 !important;
}
body.dark-mode #adminUsersList > div { 
    border-color: rgba(255, 255, 255, 0.06) !important; 
    color: #e0e0e0 !important; 
}
body.dark-mode #adminUsersList > div:hover { 
    background: rgba(255, 255, 255, 0.05) !important; 
}
body.dark-mode #adminUsersList > div > div:first-child { 
    color: #ffffff !important; 
}
body.dark-mode #adminUsersList > div > div[style*="color: #64748b"] {
    color: #94a3b8 !important;
}
body.dark-mode #adminUsersList button[style*="color: #1a3c5e"] {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #93c5fd !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
}
body.dark-mode #adminUsersList span[style*="background: rgba(0,0,0,0.05)"] {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #94a3b8 !important;
}

/* 7. Emails Tab (Editor & Live Preview) */
body.dark-mode #adminTab_emails div[style*="background: #fff"],
body.dark-mode #adminTab_emails div[style*="background:#fff"] {
    background: #1a1a1a !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}
body.dark-mode #adminTab_emails div[style*="background: #e2e8f0"] {
    background: #121212 !important;
    color: #aaa !important;
}
body.dark-mode #emailVariablesHelper {
    background: #1a1a1a !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #94a3b8 !important;
}
body.dark-mode #emailVariablesHelper > div:first-child {
    color: #f1f5f9 !important;
}
body.dark-mode #emailVariablesList code {
    background: #242424 !important;
    color: #6db388 !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}
body.dark-mode #rawHtmlEditor {
    background: #0d0d0d !important;
    color: #a6e22e !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}
body.dark-mode #testEmailBtn {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #93c5fd !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
}

/* 8. Notifications & Automated Crons Tab */
body.dark-mode #adminTab_notifications div[style*="background: #fff"],
body.dark-mode #adminTab_notifications div[style*="background:#fff"] {
    background: #1a1a1a !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    box-shadow: none !important;
    color: #e2e8f0 !important;
}
body.dark-mode #adminTab_notifications h4 {
    color: #f8fafc !important;
}
body.dark-mode #adminTab_notifications p {
    color: #94a3b8 !important;
}
body.dark-mode #adminTab_notifications a[style*="background: #f1f5f9"],
body.dark-mode #adminTab_notifications a[style*="background:#f1f5f9"] {
    background: #242424 !important;
    color: #e2e8f0 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}
body.dark-mode #adminTab_notifications span[style*="color: #8a6519"] {
    color: #e6c27a !important;
}
body.dark-mode #adminTab_notifications span[style*="color: #2d6a4f"] {
    color: #6db388 !important;
}
body.dark-mode #adminTab_notifications span[style*="color: #0284c7"] {
    background: rgba(56, 189, 248, 0.15) !important;
    color: #38bdf8 !important;
}
body.dark-mode #adminTab_notifications span[style*="color: #15803d"] {
    background: rgba(34, 197, 94, 0.15) !important;
    color: #4ade80 !important;
}
body.dark-mode #adminTab_notifications span[style*="color: #b45309"] {
    background: rgba(245, 158, 11, 0.15) !important;
    color: #fbbf24 !important;
}

/* 9. Payments & Subscriptions Tab */
body.dark-mode #paymentsContent div[style*="background: #fff"],
body.dark-mode #paymentsContent div[style*="background:#fff"] { 
    background: #1a1a1a !important; 
    border-color: rgba(255, 255, 255, 0.08) !important; 
    box-shadow: none !important; 
}
body.dark-mode #statYtdRev, 
body.dark-mode #statMonthlyAvg, 
body.dark-mode #statStripePlusMembers,
body.dark-mode #statMrrVal,
body.dark-mode #statArrVal,
body.dark-mode #statActiveTrials,
body.dark-mode #statRenewalsValue,
body.dark-mode #statPendingCancellations { 
    color: #ffffff !important; 
}
body.dark-mode #paymentsContent h4 { 
    color: #ffffff !important; 
    border-color: rgba(255, 255, 255, 0.08) !important; 
}
body.dark-mode #paymentsContent div[style*="background: #fcfbfa"],
body.dark-mode #paymentsContent div[style*="background:#fcfbfa"] {
    background: #1e1e1e !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}
body.dark-mode #paymentsContent div[style*="background: #fcfbfa"] div[style*="color: #1a3c5e"],
body.dark-mode #paymentsContent div[style*="background:#fcfbfa"] div[style*="color: #1a3c5e"] {
    color: #f1f5f9 !important;
}
body.dark-mode #paymentsContent span[style*="background: #eee"] {
    background: #2a2a2a !important;
    color: #aaa !important;
}
body.dark-mode #paymentsContent div[style*="background: #f8fafc"],
body.dark-mode #paymentsContent div[style*="background:#f8fafc"] {
    background: #141414 !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}
body.dark-mode #paymentsContent p {
    color: #94a3b8 !important;
}
body.dark-mode #statSubBreakdown, 
body.dark-mode #statRenewals { 
    color: #d0d0d0 !important; 
}
body.dark-mode #statSubBreakdown div {
    border-bottom-color: rgba(255, 255, 255, 0.06) !important;
}
body.dark-mode #statSubBreakdown span[style*="color: #1a3c5e"] {
    color: #e6c27a !important;
}
body.dark-mode #statRenewals div {
    color: #e2e8f0 !important;
    border-bottom-color: rgba(255, 255, 255, 0.06) !important;
}
body.dark-mode #statCancellationsWrapper {
    background: rgba(220, 38, 38, 0.1) !important;
    border-color: rgba(220, 38, 38, 0.3) !important;
}
body.dark-mode #statCancellationsWrapper div[style*="background: #fff5f5"] {
    background: #1f1414 !important;
    border-color: rgba(220, 38, 38, 0.35) !important;
}
body.dark-mode #statCancellationsWrapper span[style*="color: #991b1b"] {
    color: #f87171 !important;
}
body.dark-mode #statCancellationsWrapper span[style*="color: #666"] {
    color: #cbd5e1 !important;
}
body.dark-mode #adminRosterSearch {
    background: #242424 !important;
    border-color: #383838 !important;
    color: #ffffff !important;
}
body.dark-mode #adminRosterSearch::placeholder {
    color: #888 !important;
}
body.dark-mode .roster-filter-btn {
    background: transparent !important;
    border-color: transparent !important;
    color: #94a3b8 !important;
}
body.dark-mode .roster-filter-btn:hover {
    color: #e2e8f0 !important;
}
body.dark-mode .roster-filter-btn.active {
    background: #242424 !important;
    border-color: #404040 !important;
    color: #f1f5f9 !important;
}
body.dark-mode #paymentsContent div[style*="background: #f1f5f9"] {
    background: #121212 !important;
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
    color: #aaa !important;
}
body.dark-mode #statSubList {
    background: #141414 !important;
}
body.dark-mode #statSubList > div { 
    border-color: rgba(255, 255, 255, 0.06) !important; 
    color: #d0d0d0 !important; 
}
body.dark-mode #statSubList > div:hover { 
    background: rgba(255, 255, 255, 0.04) !important; 
}
body.dark-mode .roster-user-title,
body.dark-mode .roster-price-text,
body.dark-mode #statSubList div[style*="color: #0f172a"] {
    color: #ffffff !important;
}
body.dark-mode .roster-date-text,
body.dark-mode #statSubList div[style*="color: #334155"] {
    color: #cbd5e1 !important;
}
body.dark-mode .roster-inspect-btn,
body.dark-mode #statSubList button[style*="background: #f8fafc"] {
    background: #242424 !important;
    color: #e2e8f0 !important;
    border-color: #404040 !important;
}
body.dark-mode .roster-inspect-btn:hover,
body.dark-mode #statSubList button[style*="background: #f8fafc"]:hover {
    background: #2e2e2e !important;
    border-color: #555555 !important;
}
body.dark-mode #statOrphans {
    color: #e2e8f0 !important;
}
body.dark-mode #statSubList span[style*="rgba(99, 102, 241"],
body.dark-mode #statSubList span[style*="rgba(99,102,241"] {
    background: rgba(99, 102, 241, 0.22) !important;
    color: #a5b4fc !important;
    border-color: rgba(99, 102, 241, 0.45) !important;
}
body.dark-mode #statSubList span[style*="color: #4338ca"],
body.dark-mode #statSubList span[style*="color:#4338ca"] {
    color: #a5b4fc !important;
}
body.dark-mode #statStripeTrialSubtag {
    background: rgba(99, 102, 241, 0.25) !important;
    color: #a5b4fc !important;
    border-color: rgba(99, 102, 241, 0.4) !important;
}
body.dark-mode #statStripeTrialsCount {
    color: #ffffff !important;
}

/* 10. Admin Announcements Child Modal */
body.dark-mode #adminAnnounceModal .community-modal-content {
    background: #181818 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #e2e8f0 !important;
}
body.dark-mode #adminAnnounceModal div[style*="background: rgba(0,0,0,0.05)"] {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}
body.dark-mode #adminAnnounceModal .custom-input {
    background: #242424 !important;
    border-color: #383838 !important;
    color: #ffffff !important;
}
body.dark-mode #adminAnnounceModal h3 {
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
    color: #f1f5f9 !important;
}
body.dark-mode #adminAnnounceList .admin-announce-item {
    border-bottom-color: rgba(255, 255, 255, 0.06) !important;
}
body.dark-mode #adminAnnounceList .admin-announce-msg {
    color: #f1f5f9 !important;
}
body.dark-mode #adminAnnounceList .admin-announce-meta {
    color: #94a3b8 !important;
}

/* 11. Admin Grant Email Preview Modal */
body.dark-mode #adminGrantEmailPreviewModal .community-modal-content {
    background: #181818 !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}
body.dark-mode #adminGrantEmailPreviewModal div[style*="background: #fff"],
body.dark-mode #adminGrantEmailPreviewModal div[style*="background:#fff"] {
    background: #181818 !important;
    border-top-color: rgba(255, 255, 255, 0.08) !important;
}

/* 12. Custom User Picker Modal */
body.dark-mode #customUserPickerModal .community-modal-content {
    background: #181818 !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}
body.dark-mode #customUserPickerModal thead {
    background: #111111 !important;
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
    color: #94a3b8 !important;
}
body.dark-mode #customUserPickerModal tbody tr {
    border-bottom-color: rgba(255, 255, 255, 0.06) !important;
    color: #e2e8f0 !important;
}
body.dark-mode #customUserPickerModal div[style*="background: #ffffff"],
body.dark-mode #customUserPickerModal div[style*="background:#ffffff"] {
    background: #141414 !important;
}
body.dark-mode #customUserPickerModal div[style*="background: #f8fafc"],
body.dark-mode #customUserPickerModal div[style*="background:#f8fafc"] {
    background: #1a1a1a !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}
body.dark-mode #customUserPickerModal button[style*="background: #e2e8f0"],
body.dark-mode #customUserPickerModal button[style*="background:#e2e8f0"] {
    background: #242424 !important;
    color: #e2e8f0 !important;
    border-color: #404040 !important;
}
body.dark-mode #customUserPickerModal .custom-input {
    background: #242424 !important;
    color: #ffffff !important;
    border-color: #404040 !important;
}

/* 9. Admin Edit User Modal Revamped */
#adminEditUserModal .community-modal-content {
    max-width: 540px !important;
    width: 94% !important;
    background: #fcfbfa;
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 25px 60px rgba(0,0,0,0.35);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}
.adm-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #708090;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.adm-tab-btn.active {
    color: #1a3c5e;
    border-bottom-color: #6db388;
    background: rgba(109, 179, 136, 0.05);
}
.adm-stat-card {
    background: #ffffff;
    padding: 10px 6px;
    border-radius: 10px;
    border: 1px solid #eef0f3;
    text-align: center;
    transition: transform 0.15s ease;
}
.adm-stat-card:hover {
    transform: translateY(-1px);
}
.adm-stat-val {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    margin: 2px 0;
}
.adm-stat-lbl {
    font-size: 8.5px;
    color: #888;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.3px;
}

body.dark-mode #adminEditUserModal .community-modal-content {
    background: #181818 !important;
    border-color: #333333 !important;
    color: #e2e8f0 !important;
}
body.dark-mode .adm-tab-btn {
    color: #94a3b8 !important;
    border-bottom-color: transparent !important;
}
body.dark-mode .adm-tab-btn.active {
    color: #6db388 !important;
    border-bottom-color: #6db388 !important;
    background: rgba(109, 179, 136, 0.1) !important;
}
body.dark-mode .adm-stat-card {
    background: #222222 !important;
    border-color: #333333 !important;
}
body.dark-mode .adm-stat-val {
    color: #f1f5f9 !important;
}
body.dark-mode .adm-stat-lbl {
    color: #94a3b8 !important;
}
body.dark-mode #adminEditUserModal .pref-panel {
    background: #222222 !important;
    border-color: #333333 !important;
}
body.dark-mode #adminEditUserModal .custom-input { 
    background: #242424 !important; 
    border-color: #383838 !important; 
    color: #f1f5f9 !important; 
}
body.dark-mode #adminEditSubInfo { 
    background: rgba(30, 41, 59, 0.7) !important; 
    border-color: rgba(255, 255, 255, 0.1) !important; 
}
body.dark-mode #adminEditSubInfo h4 { 
    color: #f1f5f9 !important; 
}
body.dark-mode #adminEditSubInfo .pref-panel {
    background: rgba(15, 23, 42, 0.6) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}
body.dark-mode #adminEditSubTerm,
body.dark-mode #adminEditSubRenews {
    color: #e2e8f0 !important;
}
body.dark-mode #adminEditSubRefId {
    color: #94a3b8 !important;
}
body.dark-mode #adminEditEngagementInfo {
    background: rgba(109, 179, 136, 0.08) !important;
    border-color: rgba(109, 179, 136, 0.25) !important;
}
body.dark-mode #adminEditUserModal .community-modal-content > div:nth-child(2) {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}
body.dark-mode #adminEditUserModal .community-modal-content > div:nth-child(3) {
    background: #111111 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}
body.dark-mode #adminEditUserModal .community-modal-content > div:last-child {
    background: #111111 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}
body.dark-mode #admHeaderUsername {
    color: #f8fafc !important;
}
body.dark-mode #adminEditMins24h,
body.dark-mode #adminEditMins7d,
body.dark-mode #adminEditMins30d {
    color: #f1f5f9 !important;
}
body.dark-mode #adm2faMethodControls > div {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}
body.dark-mode #adm2faMethodControls span {
    color: #f1f5f9 !important;
}
body.dark-mode #admSessionsList .adm-session-card {
    background: #222222 !important;
    border-color: #333333 !important;
}
body.dark-mode #admSessionsList .adm-session-name {
    color: #f1f5f9 !important;
}
body.dark-mode #admSessionsList .adm-session-subtext {
    color: #94a3b8 !important;
}
body.dark-mode #adminConfirmDeleteUserModal .community-modal-content {
    background: #181818 !important;
    border-color: rgba(217, 83, 79, 0.4) !important;
    color: #e2e8f0 !important;
}
body.dark-mode #adminConfirmDeleteUserModal p {
    color: #f1f5f9 !important;
}
body.dark-mode #adminConfirmDeleteUserModal label {
    color: #cbd5e1 !important;
}
body.dark-mode #adminConfirmDeleteUserModal .custom-input {
    background: #242424 !important;
    border-color: #404040 !important;
    color: #ffffff !important;
}
body.dark-mode #adminGrantSubModal .community-modal-content {
    background: #181818 !important;
    border-color: rgba(230, 194, 122, 0.3) !important;
    color: #e2e8f0 !important;
}
body.dark-mode #adminGrantSubModal label {
    color: #cbd5e1 !important;
}
body.dark-mode #adminGrantSubModal .custom-input {
    background: #242424 !important;
    border-color: #383838 !important;
    color: #ffffff !important;
}
body.dark-mode #adminGrantSubModal .grant-curr-btn:not(.selected),
body.dark-mode #adminGrantSubModal .grant-mode-btn:not(.selected),
body.dark-mode #adminGrantSubModal .grant-disc-btn:not(.selected),
body.dark-mode #adminGrantSubModal .grant-trial-btn:not(.selected),
body.dark-mode #adminGrantSubModal .grant-expiry-btn:not(.selected) {
    background: #242424 !important;
    border-color: #404040 !important;
    color: #e2e8f0 !important;
}
body.dark-mode #adminGrantSubModal .community-modal-content > div:last-child {
    background: #111111 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}
body.dark-mode #adminGrantSubModal #grantStripeLinkResult {
    background: #222222 !important;
    border-color: rgba(230, 194, 122, 0.3) !important;
}
body.dark-mode #admPlusStatusCard {
    background: rgba(230, 194, 122, 0.08) !important;
    border-color: rgba(230, 194, 122, 0.25) !important;
}
body.dark-mode #admPlusCardTitle {
    color: #f1f5f9 !important;
}
body.dark-mode #admPlusCardSubtitle {
    color: #94a3b8 !important;
}
/* ==========================================================================
   ADMIN PANELS - MOBILE RESPONSIVENESS
   ========================================================================== */
@media (max-width: 768px) {
    /* Make the Top Tabs horizontally scrollable (the bar is the row holding the .admin-tab-btn buttons) */
    #masterAdminModal div:has(> .admin-tab-btn) {
        overflow-x: auto;
        flex-wrap: nowrap !important; /* beats the bar's inline flex-wrap: wrap */
        white-space: nowrap;
        justify-content: flex-start;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    #masterAdminModal div:has(> .admin-tab-btn)::-webkit-scrollbar { display: none; }
    .admin-tab-btn { flex-shrink: 0; padding: 10px 15px !important; font-size: 13px; }

    /* Overview Grids: Shrink to 2 columns, then 1 column */
    #adminTab_overview > div:nth-child(2) { grid-template-columns: 1fr 1fr !important; }
    #adminTab_overview > div:nth-child(3) { grid-template-columns: 1fr !important; }
    #adminTab_overview > div:nth-child(4) { grid-template-columns: 1fr !important; }

    /* Payments Grids */
    #paymentsContent > div:nth-child(1) { grid-template-columns: 1fr 1fr !important; }

    /* Users & Payments Lists: Convert Grids to Stacked Cards */
    /* 1. Hide the users table header completely (the payments roster keeps its header: it
       scrolls sideways as a table rather than stacking into cards) */
    #adminTab_users > div:last-child > div:first-child { display: none !important; }

    /* 2. Stack the User Rows */
    #adminUsersList > div { 
        display: flex !important; 
        flex-direction: column !important; 
        align-items: flex-start !important; 
        gap: 8px !important; 
        padding: 15px !important; 
    }
    /* Align the action buttons to the left on mobile */
    #adminUsersList > div > div:last-child { 
        width: 100%; 
        justify-content: flex-start !important; 
        margin-top: 5px; 
    }

    /* 3. Stack the Payment Sub Rows */
    #statSubList > div {
        display: flex !important; 
        flex-direction: column !important; 
        align-items: flex-start !important; 
        gap: 8px !important; 
        padding: 15px !important; 
    }
    #statSubList > div > div:last-child {
        width: 100%; 
        justify-content: flex-start !important; 
        margin-top: 5px; 
    }

    /* Make Search & Filter Inputs Stack on Users Tab */
    #adminTab_users > div:first-child { flex-direction: column !important; gap: 10px !important; }
    #adminUserSearch, #adminUserRoleFilter, #adminUserSortBy, #adminUserSortDir { width: 100% !important; box-sizing: border-box; }
    #adminTab_users > div:first-child > button { width: 100% !important; justify-content: center; }
    /* Edit User Modal Adjustments */
    #adminEditUserModal .community-modal-content { width: 95% !important; }
    #adminEditSubInfo > div { grid-template-columns: 1fr !important; }
    #adminEditSubInfo .pref-panel { margin-bottom: 4px; }
}



/* --- Loader: follows the theme through the tokens (light, dark and auto) --- */
.premium-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: var(--surface);
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.25s ease;
}

.loader-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px; 
}

.loader-logo {
    width: 80px; 
    height: auto;
    animation: pulseLogo 2s infinite ease-in-out;
    transition: filter 0.3s ease; /* Smooth transition if we invert the logo */
}

.loader-title {
    font-family: var(--font-sans);
    font-size: 22px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 10px 0;
    letter-spacing: 0;
    transition: color 0.3s ease;
}

.loader-spinner {
    width: 35px;
    height: 35px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}



















/* Turns a black logo completely white in dark mode */
body.dark-mode .loader-logo {

    filter: brightness(0) invert(1); 
}























/* --- ANIMATIONS --- */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulseLogo {
    0% { transform: scale(0.97); opacity: 0.9; }
    50% { transform: scale(1.03); opacity: 1; }
    100% { transform: scale(0.97); opacity: 0.9; }
}

.premium-loader.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
/* ========================================= */
/* PREMIUM TOOLBOX POPOVER                   */
/* ========================================= */

.toolbox-popover {
    position: fixed;
    bottom: 90px; /* Floats perfectly just above the navbar */
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: 320px;
    background: rgba(25, 25, 25, 0.75); /* Deep premium glass */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), visibility 0.4s;
    z-index: 10000;
}

/* The class JS adds to trigger the pop-up */
.toolbox-popover.show-toolbox {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.toolbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 15px;
}

/* The App Cards */
.toolbox-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 18px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.toolbox-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-4px); /* Lifts the card up slightly */
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}

.toolbox-card i {
    font-size: 28px;
    margin-bottom: 10px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
    transition: transform 0.3s ease;
}

.toolbox-card:hover i {
    transform: scale(1.1); /* Icon pops on hover */
}

.toolbox-card-title {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.5px;
}

.toolbox-card-subtitle {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 3px;
    font-weight: 500;
}

/* The "NEW" Badge */
.toolbox-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: linear-gradient(135deg, #ff6b6b, #d9534f);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    padding: 3px 6px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(217, 83, 79, 0.5);
    letter-spacing: 0.5px;
}
/* COUNTDOWN APP STYLES (Card look, tokens; the person's colour is only the dot and the progress fill) */
.cd-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 16px 16px;
    position: relative;
    overflow: hidden;
    color: var(--text-primary);
}

.cd-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.cd-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-right: -8px;
}

.cd-actions .cd-action-btn {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: -6px 0;
    padding: 0;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.cd-actions .cd-action-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.cd-actions .cd-action-btn.is-danger:hover { color: var(--danger); }

.cd-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cd-unit {
    background: var(--surface-subtle);
    padding: 6px 8px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 44px;
    border: 1px solid transparent;
}

.cd-num {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.cd-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-top: 3px;
}

.cd-completed {
    color: var(--primary-ink);
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
/* COUNTDOWN APP UPGRADES: colour swatches are real buttons with an accent ring when chosen */
.cd-swatch {
    position: relative;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    border: 0;
    box-shadow: inset 0 0 0 1px var(--text-primary-15);
    transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.cd-swatch::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; }
.cd-swatch:hover { transform: scale(1.08); }
.cd-swatch.cd-swatch-white { box-shadow: inset 0 0 0 1px var(--border-control); }
.cd-swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.cd-swatch.cd-swatch-white.active { box-shadow: inset 0 0 0 1px var(--border-control), 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

/* Progress Bar */
.cd-progress-bg {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: var(--radius-pill);
    margin-top: 12px;
    overflow: hidden;
}
.cd-progress-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    transition: width 1s linear;
}

/* Animations */
@keyframes hypePulse {
    0% { transform: scale(1); border-color: var(--border); }
    50% { transform: scale(1.01); border-color: var(--accent); }
    100% { transform: scale(1); border-color: var(--border); }
}
.cd-hype-mode {
    animation: hypePulse 2s infinite ease-in-out;
}

@keyframes celebratePop {
    0% { transform: scale(0.96); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.cd-completed-state {
    animation: celebratePop 0.3s cubic-bezier(.4,0,.2,1);
    background: var(--primary-tint) !important;
    border-color: var(--primary-line) !important;
}
/* ==========================================
   APP DOCK & WINDOW MANAGEMENT
========================================== */
#appDock {
    position: fixed;
    bottom: calc(120px + env(safe-area-inset-bottom, 0px)); /* Above the app dock and its labels rather than covering them */
    left: 50%;
    transform: translateX(-50%) translateY(100px); /* Start hidden below screen */
    display: flex;
    gap: var(--space-2);
    /* Minimised windows float over the main dock, so this glass is always dimmed */
    background: linear-gradient(var(--glass), var(--glass)), var(--glass-dim);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    z-index: 9999;
    box-shadow: var(--shadow-float);
    border: 1px solid var(--glass-border);
    --focus: var(--on-glass);
    transition: transform var(--dur-base) var(--ease), opacity var(--dur-base) var(--ease);
    opacity: 0;
    pointer-events: none;
}

#appDock.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Minimised-window buttons (addToDock): --on-glass icon on a faint tile of the tool's colour */
.dock-item {
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--on-glass);
    font-family: inherit;
    font-size: 20px;
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
    border: 0;
    position: relative;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dock-item::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    border-radius: inherit;
    background: var(--tool, var(--glass));
    opacity: var(--tile-tint);
    pointer-events: none;
}

.dock-item i {
    position: relative;
    color: inherit;
}

.dock-item:hover {
    background: var(--glass);
    transform: translateY(-2px);
}

.dock-item::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--on-glass);
    border-radius: var(--radius-pill);
    opacity: 0.6;
}
/* ==========================================
   DESKTOP MODAL ANIMATIONS (Symmetrical Pop In/Out)
========================================== */
/* 1. Base State (Closed): Slightly shrunk and invisible */
.draggable-window {
    opacity: 0;
    transform: scale(0.95); /* The "shrunk" state for the pop effect */
    
    /* This transition guarantees the animation is identical opening AND closing */
    transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease) !important;
    
    /* Strip any old one-way keyframe animations you might have had */
    animation: none !important; 
}

/* 2. Active State (Open): Full size and visible */
.draggable-window.show-window {
    opacity: 1;
    transform: scale(1); /* Springs back to 100% size */
}


/* ==========================================
   MOBILE BOTTOM SHEETS (Overrides Desktop)
========================================== */
@media (max-width: 768px) {
    .draggable-window {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important; 
        width: 100vw !important; 
        max-width: 100vw !important;
        height: 85vh !important;
        max-height: 85vh !important;
        border-radius: 24px 24px 0 0 !important;
        margin: 0 !important;
        border: none !important;
        border-top: 1px solid rgba(255,255,255,0.1) !important;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.5) !important;
        
        /* MOBILE BASE STATE: Slide off the bottom of the screen instead of shrinking */
        transform: translateY(100%) !important;
        padding-bottom: env(safe-area-inset-bottom);
        display: flex !important;
        flex-direction: column !important;
    }

    .draggable-window.show-window {
        /* MOBILE ACTIVE STATE: Slide up to the bottom edge */
        transform: translateY(0) !important;
    }

    /* Closed sheets stay display:flex off-screen, so hide them from Tab and screen readers once the slide ends */
    .draggable-window:not(.show-window) {
        visibility: hidden;
        transition: transform var(--dur-base) var(--ease), visibility 0s linear var(--dur-base) !important;
    }
    .draggable-window.show-window {
        visibility: visible;
        transition: transform var(--dur-base) var(--ease), visibility 0s linear 0s !important;
    }
    
    /* Ensure the content area stretches to fill the new uniform height */
    .draggable-window .window-content {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 !important; 
        overflow-y: auto !important;
        box-sizing: border-box !important;
    }

    .draggable-window .window-header {
        position: relative;
        padding-top: 22px !important;
        border-radius: 24px 24px 0 0 !important;
        flex-shrink: 0 !important;
    }

    .draggable-window .window-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 4px;
    }

    /* Hide the minimize button on mobile (since we have swipe-to-close) */
    .draggable-window .window-header .fa-minus {
        display: none !important; 
    }
}

/* ==========================================================================
   Glassmorphism Toast Notifications
   ========================================================================== */
.nav-bts-badge {
    position: absolute;
    top: -12px;
    right: -20px;
    font-size: 8px;
    line-height: 1;
    font-weight: 800;
    font-family: 'Poppins', sans-serif;
    color: #111;
    background: #e6c27a;
    border-radius: 7px;
    padding: 2px 4.5px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(230, 194, 122, 0.6);
    animation: btsBadgePulse 2s infinite ease-in-out;
    pointer-events: none;
}
@keyframes btsBadgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.18); }
}

.clock-toast-container {
    position: fixed;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.clock-toast {
    background: rgba(30, 35, 45, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.35);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.clock-toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.clock-toast i {
    font-size: 15px;
}

.clock-toast.success i { color: #6db388; }
.clock-toast.error i { color: #d9534f; }
.clock-toast.info i { color: #cebfaf; }
.clock-toast.warning i { color: #e6c27a; }

@keyframes pulseGlow {
    0% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.08); opacity: 1; box-shadow: 0 0 12px rgba(109,179,136,0.9); }
    100% { transform: scale(1); opacity: 0.9; }
}

/* ==========================================================================
   HABIT TRACKER APP STYLES
   ========================================================================== */
.habit-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
    position: relative;
}
.habit-card:hover {
    background: var(--surface-subtle);
}
.habit-card.completed-today {
    background: var(--primary-tint);
    border-color: var(--primary-line);
}
.habit-icon-box {
    position: relative;
    isolation: isolate;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    color: var(--ink);
}
/* The habit's own colour only ever shows as a tile tint behind an ink icon */
.habit-icon-box::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: var(--habit-tint, var(--tool-habits));
    opacity: var(--tile-tint);
}
.habit-check-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border-control);
    color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
    flex-shrink: 0;
}
.habit-check-btn:hover {
    border-color: var(--primary);
    color: var(--border-control);
}
.habit-check-btn.checked {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}
.habit-dot-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}
.habit-history-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: background-color var(--dur-fast) var(--ease);
}
.habit-history-dot.active {
    background: var(--primary);
}
.habit-dot-day {
    font-size: 10px;
    color: var(--text-tertiary);
    font-weight: 600;
}
.habit-dot-day.is-today {
    color: var(--ink);
    font-weight: 700;
}

/* ==========================================================================
   ZEN BREATHE APP STYLES
   ========================================================================== */
.breathe-preset-btn {
    flex: 1;
    min-width: 80px;
    min-height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border-control);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.breathe-preset-btn:hover {
    background: var(--surface-hover);
}
.breathe-preset-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-primary);
    font-weight: 600;
}

.breathe-stage-container {
    position: relative;
    width: 220px;
    height: 220px;
    margin: 15px auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.breathe-orb-outer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: transparent;
    border: 2px dashed var(--tool-breathe);
    transition: transform 1s var(--ease), opacity 1s var(--ease);
}

/* Flat tool colour; navy (--on-primary) text keeps contrast in both themes */
.breathe-orb-inner {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: var(--tool-breathe);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--on-primary);
    z-index: 2;
    transition: transform 1s var(--ease), opacity 1s var(--ease);
    user-select: none;
}

/* ==========================================================================
   DAILY QUOTES & WISDOM STYLES
   ========================================================================== */
.quotes-cat-tab {
    min-height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: var(--surface);
    border: 1px solid var(--border-control);
    color: var(--text-primary);
    white-space: nowrap;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.quotes-cat-tab:hover {
    background: var(--surface-hover);
}
.quotes-cat-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-primary);
    font-weight: 600;
}

.quote-display-card {
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    position: relative;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

/* GlassBar look: it floats over the person's canvas, like the dock */
#pinnedDesktopQuote {
    position: fixed;
    bottom: 85px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 480px;
    width: 90%;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-pill);
    padding: 4px 4px 4px 20px;
    color: var(--on-glass);
    z-index: 9000;
    box-shadow: var(--shadow-float);
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-base) var(--ease);
}
#pinnedDesktopQuote.show {
    opacity: 1;
    pointer-events: auto;
}

/* ==========================================================================
   APP STORE CATEGORY TABS & BADGES
   ========================================================================== */
.app-store-filter-tab {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #bbb;
    white-space: nowrap;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}
.app-store-filter-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.app-store-filter-tab.active {
    background: rgba(206, 191, 175, 0.22);
    border-color: #cebfaf;
    color: #cebfaf;
    box-shadow: 0 0 10px rgba(206, 191, 175, 0.25);
}

.app-new-pill {
    background: rgba(244, 232, 97, 0.15);
    border: 1px solid rgba(244, 232, 97, 0.55);
    color: #f4e861;
    font-size: 9px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 8px;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 0 10px rgba(244, 232, 97, 0.25);
}

/* ==========================================================================
   DOCK DRAG-TO-REMOVE TRASH BIN
   ========================================================================== */
#dockTrashZone {
    position: fixed;
    bottom: 85px;
    left: 50%;
    transform: translateX(-50%) translateY(15px) scale(0.9);
    background: rgba(30, 18, 18, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px dashed rgba(217, 83, 79, 0.45);
    color: #f58b8b;
    padding: 10px 22px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10050;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s, border-color 0.2s, box-shadow 0.2s;
    user-select: none;
}

#dockTrashZone.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0) scale(1);
}

#dockTrashZone.drag-over {
    background: rgba(217, 83, 79, 0.35);
    border: 1.5px solid #d9534f;
    color: #fff;
    transform: translateX(-50%) translateY(-3px) scale(1.08);
    box-shadow: 0 0 25px rgba(217, 83, 79, 0.6), 0 10px 35px rgba(0, 0, 0, 0.6);
}

#dockTrashZone.drag-over i {
    animation: trashShake 0.4s infinite ease-in-out;
}

@keyframes trashShake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-12deg) scale(1.2); }
    75% { transform: rotate(12deg) scale(1.2); }
}

/* ==========================================================================
   WORD GUESS GAME STYLES
   ========================================================================== */
.wordguess-board {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    justify-content: center;
    margin: 4px 0 6px;
}

.wordguess-row {
    display: flex;
    gap: 4px;
}

.wordguess-tile {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border-control);
    background: transparent;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    text-transform: uppercase;
    user-select: none;
    transition: transform 0.15s var(--ease), background-color 0.3s var(--ease), border-color 0.3s var(--ease), color 0.3s var(--ease);
}

.wordguess-tile.filled {
    border-color: var(--ink);
    animation: tilePop 0.12s ease-in-out;
}

.wordguess-tile.correct {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: var(--on-primary) !important;
}

.wordguess-tile.present {
    background: var(--gold) !important;
    border-color: var(--gold) !important;
    color: var(--on-primary) !important;
}

.wordguess-tile.absent {
    background: var(--surface-hover) !important;
    border-color: var(--surface-hover) !important;
    color: var(--text-secondary) !important;
}

.wordguess-tile.flip {
    animation: tileFlip 0.5s ease forwards;
}

@keyframes tilePop {
    0% { transform: scale(0.9); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes tileFlip {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

.wordguess-keyboard {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    margin-top: 4px;
    user-select: none;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.wordguess-keyrow {
    display: flex;
    gap: 3.5px;
    width: 100%;
    justify-content: center;
}

.wordguess-key {
    min-width: 0;
    height: 40px;
    padding: 0 2px;
    border-radius: var(--radius-sm);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
    flex: 1;
    max-width: 36px;
}

.wordguess-key:hover {
    background: var(--surface-hover);
}

.wordguess-key.wide {
    min-width: 36px;
    max-width: 54px;
    flex: 1.5;
    font-size: 10px;
}

.wordguess-key:active {
    transform: scale(0.94);
}

.wordguess-key.correct {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: var(--on-primary) !important;
}

.wordguess-key.present {
    background: var(--gold) !important;
    border-color: var(--gold) !important;
    color: var(--on-primary) !important;
}

.wordguess-key.absent {
    background: var(--border) !important;
    border-color: var(--border) !important;
    color: var(--text-secondary) !important;
}

@media (max-width: 600px) {
    #wordGuessModal .window-content {
        padding: 12px 10px !important;
    }
    #wordguess-pane-game {
        width: 100% !important;
    }
    .wordguess-keyboard {
        width: 100% !important;
        max-width: 100% !important;
        gap: 5px !important;
        margin-top: 6px !important;
    }
    .wordguess-keyrow {
        gap: 3px !important;
        width: 100% !important;
    }
    .wordguess-key {
        max-width: none !important;
        min-width: 0 !important;
        height: 44px !important;
        font-size: 13px !important;
        border-radius: var(--radius-sm) !important;
    }
    .wordguess-key.wide {
        max-width: none !important;
        min-width: 44px !important;
        flex: 1.6 !important;
        font-size: 11px !important;
    }
}

/* ==========================================================================
   WORLD CLOCKS APP STYLES
   ========================================================================== */
.world-clock-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: all 0.2s ease;
    position: relative;
}

.world-clock-card:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.world-clock-day {
    background: rgba(244, 232, 97, 0.12);
    border: 1px solid rgba(244, 232, 97, 0.3);
    color: #f4e861;
}

.world-clock-night {
    background: rgba(174, 217, 224, 0.12);
    border: 1px solid rgba(174, 217, 224, 0.3);
    color: #aed9e0;
}

/* ==========================================================================
   APP STORE SOCIAL PROOF & AVATAR STACK
   ========================================================================== */
.app-store-avatar-stack {
    display: inline-flex;
    align-items: center;
}

.app-store-avatar-bubble {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid #1a1a1a;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.app-store-downloads-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 3px 8px 3px 4px;
    border-radius: 20px;
    user-select: none;
}

/* ==========================================================================
   CALCULATOR MINI APP STYLES
   ========================================================================== */
#calculatorModal {
    width: 360px;
    height: 540px;
    max-height: 88vh;
}
.calc-btn {
    border: none;

    cursor: pointer;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    padding: 0;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.calc-btn:active {
    transform: scale(0.93);
}
.calc-btn-num {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.calc-btn-num:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.18);
}
.calc-btn-op {
    background: rgba(206, 191, 175, 0.18);
    color: #cebfaf;
    border: 1px solid rgba(206, 191, 175, 0.25);
    font-size: 18px;
}
.calc-btn-op:hover {
    background: rgba(206, 191, 175, 0.28);
    color: #ffffff;
}
.calc-btn-action {
    background: rgba(255, 255, 255, 0.05);
    color: #ff8585;
    border: 1px solid rgba(255, 133, 133, 0.2);
}
.calc-btn-action:hover {
    background: rgba(255, 133, 133, 0.15);
}
.calc-btn-equals {
    background: #6db388;
    color: #ffffff;
    border: 1px solid rgba(109, 179, 136, 0.5);
    box-shadow: 0 4px 12px rgba(109, 179, 136, 0.3);
    font-size: 20px;
    font-weight: 700;
}
.calc-btn-equals:hover {
    background: #5ea478;
    box-shadow: 0 4px 16px rgba(109, 179, 136, 0.45);
}
.calc-btn-sci {
    background: rgba(255, 255, 255, 0.03);
    color: #aed9e0;
    border: 1px solid rgba(174, 217, 224, 0.15);
    font-size: 12px;
    font-weight: 600;
    height: 34px;
    border-radius: 8px;
}
.calc-btn-sci:hover {
    background: rgba(174, 217, 224, 0.12);
    border-color: rgba(174, 217, 224, 0.3);
}
.calc-history-item {
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.calc-history-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(206, 191, 175, 0.3);
}

/* ==========================================================================
   MUSIC PLAYER ENHANCEMENTS (tokens, rebrand P6)
   ========================================================================== */
#spotifyModal {
    width: 380px;
    height: 580px;
    max-height: 88vh;
}

#spotifyModal #musicIframeWrapper {
    height: 100% !important;
    min-height: 380px !important;
    flex: 1 1 auto;
}

#spotifyModal #spotifyIframe {
    height: 100% !important;
    min-height: 380px !important;
    flex: 1 1 auto;
}

/* Source switcher: SegmentedTabs */
.music-source-tabs {
    display: flex;
    background: var(--surface-subtle);
    border: 0;
    border-radius: var(--radius-md);
    padding: 4px;
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
}

.music-tab-btn {
    position: relative;
    flex: 1;
    min-height: 36px;
    background: transparent;
    border: none;
    border-radius: var(--radius-pill);
    padding: 0 12px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.music-tab-btn::after { content: ""; position: absolute; inset: -4px 0; }
.music-tab-btn:hover { background: var(--surface-hover); color: var(--text-primary); }

.music-tab-btn.active,
.music-tab-btn.active.spotify,
.music-tab-btn.active.youtube {
    background: var(--accent);
    color: var(--on-primary);
    font-weight: 600;
    border: 0;
    box-shadow: var(--shadow-sm);
}

.music-stations-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    width: 100%;
    padding: 6px 0;
    scrollbar-width: none;
}
.music-stations-bar::-webkit-scrollbar {
    display: none;
}

/* Station chips: Chip */
.music-station-chip {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border-control);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.music-station-chip::after { content: ""; position: absolute; inset: -4px 0; }

.music-station-chip:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--border-control);
}

.music-station-chip.active-station {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-primary);
    font-weight: 600;
}

@keyframes spinVinyl {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.vinyl-active-glow {
    box-shadow: var(--shadow-float) !important;
}

/* Sleep timer and view pills: real buttons with aria-pressed */
.music-sleep-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    background: var(--surface-subtle);
    border: 1px solid transparent;
    padding: 0 12px;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.music-sleep-pill::after { content: ""; position: absolute; inset: -4px 0; }

.music-sleep-pill:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.music-sleep-pill.active,
.music-sleep-pill[aria-pressed="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-primary);
}

/* ==========================================================================
   WEATHER APP MULTI-LOCATION STYLES (tokens)
   ========================================================================== */
.weather-places-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    width: 100%;
    padding: 6px 0;
    scrollbar-width: none;
    flex-shrink: 0;
}
.weather-places-bar::-webkit-scrollbar {
    display: none;
}

/* A place is one chip: the select button plus, when there are several places, its remove button. */
.weather-place-chip {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border-control);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.weather-place-chip::after { content: ""; position: absolute; inset: -4px 0; }

.weather-place-chip:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--border-control);
}

.weather-place-chip.active-place {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-primary);
    font-weight: 600;
}

.weather-chip-del {
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    margin-left: -4px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.weather-chip-del:hover {
    background: var(--surface-hover);
    color: var(--danger);
}

/* ==========================================================================
   AMBIENT MIXER & SOUND EFFECTS REDESIGN (tokens)
   ========================================================================== */
.ambient-wave-bars {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 12px;
    margin-left: 4px;
}

.ambient-bar {
    width: 2px;
    background: var(--primary-ink);
    border-radius: 1px;
    animation: ambientBarPulse 1s ease-in-out infinite alternate;
}
.ambient-bar.bar-1 { height: 40%; animation-delay: 0.1s; }
.ambient-bar.bar-2 { height: 85%; animation-delay: 0.3s; }
.ambient-bar.bar-3 { height: 60%; animation-delay: 0.2s; }
.ambient-bar.bar-4 { height: 100%; animation-delay: 0.4s; }

@keyframes ambientBarPulse {
    0% { height: 25%; opacity: 0.5; }
    100% { height: 100%; opacity: 1; }
}

.ambient-presets-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    width: 100%;
    padding: 6px 0;
    scrollbar-width: none;
    flex-shrink: 0;
}
.ambient-presets-bar::-webkit-scrollbar {
    display: none;
}

/* Presets: Chip */
.ambient-preset-pill {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border-control);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
    flex-shrink: 0;
}
.ambient-preset-pill::after { content: ""; position: absolute; inset: -4px 0; }

.ambient-preset-pill:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--border-control);
}

.ambient-preset-pill.active-preset {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-primary);
    font-weight: 600;
}

.ambient-master-card {
    background: var(--surface-subtle);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Sound cards: SettingRow look; a playing sound gets an accent ring */
.ambient-sound-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.ambient-sound-card:hover {
    background: var(--surface);
    border-color: var(--border-control);
}

.ambient-sound-card.sound-active {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.ambient-sound-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.ambient-sound-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin: 0;
    padding: 0 8px 0 0;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    user-select: none;
}

.ambient-sound-title small {
    font-size: 12px !important;
    font-weight: 400 !important;
    color: var(--text-secondary);
    opacity: 1 !important;
}

.ambient-icon-badge {
    position: relative;
    isolation: isolate;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--ink);
    transition: transform var(--dur-fast) var(--ease);
}
.ambient-icon-badge::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: var(--tool, var(--tool-mixer));
    opacity: var(--tile-tint);
}

.ambient-sound-title:hover .ambient-icon-badge {
    transform: scale(1.05);
}

.ambient-vol-tag {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface-subtle);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    min-width: 40px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.ambient-sound-card.sound-active .ambient-vol-tag {
    color: var(--on-primary);
    background: var(--accent);
}

.ambient-slider {
    width: 100%;
    margin: 0;
    height: 6px;
    cursor: pointer;
    accent-color: var(--accent);
}

.ambient-slider.accent-blue,
.ambient-slider.accent-orange,
.ambient-slider.accent-green,
.ambient-slider.accent-beige,
.ambient-slider.accent-purple,
.ambient-slider.accent-pink,
.ambient-slider.accent-white,
.ambient-slider.accent-lime { accent-color: var(--accent); }

.ambient-bottom-toolbar {
    background: var(--surface-subtle);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    margin-top: auto;
}

.ambient-timer-pills {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* Sleep timer pills: 10px minimum text, 32px pills with a 44px hit area */
.amb-timer-btn {
    position: relative;
    min-width: 40px;
    min-height: 32px;
    background: var(--surface);
    border: 1px solid var(--border-control);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    padding: 0 8px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.amb-timer-btn::after { content: ""; position: absolute; inset: -6px -2px; }

.amb-timer-btn:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
}

.amb-timer-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-primary);
    font-weight: 600;
}

/* ==========================================================
   THEME APPLIED TOAST & UNDO BAR
   ========================================================== */
.theme-applied-toast {
    position: fixed;
    top: 25px;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%) translateY(-80px);
    background: rgba(22, 28, 36, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0,0,0,0.15);
    z-index: 999999; /* above every modal a theme can be applied from (they stack dynamically) */
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
    overflow: hidden;
    min-width: 290px;
    max-width: 90vw;
    pointer-events: auto;
}

.theme-applied-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.theme-applied-toast .toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px 10px 12px;
}

.theme-applied-toast .toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #cebfaf, #b3a290);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.theme-applied-toast .toast-text {
    flex: 1;
    min-width: 0;
}

.theme-applied-toast .toast-title {
    color: #ffffff;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    font-weight: 600;
    display: block;
    line-height: 1.2;
}

.theme-applied-toast .toast-undo-btn {
    background: #ffffff;
    color: #1a1a1a;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-family: 'Poppins', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}

.theme-applied-toast .toast-undo-btn:hover {
    transform: scale(1.04);
    background: #f0f0f0;
}

.theme-applied-toast .toast-undo-btn:active {
    transform: scale(0.97);
}

.theme-applied-toast .toast-close {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    margin-left: 2px;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.theme-applied-toast .toast-close:hover {
    color: #ffffff;
}

.theme-applied-toast .toast-progress-bar {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
}

.theme-applied-toast .toast-progress-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #cebfaf, #6db388);
    transform-origin: left;
}

/* ==========================================================================
   About Clockface Online & FAQ Modal (tokens follow the light and dark theme)
   ========================================================================== */
.about-modal-content {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.about-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.about-modal-card {
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    color: var(--text-secondary);
}

.about-modal-card h3,
.about-modal-card h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px;
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
    color: var(--ink);
}

.about-modal-card p {
    margin: 0;
    font-size: 12px;
    line-height: 18px;
    color: var(--text-secondary);
}

.about-modal-content kbd {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    border: 1px solid var(--border-control);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    line-height: 16px;
    text-align: center;
}

.about-faq-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.about-faq-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 12px 14px;
    border: 0;
    background: none;
    cursor: pointer;
    user-select: none;
    font: inherit;
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
    text-align: left;
    color: var(--ink);
    transition: background-color var(--dur-fast) var(--ease);
}

.about-faq-header:hover {
    background: var(--surface-hover);
}

.about-faq-chevron {
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform var(--dur-fast) var(--ease);
}

.about-faq-item.open .about-faq-chevron {
    transform: rotate(180deg);
    color: var(--accent-ink);
}

.about-faq-body {
    display: none;
    padding: 0 14px 12px 14px;
    font-size: 13px;
    line-height: 20px;
    color: var(--text-secondary);
}

.about-faq-item.open .about-faq-body {
    display: block;
}

@media (max-width: 480px) {
    .about-modal-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Embed Clock Generator Modal (tokens follow the light and dark theme)
   ========================================================================== */
.embed-modal-content {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.embed-modal-title {
    color: var(--ink);
}

.embed-modal-subtitle {
    font-size: 12px;
    line-height: 16px;
    color: var(--text-secondary);
}

.embed-modal-label {
    color: var(--text-secondary);
}

.embed-modal-sublabel {
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    color: var(--text-secondary);
}

.embed-input-box {
    min-height: 44px;
    padding: 10px 12px;
    background: var(--surface-subtle);
    border: 1px solid var(--border-control);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 18px;
}

.embed-callout-box {
    padding: 12px 16px;
    background: var(--gold-tint);
    border: 1px solid var(--gold-line);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
}

.embed-callout-title {
    color: var(--ink);
}

.embed-done-btn {
    min-width: 120px;
}

body.dark-mode .embed-callout-box {
    background: rgba(230, 194, 122, 0.08) !important;
    border: 1px solid rgba(230, 194, 122, 0.25) !important;
    color: #dfd5ca !important;
}

body.dark-mode .embed-callout-title {
    color: #ffffff !important;
}

body.dark-mode .embed-done-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

body.dark-mode .embed-done-btn:hover {
    background: rgba(255, 255, 255, 0.18) !important;
}

/* ==========================================================================
   Comprehensive Dark Mode Overrides for Additional Modals
   ========================================================================== */
/* Coffee, downsell, Welcome Plus, academic, Join Club, Back to School and beta welcome modals:
   their old dark-mode twins are gone - the modal paper base and tokens serve both themes (P3, css/cfo-commerce.css). */

/* Beta info modal (converted by another package): keep its inline-grey text readable on the dark paper. */
body.dark-mode #betaInfoModal p {
    color: var(--text-secondary) !important;
}

/* Ad slots: drawer footer + draggable-window modals. Kept deliberately small
   (fixed 320x50 unit) and in a consistent spot per surface so they read as a
   slim banner rather than a content block competing with the actual feature. */
.ad-slot {
    margin: 0 0 10px;
    padding: 6px 0 0;
    text-align: center;
    flex-shrink: 0;
}
/* Stack the <ins> and the upgrade CTA on top of each other (instead of hiding
   one) so the ad keeps loading in the background while the CTA placeholder
   shows - whichever resolves gets shown, without interrupting the ad request. */
.ad-slot:not(.ad-slot-appcard) {
    display: grid;
    justify-items: center;
    row-gap: 4px;
}
.ad-slot:not(.ad-slot-appcard) > ins.adsbygoogle,
.ad-slot:not(.ad-slot-appcard) > .ad-upgrade-cta {
    grid-column: 1;
    grid-row: 2;
}
.ad-slot .ad-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
/* The dismiss control is an icon in the markup; padding with a matching negative margin
   gives it a 44px target without making the label row any taller. */
.ad-slot .ad-dismiss {
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    box-sizing: content-box;
    padding: 16px;
    margin: -16px -16px -16px -10px;
    border-radius: var(--radius-pill);
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.ad-slot .ad-dismiss:hover {
    color: var(--text-primary);
}
.ad-slot ins.adsbygoogle {
    background: var(--surface-subtle);
    max-width: 100%;
    overflow: hidden;
}
/* Single source of truth for ad unit size across every placement on the site.
   Must match the "Fixed" size configured on the AdSense ad units themselves -
   if this ever changes, the ad units need updating to the same size too. */
.clockface-ad-unit {
    display: inline-block;
    width: 320px;
    height: 50px;
}
.ad-slot .ad-upgrade-cta {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 320px;
    max-width: 100%;
    height: 50px;
    margin: 0 auto;
    box-sizing: border-box;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    background: var(--gold);
    border: 0;
    color: var(--on-primary);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    line-height: 1.3;
    transition: box-shadow var(--dur-fast) var(--ease);
}
.ad-slot .ad-upgrade-cta:hover {
    box-shadow: var(--shadow-sm);
}
.ad-slot-modal {
    margin: 0 0 10px;
}

/* App Store "sponsored card" - styled to match .app-store-card so it reads
   as part of the grid rather than a banner interrupting it. */
.ad-slot.ad-slot-appcard {
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    margin: 0 0 4px;
    text-align: left;
}
.ad-slot-appcard-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.ad-slot-appcard-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--accent-tile);
    border: 1px solid var(--accent-line);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--accent-ink);
    flex-shrink: 0;
}
.ad-slot-appcard-badge {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--surface-hover);
    padding: 2px 7px;
    border-radius: var(--radius-sm);
}
.ad-slot-appcard-body {
    display: grid;
    justify-items: center;
}
.ad-slot-appcard-body > ins.adsbygoogle,
.ad-slot-appcard-body > .ad-upgrade-cta {
    grid-column: 1;
    grid-row: 1;
}
.ad-slot.ad-slot-appcard .ad-dismiss {
    margin-left: auto;
}
/* ==========================================================
   FRIENDS HUB MODAL - a paper card (.fh-card.cfo-paper), sibling of the profile modal
   ========================================================== */
.fh-card { max-width: 420px; text-align: left; padding: 24px 22px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); color: var(--text-primary); box-shadow: var(--shadow-modal); position: relative;
    /* Fixed height: header + search stay put and only .fh-body scrolls, so searching or
       switching views never makes the card grow/shrink */
    height: min(600px, 85vh); max-height: none; overflow: hidden; display: flex; flex-direction: column; box-sizing: border-box; }
.fh-body { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -8px; padding: 0 8px 10px; scrollbar-width: thin; }
.fh-header { display: flex; align-items: center; gap: 8px; margin: 0 40px 16px 0; flex-shrink: 0; }
.fh-title { font-size: 18px; line-height: 26px; font-weight: 700; color: var(--ink); }
.fh-subtitle { font-size: 12px; color: var(--text-secondary); }
.fh-avatar { position: relative; flex-shrink: 0; border-radius: 50%; }
.fh-avatar-inner { width: 100%; height: 100%; border-radius: 50%; overflow: hidden; border: 2px solid var(--border); background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--on-primary); }
.fh-avatar-inner img { width: 100%; height: 100%; object-fit: cover; }
.fh-dot { position: absolute; bottom: -1px; right: -1px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface); }
.fh-icon-btn { display: inline-grid; place-items: center; background: var(--surface-subtle); color: var(--text-secondary); border: 0; width: 44px; height: 44px; padding: 0; border-radius: var(--radius-pill); cursor: pointer; font: inherit; font-size: 14px; flex-shrink: 0; transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.fh-icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.fh-icon-btn.active { background: var(--primary-tint); color: var(--primary-ink); }
.fh-search { position: relative; margin-bottom: 10px; flex-shrink: 0; }
.fh-search i, .fh-search > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); font-size: 13px; pointer-events: none; }
.fh-search input { width: 100%; height: 44px; box-sizing: border-box; background: var(--surface-subtle); border: 1px solid var(--border-control); color: var(--text-primary); border-radius: var(--radius-md); padding: 0 44px 0 34px; font-size: 14px; font-family: inherit; transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease); }
.fh-search input::placeholder { color: var(--text-tertiary); opacity: 1; }
.fh-search input[type="search"]::-webkit-search-cancel-button, .fh-search input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.fh-search .fh-search-clear { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 44px; height: 44px; background: none; border: none; border-radius: var(--radius-pill); color: var(--text-tertiary); cursor: pointer; padding: 0; font-size: 14px; }
.fh-search .fh-search-clear i, .fh-search .fh-search-clear svg { position: static; transform: none; font-size: 14px; }
.fh-search .fh-search-clear:hover { color: var(--text-primary); }
.fh-search input:hover { border-color: var(--text-secondary); }
.fh-search input:focus { background: var(--surface); }
.fh-section-title { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; margin: 16px 0 8px 2px; }
button.fh-section-title { background: none; border: none; padding: 0; min-height: 32px; cursor: pointer; font-family: inherit; }
.fh-count { background: var(--surface-hover); color: var(--text-secondary); border-radius: var(--radius-pill); padding: 1px 7px; font-size: 10px; letter-spacing: 0; }
.fh-count:empty { display: none; }
.fh-count-alert { background: var(--danger); color: var(--surface); }
.fh-list { display: flex; flex-direction: column; gap: 6px; }
.fh-row { display: flex; align-items: center; gap: 10px; background: var(--surface-subtle); padding: 8px 10px; border-radius: var(--radius-lg); border: 1px solid transparent; }
.fh-row-main { flex: 1; min-width: 0; cursor: pointer; }
.fh-row-name { font-size: 14px; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fh-row-sub { font-size: 11px; color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fh-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.fh-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 36px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; padding: 0 12px; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text-primary); font-family: inherit; transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); white-space: nowrap; }
.fh-btn::after { content: ""; position: absolute; inset: -4px 0; }
.fh-btn-icon { min-width: 36px; padding: 0; }
.fh-btn:hover { background: var(--surface-hover); }
.fh-btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.fh-btn-primary:hover { background: var(--primary); box-shadow: var(--shadow-sm); }
.fh-btn-danger { background: var(--danger-tint); border-color: var(--danger-line); color: var(--danger); }
.fh-btn-danger:hover { background: var(--danger-tint); border-color: var(--danger); }
.fh-btn-muted { cursor: default; opacity: 0.75; }
.fh-btn:disabled { opacity: var(--disabled); cursor: default; }
.fh-facepile { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.fh-face { cursor: pointer; text-align: center; flex-shrink: 0; width: 52px; }
.fh-face-name { font-size: 10px; color: var(--text-secondary); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fh-empty { text-align: center; padding: 18px 10px; color: var(--text-secondary); font-size: 13px; line-height: 1.5; background: var(--surface-subtle); border-radius: var(--radius-lg); border: 1px dashed var(--border-control); }
.fh-link-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; background: none; border: none; border-radius: var(--radius-sm); color: var(--accent-ink); font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; margin-bottom: 6px; font-family: inherit; }
.fh-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface-subtle); padding: 10px 12px; border-radius: var(--radius-lg); margin-bottom: 6px; font-size: 13px; color: var(--text-primary); }
.fh-toggle-row small { color: var(--text-secondary); font-size: 11px; }
.fh-about-intro { font-size: 13px; color: var(--text-secondary); line-height: 1.5; margin: 4px 2px 12px; }
.fh-about-item { display: flex; gap: 12px; background: var(--surface-subtle); border: 1px solid transparent; border-radius: var(--radius-lg); padding: 11px 12px; margin-bottom: 7px; }
.fh-about-icon { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 13px; }
.fh-about-icon.is-gold { color: var(--gold-ink); }
.fh-about-icon.is-primary { color: var(--primary-ink); }
.fh-about-icon.is-accent { color: var(--accent-ink); }
.fh-about-icon.is-info { color: var(--info); }
.fh-about-icon.is-danger { color: var(--danger); }
.fh-about-icon.is-muted { color: var(--text-tertiary); }
.fh-online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary-ink); vertical-align: middle; margin-right: 4px; }
.fh-about-text { flex: 1; min-width: 0; font-size: 13px; }
.fh-about-text strong { color: var(--text-primary); }
.fh-about-text p { margin: 3px 0 0; color: var(--text-secondary); font-size: 12px; line-height: 1.45; }
.fh-about-text em { color: var(--accent-ink); font-style: normal; font-weight: 600; }
.fh-about-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.fh-about-links .fh-btn { font-size: 11px; padding: 0 10px; }
.fh-about-cta { display: flex; gap: 8px; justify-content: center; margin: 14px 0 4px; flex-wrap: wrap; }
.fh-online { color: var(--primary-ink); }
.fh-stat i, .fh-stat svg { color: var(--text-tertiary); }
/* Same sliding .theme-switch as the settings modal; the "off" track uses the control border token */
.fh-card .theme-slider { background-color: var(--border-control); }
#upmFriendsTile.fh-tile-clickable { cursor: pointer; transition: border-color var(--dur-fast) var(--ease); }
#upmFriendsTile.fh-tile-clickable:hover { border-color: var(--primary-line) !important; }
@media (max-width: 480px) {
    .fh-card { padding: 20px 14px; }
    .fh-row-actions .fh-btn-label { display: none; }
}

/* Formatted announcement / notification text (see sanitize_announcement_html in account/main.php) */
.notif-rich mark { background: rgba(230, 194, 122, 0.45); color: inherit; padding: 0 3px; border-radius: 3px; }
.notif-rich small { font-size: 0.82em; opacity: 0.85; }
.notif-rich s { opacity: 0.75; }

/* ==========================================================
   Admin Friends stats (dashboard tab + user-editor pane) - light & dark
   ========================================================== */
.afs-card { background: #fff; border: 1px solid rgba(0,0,0,0.06); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.afs-heading { font-weight: 700; color: #1a3c5e; font-size: 13.5px; margin-bottom: 12px; }
.afs-kpi { flex: 1; min-width: 120px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; text-align: center; }
.afs-kpi-sm { min-width: 90px; padding: 8px; }
.afs-kpi-val { font-size: 22px; font-weight: 800; color: #1a3c5e; }
.afs-kpi-sm .afs-kpi-val { font-size: 17px; }
.afs-kpi-lbl { font-size: 10px; color: #64748b; text-transform: uppercase; font-weight: 700; letter-spacing: 0.3px; margin-top: 2px; }
.afs-kpi-sub { font-size: 10.5px; color: #94a3b8; margin-top: 4px; }
.afs-good { color: #2d6a4f !important; }
.afs-warn { color: #b45309 !important; }
.afs-bad { color: #d9534f !important; }
.afs-muted { color: #64748b !important; }
.afs-note { font-size: 10.5px; color: #94a3b8; margin-top: 10px; }
.afs-list-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: 12.5px; }
.afs-rank { color: #94a3b8; width: 18px; display: inline-block; }
.afs-link { color: #1a3c5e; font-weight: 600; text-decoration: none; }
.afs-link:hover { text-decoration: underline; }
.afs-date { color: #94a3b8; font-size: 11px; flex-shrink: 0; }
.afs-empty { font-size: 12px; color: #94a3b8; }
.afs-section-title { font-size: 11px; font-weight: 700; color: #708090; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.afs-chip { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; cursor: pointer; }
.afs-chip:hover { border-color: #6db388; }
.afs-chip-avatar { width: 26px; height: 26px; border-radius: 50%; overflow: hidden; background: #cbd5e1; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 11px; flex-shrink: 0; }
.afs-chip-name { flex: 1; min-width: 0; font-weight: 600; color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

body.dark-mode .afs-card { background: #1a1a1a; border-color: rgba(255,255,255,0.08); box-shadow: none; }
body.dark-mode .afs-heading { color: #f8fafc; }
body.dark-mode .afs-kpi, body.dark-mode .afs-chip { background: #121212; border-color: rgba(255,255,255,0.08); }
body.dark-mode .afs-kpi-val { color: #ffffff; }
body.dark-mode .afs-kpi-lbl { color: #9ca3af; }
body.dark-mode .afs-kpi-sub, body.dark-mode .afs-note, body.dark-mode .afs-rank, body.dark-mode .afs-date, body.dark-mode .afs-empty { color: #7c8594; }
body.dark-mode .afs-good { color: #6db388 !important; }
body.dark-mode .afs-warn { color: #e6c27a !important; }
body.dark-mode .afs-bad { color: #f87171 !important; }
body.dark-mode .afs-muted { color: #9ca3af !important; }
body.dark-mode .afs-list-row { border-bottom-color: rgba(255,255,255,0.06); }
body.dark-mode .afs-link, body.dark-mode .afs-chip-name { color: #e2e8f0; }
body.dark-mode .afs-section-title { color: #9ca3af; }
body.dark-mode .afs-chip-avatar { background: #334155; }
body.dark-mode #adminFriendsStats { color: #aab2bd; }


/* ==========================================================================
   Custom Corner Logo (Plus) - rendered by render_custom_brand_html() in index.php and
   customBrandHtml() in js/index.js. Colour modes and the shadow are applied here at render
   time (not baked into the PNG) so "Match clock colour" keeps following theme changes.
   ========================================================================== */
.custom-brand {
  --cb-scale: 1;
  --cb-maxw: 40vw;
  display: inline-flex;
  align-items: center;
  max-width: var(--cb-maxw);
  min-width: 0;
}
.cb-size-s { --cb-h: 30px; --cb-fs: 17px; }
.cb-size-m { --cb-h: 42px; --cb-fs: 22px; }
.cb-size-l { --cb-h: 58px; --cb-fs: 28px; }

.custom-brand-img,
.custom-brand-mask {
  display: block;
  height: calc(var(--cb-h) * var(--cb-scale));
  max-width: var(--cb-maxw);
}
.custom-brand-img {
  width: auto;
  object-fit: contain;
  object-position: left center;
}
.custom-brand-mask {
  background-color: currentColor;
  -webkit-mask-image: var(--cb-src);
  mask-image: var(--cb-src);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: left center;
  mask-position: left center;
}
.cb-mode-invert .custom-brand-img { filter: invert(1); }
/* Shadow sits on the wrapper: a filter on the masked element itself would be clipped by its own mask */
.cb-image.cb-shadow { filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5)); }
.custom-brand:not(.cb-shadow) { text-shadow: none; }

.custom-brand-text {
  font-size: calc(var(--cb-fs) * var(--cb-scale));
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: var(--cb-maxw);
}
.cb-font-clock .custom-brand-text { font-family: var(--cb-clock-font, 'Poppins'), sans-serif; }

@media (max-width: 600px) {
  .custom-brand { --cb-scale: 0.8; --cb-maxw: 55vw; }
}

/* Corner logo menu (opened by clicking .top-brand) */
.brand-menu {
  position: fixed;
  top: 70px;
  left: 30px;
  min-width: 250px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 16px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.18);
  padding: 6px;
  z-index: 1060;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px) scale(0.97);
  transform-origin: top left;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.brand-menu.show-popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.brand-menu button,
.brand-menu a {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #444;
  cursor: pointer;
  transition: background 0.2s;
}
.brand-menu button[hidden] { display: none; }
.brand-menu button:hover,
.brand-menu a:hover,
.brand-menu button:focus-visible,
.brand-menu a:focus-visible { background: rgba(0,0,0,0.05); color: #000; }
.brand-menu i { width: 18px; text-align: center; color: #6db388; }
.brand-menu span:not(.brand-menu-plus) { flex: 1; }
.brand-menu-plus {
  background: linear-gradient(135deg, #e6c27a, #d4af37);
  color: #000;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.brand-menu-plus i { width: auto; color: #000; }
@media (max-width: 600px) {
  .brand-menu { left: 16px; top: 60px; }
}

/* Gold pulse used to point at a setting after a deeplink (e.g. "Hide logo" from the corner menu) */
@keyframes prefRowPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230,194,122,0); background: transparent; }
  30% { box-shadow: 0 0 0 4px rgba(230,194,122,0.45); background: rgba(230,194,122,0.18); }
}
.pref-highlight-row { border-radius: 10px; }
.pref-highlight-row.pref-row-pulse { animation: prefRowPulse 1.2s ease-in-out 2; }

/* ---------- Logo Studio ---------- */
.logo-studio {
  max-width: 820px !important;
  width: 94% !important;
  max-height: 92vh !important;
  overflow-y: auto;
  position: relative;
  padding: 26px 26px 18px !important;
  text-align: left;
  font-family: var(--font-sans);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.ls-head h2 { margin: 0 0 2px; padding-right: 44px; font-size: 22px; line-height: 30px; font-weight: 700; color: var(--ink); }
.ls-head h2 i { color: var(--primary-ink); margin-right: 6px; }
.ls-head p { margin: 0 0 16px; font-size: 14px; color: var(--text-secondary); }
.ls-banner {
  display: flex; gap: 10px; align-items: center;
  background: var(--gold-tint); border: 1px solid var(--gold-line);
  color: var(--gold-ink); border-radius: var(--radius-md); padding: 10px 14px; font-size: 13px; margin-bottom: 14px;
}
.ls-banner i { color: var(--gold-ink); }
.ls-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 22px; }
.ls-preview-col, .ls-controls-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.ls-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-subtle); border: 0; border-radius: var(--radius-md); padding: var(--space-1); gap: var(--space-1); }
.ls-seg-btn { border: none; background: transparent; min-height: 36px; padding: 0 10px; border-radius: var(--radius-pill); font: 500 13px var(--font-sans); color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.ls-seg-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.ls-seg-btn.active { background: var(--accent); color: var(--on-primary); font-weight: 600; box-shadow: var(--shadow-sm); }

.ls-preview-label { font-size: 11px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: -6px; }
/* Mock canvas from here to .ls-screen-dock: it mirrors the person's own clock, so its colours stay literal. */
.ls-closeup { position: relative; border-radius: var(--radius-lg); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }
.ls-closeup .ls-closeup-screen { position: relative; height: 110px; width: 100%; }
.ls-closeup .ls-closeup-screen.is-phone { height: 90px; }
/* Fade the right edge: a wide logo continues past the close-up, it isn't cut off */
.ls-closeup::after { content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 28px; background: linear-gradient(to right, transparent, rgba(0,0,0,0.25)); pointer-events: none; }
.ls-preview-frame { position: relative; width: 100%; border-radius: var(--radius-lg); overflow: hidden; background: #222; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); margin: 0 auto; }
.ls-preview-frame.is-phone { max-width: 190px; border-radius: 22px; box-shadow: 0 0 0 5px #1f2937; }
.ls-screen { position: absolute; top: 0; left: 0; transform-origin: top left; overflow: hidden; background-size: cover; background-position: center; }
.ls-screen-brand {
  position: absolute; top: 25px; left: 30px;
  font-family: 'Poppins', sans-serif; font-size: 22px; font-weight: 700;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.ls-screen.is-phone .ls-screen-brand { top: 20px; left: 20px; font-size: 18px; }
.ls-screen-clock { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; font-size: 190px; line-height: 1; white-space: nowrap; }
.ls-screen.is-phone .ls-screen-clock { font-size: 96px; }
.ls-screen-nav { position: absolute; top: 22px; right: 26px; display: flex; gap: 10px; }
.ls-screen-nav span { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,0.18); }
.ls-screen.is-phone .ls-screen-nav { display: none; }
.ls-screen.is-phone .ls-screen-dock { position: absolute; bottom: 25px; left: 50%; transform: translateX(-50%); width: 300px; height: 56px; border-radius: 18px; background: rgba(255,255,255,0.18); }
/* Preview overrides the real page's viewport-based limits with the mock screen's own */
.ls-screen .custom-brand { --cb-scale: 1; --cb-maxw: 512px; }
.ls-screen.is-phone .custom-brand { --cb-scale: 0.8; --cb-maxw: 214px; }

.ls-dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  border: 2px dashed var(--border-control); border-radius: var(--radius-lg); padding: 28px 16px; cursor: pointer; color: var(--text-secondary);
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); background: var(--surface-subtle);
}
.ls-dropzone i { font-size: 28px; color: var(--primary-ink); margin-bottom: 4px; }
.ls-dropzone strong { font-size: 14px; color: var(--ink); }
.ls-dropzone span { font-size: 13px; }
.ls-dropzone small { font-size: 11px; color: var(--text-tertiary); }
.ls-dropzone:hover, .ls-dropzone.is-dragover { border-color: var(--primary); background: var(--primary-tint); }
.ls-crop-wrap { height: 200px; background: repeating-conic-gradient(var(--surface-hover) 0% 25%, var(--surface-subtle) 0% 50%) 50% / 16px 16px; border-radius: var(--radius-md); overflow: hidden; }
.ls-crop-wrap img { display: block; max-width: 100%; }

.ls-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ls-field { display: flex; flex-direction: column; gap: 6px; }
.ls-field-row { flex-direction: row; align-items: center; justify-content: space-between; }
.ls-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.ls-optional { font-weight: 400; color: var(--text-secondary); }
.ls-input { width: 100%; box-sizing: border-box; min-height: 44px; border: 1px solid var(--border-control); border-radius: var(--radius-md); padding: 9px 12px; font: 14px var(--font-sans); background: var(--surface-subtle); color: var(--text-primary); }
.ls-input::placeholder { color: var(--text-tertiary); opacity: 1; }
.ls-input:focus { border-color: var(--focus); background: var(--surface); }
.ls-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ls-chip { position: relative; min-height: 36px; border: 1px solid var(--border-control); background: var(--surface); color: var(--text-primary); padding: 0 12px; border-radius: var(--radius-sm); font: 500 13px var(--font-sans); cursor: pointer; transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
.ls-chip:hover { background: var(--surface-hover); }
.ls-chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-primary); font-weight: 600; }
/* Fixed row height: chips clip overflowing names, which would otherwise let grid rows collapse to nothing */
.ls-font-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); grid-auto-rows: 36px; gap: 6px; max-height: 168px; overflow-y: auto; padding: 2px; flex-shrink: 0; }
.ls-font-search { position: relative; }
.ls-font-search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); font-size: 12px; pointer-events: none; }
.ls-font-search .ls-input { padding-left: 32px; }
#lsFontSearchUse { align-self: flex-start; }
#lsFontSearchUse[disabled] { opacity: var(--disabled); cursor: wait; }
.ls-font-grid .ls-chip { min-height: 0; border-radius: var(--radius-md); font-size: 13px; font-weight: 400; padding: 8px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ls-hint { font-size: 12px; color: var(--text-secondary); line-height: 1.45; }
.ls-hint-warn { color: var(--gold-ink); background: var(--gold-tint); border-radius: var(--radius-md); padding: 7px 10px; display: flex; gap: 8px; align-items: flex-start; }
.ls-error { font-size: 13px; color: var(--danger); background: var(--danger-tint); border: 1px solid var(--danger-line); border-radius: var(--radius-md); padding: 8px 10px; }
.ls-shared { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.ls-panel { display: flex; flex-direction: column; gap: 12px; }
.ls-panel[hidden], .ls-hint[hidden], .ls-error[hidden], .ls-banner[hidden], #lsImageEditor[hidden], .ls-dropzone[hidden] { display: none; }
#lsImageEditor { display: flex; flex-direction: column; gap: 12px; }
input[type="range"]#lsBgTolerance { width: 100%; }
input[type="range"]#lsBgTolerance:disabled { opacity: var(--disabled); }
#lsTextColor { width: 44px; height: 44px; border: 1px solid var(--border-control); border-radius: var(--radius-md); padding: 2px; background: var(--surface); cursor: pointer; }

/* Sticky so Save is always in reach, however far down the controls they've scrolled */
.ls-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  position: sticky; bottom: -18px; z-index: 5;
  margin: 12px -26px -18px; padding: 14px 26px 18px;
  background: inherit; border-top: 1px solid var(--border);
}
.ls-footer-actions { display: flex; gap: 8px; margin-left: auto; }
.ls-btn { border: 1px solid transparent; border-radius: var(--radius-pill); height: 44px; padding: 0 var(--space-5); font: 600 15px var(--font-sans); white-space: nowrap; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.ls-btn:disabled { opacity: var(--disabled); cursor: not-allowed; }
.ls-btn:not(:disabled):hover { box-shadow: var(--shadow-sm); }
.ls-btn:not(:disabled):active { transform: scale(0.98); }
.ls-btn-secondary { background: var(--surface-subtle); color: var(--text-primary); }
.ls-btn-secondary:not(:disabled):hover { background: var(--surface-hover); box-shadow: none; }
.ls-btn-primary { background: var(--primary); color: var(--on-primary); }
.ls-btn-plus { background: var(--gold); color: var(--on-primary); }
.ls-link-btn { border: none; background: none; min-height: 44px; padding: 0 var(--space-2); border-radius: var(--radius-pill); font: 600 13px var(--font-sans); color: var(--accent-ink); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background-color var(--dur-fast) var(--ease); }
.ls-link-btn:hover { background: var(--surface-subtle); }
.ls-link-btn[hidden] { display: none; }
.ls-danger { color: var(--danger); }
.ls-rights { margin: 16px 0 0; font-size: 11px; color: var(--text-tertiary); text-align: center; }

@media (max-width: 768px) {
  .ls-body { grid-template-columns: 1fr; gap: 14px; }
  .logo-studio { padding: 20px 16px 14px !important; }
  .ls-footer { margin: 12px -16px -14px; padding: 12px 16px 14px; bottom: -14px; }
  .ls-footer-actions { width: 100%; }
  .ls-footer-actions .ls-btn { flex: 1; justify-content: center; }
}

/* Upgrade modal: the logo the user just designed, shown above the plans */
.upg-logo-showcase { margin: 4px auto 16px; max-width: 360px; }
.upg-logo-showcase[hidden] { display: none; }
.upg-logo-showcase-stage { position: relative; width: 100%; border-radius: 12px; overflow: hidden; box-shadow: 0 6px 20px rgba(0,0,0,0.18); background: #222; }
.upg-logo-showcase-stage .ls-closeup-screen { position: relative; height: 110px; width: 100%; text-align: left; }
.upg-logo-showcase-caption { margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--gold-ink); }
.upg-logo-showcase-caption i { color: var(--gold-ink); }

/* Dark mode */
body.dark-mode .brand-menu { background: rgba(26,26,26,0.96); border-color: #333; }
body.dark-mode .brand-menu button, body.dark-mode .brand-menu a { color: #ddd; }
body.dark-mode .brand-menu button:hover, body.dark-mode .brand-menu a:hover { background: rgba(255,255,255,0.07); color: #fff; }
body.dark-mode .ls-head h2 { color: #f5f5f5; }
