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

:root {
    --primary: #c9302c;          /* 蒙古红，呼应传统配色 */
    --primary-dark: #a02422;
    --primary-light: #fbeaea;
    --bg: #f5f6f8;
    --card-bg: #ffffff;
    --border: #e1e4e8;
    --text: #24292e;
    --text-muted: #6a737d;
    --success: #28a745;
    --warning: #f0ad4e;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
    --radius: 10px;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
                 "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ===== 顶部栏 ===== */
.topbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 36px; }
.topbar h1 { font-size: 20px; font-weight: 600; }
.subtitle { font-size: 13px; opacity: .85; margin-top: 2px; }

.status-pill {
    background: rgba(255,255,255,.18);
    padding: 6px 14px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background .2s;
}
.status-pill:hover { background: rgba(255,255,255,.28); }
.status-pill .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #fff;
    animation: pulse 1.5s infinite;
}
.status-pill.ok .dot { background: #7eff7e; animation: none; }
.status-pill.error .dot { background: #ff7e7e; animation: none; }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

/* ===== 容器 & 卡片 ===== */
.container {
    max-width: 880px;
    margin: 24px auto;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.card h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

/* ===== 标签页 ===== */
.input-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 18px;
}
.tab-btn {
    flex: 1;
    padding: 9px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-muted);
    transition: all .2s;
}
.tab-btn.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== 录音按钮 ===== */
.record-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 20px 0;
}
.record-btn {
    width: 110px; height: 110px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 13px;
    transition: all .2s;
    box-shadow: 0 4px 14px rgba(201,48,44,.35);
}
.record-btn:disabled { background: #ccc; box-shadow: none; cursor: not-allowed; }
.record-btn:hover:not(:disabled) { transform: scale(1.05); }
.record-icon { font-size: 28px; }
.record-btn.recording {
    background: #d9534f;
    animation: recording-pulse 1.2s infinite;
}
@keyframes recording-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(217,83,79,.6); }
    50% { box-shadow: 0 0 0 18px rgba(217,83,79,0); }
}
.record-timer {
    font-size: 22px;
    font-family: "SF Mono", Consolas, monospace;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* ===== 上传拖拽区 ===== */
.dropzone {
    display: block;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: var(--bg);
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.dropzone-icon { font-size: 42px; margin-bottom: 8px; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.file-info {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--primary-light);
    border-radius: 8px;
    font-size: 13px;
}

/* ===== 预览 & 翻译按钮 ===== */
.preview-area {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: flex-start;
}
.preview-area audio { width: 100%; }

/* 结果区：原始录音回放 */
.result-audio {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.result-audio-label { font-size: 13px; color: var(--text-muted); }
.result-audio audio { width: 100%; }
.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 11px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: background .2s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 13px;
}
.btn-ghost:hover { background: var(--bg); }

/* ===== 加载动画 ===== */
.spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 翻译结果 ===== */
.result-empty {
    text-align: center;
    padding: 40px 0;
    color: var(--text-muted);
}
.empty-icon { font-size: 48px; opacity: .4; margin-bottom: 10px; }

.result-block {
    padding: 16px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 12px;
}
.result-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.lang-tag {
    background: var(--primary);
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.stage-tag {
    font-size: 12px;
    color: var(--warning);
    padding: 2px 8px;
    background: #fff3cd;
    border-radius: 10px;
}
.stage-tag.done { color: var(--success); background: #d4edda; }
.result-text {
    font-size: 17px;
    line-height: 1.7;
    min-height: 28px;
    color: var(--text);
}
.result-text.mongolian {
    font-family: "Segoe UI", "Arial", sans-serif;
    letter-spacing: .3px;
}
.result-text.chinese { font-weight: 500; }
.result-text.empty { color: var(--text-muted); font-style: italic; }

.timing-info {
    margin-top: 12px;
    padding: 10px 14px;
    background: #f1f8ff;
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-muted);
    font-family: "SF Mono", Consolas, monospace;
}
.error-info {
    margin-top: 12px;
    padding: 12px 14px;
    background: #fdecea;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    color: var(--primary-dark);
    font-size: 13px;
}

/* ===== 历史记录 ===== */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.history-header h2 { margin-bottom: 0; }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
    padding: 12px 14px;
    background: var(--bg);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.history-item .row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
}
.history-item .text-pair {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.history-item .mongolian-line { color: var(--text); font-size: 14px; }
.history-item .chinese-line { color: var(--text); font-size: 14px; font-weight: 500; }
.history-item .actions { display: flex; gap: 6px; }
.history-item .history-audio {
    width: 100%;
    max-width: 360px;
    margin: 8px 0;
    height: 32px;  /* 紧凑型播放器 */
}
.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 13px;
    padding: 2px 6px;
    border-radius: 4px;
}
.icon-btn:hover { background: #fff; color: var(--primary); }
.empty-hint {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 0;
    font-size: 13px;
}

.hidden { display: none !important; }

/* ===== 页脚 ===== */
.footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    padding: 24px 16px;
}

/* ===== 移动端适配 ===== */
@media (max-width: 600px) {
    .topbar { flex-direction: column; gap: 10px; align-items: flex-start; }
    .card { padding: 16px; }
    .record-btn { width: 90px; height: 90px; }
}
