:root {
  /* Base */
  --bg: #F0F2F5;
  --surface: #FFFFFF;
  --surface-elevated: #FFFFFF;
  --text: #0F172A;
  --text-secondary: #475569;
  --text-tertiary: #94A3B8;
  
  /* Brand — más profundo y versátil */
  --primary: #4A727C;
  --primary-light: #5B8C96;
  --primary-muted: rgba(91, 140, 150, 0.08);
  
  /* Semantic colors refinados */
  --danger: #E07A5F;
  --danger-soft: rgba(224, 122, 95, 0.08);
  --success: #10B981;
  --success-soft: rgba(16, 185, 129, 0.08);
  --highlight: #F2CC8F;
  
  /* Elevation moderna (más capas) */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 0 20px -5px var(--primary-light);
  
  /* Glassmorphism premium */
  --glass: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-highlight: inset 0 1px 1px rgba(255, 255, 255, 0.6);
  
  /* Espaciado escalar */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  
  /* Radii */
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;
  
  /* Tipografía */
  --font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  
  /* Transiciones */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.dark-theme {
  --bg: #0F172A;
  --surface: #1E293B;
  --surface-elevated: #334155;
  --text: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-tertiary: #64748B;
  
  --primary: #81E6D9;
  --primary-light: #5FD3C4;
  --primary-muted: rgba(129, 230, 217, 0.08);
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.5);
  --shadow-glow: 0 0 25px -5px rgba(129, 230, 217, 0.25);
  
  --glass: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

body.dark-theme .btn.primary {
  color: #1a202c;
}
body.dark-theme .status-pill,
body.dark-theme .rank-num {
  color: #f1f5f9;
  background-color: #334155;
}
body.dark-theme .btn.danger {
  color: #ffffff;
}

/* --- Base & Reset --- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-family);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background-color 0.3s, color 0.3s;
  padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  height: -webkit-fill-available;
}

body {
  min-height: -webkit-fill-available;
}

button {
  font-family: inherit;
  font-size: 1rem;
  touch-action: manipulation;
}

/* --- Header --- */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--primary);
}

.brand small {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.top-actions {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.icon-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* --- Tabs --- */
.tabs {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin: var(--space-4) auto;
  padding: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow);
  width: fit-content;
  max-width: 95vw;
  overflow-x: auto;
  position: sticky;
  top: 64px;
  z-index: 40;
  backdrop-filter: blur(12px);
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 10px 20px;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

body.dark-theme .tab-btn.active {
  color: var(--bg);
}

.tab-btn:not(.active):hover {
  background: var(--primary-muted);
  color: var(--primary);
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 20px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
  transition: transform var(--transition-base);
}

.tab-btn.active::after {
  transform: translateX(-50%) scaleX(1);
}

.tab-btn:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* --- Main Layout --- */
main {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) 6rem;
  position: relative;
  z-index: 5;
}

.view {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* --- Common UI --- */
.card-panel {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  transition: box-shadow var(--transition-base);
}

.card-panel:hover {
  box-shadow: var(--shadow-md);
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::after {
  opacity: 1;
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn.primary:hover {
  background: var(--primary-hover, #3d5f66);
  box-shadow: var(--shadow-md), var(--shadow-glow);
  transform: translateY(-1px);
}

body.dark-theme .btn.primary {
  color: var(--bg);
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.danger:hover {
  background: #c96a52;
  box-shadow: 0 4px 12px rgba(224, 122, 95, 0.25);
}

.btn.secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--glass-border);
}

.btn.secondary:hover {
  background: var(--bg);
  border-color: var(--text-tertiary);
  color: var(--text);
}

.btn.ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn.ghost:hover {
  background: var(--primary-muted);
  color: var(--primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.mini-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: var(--muted);
  cursor: pointer;
}

/* --- Validation / Toast --- */
#toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px) scale(0.9);
  background: var(--surface-elevated);
  color: var(--text);
  padding: 14px 28px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: var(--text-sm);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--glass-border);
  z-index: 9999;
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

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

/* --- Ranking List --- */
#active-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}


/* --- Cards Grid (Spotlight) --- */
.values-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--space-3);
}

.card-container {
  position: relative;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-container::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(135deg, rgba(255,255,255,0.4), transparent 40%, transparent 60%, rgba(255,255,255,0.1));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.card-container:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary-light);
}

.card-container:hover::before {
  opacity: 1;
}

/* --- Ranking List Reordering Feedback --- */
.rank-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.rank-item:hover {
  border-color: rgba(91, 140, 150, 0.2);
  box-shadow: var(--shadow);
}

.rank-num {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--primary-muted);
  color: var(--primary);
  font-weight: 800;
  font-size: var(--text-xs);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.rank-name {
  flex: 1;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text);
}

/* Drag state más sutil */
.rank-item.dragging {
  opacity: 0.9;
  box-shadow: var(--shadow-lg);
  transform: scale(1.02) rotate(1deg);
  z-index: 100;
  background: var(--surface-elevated);
  border-color: var(--primary);
}

.rank-item.drop-target {
  border: 2px dashed var(--primary);
  background: var(--primary-muted);
}

.rank-arrows {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.arrow-btn {
  background: transparent;
  border: none;
  font-size: 0.65rem;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.arrow-btn:hover {
  background: var(--ring);
  color: var(--text);
}

.arrow-placeholder {
  display: inline-block;
  width: 1em;
}

.card {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

.card-content {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  background: transparent;
  border: none;
  height: 100%;
  flex-grow: 1;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.3;
}

.card-def {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0 0 6px 0;
  flex-grow: 1;
}

/* Estado seleccionado más elegante */
.card.selected {
  position: relative;
}

.card.selected .card-content {
  background: var(--primary-muted);
}

.card.selected::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  z-index: 15;
}

body.dark-theme .card.selected::after {
  color: var(--bg);
}

.card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
  z-index: 10;
}

/* Custom value details styling */
.custom-val-details {
  margin-top: 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--glass-border);
  background: var(--bg);
  padding: 8px 12px;
}

.custom-val-details[open] {
  padding: 12px;
}

.custom-value-summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--primary);
  outline: none;
  user-select: none;
}

.custom-value-summary:hover {
  color: var(--primary-light);
}

/* --- Forms (Sendero & Inputs) --- */
.inline-form {
  background: var(--bg);
  padding: 12px;
  border-radius: 12px;
  margin-top: 16px;
}

.field {
  margin-bottom: 8px;
}

input, textarea, select {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-base);
  transition: all var(--transition-fast);
  outline: none;
}

input:hover, textarea:hover, select:hover {
  border-color: var(--text-tertiary);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-muted);
  background: var(--surface);
}

/* Select custom arrow */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

/* Smart cards más premium */
.smart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
}

.smart-card {
  position: relative;
  padding: var(--space-4);
  background: var(--surface);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.smart-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.smart-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
}

.smart-card:has(input:checked) {
  background: var(--primary-muted);
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.smart-label {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text);
}

.smart-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.4;
}

/* --- Bullseye Visual Polish --- */
.bullseye-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bullseye-visual {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: min(92vw, 360px);
  aspect-ratio: 1;
  margin: var(--space-6) auto;
  position: relative;
  border-radius: 50%;
  background: 
    radial-gradient(circle at 30% 30%, rgba(91, 140, 150, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(242, 204, 143, 0.08) 0%, transparent 50%),
    var(--bg);
  border: 1px solid var(--glass-border);
  box-shadow: 
    inset 0 0 60px rgba(91, 140, 150, 0.05),
    0 20px 40px -10px rgba(0, 0, 0, 0.15);
  overflow: visible;
}

.bullseye-label {
  position: absolute;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  background: var(--surface);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
  transition: all var(--transition-base);
  z-index: 10;
  display: flex;
  align-items: center;
}

.bullseye-label-top { 
  top: -15px; 
  left: 50%; 
  transform: translateX(-50%); 
  color: #0ea5e9; 
  border-color: rgba(14, 165, 233, 0.2); 
}
.bullseye-label-top:hover {
  transform: translateX(-50%) scale(1.05);
}

.bullseye-label-right { 
  right: -25px; 
  top: 50%; 
  transform: translateY(-50%); 
  color: #f43f5e; 
  border-color: rgba(244, 63, 94, 0.2); 
}
.bullseye-label-right:hover {
  transform: translateY(-50%) scale(1.05);
}

.bullseye-label-bottom { 
  bottom: -15px; 
  left: 50%; 
  transform: translateX(-50%); 
  color: #10b981; 
  border-color: rgba(16, 185, 129, 0.2); 
}
.bullseye-label-bottom:hover {
  transform: translateX(-50%) scale(1.05);
}

.bullseye-label-left { 
  left: -25px; 
  top: 50%; 
  transform: translateY(-50%); 
  color: #f59e0b; 
  border-color: rgba(245, 158, 11, 0.2); 
}
.bullseye-label-left:hover {
  transform: translateY(-50%) scale(1.05);
}

.bullseye-icon {
  width: 20px;
  height: 20px;
  margin-right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bullseye-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.bullseye-label span {
  font-size: 0.75rem;
  font-weight: 700;
}

.bullseye-center-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  background: var(--danger);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  box-shadow: 0 0 10px var(--danger);
  animation: center-pulse 2s infinite ease-in-out;
  pointer-events: none;
}

@keyframes center-pulse {

  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.8;
  }

  50% {
    transform: translate(-50%, -50%) scale(1.4);
    opacity: 1;
  }
}

.bullseye-success {
  animation: success-radial-pulse 0.8s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes success-radial-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(129, 230, 217, 0.4), 0 0 0 0px var(--card);
  }

  100% {
    box-shadow: 0 0 0 40px rgba(129, 230, 217, 0), 0 0 0 10px var(--card);
  }
}

.bullseye-visual canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Marker and axis logic cleaned to prevent layout shifts */
/* Fix for transform lint at line 2173 and others */
.marker {
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}

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

.slider-row label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.slider-row input[type="range"] {
  flex: 1;
  margin-left: 12px;
  min-width: 100px;
  accent-color: var(--primary);
}

/* --- Footer --- */
.app-footer {
  text-align: center;
  padding: 20px 20px 80px 20px;
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.8;
  margin-top: 40px;
  position: relative;
  z-index: 10;
}

.app-footer p {
  margin: 4px 0;
}

/* --- Galaxy Canvas --- */
#galaxy-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  opacity: 0.4;
}

/* --- Dynamic Background Glows --- */
.bg-glow {
  position: fixed;
  width: 60vw;
  height: 60vw;
  border-radius: 50%;
  filter: blur(80px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.15;
  animation: floatGlow 20s infinite alternate ease-in-out;
}

.glow-1 {
  background: var(--primary);
  top: -10%;
  right: -10%;
}

.glow-2 {
  background: var(--highlight);
  bottom: -10%;
  left: -10%;
  animation-delay: -5s;
}

@keyframes floatGlow {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(10%, 10%) scale(1.1);
  }
}

/* --- Storybook Brújula (Moomin Style) --- */
.compass-wood {
  fill: #D4A373;
  stroke: #8B5E34;
  stroke-width: 3;
}



.scarf-red {
  fill: #E07A5F;
}

.scarf-white {
  fill: #F4F1DE;
}



.character-limb {
  stroke: #5D4037;
  stroke-width: 4;
  stroke-linecap: round;
  fill: none;
}

.character-boot {
  fill: #8B5E34;
}

@keyframes walkCycle {

  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }

  50% {
    transform: translateY(-3px) rotate(1deg);
  }
}

.walking .avatar-container {
  animation: walkCycle 3s infinite ease-in-out;
}







body.dark-theme #galaxy-canvas {
  opacity: 0.8;
}

/* --- Intro Modal & Carousel --- */
.carousel-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}

.carousel-modal[style*="display: flex"] {
  opacity: 1;
  pointer-events: auto;
}

.carousel-modal.active {
  display: flex;
  /* Show when active */
  opacity: 1;
  pointer-events: all;
}

.carousel-wrap {
  width: 90%;
  max-width: 400px;
  max-height: 90vh;
  /* Handle small screens */
  overflow-y: auto;
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow2);
  transform: scale(0.95);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.carousel-modal.active .carousel-wrap {
  transform: scale(1);
}

.intro-slide {
  flex: 0 0 100%;
  padding: 20px;
  text-align: center;
}

.intro-slide h2 {
  color: var(--primary);
  margin-bottom: 1rem;
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ring);
  cursor: pointer;
  transition: background 0.3s;
}

.dot.active {
  background: var(--primary);
}

.carousel-track {
  display: flex;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}





/* --- Delete Modal --- */
.delete-modal-content {
  text-align: center;
  max-width: 320px;
}

.delete-timer {
  font-size: 2rem;
  font-weight: 800;
  margin: 16px 0;
  color: var(--danger);
}

/* --- Suggest Button --- */
.btn-suggest {
  background: linear-gradient(135deg, var(--primary) 0%, #a78bfa 100%);
  color: #fff;
  border: none;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(125, 211, 252, 0.4);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(125, 211, 252, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(125, 211, 252, 0);
  }
}

/* --- Avatar (Brújula) --- */
.avatar-float {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2500;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  /* let clicks pass through mainly */
}

.avatar-float>* {
  pointer-events: auto;
}

/* La burbuja es solo informativa (sin controles dentro): nunca debe robar
   clics a los botones que queden debajo mientras está visible. */
.avatar-bubble {
  pointer-events: none;
}

.avatar-container {
  width: 140px;
  height: 140px;
  position: relative;
  /* El avatar flota solo */
  animation: floaty 3.2s ease-in-out infinite;
  will-change: transform;
}

@keyframes floaty {

  0%,
  100% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-6px);
  }
}

.avatar-bubble {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--ring);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow2);
  max-width: 220px;
  font-size: 0.85rem;
  position: relative;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  transition: opacity 0.3s, transform 0.3s;
}

.avatar-bubble.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Triangle */
.avatar-bubble::after {
  content: "";
  position: absolute;
  bottom: -6px;
  right: 40px;
  width: 12px;
  height: 12px;
  background: var(--card);
  border-right: 1px solid var(--ring);
  border-bottom: 1px solid var(--ring);
  transform: rotate(45deg);
}

/* Internal Avatar SVG Styles */
.blink .eyeLid {
  animation: blink 4.6s infinite;
}

@keyframes blink {

  0%,
  6%,
  100% {
    transform: scaleY(0);
    opacity: 0;
  }

  2% {
    transform: scaleY(1);
    opacity: 1;
  }

  4% {
    transform: scaleY(1);
    opacity: 1;
  }

  6% {
    transform: scaleY(0);
    opacity: 0;
  }
}

.pupil {
  transition: transform .08s linear;
}

.mouth {
  opacity: 0;
  transition: opacity .2s;
}

.brow {
  opacity: 0;
  transition: opacity .2s;
}

.cheek {
  opacity: 0;
  transition: opacity .2s;
}

/* States */
.state-neutral .mouth.neutral,
.state-neutral .brow.neutral {
  opacity: 1;
}

.state-happy .mouth.happy,
.state-happy .brow.happy,
.state-happy .cheek {
  opacity: 1;
}

.state-worried .mouth.worried,
.state-worried .brow.worried,
.state-worried .cheek {
  opacity: .35;
}

.state-tired .mouth.tired,
.state-tired .brow.tired {
  opacity: 1;
}

.state-surprised .mouth.surprised,
.state-surprised .brow.surprised,
.state-surprised .cheek {
  opacity: .25;
}

.talking .needle {
  animation: wiggle .28s ease-in-out infinite alternate;
  transform-origin: 50% 56%;
}

@keyframes wiggle {
  from {
    transform: rotate(-2deg);
  }

  to {
    transform: rotate(2.4deg);
  }
}

/* --- Sendero Layout --- */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-group label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.form-row.two>* {
  flex: 1;
}

.callout {
  background: var(--bg);
  padding: 16px;
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
}

.section-divider {
  height: 1px;
  background: var(--ring);
  opacity: 0.2;
  margin: 16px 0;
}

/* --- Sendero Premium Polish --- */
.status-pill {
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--ring);
  color: #1e293b;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.status-pill.done {
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(129, 230, 217, 0.4);
}

.score-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--ring);
  color: var(--text);
  font-weight: 700;
  font-size: 0.8rem;
}

.willingness-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--ring);
  border-radius: 10px;
  background: var(--ring-soft, rgba(148, 163, 184, 0.12));
  margin: 10px 0;
}

.willingness-check input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.willingness-check label {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text);
}

.slider-word {
  font-weight: 700;
  color: var(--primary);
}

.slider-anchors {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin: -4px 0 10px;
}

.next-step-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--ring);
  border: 1px solid var(--primary);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.next-step-banner p {
  margin: 2px 0 0;
  font-weight: 600;
}

.action-item.mastered {
  opacity: 0.7;
}

.mastered-tag {
  color: var(--success, #10B981);
  font-weight: 700;
}

.exposure-timer-display {
  font-size: 2.4rem;
  font-weight: 700;
  text-align: center;
  color: var(--primary);
  margin: 8px 0;
  font-variant-numeric: tabular-nums;
}

.metaphor-text {
  font-style: italic;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--ring);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Utilities */
.card-title {
  font-weight: 800;
  color: var(--primary);
  line-height: 1.25;
}

.star {
  font-size: 1.8rem;
  margin: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Eye Pupil Animation */
#pupilL,
#pupilR,
#shineL,
#shineR {
  transform: translate(var(--px, 0), var(--py, 0));
  transition: transform 0.1s ease-out;
}



/* Animations active list */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* Focus Polish */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* --- SOS Module Styles (Steam Out) --- */
.hero-sos {
  border: 1px solid var(--danger);
  background: linear-gradient(135deg, var(--surface) 0%, var(--danger-soft) 100%);
  position: relative;
  overflow: hidden;
}

.hero-sos::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(224, 122, 95, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.badge-danger {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
}

.breath-container {
  margin: 20px auto;
  width: 160px;
  height: 160px;
  border: 1px solid var(--ring);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--bg);
  overflow: hidden;
}





.timer {
  font-variant-numeric: tabular-nums;
}

/* Overlay / Modal */
.sos-overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  z-index: 5000;
  display: none;
  /* Default hidden */
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.sos-overlay-backdrop:not([hidden]) {
  display: flex;
}

.sos-modal {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow2);
  border: 1px solid var(--ring);
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.sos-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.sos-modal-header h3 {
  margin: 0;
  color: var(--primary);
}

.sos-step-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.sos-placeholder-icon {
  font-size: 4rem;
  margin: 20px 0;
}

.sos-countdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--ring);
  background: var(--bg);
  margin: 12px 0 20px;
}

.sos-countdown-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.sos-countdown-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.tip-panel .panel-title {
  align-items: center;
}

.tip-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.tip-card {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  transition: all var(--transition-base);
}

.tip-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(91, 140, 150, 0.2);
}

.tip-card-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.tip-icon {
  font-size: 2rem;
  line-height: 1;
}

.tip-card h4 {
  margin: 0;
  font-size: var(--text-base);
  color: var(--text);
}

.tip-card .hint {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* --- New SOS Enhanced Styles --- */
.sos-main-actions {
  display: grid;
  gap: var(--space-3);
  margin-top: 16px;
}

.sos-action-large {
  width: 100%;
  padding: var(--space-4);
  font-size: var(--text-base);
  font-weight: 600;
  border-radius: var(--radius);
  text-align: left;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border: 1px solid var(--glass-border);
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.sos-action-large::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.sos-action-large:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-md);
}

.sos-action-large:hover::before {
  opacity: 1;
}

.sos-action-large.danger {
  background: var(--danger-soft);
  border-color: rgba(224, 122, 95, 0.2);
}

.sos-action-large.danger::before {
  background: var(--danger);
}

/* Box Breathing Square */
.breath-box-container {
  width: 100%;
  height: 240px;
  display: grid;
  place-items: center;
  position: relative;
  background: radial-gradient(circle at center, var(--primary-muted) 0%, transparent 70%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  margin-top: var(--space-4);
  overflow: hidden;
}

.breath-square {
  grid-area: 1 / 1;
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius);
  box-shadow: 0 0 40px rgba(91, 140, 150, 0.3);
  transition: transform 4s linear, opacity 0.5s;
  margin: auto;
  z-index: 2;
}

.breath-progress-circle {
  grid-area: 1 / 1;
  width: 180px;
  height: 180px;
  border: 2px dashed var(--ring);
  border-radius: 50%;
  opacity: 0.3;
  z-index: 1;
  margin: auto;
}

.breath-square.expanding {
  transform: scale(1.8);
}

.breath-square.contracting {
  transform: scale(1);
}

.breath-square.holding {
  animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {

  0%,
  100% {
    box-shadow: 0 0 20px var(--primary);
    filter: brightness(1);
  }

  50% {
    box-shadow: 0 0 50px var(--primary);
    filter: brightness(1.2);
  }
}

/* Sensory 5-4-3-2-1 */
.sensory-action-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.sensory-item {
  aspect-ratio: 1;
  background: var(--bg);
  border: 2px solid var(--ring);
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.sensory-item.checked {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  transform: scale(0.9);
}

/* Categories Bubbles */
/* Merged .bullseye-visual duplicate */

.bullseye-visual canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  display: block;
  margin: 0 auto;
}

.bubbles-container {
  position: relative;
  width: 100%;
  height: 250px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-top: 15px;
  overflow: hidden;
  touch-action: none;
}

.bubble {
  position: absolute;
  padding: 8px 16px;
  background: var(--card);
  border: 1px solid var(--ring);
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow);
  transition: transform 0.1s, opacity 0.2s;
}

.bubble.correct {
  border-color: var(--primary);
  color: var(--primary);
}

.bubble.burst {
  transform: scale(2);
  opacity: 0;
  pointer-events: none;
}

/* Heel Grounding Metronome */
.metronome-visual {
  height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.metronome-beat {
  width: 100%;
  height: 8px;
  background: var(--ring);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.metronome-beat::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 50%;
  background: var(--danger);
  transform: translateX(-100%);
  transition: transform 0.5s ease-in-out;
}

.metronome-beat.beat-left::after {
  transform: translateX(0);
}

.metronome-beat.beat-right::after {
  transform: translateX(100%);
}

.metronome-text {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--danger);
}

/* Haptic Pulse Animation */
.haptic-pulse {
  animation: haptic-pulse-key 0.2s ease-out;
}

@keyframes haptic-pulse-key {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}



.slider-row {
  gap: 8px;
}

.slider-row label {
  flex: 1 1 100%;
}

.slider-row input[type="range"] {
  margin-left: 0;
  width: 100%;
}

@media (max-width: 768px) {
  header {
    padding: 0.8rem 1rem;
    align-items: flex-start;
    gap: 8px;
  }

  .brand h1 {
    font-size: 1.08rem;
  }

  .top-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .tabs {
    position: sticky;
    top: 0;
    background: rgba(240, 242, 245, 0.92);
    backdrop-filter: blur(8px);
    z-index: 40;
    padding: 8px 10px;
    margin: 8px 0 12px;
    overflow-x: auto;
    justify-content: flex-start;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    white-space: nowrap;
    border: 1px solid var(--ring);
    border-radius: 999px;
    border-bottom-width: 1px;
    background: var(--card);
  }

  .tab-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
  }

  .values-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .card-container {
    min-height: auto;
    height: auto;
  }

  .row-actions {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
  }

  .row-actions .btn,
  .btn {
    min-height: 44px;
  }
}

@media (max-width: 360px) {
  .values-grid {
    grid-template-columns: 1fr;
  }
}

@media (hover: none),
(pointer: coarse) {
  .card-container {
    transform: none !important;
  }

  .card-container:hover {
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.14);
  }

  .card-container:hover .card-face::after,
  .card-container:hover .card-tooltip {
    opacity: 0;
  }

  .marker:hover {
    transform: translate(-50%, -50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 768px) {
  body.dark-theme .tabs {
    background: rgba(26, 32, 44, 0.92);
  }
}

/* --- Fixes: valores cards contrast + diana simplificada --- */




/* Bullet-proof centering applied in main block */

/* --- Overflow + alignment hardening --- */
.rank-item {
  min-width: 0;
}

.rank-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  background: var(--ring);
  color: #1e293b;
  font-weight: 700;
  font-size: 0.78rem;
}

.rank-name {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hint {
  overflow-wrap: anywhere;
}



.card-actions .btn {
  max-width: 100%;
}

.inline-actions {
  flex-wrap: wrap;
}

.smart-grid,
.tip-grid {
  align-items: stretch;
}

@media (max-width: 768px) {
  header {
    flex-wrap: wrap;
  }

  .brand,
  .top-actions {
    width: 100%;
  }

  .top-actions {
    justify-content: flex-end;
  }

}
/* Footer & legal disclaimers styles */
.app-footer {
  padding: 24px 16px;
  text-align: center;
}
.footer-privacy-box {
  background: var(--card);
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--ring);
  max-width: 450px;
  margin: 0 auto 16px auto;
}
.footer-privacy-text {
  font-size: 0.85rem;
  margin: 0;
  line-height: 1.4;
  color: var(--muted);
}
.footer-actions-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 16px;
  margin-bottom: 24px;
}
.footer-disclaimers {
  margin-top: 20px;
  padding: 16px;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--ring);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
  text-align: left;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}
.footer-disclaimers p {
  margin-bottom: 12px;
}
.footer-coffee-wrapper {
  text-align: center;
  margin: 16px 0;
}
.coffee-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  padding: 10px 20px;
}
.footer-hr {
  border: 0;
  border-top: 1px solid var(--ring);
  margin: 16px 0;
}
.footer-disclaimers .medical-warning {
  font-size: 0.75rem;
  opacity: 0.8;
  margin-top: 8px;
}

/* Minimizable Avatar Toggle Button */
.avatar-toggle-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--card);
  border: 1px solid var(--ring);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
  color: var(--text);
  padding: 0;
}
.avatar-toggle-btn:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.avatar-float.minimized {
  width: 50px !important;
  height: 50px !important;
  overflow: visible;
  cursor: pointer;
  bottom: 20px;
  right: 20px;
}
.avatar-float.minimized .avatar-bubble,
.avatar-float.minimized .avatar-container {
  display: none !important;
}
.avatar-float.minimized::before {
  content: "🧭";
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  background: var(--card);
  border: 2px solid var(--primary);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.avatar-float.minimized .avatar-toggle-btn {
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  font-size: 0.65rem;
}

/* --- Quality & Layout Fixes --- */

.list-clean {
  list-style: none;
  padding: 0;
  margin: 0;
}

.action-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--ring);
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  min-width: 0;
}



.action-item.done {
  opacity: 0.75;
  border-color: var(--primary);
  background: var(--card);
}

.action-item.done strong {
  text-decoration: line-through;
  color: var(--muted);
}

#commitmentSummary {
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  overflow: visible;
  line-height: 1.5;
  font-size: 0.9rem;
}

.text-wrap {
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

/* Prevent flex child sizing issue on small screens */
.rank-item,
.action-item,
.smart-card {
  min-width: 0;
}

/* Responsive card heights and wrap */
.card-container {
  min-height: auto !important;
  height: auto !important;
}

.card-title,
.card-def {
  word-break: break-word !important;
  overflow-wrap: break-word !important;
}

/* --- SW Update Banner --- */
.sw-update-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 2px solid var(--primary);
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: 90vw;
  text-align: center;
}

/* --- Offline Indicator --- */
#offline-indicator {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transition: opacity 0.3s, transform 0.3s;
}

/* --- Onboarding Modal --- */
#onboardingModal .carousel-wrap {
  max-width: 500px;
  background: var(--card);
  border: 1px solid var(--ring);
  border-radius: 18px;
  padding: 24px;
}
#onboardingModal .intro-slide {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
#onboardingModal .intro-slide h2 {
  color: var(--primary);
  margin: 12px 0;
}
#onboardingModal .intro-slide p {
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--muted);
}



/* --- Cabecera / Menú Desplegable Responsivo (Opción 1) --- */
.menu-container {
  position: relative;
  display: inline-block;
}

.toggle-menu-btn {
  font-size: 1.5rem;
  line-height: 1;
  padding: 4px 12px;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--primary);
  font-weight: bold;
}

.secondary-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--card);
  border: 1px solid var(--ring);
  border-radius: 16px;
  box-shadow: var(--shadow2);
  z-index: 1000;
  min-width: 210px;
  flex-direction: column;
  padding: 8px;
  gap: 4px;
}

.secondary-menu.active {
  display: flex;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.menu-item:hover,
.menu-item:focus {
  background: var(--bg);
  color: var(--primary);
}

/* El menú se expande horizontalmente en línea solo cuando el ancho real
   alcanza para los ~9 botones sin recortarlos ni ocultar el scroll (medido
   empíricamente: por debajo de esto, incluso portátiles comunes de 1366-1440px
   necesitaban un scroll horizontal invisible dentro del header). Por debajo
   de este umbral se mantiene el menú "⋯" desplegable, ya probado en todos
   los anchos de móvil/tablet. */
@media (min-width: 1500px) {
  .toggle-menu-btn {
    display: none;
  }

  .menu-container {
    min-width: 0;
    max-width: 100%;
  }

  .secondary-menu {
    display: flex !important;
    position: static;
    flex-direction: row;
    flex-wrap: nowrap;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    min-width: auto;
    max-width: 100%;
    overflow-x: auto;
    gap: 8px;
  }

  .menu-item {
    width: auto;
    padding: 8px 12px;
    background: var(--card);
    border: 1px solid var(--ring);
    border-radius: 12px;
    font-size: 0.85rem;
    box-shadow: var(--shadow);
  }

  .menu-item:hover,
  .menu-item:focus {
    background: var(--bg);
    border-color: var(--primary);
  }
}

/* Estilos para Iconos SVG */
.icon-svg {
  display: inline-block;
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  vertical-align: middle;
  flex-shrink: 0;
  transition: stroke 0.2s, fill 0.2s;
}

#soundBtn .svg-sound-on {
  display: inline-block;
}
#soundBtn .svg-sound-off {
  display: none;
}
#soundBtn.muted .svg-sound-on {
  display: none;
}
#soundBtn.muted .svg-sound-off {
  display: inline-block;
}

#themeBtn .svg-moon {
  display: inline-block;
}
#themeBtn .svg-sun {
  display: none;
}
body.dark-theme #themeBtn .svg-moon {
  display: none;
}
body.dark-theme #themeBtn .svg-sun {
  display: inline-block;
}

.menu-item span {
  vertical-align: middle;
}

/* Clases de Limpieza de Estilos Inline (Fase 3.2) */
.counter-info {
  font-size: 0.9rem;
  color: var(--muted);
}

.label-strong {
  font-weight: 900;
}

.flex-end-row {
  display: flex;
  justify-content: flex-end;
}

.deck-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.deck-search-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--ring);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.deck-filter-select {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--ring);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  cursor: pointer;
}

.deck-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  white-space: nowrap;
  font-weight: 600;
  padding: 10px 14px;
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--ring);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.cursor-pointer {
  cursor: pointer;
}

.diana-sliders-container {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.chart-container-line {
  position: relative;
  width: 100%;
  height: 250px;
  margin-top: 12px;
}

.font-85 {
  font-size: 0.85rem;
}

.justify-end {
  justify-content: flex-end;
}

.sos-main-actions {
  display: grid;
  gap: 12px;
}

.sos-action-large {
  width: 100%;
  padding: 16px;
  font-size: 1rem;
}

.sos-grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.sos-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.timer-monospace {
  font-family: monospace;
  font-weight: 700;
  color: var(--primary);
}

.vol-slider-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.vol-span {
  margin: 0;
  white-space: nowrap;
  min-width: fit-content;
}

.noise-input {
  margin: 0;
}

.cognitive-buttons-container {
  display: grid;
  gap: 10px;
}

.btn-title-block {
  display: block;
  font-weight: 700;
}

.btn-desc-block {
  display: block;
  font-size: 0.8rem;
  opacity: 0.8;
}

.primary-underline-link {
  color: var(--primary);
  text-decoration: underline;
}

.justify-center {
  justify-content: center;
}

.gap-8 {
  gap: 8px;
}

.text-left {
  text-align: left;
}

.p-24 {
  padding: 24px;
}

.close-btn-absolute {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
}

.primary-title-modal {
  color: var(--primary);
  font-size: 1.2rem;
  margin-top: 0;
  margin-bottom: 12px;
}

.modal-scroll-body {
  overflow-y: auto;
  max-height: 60vh;
  padding-right: 8px;
}

.mt-0 {
  margin-top: 0;
}

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

.avatar-title {
  display: block;
  margin-bottom: 4px;
}

.full-svg {
  width: 100%;
  height: 100%;
}

.sos-illustration-panel {
  text-align: center;
  margin-bottom: 12px;
}

.mv-20 {
  margin: 20px 0;
}

@media (prefers-reduced-motion: reduce) {
    .card-container {
        transform: none !important;
        transition: none !important;
    }
    .card-container:hover {
        transform: none !important;
    }
    #galaxy-canvas {
        display: none !important;
    }
}

/* --- Dark Mode Refinados --- */
body.dark-theme .card-container {
  background: linear-gradient(135deg, var(--surface) 0%, rgba(30, 41, 59, 0.6) 100%);
}

body.dark-theme .card-container::before {
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent 40%, transparent 60%, rgba(255,255,255,0.03));
}

body.dark-theme .rank-item {
  background: var(--surface);
}

body.dark-theme .breath-square {
  box-shadow: 0 0 40px rgba(129, 230, 217, 0.2);
}

body.dark-theme .tabs {
  background: rgba(15, 23, 42, 0.8);
  border-color: rgba(255, 255, 255, 0.06);
}

/* --- Responsive Premium --- */
@media (max-width: 640px) {
  main {
    padding: var(--space-3) var(--space-3) 6rem;
  }
  
  .card-panel {
    padding: var(--space-4);
    border-radius: var(--radius);
  }
  
  .values-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
  }
  
  .tabs {
    top: 56px;
    border-radius: var(--radius);
    padding: var(--space-1);
  }
  
  .tab-btn {
    padding: 8px 14px;
    font-size: var(--text-xs);
  }
  
  .sos-grid {
    grid-template-columns: 1fr;
  }
  
  .tip-grid {
    grid-template-columns: 1fr;
  }
  
  .avatar-float {
    bottom: 12px;
    right: 12px;
  }

  .avatar-container {
    width: 72px;
    height: 72px;
  }

  .avatar-bubble {
    max-width: 180px;
    font-size: 0.8rem;
    padding: 10px;
  }
}

@media (max-width: 400px) {
  .avatar-container {
    width: 60px;
    height: 60px;
  }
}

/* Con 6 pestañas (incluida la crítica SOS), hay que ajustar el espaciado para
   que todas quepan sin depender de que el usuario descubra el scroll táctil.
   480px cubre también teléfonos grandes como iPhone Pro Max (430px). */
@media (max-width: 480px) {
  .tabs {
    gap: 4px;
  }

  .tab-btn {
    padding: 8px 9px;
    font-size: 0.7rem;
  }

  /* La burbuja de Brújula es pointer-events:none (nunca bloquea clics),
     pero en pantallas angostas su ancho por defecto (180px) todavía tapa
     visualmente botones y campos a ancho completo durante los ~4s que
     está visible. Se reduce su huella para minimizar la superposición. */
  .avatar-container {
    width: 56px;
    height: 56px;
  }

  .avatar-bubble {
    max-width: 140px;
    font-size: 0.75rem;
    padding: 8px;
  }
}

/* --- Hojas en el Agua (Defusión ACT) --- */
.leaves-modal-card {
  max-width: 650px !important;
  width: 95% !important;
  max-height: 90vh !important;
  overflow-y: auto;
}

.guide-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.guide-btn:hover {
  background: var(--primary-muted);
  color: var(--primary);
  border-color: var(--primary);
}

.guide-panel {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  line-height: 1.45;
  box-shadow: var(--shadow-sm);
}

.guide-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 2px;
}

.guide-abort {
  color: var(--danger) !important;
}

.stream-canvas {
  height: 250px;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(3, 105, 161, 0.35) 0%, rgba(2, 132, 199, 0.45) 50%, rgba(14, 165, 233, 0.35) 100%);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 2px 12px rgba(0,0,0,0.15), 0 8px 24px rgba(0,0,0,0.12);
}

.stream-water-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.leaves-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.stream-branch {
  position: absolute;
  width: 74px;
  height: 22px;
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

.stream-branch svg {
  display: block;
  width: 100%;
  height: 100%;
}

.stream-branch-top {
  top: -6px;
  transform: rotate(10deg);
}

.stream-branch-bottom {
  bottom: -6px;
  transform: scaleY(-1) rotate(10deg);
}

.leaf-item {
  position: absolute;
  left: -220px;
  padding: 6px 14px;
  background: rgba(16, 185, 129, 0.22);
  border: 1.5px solid rgba(16, 185, 129, 0.7);
  border-radius: 20px;
  color: #059669;
  font-size: 0.88rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
  white-space: nowrap;
  user-select: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 10;
}

body.dark-theme .leaf-item {
  color: #34d399;
  background: rgba(16, 185, 129, 0.28);
  border-color: rgba(52, 211, 153, 0.7);
}

.watermark-text {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.7);
  pointer-events: none;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.card-grounding {
  background: var(--bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 14px;
}

.card-grounding h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--primary);
}

.grid-inputs {
  display: grid;
  gap: 8px;
}
