:root {
    /* Design Tokens - Dark Mode (Default) - Premium & Accessible Palette */
    --color-bg: #030712;
    /* Deep Obsidian */
    --color-surface: rgba(17, 24, 39, 0.8);
    --color-primary: #fbbf24;
    /* Refined Gold - High Contrast */
    --color-primary-glow: rgba(251, 191, 36, 0.2);
    --color-text-primary: #ffffff;
    --color-text-secondary: #cbd5e1;
    /* Increased contrast for A11y */
    --color-accent: #38bdf8;
    --color-danger: #f43f5e;

    --hex-abrirse: #f59e0b;
    --hex-presente: #10b981;
    --hex-yo: #818cf8;
    --hex-valores: #ec4899;
    --hex-accion: #3b82f6;
    --hex-analisis: #a78bfa;
    --hex-sos: #f43f5e;

    --color-success: #10b981;

    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.12);
    /* More visible borders */
    --glass-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.3),
        0 10px 15px -3px rgba(0, 0, 0, 0.5),
        inset 0 1px 1px 0 rgba(255, 255, 255, 0.07);

    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;

    --transition-base: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-spring: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);

    --font-main: 'Outfit', -apple-system, sans-serif;
}

/* Animations */
@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@keyframes breathe {

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

    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

@keyframes thoughtGlitch {

    0%,
    100% {
        transform: translateX(0);
        text-shadow: none;
    }

    25% {
        transform: translateX(-1px);
        text-shadow: -1px 0 0 rgba(239, 68, 68, 0.6), 1px 0 0 rgba(59, 130, 246, 0.6);
    }

    50% {
        transform: translateX(1px);
        text-shadow: 1px 0 0 rgba(16, 185, 129, 0.55), -1px 0 0 rgba(245, 158, 11, 0.55);
    }

    75% {
        transform: translateX(-0.5px);
        text-shadow: -1px 0 0 rgba(167, 139, 250, 0.55);
    }
}

@keyframes thoughtWavy {

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

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

.animate-slide-up {
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-scale-in {
    animation: scaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.thought-item.distort-glitch {
    animation: thoughtGlitch 0.22s infinite steps(2, end);
}

.thought-item.distort-wavy {
    animation: thoughtWavy 1.2s ease-in-out infinite;
}

.thought-item.distort-mirror {
    transform: scaleX(-1);
    opacity: 0.92;
}


[data-theme="light"] {
    --color-bg: #ffffff;
    --color-surface: rgba(243, 244, 246, 0.9);
    --color-primary: #92400e;
    --color-primary-glow: rgba(146, 64, 14, 0.1);
    --color-text-primary: #0f172a;
    --color-text-secondary: #334155;
    --glass-bg: rgba(0, 0, 0, 0.04);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 10px 15px -3px rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background-color: var(--color-bg);
    background-image:
        radial-gradient(at 0% 0%, rgba(251, 191, 36, 0.08) 0, transparent 50%),
        radial-gradient(at 100% 100%, rgba(14, 165, 233, 0.08) 0, transparent 50%),
        radial-gradient(at 50% 50%, rgba(167, 139, 250, 0.05) 0, transparent 80%);
    color: var(--color-text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color 0.5s ease;
    font-size: 16px;
    /* A11y default */
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

/* Base Layout */
#app {
    max-width: 640px;
    margin: 0 auto;
    padding: calc(24px + env(safe-area-inset-top)) 24px calc(48px + env(safe-area-inset-bottom));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Accessibility Focus States */
:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 4px;
}

/* Glassmorphism */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* Header */
header {
    margin-bottom: 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--color-primary);
    letter-spacing: -0.01em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand::before {
    content: '';
    width: 6px;
    height: 18px;
    background: var(--color-primary);
    border-radius: 10px;
    display: inline-block;
}

/* Interactive SVG Elements */
.hexaflex-container {
    perspective: 1000px;
    margin: 0 auto 2.5rem;
    position: relative;
    width: 100%;
    max-width: 440px;
    aspect-ratio: 1;
}

.hexaflex-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.hex-vertex {
    cursor: pointer;
    transition: var(--transition-spring);
    outline: none;
}

.hex-vertex:hover circle {
    r: 25;
    stroke-width: 3;
    filter: drop-shadow(0 0 15px currentColor);
}

.hex-vertex:hover foreignObject {
    transform: scale(1.1);
    transform-origin: center;
}

.hex-label {
    fill: var(--color-text-primary);
    font-size: 13px;
    font-weight: 700;
    text-anchor: middle;
    pointer-events: none;
    fill-opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hex-line {
    fill: none;
    stroke: var(--glass-border);
    stroke-width: 1.5;
    opacity: 0.4;
    transition: var(--transition-base);
}

.hex-line-gradient {
    stroke-width: 2.5;
    stroke-linecap: round;
    opacity: 0.6;
    filter: blur(1px);
}

/* Animations */
@keyframes pulse-glow {
    0% {
        filter: drop-shadow(0 0 5px var(--color-primary-glow));
        transform: scale(1);
    }

    50% {
        filter: drop-shadow(0 0 20px var(--color-primary));
        transform: scale(1.02);
    }

    100% {
        filter: drop-shadow(0 0 5px var(--color-primary-glow));
        transform: scale(1);
    }
}

.pulse-center {
    animation: pulse-glow 3s ease-in-out infinite;
    transform-origin: center;
}

.hex-vertex-pulse {
    animation: vertex-pulse 4s ease-in-out infinite;
}

@keyframes vertex-pulse {

    0%,
    100% {
        transform: scale(1);
        filter: brightness(1);
    }

    50% {
        transform: scale(1.05);
        filter: brightness(1.2);
    }
}

/* View Toggles */
.view-switch {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: var(--glass-bg);
    padding: 0.4rem;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.btn-toggle {
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    min-height: auto;
    border-radius: 50px;
    background: transparent;
    color: var(--color-text-secondary);
}

.btn-toggle.active {
    background: var(--color-primary);
    color: #000;
    box-shadow: 0 4px 12px var(--color-primary-glow);
}

/* Buttons */
button {
    font-family: var(--font-main);
    padding: 0.85rem 1.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 700;
    transition: var(--transition-base);
    min-height: 52px;
    font-size: 1rem;
}

.btn-primary {
    background: var(--color-primary);
    color: #000;
    box-shadow: 0 10px 20px -5px var(--color-primary-glow);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-primary);
    border: 1px solid var(--glass-border);
}

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

/* Tool Tabs (module tool selectors) */
.btn-tool {
    background: var(--glass-bg);
    color: var(--color-text-secondary);
    border: 1px solid var(--glass-border);
    min-height: 44px;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.btn-tool:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-text-primary);
}

.btn-tool.active {
    background: var(--color-primary);
    color: var(--color-bg);
    border-color: transparent;
    box-shadow: 0 4px 12px var(--color-primary-glow);
}

/* Text inputs */
.input-field {
    width: 100%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
    padding: 0.7rem 0.9rem;
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition-base);
}

.input-field::placeholder {
    color: var(--color-text-secondary);
    opacity: 0.7;
}

.input-field:focus {
    outline: none;
    border-color: var(--color-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Range sliders */
.slider-act {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    min-height: auto;
    padding: 0;
    border-radius: 3px;
    background: var(--glass-border);
    outline: none;
    cursor: pointer;
}

.slider-act::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid var(--color-bg);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

.slider-act::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-bg);
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
}

/* Property panel groups (thought visualizer) */
.property-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.property-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

/* Utility */
.flex-1 {
    flex: 1;
}

/* Clinical Cards */
.glass-card {
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.glass-card h2,
.glass-card h3 {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* Animations */
@keyframes glowIn {
    from {
        opacity: 0;
        filter: blur(10px);
    }

    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* Radio Doom & Gloom Specifics */
.radio-screen {
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 15px rgba(0, 255, 0, 0.2);
    text-shadow: 0 0 5px #0f0;
}

.noise-overlay {
    position: absolute;
    inset: 0;
    /* Pure-CSS static noise (no external asset) */
    background: repeating-radial-gradient(#000 0 0.0001%, #fff 0 0.0002%) 50% 0/2500px 8100px,
        repeating-conic-gradient(#000 0 0.0001%, #fff 0 0.0002%) 60% 50%/2500px 8100px;
    background-blend-mode: difference;
    opacity: 0.05;
    pointer-events: none;
    animation: noise 0.2s infinite alternate;
}

@keyframes noise {
    10% {
        transform: translate(-1%, -1%);
    }

    30% {
        transform: translate(1%, 1%);
    }

    50% {
        transform: translate(-1%, 2%);
    }

    70% {
        transform: translate(2%, 1%);
    }

    90% {
        transform: translate(-2%, -1%);
    }
}

.vu-bar {
    width: 4px;
    background: #0f0;
    margin: 0 1px;
    transition: height 0.1s ease;
}

.radio-dial {
    height: 4px;
    background: var(--glass-border);
    position: relative;
    margin: 1rem 0;
}

.radio-needle {
    position: absolute;
    top: -6px;
    width: 2px;
    height: 16px;
    background: #f00;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Celestial Animations */
@keyframes pulse {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.star {
    transition: opacity 2s ease;
}

.clinical-note {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

/* Accessibility Utilities */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Specific Triflex Styling */
.triflex-pillar {
    stroke-width: 40;
    stroke-linecap: round;
    opacity: 0.15;
    transition: var(--transition-base);
}

.triflex-group:hover .triflex-pillar {
    opacity: 0.3;
}

/* SOS Button */
#btn-sos {
    background: var(--hex-sos);
    color: white;
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.4);
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    padding: 0;
}

/* Tool Header Standard */
.tool-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    animation: slideUpFade 0.5s ease-out;
}

.tool-header .title-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.tool-header .title-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.tool-title {
    font-size: 1.15rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-header__actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.tool-header__actions .btn-ghost {
    min-height: 44px;
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
}

.btn-icon {
    min-height: 44px;
    width: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

/* Input Overrides */
.input-underline {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--glass-border);
    color: var(--color-text-primary);
    padding: 0.5rem 0;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition-base);
}

.input-underline:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Breathing Animation */
.breathing-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--color-primary) 0%, transparent 70%);
    margin: 3rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: breathe 4s ease-in-out infinite;
}

/* Responsive */
@media (max-width: 420px) {
    #app {
        padding: 16px;
    }

    .hexaflex-container {
        max-width: 340px;
    }

    .hex-label {
        font-size: 12px;
    }

    #btn-sos {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }
}
/* Dashboard Premium Controls */
.dashboard-view {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.dashboard-hero {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: linear-gradient(140deg, rgba(251, 191, 36, 0.12), rgba(14, 165, 233, 0.06));
}

.dashboard-hero__header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}

.dashboard-kicker {
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    margin-bottom: 0.2rem;
}

.dashboard-hero h1 {
    font-size: 1.8rem;
    line-height: 1.15;
    color: var(--color-primary);
}

.dashboard-subtitle {
    font-size: 0.9rem;
    margin-top: 0.5rem;
    color: var(--color-text-secondary);
    max-width: 45ch;
}

.dashboard-create-toggle {
    min-height: 42px;
    padding: 0.6rem 1rem;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.dashboard-stat-card {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
}

.dashboard-stat-card span {
    display: block;
    font-size: 0.72rem;
    color: var(--color-text-secondary);
}

.dashboard-stat-card strong {
    display: block;
    margin-top: 0.35rem;
    font-size: 1.45rem;
    line-height: 1;
}

.dashboard-create-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.dashboard-create-row {
    display: flex;
    gap: 0.75rem;
}

.dashboard-input {
    width: 100%;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--color-text-primary);
    padding: 0.7rem 0.85rem;
    min-height: 44px;
    font-family: inherit;
}

.dashboard-input::placeholder {
    color: var(--color-text-secondary);
}

.is-hidden {
    display: none !important;
}

.dashboard-toolbar {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.dashboard-toolbar label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-secondary);
    margin-bottom: 0.35rem;
}

.patient-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.patient-item {
    padding: 1rem;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.9rem;
    border: 1px solid var(--glass-border);
}

.patient-item.active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.15);
}

.patient-item__main h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.patient-item__main p {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.patient-item__actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.patient-item__actions .btn-ghost {
    min-height: 38px;
    font-size: 0.8rem;
    padding: 0.45rem 0.65rem;
}

.dashboard-empty-state {
    text-align: center;
    padding: 1.4rem 1rem;
    color: var(--color-text-secondary);
    border: 1px dashed var(--glass-border);
    border-radius: var(--radius-md);
}

.session-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.session-controls__secondary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

@media (max-width: 540px) {
    .dashboard-hero__header {
        flex-direction: column;
        align-items: stretch;
    }

    .dashboard-toolbar,
    .dashboard-stats,
    .session-controls__secondary {
        grid-template-columns: 1fr;
    }

    .dashboard-create-row,
    .patient-item {
        flex-direction: column;
        align-items: stretch;
    }

    .patient-item__actions {
        justify-content: flex-start;
    }
}

/* Toasts (ui/utils.js) */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(8px);
    color: var(--color-text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-primary);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-weight: 600;
    font-size: 0.9rem;
    pointer-events: none;
    text-align: center;
}

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

/* Animations used in JS modules */
@keyframes float {
    0% { transform: translateY(0px) translateX(0px); }
    33% { transform: translateY(-5px) translateX(3px); }
    66% { transform: translateY(3px) translateX(-2px); }
    100% { transform: translateY(0px) translateX(0px); }
}

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

/* Switch Aura for Breathing Tool (sos.js) */
.switch-aura {
    position: absolute;
    border-radius: 50%;
    transition: all 0.5s ease;
    pointer-events: none;
}
.switch-aura.active {
    animation: pulse-glow 3s infinite alternate;
}

/* Diana marks (importa.js) — la posición, escala y color se fijan inline */
.diana-mark {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: scale 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

/* Texto de carga inicial (index.html) */
.loader {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40vh;
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    text-align: center;
    animation: loader-pulse 1.6s ease-in-out infinite;
}

@keyframes loader-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.9; }
}

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