:root {
  color-scheme: dark;
  --life-bg: #090d16;
  --life-surface: #111827;
  --life-card: rgba(17, 24, 39, 0.85);
  --life-border: rgba(99, 102, 241, 0.2);
  --life-accent: #6366f1;
  --life-accent-glow: rgba(99, 102, 241, 0.35);
  --life-accent-cyan: #06b6d4;
  --life-text: #f8fafc;
  --life-muted: #9ca3af;
  --life-lived: #4f46e5;
  --life-future: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
  color-scheme: light;
  --life-bg: #f8fafc;
  --life-surface: #ffffff;
  --life-card: rgba(255, 255, 255, 0.95);
  --life-border: rgba(79, 70, 229, 0.2);
  --life-accent: #4f46e5;
  --life-accent-glow: rgba(79, 70, 229, 0.25);
  --life-accent-cyan: #0891b2;
  --life-text: #0f172a;
  --life-muted: #64748b;
  --life-lived: #6366f1;
  --life-future: rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--life-bg);
  color: var(--life-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand-logo-box {
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.life-app-layout {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem;
}

.life-grid {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 1.25rem;
}

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

/* Lienzo de las 4.000 Semanas */
.life-stage {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.matrix-card {
  background: var(--life-surface);
  border: 1px solid var(--life-border);
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.1);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.matrix-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.matrix-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--life-accent);
}

.matrix-legend {
  display: flex;
  gap: 0.85rem;
  font-size: 0.75rem;
  color: var(--life-muted);
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 4px;
}

/* Cuadrícula de Semanas */
.weeks-canvas-wrap {
  width: 100%;
  overflow-x: auto;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid var(--life-border);
}

#weeks-grid-canvas {
  width: 100%;
  max-width: 800px;
  display: block;
  margin: 0 auto;
}

/* Métricas Cósmicas y Biométricas */
.cosmic-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .cosmic-metrics-grid {
    grid-template-columns: 1fr;
  }
}

.cosmic-box {
  background: var(--life-surface);
  border: 1px solid var(--life-border);
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cosmic-label {
  font-size: 0.72rem;
  color: var(--life-muted);
  text-transform: uppercase;
}

.cosmic-val {
  font-size: 1.25rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--life-accent-cyan);
}

.cosmic-desc {
  font-size: 0.72rem;
  color: var(--life-muted);
}

/* Barra Lateral de Configuración y Sociología */
.life-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.config-card {
  background: var(--life-surface);
  border: 1px solid var(--life-border);
  border-radius: 16px;
  padding: 1.25rem;
}

.config-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--life-accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.inputs-group-vertical {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.input-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.input-label {
  font-size: 0.75rem;
  color: var(--life-muted);
  font-weight: 500;
}

.input-field {
  background: var(--life-surface);
  border: 1px solid var(--life-border);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  color: var(--life-text);
  font-size: 0.875rem;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select.input-field {
  cursor: pointer;
  background-color: var(--life-surface);
  color: var(--life-text);
}

.input-field option {
  background-color: #111827;
  color: #f8fafc;
  padding: 0.6rem 0.85rem;
}

[data-theme="light"] .input-field option {
  background-color: #ffffff;
  color: #0f172a;
}

.input-field:focus {
  border-color: var(--life-accent);
  box-shadow: 0 0 0 2px var(--life-accent-glow);
}

/* Proyecciones de Relaciones y Tiempo Restante */
.relationships-card {
  background: var(--life-surface);
  border: 1px solid var(--life-border);
  border-radius: 16px;
  padding: 1.25rem;
}

.rel-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.rel-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.rel-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
}

.rel-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #06b6d4);
  border-radius: 9999px;
  transition: width 0.3s ease;
}

/* Botón de Exportación */
.btn-export-life {
  width: 100%;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.85rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
  transition: opacity 0.2s;
}

.btn-export-life:hover {
  opacity: 0.92;
}

/* Modal */
.life-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 1rem;
}

.life-modal.active {
  display: flex;
}

.life-modal-content {
  background: var(--life-surface);
  border: 1px solid var(--life-border);
  border-radius: 18px;
  max-width: 580px;
  width: 100%;
  padding: 1.5rem;
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--life-muted);
  cursor: pointer;
}
