/* Base styles */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    color: #0f172a;
    background: #0f172a;
}

.page-root {
    position: relative;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px 16px;
    box-sizing: border-box;
}

.bg-video {
    position: fixed;
    right: 0;
    bottom: 0;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    object-fit: cover;
    z-index: -2;
    background: #000;
}

.bg-overlay {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.08) 0, transparent 45%),
        linear-gradient(to bottom, rgba(15, 23, 42, 0.86), rgba(15, 23, 42, 0.96));
}

.onboarding-card {
    max-width: 720px;
    width: 100%;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 20px;
    padding: 32px 36px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.45);
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #ffffffcc;
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    font-weight: 600;
    letter-spacing: 0.05em;
}

.language-selector {
    position: relative;
}

#lang-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    background: #1d2330;
    color: #fff;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.2s ease;
}

#lang-toggle:hover,
#lang-toggle:focus {
    background: #353d52;
}

.lang-options {
    position: absolute;
    right: 0;
    margin-top: 0.5rem;
    background: #fff;
    box-shadow: 0 12px 32px rgba(27, 34, 51, 0.18);
    border-radius: 0.75rem;
    width: min(280px, 90vw);
    max-height: 320px;
    overflow-y: auto;
    padding: 0.5rem;
    transform: translateX(0);
}

.lang-option {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 0.6rem;
    text-align: left;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.lang-option:hover,
.lang-option:focus {
    background: rgba(53, 61, 82, 0.08);
}

.lang-option.active {
    background: linear-gradient(135deg, #5a6cff, #6dc7ff);
    color: #fff;
}

.greeting-ticker {
    position: fixed;
    top: clamp(12px, 4vw, 32px);
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.9rem;
    font-size: 0.85rem;
    color: #1d2330;
    background: rgba(255, 255, 255, 0.68);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
    max-width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 35;
    pointer-events: none;
}

.intro-screen {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at top left, #ede7ff, #d5f1ff);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 30;
}

.intro-content {
    text-align: center;
    position: relative;
}

.greeting-word {
    font-size: clamp(2.5rem, 8vw, 5rem);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.greeting-word.animate {
    animation: fadeSlide 0.4s ease-in-out;
}

@keyframes fadeSlide {
    0% {
        opacity: 0;
        transform: translateY(12px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.skip-button {
    margin-top: 1.5rem;
    background: rgba(29, 35, 48, 0.15);
    color: #1d2330;
    border: none;
    padding: 0.5rem 1.1rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.skip-button:hover,
.skip-button:focus {
    background: rgba(29, 35, 48, 0.3);
}

.steps {
    padding: clamp(1.5rem, 4vw, 2.5rem) 0;
}

.step {
    width: 100%;
}

.card {
    background: transparent;
    border-radius: 1.25rem;
    padding: clamp(2rem, 5vw, 3rem);
    box-shadow: none;
}

h1, h2 {
    margin-top: 0;
    color: #1d2330;
}

.frizz-text {
    font-size: clamp(1.6rem, 3vw, 2rem);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1.5rem;
}

.subtitle {
    color: #566079;
    margin-bottom: 1rem;
}

.scale-label {
    color: #394059;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

input[type="text"] {
    width: 100%;
    padding: 0.9rem 1rem;
    border-radius: 0.9rem;
    border: 1px solid rgba(29, 35, 48, 0.15);
    font-size: 1rem;
    margin-bottom: 1rem;
}

input[type="text"]:focus {
    outline: 2px solid rgba(53, 61, 82, 0.25);
}

.primary-button {
    background: linear-gradient(135deg, #5a6cff, #6dc7ff);
    border: none;
    color: #fff;
    padding: 0.9rem 1.6rem;
    border-radius: 999px;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.primary-button:hover,
.primary-button:focus {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(90, 108, 255, 0.3);
}

.error-message {
    color: #c62828;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.scale-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 0.6rem;
}

.scale-button {
    background: #edf0ff;
    border: none;
    border-radius: 0.75rem;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.scale-button:hover,
.scale-button:focus {
    background: #dbe2ff;
}

.scale-button.active {
    background: linear-gradient(135deg, #5a6cff, #6dc7ff);
    color: #fff;
    transform: translateY(-1px);
}

.option-grid {
    display: grid;
    gap: 0.75rem;
}

#step-q2 .card h2 {
    margin-bottom: 0.75rem;
}

#background-options {
    gap: 0.6rem;
}

@media (min-width: 560px) {
    .option-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.option-button {
    background: #ffffff;
    border: 1px solid rgba(29, 35, 48, 0.12);
    border-radius: 1rem;
    padding: 0.95rem 1.1rem;
    text-align: left;
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.option-button:hover,
.option-button:focus {
    border-color: #5a6cff;
    box-shadow: 0 10px 20px rgba(90, 108, 255, 0.16);
}

.option-button.active {
    border-color: #5a6cff;
    box-shadow: 0 12px 26px rgba(90, 108, 255, 0.2);
}

.status-message {
    margin-top: 1.5rem;
    font-size: 0.95rem;
    color: #394059;
}

.status-message.success {
    color: #2e7d32;
}

.status-message.error {
    color: #c62828;
}

.noscript-warning {
    background: #c62828;
    color: #fff;
    padding: 0.8rem 1rem;
    text-align: center;
}

@media (max-width: 600px) {
    .app-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    #lang-toggle {
        width: 100%;
        justify-content: center;
    }

    .language-selector {
        width: 100%;
    }

    .lang-options {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: min(320px, calc(100vw - 32px));
    }

    .onboarding-card {
        padding: 20px 18px;
        border-radius: 16px;
    }

    .card {
        padding: 1.75rem 1.25rem;
    }

    .greeting-ticker {
        font-size: 0.8rem;
        padding: 0.3rem 0.75rem;
    }
}

.chat-container {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #1d2330;
}

.chat-log {
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-right: 0.25rem;
}

.chat-message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    line-height: 1.45;
    font-size: 0.95rem;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
    word-break: break-word;
}

.chat-message.chat-assistant {
    margin-right: auto;
    background: rgba(90, 108, 255, 0.12);
    color: #1d2330;
}

.chat-message.chat-user {
    margin-left: auto;
    background: linear-gradient(135deg, #5a6cff, #6dc7ff);
    color: #fff;
}

.chat-message.chat-system {
    margin: 0 auto;
    background: rgba(15, 23, 42, 0.1);
    color: #1d2330;
}

.chat-typing {
    font-size: 0.85rem;
    color: #566079;
    font-style: italic;
}

.chat-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.chat-form textarea {
    flex: 1;
    min-height: 64px;
    resize: vertical;
    border-radius: 1rem;
    border: 1px solid rgba(29, 35, 48, 0.15);
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #1d2330;
}

.chat-form textarea:focus {
    outline: 2px solid rgba(90, 108, 255, 0.3);
}

.chat-send-button {
    flex: 0 0 auto;
    align-self: stretch;
}

@media (max-width: 600px) {
    .chat-log {
        max-height: 220px;
    }

    .chat-form {
        flex-direction: column;
        align-items: stretch;
    }

    .chat-send-button {
        width: 100%;
    }
}
