/* ============================================
   AIAM - Modern Apple-Inspired Theme
   Med alla moderna förbättringar
   ============================================ */

/* === CSS CUSTOM PROPERTIES === */
:root {
    /* Colors - Sinnesskin Palette (Synced with sinnesskin-core.css) */
    --primary: #B8A9C9;
    /* Lavendel - närvaro & lugn */
    --primary-dark: #8B7F9E;
    --primary-light: #D4CFC7;
    /* Ljusare lavendel */
    --secondary: #9DBF9E;
    /* Salvia - healing & balans */
    --accent: #C97C5D;
    /* Terrakotta - trygghet & värme */
    --error: #C97C5D;
    /* Terrakotta för varningar */
    --warning: #F9B872;
    /* Bärnsten */
    --success: #9DBF9E;
    /* Salvia */

    --background: #FFFCF9;
    /* Sand surface */
    --surface: #F5F0E8;
    /* Sand light */
    --surface-elevated: #FFFFFF;
    --text-primary: #2E2A28;
    /* Varm mörk grå */
    --text-secondary: #4A4542;
    /* Mjuk djup grå */
    --text-tertiary: #8B7F9E;
    /* Lavendel */
    --border: #E8DFD3;
    /* Sand dark */
    --brand-text-gradient: linear-gradient(135deg, #C97C5D 0%, #C97C5D 62%, #EBC7A4 78%, #B7ACC6 100%);

    --message-sent: #C97C5D;
    /* Terrakotta för användarmeddelanden */
    --message-received: #F5F0E8;
    /* Sand light för AI-meddelanden */

    /* Spacing - Fluid (Apple-style) */
    --spacing-1: clamp(4px, 0.5vw, 8px);
    --spacing-2: clamp(8px, 1vw, 12px);
    --spacing-3: clamp(12px, 1.5vw, 16px);
    --spacing-4: clamp(16px, 2vw, 24px);
    --spacing-5: clamp(24px, 3vw, 32px);
    --spacing-6: clamp(32px, 4vw, 48px);
    --spacing-7: clamp(48px, 6vw, 64px);
    --brand-logo-gap: clamp(8px, 1.3vw, 12px);

    /* Typography - Fluid (skalas dynamiskt) */
    --font-xs: clamp(11px, 1.5vw, 13px);
    --font-sm: clamp(13px, 2vw, 15px);
    --font-base: clamp(15px, 2.5vw, 17px);
    --font-lg: clamp(17px, 3vw, 20px);
    --font-xl: clamp(20px, 4vw, 28px);
    --font-2xl: clamp(28px, 5vw, 42px);

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.15);

    /* Transitions */
    --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);
}

[data-theme="dark"] {
    --background: #1A1625;
    /* Synced with Sinnesskin dark */
    --surface: #2A2435;
    /* Sand dark mode */
    --surface-elevated: #332B42;
    --text-primary: #F5F0E8;
    /* Sand light for text */
    --text-secondary: #D4CFC7;
    /* Ljusare text i dark mode */
    --text-tertiary: #6B5F7E;
    --border: #332B42;
    --message-sent: #8B7F9E;
    --message-received: #251E2F;
    --brand-text-gradient: linear-gradient(135deg, #E3A07F 0%, #E3A07F 64%, #F3D4B7 80%, #C6BCD4 100%);
}

[data-theme="dark"] .secondary-btn {
    background: rgba(26, 22, 37, 0.60);
    border-color: rgba(184, 169, 201, 0.3);
}

[data-theme="dark"] .secondary-btn:hover {
    background: rgba(184, 169, 201, 0.15);
    border-color: rgba(184, 169, 201, 0.5);
    box-shadow: 0 4px 20px rgba(184, 169, 201, 0.15);
}

/* === RESET & BASE === */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    width: 100%;
    overflow-x: hidden;
}

/* Reduced motion support (A11Y) */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    width: 100%;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    font-size: var(--font-base);
    line-height: 1.65;
    transition: background var(--transition-base), color var(--transition-base);
    letter-spacing: -0.01em;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Serif för varmare läskänsla */
h1,
h2,
h3,
.brand-name,
.auth-brand {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.message-text,
.chat-input {
    font-family: 'Inter', -apple-system, sans-serif;
    line-height: 1.7;
}

.preload * {
    transition: none !important;
}

/* === FOCUS STYLES (A11Y) === */
:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* === AUTH SCREEN === */
.auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* flex-start + auto-marginal på containern: centrerar när det får plats,
       men låter hela innehållet scrolla från toppen på små skärmar (annars
       klipps toppen bort i en centrerad flexbox och blir oåtkomlig). */
    justify-content: flex-start;
    background: var(--surface);
    padding: max(var(--spacing-4), env(safe-area-inset-top)) var(--spacing-4)
        max(var(--spacing-4), env(safe-area-inset-bottom)) var(--spacing-4);
    background-image:
        radial-gradient(circle at 20% 50%, rgba(201, 124, 93, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(184, 169, 201, 0.08) 0%, transparent 50%);
    z-index: 9999;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.auth-container {
    background: rgba(255, 252, 249, 0.65);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(46, 42, 40, 0.08), 0 2px 12px rgba(46, 42, 40, 0.04);
    padding: 40px 32px 32px 32px;
    max-width: min(420px, 85vw);
    width: 100%;
    /* auto topp-marginal + footerns auto topp-marginal delar ledigt utrymme =>
       kortet hamnar centrerat och footern längst ned. Vid litet utrymme
       kollapsar marginalerna och hela vyn går att scrolla (ingen klippning). */
    margin: auto auto 0 auto;
    border: 1px solid rgba(232, 223, 211, 0.3);
    animation: fadeInUp var(--transition-slow);
}

/* Desktop: större container */
@media (min-width: 769px) {
    .auth-container {
        max-width: min(380px, 80vw);
        padding: 40px 32px;
    }
}

@media (max-width: 768px) {
    .auth-container {
        max-width: 90vw;
        padding: 28px 20px;
        border-radius: 16px;
    }
}

@media (max-width: 480px) {
    .auth-container {
        max-width: 92vw;
        padding: 24px 18px;
        border-radius: 14px;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 24px;
}

/* Modern Auth Logo */
.auth-logo {
    margin-bottom: var(--brand-logo-gap);
    cursor: pointer;
}

.auth-logo,
.modern-logo,
.auth-logo *,
.modern-logo * {
    cursor: pointer !important;
}

.cor-nervosum-logo {
    overflow: visible;
    display: block;
    opacity: 1 !important;
    transform-origin: 50px 55px;
    animation: cor-heartbeat 3.43s ease-in-out infinite;
}

.cn-base {
    fill: none;
    stroke: #D6CCC2;
    stroke-width: 2.1;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cn-heart-fill {
    fill: #C97C5D;
    opacity: 0.86;
}

.cn-divider {
    fill: none;
    stroke: rgba(232, 195, 158, 0.85);
    stroke-width: 1.3;
    stroke-linecap: round;
}

.cn-neural-main,
.cn-neural-branch {
    fill: none;
    stroke: #9B8BBF;
    stroke-width: 1.55;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cn-neural-branch {
    stroke-width: 1.2;
}

.cn-synapse {
    fill: #F9B872;
    opacity: 0.95;
}

.auth-logo svg {
    filter: drop-shadow(0 4px 20px rgba(201, 124, 93, 0.25));
    animation: float 3s ease-in-out infinite;
}

.auth-logo .cor-nervosum-logo {
    width: 96px;
    height: 96px;
    display: block;
}

.modern-logo .cor-nervosum-logo {
    width: 62px;
    height: 62px;
    display: block;
}

@keyframes cor-heartbeat {

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

    14% {
        transform: scale(1.012);
    }

    28% {
        transform: scale(1);
    }

    42% {
        transform: scale(1.009);
    }

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

@keyframes float {

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

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

.auth-brand {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(30px, 9vw, 42px);
    font-weight: 600;
    letter-spacing: 3px;
    color: var(--accent);
    background: var(--brand-text-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0 0 6px 0;
}

.auth-tagline {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 0;
    opacity: 0.7;
}

.logo svg {
    width: clamp(180px, 32vw, 260px);
    height: auto;
    margin-bottom: 8px;
}

.logo .cor-nervosum-logo {
    width: 96px;
    height: 96px;
    margin-bottom: 0;
}

.logo h1 {
    font-size: clamp(36px, 5vw, 56px);
    font-weight: 700;
    margin-bottom: var(--spacing-2);
    letter-spacing: -1.5px;
    line-height: 1.1;
}

/* Emotionellt rubrikpar – egen behållare så .logo:s flex-gap inte påverkar dem */
.auth-taglines {
    text-align: center;
    margin-top: 4px;
}

.auth-subtitle {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.5rem;
    font-style: italic;
    font-weight: 500;
    color: #9B8BBF;
    margin: 0;
    line-height: 1.1;
}

.logo .subtitle {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-tertiary);
    margin: 1px 0 0;
    line-height: 1.35;
    letter-spacing: 0.3px;
}

/* === MOTIVATION WORDS === */
.motivation-words {
    position: relative;
    height: 36px;
    margin: 0 0 24px 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: visible;
}

.motivation-words .word {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.45rem;
    font-weight: 700;
    background: linear-gradient(135deg, #C97C5D 0%, #B8A9C9 50%, #F9B872 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0;
    animation: wordRotate 120s infinite;
    z-index: 2;
    text-align: center;
    width: 100%;
}

/* First word starts visible */
.motivation-words .word:first-child {
    opacity: 1;
    animation: wordRotateFirst 120s infinite;
}

.motivation-words .word:nth-child(1) {
    animation-delay: 0s;
}

.motivation-words .word:nth-child(2) {
    animation-delay: 10s;
}

.motivation-words .word:nth-child(3) {
    animation-delay: 20s;
}

.motivation-words .word:nth-child(4) {
    animation-delay: 30s;
}

.motivation-words .word:nth-child(5) {
    animation-delay: 40s;
}

.motivation-words .word:nth-child(6) {
    animation-delay: 50s;
}

.motivation-words .word:nth-child(7) {
    animation-delay: 60s;
}

.motivation-words .word:nth-child(8) {
    animation-delay: 70s;
}

.motivation-words .word:nth-child(9) {
    animation-delay: 80s;
}

.motivation-words .word:nth-child(10) {
    animation-delay: 90s;
}

.motivation-words .word:nth-child(11) {
    animation-delay: 100s;
}

.motivation-words .word:nth-child(12) {
    animation-delay: 110s;
}

@keyframes wordRotate {

    0%,
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(20px) scale(0.9);
        filter: blur(4px);
    }

    2%,
    6% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
        filter: blur(0px);
    }

    8% {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px) scale(0.9);
        filter: blur(4px);
    }
}

/* First word animation - starts visible */
@keyframes wordRotateFirst {

    0%,
    6% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
        filter: blur(0px);
    }

    8%,
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px) scale(0.9);
        filter: blur(4px);
    }
}

/* === AUTH FORM === */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-form h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: var(--font-xl);
    font-weight: 700;
    margin-bottom: var(--spacing-4);
}

.auth-form input,
.auth-form select {
    padding: 16px 20px;
    border: 1.5px solid var(--border);
    border-radius: 14px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 16px;
    background: var(--surface);
    color: var(--text-primary);
    transition: all 0.25s ease;
    min-height: 52px;
}

.auth-form input:hover,
.auth-form select:hover {
    border-color: rgba(201, 124, 93, 0.4);
}

.auth-form input:focus,
.auth-form select:focus {
    outline: none;
    border-color: #C97C5D;
    background: var(--background);
    box-shadow: 0 0 0 4px rgba(201, 124, 93, 0.12);
}

.auth-form input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

/* Auth divider */
.auth-divider {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 14px;
    margin: 0;
    letter-spacing: 2px;
}

/* === BUTTONS === */
.primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: clamp(14px, 2vw, 18px) clamp(24px, 3vw, 32px);
    background: linear-gradient(135deg, #C97C5D 0%, #B8A9C9 100%);
    color: white;
    border: none;
    border-radius: 18px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 52px;
    touch-action: manipulation;
    box-shadow: 0 4px 20px rgba(201, 124, 93, 0.25);
}

.primary-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 32px rgba(201, 124, 93, 0.35);
    filter: brightness(1.08);
}

.primary-btn:active {
    transform: translateY(0px) scale(0.98);
    box-shadow: 0 4px 16px rgba(201, 124, 93, 0.3);
}

.forgot-password-link {
    align-self: flex-end;
    margin-top: -6px;
    color: var(--primary);
    font-size: var(--font-sm);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition-fast);
}

.forgot-password-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.switch-form {
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--font-sm);
    margin: 0;
}

.switch-form a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.switch-form a:hover {
    text-decoration: underline;
}

/* === ERROR MESSAGE === */
.error-message {
    color: var(--error);
    padding: var(--spacing-3);
    background: rgba(255, 59, 48, 0.1);
    border-radius: var(--radius-md);
    display: none;
    font-size: var(--font-sm);
    border: 0.5px solid rgba(255, 59, 48, 0.3);
}

.error-message.show {
    display: block;
    animation: shake 0.4s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-8px);
    }

    75% {
        transform: translateX(8px);
    }
}

/* === CHAT SCREEN === */
.chat-screen {
    visibility: hidden;
    opacity: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--background);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 1000;
    transition: opacity 0.2s ease, visibility 0s 0.2s;
}

.chat-screen.visible {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.2s ease, visibility 0s 0s;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-3) var(--spacing-4);
    background: var(--background);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding-top: max(var(--spacing-3), env(safe-area-inset-top));
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--brand-logo-gap);
    flex: 1;
    justify-content: center;
}

.modern-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    line-height: 0;
    margin-top: -1px;
    cursor: pointer;
    transition: transform 0.22s ease, filter 0.22s ease;
}

.auth-logo:hover,
.modern-logo:hover {
    transform: translateY(-2px) scale(1.03);
}

.modern-logo svg {
    filter: drop-shadow(0 2px 8px rgba(201, 124, 93, 0.3));
}

.auth-logo svg,
.modern-logo svg,
.cor-nervosum-logo,
.cn-heart-fill,
.cn-neural-main,
.cn-neural-branch,
.cn-synapse {
    transition: transform 0.22s ease, filter 0.22s ease, opacity 0.22s ease;
}

.logo-hover-active .cor-nervosum-logo,
.auth-logo:hover .cor-nervosum-logo,
.modern-logo:hover .cor-nervosum-logo {
    transform: scale(1.045);
}

.logo-hover-active svg,
.auth-logo:hover svg,
.modern-logo:hover svg {
    filter: drop-shadow(0 6px 20px rgba(201, 124, 93, 0.45));
}

.logo-hover-active .cn-heart-fill,
.auth-logo:hover .cn-heart-fill,
.modern-logo:hover .cn-heart-fill {
    opacity: 0.98;
}

.logo-hover-active .cn-neural-main,
.logo-hover-active .cn-neural-branch,
.auth-logo:hover .cn-neural-main,
.auth-logo:hover .cn-neural-branch,
.modern-logo:hover .cn-neural-main,
.modern-logo:hover .cn-neural-branch {
    opacity: 1;
}

.header-right {
    position: relative;
}

.header-info h3,
.header-info .brand-name {
    font-size: var(--font-2xl);
    font-weight: 600;
    font-family: 'Cormorant Garamond', serif;
    margin: 0;
    line-height: 1.04;
    color: var(--accent);
    background: var(--brand-text-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.header-info {
    cursor: pointer;
}

.header-info .status {
    font-size: var(--font-xs);
    color: var(--text-secondary);
    margin: 2px 0 0 0;
}

.logo h1.auth-brand {
    margin: 0;
    line-height: 1.04;
}

.online-status {
    display: none;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

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

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

/* === HAMBURGER MENU === */
.menu-toggle {
    width: 44px;
    height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.menu-toggle:hover {
    background: var(--surface);
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all var(--transition-fast);
}

.menu-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* === DROPDOWN MENU === */
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--spacing-2);
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all var(--transition-fast);
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: min(70vh, 70dvh);
    -webkit-overflow-scrolling: touch;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    width: 100%;
    padding: var(--spacing-3) var(--spacing-4);
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: var(--font-sm);
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.menu-item:hover {
    background: var(--surface);
}

.menu-item svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.menu-item-crisis {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.menu-item-crisis svg {
    color: var(--primary);
}

.menu-item-crisis:hover {
    background: rgba(201, 124, 93, 0.12);
}

.menu-item.logout {
    color: var(--error);
}

.menu-item.logout svg {
    color: var(--error);
}

.menu-item.logout:hover {
    background: rgba(239, 68, 68, 0.1);
}

.menu-divider {
    height: 1px;
    background: var(--border);
    margin: var(--spacing-1) 0;
}

/* Legacy button styles - keep for compatibility */
.header-icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dark-mode-btn,
.logout-btn {
    padding: var(--spacing-2) var(--spacing-3);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--primary);
    border-radius: var(--radius-full);
    font-size: var(--font-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 44px;
    min-width: 44px;
    white-space: nowrap;
}

.dark-mode-btn:hover,
.logout-btn:hover {
    background: var(--surface-elevated);
    transform: translateY(-1px);
}

/* === MESSAGES === */
.chat-content-wrapper {
    flex: 1;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.chat-messages {
    width: 100%;
    max-width: 700px;
    padding: var(--spacing-3);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-1);
    align-items: stretch;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: var(--radius-full);
}

/* === SKELETON LOADER === */
.skeleton-loader {
    padding: var(--spacing-4);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4);
}

.skeleton-message {
    display: flex;
    gap: var(--spacing-2);
    align-items: flex-start;
}

.skeleton-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg,
            var(--surface) 0%,
            var(--border) 50%,
            var(--surface) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-text {
    flex: 1;
    height: 60px;
    border-radius: var(--radius-md);
    background: linear-gradient(90deg,
            var(--surface) 0%,
            var(--border) 50%,
            var(--surface) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-message:nth-child(2) .skeleton-text {
    height: 80px;
}

.skeleton-message:nth-child(3) .skeleton-text {
    height: 50px;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* === MESSAGE === */
.message {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease-out;
    width: 100%;
}

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

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

.message.user {
    align-items: flex-end;
}

.message.ai {
    align-items: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 14px 18px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    text-align: left;
    word-wrap: break-word;
    border-radius: 22px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    position: relative;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #C97C5D 0%, #B8A9C9 100%);
    color: white;
    border-bottom-right-radius: 6px;
    margin-left: auto;
    box-shadow: 0 3px 12px rgba(201, 124, 93, 0.3);
}

/* Mona: samma bubbelform som användaren (max-width, radius, skugga) men ljus variant + vänsterjustering */
.message.ai .message-bubble {
    background: linear-gradient(135deg, #EDE8F4 0%, #F4EBE3 100%);
    color: #2E2A28;
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(184, 169, 201, 0.45);
    margin-right: auto;
    box-shadow: 0 3px 12px rgba(184, 169, 201, 0.22);
}

[data-theme="dark"] .message.ai .message-bubble {
    background: linear-gradient(135deg, rgba(45, 38, 58, 0.95) 0%, rgba(55, 44, 52, 0.95) 100%);
    color: var(--text-primary);
    border-color: rgba(184, 169, 201, 0.35);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}

/* === TIMESTAMP === */
.message-time {
    display: block;
    font-size: 11px;
    margin-top: 6px;
    opacity: 0.6;
}

.message.user .message-time {
    color: rgba(255, 255, 255, 0.7);
    text-align: right;
}

.message.ai .message-time {
    color: var(--text-tertiary);
    text-align: left;
}

/* Legacy timestamp style */
.message-timestamp {
    font-size: var(--font-xs);
    color: var(--text-tertiary);
    margin-top: var(--spacing-1);
    text-align: right;
    opacity: 0.7;
}

.message.ai .message-timestamp {
    text-align: left;
    padding-left: var(--spacing-1);
}

/* === TYPING INDICATOR === */
#typing-indicator {
    margin-top: 8px;
}

.typing-indicator {
    display: inline-flex;
    gap: 5px;
    padding: 14px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    border-bottom-left-radius: 6px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #C97C5D;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

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

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

/* === STREAMING MESSAGE STYLES === (endast Monas bubbla) */
.message.ai.streaming .message-bubble {
    border: 2px solid rgba(201, 124, 93, 0.55);
    background: linear-gradient(135deg, rgba(237, 232, 244, 0.95) 0%, rgba(244, 235, 227, 0.95) 100%);
    animation: streamingPulse 1.5s infinite;
}

@keyframes streamingPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(201, 124, 93, 0.4);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(201, 124, 93, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(201, 124, 93, 0);
    }
}

.message-bubble .stream-placeholder {
    font-style: italic;
    opacity: 0.72;
    font-size: 0.95em;
}

/* === THINKING PROCESS DISPLAY === */
.thinking-process {
    margin-bottom: 12px;
    margin-right: auto;
    max-width: 70%;
}

.thinking-process details {
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(139, 127, 158, 0.08) 0%, rgba(168, 201, 165, 0.08) 100%);
    border: 1px solid rgba(139, 127, 158, 0.2);
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}

.thinking-process details[open] {
    background: linear-gradient(135deg, rgba(139, 127, 158, 0.12) 0%, rgba(168, 201, 165, 0.12) 100%);
    border-color: rgba(139, 127, 158, 0.4);
}

.thinking-process summary {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: #C97C5D;
    user-select: none;
}

.thinking-process summary:hover {
    color: #B8A9C9;
}

.thinking-content {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(139, 127, 158, 0.1);
    display: block;
}

.thinking-item {
    margin-bottom: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-left: 3px solid #C97C5D;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.5;
}

.thinking-item strong {
    color: #C97C5D;
    display: block;
    margin-bottom: 4px;
}

.thinking-item ul {
    margin: 4px 0 0 16px;
    padding: 0;
}

.thinking-item li {
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 12px;
}

.message-text {
    word-wrap: break-word;
    white-space: normal;
    user-select: text;
}

/* === INPUT === */
.chat-input-container {
    padding: var(--spacing-4);
    background: var(--background);
    border-top: none;
    padding-bottom: max(var(--spacing-4), env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
}

.chat-input-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.input-wrapper {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    gap: var(--spacing-3);
    align-items: center;
    background: var(--surface);
    border-radius: 28px;
    padding: var(--spacing-2) var(--spacing-3);
    border: 1.5px solid var(--border);
    transition: all var(--transition-base);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(201, 124, 93, 0.15);
}

#message-input {
    flex: 1;
    padding: var(--spacing-2) var(--spacing-2);
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: var(--font-base);
    font-family: 'Inter', sans-serif;
    resize: none;
    max-height: 120px;
    min-height: 24px;
    line-height: 1.5;
}

#message-input::placeholder {
    color: var(--text-tertiary);
}

#message-input:focus {
    outline: none;
}

/* === SEND BUTTON === */
.send-btn {
    width: 58px;
    height: 44px;
    min-width: 58px;
    min-height: 44px;
    border-radius: 9999px;
    background: linear-gradient(135deg, #C97C5D 0%, #B8A9C9 100%);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 0 4px 16px rgba(201, 124, 93, 0.25);
    color: white;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(201, 124, 93, 0.35);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.send-btn:disabled {
    background: var(--text-tertiary);
    opacity: 0.5;
    box-shadow: none;
}

/* === OFFLINE INDICATOR === */
.offline-indicator {
    position: fixed;
    top: calc(60px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    background: var(--error);
    color: white;
    padding: var(--spacing-2) var(--spacing-4);
    border-radius: var(--radius-md);
    font-size: var(--font-sm);
    font-weight: 600;
    z-index: 1000;
    animation: slideDown var(--transition-base);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* === INSIGHTS WIDGET === */
.insights-widget {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: var(--spacing-4);
    background: var(--surface);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-3) var(--spacing-4);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    animation: slideInRight var(--transition-base);
    max-width: 280px;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

.insight-content {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
}

.insight-icon {
    font-size: var(--font-lg);
}

.insight-text {
    font-size: var(--font-xs);
    color: var(--text-primary);
    font-weight: 500;
}

/* === ERROR BOUNDARY === */
.error-boundary {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-7);
    text-align: center;
}

.error-boundary h2 {
    color: var(--error);
    margin-bottom: var(--spacing-4);
}

.error-boundary p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-4);
}

.error-boundary button {
    padding: var(--spacing-3) var(--spacing-5);
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    min-height: 44px;
}

/* === WELCOME MESSAGE === */
.welcome-message {
    text-align: center;
    padding: var(--spacing-7) var(--spacing-4);
}

/* Melfis första hälsning ska se ut som ett vanligt meddelande – en bubbla uppe
   till vänster – inte som ett centrerat block mitt på skärmen. Den får klassen
   "message ai welcome-message" via JS, så vi neutraliserar centreringen här. */
.message.welcome-message {
    text-align: left;
    padding: 0;
}

.welcome-message h2 {
    font-size: var(--font-xl);
    font-weight: 700;
    margin-bottom: var(--spacing-4);
}

.welcome-message p {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--spacing-2);
}

.welcome-message .disclaimer {
    font-size: var(--font-xs);
    color: var(--text-tertiary);
    margin-top: var(--spacing-4);
    padding-top: var(--spacing-4);
    border-top: 1px solid var(--border);
}

/* === HIGH CONTRAST (A11Y) === */
@media (prefers-contrast: high) {
    :root {
        --border: #000000;
    }

    [data-theme="dark"] {
        --border: #FFFFFF;
    }
}

/* === RESPONSIVE === */

/* Phones: <480px */
@media (max-width: 480px) {
    .auth-container {
        padding: var(--spacing-5);
    }

    /* Mindre rubrikblock så hela auth-vyn får plats utan att kännas "för stor" */
    .logo {
        margin-bottom: 16px;
        gap: 4px;
    }

    .auth-logo .cor-nervosum-logo,
    .logo .cor-nervosum-logo {
        width: 76px;
        height: 76px;
    }

    .auth-subtitle {
        font-size: 1.2rem;
    }

    .auth-tagline {
        font-size: 12px;
        letter-spacing: 2px;
    }

    .header-right {
        gap: var(--spacing-1);
    }

    .dark-mode-btn,
    .logout-btn {
        padding: var(--spacing-1) var(--spacing-2);
        font-size: 11px;
    }

    .message-bubble {
        max-width: 85%;
    }

    .insights-widget {
        left: var(--spacing-2);
        right: var(--spacing-2);
        max-width: none;
    }
}

.input-group {
    position: relative;
    margin-bottom: var(--spacing-4);
    overflow: visible;
}

.input-group input,
.input-group select {
    min-height: 48px;
    line-height: 1.2;
}

/* Tablets: 768px - 1024px */
@media (min-width: 768px) and (max-width: 1024px) {
    .message-bubble {
        max-width: 65%;
    }
}

/* Desktop: 1025px+ */
@media (min-width: 769px) {
    .auth-container {
        max-width: 520px;
        padding: 64px 56px 48px 56px;
    }
}

@media (max-width: 768px) {
    .auth-container {
        max-width: 99vw;
        padding: 24px 2vw 24px 2vw;
    }

    .logo svg {
        max-height: 80px;
    }
}

/* === TOUCH DEVICES === */
@media (hover: none) {

    .primary-btn:hover,
    .dark-mode-btn:hover,
    .logout-btn:hover {
        transform: none;
    }
}

/* ============================================
   WIZARD REGISTRATION FORM
   ============================================ */

.wizard-form {
    position: relative;
}

.wizard-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-6);
    padding: 0 var(--spacing-2);
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-1);
    flex: 0 0 auto;
    z-index: 2;
}

.step-number {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-base);
    color: var(--text-secondary);
    transition: all var(--transition-base);
}

.progress-step.active .step-number {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(201, 124, 93, 0.3);
}

.progress-step.completed .step-number {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.step-label {
    font-size: var(--font-xs);
    color: var(--text-secondary);
    font-weight: 500;
}

.progress-step.active .step-label {
    color: var(--primary);
    font-weight: 600;
}

.progress-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 var(--spacing-2);
    position: relative;
    top: -12px;
}

.wizard-step {
    display: none;
    animation: slideIn var(--transition-base);
}

.wizard-step.active {
    display: block;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

.step-title {
    font-size: var(--font-xl);
    font-weight: 700;
    margin-bottom: var(--spacing-4);
    color: var(--text-primary);
}

.input-group {
    position: relative;
    margin-bottom: var(--spacing-4);
}

.input-group input,
.input-group select {
    width: 100%;
    padding: var(--spacing-3) var(--spacing-4);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--font-base);
    transition: all var(--transition-fast);
    background: var(--background);
    color: var(--text-primary);
}

/* Add padding for password inputs with toggle button */
.input-group input[type="password"] {
    padding-right: 48px;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(201, 124, 93, 0.1);
}

.input-group input.valid {
    border-color: var(--success);
}

.input-group input.invalid {
    border-color: var(--error);
}

.input-validation {
    position: absolute;
    right: var(--spacing-3);
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.input-group input.valid~.input-validation::after {
    content: '✓';
    color: var(--success);
    opacity: 1;
}

.input-group input.invalid~.input-validation::after {
    content: '✗';
    color: var(--error);
    opacity: 1;
}

.toggle-password {
    position: absolute;
    right: var(--spacing-3);
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--spacing-1);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: color var(--transition-fast), transform var(--transition-fast);
    flex-shrink: 0;
    z-index: 2;
}

.toggle-password:hover {
    color: var(--primary);
    transform: translateY(-50%) scale(1.1);
}

.password-strength {
    margin-top: calc(var(--spacing-2) * -1);
    margin-bottom: var(--spacing-4);
}

.strength-bar {
    height: 4px;
    background: var(--surface);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--spacing-1);
}

.strength-fill {
    height: 100%;
    width: 0%;
    transition: all var(--transition-base);
    border-radius: var(--radius-full);
}

.strength-fill.weak {
    width: 33%;
    background: var(--error);
}

.strength-fill.medium {
    width: 66%;
    background: var(--warning);
}

.strength-fill.strong {
    width: 100%;
    background: var(--success);
}

.strength-text {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

.help-text {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-4);
    text-align: center;
    padding: var(--spacing-3);
    background: var(--surface);
    border-radius: var(--radius-md);
}

.button-group {
    display: flex;
    gap: var(--spacing-3);
}

.secondary-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-2);
    padding: var(--spacing-3) var(--spacing-4);
    background: rgba(255, 252, 249, 0.50);
    border: 2px solid rgba(201, 124, 93, 0.3);
    color: var(--text-primary);
    border-radius: 18px;
    font-size: var(--font-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.secondary-btn:hover {
    background: rgba(201, 124, 93, 0.15);
    border-color: rgba(201, 124, 93, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(201, 124, 93, 0.15);
}

.primary-btn.success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

.welcome-animation {
    text-align: center;
    margin-bottom: var(--spacing-4);
}

.pulse-animation {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

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

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

.welcome-text {
    text-align: center;
    font-size: var(--font-base);
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--spacing-5);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
    position: fixed;
    top: var(--spacing-4);
    right: var(--spacing-4);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
    pointer-events: none;
}

.toast {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-3) var(--spacing-4);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    min-width: 300px;
    max-width: 400px;
    pointer-events: auto;
    animation: toastSlideIn var(--transition-base);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

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

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: var(--font-sm);
    margin-bottom: var(--spacing-1);
}

.toast-message {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.typing-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    padding: var(--spacing-3);
    background: var(--message-received);
    border-radius: var(--radius-lg);
    width: fit-content;
    margin: var(--spacing-2) 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

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

    30% {
        transform: translateY(-10px);
    }
}

/* ============================================
   MESSAGE TIMESTAMPS
   ============================================ */

.message-time {
    font-size: var(--font-xs);
    color: var(--text-tertiary);
    margin-top: var(--spacing-1);
    display: block;
}

.message-sent .message-time {
    text-align: right;
}

/* ============================================
   IMPROVED BUTTONS WITH ICONS
   ============================================ */

.primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-2);
}

.primary-btn svg {
    transition: transform var(--transition-fast);
}

.primary-btn:hover svg {
    transform: translateX(4px);
}

.secondary-btn svg {
    transition: transform var(--transition-fast);
}

.secondary-btn:hover svg {
    transform: translateX(-4px);
}


/* ============================================
   PULSATING HEADER LOGO
   ============================================ */

.header-heart-logo {
    animation: heartbeat 1.5s ease-in-out infinite;
    transform-origin: center;
}

@keyframes heartbeat {

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

    10% {
        transform: scale(1.1);
    }

    20% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.08);
    }

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

/* ============================================
   ENHANCED INPUT FOCUS EFFECTS
   ============================================ */

input:focus,
textarea:focus,
select:focus {
    transform: translateY(-1px);
}

.message-input:focus {
    box-shadow: 0 0 0 4px rgba(201, 124, 93, 0.15), var(--shadow-md);
}

/* ============================================
   BUTTON HOVER ENHANCEMENTS
   ============================================ */

button:not(:disabled):hover {
    transform: translateY(-2px);
}

button:not(:disabled):active {
    transform: translateY(0);
}

.primary-btn:hover {
    box-shadow: 0 8px 20px rgba(201, 124, 93, 0.4);
}

.send-button:hover {
    background: linear-gradient(135deg, #5558e3 0%, #4338ca 100%);
}

/* ============================================
   MESSAGE BUBBLE ANIMATIONS
   ============================================ */

.message {
    animation: messageSlideIn 0.3s ease-out;
}

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

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

.message-sent {
    animation: messageSentSlideIn 0.3s ease-out;
}

@keyframes messageSentSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

.message-received {
    animation: messageReceivedSlideIn 0.3s ease-out;
}

@keyframes messageReceivedSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

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

/* ============================================
   LOADING STATES & SKELETON SCREENS
   ============================================ */

.skeleton-loader {
    padding: var(--spacing-4);
}

.skeleton-message {
    display: flex;
    gap: var(--spacing-3);
    margin-bottom: var(--spacing-4);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(90deg, var(--surface) 0%, var(--surface-elevated) 50%, var(--surface) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-text {
    flex: 1;
    height: 60px;
    border-radius: var(--radius-md);
    background: linear-gradient(90deg, var(--surface) 0%, var(--surface-elevated) 50%, var(--surface) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   RESPONSIVE IMPROVEMENTS
   ============================================ */

@media (max-width: 768px) {
    .wizard-progress {
        padding: 0;
    }

    .step-number {
        width: 36px;
        height: 36px;
        font-size: var(--font-sm);
    }

    .step-label {
        font-size: 10px;
    }

    .progress-line {
        margin: 0 var(--spacing-1);
    }

    .toast-container {
        right: var(--spacing-2);
        left: var(--spacing-2);
    }

    .toast {
        min-width: auto;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .button-group {
        flex-direction: column;
    }

    .secondary-btn,
    .primary-btn {
        width: 100%;
    }

    .step-title {
        font-size: var(--font-lg);
    }
}

/* ============================================
   SPLASH SCREEN - Professionell laddningsskärm
   ============================================ */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, #C97C5D 50%, #F9B872 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: white;
}

.splash-logo {
    animation: splash-pulse 2s ease-in-out infinite;
    margin-bottom: var(--spacing-4);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 0;
}

.splash-logo svg {
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 8px 32px rgba(0, 0, 0, 0.3));
}

.splash-logo .cor-nervosum-logo {
    transform-origin: 50% 50%;
    transform: translateX(6px);
}

@keyframes splash-pulse {

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

    50% {
        transform: scale(1.05);
    }
}

.splash-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(36px, 8vw, 56px);
    font-weight: 700;
    letter-spacing: 8px;
    margin-bottom: var(--spacing-2);
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .cn-base {
    stroke: rgba(245, 240, 232, 0.78);
}

[data-theme="dark"] .cn-heart-fill {
    fill: #C97C5D;
    opacity: 0.92;
}

[data-theme="dark"] .cn-neural-main,
[data-theme="dark"] .cn-neural-branch {
    stroke: #B8A9C9;
}

[data-theme="dark"] .cn-synapse {
    fill: #F9B872;
    filter: drop-shadow(0 0 7px rgba(249, 184, 114, 0.34));
}

.splash-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: var(--font-lg);
    opacity: 0.9;
    margin-bottom: var(--spacing-5);
    letter-spacing: 2px;
}

.splash-loader {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: 0 auto;
}

.splash-loader-bar {
    width: 0%;
    height: 100%;
    background: white;
    border-radius: var(--radius-full);
    animation: splash-loading 1.5s ease-in-out forwards;
}

@keyframes splash-loading {
    0% {
        width: 0%;
    }

    50% {
        width: 70%;
    }

    100% {
        width: 100%;
    }
}

/* ============================================
   PROFESSIONAL FOOTER (inside auth-screen)
   ============================================ */
.auth-footer {
    width: 100%;
    padding: var(--spacing-2) var(--spacing-4);
    margin-top: auto;
    text-align: center;
}

.auth-footer .footer-content {
    max-width: 620px;
    margin: 0 auto;
    padding-top: var(--spacing-3);
    border-top: 1px solid var(--border);
}

.auth-footer .footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px 14px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.auth-footer .footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-xs);
    font-weight: 500;
    letter-spacing: 0.2px;
    padding: 2px;
    cursor: pointer;
    background: none;
    border: none;
    transition: color var(--transition-fast);
}

.auth-footer .footer-link:hover {
    color: var(--primary);
}

/* Pipe-tecknen ersätts av luftigt, jämnt avstånd */
.auth-footer .footer-divider {
    display: none;
}

.auth-footer .footer-safety {
    color: var(--text-secondary);
    font-size: var(--font-xs);
    line-height: 1.4;
    margin: 0 0 3px;
}

.auth-footer .footer-copyright {
    color: var(--text-tertiary);
    font-size: var(--font-xs);
    line-height: 1.4;
    margin: 0;
    opacity: 0.9;
}

/* Krissupport lyfts fram diskret som en mjuk pill i varumärkesfärg */
.footer-link-crisis {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary) !important;
    font-weight: 600;
    background: rgba(201, 124, 93, 0.10);
    border-radius: 999px;
    padding: 3px 11px !important;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.footer-link-crisis:hover {
    background: rgba(201, 124, 93, 0.18);
    color: var(--primary) !important;
    opacity: 1;
}

.footer-link-crisis .crisis-icon {
    flex-shrink: 0;
}

/* ---- Footer-info-meny ----
   Desktop: info-länkarna ligger inline (display: contents gör <a>-barnen till
   flex-objekt i .footer-links), och hamburger-knappen är dold.
   Mobil (se @media nedan): länkarna fälls in bakom "tre streck"-knappen. */
.footer-menu-toggle {
    display: none;
}

.auth-footer .footer-info-links {
    display: contents;
}

/* Old site-footer - hidden */
.site-footer {
    display: none;
}

/* ===== Mobil: samla info & villkor bakom en hamburger-knapp ===== */
@media (max-width: 600px) {
    .auth-footer {
        padding: var(--spacing-3) var(--spacing-3) 0;
    }

    .auth-footer .footer-content {
        padding-top: var(--spacing-4);
    }

    .auth-footer .footer-links {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 12px;
    }

    .auth-footer .footer-link-crisis {
        font-size: 13px;
        padding: 7px 16px !important;
    }

    /* "Tre streck"-knappen */
    .footer-menu-toggle {
        display: inline-flex;
        align-items: center;
        gap: 9px;
        padding: 8px 16px;
        background: var(--surface-elevated);
        border: 1px solid var(--border);
        border-radius: var(--radius-full);
        color: var(--text-secondary);
        font-family: inherit;
        font-size: 12.5px;
        font-weight: 600;
        letter-spacing: 0.2px;
        cursor: pointer;
        transition: background var(--transition-fast), border-color var(--transition-fast);
    }

    .footer-menu-toggle:hover,
    .footer-menu-toggle[aria-expanded="true"] {
        background: var(--surface);
        border-color: var(--primary);
        color: var(--text-primary);
    }

    .footer-menu-lines {
        display: inline-flex;
        flex-direction: column;
        justify-content: center;
        gap: 3px;
        width: 16px;
    }

    .footer-menu-lines span {
        display: block;
        height: 2px;
        width: 100%;
        background: currentColor;
        border-radius: 2px;
        transition: transform var(--transition-fast), opacity var(--transition-fast);
    }

    /* Animera till ett kryss när menyn är öppen */
    .footer-menu-toggle[aria-expanded="true"] .footer-menu-lines span:nth-child(1) {
        transform: translateY(5px) rotate(45deg);
    }

    .footer-menu-toggle[aria-expanded="true"] .footer-menu-lines span:nth-child(2) {
        opacity: 0;
    }

    .footer-menu-toggle[aria-expanded="true"] .footer-menu-lines span:nth-child(3) {
        transform: translateY(-5px) rotate(-45deg);
    }

    /* Utfällbar panel med info-länkarna */
    .auth-footer .footer-info-links {
        display: none;
        width: 100%;
        max-width: 280px;
        margin: 2px auto 0;
        flex-direction: column;
        background: var(--surface-elevated);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        overflow: hidden;
    }

    .auth-footer .footer-info-links.open {
        display: flex;
        animation: footerInfoFade var(--transition-base) ease;
    }

    .auth-footer .footer-info-links a {
        display: block;
        padding: 11px 16px;
        font-size: 13.5px;
        text-align: center;
    }

    .auth-footer .footer-info-links a:not(:last-child) {
        border-bottom: 1px solid var(--border);
    }

    .auth-footer .footer-safety {
        font-size: 12px;
        line-height: 1.5;
        margin: 4px 0 6px;
    }

    .auth-footer .footer-copyright {
        font-size: 11.5px;
        line-height: 1.5;
    }
}

@keyframes footerInfoFade {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

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

/* ============================================
   INFO-MODAL (Om Melfi / GDPR / Kris / Hur det fungerar)
   ============================================ */
.info-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-4);
}

.info-modal.is-open {
    display: flex;
}

.info-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(46, 42, 40, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: infoModalFade var(--transition-base) ease;
}

.info-modal-panel {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: min(85vh, 85dvh);
    overflow-y: auto;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: var(--spacing-6) var(--spacing-5) var(--spacing-5);
    animation: infoModalRise var(--transition-base) cubic-bezier(0.22, 1, 0.36, 1);
}

.info-modal-close {
    position: absolute;
    top: var(--spacing-3);
    right: var(--spacing-3);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--surface);
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.info-modal-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

.info-modal-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: var(--font-2xl);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--spacing-4);
    padding-right: var(--spacing-6);
}

.info-modal-body {
    color: var(--text-secondary);
    font-size: var(--font-base);
    line-height: 1.65;
}

.info-modal-body h3 {
    font-family: 'Inter', sans-serif;
    font-size: var(--font-base);
    font-weight: 600;
    color: var(--text-primary);
    margin: var(--spacing-4) 0 var(--spacing-1);
}

.info-modal-body h3:first-child {
    margin-top: 0;
}

.info-modal-body p {
    margin: 0 0 var(--spacing-3);
}

.info-modal-body ul {
    margin: 0 0 var(--spacing-3);
    padding-left: 1.25em;
}

.info-modal-body li {
    margin-bottom: var(--spacing-1);
}

.info-modal-body a {
    color: var(--accent);
    text-decoration: underline;
}

.info-modal-body strong {
    color: var(--text-primary);
}

.info-modal-callout {
    display: flex;
    gap: var(--spacing-2);
    background: rgba(201, 124, 93, 0.1);
    border: 1px solid rgba(201, 124, 93, 0.25);
    border-radius: var(--radius-md);
    padding: var(--spacing-3);
    margin: 0 0 var(--spacing-4);
    color: var(--text-primary);
    font-size: var(--font-sm);
}

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

.info-crisis-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--spacing-3);
    padding: var(--spacing-2) 0;
    border-bottom: 1px solid var(--border);
}

.info-crisis-list li:last-child {
    border-bottom: none;
}

.info-crisis-list .crisis-number {
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}

.info-modal-updated {
    margin-top: var(--spacing-4);
    font-size: var(--font-xs);
    color: var(--text-tertiary);
}

/* Modaler på mobil: följ den synliga ytan (dvh), respektera safe-area i botten,
   och dra ner padding så innehållet får plats utan att kännas trångt. */
@media (max-width: 600px) {
    .info-modal {
        padding: var(--spacing-3);
    }

    .info-modal-panel {
        max-width: 100%;
        max-height: min(90vh, 90dvh);
        padding: var(--spacing-5) var(--spacing-4)
                 max(var(--spacing-4), env(safe-area-inset-bottom));
    }

    .info-modal-title {
        font-size: var(--font-xl);
        padding-right: var(--spacing-5);
    }
}

@keyframes infoModalFade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes infoModalRise {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }

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

/* ============================================
   ENHANCED HERO SECTION
   ============================================ */
.auth-screen .step-container {
    position: relative;
}

.auth-screen .step-container::before {
    content: '';
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(201, 124, 93, 0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.auth-screen h1:not(.auth-brand),
.step-title {
    font-family: 'Cormorant Garamond', Georgia, serif !important;
}

/* Hero gradient background for auth */
.auth-screen {
    background: linear-gradient(180deg, var(--background) 0%, var(--surface) 100%);
}

[data-theme="dark"] .auth-screen {
    background: linear-gradient(180deg, var(--background) 0%, rgba(30, 41, 59, 0.5) 100%);
}

/* ============================================
   TYPOGRAPHY ENHANCEMENTS
   ============================================ */
h1,
h2,
h3,
.header-info h3 {
    font-family: 'Cormorant Garamond', Georgia, serif;
}

.auth-brand {
    font-family: 'Cormorant Garamond', serif !important;
}

.message-content,
.chat-input-container textarea,
p {
    font-family: 'Inter', sans-serif;
}

/* Gradient text for headings */
.step-title,
.auth-screen h1:not(.auth-brand) {
    background: linear-gradient(135deg, var(--primary), #B8A9C9);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Keep Mona wordmark identical across login + chat container */
.auth-brand,
.header-info .brand-name {
    color: var(--accent);
    background: var(--brand-text-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

@media (max-width: 768px) {
    .site-footer {
        padding: var(--spacing-3) var(--spacing-2);
    }

    .footer-links {
        gap: var(--spacing-3);
    }
}

/* ============================================
   #8 - DESKTOP INSIGHTS PANEL
   Sidopanel med sessionsinsikter på desktop
   ============================================ */

/* Desktop layout med sidopanel */
@media (min-width: 1200px) {
    .chat-screen {
        display: flex !important;
        flex-direction: column;
        max-width: none;
        width: 100%;
        margin: 0;
    }

    .chat-header {
        grid-column: 1 / -1;
    }

    .chat-messages {
        grid-column: 1;
        max-width: 700px;
    }

    .chat-input-container {
        grid-column: 1;
    }

    .insights-panel {
        grid-column: 2;
        grid-row: 2 / 4;
        display: flex !important;
        flex-direction: column;
        gap: var(--spacing-3);
        padding: var(--spacing-4);
        border-left: 1px solid var(--border);
        background: var(--surface);
        overflow-y: auto;
        height: calc(100vh - 70px);
    }

    .insights-panel-mobile {
        display: none !important;
    }
}

/* Dölj på mobil */
@media (max-width: 1199px) {
    .insights-panel {
        display: none !important;
    }

    .insights-panel-mobile {
        display: block;
    }
}

/* Insights Panel Styling */
.insights-panel {
    display: none;
}

.insights-section {
    background: var(--surface-elevated);
    border-radius: var(--radius-lg);
    padding: var(--spacing-4);
    border: 1px solid var(--border);
}

.insights-section-title {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-3);
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
}

.insights-section-title .icon {
    font-size: 18px;
}

/* Session Info */
.session-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-2);
}

.stat-item {
    display: flex;
    flex-direction: column;
    padding: var(--spacing-2);
    background: var(--surface);
    border-radius: var(--radius-md);
}

.stat-value {
    font-size: var(--font-xl);
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

/* Current Emotion */
.current-emotion {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-3);
    background: var(--surface);
    border-radius: var(--radius-md);
}

.emotion-icon {
    font-size: 32px;
    animation: pulse-soft 2s ease-in-out infinite;
}

@keyframes pulse-soft {

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

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

.emotion-details {
    flex: 1;
}

.emotion-name {
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
}

.emotion-depth {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

.emotion-trend {
    font-size: var(--font-xs);
    padding: 4px 8px;
    border-radius: var(--radius-full);
    font-weight: 500;
}

.emotion-trend.improving {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.emotion-trend.declining {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.emotion-trend.stable {
    background: var(--surface);
    color: var(--text-secondary);
}

/* Therapy Stage */
.therapy-stage-display {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    padding: var(--spacing-3);
    background: linear-gradient(135deg, rgba(201, 124, 93, 0.1), rgba(184, 169, 201, 0.1));
    border-radius: var(--radius-md);
}

.stage-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
}

.stage-name {
    font-weight: 500;
    color: var(--text-primary);
    text-transform: capitalize;
}

/* Insights List */
.insights-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
}

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-2);
    padding: var(--spacing-2);
    background: var(--surface);
    border-radius: var(--radius-sm);
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

.insight-item .insight-bullet {
    color: var(--primary);
    font-weight: 600;
}

/* ============================================
   #9 - EMOTIONAL TIMELINE
   Visuell känsloresa
   ============================================ */

.emotional-timeline {
    height: 120px;
    position: relative;
    margin: var(--spacing-3) 0;
}

.timeline-canvas {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-md);
    background: var(--surface);
}

/* Emotion Journey Pills */
.emotion-journey {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-1);
    margin-top: var(--spacing-2);
}

.emotion-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-xs);
    font-weight: 500;
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.emotion-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.emotion-pill[data-emotion="glädje"] .dot {
    background: #9DBF9E;
}

.emotion-pill[data-emotion="hopp"] .dot {
    background: #9DBF9E;
}

.emotion-pill[data-emotion="lättnad"] .dot {
    background: #B8A9C9;
}

.emotion-pill[data-emotion="lugn"] .dot {
    background: #9DBF9E;
}

.emotion-pill[data-emotion="neutral"] .dot {
    background: #9CA3AF;
}

.emotion-pill[data-emotion="oro"] .dot {
    background: #F59E0B;
}

.emotion-pill[data-emotion="frustration"] .dot {
    background: #F9B872;
}

.emotion-pill[data-emotion="sorg"] .dot {
    background: #8B7F9E;
}

.emotion-pill[data-emotion="ångest"] .dot {
    background: #C97C5D;
}

.emotion-pill[data-emotion="förtvivlan"] .dot {
    background: #B8A9C9;
}

.emotion-pill[data-emotion="stress"] .dot {
    background: #F9B872;
}

/* Timeline Summary */
.timeline-summary {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-2);
    background: var(--surface);
    border-radius: var(--radius-sm);
    font-size: var(--font-xs);
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.summary-value {
    font-weight: 600;
    color: var(--primary);
}

.summary-label {
    color: var(--text-secondary);
}

/* Thinking Indicator i chat */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    padding: var(--spacing-3);
    margin: var(--spacing-2) 0;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    animation: fadeIn 0.3s ease;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: thinking-bounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinking-bounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.thinking-text {
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

.thinking-budget {
    margin-left: auto;
    font-size: var(--font-xs);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

/* Collapsible Thinking Process in Messages */
.message-thinking {
    margin-top: var(--spacing-2);
    padding: var(--spacing-2);
    background: rgba(99, 102, 241, 0.05);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary);
}

.thinking-toggle {
    display: flex;
    align-items: center;
    gap: var(--spacing-1);
    font-size: var(--font-xs);
    color: var(--primary);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}

.thinking-toggle:hover {
    text-decoration: underline;
}

.thinking-content {
    display: none;
    margin-top: var(--spacing-2);
    font-size: var(--font-xs);
    color: var(--text-secondary);
    line-height: 1.6;
}

.thinking-content.expanded {
    display: block;
}

.thinking-content p {
    margin-bottom: var(--spacing-1);
}

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

/* 🌌 Quantum Leap Info */
.quantum-leap-info {
    margin-top: var(--spacing-3);
    padding: var(--spacing-3);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(184, 169, 201, 0.08) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.quantum-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    cursor: pointer;
    font-weight: 600;
    color: var(--primary);
    user-select: none;
}

.quantum-header:hover {
    opacity: 0.8;
}

.quantum-icon {
    font-size: 1.2em;
}

.quantum-title {
    flex: 1;
    font-size: var(--font-sm);
}

.quantum-level {
    background: linear-gradient(135deg, #B8A9C9 0%, #C97C5D 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: var(--font-xs);
    font-weight: bold;
}

.quantum-header .arrow {
    transition: transform 0.3s ease;
    font-size: 0.8em;
}

.quantum-content {
    display: none;
    margin-top: var(--spacing-3);
    padding-top: var(--spacing-3);
    border-top: 1px solid rgba(99, 102, 241, 0.1);
}

.quantum-content.expanded {
    display: block;
    animation: fadeInDown 0.3s ease;
}

.quantum-metric {
    margin-bottom: var(--spacing-2);
    font-size: var(--font-sm);
    color: var(--text-primary);
}

.quantum-metric strong {
    color: var(--primary);
    font-weight: 600;
}

.quantum-insights {
    margin-top: var(--spacing-3);
    padding-top: var(--spacing-3);
    border-top: 1px solid rgba(99, 102, 241, 0.1);
}

.quantum-insights ul {
    margin: var(--spacing-2) 0 0 var(--spacing-4);
    list-style: none;
}

.quantum-insights li {
    position: relative;
    padding-left: var(--spacing-3);
    margin-bottom: var(--spacing-1);
    font-size: var(--font-xs);
    color: var(--text-secondary);
    line-height: 1.5;
}

.quantum-insights li:before {
    content: "✨";
    position: absolute;
    left: 0;
}

/* Feedback Widget */
.feedback-widget {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    margin-top: var(--spacing-2);
    padding: var(--spacing-2);
    background: var(--surface);
    border-radius: var(--radius-md);
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.3s ease forwards;
    animation-delay: 0.5s;
}

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

.feedback-prompt {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

.feedback-stars {
    display: flex;
    gap: 2px;
}

.feedback-star {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
    padding: 2px;
}

.feedback-star:hover,
.feedback-star.active {
    color: #F59E0B;
    transform: scale(1.2);
}

/* Crisis Alert in Insights */
.crisis-alert {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    padding: var(--spacing-3);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: var(--error);
    font-size: var(--font-sm);
}

.crisis-alert-icon {
    font-size: 20px;
}

/* ── Kontoinställningar (modal) ───────────────────────────────────────── */
.account-section-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 14px;
    color: var(--text-primary, #2E2A28);
}

.account-field {
    margin-bottom: 14px;
}

.account-field label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary, #8B7F7A);
    margin-bottom: 6px;
}

.account-field input {
    width: 100%;
    padding: 14px 16px;
    min-height: 50px;
    border: 1.5px solid var(--border-color, #ECE4DC);
    border-radius: 14px;
    font-size: 1rem;
    background: var(--surface-soft, #FCFAF8);
    color: var(--text-primary, #2E2A28);
    box-sizing: border-box;
}

.account-field input:focus {
    outline: none;
    border-color: #C97C5D;
    box-shadow: 0 0 0 3px rgba(201, 124, 93, 0.15);
}

.account-divider {
    border: none;
    border-top: 1px solid var(--border-color, #ECE4DC);
    margin: 26px 0;
}

.account-msg {
    min-height: 1.2em;
    margin: 10px 0 0;
    font-size: 0.88rem;
}

.account-msg.ok { color: #4f7a63; }
.account-msg.err { color: #B4503A; }

.account-hint {
    color: var(--text-secondary, #8B7F7A);
    font-size: 0.9rem;
    margin: 0 0 14px;
    line-height: 1.5;
}

.account-full-btn {
    width: 100%;
}

/* Radera konto – tydligt men inte skrikigt */
.account-danger-title {
    color: #B4503A;
}

.account-danger-text {
    color: var(--text-secondary, #8B7F7A);
    font-size: 0.9rem;
    margin: 0 0 14px;
    line-height: 1.5;
}

.danger-btn {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid #D98B73;
    background: transparent;
    color: #B4503A;
    border-radius: 12px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.danger-btn:hover {
    background: #B4503A;
    border-color: #B4503A;
    color: #fff;
}

/* === Gäst-gräns: konto-uppmaning i chatten === */
.guest-limit-cta {
    margin: 14px auto 8px;
    max-width: 520px;
    padding: 18px 20px;
    background: rgba(139, 127, 158, 0.08);
    border: 1px solid var(--border, rgba(139, 127, 158, 0.25));
    border-radius: 16px;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.guest-limit-cta-title {
    margin: 0 0 6px;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--primary, #8B7F9E);
}

.guest-limit-cta-text {
    margin: 0 0 14px;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text-secondary, #6b6478);
}

.guest-limit-cta-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.guest-limit-cta-actions .primary-btn.guest-limit-create {
    width: 100%;
    max-width: 280px;
}

.guest-limit-login {
    background: none;
    border: none;
    color: var(--primary, #8B7F9E);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.guest-limit-login:hover {
    color: var(--primary-dark, #6f6485);
}

/* === FLYTANDE TEMA-KNAPP (startsidan) ===
   Ger samma ljus/mörker-växling på startsidan som finns i chattens meny. */
.theme-toggle-floating {
    position: fixed;
    top: max(var(--spacing-4), env(safe-area-inset-top));
    right: max(var(--spacing-4), env(safe-area-inset-right));
    z-index: 20;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-elevated, var(--background));
    color: var(--text-secondary);
    cursor: pointer;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.06));
    transition: background var(--transition-fast), color var(--transition-fast),
        transform var(--transition-fast);
}

.theme-toggle-floating:hover {
    color: var(--primary);
    transform: translateY(-1px);
}

.theme-toggle-floating .icon-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle-floating .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle-floating .icon-moon {
    display: block;
}

/* === SÄKERHETSRAD UNDER CHATT-INPUT ===
   Diskret, men alltid synlig påminnelse om att Melfi inte är akutvård. */
.chat-disclaimer {
    margin: var(--spacing-2) auto 0;
    max-width: 720px;
    padding: 0 var(--spacing-2);
    text-align: center;
    font-size: var(--font-xs, 0.75rem);
    line-height: 1.4;
    color: var(--text-tertiary, var(--text-secondary));
}

.chat-disclaimer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.chat-disclaimer a:hover {
    text-decoration: underline;
}

@media (max-width: 600px) {
    .chat-disclaimer {
        font-size: 0.7rem;
    }

    .theme-toggle-floating {
        width: 38px;
        height: 38px;
    }
}