/* ===========================================
   音乐生成工具 - 响应式样式
   设计方向：现代简约 + 柔和渐变 + 卡片式布局
   =========================================== */

:root {
    /* 色彩系统 */
    --primary: #4F46E5;
    --primary-light: #6366F1;
    --primary-dark: #4338CA;
    --accent: #F97316;
    --accent-light: #FB923C;
    --bg-main: #FAFAF9;
    --bg-card: #FFFFFF;
    --bg-input: #F5F5F4;
    --text-primary: #1C1917;
    --text-secondary: #57534E;
    --text-muted: #A8A29E;
    --border: #E7E5E4;
    --border-focus: #A5B4FC;
    --success: #22C55E;
    --error: #EF4444;
    --warning: #F59E0B;

    /* 圆角 */
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    /* 阴影 */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.06);
    --shadow-md: 0 6px 12px -2px rgba(0,0,0,0.08), 0 3px 6px -2px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 20px -4px rgba(0,0,0,0.1), 0 6px 10px -4px rgba(0,0,0,0.1);

    /* 间距 */
    --space-xs: 6px;
    --space-sm: 10px;
    --space-md: 20px;
    --space-lg: 28px;
    --space-xl: 40px;

    /* 字体 - 高清屏基准 */
    --font-sans: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --base-font-size: 18px;
    --input-font-size: 18px;
    --btn-font-size: 18px;
    --touch-target: 56px;

    /* 安全区域 - iPhone 刘海/灵动岛适配 */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* 触摸交互优化 */
button, .btn, .style-preset, .mode-option, .history-link, summary {
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* 防止 iOS 双击缩放 */
input, textarea, select, button {
    font-size: 16px;
}

/* 可滚动区域 iOS 平滑滚动 */
.lyrics-card, .login-disclaimer-content, .history-list {
    -webkit-overflow-scrolling: touch;
}

/* 主内容区域给 sticky header 留空间 */
.main {
    scroll-margin-top: 60px;
}

html {
    font-size: var(--base-font-size);
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
    padding-left: var(--safe-area-left);
    padding-right: var(--safe-area-right);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* ===========================================
   主容器
   =========================================== */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===========================================
   顶部导航
   =========================================== */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding-top: var(--safe-area-top);
}

.header-content {
    max-width: 100%;
    margin: 0 auto;
    padding: var(--space-sm) var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: nowrap;
    min-height: 52px;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
}

.logo-icon {
    font-size: 1.3rem;
}

.logo-text {
    white-space: nowrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.quota {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    min-width: 52px;
    flex-shrink: 0;
}

.quota-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.quota-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

.username {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.btn-logout {
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 40px;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-logout:active {
    background: var(--bg-input);
    border-color: var(--primary);
    color: var(--primary);
}

/* 桌面端才显示 hover 效果（移动端用 active） */
@media (hover: hover) {
    .btn-logout:hover {
        background: var(--bg-input);
        border-color: var(--text-muted);
    }

    .style-preset:hover {
        border-color: var(--primary);
        color: var(--primary);
        background: #EEF2FF;
    }

    .btn-primary:hover:not(:disabled) {
        background: linear-gradient(135deg, var(--primary-dark), var(--primary));
        transform: translateY(-1px);
        box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
    }

    .login-footer a:hover {
        text-decoration: underline;
    }
}

/* ===========================================
   消息提示 - 固定 Toast
   =========================================== */
.message {
    display: none;
    position: fixed;
    top: calc(60px + var(--safe-area-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    text-align: center;
    max-width: calc(100vw - 32px);
    width: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    animation: toastIn 0.3s ease;
}

.message.show {
    display: block;
}

.message.error {
    background: #FEF2F2;
    color: var(--error);
    border: 2px solid #FECACA;
}

.message.success {
    background: #F0FDF4;
    color: var(--success);
    border: 2px solid #BBF7D0;
}

.message.info {
    background: #EFF6FF;
    color: #1D4ED8;
    border: 2px solid #BFDBFE;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===========================================
   微信环境提示横幅
   =========================================== */
.wechat-banner {
    padding: var(--space-sm) var(--space-lg);
    margin: var(--space-sm) var(--space-md);
    background: #FEF3C7;
    border: 1px solid #FDE68A;
    border-radius: var(--radius-md);
    color: #92400E;
    font-size: 0.9rem;
    text-align: center;
    font-weight: 500;
}

/* ===========================================
   内嵌音频播放器
   =========================================== */
.player-card {
    background: var(--bg-input);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin-top: var(--space-md);
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.player-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.player-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    line-height: 1;
}

.player-audio {
    width: 100%;
    border-radius: var(--radius-sm);
    outline: none;
}

.history-player {
    width: 100%;
    padding: 0;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===========================================
   浏览器打开引导
   =========================================== */
.browser-guide {
    background: #EEF2FF;
    border: 2px solid #A5B4FC;
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    margin-top: var(--space-md);
    position: relative;
    text-align: center;
    font-size: 0.95rem;
    color: var(--primary-dark);
    animation: slideDown 0.3s ease;
}

.browser-guide p {
    margin: 0;
}

.guide-close {
    position: absolute;
    top: var(--space-xs);
    right: var(--space-sm);
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--text-muted);
    cursor: pointer;
}

/* ===========================================
   主内容区
   =========================================== */
.main {
    flex: 1;
    padding: var(--space-md);
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
}

/* ===========================================
   步骤卡片
   =========================================== */
.step {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-lg);
}

.step-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.step-num {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    border-radius: 50%;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.step h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===========================================
   免责声明
   =========================================== */
.disclaimer {
    background: #FFFBEB;
    border: 2px solid #FDE68A;
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    overflow: hidden;
}

.disclaimer summary {
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-weight: 600;
    font-size: 1rem;
    color: #92400E;
    user-select: none;
}

.disclaimer-icon {
    font-size: 1.2rem;
}

.disclaimer-arrow {
    margin-left: auto;
    transition: transform 0.2s;
    font-size: 1.4rem;
}

.disclaimer[open] .disclaimer-arrow {
    transform: rotate(90deg);
}

.disclaimer-content {
    padding: 0 var(--space-lg) var(--space-lg);
}

.disclaimer-content ol {
    padding-left: var(--space-lg);
    font-size: 0.95rem;
    color: #92400E;
    line-height: 1.8;
}

.disclaimer-content li + li {
    margin-top: var(--space-sm);
}

/* ===========================================
   模式选择器
   =========================================== */
.mode-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.mode-option {
    cursor: pointer;
}

.mode-option input {
    display: none;
}

.mode-card {
    display: grid;
    grid-template-areas:
        "icon title"
        "icon desc";
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-input);
    border: 3px solid transparent;
    border-radius: var(--radius-lg);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                background 0.2s,
                border-color 0.2s;
    text-align: left;
    min-height: 80px;
}

/* Hover 效果：未选中时悬停有轻微提升 + 焦点色描边 */
.mode-option:hover .mode-card {
    border-color: var(--border-focus);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.mode-option input:checked + .mode-card {
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15), var(--shadow-md);
    transform: translateY(-2px);
}

.mode-icon {
    grid-area: icon;
    font-size: 1.9rem;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.mode-title {
    grid-area: title;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
}

.mode-desc {
    grid-area: desc;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ===========================================
   输入框和按钮
   =========================================== */
.input-section {
    margin-bottom: var(--space-md);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.input, .textarea {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    font-size: var(--input-font-size);
    font-family: inherit;
    color: var(--text-primary);
    transition: all 0.2s;
}

.input:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.input::placeholder, .textarea::placeholder {
    color: var(--text-muted);
}

/* Step 2 风格描述：多行 textarea */
.style-textarea {
    min-height: 96px;
    max-height: 220px;
    resize: vertical;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

.textarea {
    min-height: 220px;
    resize: vertical;
    line-height: 1.8;
}

.theme-textarea {
    min-height: 100px;
    max-height: 200px;
    line-height: 1.6;
}

.theme-hints {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.hint-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.hint-tag {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.hint-tag:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #EEF2FF;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-xl);
    font-size: var(--btn-font-size);
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s;
    min-height: var(--touch-target);
}

.btn-icon {
    font-size: 1.2rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.btn-primary:active {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    transform: scale(0.98);
}

.btn-primary:disabled {
    background: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.btn-secondary:active {
    background: var(--border);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:active {
    background: #EEF2FF;
}

/* ===========================================
   歌词显示区
   =========================================== */
.lyrics-section {
    margin-top: var(--space-lg);
}

.lyrics-card {
    background: var(--bg-input);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    max-height: 320px;
    overflow-y: auto;
}

.lyrics-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--text-primary);
}

.lyrics-actions {
    margin-bottom: var(--space-md);
}

.modify-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
}

/* ===========================================
   下载成功卡片
   =========================================== */
.success-card {
    text-align: center;
    padding: var(--space-xl);
    background: linear-gradient(135deg, #F0FDF4, #DCFCE7);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-lg);
}

.success-icon {
    font-size: 3.5rem;
    margin-bottom: var(--space-md);
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.success-text {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.success-hint {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.download-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.btn-download {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    box-shadow: 0 6px 16px rgba(249, 115, 22, 0.35);
}

.btn-download:active {
    transform: scale(0.98);
}

.btn-home {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border);
    transition: all 0.2s;
}

.btn-home:active {
    background: var(--bg-input);
    border-color: var(--primary);
    color: var(--primary);
}

@media (hover: hover) {
    .btn-home:hover {
        background: var(--bg-input);
        border-color: var(--text-muted);
    }
}

/* ===========================================
   历史记录
   =========================================== */
.history-list {
    display: flex;
    flex-direction: column;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) 0;
    border-bottom: 1px solid var(--border);
    gap: var(--space-md);
}

.history-item:last-child {
    border-bottom: none;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-type {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.history-time {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.history-expiry {
    font-size: 0.85rem;
    color: var(--warning);
    margin-top: 4px;
}

.history-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s;
}

.history-link:active {
    background: var(--primary-dark);
}

.history-wechat-actions {
    display: flex;
    gap: var(--space-xs);
    flex-shrink: 0;
}

.history-wechat-actions .history-link {
    font-size: 0.82rem;
    padding: var(--space-xs) var(--space-sm);
    min-height: 38px;
}

.history-wechat-actions .btn-play {
    background: #6366F1;
}

.history-wechat-actions .btn-copy {
    background: #F97316;
}

/* 非微信环境的按钮组 */
.history-actions {
    display: flex;
    gap: var(--space-xs);
    flex-shrink: 0;
}

.history-actions .history-link {
    font-size: 0.82rem;
    padding: var(--space-xs) var(--space-sm);
    min-height: 38px;
}

.history-actions .btn-play {
    background: #6366F1;
}

@media only screen and (max-width: 480px) {
    .history-actions {
        flex-direction: column;
        width: 100%;
    }

    .history-actions .history-link {
        justify-content: center;
        font-size: 0.85rem;
    }
}

@media only screen and (max-width: 480px) {
    .history-wechat-actions {
        flex-direction: column;
        width: 100%;
    }

    .history-wechat-actions .history-link {
        justify-content: center;
        font-size: 0.85rem;
    }
}

/* ===========================================
   风格预设按钮
   =========================================== */
.style-presets {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.style-preset {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.style-preset:active {
    transform: scale(0.96);
    border-color: var(--primary);
    color: var(--primary);
    background: #EEF2FF;
}

.style-preset.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.vocal-type-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.vocal-type-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.vocal-preset {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.vocal-preset:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #EEF2FF;
}

.vocal-preset:active {
    transform: scale(0.96);
    border-color: var(--primary);
    color: var(--primary);
    background: #EEF2FF;
}

.vocal-preset.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ===========================================
   生成中遮罩层
   =========================================== */
.generating-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(28, 25, 23, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: white;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 1000;
    padding: var(--space-xl);
}

.generating-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.generating-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xl);
}

.hourglass {
    font-size: 5rem;
    animation: rotate 2s linear infinite;
    filter: drop-shadow(0 8px 24px rgba(79, 70, 229, 0.5));
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(180deg); }
    100% { transform: rotate(360deg); }
}

.wave {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(79, 70, 229, 0.35);
    animation: wave 2s ease-in-out infinite;
}

.wave:nth-child(2) {
    animation-delay: 0.5s;
}

.wave:nth-child(3) {
    animation-delay: 1s;
}

@keyframes wave {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(3.5);
        opacity: 0;
    }
}

.generating-animation {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer {
    font-size: 2.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: white;
    letter-spacing: 2px;
}

.progress-bar-container {
    width: 240px;
    height: 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 6px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.generating-text {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.85);
    text-align: center;
}

/* ===========================================
   手机适配 (0 - 480px) - 移动优先基础样式
   =========================================== */
@media only screen and (max-width: 480px) {
    :root {
        --base-font-size: 16px;
        --input-font-size: 16px;
        --btn-font-size: 16px;
        --touch-target: 52px;
        --space-md: 16px;
        --space-lg: 22px;
        --space-xl: 30px;
    }

    /* 在小屏上隐藏用户名 */
    .header-content .username {
        display: none;
    }

    .main {
        padding: var(--space-sm);
    }

    .step {
        padding: var(--space-md);
        border-radius: var(--radius-lg);
        margin-bottom: var(--space-sm);
    }

    .step-header {
        gap: var(--space-sm);
        margin-bottom: var(--space-md);
    }

    .step-num {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }

    .step h2 {
        font-size: 1.15rem;
    }

    /* 模式选择器 - 全宽堆叠 */
    .mode-selector {
        gap: var(--space-sm);
    }

    /* 输入框 */
    .input, .textarea {
        padding: var(--space-sm) var(--space-md);
        border-radius: var(--radius-md);
    }

    .textarea {
        min-height: 160px;
        font-size: 16px;
    }

    /* 按钮 */
    .btn {
        padding: var(--space-sm) var(--space-md);
        border-radius: var(--radius-md);
        width: 100%;
    }

    .btn-icon {
        font-size: 1.1rem;
    }

    /* 歌词卡片 */
    .lyrics-card {
        padding: var(--space-md);
        max-height: 260px;
    }

    .lyrics-text {
        font-size: 0.95rem;
        line-height: 1.7;
    }

    /* 修改区域 - 垂直堆叠 */
    .modify-section {
        flex-direction: column;
    }

    .modify-section .input {
        width: 100%;
        margin-bottom: 0;
    }

    /* 成功卡片 */
    .success-card {
        padding: var(--space-lg);
    }

    .success-icon {
        font-size: 2.8rem;
    }

    .success-text {
        font-size: 1.2rem;
    }

    .success-hint {
        font-size: 0.85rem;
    }

    /* 下载按钮 - 垂直排列 */
    .download-actions {
        flex-direction: column;
    }

    .download-actions .btn {
        width: 100%;
    }

    /* 风格预设 */
    .style-presets {
        gap: var(--space-xs);
    }

    .style-preset {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.82rem;
        min-height: 38px;
        border-radius: var(--radius-md);
    }

    .vocal-preset {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.82rem;
        min-height: 38px;
        border-radius: var(--radius-md);
    }

    /* 历史记录 */
    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
        padding: var(--space-md) 0;
    }

    .history-link {
        align-self: stretch;
        justify-content: center;
        padding: var(--space-sm) var(--space-md);
        border-radius: var(--radius-md);
    }

    .history-type {
        font-size: 0.95rem;
    }

    .history-time, .history-expiry {
        font-size: 0.8rem;
    }

    /* 消息提示 */
    .message {
        top: calc(44px + var(--safe-area-top));
        padding: var(--space-sm) var(--space-md);
        font-size: 0.9rem;
        border-radius: var(--radius-md);
        max-width: calc(100vw - 16px);
        left: 50%;
        transform: translateX(-50%);
    }

    .message.show {
        transform: translateX(-50%);
    }

    @keyframes toastIn {
        from {
            opacity: 0;
            transform: translateX(-50%) translateY(-12px);
        }
        to {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }
    }

    .wechat-banner {
        margin: var(--space-xs) var(--space-sm);
        font-size: 0.82rem;
        padding: var(--space-xs) var(--space-md);
    }

    /* 内嵌播放器 - 移动端 */
    .player-card {
        padding: var(--space-sm);
    }

    .player-title {
        font-size: 0.88rem;
    }

    /* 浏览器引导 - 移动端 */
    .browser-guide {
        font-size: 0.85rem;
        padding: var(--space-sm) var(--space-md);
    }

    /* 免责声明 */
    .disclaimer summary {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.9rem;
    }

    .disclaimer-content {
        padding: 0 var(--space-md) var(--space-md);
    }

    .disclaimer-content ol {
        font-size: 0.85rem;
    }

    /* 生成中遮罩层 */
    .generating-overlay {
        padding: var(--space-lg);
    }

    .hourglass {
        font-size: 3.5rem;
    }

    .timer {
        font-size: 2rem;
    }

    .progress-bar-container {
        width: 180px;
        height: 10px;
    }

    .progress-text {
        font-size: 1.2rem;
    }

    .generating-text {
        font-size: 1rem;
    }

    .wave {
        width: 80px;
        height: 80px;
    }

    .generating-animation {
        width: 80px;
        height: 80px;
    }

    /* 配额显示更紧凑 */
    .quota {
        min-width: 44px;
        padding: var(--space-xs);
    }

    .quota-label {
        font-size: 0.55rem;
    }

    .quota-value {
        font-size: 0.72rem;
    }

    .btn-logout {
        font-size: 0.72rem;
        min-height: 36px;
        padding: 4px 8px;
    }

    .logo-text {
        font-size: 0.9rem;
    }
}
@media only screen and (min-width: 481px) and (max-width: 768px) {
    .btn {
        width: auto;
    }

    .main {
        padding: var(--space-lg);
    }

    .step {
        padding: var(--space-xl);
    }

    .mode-selector {
        gap: var(--space-lg);
    }

    .download-actions {
        flex-direction: row;
    }

    .download-actions .btn {
        flex: 1;
    }

    .modify-section {
        flex-direction: row;
        align-items: center;
    }

    .modify-section .input {
        flex: 1;
        margin-bottom: 0;
    }

    .history-item {
        flex-direction: row;
        align-items: center;
    }

    .history-link {
        align-self: auto;
    }
}

/* ===========================================
   桌面端覆盖样式 (769px+)
   =========================================== */
@media only screen and (min-width: 769px) {
    :root {
        --base-font-size: 18px;
        --input-font-size: 18px;
        --btn-font-size: 18px;
    }

    .btn {
        width: auto;
    }

    .header-content {
        padding: var(--space-md) var(--space-xl);
    }

    .header-content .username {
        display: inline;
    }

    .logo {
        font-size: 1.2rem;
    }

    .logo-icon {
        font-size: 1.6rem;
    }

    .quota {
        flex-direction: row;
        gap: var(--space-sm);
        padding: var(--space-xs) var(--space-md);
        min-width: auto;
    }

    .quota-label {
        font-size: 0.7rem;
    }

    .quota-value {
        font-size: 0.9rem;
    }

    .btn-logout {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.9rem;
        min-height: var(--touch-target);
    }

    .main {
        padding: var(--space-xl);
    }

    .step {
        padding: var(--space-xl);
        border-radius: var(--radius-xl);
    }

    .step-header {
        margin-bottom: var(--space-xl);
    }

    .step-num {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .step h2 {
        font-size: 1.4rem;
    }

    .mode-selector {
        gap: var(--space-lg);
    }

    .input-group {
        flex-direction: row;
    }

    .input-group .btn {
        width: auto;
        white-space: nowrap;
    }

    .lyrics-card {
        max-height: 400px;
    }

    .modify-section {
        flex-direction: row;
        align-items: center;
    }

    .modify-section .input {
        flex: 1;
        margin: 0;
    }

    .modify-section .btn {
        width: auto;
    }

    .download-actions {
        flex-direction: row;
    }

    .download-actions .btn {
        flex: 1;
        max-width: 220px;
    }

    .history-item {
        flex-direction: row;
        align-items: center;
        padding: var(--space-lg) 0;
    }

    .history-link {
        align-self: auto;
    }

    .style-presets {
        gap: var(--space-sm);
    }

    .style-preset {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.9rem;
        min-height: 44px;
    }
}

/* ===========================================
   动画增强
   =========================================== */
.step {
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step:nth-child(2) {
    animation-delay: 0.1s;
}

.step:nth-child(3) {
    animation-delay: 0.2s;
}

/* ===========================================
   空状态
   =========================================== */
.history-list:empty::after,
#history-list:empty::after {
    content: '暂无生成记录';
    display: block;
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
    font-size: 1rem;
}

/* ===========================================
   登录页面
   =========================================== */

/* ===========================================
   减少动画偏好
   =========================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .step {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

/* 纯音乐模式：mode-card 选中时的紫色高亮（区别于歌曲的蓝紫色） */
.mode-option:has(input[value="instrumental"]:checked) + * .mode-card,
.mode-option input[value="instrumental"]:checked + .mode-card {
    background: #F3E8FF;
    border-color: #9333EA;
    box-shadow: 0 0 0 4px rgba(147, 51, 234, 0.15);
}

/* 历史记录中的纯音乐 badge */
.history-badge {
    display: inline-block;
    background: #F3E8FF;
    color: #6B21A8;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    margin-left: 8px;
    font-weight: 500;
    vertical-align: middle;
}
