/* HUSHIKO App Styles - Extends landing page styles */

/* Import base variables from styles.css */
@import url('styles.css');

/* ===========================
   App Layout
   =========================== */

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-md);
    min-height: calc(100vh - 80px);
}

/* ===========================
   App Navigation (BEM)
   =========================== */

.app-nav {
    background: var(--color-white);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Container */
.app-nav__container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem var(--spacing-md);
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
}

/* Logo */
.app-nav__logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-purple-dark);
    text-decoration: none;
    transition: transform var(--transition-fast);
}

.app-nav__logo:hover {
    transform: scale(1.05);
}

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

.app-nav__logo-img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

/* Navigation Links */
.app-nav__links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.app-nav__link {
    color: var(--color-dark);
    font-weight: 500;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    position: relative;
    display: inline-block;
}

.app-nav__link:hover {
    color: var(--color-purple);
    background: rgba(155, 135, 217, 0.1);
}

.app-nav__link--active {
    color: var(--color-purple);
    font-weight: 600;
}

.app-nav__link--active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 1rem;
    right: 1rem;
    height: 2px;
    background: var(--color-purple);
    border-radius: 2px;
}

.app-nav__link:focus-visible {
    outline: 2px solid var(--color-purple);
    outline-offset: 2px;
}

/* Actions Section (Credits + User Menu) */
.app-nav__actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* User Section */
.app-nav__user {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Credits Badge */
.app-nav__credits {
    background: var(--gradient-hero);
    color: var(--color-white);
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 8px rgba(155, 135, 217, 0.3);
    transition: all var(--transition-fast);
    cursor: default;
}

.app-nav__credits:hover {
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.4);
    transform: translateY(-1px);
}

.app-nav__credits-icon {
    font-size: 1.125rem;
}

.app-nav__credits-count {
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* User Menu */
.app-nav__user-menu {
    position: relative;
}

/* User Avatar */
.app-nav__user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gradient-hero);
    color: var(--color-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.125rem;
    cursor: pointer;
    border: 3px solid var(--color-white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all var(--transition-fast);
    position: relative;
}

.app-nav__user-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.3);
}

.app-nav__user-avatar:focus-visible {
    outline: 2px solid var(--color-purple);
    outline-offset: 2px;
}

.app-nav__user-avatar::after {
    content: '▼';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: var(--color-white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    color: var(--color-purple);
    border: 2px solid var(--color-white);
    transition: transform var(--transition-fast);
}

.app-nav__user-avatar:hover::after {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.app-nav__dropdown {
    position: absolute;
    top: calc(100% + 0.75rem);
    right: 0;
    background: var(--color-white);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-md);
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
    border: 1px solid rgba(0, 0, 0, 0.08);
    overflow: hidden;
    z-index: 100;
}

.app-nav__dropdown--active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.app-nav__dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 12px;
    width: 16px;
    height: 16px;
    background: var(--color-white);
    transform: rotate(45deg);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    border-left: 1px solid rgba(0, 0, 0, 0.08);
}

/* Dropdown Items */
.app-nav__dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    text-align: left;
    width: 100%;
    color: var(--color-dark);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9375rem;
    font-family: inherit;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.app-nav__dropdown-item:hover {
    background: var(--color-cream);
    color: var(--color-purple);
}

.app-nav__dropdown-item:focus-visible {
    outline: 2px solid var(--color-purple);
    outline-offset: -2px;
    background: var(--color-cream);
}

.app-nav__dropdown-item--danger {
    color: var(--color-error);
}

.app-nav__dropdown-item--danger:hover {
    background: #fff5f5;
    color: var(--color-error);
}

.app-nav__dropdown-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.app-nav__dropdown-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    margin: 0.5rem 0;
}

/* Mobile Toggle */
.app-nav__mobile-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.app-nav__mobile-toggle:hover {
    background: rgba(155, 135, 217, 0.1);
}

.app-nav__mobile-toggle:focus-visible {
    outline: 2px solid var(--color-purple);
    outline-offset: 2px;
}

.app-nav__mobile-toggle-bar {
    display: block;
    width: 24px;
    height: 3px;
    background: var(--color-purple);
    border-radius: 2px;
    transition: all var(--transition-fast);
}

.app-nav__mobile-toggle--active .app-nav__mobile-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.app-nav__mobile-toggle--active .app-nav__mobile-line:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.app-nav__mobile-toggle--active .app-nav__mobile-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile toggle line */
.app-nav__mobile-line {
    display: block;
    width: 24px;
    height: 3px;
    background: var(--color-purple);
    border-radius: 2px;
    transition: all var(--transition-fast);
}

.app-nav__mobile-toggle span {
    display: block;
    width: 24px;
    height: 3px;
    background: var(--color-purple);
    border-radius: 2px;
    transition: all var(--transition-fast);
}

.app-nav__mobile-toggle--active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.app-nav__mobile-toggle--active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.app-nav__mobile-toggle--active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile Overlay */
.app-nav__mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    z-index: 80;
}

.app-nav__mobile-overlay--active {
    opacity: 1;
    visibility: visible;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .app-nav__mobile-toggle {
        display: flex;
    }

    .app-nav__actions {
        gap: 1rem;
    }

    .app-nav__links {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: var(--color-white);
        flex-direction: column;
        padding: 1rem;
        gap: 0;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        transform: translateY(-120%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 90;
        border-bottom: 3px solid var(--color-purple);
    }

    .app-nav__links--active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .app-nav__link {
        width: 100%;
        padding: 1rem;
        border-radius: var(--radius-sm);
    }

    .app-nav__link--active::after {
        display: block; /* Keep active indicator visible on mobile */
        bottom: 5px; /* Adjust position for mobile layout */
        left: 1rem;
        right: 1rem;
        width: calc(100% - 2rem);
    }

    .app-nav__user {
        gap: 1rem;
    }

    .app-nav__credits {
        font-size: 0.8125rem;
        padding: 0.5rem 1rem;
    }

    .app-nav__credits-icon {
        font-size: 1rem;
    }

    .app-nav__user-avatar {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    .app-nav__dropdown {
        right: -10px;
    }
}

@media (max-width: 480px) {
    .app-nav__container {
        padding: 0.75rem 1rem;
    }

    .app-nav__logo {
        font-size: 1.25rem;
    }

    .app-nav__logo-img {
        height: 32px;
    }

    .app-nav__logo-icon {
        font-size: 1.5rem;
    }

    .app-nav__credits {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
        gap: 0.375rem;
    }

    .app-nav__credits-icon {
        font-size: 0.875rem;
    }

    .app-nav__user-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.9375rem;
    }

    .app-nav__dropdown {
        min-width: 200px;
        right: -5px;
    }
}

/* ===========================
   Navigation Greeting (Dashboard)
   =========================== */

.app-nav__greeting {
    background: linear-gradient(135deg, rgba(155, 135, 217, 0.05) 0%, rgba(74, 144, 226, 0.05) 100%);
    border-top: 1px solid rgba(155, 135, 217, 0.1);
    padding: 2rem var(--spacing-md);
    text-align: center;
}

.app-nav__greeting-title {
    font-family: var(--font-heading);
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    color: var(--color-purple-dark);
    margin: 0 0 0.5rem 0;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.app-nav__greeting-subtitle {
    font-size: 1.125rem;
    color: var(--color-gray-600);
    margin: 0;
    font-weight: 500;
}

@media (max-width: 768px) {
    .app-nav__greeting {
        padding: 1.5rem 1rem;
    }

    .app-nav__greeting-title {
        font-size: 1.5rem;
    }

    .app-nav__greeting-subtitle {
        font-size: 1rem;
    }
}

/* ===========================
   Auth Pages (Login/Register)
   =========================== */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-cream);
    padding: var(--spacing-md);
}

.auth-card {
    background: var(--color-white);
    padding: 3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 450px;
    width: 100%;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo .logo-icon {
    font-size: 3rem;
}

.auth-logo h1 {
    color: var(--color-purple);
    margin-top: 0.5rem;
    font-size: 2rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* Increased from 0.5rem for better spacing */
}

.form-group label {
    font-weight: 600;
    color: var(--color-dark);
    font-size: 1rem;
    line-height: 1.5;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.875rem 1rem; /* Slightly larger padding for better touch targets */
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all var(--transition-fast);
    font-family: inherit;
    width: 100%; /* Ensure full width */
    max-width: 100%;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-purple);
    box-shadow: 0 0 0 3px rgba(155, 135, 217, 0.1);
}

.form-group input:hover:not(:focus),
.form-group select:hover:not(:focus),
.form-group textarea:hover:not(:focus) {
    border-color: #c0c0c0;
}

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

.form-group textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.form-error {
    color: var(--color-error);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Responsive form elements */
@media (max-width: 480px) {
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevent iOS zoom on focus */
        padding: 0.75rem;
    }

    .form-group label {
        font-size: 0.9375rem;
    }
}

.auth-footer {
    text-align: center;
    margin-top: 2rem;
    color: var(--color-gray-600);
}

.auth-footer a {
    color: var(--color-purple);
    font-weight: 600;
}

/* ===========================
   Dashboard
   =========================== */

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--color-white);
    padding: 2rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.stat-icon {
    font-size: 3rem;
}

.stat-content h3 {
    color: var(--color-purple-dark);
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.stat-content p {
    color: var(--color-gray-600);
    margin: 0;
}

/* Mini Loaders - dopasowane do rozmiaru elementu */
.mini-loader {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid rgba(155, 135, 217, 0.2);
    border-top-color: var(--color-purple);
    border-radius: 50%;
    animation: mini-spin 0.8s linear infinite;
    vertical-align: middle;
}

/* Loader dla stat cards - większy */
.stat-content h3 .mini-loader {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 3px;
}

/* Loader dla sekcji - średni */
.section-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    gap: 1rem;
    color: var(--color-gray-500);
    font-size: 0.9rem;
}

.section-loader .mini-loader {
    width: 1.5rem;
    height: 1.5rem;
}

/* Inline variant - mniejszy padding */
.section-loader--inline {
    padding: 1.5rem;
}

/* Skeleton loader dla kart */
.skeleton-card {
    background: linear-gradient(90deg,
        rgba(155, 135, 217, 0.08) 25%,
        rgba(155, 135, 217, 0.15) 50%,
        rgba(155, 135, 217, 0.08) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-md);
    min-height: 200px;
}

.skeleton-card--small {
    min-height: 120px;
}

@keyframes mini-spin {
    to { transform: rotate(360deg); }
}

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

.dashboard-sections {
    display: grid;
    gap: var(--spacing-lg);
}

.dashboard-section {
    background: var(--color-white);
    padding: 2rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.section-header h2 {
    color: var(--color-purple-dark);
}

/* ===========================
   Story Cards
   =========================== */

.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.story-card {
    background: var(--color-white);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    cursor: pointer;
}

.story-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.story-card-image {
    position: relative;
    width: 100%;
    padding-top: 66.67%; /* 3:2 aspect ratio */
    background: var(--color-cream);
    overflow: hidden;
}

.story-card-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    background: var(--gradient-bedtime);
}

.status-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-white);
}

.status-badge.processing {
    background: #ff9800;
}

.status-badge.ready {
    background: #4caf50;
}

.status-badge.completed {
    background: var(--color-purple);
}

.status-badge.failed {
    background: var(--color-error);
}

.story-card-content {
    padding: 1rem 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.story-card-title {
    color: var(--color-dark);
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.story-card-subtitle {
    color: var(--color-gray-600);
    font-size: 0.8rem;
    font-style: italic;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.story-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--color-gray-600);
    font-size: 0.8rem;
    margin: 0;
}

.story-card-language {
    background: var(--color-cream);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.story-card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: nowrap;
    min-height: 44px;
}

.btn-play,
.btn-delete,
.btn-pdf {
    flex-shrink: 0;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    white-space: nowrap;
    font-size: 0.875rem;
}

.btn-play {
    flex: 1;
    background: linear-gradient(135deg, var(--color-purple) 0%, #B794F6 100%);
    color: var(--color-white);
    box-shadow: 0 2px 8px rgba(155, 135, 217, 0.3);
}

.btn-play:hover {
    background: linear-gradient(135deg, #8B6EAD 0%, #A78BEE 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.4);
}

.btn-delete {
    background: var(--color-cream);
    color: var(--color-gray-600);
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
}

.btn-delete:hover {
    background: #ffe6e6;
    color: var(--color-error);
    transform: scale(1.1);
}

/* ===========================
   Child Cards - IMPROVED DESIGN
   =========================== */

.children-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

/* ========== Base Card Styles ========== */
.child-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px solid transparent;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.child-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(155, 135, 217, 0.15);
    border-color: rgba(155, 135, 217, 0.3);
}

/* ========== Selected State (Very Prominent) ========== */
.child-card.selected {
    border-color: var(--color-purple);
    background: linear-gradient(135deg, #ffffff 0%, #faf8fc 100%);
    box-shadow: 0 8px 24px rgba(155, 135, 217, 0.25);
}

.child-card.selected:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 32px rgba(155, 135, 217, 0.3);
}

/* Selected Badge */
.selected-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--gradient-hero);
    color: var(--color-white);
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(155, 135, 217, 0.4);
    z-index: 10;
}

/* ========== Card Header (Avatar Section) ========== */
.child-card-header {
    padding: 2rem 1.5rem 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg, var(--color-cream) 0%, transparent 100%);
}

.child-avatar {
    font-size: 4.5rem;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fff 0%, var(--color-cream) 100%);
    border-radius: 50%;
    border: 4px solid var(--color-white);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.child-card:hover .child-avatar {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(155, 135, 217, 0.2);
}

.child-card.selected .child-avatar {
    border-color: var(--color-purple);
    box-shadow: 0 6px 20px rgba(155, 135, 217, 0.3);
}

/* ========== Card Body (Text Content) ========== */
.child-card-body {
    padding: 0.5rem 1.5rem 1.5rem;
    text-align: center;
    flex: 1;
}

.child-name {
    color: var(--color-purple);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.child-age {
    color: var(--color-gray-600);
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
    letter-spacing: 0.01em;
}

/* ========== Character Type Badge ========== */
.character-type-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    background: white;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 2px solid var(--color-cream);
    transition: all 0.3s ease;
}

.character-type-badge:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.2);
}

/* ========== Visual Config Badge ========== */
.visual-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    background: linear-gradient(135deg, rgba(155, 135, 217, 0.1) 0%, rgba(255, 159, 102, 0.1) 100%);
    border: 1px solid rgba(155, 135, 217, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-purple);
    margin-top: 0.5rem;
    cursor: help;
    transition: all 0.3s ease;
}

.visual-badge:hover {
    background: linear-gradient(135deg, rgba(155, 135, 217, 0.15) 0%, rgba(255, 159, 102, 0.15) 100%);
    border-color: rgba(155, 135, 217, 0.3);
    transform: translateY(-1px);
}

/* ========== Card Actions ========== */
.child-card-actions {
    padding: 0 1.5rem 1.5rem;
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    justify-content: center;
}

/* Primary Select Button */
.btn-select-child,
.btn-selected-child {
    width: 100%;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    letter-spacing: 0.3px;
}

.btn-select-child {
    background: var(--gradient-hero);
    color: var(--color-white);
    box-shadow: 0 2px 8px rgba(155, 135, 217, 0.3);
}

.btn-select-child:hover {
    background: linear-gradient(135deg, #8B6EAD 0%, var(--color-purple) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.4);
}

.btn-select-child:active {
    transform: translateY(0);
}

/* Selected State Button (Disabled) */
.btn-selected-child {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: var(--color-white);
    cursor: not-allowed;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.btn-icon-inline {
    font-size: 1.1rem;
}

/* Secondary Actions Row (Edit/Delete) */
.child-card-secondary-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.btn-icon-secondary {
    flex: 1;
    max-width: 80px;
    padding: 0.4rem 0.6rem;
    border: 1.5px solid #e0e0e0;
    background: var(--color-white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.btn-icon-secondary:hover {
    background: var(--color-cream);
    border-color: var(--color-purple);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-icon-secondary.delete:hover {
    background: #fff5f5;
    border-color: var(--color-error);
}

/* ========== Add Child Card ========== */
.add-child-card {
    background: linear-gradient(135deg, var(--color-cream) 0%, #fff 100%);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px dashed rgba(155, 135, 217, 0.4);
    min-height: 320px;
    padding: 2rem;
}

.add-child-card:hover {
    background: var(--color-white);
    border-color: var(--color-purple);
    border-style: solid;
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(155, 135, 217, 0.15);
}

.add-child-card .icon {
    font-size: 4rem;
    color: var(--color-purple);
    transition: transform 0.3s ease;
}

.add-child-card:hover .icon {
    transform: scale(1.1);
}

.add-child-card p {
    color: var(--color-purple);
    font-weight: 600;
    font-size: 1.125rem;
    margin: 0;
}

/* ========== Responsive Adjustments ========== */
@media (max-width: 768px) {
    .children-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1.5rem;
    }

    .child-avatar {
        width: 90px;
        height: 90px;
        font-size: 4rem;
    }

    .child-name {
        font-size: 1.35rem;
    }
}

@media (max-width: 480px) {
    .children-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .selected-badge {
        font-size: 0.7rem;
        padding: 0.35rem 0.75rem;
    }
}

/* ===========================
   Audio Player
   =========================== */

.audio-player {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
}

.player-images {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    background: var(--color-dark);
    overflow: hidden;
}

.image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.player-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;  /* Fill entire player width with no margins */
    object-position: center;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.image-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-cream) 0%, var(--color-beige) 100%);
    gap: 1rem;
}

.placeholder-spinner {
    font-size: 3rem;
    animation: pulse 2s ease-in-out infinite;
}

.placeholder-text {
    font-size: 1rem;
    color: var(--color-dark-gray);
    font-weight: 500;
}

.placeholder-failed .placeholder-spinner {
    animation: none;
}

.placeholder-failed {
    background: linear-gradient(135deg, #ffe5e5 0%, #ffcccc 100%);
}

.image-error-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--color-beige);
    gap: 0.5rem;
}

.image-error-fallback .placeholder-icon {
    font-size: 2.5rem;
    opacity: 0.5;
}

.image-error-fallback .placeholder-text {
    font-size: 0.875rem;
    color: var(--color-gray);
}

.hidden {
    display: none !important;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

/* Responsive image handling for different devices */
@media (min-aspect-ratio: 3/4) and (max-aspect-ratio: 4/3) {
    /* Tablets (iPad 4:3) - crop sides to fit */
    .player-image {
        object-fit: cover;
        object-position: center;
    }
}

@media (max-width: 768px) and (orientation: portrait) {
    /* Mobile portrait - crop to fit */
    .player-image {
        object-fit: cover;
        object-position: center;
    }
}

.player-karaoke {
    padding: 0.5rem 1rem 0 1rem; /* Top padding only - no vertical centering */
    background: var(--color-cream);
    height: 2.75rem; /* Exact height: 2.25rem (line) + 0.5rem (top padding) */
    overflow: hidden;
    display: flex;
    align-items: flex-start; /* Top-align instead of center - critical! */
    justify-content: center;
}

.karaoke-text {
    font-size: 1.5rem;
    line-height: 1.5; /* Reduced from 1.8 - less spacing = more accurate scroll */
    color: var(--color-dark);
    overflow: hidden; /* Hide overflow text */
    position: relative;
    width: 100%;
    height: 2.25rem; /* Show only one line (font-size × line-height = 1.5 × 1.5 = 2.25rem) */
    text-align: center;
}

.karaoke-paragraph {
    display: block;
    margin: 0;
    white-space: nowrap; /* Keep line on one row, no wrapping */
}

.karaoke-word {
    display: inline;
    transition: all 0.2s ease;
    cursor: pointer;
    padding: 0 0.15rem;
}

.karaoke-word.active {
    color: var(--color-purple);
    font-weight: 700;
    transform: scale(1.05);
    display: inline-block; /* Allow transform */
}

/* Responsive karaoke font sizes */
@media (max-width: 767px) {
    .karaoke-text {
        font-size: 1rem;
        line-height: 1.3;
    }

    .player-karaoke {
        height: 50px;
        min-height: 50px;
        padding: 0.5rem 1rem;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .karaoke-text {
        font-size: 1.2rem;
        line-height: 1.35;
    }

    .player-karaoke {
        height: 60px;
        min-height: 60px;
        padding: 0.75rem 1.5rem;
    }
}

@media (min-width: 1024px) {
    .karaoke-text {
        font-size: 1.5rem;
        line-height: 1.4;
    }

    .player-karaoke {
        height: 70px;
        min-height: 70px;
        padding: 1rem 2rem;
    }
}

.player-controls {
    padding: 1rem 2rem;
    background: var(--color-white);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.player-controls-main {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.btn-play-pause {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--color-purple);
    color: var(--color-white);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-play-pause:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.btn-fullscreen {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f0f0f0;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-fullscreen:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

.player-progress {
    flex: 1;
}

.progress-bar {
    position: relative;
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 6px;
    background: var(--color-purple);
    border-radius: 3px;
    transition: width 0.1s ease;
    pointer-events: none; /* Don't block slider interaction */
}

.progress-bar input[type="range"] {
    position: absolute;
    top: -8px; /* Extend hit area above and below */
    left: 0;
    width: 100%;
    height: 22px; /* Larger touch target */
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
    margin: 0; /* Remove default margin */
}

/* Better touch targets for mobile */
@media (max-width: 768px) {
    .progress-bar {
        height: 8px;
    }

    .progress-fill {
        height: 8px;
    }

    .progress-bar input[type="range"] {
        top: -12px; /* Even larger hit area */
        height: 32px;
    }
}

.progress-time {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--color-gray-600);
}

.player-volume {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.player-volume button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

.player-volume input[type="range"] {
    flex: 1;
    max-width: 100px;
}

/* Fullscreen mode */
.audio-player.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    border-radius: 0;
}

.audio-player.fullscreen .player-images {
    height: calc(100vh - 160px);
    padding-top: 0;
}

.audio-player.fullscreen .player-karaoke {
    height: 60px;
    padding: 0.5rem 2rem;
}

.audio-player.fullscreen .karaoke-text {
    font-size: 1.8rem;
}

/* Hide navigation in fullscreen mode */
.audio-player.fullscreen ~ .app-nav,
body:has(.audio-player.fullscreen) .app-nav {
    display: none;
}

/* Landscape orientation optimizations for MOBILE ONLY */
@media (max-width: 896px) and (orientation: landscape) and (max-height: 500px) {
    /* Player page: make header overlay (not pushing content) */
    .app-nav {
        position: fixed;
        width: 100%;
        top: 0;
        left: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        z-index: 1001;
        transform: translateY(-100%);
        transition: transform 0.3s ease;
    }

    /* Show header on hover/touch at top edge */
    .app-nav:hover,
    .app-nav:focus-within {
        transform: translateY(0);
    }

    /* Player content should start from top (header overlays it) */
    .app-container {
        padding-top: 0;
    }

    /* Fullscreen mode: reduce heights to fit controls on screen */
    .audio-player.fullscreen {
        display: flex;
        flex-direction: column;
        height: 100vh;
    }

    .audio-player.fullscreen .player-images {
        flex: 1;
        padding-top: 0;
        min-height: 0; /* Allow flex shrink */
    }

    .audio-player.fullscreen .image-container {
        position: relative;
        width: 100%;
        height: 100%;
    }

    .audio-player.fullscreen .player-karaoke {
        height: 45px;
        min-height: 45px;
        padding: 0.5rem 1rem;
        flex-shrink: 0;
    }

    .audio-player.fullscreen .karaoke-text {
        font-size: 1.1rem;
        line-height: 1.4;
    }

    .audio-player.fullscreen .player-controls {
        padding: 0.75rem 1rem;
        flex-shrink: 0;
    }

    .audio-player.fullscreen .player-controls-main {
        gap: 0.5rem;
    }

    .audio-player.fullscreen .btn-play-pause {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .audio-player.fullscreen .player-volume {
        display: none; /* Hide volume controls to save space */
    }
}

/* ===========================
   IMMERSIVE PLAYER (Cinema Mode)
   =========================== */

.audio-player.immersive {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: #000;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}

/* Full-screen background image */
.immersive .player-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.immersive .player-background .player-image,
.immersive .player-background .image-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.immersive .player-background .image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(155, 135, 217, 0.3) 0%, rgba(255, 159, 102, 0.2) 100%);
}

/* Gradient overlay - only bottom 50% */
.immersive .player-gradient-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    /* Auto-hide animation */
    transition: opacity 0.3s ease;
    opacity: 1;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 40%,
        rgba(0, 0, 0, 0.4) 65%,
        rgba(0, 0, 0, 0.85) 100%
    );
}

.immersive .player-gradient-overlay.hidden {
    opacity: 0;
}

/* Header bar (back button, title, badge) */
.immersive .player-header-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 100%);
    /* Auto-hide animation */
    transition: opacity 0.3s ease, visibility 0.3s ease;
    opacity: 1;
    visibility: visible;
}

.immersive .player-header-bar.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.immersive .player-back-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.immersive .player-back-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

.immersive .player-title {
    flex: 1;
    margin: 0 1rem;
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Image counter badge */
.immersive .player-image-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 0.8125rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* Bottom content container */
.immersive .player-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    padding: 0 1.5rem 1.5rem;
}

/* Karaoke overlay on image - positioned absolutely for independent animation */
.immersive .player-karaoke-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 140px; /* Above controls */
    z-index: 15;
    padding: 1rem 2rem;
    text-align: center;
    /* Animate position when controls hide/show */
    transition: bottom 0.3s ease;
}

/* When controls are hidden, karaoke moves to bottom of screen */
.immersive .player-karaoke-overlay.controls-hidden {
    bottom: 40px;
}

.immersive .karaoke-line {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
    max-width: 100%;
}

.immersive .karaoke-word {
    display: inline-block;
    font-size: 1.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 4px 12px rgba(0, 0, 0, 0.5);
    transition: all 0.15s ease;
    padding: 0 0.1rem;
}

.immersive .karaoke-word.active {
    color: white;
    font-weight: 700;
    transform: scale(1.05);
}

/* Glassmorphic controls */
.immersive .player-glass-controls {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 1rem 1.25rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    /* Auto-hide animation */
    transition: opacity 0.3s ease, visibility 0.3s ease;
    opacity: 1;
    visibility: visible;
}

.immersive .player-glass-controls.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Progress row */
.immersive .glass-progress-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.immersive .glass-time {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8125rem;
    font-weight: 500;
    min-width: 40px;
    text-align: center;
}

.immersive .glass-progress {
    flex: 1;
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    cursor: pointer;
}

.immersive .glass-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: white;
    border-radius: 2px;
    transition: width 0.1s linear;
    pointer-events: none;
}

.immersive .glass-progress input[type="range"] {
    position: absolute;
    top: -10px;
    left: 0;
    width: 100%;
    height: 24px;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

/* Controls row */
.immersive .glass-controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Glass button base */
.immersive .glass-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.125rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.immersive .glass-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.immersive .glass-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.immersive .glass-btn.active {
    background: rgba(155, 135, 217, 0.4);
    border-color: rgba(155, 135, 217, 0.5);
}

/* Main play button - larger */
.immersive .glass-btn-main {
    width: 60px;
    height: 60px;
    background: rgba(155, 135, 217, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 1.5rem;
    box-shadow: 0 4px 20px rgba(155, 135, 217, 0.4);
}

.immersive .glass-btn-main:hover {
    background: rgba(155, 135, 217, 0.5);
    box-shadow: 0 6px 24px rgba(155, 135, 217, 0.5);
}

/* Speed button text */
.immersive .glass-btn-speed {
    font-size: 0.75rem;
    font-weight: 700;
}

/* Click anywhere to play/pause hint */
.immersive .player-click-area {
    position: absolute;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 200px;
    z-index: 5;
    cursor: pointer;
}

/* Loading state */
.immersive .player-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    color: white;
    text-align: center;
}

.immersive .player-loading .loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive adjustments for immersive player */
@media (max-width: 768px) {
    .immersive .player-header-bar {
        padding: 0.75rem 1rem;
    }

    .immersive .player-back-btn {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .immersive .player-title {
        font-size: 1rem;
    }

    .immersive .player-bottom {
        padding: 0 1rem 1rem;
    }

    .immersive .karaoke-word {
        font-size: 1.25rem;
    }

    .immersive .player-karaoke-overlay {
        bottom: 120px; /* Smaller controls on mobile */
        padding: 0.75rem 1rem;
    }

    .immersive .player-karaoke-overlay.controls-hidden {
        bottom: 30px;
    }

    .immersive .player-glass-controls {
        padding: 0.75rem 1rem;
        border-radius: 20px;
    }

    .immersive .glass-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .immersive .glass-btn-main {
        width: 52px;
        height: 52px;
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .immersive .karaoke-word {
        font-size: 1.125rem;
    }

    .immersive .glass-controls-row {
        gap: 0.25rem;
    }

    .immersive .glass-btn {
        width: 36px;
        height: 36px;
    }

    .immersive .glass-btn-main {
        width: 48px;
        height: 48px;
    }
}

/* Large screens */
@media (min-width: 1200px) {
    .immersive .player-header-bar {
        padding: 1.5rem 2rem;
    }

    .immersive .player-title {
        font-size: 1.5rem;
    }

    .immersive .player-bottom {
        padding: 0 2rem 2rem;
        max-width: 900px;
        margin: 0 auto;
        width: 100%;
    }

    .immersive .karaoke-word {
        font-size: 2rem;
    }
}

/* Hide navigation when immersive player is active */
body:has(.audio-player.immersive) .app-nav,
body:has(.audio-player.immersive) .player-header {
    display: none !important;
}

/* ===========================
   Generator Page - IMPROVED LAYOUT
   =========================== */

.generator-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: var(--spacing-md);
}

.generator-form {
    background: var(--color-white);
    padding: 3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 2rem; /* Consistent spacing between form groups */
}

/* Ensure form groups have consistent spacing */
.generator-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .generator-container {
        padding: var(--spacing-sm);
    }

    .generator-form {
        padding: 2rem 1.5rem;
        gap: 1.5rem;
    }
}

@media (max-width: 480px) {
    .generator-form {
        padding: 1.5rem 1rem;
        gap: 1.25rem;
    }
}

.child-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.child-option {
    padding: 1.5rem;
    background: var(--color-cream);
    border: 3px solid transparent;
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.child-option:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.child-option.selected {
    border-color: var(--color-purple);
    background: var(--color-white);
}

.child-option .avatar {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.child-option .name {
    font-weight: 600;
    color: var(--color-dark);
}

.theme-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.theme-tag {
    padding: 0.5rem 1rem;
    background: var(--color-cream);
    border: 2px solid var(--color-purple);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: 0.875rem;
    font-weight: 500;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.theme-tag.selected {
    background: var(--gradient-hero);
    color: var(--color-white);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.4);
    border-color: transparent;
}

.theme-tag:hover {
    background: var(--color-purple);
    color: var(--color-white);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.3);
}

.theme-tag:active {
    transform: translateY(0) scale(0.98);
}

/* Loading state for themes */
.themes-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    color: #666;
    font-size: 0.875rem;
}

.themes-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-purple);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===========================
   GENERATOR PAGE - NEW UI (2025)
   =========================== */

/* Generator Header with Credits */
.generator-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.generator-header-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-dark);
    margin: 0 0 0.25rem 0;
}

.generator-header-content p {
    font-size: 0.9375rem;
    color: #666;
    margin: 0;
}

.generator-credits-badge {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(155, 135, 217, 0.12) 0%, rgba(255, 159, 102, 0.12) 100%);
    border: 2px solid rgba(155, 135, 217, 0.3);
    border-radius: 50px;
    flex-shrink: 0;
}

.generator-credits-badge .credits-icon {
    font-size: 1rem;
}

.generator-credits-badge .credits-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-purple);
    font-family: 'Quicksand', sans-serif;
}

.generator-credits-badge .credits-label {
    font-size: 0.75rem;
    color: #666;
}

/* Visual Stepper */
.generator-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 1rem 1.5rem;
    margin-bottom: 1.25rem;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.stepper-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    position: relative;
}

.stepper-step .step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.stepper-step .step-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.stepper-step.active .step-number {
    background: var(--gradient-hero);
    color: white;
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.4);
}

.stepper-step.active .step-label {
    color: var(--color-purple);
}

.stepper-step.completed .step-number {
    background: #4CAF50;
    color: white;
}

.stepper-step.completed .step-label {
    color: #4CAF50;
}

.stepper-connector {
    width: 50px;
    height: 2px;
    background: #e0e0e0;
    border-radius: 2px;
    transition: background 0.3s ease;
}

.stepper-connector.active {
    background: var(--gradient-hero);
}

/* Step Cards */
.step-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 1rem;
    overflow: visible;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.step-card:hover {
    box-shadow: var(--shadow-lg);
}

.step-card:focus-within {
    border-color: var(--color-purple);
}

.step-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(155, 135, 217, 0.05) 0%, rgba(255, 159, 102, 0.05) 100%);
    border-bottom: 1px solid rgba(155, 135, 217, 0.1);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.step-card-number {
    display: flex;
    align-items: baseline;
    gap: 2px;
    padding: 0.375rem 0.625rem;
    background: var(--gradient-hero);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.step-card-number .current {
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.step-card-number .separator {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

.step-card-number .total {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

.step-card-title {
    flex: 1;
}

.step-card-title h2 {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--color-dark);
    margin: 0;
    font-family: 'Quicksand', sans-serif;
    line-height: 1.3;
}

.step-card-title p {
    font-size: 0.8125rem;
    color: #666;
    margin: 0.25rem 0 0 0;
}

.optional-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: #e8f5e9;
    color: #4CAF50;
    border-radius: var(--radius-full);
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
    margin-left: 0.5rem;
}

.step-card-content {
    padding: 1.25rem 1.5rem 1.5rem;
    overflow: visible;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Theme Tiles Grid */
.theme-tiles-container {
    margin-bottom: 1.25rem;
    overflow: visible;
}

.theme-tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    overflow: visible;
    padding: 0.5rem;
}

.theme-tiles-grid .theme-tag {
    position: relative;
    padding: 0.625rem 0.75rem;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-align: left;
    font-size: 0.75rem;
    line-height: 1.3;
    min-height: 44px;
    overflow: visible;
}

.theme-tiles-grid .theme-tag .theme-text {
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.8125rem;
    color: #333;
}

.theme-tiles-grid .theme-tag:hover {
    border-color: var(--color-purple);
    background: rgba(155, 135, 217, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.15);
    color: #333;
}

.theme-tiles-grid .theme-tag:hover .theme-text {
    color: #333;
}

.theme-tiles-grid .theme-tag.selected {
    border-color: var(--color-purple);
    background: linear-gradient(135deg, rgba(155, 135, 217, 0.1) 0%, rgba(255, 159, 102, 0.1) 100%);
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.2);
}

.theme-tiles-grid .theme-tag.selected::before {
    content: '✓';
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background: var(--gradient-hero);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    font-weight: bold;
    z-index: 10;
    pointer-events: none;
}

/* Loading spinner small */
.loading-spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(155, 135, 217, 0.3);
    border-top-color: var(--color-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Custom Theme Input */
.custom-theme-input {
    border-top: 1px solid #e0e0e0;
    padding-top: 1rem;
}

.custom-theme-input label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 0.5rem;
}

.textarea-wrapper {
    position: relative;
}

.textarea-wrapper textarea {
    width: 100%;
    padding: 0.75rem;
    padding-bottom: 1.5rem;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-family: inherit;
    resize: vertical;
    min-height: 70px;
    transition: all 0.2s ease;
}

.textarea-wrapper textarea:focus {
    border-color: var(--color-purple);
    outline: none;
    box-shadow: 0 0 0 3px rgba(155, 135, 217, 0.1);
}

.char-counter {
    position: absolute;
    bottom: 0.5rem;
    right: 0.75rem;
    font-size: 0.6875rem;
    color: #999;
}

.char-counter span:first-child {
    transition: color 0.2s ease;
}

.textarea-wrapper textarea:focus + .char-counter span:first-child {
    color: var(--color-purple);
}

/* Language Tiles */
.language-tiles-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.language-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.625rem 0.5rem;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.language-tile:hover {
    border-color: var(--color-purple);
    background: rgba(155, 135, 217, 0.05);
    transform: translateY(-2px);
}

.language-tile.selected {
    border-color: var(--color-purple);
    background: linear-gradient(135deg, rgba(155, 135, 217, 0.1) 0%, rgba(255, 159, 102, 0.1) 100%);
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.2);
}

.language-tile .lang-flag {
    font-size: 1.5rem;
}

.language-tile .lang-native {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-dark);
}

/* Number of Characters Slider */
.num-characters-container {
    margin-top: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(155, 135, 217, 0.05) 0%, rgba(255, 159, 102, 0.05) 100%);
    border-radius: var(--radius-md);
    border: 2px dashed rgba(155, 135, 217, 0.3);
}

.num-characters-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #666;
}

.num-characters-icon {
    font-size: 1rem;
}

.num-characters-slider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.num-characters-slider .slider-btn {
    width: 36px;
    height: 36px;
    border: 2px solid var(--color-purple);
    border-radius: 50%;
    background: white;
    color: var(--color-purple);
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.num-characters-slider .slider-btn:hover {
    background: var(--color-purple);
    color: white;
}

.num-characters-slider .slider-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.num-characters-slider .slider-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    min-width: 80px;
}

.num-characters-slider .slider-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-purple);
    line-height: 1;
    font-family: 'Quicksand', sans-serif;
}

.num-characters-slider .slider-unit {
    font-size: 0.625rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Submit Section */
.generator-submit-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-top: 0.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.submit-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.submit-cost {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: #666;
    flex-wrap: wrap;
}

.submit-cost .cost-icon {
    font-size: 1rem;
}

.submit-cost strong {
    color: var(--color-purple);
    font-size: 1rem;
}

.submit-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
}

.btn-back .btn-icon {
    font-size: 0.875rem;
}

.btn-generate {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    background: var(--gradient-hero);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.3);
    white-space: nowrap;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(155, 135, 217, 0.4);
}

.btn-generate .btn-icon {
    font-size: 1rem;
}

/* Generating Screen */
.generating-screen {
    margin-top: 1.5rem;
}

.generating-card {
    background: white;
    padding: 3rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.generating-animation {
    margin-bottom: 2rem;
}

.fairy-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

.fairy-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(155, 135, 217, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    animation: pulseGlow 2s ease-in-out infinite;
}

.fairy {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    animation: floatFairy 3s ease-in-out infinite;
}

.sparkles {
    position: absolute;
    inset: 0;
}

.sparkle {
    position: absolute;
    font-size: 1.25rem;
    opacity: 0;
    animation: sparkle 2s ease-in-out infinite;
}

.sparkle:nth-child(1) { top: 10%; left: 20%; animation-delay: 0s; }
.sparkle:nth-child(2) { top: 20%; right: 15%; animation-delay: 0.3s; }
.sparkle:nth-child(3) { bottom: 30%; left: 10%; animation-delay: 0.6s; }
.sparkle:nth-child(4) { bottom: 20%; right: 20%; animation-delay: 0.9s; }
.sparkle:nth-child(5) { top: 40%; left: 5%; animation-delay: 1.2s; }
.sparkle:nth-child(6) { top: 35%; right: 5%; animation-delay: 1.5s; }

@keyframes pulseGlow {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 0.5; }
}

@keyframes floatFairy {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-8px) rotate(3deg); }
    75% { transform: translateY(4px) rotate(-3deg); }
}

@keyframes sparkle {
    0%, 100% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 1; transform: scale(1.2); }
}

.generating-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-dark);
    margin: 0 0 0.5rem 0;
    font-family: 'Quicksand', sans-serif;
}

.generating-subtitle {
    font-size: 1rem;
    color: #666;
    margin: 0 0 2rem 0;
}

/* Progress Bar */
.generating-progress {
    max-width: 500px;
    margin: 0 auto 2rem;
}

.progress-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--gradient-hero);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-stages {
    display: flex;
    justify-content: space-between;
}

.progress-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    opacity: 0.4;
    transition: all 0.3s ease;
}

.progress-stage.active {
    opacity: 1;
}

.progress-stage.completed {
    opacity: 1;
}

.progress-stage.completed .stage-icon {
    transform: scale(1.1);
}

.progress-stage .stage-icon {
    font-size: 1.25rem;
    transition: transform 0.3s ease;
}

.progress-stage .stage-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Generating Info Box */
.generating-info {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(155, 135, 217, 0.08) 0%, rgba(255, 159, 102, 0.08) 100%);
    border-radius: var(--radius-md);
    border: 2px solid rgba(155, 135, 217, 0.2);
    text-align: left;
    max-width: 500px;
    margin: 0 auto;
}

.generating-info .info-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.generating-info p {
    font-size: 0.875rem;
    color: #666;
    line-height: 1.6;
    margin: 0;
}

.generating-info a {
    color: var(--color-purple);
    text-decoration: underline;
    font-weight: 600;
}

/* Responsive - Generator Page */
@media (max-width: 768px) {
    .generator-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .generator-header-content h1 {
        font-size: 1.5rem;
    }

    .generator-credits-badge {
        align-self: flex-start;
        padding: 0.5rem 1rem;
    }

    .generator-credits-badge .credits-value {
        font-size: 1.25rem;
    }

    .generator-stepper {
        gap: 0;
        padding: 0.75rem 1rem;
    }

    .stepper-step {
        padding: 0.25rem 0.5rem;
    }

    .stepper-step .step-number {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .stepper-step .step-label {
        font-size: 0.5625rem;
    }

    .stepper-connector {
        width: 24px;
    }

    .step-card-header {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .step-card-title h2 {
        font-size: 0.9375rem;
    }

    .step-card-title p {
        font-size: 0.75rem;
    }

    .step-card-content {
        padding: 1rem;
    }

    .theme-tiles-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .language-tiles-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .generator-submit-section {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }

    .submit-actions {
        width: 100%;
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .submit-actions .btn-back,
    .submit-actions .btn-generate {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .generator-stepper {
        flex-wrap: wrap;
        justify-content: center;
        padding: 0.625rem 0.75rem;
    }

    .stepper-connector {
        display: none;
    }

    .stepper-step {
        flex: 0 0 auto;
    }

    .theme-tiles-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .language-tiles-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.375rem;
    }

    .language-tile {
        padding: 0.5rem 0.25rem;
    }

    .language-tile .lang-flag {
        font-size: 1.25rem;
    }

    .language-tile .lang-native {
        font-size: 0.5625rem;
    }
}

/* Character Selection - IMPROVED LAYOUT */
.character-profiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.character-profile {
    background: var(--color-white);
    border: 3px solid #e0e0e0;
    border-radius: var(--radius-md);
    padding: 1.25rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.character-profile:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(155, 135, 217, 0.15);
    border-color: var(--color-purple);
}

.character-profile.selected {
    border-color: var(--color-purple);
    background: linear-gradient(135deg, #faf8fc 0%, #ffffff 100%);
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.2);
}

.character-profile.selected::after {
    content: '✓';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    background: var(--gradient-hero);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(155, 135, 217, 0.4);
}

.character-profile .profile-avatar {
    font-size: 3rem;
    margin-bottom: 0.25rem;
    line-height: 1;
    transition: transform var(--transition-fast);
}

/* SVG avatars in generator - limit size to fit container */
.character-profile .profile-avatar svg {
    width: 64px;
    height: 64px;
    max-width: 100%;
    display: block;
    margin: 0 auto;
}

.character-profile:hover .profile-avatar {
    transform: scale(1.1);
}

.character-profile .profile-name {
    font-weight: 600;
    color: var(--color-dark);
    font-size: 0.9375rem;
    line-height: 1.3;
}

.character-profile .profile-age {
    font-size: 0.8125rem;
    color: var(--color-gray-600);
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .character-profiles {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.875rem;
    }

    .character-profile {
        padding: 1rem 0.75rem;
    }

    .character-profile .profile-avatar {
        font-size: 2.5rem;
    }

    .character-profile .profile-name {
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .character-profiles {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.75rem;
    }

    .character-profile {
        padding: 0.875rem 0.5rem;
    }

    .character-profile .profile-avatar {
        font-size: 2.25rem;
    }
}

/* Selected Characters */
.selected-characters {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.character-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 2px solid #e0e0e0;
    transition: all var(--transition-fast);
}

.character-card:hover {
    border-color: var(--color-purple);
    box-shadow: var(--shadow-sm);
}

.character-number {
    width: 32px;
    height: 32px;
    background: var(--color-purple);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.character-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.char-name-input,
.char-role-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d0d0d0;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: var(--font-primary);
    transition: border-color var(--transition-fast);
}

.char-name-input:focus,
.char-role-input:focus {
    outline: none;
    border-color: var(--color-purple);
    box-shadow: 0 0 0 3px rgba(155, 135, 217, 0.1);
}

.char-name-input {
    font-weight: 600;
}

.char-role-input {
    font-style: italic;
    color: var(--color-gray);
}

.btn-remove {
    background: var(--color-error);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-remove:hover {
    background: #ff3838;
    transform: scale(1.05);
}

.btn-custom-character {
    width: 100%;
    padding: 1rem;
    background: var(--color-cream);
    border: 2px dashed var(--color-purple);
    border-radius: var(--radius-md);
    color: var(--color-purple);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-custom-character:hover {
    background: white;
    border-style: solid;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.character-limit {
    font-size: 0.875rem;
    color: var(--color-gray);
    margin-top: 0.5rem;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .character-profiles {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .character-card {
        flex-direction: column;
        text-align: center;
    }

    .btn-remove {
        width: 100%;
    }
}

.theme-tag:hover {
    background: var(--color-purple);
    color: var(--color-white);
}

/* ===========================
   AI Preview Modal
   =========================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.preview-modal {
    position: relative;
    background: white;
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 1;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--color-dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--color-gray-500);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: #f0f0f0;
    color: var(--color-dark);
}

.preview-loading {
    text-align: center;
    padding: 3rem 1rem;
}

.preview-loading p {
    margin-top: 1rem;
    color: var(--color-gray-600);
    font-size: 1rem;
}

.preview-content {
    animation: fadeIn 0.3s ease;
}

.preview-characters {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.preview-character-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 2px solid #e0e0e0;
    transition: all var(--transition-fast);
    animation: slideInLeft 0.4s ease;
}

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

.preview-character-card:hover {
    border-color: var(--color-purple);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.preview-char-number {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--color-purple) 0%, var(--color-purple-dark) 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.125rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.3);
}

.preview-char-content {
    flex: 1;
}

.preview-char-name {
    font-size: 1.25rem;
    margin: 0 0 0.5rem 0;
    color: var(--color-dark);
    font-weight: 600;
}

.preview-char-role {
    font-size: 1rem;
    color: var(--color-purple);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.preview-char-role strong {
    color: var(--color-dark);
}

.preview-char-desc {
    font-size: 0.875rem;
    color: var(--color-gray-600);
    line-height: 1.5;
    font-style: italic;
}

.preview-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

.preview-actions .btn-primary {
    background: linear-gradient(135deg, var(--color-purple) 0%, var(--color-purple-dark) 100%);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(155, 135, 217, 0.4);
    }
    50% {
        box-shadow: 0 6px 20px rgba(155, 135, 217, 0.6);
    }
}

.preview-error {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--color-error);
}

.preview-error p {
    margin-bottom: 1rem;
    font-size: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .preview-modal {
        width: 95%;
        padding: 1.5rem;
        max-height: 90vh;
    }

    .preview-character-card {
        flex-direction: column;
        text-align: center;
    }

    .preview-char-number {
        margin: 0 auto;
    }

    .preview-actions {
        gap: 0.75rem;
    }
}

/* ===========================
   Loading Spinner
   =========================== */

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--color-cream);
    border-top-color: var(--color-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-spinner.small {
    width: 30px;
    height: 30px;
    border-width: 3px;
}

.loading-message {
    margin-top: 1.5rem;
    color: var(--color-gray-600);
    font-size: 1.125rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===========================
   Modal - FIXED POSITIONING & ANIMATIONS
   =========================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

/* Modal Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content {
    position: relative;
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

/* Szerszy modal dla konfiguratora postaci */
.modal-content--wide {
    max-width: 900px;
}

/* Na małych ekranach modal zawsze na pełną szerokość */
@media (max-width: 768px) {
    .modal-content--wide {
        max-width: 95%;
    }
}

/* ===========================
   Unified PDF Button Style - Magical Design
   =========================== */

.btn-pdf {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    width: 40px;
    height: 40px;
    padding: 0;
    background: linear-gradient(135deg, #FF9F66 0%, #FFBB8E 100%);
    color: white;
    border: none;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(255, 159, 102, 0.3);
    overflow: visible;
}

/* PDF label tooltip */
.btn-pdf::after {
    content: 'PDF';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background: linear-gradient(135deg, #FF9F66 0%, #FFBB8E 100%);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(255, 159, 102, 0.3);
}

.btn-pdf:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
    bottom: -22px;
}

.btn-pdf:hover {
    background: linear-gradient(135deg, #FF8C42 0%, #FFAA70 100%);
    transform: scale(1.15) rotate(-5deg);
    box-shadow: 0 4px 15px rgba(255, 159, 102, 0.5);
}

.btn-pdf:active {
    transform: scale(1.05);
}

.btn-pdf:disabled {
    opacity: 0.7;
    cursor: wait;
    animation: pdfLoading 1s ease-in-out infinite;
}

@keyframes pdfLoading {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.btn-pdf svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2.5;
}

/* ===========================
   Button Loading States
   =========================== */

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: btn-spinner 0.6s linear infinite;
}

.btn-loading .btn-text {
    visibility: hidden;
}

@keyframes btn-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Primary button loading */
.btn-primary.btn-loading {
    background: linear-gradient(135deg, #b8a7e0 0%, #a895c7 100%);
}

/* Secondary button loading */
.btn-secondary.btn-loading {
    background: #f0f0f0;
}

/* ===========================
   Character Configurator Modal
   =========================== */

.configurator-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 2rem;
    min-height: 400px;
}

.configurator-preview {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, #faf8fc 0%, #fff8f0 100%);
    border-radius: var(--radius-md);
    border: 2px solid rgba(155, 135, 217, 0.2);
}

.configurator-avatar {
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 50%;
    border: 3px solid var(--color-purple);
    box-shadow: 0 8px 24px rgba(155, 135, 217, 0.2);
    overflow: hidden;
}

.configurator-avatar svg {
    width: 140px;
    height: 140px;
}

.configurator-basic-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.configurator-basic-info .form-group {
    margin: 0;
}

.configurator-basic-info input,
.configurator-basic-info select {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.configurator-basic-info label {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.configurator-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.configurator-type-select {
    padding: 1rem;
    background: #f8f6fc;
    border-radius: var(--radius-sm);
    border: 1px solid #e8e4f0;
}

.configurator-type-select label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--color-purple);
}

.configurator-type-select select {
    width: 100%;
    padding: 0.625rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
}

.configurator-rotators {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.configurator-rotator-item {
    background: white;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid #e8e4f0;
}

.configurator-rotator-item label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Make outfit rotator span full width */
.configurator-rotator-item.full-width {
    grid-column: 1 / -1;
}

/* Emoji grid for pet/toy */
.configurator-emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    padding: 1rem;
    background: white;
    border-radius: var(--radius-sm);
    border: 1px solid #e8e4f0;
    max-height: 280px;
    overflow-y: auto;
}

.configurator-emoji-grid .emoji-btn {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1.75rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.configurator-emoji-grid .emoji-btn:hover {
    border-color: var(--color-purple);
    transform: scale(1.05);
}

.configurator-emoji-grid .emoji-btn.selected {
    border-color: var(--color-purple);
    background: rgba(155, 135, 217, 0.1);
}

/* Responsive - stack on mobile */
@media (max-width: 700px) {
    .configurator-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .configurator-preview {
        position: relative;
        flex-direction: row;
        padding: 1rem;
    }

    .configurator-avatar {
        width: 100px;
        height: 100px;
        flex-shrink: 0;
    }

    .configurator-avatar svg {
        width: 80px;
        height: 80px;
    }

    .configurator-basic-info {
        flex: 1;
    }

    .configurator-rotators {
        grid-template-columns: 1fr;
    }

    .configurator-emoji-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 2rem 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
    color: var(--color-purple);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--color-gray-600);
    cursor: pointer;
    transition: color var(--transition-fast);
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-close:hover {
    color: var(--color-dark);
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    padding: 1rem 2rem 2rem;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* ===========================
   Toast Notifications
   =========================== */

#toast-container {
    position: fixed;
    top: 100px;
    right: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toast {
    padding: 1rem 1.5rem;
    background: var(--color-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    border-left: 4px solid #4caf50;
}

.toast-error {
    border-left: 4px solid #f44336;
}

.toast-info {
    border-left: 4px solid var(--color-purple);
}

/* ===========================
   Empty State
   =========================== */

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--color-gray-600);
    background: linear-gradient(135deg, #faf8fc 0%, #fff8f0 100%);
    border-radius: var(--radius-lg);
    border: 2px dashed #e0d8eb;
    max-width: 500px;
    margin: 2rem auto;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    filter: grayscale(20%);
    opacity: 0.9;
}

.empty-state h3 {
    color: var(--color-purple);
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.empty-state p {
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.5;
}

.empty-state .btn-primary {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
}

/* ===========================
   Pricing Cards (Store)
   =========================== */

.packages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.package-card {
    background: var(--color-white);
    padding: 2.5rem 2rem;
    border-radius: var(--radius-md);
    border: 3px solid transparent;
    text-align: center;
    transition: all var(--transition-base);
}

.package-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.package-card.featured {
    border-color: var(--color-purple);
}

/* ===========================
   Responsive Design
   =========================== */

@media (max-width: 768px) {
    .app-nav-links {
        gap: 1rem;
        font-size: 0.875rem;
    }

    .app-nav-user {
        gap: 1rem;
    }

    .user-credits {
        padding: 0.4rem 0.8rem;
        font-size: 0.875rem;
    }

    .stories-grid,
    .children-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 2rem;
    }

    .karaoke-text {
        font-size: 1.25rem;
    }

    .player-controls {
        padding: 1.5rem;
    }

    #toast-container {
        right: 1rem;
        left: 1rem;
    }

    .toast {
        min-width: auto;
    }
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-menu-toggle span {
    display: block;
    width: 24px;
    height: 3px;
    background: var(--color-purple);
    border-radius: 2px;
    transition: all var(--transition-fast);
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

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

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .app-nav-links {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: var(--color-white);
        flex-direction: column;
        padding: 1rem;
        gap: 0.5rem;
        box-shadow: var(--shadow-lg);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-base);
        z-index: 90;
    }

    .app-nav-links.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .app-nav-links a {
        padding: 0.75rem 1rem;
        border-radius: var(--radius-sm);
        transition: background var(--transition-fast);
    }

    .app-nav-links a:hover,
    .app-nav-links a.active {
        background: rgba(155, 135, 217, 0.1);
    }

    .user-credits {
        font-size: 0.875rem;
        padding: 0.4rem 0.8rem;
    }
}

@media (max-width: 480px) {
    .generator-form {
        padding: 2rem 1.5rem;
    }

    .child-selector {
        grid-template-columns: 1fr;
    }

    .app-nav .nav-container {
        padding: 1rem;
    }

    .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }
}

/* ===========================
   Fairy Animation (Story Generator Loading)
   =========================== */

.fairy-animation {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 2rem;
}

.fairy {
    font-size: 4rem;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    animation: fairy-fly 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

@keyframes fairy-fly {
    0%, 100% {
        transform: translate(-50%, -50%) translateY(0) rotate(0deg);
    }
    25% {
        transform: translate(-50%, -50%) translateY(-20px) rotate(5deg);
    }
    50% {
        transform: translate(-50%, -50%) translateY(-10px) rotate(0deg);
    }
    75% {
        transform: translate(-50%, -50%) translateY(-20px) rotate(-5deg);
    }
}

.sparkles {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.sparkle {
    position: absolute;
    font-size: 1.5rem;
    opacity: 0;
    animation: sparkle-twinkle 2s ease-in-out infinite;
}

.sparkle:nth-child(1) {
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.sparkle:nth-child(2) {
    top: 30%;
    right: 15%;
    animation-delay: 0.5s;
}

.sparkle:nth-child(3) {
    bottom: 25%;
    left: 20%;
    animation-delay: 1s;
}

.sparkle:nth-child(4) {
    bottom: 30%;
    right: 10%;
    animation-delay: 1.5s;
}

@keyframes sparkle-twinkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.2) rotate(180deg);
    }
}

/* Remove old spinner when fairy is present */
.loading-container:has(.fairy-animation) .loading-spinner {
    display: none;
}

/* Story paragraph styles (for plain text display without karaoke) */
.story-paragraph {
    margin-bottom: 1rem;
    line-height: 1.8;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.story-paragraph:last-child {
    margin-bottom: 0;
}

/* ===========================
   Empty States (UI FIX 2025-11-19)
   =========================== */

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    background: var(--color-cream);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.8;
    line-height: 1;
}

.empty-state h3 {
    color: var(--color-purple-deeper);
    margin-bottom: 0.75rem;
    font-size: 1.5rem;
}

.empty-state p {
    color: var(--color-gray-600);
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.empty-state .btn-primary {
    margin-top: 1rem;
}

/* ===========================
   Quick Actions Grid (UI FIX 2025-11-19)
   =========================== */

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.quick-actions-grid .btn-primary,
.quick-actions-grid .btn-secondary {
    text-align: center;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.quick-actions-grid .btn-primary {
    background: linear-gradient(135deg, var(--color-purple) 0%, #B794F6 100%);
    box-shadow: 0 4px 15px rgba(155, 135, 217, 0.35);
}

.quick-actions-grid .btn-primary:hover {
    background: linear-gradient(135deg, #8B6EAD 0%, #A78BEE 100%);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 25px rgba(155, 135, 217, 0.45);
}

.quick-actions-grid .btn-secondary {
    background: white;
    border: 2px solid var(--color-purple);
    color: var(--color-purple);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.quick-actions-grid .btn-secondary:hover {
    background: linear-gradient(135deg, rgba(155, 135, 217, 0.1) 0%, rgba(255, 159, 102, 0.1) 100%);
    border-color: var(--color-orange);
    color: var(--color-dark);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

/* ===========================
   Avatar Configurator Animations
   =========================== */

@keyframes pulse-animation {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

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

/* ===========================
   Trait Rotator Component
   =========================== */

.trait-rotator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    background: white;
}

.rotator-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: linear-gradient(135deg, #9B7EBD 0%, #FF9F66 100%);
    color: white;
    font-size: 1.25rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.rotator-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(155, 135, 217, 0.4);
}

.rotator-btn:active {
    transform: scale(0.95);
}

.rotator-value {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
    color: #333;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
