/* ========================================
   Conversations Page - Multi-Speaker Creator
   Follows TTS monochrome design system
   ======================================== */

/* Page Background */
.dashboard-content:has(.conv-container) {
    min-height: calc(100vh - 64px);
    position: relative;
    overflow-x: hidden;
    max-width: 100%;
}

/* Template Buttons */
.conv-template-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: hsl(var(--muted-foreground));
    background: transparent;
    border: 1px solid hsl(var(--border) / 0.5);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.conv-template-btn:hover {
    color: hsl(var(--foreground));
    background: hsl(var(--secondary));
    border-color: hsl(var(--border));
}

/* Template List Items */
.template-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: 8px;
    transition: all 0.2s ease;
}

.template-list-item:hover {
    border-color: hsl(var(--primary) / 0.5);
    background: hsl(var(--secondary) / 0.3);
}

.template-list-item-content {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.template-list-item-title {
    font-weight: 500;
    color: hsl(var(--foreground));
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-list-item-meta {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

.template-list-item-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
}

.template-delete-btn {
    padding: 0.4rem;
    color: hsl(var(--destructive));
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s;
}

.template-delete-btn:hover {
    opacity: 1;
    background: hsl(var(--destructive) / 0.1);
}

/* Container Layout - same as TTS */
.conv-container {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    align-items: start;
    box-sizing: border-box;
}

/* Main Content */
.conv-main {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ========================================
   Section Labels
   ======================================== */

.conv-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.conv-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.conv-hint {
    font-size: 0.8rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.25rem;
}

/* ========================================
   Title Input
   ======================================== */

.conv-title-input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 0.75rem;
    color: hsl(var(--foreground));
    font-family: 'Geist', system-ui, -apple-system, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.25s ease;
    letter-spacing: -0.01em;
}

.conv-title-input:focus {
    outline: none;
    border-color: hsl(var(--foreground) / 0.25);
    box-shadow: 0 0 0 3px hsl(var(--foreground) / 0.04);
}

.conv-title-input::placeholder {
    color: hsl(var(--muted-foreground) / 0.5);
    font-weight: 400;
}

/* ========================================
   Speakers Panel
   ======================================== */

.speakers-panel {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 1.25rem;
    padding: 1.5rem;
    box-shadow: 0 4px 20px -5px hsl(0 0% 0% / 0.08);
}

.dark .speakers-panel {
    box-shadow: 0 4px 20px -5px hsl(0 0% 0% / 0.2);
}

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

.speakers-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.add-speaker-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    border: none;
    border-radius: 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.add-speaker-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px hsl(0 0% 0% / 0.15);
}

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

/* Individual Speaker Card */
.speaker-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: 1rem;
    transition: all 0.25s ease;
}

.speaker-card:hover {
    border-color: hsl(var(--foreground) / 0.2);
}

.speaker-avatar-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    border: 2.5px solid currentColor;
    background: hsl(var(--secondary));
}

.speaker-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.speaker-name-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: hsl(var(--secondary));
    border: 1px solid transparent;
    border-radius: 0.5rem;
    color: hsl(var(--foreground));
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 0;
}

.speaker-name-input:focus {
    outline: none;
    border-color: hsl(var(--foreground) / 0.3);
    background: hsl(var(--background));
}

.speaker-voice-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: hsl(var(--secondary));
    border: 1px solid transparent;
    border-radius: 0.5rem;
    color: hsl(var(--foreground));
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.speaker-voice-btn:hover {
    border-color: hsl(var(--foreground) / 0.2);
    background: hsl(var(--foreground) / 0.05);
}

.speaker-voice-btn img {
    width: 24px;
    height: 24px;
    border-radius: 0.375rem;
    object-fit: cover;
}

.speaker-voice-btn svg {
    color: hsl(var(--muted-foreground));
}

.speaker-speed-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.speaker-speed-label {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
}

.speaker-speed-input {
    width: 3.5rem;
    padding: 0.35rem 0.5rem;
    background: hsl(var(--secondary));
    border: 1px solid transparent;
    border-radius: 0.375rem;
    color: hsl(var(--foreground));
    font-size: 0.8rem;
    text-align: center;
    transition: all 0.2s ease;
    -moz-appearance: textfield;
}

.speaker-speed-input::-webkit-outer-spin-button,
.speaker-speed-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.speaker-speed-input:focus {
    outline: none;
    border-color: hsl(var(--foreground) / 0.3);
}

.remove-speaker-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.remove-speaker-btn:hover {
    background: hsl(0 80% 50% / 0.1);
    border-color: hsl(0 80% 50% / 0.3);
    color: hsl(0 80% 50%);
}

.speakers-empty {
    text-align: center;
    padding: 2rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.9rem;
}

/* ========================================
   Messages Timeline
   ======================================== */

.messages-panel {
    margin-top: 1.5rem;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 1.25rem;
    padding: 1.5rem;
    box-shadow: 0 4px 20px -5px hsl(0 0% 0% / 0.08);
}

.dark .messages-panel {
    box-shadow: 0 4px 20px -5px hsl(0 0% 0% / 0.2);
}

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

.messages-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.messages-count {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    background: hsl(var(--secondary));
    padding: 0.25rem 0.625rem;
    border-radius: 1rem;
    font-weight: 500;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* Individual Message */
.message-item {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: 1rem;
    transition: all 0.25s ease;
    position: relative;
}

.message-item:hover {
    border-color: hsl(var(--foreground) / 0.15);
}

.message-avatar-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    border: 2.5px solid currentColor;
    background: hsl(var(--secondary));
    margin-top: 0.25rem;
}

.message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.message-top-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.message-speaker-select {
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    background: hsl(var(--secondary));
    border: 1px solid transparent;
    border-radius: 0.5rem;
    color: hsl(var(--foreground));
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

.message-speaker-select:focus {
    outline: none;
    border-color: hsl(var(--foreground) / 0.3);
}

.message-speed-inline {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.message-speed-inline label {
    font-size: 0.7rem;
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
}

.message-speed-inline input {
    width: 3rem;
    padding: 0.3rem 0.4rem;
    background: hsl(var(--secondary));
    border: 1px solid transparent;
    border-radius: 0.375rem;
    color: hsl(var(--foreground));
    font-size: 0.8rem;
    text-align: center;
    transition: all 0.2s ease;
    -moz-appearance: textfield;
}

.message-speed-inline input::-webkit-outer-spin-button,
.message-speed-inline input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.message-speed-inline input:focus {
    outline: none;
    border-color: hsl(var(--foreground) / 0.3);
}

.message-text-input {
    width: 100%;
    padding: 0.75rem;
    background: hsl(var(--secondary) / 0.5);
    border: 1px solid transparent;
    border-radius: 0.75rem;
    color: hsl(var(--foreground));
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 60px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.message-text-input:focus {
    outline: none;
    border-color: hsl(var(--foreground) / 0.2);
    background: hsl(var(--background));
}

.message-text-input::placeholder {
    color: hsl(var(--muted-foreground));
}

.message-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
    margin-top: 0.25rem;
}

.message-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    transition: all 0.2s ease;
}

.message-action-btn:hover {
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
}

.message-action-btn.delete:hover {
    background: hsl(0 80% 50% / 0.1);
    color: hsl(0 80% 50%);
}

/* Add Message Button */
.add-message-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem;
    background: transparent;
    border: 2px dashed hsl(var(--border));
    border-radius: 1rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
}

.add-message-btn:hover {
    border-color: hsl(var(--foreground) / 0.3);
    color: hsl(var(--foreground));
    background: hsl(var(--foreground) / 0.02);
}

.messages-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: hsl(var(--muted-foreground));
}

.messages-empty svg {
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

.messages-empty p {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.messages-empty span {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* ========================================
   Generate Section
   ======================================== */

.conv-generate-section {
    position: fixed;
    bottom: 0;
    left: 260px;
    right: 0;
    z-index: 30;
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding: 1rem 2rem 1.5rem;
    box-sizing: border-box;
    background: linear-gradient(to top, hsl(var(--background)) 55%, hsl(var(--background) / 0.85) 80%, transparent);
    pointer-events: none;
}

.conv-generate-section > * {
    pointer-events: auto;
}

html.sidebar-collapsed .conv-generate-section {
    left: 72px;
}

.conv-mobile-settings-btn {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: 1rem;
    color: hsl(var(--foreground));
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.conv-mobile-settings-btn:hover {
    background: hsl(var(--secondary));
}

.conv-generate-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.125rem 2rem;
    background: hsl(var(--foreground));
    border: none;
    border-radius: 1rem;
    color: hsl(var(--background));
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px -5px hsl(0 0% 0% / 0.15);
}

.conv-generate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px -5px hsl(0 0% 0% / 0.2);
}

.conv-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.conv-generate-btn .btn-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.conv-generate-btn .btn-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ========================================
   Lock Banner (429 Stuck Lock Warning)
   ======================================== */

.conv-lock-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    background: hsl(45 93% 47% / 0.08);
    border: 1px solid hsl(45 93% 47% / 0.25);
    border-radius: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.conv-lock-banner-content {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: hsl(45 70% 35%);
    font-size: 0.85rem;
    font-weight: 500;
}

.dark .conv-lock-banner-content {
    color: hsl(45 93% 60%);
}

.conv-lock-banner-content svg {
    flex-shrink: 0;
    color: hsl(45 93% 47%);
}

.conv-lock-banner-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.conv-lock-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    border: none;
    border-radius: 0.625rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.conv-lock-btn.cancel-retry {
    background: hsl(0 75% 50%);
    color: white;
}

.conv-lock-btn.cancel-retry:hover {
    background: hsl(0 75% 42%);
    transform: translateY(-1px);
}

.conv-lock-btn.cancel-retry:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.conv-lock-btn.view-history {
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
}

.conv-lock-btn.view-history:hover {
    background: hsl(var(--foreground) / 0.1);
}

/* ========================================
   Conversation History
   ======================================== */

.conv-history {
    margin-top: 1rem;
}

.conv-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.conv-history-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.conv-history-header .view-all-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: hsl(var(--primary));
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.conv-history-header .view-all-link:hover {
    opacity: 0.8;
}

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

.conv-history-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 1rem;
    transition: all 0.25s ease;
}

.conv-history-item:hover {
    border-color: hsl(var(--foreground) / 0.15);
    transform: translateY(-1px);
}

.conv-history-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--secondary));
    border-radius: 0.75rem;
    flex-shrink: 0;
    color: hsl(var(--foreground));
}

.conv-history-info {
    flex: 1;
    min-width: 0;
}

.conv-history-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-history-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.25rem;
}

.conv-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.conv-status-badge.processing {
    background: hsl(45 93% 47% / 0.12);
    color: hsl(45 93% 40%);
}

.conv-status-badge.completed {
    background: hsl(142 76% 36% / 0.12);
    color: hsl(142 76% 36%);
}

.conv-status-badge.failed {
    background: hsl(0 80% 50% / 0.12);
    color: hsl(0 80% 50%);
}

.conv-status-badge.cancelled {
    background: hsl(var(--muted-foreground) / 0.12);
    color: hsl(var(--muted-foreground));
}

/* Processing spinner */
.conv-status-badge.processing::before {
    content: '';
    width: 8px;
    height: 8px;
    border: 1.5px solid hsl(45 93% 40% / 0.3);
    border-top-color: hsl(45 93% 40%);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.conv-history-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.conv-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: hsl(var(--secondary));
    border: none;
    border-radius: 0.625rem;
    color: hsl(var(--foreground));
    cursor: pointer;
    transition: all 0.2s ease;
}

.conv-action-btn:hover {
    background: hsl(var(--foreground) / 0.1);
    transform: translateY(-1px);
}

.conv-action-btn.cancel:hover {
    background: hsl(0 80% 50% / 0.1);
    color: hsl(0 80% 50%);
}

.conv-history-empty {
    text-align: center;
    padding: 2rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.85rem;
}

/* Audio player mini */
.conv-audio-player {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.conv-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    border: none;
    flex-shrink: 0;
}

.conv-play-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px hsl(0 0% 0% / 0.15);
}

/* ========================================
   Settings Sidebar
   ======================================== */

.conv-sidebar {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 1.5rem;
    padding: 1.75rem;
    height: fit-content;
    box-shadow: 0 8px 32px -8px hsl(0 0% 0% / 0.08);
    position: sticky;
    top: 2rem;
}

.dark .conv-sidebar {
    box-shadow: 0 8px 32px -8px hsl(0 0% 0% / 0.2);
}

.conv-sidebar .sidebar-mobile-header {
    display: none;
}

.conv-sidebar .settings-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Reuse TTS setting styles */
.conv-sidebar .setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.conv-sidebar .setting-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    letter-spacing: 0.02em;
}

.conv-sidebar .setting-value {
    font-weight: 500;
    color: hsl(var(--muted-foreground));
}

.conv-sidebar .setting-hint {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

/* Model Toggle */
.conv-sidebar .model-toggle {
    display: flex;
    background: hsl(var(--secondary));
    border-radius: 0.75rem;
    padding: 0.25rem;
}

.conv-sidebar .model-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conv-sidebar .model-btn.active {
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    box-shadow: 0 4px 12px hsl(0 0% 0% / 0.15);
}

.conv-sidebar .model-btn:hover:not(.active) {
    color: hsl(var(--foreground));
}

.conv-sidebar .model-new-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.4rem;
    margin-left: 0.35rem;
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-radius: 0.25rem;
    line-height: 1;
}

.conv-sidebar .model-btn.active .model-new-badge {
    background: hsl(var(--background));
    color: hsl(var(--foreground));
}

/* Format Toggle */
.conv-sidebar .format-toggle {
    display: flex;
    background: hsl(var(--secondary));
    border-radius: 0.75rem;
    padding: 0.25rem;
}

.conv-sidebar .format-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.conv-sidebar .format-btn.active {
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    box-shadow: 0 4px 12px hsl(0 0% 0% / 0.15);
}

.conv-sidebar .format-btn:hover:not(.active) {
    color: hsl(var(--foreground));
}

/* Slider */
.conv-sidebar .setting-slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: hsl(var(--secondary));
    appearance: none;
    cursor: pointer;
}

.conv-sidebar .setting-slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: hsl(var(--foreground));
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px hsl(0 0% 0% / 0.15);
    border: 3px solid hsl(var(--background));
}

.conv-sidebar .setting-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px hsl(0 0% 0% / 0.2);
}

.conv-sidebar .setting-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: 3px solid hsl(var(--background));
    border-radius: 50%;
    background: hsl(var(--foreground));
    cursor: pointer;
    box-shadow: 0 2px 8px hsl(0 0% 0% / 0.15);
}

.conv-sidebar .editable-value {
    width: 2.5rem;
    padding: 0.15rem 0.25rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
    font-size: 0.8rem;
    text-align: right;
    transition: all 0.2s ease;
}

.conv-sidebar .editable-value:focus {
    outline: none;
    border-color: hsl(var(--foreground) / 0.3);
    background: hsl(var(--secondary));
}

/* Reset Button */
.conv-sidebar .reset-section {
    padding-top: 0.5rem;
    border-top: 1px solid hsl(var(--border));
}

.conv-sidebar .reset-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: transparent;
    border: 1px solid hsl(var(--border));
    border-radius: 0.75rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    width: 100%;
    justify-content: center;
}

.conv-sidebar .reset-btn:hover {
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
    border-color: hsl(var(--foreground) / 0.2);
}

/* Language Selector — reused from TTS */
.conv-sidebar .language-select-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1rem;
    background: hsl(var(--secondary));
    border: 1px solid transparent;
    border-radius: 0.75rem;
    color: hsl(var(--foreground));
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.conv-sidebar .language-select-btn:hover {
    border-color: hsl(var(--foreground) / 0.2);
}

.conv-sidebar .language-selected-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.conv-sidebar .lang-flag img {
    width: 20px;
    height: 14px;
    object-fit: cover;
    border-radius: 2px;
    vertical-align: middle;
}

.conv-sidebar .language-count-badge {
    font-size: 0.7rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    background: hsl(var(--secondary));
    padding: 0.15rem 0.5rem;
    border-radius: 1rem;
    margin-left: 0.5rem;
}

.conv-sidebar .language-chevron {
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}

/* Advanced settings in sidebar */
.conv-sidebar .advanced-settings {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding-top: 0.5rem;
}

/* ========================================
   Voice Modal Reuse
   ======================================== */

.conv-voice-modal-overlay {
    position: fixed;
    inset: 0;
    background: hsl(0 0% 0% / 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    backdrop-filter: blur(4px);
}

.conv-voice-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.conv-voice-modal {
    width: 95vw;
    max-width: 1100px;
    max-height: 90vh;
    background: hsl(var(--background));
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px -12px hsl(0 0% 0% / 0.25);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s ease;
}

.conv-voice-modal-overlay.active .conv-voice-modal {
    transform: translateY(0) scale(1);
}

.conv-voice-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid hsl(var(--border));
}

.conv-voice-modal .modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: hsl(var(--foreground));
}

.conv-voice-modal .modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: hsl(var(--secondary));
    border: none;
    border-radius: 0.625rem;
    color: hsl(var(--foreground));
    cursor: pointer;
    transition: all 0.2s ease;
}

.conv-voice-modal .modal-close:hover {
    background: hsl(var(--foreground) / 0.1);
}

.conv-voice-modal .modal-content {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Voice search in conv modal */
.conv-voice-search {
    position: relative;
    margin-bottom: 1rem;
}

.conv-voice-search svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: hsl(var(--muted-foreground));
}

.conv-voice-search input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    background: hsl(var(--secondary));
    border: 1px solid transparent;
    border-radius: 0.875rem;
    color: hsl(var(--foreground));
    font-size: 0.9rem;
    transition: all 0.25s ease;
}

.conv-voice-search input:focus {
    outline: none;
    border-color: hsl(var(--foreground) / 0.3);
    background: hsl(var(--background));
}

.conv-voice-search input::placeholder {
    color: hsl(var(--muted-foreground));
}

/* Voice filters */
.conv-voice-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.conv-voice-filters select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    background: hsl(var(--secondary));
    border: 1px solid transparent;
    border-radius: 0.5rem;
    color: hsl(var(--foreground));
    font-size: 0.8rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

/* Voice Grid — matches TTS layout */
.conv-voice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    max-height: 55vh;
    overflow-y: auto;
    padding-right: 0.5rem;
    padding-top: 30px;
}

/* Voice Card — column layout matching TTS */
.conv-voice-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    position: relative;
    min-height: 180px;
}

.conv-voice-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px -8px hsl(0 0% 0% / 0.12);
    border-color: hsl(var(--foreground) / 0.2);
}

.conv-voice-card.selected {
    border-color: hsl(var(--foreground));
    box-shadow: 0 0 0 2px hsl(var(--foreground) / 0.15);
}

.conv-voice-card .conv-voice-avatar {
    width: 64px;
    height: 64px;
    border-radius: 0.875rem;
    object-fit: cover;
    background: hsl(var(--secondary));
    border: 2px solid hsl(var(--background));
    box-shadow: 0 4px 12px hsl(0 0% 0% / 0.1);
    transition: all 0.25s ease;
}

.conv-voice-card:hover .conv-voice-avatar {
    transform: scale(1.05);
}

.conv-voice-card-info {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.conv-voice-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: hsl(var(--foreground));
    margin-bottom: 0;
}

/* Voice Tags */
.conv-voice-tags {
    display: flex;
    gap: 0.375rem;
    justify-content: center;
    flex-wrap: wrap;
}

.conv-voice-tag {
    padding: 0.2rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.65rem;
    font-weight: 500;
    background: hsl(var(--secondary));
    color: hsl(var(--muted-foreground));
}

.conv-voice-tag img {
    width: 14px;
    height: 10px;
    object-fit: cover;
    border-radius: 1px;
    vertical-align: middle;
    margin-right: 2px;
}

/* Voice Description */
.conv-voice-description {
    font-size: 0.72rem;
    color: hsl(var(--muted-foreground));
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-voice-premium-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    color: hsl(45, 100%, 50%);
    z-index: 2;
    filter: drop-shadow(0 1px 2px hsl(0 0% 0% / 0.2));
}

.conv-voice-premium-badge svg {
    display: block;
}

/* Voice preview button — matches TTS */
.conv-voice-preview-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-top: 0.375rem;
    box-shadow: 0 4px 12px hsl(0 0% 0% / 0.15);
}

.conv-voice-preview-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px hsl(0 0% 0% / 0.2);
}

.conv-voice-preview-btn.playing {
    background: hsl(var(--foreground));
}

/* Speaker voice avatar in card */
.speaker-voice-avatar {
    width: 24px;
    height: 24px;
    border-radius: 0.375rem;
    object-fit: cover;
    background: hsl(var(--secondary));
}

/* Message voice avatar */
.message-voice-avatar {
    width: 22px;
    height: 22px;
    border-radius: 0.375rem;
    object-fit: cover;
    background: hsl(var(--secondary));
    flex-shrink: 0;
}

/* Per-speaker / per-message settings expander */
.speaker-settings-toggle,
.message-settings-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    background: transparent;
    border: 1px solid hsl(var(--border));
    border-radius: 0.375rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.speaker-settings-toggle:hover,
.message-settings-toggle:hover {
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
}

.speaker-settings-toggle svg,
.message-settings-toggle svg {
    transition: transform 0.2s ease;
}

.speaker-settings-toggle.open svg,
.message-settings-toggle.open svg {
    transform: rotate(180deg);
}

.speaker-extra-settings,
.message-extra-settings {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: hsl(var(--secondary) / 0.3);
    border-radius: 0.75rem;
    margin-top: 0.5rem;
}

.speaker-extra-settings.open,
.message-extra-settings.open {
    display: flex;
}

.inline-setting {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.inline-setting label {
    font-size: 0.7rem;
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
    min-width: 70px;
}

.inline-setting input[type="number"],
.inline-setting select {
    flex: 1;
    padding: 0.3rem 0.5rem;
    background: hsl(var(--secondary));
    border: 1px solid transparent;
    border-radius: 0.375rem;
    color: hsl(var(--foreground));
    font-size: 0.75rem;
    transition: all 0.2s ease;
    -moz-appearance: textfield;
}

.inline-setting input[type="number"]::-webkit-outer-spin-button,
.inline-setting input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.inline-setting input:focus,
.inline-setting select:focus {
    outline: none;
    border-color: hsl(var(--foreground) / 0.3);
}

/* Language modal — reused from TTS */
.conv-language-modal-overlay {
    position: fixed;
    inset: 0;
    background: hsl(0 0% 0% / 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    backdrop-filter: blur(4px);
}

.conv-language-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.conv-language-modal {
    width: 90vw;
    max-width: 520px;
    max-height: 80vh;
    background: hsl(var(--background));
    border-radius: 1.25rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px -12px hsl(0 0% 0% / 0.25);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s ease;
}

.conv-language-modal-overlay.active .conv-language-modal {
    transform: translateY(0) scale(1);
}

.conv-language-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid hsl(var(--border));
}

.conv-language-modal .modal-content {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.conv-language-search {
    position: relative;
    margin-bottom: 1rem;
}

.conv-language-search svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: hsl(var(--muted-foreground));
}

.conv-language-search input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    background: hsl(var(--secondary));
    border: 1px solid transparent;
    border-radius: 0.875rem;
    color: hsl(var(--foreground));
    font-size: 0.9rem;
    transition: all 0.25s ease;
}

.conv-language-search input:focus {
    outline: none;
    border-color: hsl(var(--foreground) / 0.3);
    background: hsl(var(--background));
}

.conv-language-grid {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 55vh;
    overflow-y: auto;
}

.conv-language-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.75rem;
    color: hsl(var(--foreground));
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: left;
}

.conv-language-option:hover {
    background: hsl(var(--secondary));
}

.conv-language-option.selected {
    background: hsl(var(--foreground) / 0.05);
    border-color: hsl(var(--foreground) / 0.15);
}

.conv-language-option .language-flag img {
    width: 24px;
    height: 16px;
    object-fit: cover;
    border-radius: 2px;
}

.conv-language-option .language-check {
    margin-left: auto;
}

.conv-language-option.advanced-only {
    opacity: 0.6;
}

.conv-language-option .advanced-only-badge {
    font-size: 0.6rem;
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-weight: 600;
    margin-left: auto;
}

.conv-language-section-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
}

.conv-language-section-divider .divider-line {
    flex: 1;
    height: 1px;
    background: hsl(var(--border));
}

.conv-language-section-divider .divider-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
}

/* Loading State */
.conv-voice-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: hsl(var(--muted-foreground));
    gap: 0.75rem;
}

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

.spinner {
    animation: spin 1s linear infinite;
}

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

@media (max-width: 1024px) {
    .conv-container {
        grid-template-columns: 1fr;
    }

    .conv-sidebar {
        position: fixed;
        right: -100%;
        top: 0;
        bottom: 0;
        width: 360px;
        max-width: 85vw;
        z-index: 100;
        border-radius: 1.5rem 0 0 1.5rem;
        transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
    }

    .conv-sidebar.open {
        right: 0;
    }

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

    .conv-sidebar .sidebar-mobile-header h3 {
        font-size: 1.1rem;
        font-weight: 700;
        color: hsl(var(--foreground));
    }

    .conv-sidebar .close-sidebar-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: hsl(var(--secondary));
        border: none;
        border-radius: 0.625rem;
        color: hsl(var(--foreground));
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .conv-sidebar .close-sidebar-btn:hover {
        background: hsl(var(--foreground) / 0.1);
    }

    .conv-generate-section {
        left: 0;
    }

    .conv-mobile-settings-btn {
        display: flex;
    }

    .conv-sidebar-overlay {
        position: fixed;
        inset: 0;
        background: hsl(0 0% 0% / 0.4);
        z-index: 99;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        backdrop-filter: blur(2px);
    }

    .conv-sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }
}

/* ========================================
   AI Creation Mode
   ======================================== */

/* Mode Toggle — centered, compact, outside grid */
.conv-mode-row {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.conv-mode-toggle {
    display: inline-flex;
    background: hsl(var(--secondary));
    border-radius: 0.625rem;
    padding: 3px;
    gap: 2px;
}

.conv-mode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 1rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.775rem;
    font-weight: 550;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    white-space: nowrap;
}

.conv-mode-btn.active {
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    box-shadow: 0 1px 4px hsl(0 0% 0% / 0.12);
}

.conv-mode-btn:hover:not(.active) {
    color: hsl(var(--foreground));
}

.conv-mode-btn svg {
    opacity: 0.6;
}

.conv-mode-btn.active svg {
    opacity: 1;
}

/* ========================================
   AI Creation Panel
   ======================================== */

/* Entry animations */
@keyframes ai-fade-up {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes ai-scale-in {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes ai-popover-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-creation-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 400px;
    animation: ai-fade-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.ai-centered-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: 3rem 0 1rem;
}

/* Header */
.ai-centered-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 2.5rem;
    animation: ai-fade-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both;
}

.ai-centered-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: hsl(var(--foreground) / 0.05);
    color: hsl(var(--muted-foreground));
    margin-bottom: 1.25rem;
    transition: all 0.3s ease;
}

.ai-centered-title {
    font-family: 'Geist', system-ui, -apple-system, sans-serif;
    font-size: 1.65rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    margin: 0 0 0.5rem 0;
    letter-spacing: -0.025em;
}

.ai-centered-subtitle {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    margin: 0;
    line-height: 1.65;
    max-width: 440px;
}

/* Main Input Wrapper */
.ai-input-wrapper {
    width: 100%;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 1.25rem;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 1px 3px hsl(0 0% 0% / 0.04), 0 4px 16px -4px hsl(0 0% 0% / 0.04);
    animation: ai-scale-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.ai-input-wrapper:focus-within {
    border-color: hsl(var(--foreground) / 0.2);
    box-shadow: 0 1px 3px hsl(0 0% 0% / 0.04), 0 8px 32px -8px hsl(0 0% 0% / 0.08);
}

.ai-main-input {
    width: 100%;
    padding: 1.25rem 1.25rem 0.5rem;
    background: transparent;
    border: none;
    color: hsl(var(--foreground));
    font-size: 0.925rem;
    font-family: inherit;
    line-height: 1.65;
    resize: none;
    min-height: 88px;
    box-sizing: border-box;
}

.ai-main-input:focus {
    outline: none;
}

.ai-main-input::placeholder {
    color: hsl(var(--muted-foreground) / 0.45);
}

/* Footer row */
.ai-input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.375rem 0.625rem 0.625rem 1rem;
}

.ai-input-left {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
}

.ai-input-hint {
    font-size: 0.7rem;
    color: hsl(var(--muted-foreground) / 0.6);
    white-space: nowrap;
}

/* ── Settings Dropdown ────────────────── */
.ai-settings-dropdown {
    position: relative;
}

.ai-settings-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.6rem;
    background: transparent;
    border: 1px solid hsl(var(--border));
    border-radius: 0.5rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.725rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ai-settings-toggle:hover {
    color: hsl(var(--foreground));
    border-color: hsl(var(--foreground) / 0.15);
    background: hsl(var(--secondary));
}

.ai-settings-toggle svg:first-child {
    opacity: 0.5;
}

.ai-settings-label {
    font-size: 0.725rem;
}

/* Popover */
/* Backdrop overlay — blocks clicks behind popover */
.ai-settings-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9998;
}

.ai-settings-backdrop.open {
    display: block;
}

/* Popover — fixed position, placed by JS next to the toggle button */
.ai-settings-popover {
    position: fixed;
    min-width: 250px;
    border-radius: 1rem;
    padding: 0.875rem;
    z-index: 9999;
    display: none;
    flex-direction: column;
    gap: 0.875rem;
    background-color: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

.ai-settings-popover[data-theme="dark"] {
    background-color: #1c1c1c;
    border-color: #333;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

.ai-settings-popover.open {
    display: flex;
    animation: ai-popover-in 0.18s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.ai-settings-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.ai-settings-group-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-left: 0.1rem;
}

.ai-settings-hint {
    font-size: 0.675rem;
    color: hsl(var(--muted-foreground) / 0.7);
    margin: 0;
    line-height: 1.4;
    padding-left: 0.1rem;
}

/* Toggle button groups */
.ai-model-options,
.ai-format-options {
    display: flex;
    background: hsl(var(--secondary));
    border-radius: 0.5rem;
    padding: 3px;
    gap: 2px;
}

.ai-model-opt,
.ai-format-opt {
    flex: 1;
    padding: 0.4rem 0.5rem;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    font-weight: 550;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.ai-model-opt:hover:not(.active),
.ai-format-opt:hover:not(.active) {
    color: hsl(var(--foreground));
    background: hsl(var(--foreground) / 0.04);
}

.ai-model-opt.active,
.ai-format-opt.active {
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    box-shadow: 0 1px 4px hsl(0 0% 0% / 0.12);
}

/* ── Generate Button ──────────────────── */
.ai-generate-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    border: none;
    border-radius: 0.625rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.ai-generate-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px hsl(0 0% 0% / 0.12);
}

.ai-generate-btn:active:not(:disabled) {
    transform: scale(0.97);
    box-shadow: none;
}

.ai-generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ai-gen-text,
.ai-gen-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* ── Status Message ───────────────────── */
.ai-status-message {
    width: 100%;
    padding: 0.7rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.8rem;
    margin-top: 0.75rem;
    text-align: center;
    animation: ai-fade-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.ai-status-message.success {
    background: hsl(142 71% 45% / 0.08);
    color: hsl(142 71% 40%);
    border: 1px solid hsl(142 71% 45% / 0.15);
}

.ai-status-message.error {
    background: hsl(0 72% 51% / 0.08);
    color: hsl(0 72% 51%);
    border: 1px solid hsl(0 72% 51% / 0.15);
}

/* ── Suggestion Chips ─────────────────── */
.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 1.5rem;
    animation: ai-fade-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.ai-suggestion-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid hsl(var(--border));
    border-radius: 2rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.775rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ai-suggestion-chip:hover {
    color: hsl(var(--foreground));
    border-color: hsl(var(--foreground) / 0.2);
    background: hsl(var(--foreground) / 0.03);
}

.ai-suggestion-chip:active {
    transform: scale(0.97);
}

/* ── JSON Import Collapse ─────────────── */
.ai-json-collapse {
    width: 100%;
    margin-top: 2rem;
    animation: ai-fade-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.25s both;
}

.ai-json-collapse-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground) / 0.7);
    cursor: pointer;
    padding: 0.4rem 0;
    transition: color 0.2s ease;
    list-style: none;
}

.ai-json-collapse-trigger::-webkit-details-marker {
    display: none;
}

.ai-json-collapse-trigger::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
}

.ai-json-collapse[open] .ai-json-collapse-trigger::before {
    transform: rotate(45deg);
}

.ai-json-collapse-trigger:hover {
    color: hsl(var(--foreground));
}

.ai-json-collapse .ai-json-section {
    margin-top: 0.75rem;
    animation: ai-fade-up 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* JSON Import Section */
.ai-json-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ai-json-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.ai-json-actions {
    display: flex;
    gap: 0.5rem;
}

.ai-json-sample-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4rem 0.75rem;
    background: hsl(var(--secondary));
    border: 1px solid hsl(var(--border));
    border-radius: 0.5rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-json-sample-btn:hover {
    color: hsl(var(--foreground));
    border-color: hsl(var(--foreground) / 0.2);
    background: hsl(var(--foreground) / 0.05);
}

.ai-json-input {
    width: 100%;
    padding: 1rem 1.25rem;
    background: hsl(220 15% 8%);
    border: 1px solid hsl(var(--border));
    border-radius: 0.75rem;
    color: hsl(142 40% 70%);
    font-size: 0.8rem;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    line-height: 1.6;
    resize: vertical;
    min-height: 120px;
    transition: all 0.3s ease;
    tab-size: 2;
}

.ai-json-input:focus {
    outline: none;
    border-color: hsl(142 40% 50% / 0.4);
    box-shadow: 0 0 0 3px hsl(142 40% 50% / 0.08);
}

.ai-json-input::placeholder {
    color: hsl(220 10% 40%);
}

:root:not(.dark) .ai-json-input {
    background: hsl(220 14% 96%);
    color: hsl(220 13% 30%);
}

:root:not(.dark) .ai-json-input:focus {
    border-color: hsl(var(--foreground) / 0.3);
    box-shadow: 0 0 0 3px hsl(var(--foreground) / 0.06);
}

:root:not(.dark) .ai-json-input::placeholder {
    color: hsl(var(--muted-foreground));
}

/* JSON Status */
.ai-json-status {
    font-size: 0.8rem;
    padding: 0;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    min-height: 0;
    overflow: hidden;
}

.ai-json-status.success {
    padding: 0.65rem 1rem;
    background: hsl(142 76% 36% / 0.1);
    color: hsl(142 76% 36%);
    border: 1px solid hsl(142 76% 36% / 0.2);
    min-height: auto;
}

.ai-json-status.error {
    padding: 0.65rem 1rem;
    background: hsl(0 80% 50% / 0.1);
    color: hsl(0 80% 55%);
    border: 1px solid hsl(0 80% 50% / 0.2);
    min-height: auto;
}

/* Parse Button */
.ai-json-parse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    border: none;
    border-radius: 0.75rem;
    font-size: 0.85rem;
    font-weight: 650;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ai-json-parse-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px hsl(0 0% 0% / 0.12);
}

.ai-json-parse-btn:active {
    transform: translateY(0);
}

/* Studio mode panel spacing */
#manualModePanel {
    flex-direction: column;
    gap: 2rem;
}

@media (max-width: 640px) {
    .speaker-info-row {
        flex-direction: column;
        align-items: stretch;
    }

    .conv-voice-grid {
        grid-template-columns: 1fr 1fr;
    }

    .message-top-row {
        flex-wrap: wrap;
    }

    .ai-centered-container {
        padding: 1rem 0;
    }

    .ai-centered-title {
        font-size: 1.25rem;
    }

    .ai-suggestions {
        gap: 0.375rem;
    }

    .ai-suggestion-chip {
        font-size: 0.7rem;
        padding: 0.4rem 0.75rem;
    }

    .ai-input-left {
        gap: 0.4rem;
    }

    .ai-input-hint {
        display: none;
    }

    .ai-settings-popover {
        left: -0.5rem;
        min-width: 220px;
    }
}