/* ===================================================================
   帕金森病语音筛查 — 移动端样式
   移动优先设计，支持桌面端自适应
   =================================================================== */

/* --- CSS 变量 --- */
:root {
    --primary: #4A90D9;
    --primary-dark: #357ABD;
    --danger: #F44336;
    --warning: #FF9800;
    --success: #4CAF50;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-secondary: #7f8c8d;
    --border: #e1e8ed;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 16px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
             "Microsoft YaHei", sans-serif;
}

/* --- 基础重置 --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* --- 容器 --- */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px 16px 40px;
    min-height: 100vh;
    min-height: 100dvh;
}

/* --- 头部 --- */
.header {
    text-align: center;
    padding: 24px 0 20px;
}

.header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* --- 录音卡片 --- */
.recorder-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px 20px;
    box-shadow: var(--shadow);
    text-align: center;
    margin-bottom: 20px;
}

.instruction {
    margin-bottom: 24px;
}

.instruction p {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 4px;
}

.hint {
    font-size: 0.85rem !important;
    color: var(--text-secondary) !important;
}

/* --- 录音按钮 --- */
.record-btn {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--border);
    background: var(--card-bg);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s ease;
    margin: 0 auto 16px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

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

.record-btn:not(:disabled):hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(74, 144, 217, 0.15);
}

.record-btn:not(:disabled):active,
.record-btn.recording {
    border-color: var(--danger);
    background: #FFF5F5;
    box-shadow: 0 0 0 8px rgba(244, 67, 54, 0.15);
    transform: scale(1.05);
}

.record-btn.recording .btn-icon {
    animation: pulse 0.6s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.btn-icon {
    font-size: 2.2rem;
    line-height: 1;
}

.btn-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* --- 倒计时 --- */
.timer {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--danger);
    margin: 8px 0;
}

.timer.warning {
    animation: blink 0.5s ease-in-out infinite;
}

@keyframes blink {
    50% { opacity: 0.3; }
}

/* --- 波形 --- */
.waveform {
    width: 100%;
    height: 80px;
    border-radius: 8px;
    background: #fafbfc;
    border: 1px solid var(--border);
    margin-top: 12px;
}

/* --- 状态提示 --- */
.status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 12px;
    padding: 8px 16px;
    border-radius: 20px;
    background: #f0f4f8;
    display: inline-block;
}

.status.error {
    background: #FFF0F0;
    color: var(--danger);
}

.status.success {
    background: #F0FFF4;
    color: var(--success);
}

/* --- 结果卡片 --- */
.result-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px 20px;
    box-shadow: var(--shadow);
    text-align: center;
}

.result-card h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

/* 环形仪表 */
.result-gauge {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 16px;
}

.gauge-svg {
    width: 100%;
    height: 100%;
}

.gauge-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.probability-num {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
    display: block;
    line-height: 1;
}

.probability-unit {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* 风险标签 */
.risk-badge {
    display: inline-block;
    padding: 8px 24px;
    border-radius: 24px;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
}

.risk-badge.low { background: var(--success); }
.risk-badge.medium { background: var(--warning); }
.risk-badge.high { background: var(--danger); }

.result-summary {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* 免责声明 */
.disclaimer-details {
    text-align: left;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 8px;
}

.disclaimer-details summary {
    cursor: pointer;
    color: var(--warning);
    font-weight: 600;
    margin-bottom: 8px;
}

.disclaimer-details p {
    line-height: 1.5;
}

/* --- 加载遮罩 --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.loading-overlay p {
    margin-top: 16px;
    font-size: 1rem;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* --- 错误提示 --- */
.error-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 0.9rem;
    z-index: 200;
    max-width: 90vw;
    text-align: center;
    animation: slideUp 0.3s ease;
}

.error-toast.hidden { display: none; }

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* --- 通用 --- */
.hidden { display: none !important; }

/* --- 桌面端 --- */
@media (min-width: 768px) {
    .container {
        padding-top: 40px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .record-btn {
        width: 140px;
        height: 140px;
    }

    .btn-icon {
        font-size: 2.6rem;
    }
}
