:root {
    --c-primary: #2563eb;
    --c-primary-hover: #1d4ed8;
    --c-primary-light: #eff6ff;
    --c-success: #0d9488;
    --c-success-hover: #0f766e;
    --c-bg: #f1f5f9;
    --c-card: #ffffff;
    --c-text: #1e293b;
    --c-text-muted: #64748b;
    --c-text-light: #94a3b8;
    --c-border: #e2e8f0;
    --c-shadow: rgba(0, 0, 0, 0.06);
    --c-shadow-lg: rgba(0, 0, 0, 0.1);
    --radius: 14px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Inter', 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.app {
    max-width: 680px;
    margin: 0 auto;
    padding: 0 20px 40px;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 32px 0 24px;
}

.logo {
    width: 44px;
    height: 44px;
    color: var(--c-primary);
    flex-shrink: 0;
}

.header-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-sub {
    font-size: 0.85rem;
    color: var(--c-text-muted);
    margin-top: 2px;
}

/* Card */
.card {
    background: var(--c-card);
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
    padding: 28px;
    box-shadow: 0 1px 3px var(--c-shadow);
    margin-bottom: 20px;
}

/* Label */
.label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--c-text);
    margin-bottom: 8px;
}

/* Voice selector */
.voice-row {
    margin-bottom: 24px;
}

.voice-row .label {
    display: inline;
    margin-right: 12px;
    vertical-align: middle;
}

.select-wrap {
    display: inline-block;
    position: relative;
    min-width: 220px;
}

.select-wrap select {
    width: 100%;
    padding: 9px 36px 9px 14px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--c-text);
    background: var(--c-bg);
    appearance: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.select-wrap::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--c-text-muted);
    pointer-events: none;
}

.select-wrap select:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.voice-count {
    display: inline-block;
    margin-left: 10px;
    font-size: 0.8rem;
    color: var(--c-text-muted);
    background: var(--c-bg);
    padding: 3px 10px;
    border-radius: 20px;
    vertical-align: middle;
}

optgroup {
    font-weight: 600;
    color: var(--c-primary);
    font-size: 0.85rem;
}

option {
    color: var(--c-text);
    font-size: 0.9rem;
    padding: 6px;
}

/* Text area */
.text-row {
    margin-bottom: 24px;
}

textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--c-text);
    font-family: inherit;
    line-height: 1.7;
    resize: vertical;
    min-height: 100px;
    max-height: 280px;
    background: var(--c-bg);
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.char-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}

.char-count {
    font-size: 0.78rem;
    color: var(--c-text-muted);
    font-variant-numeric: tabular-nums;
}

.char-count.over {
    color: #ef4444;
    font-weight: 600;
}

/* Synth button */
.btn-synth {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--c-primary) 0%, #4f46e5 100%);
    color: white;
    font-size: 1.05rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: opacity 0.2s, transform 0.15s;
}

.btn-synth:hover:not(:disabled) {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
}

.btn-synth:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* Output card */
.output-card {
    animation: slideUp 0.3s ease;
}

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

.audio-section {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--c-border);
}

.audio-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--c-text-muted);
}

.audio-header-icon {
    width: 18px;
    height: 18px;
    color: var(--c-primary);
}

audio {
    width: 100%;
}

/* Download button */
.action-row {
    padding-top: 16px;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: var(--c-card);
    color: var(--c-text);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-download:hover {
    background: var(--c-bg);
    border-color: var(--c-text-muted);
}

/* Footer */
.footer {
    text-align: center;
    padding: 32px 0 20px;
    font-size: 0.78rem;
    color: var(--c-text-light);
}

/* Responsive */
@media (max-width: 600px) {
    .app { padding: 0 14px 32px; }
    .header { padding: 24px 0 18px; }
    .card { padding: 20px; }
    .select-wrap { min-width: 100%; margin-top: 6px; }
    .voice-count { margin-top: 6px; }
    .header-text h1 { font-size: 1.25rem; }
}
