*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #1a1a2e;
    --bg-surface: #16213e;
    --bg-card: #1f2b47;
    --bg-input: #0f1729;
    --border: #2a3a5c;
    --border-focus: #4a6fa5;
    --text: #e0e0e0;
    --text-muted: #8899aa;
    --primary: #4a9eff;
    --primary-hover: #3a8eef;
    --danger: #e74c5e;
    --danger-hover: #d73c4e;
    --success: #4ecb71;
    --warning: #f0a030;
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px;
}

header {
    margin-bottom: 32px;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: #fff;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-surface);
    padding: 4px;
    border-radius: var(--radius);
}

.tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

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

.tab.active {
    background: var(--primary);
    color: #fff;
}

/* Tab content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Form elements */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

textarea,
input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
    resize: vertical;
}

textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: var(--border-focus);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238899aa' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    padding: 6px 12px;
    font-size: 0.8rem;
    border: 1px solid var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger);
    color: #fff;
}

/* Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.hidden {
    display: none !important;
}

/* Status messages */
.status {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.status.info {
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.3);
    color: var(--primary);
}

.status.success {
    background: rgba(78, 203, 113, 0.1);
    border: 1px solid rgba(78, 203, 113, 0.3);
    color: var(--success);
}

.status.error {
    background: rgba(231, 76, 94, 0.1);
    border: 1px solid rgba(231, 76, 94, 0.3);
    color: var(--danger);
}

/* Audio result */
.audio-result {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.audio-result audio {
    flex: 1;
    min-width: 200px;
    height: 40px;
}

/* Profiles list */
.profiles-section {
    margin-bottom: 32px;
}

.profiles-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: #fff;
}

.profiles-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.profile-item .profile-name {
    font-weight: 500;
}

.profiles-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 16px;
    text-align: center;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* Accordion */
.accordion {
    margin-bottom: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.accordion summary {
    padding: 14px 16px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.accordion summary::-webkit-details-marker {
    display: none;
}

.accordion summary::after {
    content: '\25B6';
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.accordion[open] summary::after {
    transform: rotate(90deg);
}

.accordion .profiles-list {
    padding: 0 16px 16px;
}

/* Profile creation steps */
.profile-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.step {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: opacity 0.3s;
}

.step.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.step-number {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step.done .step-number {
    background: var(--success);
}

.step-title {
    font-weight: 500;
    font-size: 0.95rem;
}

.step-body {
    padding: 16px;
}

/* Drop zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(74, 158, 255, 0.05);
    color: var(--text);
}

.file-info {
    margin: 12px 0;
    padding: 10px 14px;
    background: var(--bg-input);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.loading {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-form {
    width: 100%;
    max-width: 360px;
    background: var(--bg-card);
    padding: 32px 28px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.login-form h1 {
    text-align: center;
    margin-bottom: 24px;
    color: #fff;
}

.login-form .status {
    margin-bottom: 16px;
}

/* Header */
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.header-row h1 {
    margin-bottom: 0;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 16px 12px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .audio-result {
        flex-direction: column;
        align-items: stretch;
    }

    .audio-result audio {
        width: 100%;
    }

    .audio-result .btn {
        text-align: center;
        justify-content: center;
    }
}
