:root {
  /* Modern Design System - Vibrant & Hopeful */
  --bg-primary: #fcfdfe;
  --bg-secondary: #f0f4f8;
  --text-primary: #1a1f36;
  --text-secondary: #4f566b;
  --text-muted: #8792a2;
  
  --primary: #6366f1; /* Indigo */
  --primary-glow: rgba(99, 102, 241, 0.2);
  --secondary: #ec4899; /* Pink */
  --accent: #f59e0b; /* Amber */
  --success: #10b981; /* Emerald */
  --danger: #ef4444; /* Rose */
  --info: #3b82f6; /* Blue */

  /* Glassmorphism & Borders */
  --glass: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(255, 255, 255, 0.4);
  --border: #e6ebf1;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow: 0 10px 15px -3px rgba(0,0,0,0.06), 0 4px 6px -2px rgba(0,0,0,0.03);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.08), 0 10px 10px -5px rgba(0,0,0,0.03);
  --shadow-xl: 0 30px 60px -12px rgba(50,50,93,0.15), 0 18px 36px -18px rgba(0,0,0,0.1);

  /* Spacing & Radius */
  --radius-sm: 0.5rem;
  --radius: 1rem;
  --radius-lg: 1.5rem;
  --radius-xl: 2.5rem;
  --gap: 1.5rem;
  
  /* Typography */
  --font-display: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  
  /* Motion */
  --ease: cubic-bezier(0.34, 1.56, 0.64, 1); /* Bouncy spring */
  --transition: 0.3s var(--ease);
}

/* Base Reset & Core Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

/* Ensure [hidden] attribute actually hides elements */
[hidden] {
  display: none !important;
}

/* Force cursor visible above everything */
#cursor, #cursorTrail {
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
  pointer-events: none !important;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  background-attachment: fixed;
}

/* Custom Cursor */
.cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 10px;
  height: 10px;
  background: var(--primary);
  border-radius: 50%;
  pointer-events: none;
  z-index: 999999;
  mix-blend-mode: multiply;
  transition: transform 0.1s ease;
  will-change: transform;
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
}

.cursor-trail {
  position: fixed;
  top: 0;
  left: 0;
  width: 32px;
  height: 32px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  pointer-events: none;
  z-index: 999998;
  transition: transform 0.15s var(--ease), width 0.3s var(--ease), height 0.3s var(--ease), opacity 0.3s ease;
  will-change: transform;
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
}

.cursor--hover { transform: scale(1.5); background: var(--secondary); }
.cursor-trail--hover { width: 50px; height: 50px; border-color: var(--secondary); border-width: 3px; }

/* Site Header */
.sitehead {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

.sitehead__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gap);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand__mark {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
  transition: transform 0.4s var(--ease);
}

.brand:hover .brand__mark { transform: rotate(-10deg) scale(1.1); }

.brand__name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Navigation */
.nav { display: flex; gap: 0.5rem; }

.nav__link {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 700;
  padding: 0.625rem 1.25rem;
  border-radius: 999px;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  transition: all 0.3s var(--ease);
}

.nav__link:hover { color: var(--primary); background: rgba(99, 102, 241, 0.08); transform: translateY(-2px); }
.nav__link[aria-current="page"] { color: var(--primary); background: rgba(99, 102, 241, 0.12); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.75rem;
  font-family: var(--font-display);
  font-weight: 700;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: all 0.3s var(--ease);
  font-size: 1rem;
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover, #4f46e5));
  color: white;
  box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

.btn--primary:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 15px 30px -8px rgba(99, 102, 241, 0.5); }

.btn--ghost {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 2px solid var(--border);
}

.btn--ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--bg-primary); transform: translateY(-4px); }

/* App Container & Sections */
.app { max-width: 1200px; margin: 0 auto; padding: 4rem var(--gap); }

.page { display: grid; gap: 4rem; }

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 4rem;
  align-items: center;
}

.hero__title {
  font-family: var(--font-display);
  font-size: 5rem;
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -0.06em;
  margin-bottom: 2rem;
  color: var(--text-primary);
}

.hero__lead {
  font-size: 1.25rem;
  color: var(--text-secondary);
  max-width: 32rem;
  margin-bottom: 3rem;
}

.hero__actions { display: flex; gap: 1rem; }

/* Cards & Panels */
.card {
  background: var(--bg-primary);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: all 0.4s var(--ease);
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-12px) rotate(1deg);
  box-shadow: var(--shadow-xl);
  border-color: var(--primary);
}

/* Modals */
dialog {
  padding: 0;
  border: none;
  background: transparent;
  outline: none;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: auto;
  z-index: 11000;
  cursor: auto !important;
}

dialog * {
  cursor: auto !important;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  z-index: 10999;
}

dialog > * {
  pointer-events: auto;
}

dialog form {
  pointer-events: auto;
}

dialog button {
  pointer-events: auto !important;
}

/* Specific dialog styles */
#tosDialog {
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  pointer-events: auto;
}

#rulesDialog {
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  pointer-events: auto;
}

#helpDialog {
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  pointer-events: auto;
}

#onboardingDialog {
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  pointer-events: auto;
}

button, input, form, a {
  pointer-events: auto !important;
}


.glass {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  pointer-events: auto;
}

/* Mood Tracker */
.mood {
  background: var(--bg-primary);
  padding: 4rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.mood__options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1.5rem;
  margin-top: 3rem;
}

.mood__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 2.5rem 1rem;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  transition: all 0.4s var(--ease);
}

.mood__btn:hover {
  transform: translateY(-15px) scale(1.05);
  background: var(--bg-primary);
  box-shadow: var(--shadow-xl);
  border-color: var(--primary);
}

.mood__icon svg { width: 56px; height: 56px; transition: transform 0.4s var(--ease); }
.mood__btn:hover .mood__icon svg { transform: scale(1.25) rotate(5deg); }

.mood__label { font-family: var(--font-display); font-weight: 800; font-size: 1.125rem; }

.mood__history { margin-top: 4rem; padding-top: 3rem; border-top: 1px solid var(--border); }

.mood__list { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

.mood__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s var(--ease);
}

.mood__item:hover { transform: scale(1.1); box-shadow: var(--shadow); }
.mood__item .emoji svg { width: 24px; height: 24px; }

/* Interactive Draggable Elements */
.is-dragging {
  opacity: 0.6;
  transform: scale(0.95);
  z-index: 2000;
}

/* Floating Animations */
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-20px) rotate(2deg); }
}

.float { animation: float 6s ease-in-out infinite; }

/* Reveal Animation */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 1s var(--ease), transform 1s var(--ease);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Forms & Inputs */
.input {
  width: 100%;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-secondary);
  font-family: var(--font-body);
  font-size: 1.125rem;
  transition: all 0.3s var(--ease);
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-primary);
  box-shadow: 0 0 0 6px var(--primary-glow);
  transform: scale(1.01);
}

/* Chat & Vent Lists */
.list { list-style: none; display: grid; gap: 1.5rem; }

.chat {
  height: 500px;
  overflow-y: auto;
  padding: 2rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat__msg {
  padding: 1.25rem;
  border-radius: var(--radius);
  background: var(--bg-primary);
  box-shadow: var(--shadow-sm);
  max-width: 80%;
  align-self: flex-start;
  transition: all 0.3s var(--ease);
}

.chat__msg:hover { transform: scale(1.02); box-shadow: var(--shadow); }

/* Responsive Grid */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2.5rem;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .hero { grid-template-columns: 1fr; text-align: center; }
  .hero__title { font-size: 3.5rem; }
  .hero__actions { justify-content: center; }
  
  .sitehead__inner { position: relative; }
  
  #navToggle { display: flex !important; }
  
  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-primary);
  
  .nav__link { width: 100%; text-align: left; padding: 1rem; }
  
  #mobileHelpBtn { display: flex !important; width: 100%; }
  
  .sitehead__tools { display: none; } /* Hide tools on very small screens or move to nav */
  
  .cursor, .cursor-trail { display: none; }
  body { cursor: default; }
}

/* Chips & Tags */
.chip-sm {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.75rem;
}

/* Chat fullscreen button */
.chat-fullscreen {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 1.25rem;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}
.chat-fullscreen:hover { opacity: 1; }

.chat-fullscreen.active {
  opacity: 1;
  transform: rotate(45deg);
}

/* Fullscreen chat styling */
#pageChat.chat-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  z-index: 2000;
  padding: 4rem var(--gap);
  overflow: auto;
}

/* Light/dark theme overrides - HIGHEST SPECIFICITY */
:root[data-theme="dark"] {
  --bg-primary: #1a1a2e !important;
  --bg-secondary: #16213e !important;
  --text-primary: #eaeaea !important;
  --text-secondary: #c5c6c7 !important;
  --text-muted: #888888 !important;
  --border: #333 !important;
  --glass: rgba(20,20,40,0.75) !important;
  --glass-border: rgba(255,255,255,0.1) !important;
}

.chip {
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 700;
  transition: all 0.3s var(--ease);
  box-shadow: var(--shadow-sm);
  cursor: none !important;
}

.chip:hover {
  transform: translateY(-3px) scale(1.05);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow);
}

.chip.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
}

/* Checkbox Modernization */
.check-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-secondary);
  transition: all 0.3s var(--ease);
}

.check-container:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  background: var(--bg-primary);
}

.check-container input {
  appearance: none;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg-primary);
  position: relative;
  transition: all 0.2s ease;
}

.check-container input:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.check-container input:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-weight: 900;
  font-size: 1rem;
}
.reveal-text { overflow: hidden; }
.reveal-text span { display: block; animation: revealText 0.8s var(--ease) forwards; }

@keyframes revealText {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
