/* Premium Design System for SpeakSimple & Visual Scheduler */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* HSL-tailored Color Palette (Slate Premium) */
  --bg-main: #0b0f19;
  --bg-card: rgba(23, 29, 43, 0.7);
  --bg-card-hover: rgba(30, 39, 57, 0.9);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --primary: #0ea5e9;
  --primary-glow: rgba(14, 165, 233, 0.25);
  --brand-gradient: linear-gradient(135deg, #00f5d4, #0ea5e9, #8b5cf6);
  
  /* Fitzgerald Color Codes (High-contrast, accessible) */
  --fitz-yellow-bg: #fef08a; /* Pronouns & People */
  --fitz-yellow-text: #1e1b4b;
  --fitz-yellow-border: #facc15;
  
  --fitz-green-bg: #bbf7d0; /* Verbs & Actions */
  --fitz-green-text: #064e3b;
  --fitz-green-border: #4ade80;
  
  --fitz-blue-bg: #bfdbfe; /* Adjectives & Adverbs */
  --fitz-blue-text: #1e3a8a;
  --fitz-blue-border: #60a5fa;
  
  --fitz-orange-bg: #ffedd5; /* Nouns (Things/Places) */
  --fitz-orange-text: #7c2d12;
  --fitz-orange-border: #fb923c;
  
  --fitz-pink-bg: #fce7f3; /* Social Words & Conjunctions */
  --fitz-pink-text: #701a75;
  --fitz-pink-border: #f472b6;
  
  --fitz-grey-bg: #f3f4f6; /* Determiners, Prepositions & Transition Social */
  --fitz-grey-text: #1f2937;
  --fitz-grey-border: #d1d5db;
  
  --danger: #ef4444;
  --success: #22c55e;
  
  /* Layout constraints */
  --header-height: 72px;
  --nav-height: 80px;
}

/* Base resets & typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Glassmorphism & Card Utilities */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.glass-premium {
  background: radial-gradient(120% 120% at 50% 0%, rgba(255, 255, 255, 0.05) 0%, rgba(0, 0, 0, 0) 100%), var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
}

/* App Skeleton Layout */
.app-container {
  display: grid;
  grid-template-rows: var(--header-height) 1fr var(--nav-height);
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* Header styling */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-color);
  z-index: 40;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.logo-icon-img {
  width: 36px;
  height: 36px;
  background: var(--brand-gradient); /* Takes user dynamic theme gradient by default! */
  mask: url(assets/logo.png) no-repeat center;
  -webkit-mask: url(assets/logo.png) no-repeat center;
  mask-size: contain;
  -webkit-mask-size: contain;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-section:hover .logo-icon-img {
  transform: scale(1.08) rotate(-3deg);
  background: var(--brand-gradient); /* gorgeous brand-aligned gradient hover highlight */
}

.logo-text {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #f8fafc;
  transition: all 0.3s ease;
}

.logo-accent-text {
  color: var(--primary);
  transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Caregiver mode badge */
.caregiver-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-weight: 500;
  font-size: 0.85rem;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.caregiver-badge.active {
  background: var(--primary);
  border-color: rgba(255, 255, 255, 0.2);
  color: white;
}

/* Navigation System */
nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 32px;
  border-top: 1px solid var(--border-color);
  padding: 0 24px;
  z-index: 40;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 24px;
  color: var(--text-secondary);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 100px;
  touch-action: manipulation;
}

.nav-tab svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
  transition: transform 0.25s ease;
}

.nav-tab span {
  font-size: 0.85rem;
  font-weight: 500;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.nav-tab:active {
  transform: scale(0.95);
}

.nav-tab.active {
  color: var(--text-primary);
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.2);
  box-shadow: 0 0 15px -3px var(--primary-glow);
}

.nav-tab.active svg {
  stroke: var(--primary);
  transform: translateY(-2px);
}

/* Viewport Shell */
main {
  padding: 24px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%; /* DEFINITE HEIGHT RESOLUTION */
  min-height: 0; /* CRITICAL CSS GRID HEIGHT PROPAGATION */
}

.view-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  padding: 24px;
  display: none;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  min-height: 0; /* CRITICAL FLEX HEIGHT RESOLUTION */
}

.view-container.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  height: 100%;
  opacity: 1;
  transform: translateY(0);
  position: relative;
  min-height: 0; /* CRITICAL FLEX HEIGHT RESOLUTION */
}

/* AAC MODULE SPECIFICS */
.aac-layout {
  display: grid;
  grid-template-rows: 110px auto auto 1fr;
  gap: 12px;
  height: 100%;
  overflow: hidden;
  min-height: 0; /* CRITICAL GRID ITEM HEIGHT RESOLUTION */
}

/* Speech Bar display */
.speech-bar-container {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  gap: 16px;
  overflow: hidden;
}

.speech-accumulator {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  height: 100%;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.speech-word-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  height: 68px;
  border-radius: 12px;
  padding: 4px;
  position: relative;
  animation: popIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.speech-word-card img, .speech-word-card svg {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
}

.speech-word-card span {
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 2px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.speech-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  height: 100%;
}

.speech-btn {
  height: 64px;
  padding: 0 16px;
  border-radius: 16px;
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: manipulation;
}

.btn-speak {
  background: var(--primary);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px var(--primary-glow);
  min-width: 140px;
}

.btn-speak:active {
  transform: scale(0.95);
  box-shadow: 0 2px 6px var(--primary-glow);
}

.btn-clear-word {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  width: 64px;
}

.btn-clear-all {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.25);
  width: 64px;
}

.btn-clear-word:active, .btn-clear-all:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.1);
}

/* AAC Grid Layout */
.aac-grid-wrapper {
  height: 100%;
  overflow-y: hidden;
  padding-right: 4px;
  min-height: 0; /* CRITICAL GRID ITEM HEIGHT RESOLUTION */
}

.aac-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  --grid-gap: 16px;
  gap: var(--grid-gap);
  padding: 4px;
  margin-bottom: 0;
  height: calc(100% - 8px);
}

.aac-grid.size-small {
  --grid-gap: 8px;
  gap: var(--grid-gap);
}
.aac-grid.size-large {
  --grid-gap: 20px;
  gap: var(--grid-gap);
}
.aac-grid.size-xlarge {
  --grid-gap: 24px;
  gap: var(--grid-gap);
}



/* Dynamic percentage-based row constraints relative to wrapper height */
.aac-grid.grid-rows-2 {
  grid-template-rows: repeat(2, calc((100% - var(--grid-gap)) / 2));
  grid-auto-rows: calc((100% - var(--grid-gap)) / 2);
}
.aac-grid.grid-rows-3 {
  grid-template-rows: repeat(3, calc((100% - (var(--grid-gap) * 2)) / 3));
  grid-auto-rows: calc((100% - (var(--grid-gap) * 2)) / 3);
}
.aac-grid.grid-rows-4 {
  grid-template-rows: repeat(4, calc((100% - (var(--grid-gap) * 3)) / 4));
  grid-auto-rows: calc((100% - (var(--grid-gap) * 3)) / 4);
}
.aac-grid.grid-rows-5 {
  grid-template-rows: repeat(5, calc((100% - (var(--grid-gap) * 4)) / 5));
  grid-auto-rows: calc((100% - (var(--grid-gap) * 4)) / 5);
}
.aac-grid.grid-rows-6 {
  grid-template-rows: repeat(6, calc((100% - (var(--grid-gap) * 5)) / 6));
  grid-auto-rows: calc((100% - (var(--grid-gap) * 5)) / 6);
}


/* Folder button on the AAC board */
.aac-folder-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  border-radius: 20px;
  padding: 12px;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s ease;
  box-shadow: 0 6px 16px -3px rgba(0, 0, 0, 0.5);
  touch-action: manipulation;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.08));
  border: 2px solid rgba(99, 102, 241, 0.35);
}

.aac-folder-btn:active {
  transform: scale(0.94);
}

.aac-folder-btn > svg {
  width: 52%;
  height: 52%;
  object-fit: contain;
  margin-bottom: 8px;
  border-radius: 10px;
  pointer-events: none;
}

.aac-folder-btn.has-image {
  padding: 0 !important;
  overflow: hidden !important;
}

.aac-folder-btn.has-image img {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 18px !important;
  margin: 0 !important;
  z-index: 1 !important;
  pointer-events: none;
}

.aac-folder-btn.has-image span {
  position: absolute !important;
  bottom: 12px !important;
  left: 8px !important;
  right: 8px !important;
  height: auto !important;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 0 !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  font-size: 1.25rem !important;
  line-height: 1.1 !important;
  z-index: 2 !important;
  text-shadow: 
    -1.5px -1.5px 0 #000,  
     1.5px -1.5px 0 #000,
    -1.5px  1.5px 0 #000,
     1.5px  1.5px 0 #000,
     0 2px 5px rgba(0, 0, 0, 0.9) !important;
  text-transform: uppercase !important;
}

.aac-folder-btn .folder-icon {
  width: 44%;
  height: 44%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  color: var(--primary);
  opacity: 0.9;
}

.aac-folder-btn .folder-icon svg {
  width: 100%;
  height: 100%;
}

.aac-folder-btn span {
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
  color: #c7d2fe;
  pointer-events: none;
}

.aac-folder-btn .folder-count {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

/* Navigation Paging Buttons */
.nav-page-btn {
  background: rgba(255, 255, 255, 0.03) !important;
  border: 2px dashed var(--primary) !important;
  opacity: 0.95;
}
.nav-page-btn:hover {
  background: rgba(14, 165, 233, 0.08) !important;
  border-style: solid !important;
  box-shadow: 0 0 12px var(--primary-glow) !important;
  transform: scale(1.02);
}

/* Drag and Drop visual feedback styling */
.aac-btn.dragging, .aac-folder-btn.dragging {
  opacity: 0.45;
  border: 2px dashed var(--primary) !important;
  transform: scale(0.95);
  box-shadow: none;
  background: rgba(99, 102, 241, 0.05) !important;
}

.aac-btn.drag-over, .aac-folder-btn.drag-over {
  border: 2px solid var(--primary) !important;
  box-shadow: 0 0 15px var(--primary-glow) !important;
  transform: scale(1.05);
}

/* Breadcrumb navigation bar */
.aac-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.aac-breadcrumb::-webkit-scrollbar { display: none; }

.breadcrumb-item {
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  color: var(--text-secondary);
}
.breadcrumb-item:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--text-primary);
}
.breadcrumb-item.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
}
.breadcrumb-separator {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* AAC Action Buttons */
.aac-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  border-radius: 20px;
  padding: 12px;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 6px 12px -3px rgba(0, 0, 0, 0.4);
  touch-action: manipulation;
  overflow: hidden;
  border: 2px solid transparent;
}

.aac-btn:active {
  transform: scale(0.94);
}

.aac-btn svg {
  width: 52%;
  height: 52%;
  object-fit: contain;
  margin-bottom: 8px;
  border-radius: 10px;
  pointer-events: none;
}

.aac-btn.has-image {
  padding: 0 !important;
  overflow: hidden !important;
}

.aac-btn.has-image img {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 18px !important;
  margin: 0 !important;
  z-index: 1 !important;
  pointer-events: none;
}

.aac-btn.has-image span {
  position: absolute !important;
  bottom: 12px !important;
  left: 8px !important;
  right: 8px !important;
  height: auto !important;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 0 !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  font-size: 1.25rem !important;
  line-height: 1.1 !important;
  z-index: 2 !important;
  text-shadow: 
    -1.5px -1.5px 0 #000,  
     1.5px -1.5px 0 #000,
    -1.5px  1.5px 0 #000,
     1.5px  1.5px 0 #000,
     0 2px 5px rgba(0, 0, 0, 0.9) !important;
  text-transform: uppercase !important;
}

.aac-btn span {
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
  pointer-events: none;
}

/* Color Coding - Fitzgerald Accentuation */
.cat-yellow {
  background-color: var(--fitz-yellow-bg) !important;
  color: var(--fitz-yellow-text) !important;
  border-color: var(--fitz-yellow-border) !important;
}
.cat-yellow:hover {
  filter: brightness(1.03);
}

.cat-green {
  background-color: var(--fitz-green-bg) !important;
  color: var(--fitz-green-text) !important;
  border-color: var(--fitz-green-border) !important;
}
.cat-green:hover {
  filter: brightness(1.03);
}

.cat-blue {
  background-color: var(--fitz-blue-bg) !important;
  color: var(--fitz-blue-text) !important;
  border-color: var(--fitz-blue-border) !important;
}
.cat-blue:hover {
  filter: brightness(1.03);
}

.cat-orange {
  background-color: var(--fitz-orange-bg) !important;
  color: var(--fitz-orange-text) !important;
  border-color: var(--fitz-orange-border) !important;
}
.cat-orange:hover {
  filter: brightness(1.03);
}

.cat-pink {
  background-color: var(--fitz-pink-bg) !important;
  color: var(--fitz-pink-text) !important;
  border-color: var(--fitz-pink-border) !important;
}
.cat-pink:hover {
  filter: brightness(1.03);
}

.cat-grey {
  background-color: var(--fitz-grey-bg) !important;
  color: var(--fitz-grey-text) !important;
  border-color: var(--fitz-grey-border) !important;
}
.cat-grey:hover {
  filter: brightness(1.03);
}

/* Folder-type rows in the Caregiver Cards list */
.cat-folder {
  background-color: rgba(99, 102, 241, 0.15) !important;
  color: #c7d2fe !important;
  border-color: rgba(99, 102, 241, 0.3) !important;
}
.cat-folder:hover {
  filter: brightness(1.1);
}

/* Caregiver Overlay Buttons inside Edit Mode */
.edit-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

body.edit-mode-active .edit-badge {
  display: flex;
}

/* Select Badge in Edit Mode */
.select-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  background: rgba(15, 23, 42, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: white;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 10;
  cursor: pointer;
  transition: all 0.15s ease;
}

body.edit-mode-active .select-badge {
  display: flex;
}

.aac-btn.selected {
  border-color: var(--primary) !important;
  box-shadow: 0 0 12px var(--primary-glow) !important;
  outline: 2px solid rgba(99, 102, 241, 0.5);
  outline-offset: 2px;
}

.aac-btn.selected .select-badge {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 700;
}

/* Breadcrumb drop target highlight */
.breadcrumb-item.drag-over {
  background: rgba(99, 102, 241, 0.25) !important;
  border-color: var(--primary) !important;
  color: white !important;
  box-shadow: 0 0 12px var(--primary-glow);
  transform: scale(1.05);
}

/* Floating Selection Toolbar */
.selection-toolbar {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  z-index: 100;
  animation: slideUpToolbar 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 90vw;
}

@keyframes slideUpToolbar {
  from { 
    opacity: 0;
    transform: translateX(-50%) translateY(20px); 
  }
  to { 
    opacity: 1;
    transform: translateX(-50%) translateY(0); 
  }
}

.sel-toolbar-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.sel-toolbar-count {
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.sel-toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sel-toolbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: 'Outfit', sans-serif;
}

.sel-toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sel-toolbar-btn:active {
  transform: scale(0.95);
}

.sel-btn-move-main {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
}

.sel-btn-move-main:hover {
  background: rgba(99, 102, 241, 0.25);
}

.sel-btn-delete {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.sel-btn-delete:hover {
  background: rgba(239, 68, 68, 0.2);
}

.sel-btn-cancel {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.sel-btn-cancel:hover {
  color: var(--text-primary);
}

body.edit-mode-active .aac-btn {
  animation: shake 0.5s infinite alternate;
}

body.edit-mode-active .aac-btn:nth-child(even) {
  animation-duration: 0.45s;
}

/* Grid configurations */
.grid-cols-2 { grid-template-columns: repeat(2, 1fr) !important; }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr) !important; }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr) !important; }
.grid-cols-5 { grid-template-columns: repeat(5, 1fr) !important; }
.grid-cols-6 { grid-template-columns: repeat(6, 1fr) !important; }

/* AAC Dynamic Page Selector Pills (edit mode only) */
.aac-pages-bar {
  display: none;
}
body.edit-mode-active .aac-pages-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 4px 8px 4px;
  scrollbar-width: none;
  touch-action: pan-x;
  flex-shrink: 0;
}
.aac-pages-bar::-webkit-scrollbar {
  display: none;
}

.page-pill {
  padding: 10px 18px;
  border-radius: 40px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  touch-action: manipulation;
}
.page-pill:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}
.page-pill:active {
  transform: scale(0.95);
}
.page-pill.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
  box-shadow: 0 0 15px -3px var(--primary-glow);
}
.page-pill-add {
  border-style: dashed;
  border-color: var(--primary);
  color: var(--primary);
}
.page-pill-add:hover {
  background: rgba(99, 102, 241, 0.05);
  color: #818cf8;
}

/* Caregiver page tree hierarchy */
.page-tree-container {
  margin-bottom: 20px;
}
.page-tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  margin-bottom: 8px;
  transition: all 0.15s ease;
  touch-action: none;
  -webkit-user-drag: element;
  user-select: none;
  -webkit-user-select: none;
}
.page-tree-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.page-tree-item.page-dragging {
  opacity: 0.35;
  border: 2px dashed var(--primary) !important;
  background: rgba(255, 255, 255, 0.01) !important;
}
.page-tree-item.drag-inside {
  background: rgba(14, 165, 233, 0.15) !important;
  border: 2px dashed var(--primary) !important;
  transform: scale(1.02);
}
.page-tree-item.drag-before {
  border-top: 3px solid var(--primary) !important;
}
.page-tree-item.drag-after {
  border-bottom: 3px solid var(--primary) !important;
}

.page-tree-root-dropzone {
  padding: 14px;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.01);
  margin-bottom: 12px;
  transition: all 0.2s ease;
  display: none;
  opacity: 0;
  user-select: none;
}
.page-tree-root-dropzone.active {
  display: block;
  opacity: 1;
  animation: slideDownFadeIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.page-tree-root-dropzone.drag-over {
  background: rgba(14, 165, 233, 0.15) !important;
  border-color: var(--primary) !important;
  color: #ffffff !important;
  box-shadow: 0 0 15px var(--primary-glow);
}

@keyframes slideDownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-tree-info {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}
.page-tree-info * {
  pointer-events: none;
}
.page-tree-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}
.page-tree-icon svg {
  width: 18px;
  height: 18px;
}
.page-tree-name {
  font-weight: 600;
  font-size: 0.95rem;
}
.page-tree-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.page-tree-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* AAC Button Sizing Variations */
.aac-grid.size-small {
  gap: 8px;
}
.aac-grid.size-small .aac-btn {
  padding: 8px;
  border-radius: 12px;
  aspect-ratio: 1.25;
}
.aac-grid.size-small .aac-btn span {
  font-size: 0.8rem;
}
.aac-grid.size-small .aac-btn img,
.aac-grid.size-small .aac-btn svg {
  width: 44%;
  height: 44%;
  margin-bottom: 4px;
}

.aac-grid.size-large {
  gap: 20px;
}
.aac-grid.size-large .aac-btn {
  padding: 16px;
  border-radius: 24px;
  aspect-ratio: 1.05;
}
.aac-grid.size-large .aac-btn span {
  font-size: 1.25rem;
}
.aac-grid.size-large .aac-btn img,
.aac-grid.size-large .aac-btn svg {
  width: 58%;
  height: 58%;
  margin-bottom: 12px;
}

.aac-grid.size-xlarge {
  gap: 24px;
}
.aac-grid.size-xlarge .aac-btn {
  padding: 20px;
  border-radius: 28px;
  aspect-ratio: 1.0;
}
.aac-grid.size-xlarge .aac-btn span {
  font-size: 1.45rem;
}
.aac-grid.size-xlarge .aac-btn img,
.aac-grid.size-xlarge .aac-btn svg {
  width: 64%;
  height: 64%;
  margin-bottom: 16px;
}

/* NOW & NEXT MODULE SPECIFICS */
.now-next-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100%;
}

.anchor-title {
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  background: linear-gradient(to right, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.now-next-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  flex: 1;
}

.now-next-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 24px;
  position: relative;
  overflow: hidden;
  height: 100%;
  transition: transform 0.2s ease;
}

.now-next-card:hover {
  transform: translateY(-4px);
}

.card-badge {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 8px 24px;
  border-radius: 40px;
  margin-bottom: 24px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.badge-now {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-next {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.card-visual-wrapper {
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
  overflow: hidden;
  padding: 16px;
}

.card-visual-wrapper img, .card-visual-wrapper svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
}

.card-activity-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}

.card-time-slot {
  font-size: 1.15rem;
  color: var(--text-secondary);
  font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 16px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Time progress indicator */
.progress-ring-container {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
}

/* INTERACTIVE SCHEDULER MODULE */
.scheduler-layout {
  display: grid;
  grid-template-rows: 60px 1fr;
  gap: 20px;
  height: 100%;
  overflow: hidden;
}

.scheduler-subnav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.02);
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  width: max-content;
  margin: 0 auto;
}

.subnav-btn {
  padding: 8px 24px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.subnav-btn.active {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.scheduler-views-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.sched-view {
  width: 100%;
  height: 100%;
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  overflow-y: auto;
  padding-bottom: 30px;
}

.sched-view.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Timeline Layout (Daily) */
.timeline-container {
  max-width: 700px;
  margin: 0 auto;
  position: relative;
  padding-left: 32px;
}

.timeline-container::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 15px;
  width: 2px;
  background: linear-gradient(to bottom, var(--primary), rgba(99, 102, 241, 0.1));
}

.timeline-item {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 20px;
  margin-bottom: 24px;
  position: relative;
}

.timeline-dot {
  position: absolute;
  left: -24px;
  top: 26px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-main);
  border: 3px solid var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  z-index: 10;
}

.timeline-dot.passed {
  border-color: var(--text-muted);
}

.timeline-dot.active {
  border-color: var(--danger);
  animation: pulseGlow 1.5s infinite;
}

.timeline-time {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
  padding-top: 22px;
  text-align: right;
}

.timeline-time.active {
  color: var(--text-primary);
}

.timeline-card {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  gap: 16px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.timeline-card:hover {
  transform: translateX(4px);
}

.timeline-card.active {
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.1);
  background: rgba(239, 68, 68, 0.02);
}

.timeline-card-visual {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.timeline-card-visual img, .timeline-card-visual svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.timeline-card-info {
  flex: 1;
}

.timeline-card-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.timeline-card-duration {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.timeline-status {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 30px;
}

.status-now {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-next {
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.status-later {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

/* Weekly Grid Views */
.weekly-container {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  height: 100%;
  min-width: 900px; /* Horizontal scroll on smaller screens */
}

.weekly-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  min-height: 400px;
}

.weekly-day-header {
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.weekly-day-header.today {
  color: var(--primary);
  font-weight: 800;
}

.weekly-event-card {
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s ease;
}

.weekly-event-card:hover {
  background: rgba(255, 255, 255, 0.04);
}

.weekly-event-card img, .weekly-event-card svg {
  width: 32px;
  height: 32px;
  object-fit: contain;
  align-self: center;
}

.weekly-event-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weekly-event-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Monthly Traditional Grid Calendar */
.monthly-container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.monthly-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
}

.monthly-month-title {
  font-size: 1.4rem;
  font-weight: 700;
}

.monthly-nav {
  display: flex;
  gap: 8px;
}

.monthly-nav-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.monthly-nav-btn:active {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(0.9);
}

.monthly-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.monthly-day-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
  padding: 8px 0;
}

.monthly-cell {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}

.monthly-cell:hover {
  background: rgba(255, 255, 255, 0.04);
}

.monthly-cell.today {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.monthly-cell.other-month {
  opacity: 0.3;
}

.monthly-cell-number {
  font-size: 0.9rem;
  font-weight: 600;
}

.monthly-cell-events-dots {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.event-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

/* CAREGIVER DASHBOARD & FORMS */
.dashboard-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  height: 100%;
  overflow: hidden;
}

.dash-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-sidebar-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.dash-sidebar-btn svg {
  width: 20px;
  height: 20px;
}

.dash-sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
}

.dash-sidebar-btn.active {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.dash-content {
  overflow-y: auto;
  padding-right: 8px;
}

.dash-pane {
  display: none;
}

.dash-pane.active {
  display: block;
}

.dash-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 20px;
}

/* Form controls */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: rgba(15, 20, 35, 0.95);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

/* Dark mode dropdown options */
.form-select option {
  background: #151b2e;
  color: var(--text-primary);
  padding: 8px 12px;
}

.form-select option:checked {
  background: var(--primary);
  color: white;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Button variants */
.btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:active {
  transform: scale(0.97);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-secondary:active {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(0.97);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:active {
  background: rgba(239, 68, 68, 0.25);
  transform: scale(0.97);
}

/* Image Picker Widget */
.image-picker-container {
  display: flex;
  gap: 16px;
  align-items: center;
}

.image-picker-preview {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  border: 2px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  flex-shrink: 0;
}

.image-picker-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-picker-btn-wrapper {
  flex: 1;
}

/* Overlay & Passcode Modal */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(7, 10, 18, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.overlay.active {
  display: flex;
  opacity: 1;
}

.modal {
  width: 90%;
  max-width: 480px;
  padding: 32px;
  position: relative;
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.overlay.active .modal {
  transform: scale(1);
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
}

/* Passcode Pin Pad Grid */
.pin-display-container {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-secondary);
  transition: all 0.15s ease;
}

.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  transform: scale(1.2);
}

.pin-pad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 280px;
  margin: 0 auto;
}

.pin-btn {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
}

.pin-btn:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.9);
}

.pin-btn.btn-action {
  font-size: 0.95rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
}

.pin-btn.btn-action:active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* Caregiver Config Items */
.caregiver-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  margin-bottom: 12px;
  touch-action: none;
  -webkit-user-drag: element;
  user-select: none;
  -webkit-user-select: none;
  transition: border 0.15s ease, background 0.15s ease;
}

.caregiver-item-row.touch-dragging,
.caregiver-item-row.card-dragging {
  opacity: 0.35;
  border: 2px dashed var(--primary) !important;
  background: rgba(255, 255, 255, 0.01) !important;
}

.caregiver-item-row.drag-before {
  border-top: 3px solid var(--primary) !important;
}

.caregiver-item-row.drag-after {
  border-bottom: 3px solid var(--primary) !important;
}

.caregiver-page-section {
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.caregiver-page-section.drag-over {
  background: rgba(14, 165, 233, 0.08) !important;
  border: 1px dashed var(--primary) !important;
}


.item-details {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-thumbnail {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-thumbnail img, .item-thumbnail svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.item-text {
  display: flex;
  flex-direction: column;
}

.item-title {
  font-size: 1rem;
  font-weight: 600;
}

.item-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.item-actions {
  display: flex;
  gap: 8px;
}

/* Animations */
@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes shake {
  0% { transform: rotate(-1deg); }
  100% { transform: rotate(1deg); }
}

@keyframes pulseGlow {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Theme Swatches Color Picker UI */
.theme-swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  touch-action: manipulation;
}
.theme-swatch:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}
.theme-swatch-circle {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* =====================================================
   COMPREHENSIVE RESPONSIVE BREAKPOINTS
   Covers: phones, small tablets, tablets, large tablets, desktops
   ===================================================== */

/* ---- GLOBAL FLUID SCALING ---- */
html {
  font-size: clamp(14px, 1.6vw, 18px);
}

/* ---- EXTRA LARGE SCREENS (1280px+) ---- */
@media (min-width: 1280px) {
  .now-next-grid {
    gap: 40px;
    max-width: 1100px;
    margin: 0 auto;
  }
  .card-visual-wrapper {
    width: 260px;
    height: 260px;
  }
  .timeline-container {
    max-width: 800px;
  }
  .monthly-container {
    max-width: 900px;
  }
}

/* ---- LARGE TABLETS / SMALL DESKTOPS (1025px – 1279px) ---- */
@media (max-width: 1279px) {
  .card-visual-wrapper {
    width: 200px;
    height: 200px;
  }
  .card-activity-title {
    font-size: 1.7rem;
  }
}

/* ---- MEDIUM TABLETS / LANDSCAPE PHONES (769px – 1024px) ---- */
@media (max-width: 1024px) {
  :root {
    --header-height: 64px;
    --nav-height: 72px;
  }

  main {
    padding: 16px;
  }

  .view-container {
    padding: 16px;
  }

  .aac-grid {
    gap: 12px;
  }

  .aac-btn span, .aac-folder-btn span {
    font-size: 0.95rem;
  }

  .now-next-grid {
    gap: 20px;
  }

  .card-visual-wrapper {
    width: 180px;
    height: 180px;
  }

  .card-activity-title {
    font-size: 1.5rem;
  }

  .card-badge {
    font-size: 1.1rem;
    padding: 6px 20px;
    margin-bottom: 16px;
  }

  .anchor-title {
    font-size: 1.5rem;
  }

  .nav-tab {
    padding: 8px 16px;
    min-width: 80px;
  }

  nav {
    gap: 16px;
  }

  .speech-btn {
    height: 56px;
    padding: 0 12px;
  }

  .btn-speak {
    min-width: 120px;
  }

  .btn-speak span {
    display: inline;
  }

  .weekly-container {
    min-width: 700px;
  }

  .dashboard-layout {
    grid-template-columns: 200px 1fr;
    gap: 16px;
  }
}

/* ---- PORTRAIT TABLETS / LARGE PHONES (641px – 768px) ---- */
@media (max-width: 768px) {
  :root {
    --header-height: 60px;
    --nav-height: 68px;
  }

  main {
    padding: 12px;
  }

  .view-container {
    padding: 12px;
  }

  /* Header shrinks */
  header {
    padding: 0 16px;
  }

  .logo-text {
    font-size: 1.1rem;
  }

  .logo-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .caregiver-badge {
    padding: 6px 12px;
    font-size: 0.75rem;
  }

  .caregiver-badge svg {
    width: 14px;
    height: 14px;
  }

  /* Nav system */
  nav {
    gap: 8px;
    padding: 0 12px;
  }

  .nav-tab {
    padding: 6px 12px;
    min-width: 64px;
  }

  .nav-tab svg {
    width: 22px;
    height: 22px;
  }

  .nav-tab span {
    font-size: 0.7rem;
  }

  /* AAC: Dynamic grids on portrait tablets */
  .aac-grid {
    gap: 10px;
  }

  .aac-btn span, .aac-folder-btn span {
    font-size: 0.9rem;
  }

  .aac-btn, .aac-folder-btn {
    padding: 10px;
    border-radius: 16px;
  }

  /* Speech bar compresses */
  .aac-layout {
    grid-template-rows: 90px auto auto 1fr;
    gap: 12px;
  }

  .speech-bar-container {
    padding: 8px 12px;
    gap: 10px;
  }

  .speech-word-card {
    min-width: 56px;
    height: 56px;
  }

  .speech-word-card img, .speech-word-card svg {
    width: 26px;
    height: 26px;
  }

  .speech-word-card span {
    font-size: 0.6rem;
  }

  .speech-btn {
    height: 48px;
    padding: 0 10px;
    font-size: 0.85rem;
    border-radius: 12px;
  }

  .btn-speak {
    min-width: 100px;
  }

  .btn-clear-word, .btn-clear-all {
    width: 48px;
  }

  /* Now & Next stacks vertically */
  .now-next-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .now-next-card {
    padding: 24px 16px;
  }

  .card-visual-wrapper {
    width: 140px;
    height: 140px;
    margin-bottom: 16px;
  }

  .card-activity-title {
    font-size: 1.3rem;
  }

  .card-time-slot {
    font-size: 1rem;
  }

  .card-badge {
    font-size: 1rem;
    padding: 6px 16px;
    margin-bottom: 12px;
  }

  .anchor-title {
    font-size: 1.3rem;
    margin-bottom: 4px;
  }

  /* Scheduler subnav */
  .scheduler-subnav {
    gap: 8px;
    padding: 4px;
  }

  .subnav-btn {
    padding: 6px 16px;
    font-size: 0.85rem;
  }

  /* Weekly view scrollable */
  .weekly-container {
    min-width: 600px;
  }

  .weekly-column {
    padding: 8px;
    min-height: 300px;
  }

  /* Monthly calendar */
  .monthly-container {
    max-width: 100%;
  }

  .monthly-grid {
    gap: 4px;
  }

  .monthly-cell {
    border-radius: 8px;
    padding: 4px;
  }

  .monthly-cell-number {
    font-size: 0.8rem;
  }

  /* Timeline */
  .timeline-item {
    grid-template-columns: 60px 1fr;
    gap: 12px;
    margin-bottom: 16px;
  }

  .timeline-card {
    padding: 12px 14px;
    gap: 12px;
  }

  .timeline-card-visual {
    width: 48px;
    height: 48px;
  }

  .timeline-card-title {
    font-size: 1rem;
  }

  /* Caregiver dashboard stacks */
  .dashboard-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .dash-sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
  }

  .dash-sidebar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: normal;
    padding: 12px 6px;
    font-size: 0.8rem;
    gap: 6px;
    border-radius: 12px;
  }

  .dash-title {
    font-size: 1.2rem;
  }

  /* Forms */
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Modals */
  .modal {
    padding: 24px 20px;
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal-title {
    font-size: 1.2rem;
    margin-bottom: 16px;
  }

  .pin-pad-grid {
    max-width: 240px;
    gap: 12px;
  }

  .pin-btn {
    font-size: 1.3rem;
  }
}

/* ---- SMALL PHONES (481px – 640px) ---- */
@media (max-width: 640px) {
  :root {
    --header-height: 56px;
    --nav-height: 64px;
  }

  /* Header compact */
  .logo-text {
    font-size: 1rem;
  }

  .caregiver-badge span {
    display: none;
  }

  /* Nav: icons only on small phones */
  .nav-tab span {
    font-size: 0.6rem;
  }

  .nav-tab {
    padding: 6px 10px;
    min-width: auto;
  }

  nav {
    gap: 4px;
    justify-content: space-around;
  }

  /* AAC: smaller buttons */
  .aac-grid {
    gap: 8px;
  }

  .aac-btn, .aac-folder-btn {
    padding: 8px;
    border-radius: 14px;
  }

  .aac-btn span, .aac-folder-btn span {
    font-size: 0.8rem;
  }

  .aac-btn img, .aac-btn svg,
  .aac-folder-btn img, .aac-folder-btn > svg, .aac-folder-btn .folder-icon {
    width: 48%;
    height: 48%;
    margin-bottom: 4px;
  }

  /* Speech bar more compact */
  .aac-layout {
    grid-template-rows: 80px auto auto 1fr;
    gap: 8px;
  }

  .speech-bar-container {
    padding: 6px 8px;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .speech-controls {
    gap: 6px;
  }

  .speech-btn {
    height: 42px;
    padding: 0 8px;
    border-radius: 10px;
    font-size: 0.8rem;
  }

  .btn-speak {
    min-width: 80px;
  }

  .btn-speak span {
    display: none;
  }

  .btn-clear-word, .btn-clear-all {
    width: 42px;
  }

  .btn-clear-word svg, .btn-clear-all svg, .btn-speak svg {
    width: 18px;
    height: 18px;
  }

  .speech-word-card {
    min-width: 48px;
    height: 48px;
  }

  .speech-word-card img, .speech-word-card svg {
    width: 22px;
    height: 22px;
  }

  .speech-word-card span {
    font-size: 0.55rem;
  }

  /* Now & Next */
  .card-visual-wrapper {
    width: 120px;
    height: 120px;
    padding: 12px;
  }

  .now-next-card {
    padding: 20px 12px;
  }

  .card-activity-title {
    font-size: 1.15rem;
  }

  /* Scheduler */
  .scheduler-layout {
    grid-template-rows: 50px 1fr;
    gap: 12px;
  }

  .scheduler-subnav {
    gap: 4px;
  }

  .subnav-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
  }

  .scheduler-subnav button[data-view="weekly"] {
    display: none !important;
  }

  /* Timeline compact */
  .timeline-container {
    padding-left: 24px;
  }

  .timeline-container::before {
    left: 10px;
  }

  .timeline-dot {
    left: -20px;
    width: 12px;
    height: 12px;
  }

  .timeline-item {
    grid-template-columns: 50px 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }

  .timeline-time {
    font-size: 0.8rem;
    padding-top: 16px;
  }

  .timeline-card {
    padding: 10px 12px;
    gap: 10px;
  }

  .timeline-card-visual {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  .timeline-card-title {
    font-size: 0.9rem;
  }

  .timeline-card-duration {
    font-size: 0.75rem;
  }

  .timeline-status {
    font-size: 0.7rem;
    padding: 3px 8px;
  }

  /* Weekly full-width stacked columns on smaller phones */
  .weekly-container {
    grid-template-columns: 1fr;
    min-width: 100%;
  }

  .weekly-column {
    min-height: auto;
    padding: 10px;
  }

  .weekly-event-card img, .weekly-event-card svg {
    width: 24px;
    height: 24px;
  }

  .weekly-event-title {
    font-size: 0.8rem;
  }

  /* Monthly */
  .monthly-month-title {
    font-size: 1.1rem;
  }

  .monthly-nav-btn {
    width: 36px;
    height: 36px;
  }

  /* Caregiver list items */
  .caregiver-item-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
  }

  .item-actions {
    align-self: flex-end;
  }

  .btn {
    padding: 10px 16px;
    font-size: 0.85rem;
  }

  /* Modal */
  .modal {
    width: 95%;
    padding: 20px 16px;
  }

  .modal-title {
    font-size: 1.1rem;
  }

  .image-picker-container {
    flex-direction: column;
  }

  .image-picker-preview {
    width: 100%;
    height: 80px;
  }
}

/* ---- EXTRA-SMALL PHONES (≤480px) ---- */
@media (max-width: 480px) {
  :root {
    --header-height: 52px;
    --nav-height: 60px;
  }

  header {
    padding: 0 10px;
  }

  .logo-section {
    gap: 8px;
  }

  .logo-icon {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
    border-radius: 8px;
  }

  .logo-text {
    font-size: 0.9rem;
  }

  /* Nav minimal */
  nav {
    gap: 2px;
    padding: 0 6px;
  }

  .nav-tab {
    padding: 4px 8px;
    gap: 2px;
  }

  .nav-tab svg {
    width: 20px;
    height: 20px;
  }

  .nav-tab span {
    font-size: 0.55rem;
  }

  /* AAC: smaller screens */
  .aac-grid {
    gap: 8px;
  }

  .aac-btn, .aac-folder-btn {
    padding: 8px 6px;
    border-radius: 12px;
  }

  .aac-btn span, .aac-folder-btn span {
    font-size: 0.75rem;
  }

  .aac-btn.has-image span, .aac-folder-btn.has-image span {
    font-size: 0.95rem !important;
    bottom: 8px !important;
  }

  /* Speech bar minimal */
  .aac-layout {
    grid-template-rows: 70px auto auto 1fr;
    gap: 6px;
  }

  .speech-bar-container {
    padding: 4px 6px;
    gap: 4px;
    border-radius: 14px;
  }

  .speech-btn {
    height: 38px;
    border-radius: 8px;
  }

  .btn-speak {
    min-width: 38px;
  }

  .btn-clear-word, .btn-clear-all {
    width: 38px;
  }

  .speech-word-card {
    min-width: 42px;
    height: 42px;
    border-radius: 8px;
  }

  .speech-word-card img, .speech-word-card svg {
    width: 18px;
    height: 18px;
  }

  .speech-word-card span {
    font-size: 0.5rem;
  }

  /* Now & Next extra compact */
  .now-next-card {
    padding: 16px 10px;
    border-radius: 16px;
  }

  .card-visual-wrapper {
    width: 100px;
    height: 100px;
    padding: 8px;
    border-radius: 16px;
    margin-bottom: 12px;
  }

  .card-activity-title {
    font-size: 1rem;
  }

  .card-time-slot {
    font-size: 0.85rem;
    padding: 4px 10px;
  }

  .card-badge {
    font-size: 0.85rem;
    padding: 4px 12px;
    margin-bottom: 10px;
  }

  .anchor-title {
    font-size: 1.1rem;
  }

  .progress-ring-container {
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
  }

  /* Scheduler subnav */
  .scheduler-layout {
    grid-template-rows: 44px 1fr;
    gap: 8px;
  }

  .subnav-btn {
    padding: 4px 10px;
    font-size: 0.7rem;
  }

  /* Monthly cells minimal */
  .monthly-cell {
    aspect-ratio: auto;
    min-height: 36px;
    padding: 3px;
    border-radius: 6px;
  }

  .monthly-cell-number {
    font-size: 0.7rem;
  }

  .event-dot {
    width: 4px;
    height: 4px;
  }

  .monthly-day-label {
    font-size: 0.65rem;
    padding: 4px 0;
  }

  .monthly-grid {
    gap: 3px;
  }

  /* Pin pad compact */
  .pin-pad-grid {
    max-width: 200px;
    gap: 10px;
  }

  .pin-btn {
    font-size: 1.1rem;
  }

  .pin-display-container {
    gap: 12px;
    margin-bottom: 16px;
  }

  .pin-dot {
    width: 14px;
    height: 14px;
  }

  /* Caregiver dashboard */
  .dash-sidebar-btn {
    padding: 10px 4px;
    font-size: 0.75rem;
    gap: 4px;
  }

  .dash-sidebar-btn svg {
    width: 16px;
    height: 16px;
  }

  .dash-title {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }

  .form-label {
    font-size: 0.8rem;
  }

  .form-input, .form-select {
    padding: 10px 12px;
    font-size: 0.85rem;
    border-radius: 10px;
  }
}

/* ---- LANDSCAPE PHONE ORIENTATION ---- */
@media (max-height: 500px) and (orientation: landscape) {
  body:not(.rotation-locked-active) {
    --header-height: 44px;
    --nav-height: 52px;
  }

  body:not(.rotation-locked-active) .logo-text {
    display: none;
  }

  body:not(.rotation-locked-active) nav {
    gap: 4px;
  }

  body:not(.rotation-locked-active) .nav-tab {
    flex-direction: row;
    padding: 4px 12px;
    gap: 6px;
  }

  body:not(.rotation-locked-active) .nav-tab svg {
    width: 18px;
    height: 18px;
  }

  body:not(.rotation-locked-active) .nav-tab span {
    font-size: 0.65rem;
  }

  body:not(.rotation-locked-active) main {
    padding: 8px;
  }

  body:not(.rotation-locked-active) .view-container {
    padding: 8px;
  }

  /* AAC: wider grid, shorter buttons */
  body:not(.rotation-locked-active) .aac-layout {
    grid-template-rows: 60px auto auto 1fr;
    gap: 6px;
  }

  body:not(.rotation-locked-active) .aac-grid {
    gap: 6px;
  }

  body:not(.rotation-locked-active) .aac-btn {
    padding: 6px;
    border-radius: 10px;
  }

  body:not(.rotation-locked-active) .aac-btn span {
    font-size: 0.7rem;
  }

  /* Now & Next side-by-side in landscape */
  body:not(.rotation-locked-active) .now-next-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  body:not(.rotation-locked-active) .now-next-card {
    padding: 12px 8px;
  }

  body:not(.rotation-locked-active) .card-visual-wrapper {
    width: 80px;
    height: 80px;
    margin-bottom: 8px;
    padding: 6px;
  }

  body:not(.rotation-locked-active) .card-activity-title {
    font-size: 0.95rem;
  }

  body:not(.rotation-locked-active) .card-badge {
    font-size: 0.8rem;
    padding: 3px 10px;
    margin-bottom: 6px;
  }

  body:not(.rotation-locked-active) .anchor-title {
    font-size: 1rem;
    margin-bottom: 4px;
  }

  body:not(.rotation-locked-active) .speech-btn {
    height: 36px;
  }

  body:not(.rotation-locked-active) .speech-word-card {
    min-width: 40px;
    height: 40px;
  }

  /* Modal scrolling in landscape */
  body:not(.rotation-locked-active) .modal {
    max-height: 95vh;
    overflow-y: auto;
  }

  /* ═══════════════════════════════════════════════════════════════
     Visual portrait overrides when rotation lock is active in landscape
     Allows grid, now-next, buttons, nav & logo to render identically to portrait!
     ═══════════════════════════════════════════════════════════════ */
  body.rotation-locked-active {
    --header-height: 52px;
    --nav-height: 60px;
  }

  body.rotation-locked-active .logo-section {
    gap: 8px;
  }

  body.rotation-locked-active .logo-icon-img {
    width: 28px;
    height: 28px;
  }

  body.rotation-locked-active .logo-text {
    font-size: 0.9rem;
    display: inline !important; /* Keep logo text visible in visual portrait */
  }

  body.rotation-locked-active nav {
    gap: 2px;
    padding: 0 6px;
    flex-direction: row;
    justify-content: space-around;
  }

  body.rotation-locked-active .nav-tab {
    padding: 4px 8px;
    gap: 2px;
    flex-direction: column; /* Vertical stacked columns: icon top, text bottom */
    min-width: auto;
  }

  body.rotation-locked-active .nav-tab svg {
    width: 20px;
    height: 20px;
  }

  body.rotation-locked-active .nav-tab span {
    font-size: 0.55rem;
  }

  body.rotation-locked-active main {
    padding: 12px;
  }

  body.rotation-locked-active .view-container {
    padding: 12px;
  }

  body.rotation-locked-active .aac-grid {
    gap: 8px;
  }

  body.rotation-locked-active .aac-btn, 
  body.rotation-locked-active .aac-folder-btn {
    padding: 8px 6px;
    border-radius: 12px;
  }

  body.rotation-locked-active .aac-btn span, 
  body.rotation-locked-active .aac-folder-btn span {
    font-size: 0.75rem;
  }

  body.rotation-locked-active .aac-btn.has-image span,
  body.rotation-locked-active .aac-folder-btn.has-image span {
    font-size: 0.95rem !important;
    bottom: 8px !important;
  }

  body.rotation-locked-active .aac-btn img,
  body.rotation-locked-active .aac-btn svg,
  body.rotation-locked-active .aac-folder-btn img,
  body.rotation-locked-active .aac-folder-btn svg {
    width: 48%;
    height: 48%;
    margin-bottom: 4px;
  }

  body.rotation-locked-active .aac-layout {
    grid-template-rows: 70px auto auto 1fr;
    gap: 6px;
  }

  body.rotation-locked-active .speech-bar-container {
    padding: 4px 6px;
    gap: 4px;
    border-radius: 14px;
  }

  body.rotation-locked-active .speech-btn {
    height: 38px;
    border-radius: 8px;
  }

  body.rotation-locked-active .btn-speak {
    min-width: 38px;
  }

  body.rotation-locked-active .btn-speak span {
    display: none; /* Hide speak button text in compact visual portrait */
  }

  body.rotation-locked-active .btn-clear-word, 
  body.rotation-locked-active .btn-clear-all {
    width: 38px;
  }

  body.rotation-locked-active .speech-word-card {
    min-width: 42px;
    height: 42px;
    border-radius: 8px;
  }

  body.rotation-locked-active .speech-word-card img, 
  body.rotation-locked-active .speech-word-card svg {
    width: 18px;
    height: 18px;
  }

  body.rotation-locked-active .speech-word-card span {
    font-size: 0.5rem;
  }

  body.rotation-locked-active .now-next-grid {
    grid-template-columns: 1fr; /* Stacks vertically in visual portrait! */
    gap: 12px;
  }

  body.rotation-locked-active .now-next-card {
    padding: 16px 10px;
    border-radius: 16px;
  }

  body.rotation-locked-active .card-visual-wrapper {
    width: 100px;
    height: 100px;
    padding: 8px;
    border-radius: 16px;
    margin-bottom: 12px;
  }

  body.rotation-locked-active .card-activity-title {
    font-size: 1rem;
  }

  body.rotation-locked-active .card-time-slot {
    font-size: 0.85rem;
    padding: 4px 10px;
  }

  body.rotation-locked-active .card-badge {
    font-size: 0.85rem;
    padding: 4px 12px;
    margin-bottom: 10px;
  }

  body.rotation-locked-active .progress-ring-container {
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
  }
}

/* ---- SAFE AREA INSETS (iOS notch/home bar) ---- */
@supports (padding: env(safe-area-inset-bottom)) {
  nav {
    padding-bottom: env(safe-area-inset-bottom);
  }

  header {
    padding-top: env(safe-area-inset-top);
  }

  .overlay {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
}

/* ═══════════════════════════════════════════════════════════════
   Touch Drag & Drop
   ═══════════════════════════════════════════════════════════════ */

/* Floating ghost that follows the finger */
.touch-drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.65;
  transform: scale(1.08);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  transition: transform 0.1s ease;
  overflow: hidden;
  /* Prevent text selection flicker */
  user-select: none;
  -webkit-user-select: none;
}

/* Source tile dims while being dragged */
.touch-dragging {
  opacity: 0.35;
  transform: scale(0.96);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

/* Draggable tiles: allow vertical pan (scroll) unless a long-press drag activates */
body.edit-mode-active .aac-btn[draggable="true"],
body.edit-mode-active .aac-folder-btn[draggable="true"] {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Highlighted drop target on touch */
.aac-btn.touch-drag-over,
.aac-folder-btn.touch-drag-over {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
  background: rgba(99, 102, 241, 0.18) !important;
  transform: scale(1.04);
  transition: transform 0.12s ease, background 0.12s ease;
}

/* ═══════════════════════════════════════════════════════════════
   Grid Diagnostics Overlay (Simulator support)
   ═══════════════════════════════════════════════════════════════ */
body.debug-grid-active .aac-grid {
  outline: 3px dashed #ef4444 !important;
  outline-offset: -3px;
  background: rgba(239, 68, 68, 0.05) !important;
}

body.debug-grid-active .aac-btn,
body.debug-grid-active .aac-folder-btn {
  outline: 2px solid #22c55e !important;
  outline-offset: -2px;
}

/* Reveal invisible structural placeholders as blue dashed boxes in debug mode! */
body.debug-grid-active .aac-btn[style*="visibility: hidden"] {
  visibility: visible !important;
  opacity: 0.25 !important;
  border: 2px dashed rgba(14, 165, 233, 0.4) !important;
  background: rgba(14, 165, 233, 0.03) !important;
  outline: 2px dashed #0ea5e9 !important;
  outline-offset: -2px;
  pointer-events: auto !important;
}

body.debug-grid-active .aac-btn[style*="visibility: hidden"] svg {
  visibility: visible !important;
  opacity: 0.15 !important;
  stroke: #0ea5e9 !important;
}

body.debug-grid-active .aac-btn[style*="visibility: hidden"] span {
  visibility: visible !important;
  opacity: 0.3 !important;
  color: #0ea5e9 !important;
}

/* ═══════════════════════════════════════════════════════════════
   Caregiver Setup Premium Toggle Switch Styles
   ═══════════════════════════════════════════════════════════════ */
.toggle-switch-wrapper {
  position: relative;
  width: 48px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 34px;
}

.toggle-switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

input:checked + .toggle-switch-slider {
  background-color: rgba(14, 165, 233, 0.2);
  border-color: var(--primary);
}

input:checked + .toggle-switch-slider:before {
  transform: translateX(24px);
  background-color: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}

/* ═══════════════════════════════════════════════════════════════
   Visually lock screen rotation to Portrait on mobile phones in landscape
   Active ONLY when caregiver locks rotation!
   ═══════════════════════════════════════════════════════════════ */
@media (orientation: landscape) {
  body.rotation-locked-active .app-container {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100vh; /* Set width to Portrait height */
    height: 100vw; /* Set height to Portrait width */
    transform: translate(-50%, -50%) rotate(-90deg);
    transform-origin: center center;
    box-shadow: 0 0 100px rgba(0, 0, 0, 0.85);
  }

  body.rotation-locked-active {
    background-color: #0b0f19;
  }
}

/* =================================================================
   CRITICAL OVERRIDE: Force custom image cards & folders to fill
   the entire tile space edge-to-edge (full bleed) under all modes,
   viewports, grid sizes, and states.
   ================================================================= */
.aac-btn.has-image,
.aac-folder-btn.has-image,
.aac-grid .aac-btn.has-image,
.aac-grid .aac-folder-btn.has-image,
body.rotation-locked-active .aac-btn.has-image,
body.rotation-locked-active .aac-folder-btn.has-image,
.aac-grid.size-small .aac-btn.has-image,
.aac-grid.size-large .aac-btn.has-image,
.aac-grid.size-xlarge .aac-btn.has-image,
.aac-grid.size-small .aac-folder-btn.has-image,
.aac-grid.size-large .aac-folder-btn.has-image,
.aac-grid.size-xlarge .aac-folder-btn.has-image {
  padding: 0 !important;
  overflow: hidden !important;
  border-width: 2px !important;
}

.aac-btn.has-image img,
.aac-folder-btn.has-image img,
.aac-grid .aac-btn.has-image img,
.aac-grid .aac-folder-btn.has-image img,
body.rotation-locked-active .aac-btn.has-image img,
body.rotation-locked-active .aac-folder-btn.has-image img,
.aac-grid.size-small .aac-btn.has-image img,
.aac-grid.size-large .aac-btn.has-image img,
.aac-grid.size-xlarge .aac-btn.has-image img,
.aac-grid.size-small .aac-folder-btn.has-image img,
.aac-grid.size-large .aac-folder-btn.has-image img,
.aac-grid.size-xlarge .aac-folder-btn.has-image img {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: cover !important;
  border-radius: inherit !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: 1 !important;
  display: block !important;
}

/* Ensure text label overlays directly on top of the image centered at the bottom of the card */
.aac-btn.has-image span,
.aac-folder-btn.has-image span,
.aac-grid .aac-btn.has-image span,
.aac-grid .aac-folder-btn.has-image span,
body.rotation-locked-active .aac-btn.has-image span,
body.rotation-locked-active .aac-folder-btn.has-image span,
.aac-grid.size-small .aac-btn.has-image span,
.aac-grid.size-large .aac-btn.has-image span,
.aac-grid.size-xlarge .aac-btn.has-image span,
.aac-grid.size-small .aac-folder-btn.has-image span,
.aac-grid.size-large .aac-folder-btn.has-image span,
.aac-grid.size-xlarge .aac-folder-btn.has-image span {
  position: absolute !important;
  bottom: 12px !important;
  left: 8px !important;
  right: 8px !important;
  height: auto !important;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 0 !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  font-size: 1.25rem !important;
  line-height: 1.1 !important;
  z-index: 2 !important;
  text-shadow: 
    -1.5px -1.5px 0 #000,  
     1.5px -1.5px 0 #000,
    -1.5px  1.5px 0 #000,
     1.5px  1.5px 0 #000,
     0 2px 5px rgba(0, 0, 0, 0.9) !important;
  text-transform: uppercase !important;
  display: block !important;
}

/* Make font/bottom slightly smaller under mobile screen sizes and rotation lock active */
@media (max-width: 640px) {
  .aac-btn.has-image span,
  .aac-folder-btn.has-image span,
  .aac-grid .aac-btn.has-image span,
  .aac-grid .aac-folder-btn.has-image span,
  body.rotation-locked-active .aac-btn.has-image span,
  body.rotation-locked-active .aac-folder-btn.has-image span {
    font-size: 0.95rem !important;
    bottom: 8px !important;
  }
}
@media (max-width: 480px) {
  .aac-btn.has-image span,
  .aac-folder-btn.has-image span,
  .aac-grid .aac-btn.has-image span,
  .aac-grid .aac-folder-btn.has-image span {
    font-size: 0.95rem !important;
    bottom: 8px !important;
  }
}



/* ---- SPLASH SCREEN & WELCOME ONBOARDING OVERLAY ---- */
.splash-screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #151b2e 0%, #0b0f19 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.5s ease-out, visibility 0.5s;
}
.splash-screen-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
}
.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.splash-logo {
  width: 96px;
  height: 96px;
  background: var(--primary);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 40px rgba(14, 165, 233, 0.4);
  font-size: 2.8rem;
  font-weight: 800;
  color: white;
  animation: logoPulse 2s infinite ease-in-out;
}
@keyframes logoPulse {
  0% { transform: scale(1); box-shadow: 0 0 30px rgba(14, 165, 233, 0.3); }
  50% { transform: scale(1.05); box-shadow: 0 0 50px rgba(14, 165, 233, 0.55); }
  100% { transform: scale(1); box-shadow: 0 0 30px rgba(14, 165, 233, 0.3); }
}
.splash-title {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: white;
}
.splash-spinner {
  width: 36px;
  height: 36px;
  border: 3.5px solid rgba(255, 255, 255, 0.05);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-top: 12px;
}

.welcome-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(7, 10, 18, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  opacity: 1;
  transition: opacity 0.4s ease, visibility 0.4s;
  overflow-y: auto;
  padding: 20px 0;
}
.welcome-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
}
.welcome-card {
  width: 90%;
  max-width: 550px;
  background: rgba(15, 22, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: cardFadeIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes cardFadeIn {
  from { transform: translateY(20px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.welcome-logo-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}
.welcome-logo-title {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: white;
  margin: 0;
}
.welcome-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.welcome-nav-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 8px;
}
.welcome-tab-btn {
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 10px 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.welcome-tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.welcome-pane {
  display: none;
  animation: paneFadeIn 0.3s ease;
}
.welcome-pane.active {
  display: block;
}
@keyframes paneFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* PWA INSTALL INSTRUCTIONS SECTION */
.pwa-guide-section {
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
  margin-top: 8px;
}
.pwa-guide-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: white;
  margin-bottom: 12px;
  text-align: center;
  letter-spacing: 0.5px;
}
.pwa-guide-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}
.pwa-guide-tab-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pwa-guide-tab-btn svg {
  width: 14px;
  height: 14px;
}
.pwa-guide-tab-btn.active {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  border-color: rgba(255, 255, 255, 0.2);
}
.pwa-guide-pane {
  display: none;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px;
  animation: paneFadeIn 0.3s ease;
}
.pwa-guide-pane.active {
  display: block;
}
.pwa-step-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-left: 0;
  margin: 0;
  list-style: none;
}
.pwa-step-item {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.pwa-step-num {
  width: 20px;
  height: 20px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.pwa-step-content {
  flex: 1;
}
.pwa-badge-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 600;
  color: white;
  font-size: 0.75rem;
  vertical-align: middle;
}
.pwa-badge-inline svg {
  width: 12px;
  height: 12px;
}

/* Coordinate Grid Empty Editable Slots */
.aac-btn.empty-cell-editable {
  border: 2px dashed rgba(255, 255, 255, 0.15) !important;
  background: rgba(255, 255, 255, 0.01) !important;
  box-shadow: none !important;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.aac-btn.empty-cell-editable:hover {
  border-color: var(--primary) !important;
  background: rgba(99, 102, 241, 0.05) !important;
}

.aac-btn.empty-cell-editable.drag-over {
  border-color: var(--primary) !important;
  background: rgba(99, 102, 241, 0.1) !important;
  transform: scale(1.02);
}

