/* Sora / iPhone TTS Design System */
:root {
    --tts-bg: #000000;
    --tts-card-bg: #1c1c1e;
    --tts-accent: #0a84ff;
    --tts-accent-glow: rgba(10, 132, 255, 0.4);
    --tts-text: #ffffff;
    --tts-text-secondary: #8e8e93;
    --tts-border: rgba(255, 255, 255, 0.1);
}

.tts-container {
    max-width: 1200px;
    /* Wider for desktop */
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Glass Card */
.tts-glass-card {
    background: rgba(28, 28, 30, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--tts-border);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Header Controls */
.tts-controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.tts-select-group {
    background: #2c2c2e;
    border-radius: 12px;
    padding: 4px;
    display: flex;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    flex-grow: 1;
    /* Expand on mobile */
    justify-content: center;
}

.tts-select {
    background: transparent;
    color: white;
    border: none;
    padding: 8px 12px;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    width: 100%;
}

.tts-select:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tts-select option {
    background: #1c1c1e;
    color: white;
}

/* Text Area */
.tts-input-wrapper {
    position: relative;
    background: #000;
    border-radius: 18px;
    padding: 20px;
    border: 1px solid var(--tts-border);
    transition: border-color 0.3s, box-shadow 0.3s;
}

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

.tts-textarea {
    width: 100%;
    min-height: 150px;
    background: transparent;
    border: none;
    color: var(--tts-text);
    font-size: 1.1rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

.tts-char-counter {
    position: absolute;
    bottom: 12px;
    left: 20px;
    font-size: 0.8rem;
    color: var(--tts-text-secondary);
}

/* Advanced Sliders */
.tts-sliders {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
}

.slider-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slider-label {
    font-size: 0.8rem;
    color: var(--tts-text-secondary);
    display: flex;
    justify-content: space-between;
}

.tts-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: #3a3a3c;
    border-radius: 2px;
    outline: none;
}

.tts-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

.tts-range::-webkit-slider-thumb:active {
    transform: scale(1.2);
}

/* Player & Visualizer */
.tts-player-card {
    background: linear-gradient(145deg, #1c1c1e, #2c2c2e);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    padding: 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
    /* Desktop layout default: below input, but we'll use flex for desktop specific */
}

.visualizer-container {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 20px;
}

.viz-bar {
    width: 6px;
    height: 10px;
    background: var(--tts-accent);
    border-radius: 3px;
    transition: height 0.1s ease;
    box-shadow: 0 0 10px var(--tts-accent-glow);
}

.tts-play-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--tts-text);
    color: black;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-left: 5px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 10px 40px rgba(255, 255, 255, 0.2);
}

.tts-play-btn:hover {
    transform: scale(1.05);
}

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

.tts-play-btn.playing {
    padding-left: 0;
    box-shadow: 0 0 50px var(--tts-accent-glow);
}

/* Quick Chips */
.tts-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.tts-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tts-chip:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* Animations */
@keyframes glow-pulse {
    0% {
        box-shadow: 0 0 20px var(--tts-accent-glow);
    }

    50% {
        box-shadow: 0 0 40px var(--tts-accent-glow), 0 0 10px var(--tts-accent);
    }

    100% {
        box-shadow: 0 0 20px var(--tts-accent-glow);
    }
}

.playing .viz-bar {
    animation: bounce-bar 0.5s infinite ease-in-out alternate;
}

@keyframes bounce-bar {
    0% {
        height: 10px;
    }

    100% {
        height: 40px;
    }
}

/* --- RESPONSIVE ADJUSTMENTS --- */

/* Desktop Specifics (Natural Wide Mode) */
@media (min-width: 900px) {
    .tts-container {
        display: grid;
        grid-template-columns: 2fr 1fr;
        /* Input vs Controls */
        gap: 24px;
        align-items: start;
    }

    .tts-glass-card {
        grid-column: 1;
        /* Main content left */
        margin-bottom: 0;
        min-height: 500px;
    }

    .tts-player-card {
        grid-column: 2;
        /* Player right */
        margin-top: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .tts-textarea {
        font-size: 1.2rem;
        /* Larger text on desktop */
    }
}

/* Avatar Scrolling List */
.avatar-scroll-container {
    width: 100%;
    overflow-x: auto;
    padding: 15px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 20px;
}

.avatar-scroll-container::-webkit-scrollbar {
    display: none;
}

.avatar-list {
    display: flex;
    gap: 20px;
    padding: 0 10px;
    width: max-content;
}

.avatar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0.5;
    width: 90px;
    /* Bigger touch target */
}

.avatar-item.active {
    opacity: 1;
    transform: scale(1.15) translateY(-5px);
}

.avatar-item.active .avatar-img {
    box-shadow: 0 0 25px var(--tts-accent), 0 0 0 3px rgba(143, 115, 255, 0.5);
    border-color: var(--tts-accent);
}

.avatar-img {
    width: 85px;
    /* Larger Image */
    height: 85px;
    border-radius: 50%;
    background-color: #1f2937;
    background-size: 300% 100%;
    background-repeat: no-repeat;
    border: 3px solid transparent;
    /* Prepare for border */
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.avatar-name {
    font-size: 0.9rem;
    color: #fff;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* Sprite Mappings */
/* Sheet 1: Lona, Grandpa, Kid */
.av-lona .avatar-img {
    background-image: url('assets/avatars/avatars-1.png');
    background-position: 0% 0%;
}

.av-grandpa .avatar-img {
    background-image: url('assets/avatars/avatars-1.png');
    background-position: 50% 0%;
}

.av-kid .avatar-img {
    background-image: url('assets/avatars/avatars-1.png');
    background-position: 100% 0%;
}

/* Sheet 2: Narrator, Gamer, Anchor */
.av-narrator .avatar-img {
    background-image: url('assets/avatars/avatars-2.png');
    background-position: 0% 0%;
}

.av-gamer .avatar-img {
    background-image: url('assets/avatars/avatars-2.png');
    background-position: 50% 0%;
}

.av-anchor .avatar-img {
    background-image: url('assets/avatars/avatars-2.png');
    background-position: 100% 0%;
}

/* Sheet 3: Chill, Mystery, Robot */
.av-chill .avatar-img {
    background-image: url('assets/avatars/avatars-3.png');
    background-position: 0% 0%;
}

.av-mystery .avatar-img {
    background-image: url('assets/avatars/avatars-3.png');
    background-position: 50% 0%;
}

.av-robot .avatar-img {
    background-image: url('assets/avatars/avatars-3.png');
    background-position: 100% 0%;
}

/* Single: Executive */
.av-executive .avatar-img {
    background-image: url('assets/avatars/avatar-executive.png');
    background-size: cover;
}

/* Mobile Specifics */
@media (max-width: 768px) {
    .tts-container {
        padding: 10px;
    }

    .avatar-item {
        width: 80px;
        /* Bigger touch target for mobile */
    }

    .avatar-img {
        width: 75px;
        height: 75px;
    }

    .tts-glass-card {
        padding: 16px;
        border-radius: 18px;
    }

    .tts-textarea {
        font-size: 1.1rem;
        min-height: 120px;
    }

    .tts-controls-header {
        flex-direction: column;
        gap: 10px;
    }

    .tts-select-group {
        width: 100%;
    }

    .tts-play-btn {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .tts-player-card {
        padding: 20px;
    }

    .tts-chips {
        gap: 6px;
    }

    .tts-chip {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}