/* VoiceBox - Dark Studio Theme (extends pibico.css) */

/* === Dark Theme Override === */
:root {
    --primary-color: #4682b4;
    --secondary-color: #6a9bc3;
    --accent-color: #7eb8e0;
    --text-color: #e0e0ef;
    --text-light: #8888a8;
    --bg-gradient: none;
    --glass-bg: #1a1b2e;
    --glass-border: rgba(255, 255, 255, 0.06);
    --surface: #1a1b2e;
    --surface-hover: #22233a;
    --input-bg: #252640;
    --body-bg: #0f0f1a;
    --border: rgba(255, 255, 255, 0.08);
    --danger: #ef4444;
    --success: #22c55e;
}

body {
    background: var(--body-bg) !important;
    color: var(--text-color);
}

/* === App Layout === */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* === Toolbar (top bar) === */
.toolbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    flex-shrink: 0;
    z-index: 100;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toolbar-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent-color);
}

.toolbar-logo svg {
    width: 22px;
    height: 22px;
    stroke: var(--primary-color);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Generate button */
.btn-generate {
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 0.45rem 1.25rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.btn-generate:hover:not(:disabled) {
    background: #5a9fd4;
    box-shadow: 0 0 12px rgba(70, 130, 180, 0.4);
}

.btn-generate:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn-generate svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    stroke: none;
}

/* Progress bar (inline in toolbar) */
.toolbar-progress {
    display: none;
    align-items: center;
    gap: 0.5rem;
    min-width: 180px;
}

.toolbar-progress.active {
    display: flex;
}

.toolbar-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--input-bg);
    border-radius: 2px;
    overflow: hidden;
}

.toolbar-progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s;
    animation: progress-pulse 2s ease-in-out infinite;
}

.toolbar-progress-text {
    font-size: 0.7rem;
    color: var(--text-light);
    white-space: nowrap;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Toolbar icon buttons */
.toolbar-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    width: 34px;
    height: 34px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: var(--surface-hover);
    color: var(--text-color);
    border-color: rgba(255, 255, 255, 0.12);
}

.toolbar-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.toolbar-link {
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.toolbar-link:hover {
    color: var(--text-color);
    background: var(--surface-hover);
}

.toolbar-link svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* === Three-Column Layout === */
.studio-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* --- Sidebar (Voices) --- */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-header h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
    font-weight: 600;
}

.btn-add-profile {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.btn-add-profile:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* Sidebar tabs */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-tab {
    flex: 1;
    padding: 0.5rem 0;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-light);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-tab:hover {
    color: var(--text-color);
}

.sidebar-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.sidebar-tab-panel {
    display: none;
    flex: 1;
    overflow: hidden;
    flex-direction: column;
}

.sidebar-tab-panel.active {
    display: flex;
}

/* Preset voice cards */
.preset-card {
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid transparent;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.25rem;
}

.preset-card:hover {
    background: var(--surface-hover);
    border-left-color: rgba(139, 92, 246, 0.3);
}

.preset-card.selected {
    background: rgba(139, 92, 246, 0.12);
    border-left-color: #8b5cf6;
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.1);
}

.preset-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #6d28d9, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.preset-lang-badge {
    display: inline-block;
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}

.preset-gender {
    font-size: 0.65rem;
    color: var(--text-light);
}

.history-badge {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
}

.history-badge.preset {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}

.history-badge.clone {
    background: rgba(70, 130, 180, 0.15);
    color: var(--primary-color);
}

/* Inline create form */
.sidebar-create-form {
    display: none;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
}

.sidebar-create-form.open {
    display: flex;
}

.sidebar-create-form input,
.sidebar-create-form select {
    width: 100%;
    padding: 0.4rem 0.6rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-color);
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.2s;
}

.sidebar-create-form input:focus,
.sidebar-create-form select:focus {
    border-color: var(--primary-color);
}

.sidebar-create-form select option {
    background: var(--input-bg);
    color: var(--text-color);
}

.sidebar-create-actions {
    display: flex;
    gap: 0.4rem;
}

.btn-create {
    flex: 1;
    padding: 0.35rem;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-create:hover {
    background: #5a9fd4;
}

.btn-cancel-create {
    padding: 0.35rem 0.6rem;
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel-create:hover {
    background: var(--surface-hover);
    color: var(--text-color);
}

/* Profile list */
.sidebar-profiles {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.sidebar-profiles::-webkit-scrollbar {
    width: 4px;
}

.sidebar-profiles::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-profiles::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.profile-card {
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid transparent;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.25rem;
}

.profile-card:hover {
    background: var(--surface-hover);
    border-left-color: rgba(70, 130, 180, 0.3);
}

.profile-card.selected {
    background: rgba(70, 130, 180, 0.12);
    border-left-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(70, 130, 180, 0.1);
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #2c5171, #4682b4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

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

.profile-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-meta {
    font-size: 0.7rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.1rem;
}

.profile-badge {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
}

.profile-badge.ready {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.profile-actions {
    display: flex;
    opacity: 0;
    transition: opacity 0.2s;
}

.profile-card:hover .profile-actions {
    opacity: 1;
}

.profile-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 4px;
    color: var(--text-light);
    transition: all 0.2s;
}

.profile-actions button:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.empty-text {
    color: var(--text-light);
    font-size: 0.8rem;
    text-align: center;
    padding: 2rem 1rem;
}

/* --- Center (Text Editor) --- */
.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
    min-width: 0;
}

.editor-textarea {
    flex: 1;
    min-height: 200px;
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    color: var(--text-color);
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.6;
    resize: none;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.editor-textarea::placeholder {
    color: var(--text-light);
}

.editor-textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(70, 130, 180, 0.15);
}

.editor-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.5rem;
}

.char-count {
    font-size: 0.7rem;
    color: var(--text-light);
}

/* --- Right Panel (Settings + Output) --- */
.settings-panel {
    width: 320px;
    min-width: 320px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.settings-panel::-webkit-scrollbar {
    width: 4px;
}

.settings-panel::-webkit-scrollbar-track {
    background: transparent;
}

.settings-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.settings-section {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-light);
    font-weight: 600;
    margin-bottom: 0.75rem;
}

/* Form controls in settings */
.setting-row {
    margin-bottom: 0.65rem;
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.setting-label span {
    font-size: 0.8rem;
    color: var(--text-color);
}

.setting-value {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.setting-select,
.setting-input {
    width: 100%;
    padding: 0.45rem 0.65rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.2s;
}

.setting-select:focus,
.setting-input:focus {
    border-color: var(--primary-color);
}

.setting-select option {
    background: var(--input-bg);
    color: var(--text-color);
}

/* Custom range sliders */
.setting-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--input-bg);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.setting-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid var(--surface);
    box-shadow: 0 0 4px rgba(70, 130, 180, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
}

.setting-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 8px rgba(70, 130, 180, 0.6);
}

.setting-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid var(--surface);
    box-shadow: 0 0 4px rgba(70, 130, 180, 0.4);
}

.setting-slider::-moz-range-track {
    height: 6px;
    background: var(--input-bg);
    border-radius: 3px;
    border: none;
}

/* === Audio Output Section === */
.audio-output {
    padding: 1rem 1.25rem;
    display: none;
}

.audio-output.active {
    display: block;
}

.audio-player-container {
    background: var(--input-bg);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.audio-player-container audio {
    width: 100%;
    height: 36px;
}

.audio-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-light);
}

.btn-download {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-color);
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    width: 100%;
    justify-content: center;
    margin-top: 0.5rem;
}

.btn-download:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-download svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* === Samples Section === */
.sample-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.sample-item {
    padding: 0.45rem 0.6rem;
    background: var(--input-bg);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-color);
}

.sample-item .sample-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sample-item .sample-duration {
    color: var(--text-light);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.sample-item .sample-snr {
    color: var(--text-light);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.sample-primary {
    color: var(--success);
    font-size: 0.65rem;
    font-weight: 600;
}

.sample-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 2px;
    border-radius: 3px;
    display: flex;
    transition: color 0.2s;
}

.sample-delete:hover {
    color: var(--danger);
}

.sample-delete svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Upload + Record row */
.sample-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.sample-input-row .drop-zone {
    flex: 1;
}

/* Record button */
.btn-record {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    width: 72px;
    min-width: 72px;
    background: var(--input-bg);
    border: 2px dashed var(--border);
    border-radius: 8px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
    padding: 0.5rem 0.25rem;
}

.btn-record:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.btn-record.recording {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    animation: record-pulse 1.2s ease-in-out infinite;
}

@keyframes record-pulse {
    0%, 100% { border-color: var(--danger); }
    50% { border-color: rgba(239, 68, 68, 0.3); }
}

.btn-record .mic-icon {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn-record .record-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.btn-record .record-time {
    font-size: 0.7rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Recording preview */
.record-preview {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding: 0.4rem 0.5rem;
    background: var(--input-bg);
    border-radius: 6px;
}

.record-preview audio {
    flex: 1;
    height: 32px;
}

.btn-discard-record {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px;
    border-radius: 4px;
    display: flex;
    transition: color 0.2s;
}

.btn-discard-record:hover {
    color: var(--danger);
}

.btn-discard-record svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Drag-drop upload zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary-color);
    background: rgba(70, 130, 180, 0.05);
}

.drop-zone.dragover {
    animation: drop-pulse 1s ease-in-out infinite;
}

@keyframes drop-pulse {
    0%, 100% { background: rgba(70, 130, 180, 0.05); }
    50% { background: rgba(70, 130, 180, 0.12); }
}

.drop-zone-icon {
    color: var(--text-light);
    margin-bottom: 0.3rem;
}

.drop-zone-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.drop-zone-text {
    font-size: 0.75rem;
    color: var(--text-light);
}

.drop-zone-text strong {
    color: var(--primary-color);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Transcript row */
.transcript-row {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.transcript-input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-color);
    font-size: 0.75rem;
    outline: none;
    transition: border-color 0.2s;
}

.transcript-input:focus {
    border-color: var(--primary-color);
}

.btn-small {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 0.35rem 0.55rem;
    border-radius: 5px;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-small:hover {
    background: var(--surface-hover);
    color: var(--text-color);
}

.btn-small:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-small svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn-upload-sample {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    width: 100%;
    justify-content: center;
    margin-top: 0.5rem;
    padding: 0.4rem;
    font-weight: 600;
}

.btn-upload-sample:hover {
    background: #5a9fd4;
}

/* No profile selected message */
.no-profile-msg {
    color: var(--text-light);
    font-size: 0.8rem;
    text-align: center;
    padding: 1.5rem 1rem;
    font-style: italic;
}

/* === Auth Overlay === */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 26, 0.92);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.auth-card h3 {
    color: var(--accent-color);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.auth-card p {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}

.auth-input-group {
    display: flex;
    gap: 0.5rem;
}

.auth-input {
    flex: 1;
    padding: 0.55rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.auth-input:focus {
    border-color: var(--primary-color);
}

.btn-auth {
    padding: 0.55rem 1.25rem;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-auth:hover {
    background: #5a9fd4;
}

.auth-error {
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: 0.75rem;
}

/* === Footer === */
.app-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.7rem;
    color: var(--text-light);
    flex-shrink: 0;
}

.app-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
}

.footer-sep {
    opacity: 0.3;
}

/* === Slide Panels (History) === */
.slide-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.slide-panel-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 45%;
    min-width: 360px;
    max-width: 560px;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
    z-index: 201;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.slide-panel.open {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header h3 {
    color: var(--accent-color);
    font-size: 0.95rem;
}

.panel-close {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    transition: all 0.2s;
}

.panel-close:hover {
    background: var(--surface-hover);
    color: var(--text-color);
}

.panel-close svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

.panel-section {
    margin-bottom: 1rem;
}

.panel-section .setting-select {
    margin-bottom: 0.75rem;
}

/* History items */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--input-bg);
}

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

.history-item-header span {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-color);
}

.history-item-text {
    font-size: 0.8rem;
    color: var(--text-light);
    line-height: 1.4;
    max-height: 3em;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.4rem;
}

.history-item-meta {
    font-size: 0.7rem;
    color: var(--text-light);
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.history-item audio {
    width: 100%;
    height: 32px;
    margin-top: 0.5rem;
}

.history-item-actions button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 3px;
    border-radius: 4px;
    display: flex;
    transition: color 0.2s;
}

.history-item-actions button:hover {
    color: var(--danger);
}

.history-pagination {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    padding: 1rem 0;
}

.page-btn {
    min-width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-light);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover {
    background: var(--surface-hover);
    color: var(--text-color);
}

.page-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* === Toast === */
.toast-container {
    position: fixed;
    bottom: 50px;
    right: 1rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.65rem 1rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    font-size: 0.8rem;
    color: var(--text-color);
    animation: toast-in 0.3s ease;
    max-width: 350px;
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.toast.success {
    border-color: rgba(34, 197, 94, 0.3);
    color: #86efac;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Responsive === */

/* Tablet */
@media (max-width: 1024px) {
    .settings-panel {
        width: 280px;
        min-width: 280px;
    }

    .sidebar {
        width: 220px;
        min-width: 220px;
    }
}

/* Mobile: fixed bars, absolute content */
@media (max-width: 768px) {
    /* Use fixed positioning for all chrome bars */
    .app-layout {
        height: auto;
        min-height: 100%;
        overflow: visible;
        position: relative;
    }

    /* Prevent iOS zoom on focus */
    input[type="text"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }

    /* --- Toolbar: fixed top --- */
    .toolbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 46px;
        padding: 0 0.75rem;
        z-index: 100;
    }

    .toolbar-logo span {
        font-size: 0.95rem;
    }

    .toolbar-link {
        display: none;
    }

    .toolbar-center {
        flex: 1;
        justify-content: center;
    }

    .btn-generate {
        padding: 0.35rem 0.9rem;
        font-size: 0.8rem;
    }

    .toolbar-progress {
        min-width: 100px;
    }

    /* --- Footer: fixed bottom --- */
    .app-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(24px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        font-size: 0.6rem;
        gap: 0.5rem;
        z-index: 100;
    }

    /* --- Mobile tabs: fixed above footer --- */
    .mobile-tabs {
        display: flex !important;
        position: fixed;
        bottom: calc(24px + env(safe-area-inset-bottom, 0px));
        left: 0;
        right: 0;
        height: 48px;
        background: var(--surface);
        border-top: 1px solid var(--border);
        z-index: 100;
    }

    .mobile-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
        background: none;
        border: none;
        color: var(--text-light);
        font-size: 0.6rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        cursor: pointer;
        transition: color 0.2s;
        position: relative;
    }

    .mobile-tab svg {
        width: 20px;
        height: 20px;
        stroke: currentColor;
        fill: none;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .mobile-tab.active {
        color: var(--primary-color);
    }

    .mobile-tab.active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 25%;
        right: 25%;
        height: 2px;
        background: var(--primary-color);
        border-radius: 0 0 2px 2px;
    }

    /* --- Studio layout: fills between toolbar and tabs --- */
    .studio-layout {
        position: fixed;
        top: 46px;
        left: 0;
        right: 0;
        bottom: calc(48px + 24px + env(safe-area-inset-bottom, 0px));
        display: block;
        overflow: hidden;
    }

    /* --- Panels: fill studio-layout, only active shown --- */
    .sidebar,
    .editor-panel,
    .settings-panel {
        display: none !important;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        min-width: unset !important;
        max-width: unset !important;
        border: none !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar.mobile-active {
        display: flex !important;
        flex-direction: column;
        background: var(--surface);
    }

    .editor-panel.mobile-active {
        display: flex !important;
        flex-direction: column;
        padding: 0.75rem;
        background: var(--body-bg);
    }

    .settings-panel.mobile-active {
        display: block !important;
        background: var(--surface);
    }

    /* Sidebar children — 2-col grid on mobile */
    .sidebar-profiles {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
        padding: 0.5rem;
        align-content: start;
    }

    .sidebar-profiles .empty-text {
        grid-column: 1 / -1;
    }

    .profile-card,
    .preset-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 0.75rem 0.5rem;
        border-left: none !important;
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 0;
    }

    .profile-card.selected {
        border-color: var(--primary-color);
        border-left-color: var(--primary-color) !important;
    }

    .preset-card.selected {
        border-color: #8b5cf6;
        border-left-color: #8b5cf6 !important;
    }

    .profile-avatar {
        width: 42px;
        height: 42px;
        font-size: 1rem;
        margin-bottom: 0.3rem;
    }

    .profile-info {
        min-width: 0;
        width: 100%;
    }

    .profile-name {
        font-size: 0.8rem;
    }

    .profile-meta {
        justify-content: center;
        font-size: 0.65rem;
    }

    .profile-actions {
        opacity: 1;
        margin-top: 0.3rem;
    }

    /* Editor children */
    .editor-textarea {
        flex: 1;
        min-height: 120px;
        font-size: 0.9rem;
    }

    /* Slide panels full width */
    .slide-panel {
        width: 100%;
        min-width: unset;
        max-width: unset;
    }

    /* Toast above tabs + footer */
    .toast-container {
        bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    }

    /* History meta wrap */
    .history-item-meta {
        flex-wrap: wrap;
    }
}

/* Hide mobile tabs on desktop */
.mobile-tabs {
    display: none;
}
