:root {
    --cv-primary: #4f46e5;
    --cv-danger: #dc2626;
    --cv-warn: #d97706;
    --cv-ok: #059669;
    --cv-gray-50: #f9fafb;
    --cv-gray-100: #f3f4f6;
    --cv-gray-200: #e5e7eb;
    --cv-gray-400: #9ca3af;
    --cv-gray-600: #4b5563;
    --cv-gray-800: #1f2937;
    /* 微信通话配色 */
    --cv-wx-green: #07c160;
    --cv-wx-red: #fa5151;
    --cv-call-bg-1: #38424c;
    --cv-call-bg-2: #1f262d;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--cv-gray-100);
    color: var(--cv-gray-800);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ==================== 待机页 ==================== */

.cv-app {
    max-width: 560px;
    margin: 0 auto;
    padding: 12px 12px 28px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cv-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px; }
.cv-title { display: flex; align-items: center; gap: 10px; }
.cv-logo { font-size: 26px; }
.cv-title h1 { margin: 0; font-size: 18px; }
.cv-sub { margin: 2px 0 0; font-size: 12px; color: var(--cv-gray-400); }
.cv-header-actions { display: flex; gap: 6px; align-items: center; }

.cv-icon-btn {
    width: 38px; height: 38px; border: none; border-radius: 10px;
    background: white; font-size: 17px; cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex; align-items: center; justify-content: center;
    text-decoration: none; color: inherit;
}
.cv-icon-btn.on { background: #fee2e2; }

.cv-card { background: white; border-radius: 14px; padding: 14px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }

.cv-status-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cv-badge {
    font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px;
    background: var(--cv-gray-100); color: var(--cv-gray-600);
}
.cv-badge-running { background: #ecfdf5; color: var(--cv-ok); }
.cv-badge-done { background: #eef2ff; color: var(--cv-primary); }
.cv-badge-error { background: #fef2f2; color: var(--cv-danger); }
.cv-elapsed { font-size: 12px; color: var(--cv-gray-400); }

.cv-status-topic { font-size: 15px; font-weight: 600; line-height: 1.45; margin-bottom: 10px; word-break: break-word; }
.cv-status-line { display: flex; gap: 8px; font-size: 13px; line-height: 1.5; margin-bottom: 4px; }
.cv-label { color: var(--cv-gray-400); flex-shrink: 0; width: 42px; }
.cv-warn { color: var(--cv-warn); font-weight: 600; }

.cv-progress-wrap { margin-top: 10px; }
.cv-progress-wrap summary { font-size: 12px; color: var(--cv-gray-600); cursor: pointer; }
.cv-progress {
    margin: 8px 0 0; padding-left: 18px; font-size: 12px; color: var(--cv-gray-600);
    line-height: 1.6; max-height: 190px; overflow-y: auto;
}

.cv-call { display: flex; flex-direction: column; gap: 10px; }
.cv-call-btn {
    width: 100%; height: 54px; border: none; border-radius: 14px;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: white; font-size: 16px; font-weight: 600; cursor: pointer;
    box-shadow: 0 6px 18px rgba(79,70,229,0.28);
}
.cv-call-btn.active { background: linear-gradient(135deg, #059669, #10b981); }
.cv-call-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.cv-call-secondary { display: flex; gap: 10px; }
.cv-btn {
    flex: 1; height: 44px; border: 1px solid var(--cv-gray-200); border-radius: 12px;
    background: white; font-size: 14px; font-weight: 600; color: var(--cv-gray-600); cursor: pointer;
}
.cv-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cv-btn-warn { color: var(--cv-warn); border-color: #fde68a; background: #fffbeb; }
.cv-btn-danger { color: var(--cv-danger); border-color: #fecaca; background: #fef2f2; }
.cv-btn-primary { color: white; border: none; background: linear-gradient(135deg, #4f46e5, #6366f1); }
.cv-btn-light { color: #e9eef3; border-color: rgba(255,255,255,0.28); background: rgba(255,255,255,0.14); }

.cv-tip { font-size: 12px; color: var(--cv-gray-400); line-height: 1.6; }

.cv-transcript-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 13px; font-weight: 600; margin-bottom: 10px;
}
.cv-link-btn { border: none; background: none; color: var(--cv-primary); font-size: 12px; cursor: pointer; }
.cv-link-light { color: #9fd8b6; }
.cv-transcript-body {
    max-height: 320px; overflow-y: auto; display: flex; flex-direction: column;
    gap: 8px; padding-bottom: 8px;
}
.cv-transcript-dark { max-height: 190px; }
.cv-empty { color: var(--cv-gray-400); font-size: 13px; text-align: center; padding: 18px 0; }
.cv-empty-dark { color: rgba(255,255,255,0.45); }

.cv-row { display: flex; flex-direction: column; gap: 2px; }
.cv-row-user { align-items: flex-end; }
.cv-who { font-size: 11px; color: var(--cv-gray-400); }
.cv-bubble {
    max-width: 82%; padding: 9px 12px; border-radius: 12px; font-size: 14px;
    line-height: 1.5; word-break: break-word; background: var(--cv-gray-100);
}
.cv-row-user .cv-bubble { background: #dcf8c6; }
.cv-row-note .cv-bubble { background: #fffbeb; color: var(--cv-warn); font-size: 12px; }
/* 通话页（深色）里的气泡 */
.cv-transcript-dark .cv-bubble { background: rgba(255,255,255,0.12); color: #eef2f6; }
.cv-transcript-dark .cv-row-user .cv-bubble { background: rgba(7,193,96,0.28); color: #eafff2; }
.cv-transcript-dark .cv-row-note .cv-bubble { background: rgba(255,255,255,0.08); color: #ffd79a; }
.cv-transcript-dark .cv-who { color: rgba(255,255,255,0.45); }

.cv-text-fallback { display: flex; gap: 8px; margin-top: 10px; }
.cv-text-fallback input {
    flex: 1; height: 42px; border-radius: 10px; border: 1px solid var(--cv-gray-200);
    padding: 0 12px; font-size: 14px;
}
.cv-text-fallback .cv-btn { flex: 0 0 76px; }
.cv-text-dark input {
    background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.22); color: #f2f6fa;
}
.cv-text-dark input::placeholder { color: rgba(255,255,255,0.45); }

/* 最小化悬浮条 */
.cv-min-bar {
    display: flex; align-items: center; gap: 8px; cursor: pointer;
    background: var(--cv-wx-green); color: white; border-radius: 12px;
    padding: 10px 14px; font-size: 13px; box-shadow: 0 6px 16px rgba(7,193,96,0.32);
}
.cv-min-avatar {
    width: 24px; height: 24px; border-radius: 7px; background: rgba(255,255,255,0.22);
    display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.cv-min-text { font-weight: 600; }
.cv-min-timer { font-variant-numeric: tabular-nums; opacity: 0.92; }
.cv-min-enter { margin-left: auto; opacity: 0.92; }

/* 上传文件 */
.cv-btn-icon { flex: 0 0 46px !important; font-size: 17px; }
.cv-upload-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cv-upload-item {
    display: flex; align-items: center; gap: 8px; padding: 7px 10px;
    background: #f6fffa; border: 1px solid #d8f3e3; border-radius: 9px; font-size: 12px;
    color: var(--cv-gray-600); cursor: pointer;
}
.cv-upload-item:hover { background: #ecfff5; }
.cv-upload-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-upload-size { color: var(--cv-gray-400); flex-shrink: 0; }
.cv-upload-hint { color: var(--cv-ok); flex-shrink: 0; }
.cv-upload-list-dark .cv-upload-item {
    background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.18); color: #e9eef3;
}
.cv-upload-list-dark .cv-upload-size { color: rgba(255,255,255,0.5); }
.cv-upload-list-dark .cv-upload-hint { color: #7ee0a6; }

/* 任务列表 */
.cv-task-list { display: flex; flex-direction: column; gap: 8px; max-height: 380px; overflow-y: auto; }
.cv-task-item {
    border: 1px solid #e8eaed; border-radius: 10px; padding: 9px 11px; cursor: pointer;
    background: #fff; transition: background .15s;
}
.cv-task-item:hover { background: #f7fffb; }
.cv-task-item.cv-task-open { background: #f2fff8; border-color: #bfe9d3; }
.cv-task-top { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.cv-task-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--cv-gray-400); }
.cv-task-dot.run { background: #07c160; animation: cvPulse 1.2s infinite; }
.cv-task-dot.done { background: #07c160; }
.cv-task-dot.error { background: var(--cv-wx-red); }
.cv-task-dot.cancel { background: #f0ad4e; }
@keyframes cvPulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.cv-task-state { font-size: 12px; font-weight: 600; color: var(--cv-gray-700); }
.cv-task-meta { margin-left: auto; font-size: 11px; color: var(--cv-gray-400); flex-shrink: 0; }
.cv-task-text { font-size: 13px; color: var(--cv-gray-700); line-height: 1.45; word-break: break-all; }
.cv-task-result { margin-top: 5px; font-size: 12px; color: var(--cv-gray-500); line-height: 1.45;
    white-space: pre-wrap; word-break: break-all; }
.cv-task-progress { margin: 6px 0 0; padding: 7px 9px; background: #f7f8f9; border-radius: 8px;
    max-height: 220px; overflow-y: auto; list-style: none; }
.cv-task-progress li { font-size: 11px; color: var(--cv-gray-500); line-height: 1.5; word-break: break-all; }
.cv-task-actions { display: flex; gap: 8px; margin-top: 8px; }
.cv-task-actions button { font-size: 12px; padding: 4px 10px; }

/* 预约来电 */
.cv-scheduled-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.cv-scheduled-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    background: #f6fffa; border: 1px solid #d8f3e3; border-radius: 10px;
}
.cv-scheduled-time {
    font-size: 14px; font-weight: 700; color: var(--cv-ok); flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.cv-scheduled-text {
    font-size: 13px; color: var(--cv-gray-600); flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cv-scheduled-cancel {
    border: none; background: none; color: var(--cv-gray-400); font-size: 15px;
    cursor: pointer; padding: 2px 4px; flex-shrink: 0;
}
.cv-scheduled-cancel:hover { color: var(--cv-danger); }
.cv-schedule-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cv-schedule-form input {
    height: 42px; border-radius: 10px; border: 1px solid var(--cv-gray-200);
    padding: 0 12px; font-size: 13px; min-width: 0;
}
.cv-schedule-form .cv-btn { grid-column: 1 / -1; height: 42px; }
@media (max-width: 420px) {
    .cv-schedule-form { grid-template-columns: 1fr; }
}

/* 本机 Codex 桥接状态 */
.cv-bridge {
    display: flex; align-items: center; gap: 8px; padding: 10px 12px;
    background: white; border-radius: 12px; font-size: 12px; color: var(--cv-gray-600);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.cv-bridge-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--cv-gray-400); flex-shrink: 0;
}
.cv-bridge.on .cv-bridge-dot { background: var(--cv-wx-green); box-shadow: 0 0 0 3px rgba(7,193,96,0.18); }
.cv-bridge.on { color: #0b6b3a; background: #f4fff9; }
.cv-bridge-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-bridge-help-btn {
    border: 1px solid var(--cv-gray-200); background: white; border-radius: 8px;
    font-size: 12px; padding: 4px 8px; cursor: pointer; color: var(--cv-primary); flex-shrink: 0;
}
.cv-bridge-help {
    background: white; border-radius: 12px; padding: 12px 14px; font-size: 12px;
    line-height: 1.7; color: var(--cv-gray-600); box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.cv-bridge-help p { margin: 4px 0; }
.cv-bridge-help ol { margin: 6px 0 6px 18px; padding: 0; }
.cv-bridge-help pre {
    background: var(--cv-gray-100); border-radius: 8px; padding: 10px; overflow-x: auto;
    font-size: 11.5px; margin: 6px 0; white-space: pre-wrap; word-break: break-all;
}
.cv-bridge-help code { background: var(--cv-gray-100); padding: 1px 4px; border-radius: 4px; }
.cv-bridge-note { color: var(--cv-gray-400); }

/* ==================== 通话页（微信语音通话） ==================== */

.cv-call-screen {
    position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
    background: radial-gradient(120% 80% at 50% 0%, var(--cv-call-bg-1) 0%, var(--cv-call-bg-2) 62%, #12171c 100%);
    color: #f2f6fa; padding: calc(10px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
    animation: cvCallIn 0.22s ease;
}
@keyframes cvCallIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.cv-call-top { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.cv-call-top-title { font-size: 14px; color: rgba(255,255,255,0.72); }
.cv-ghost-btn {
    width: 38px; height: 38px; border: none; border-radius: 50%;
    background: rgba(255,255,255,0.12); color: #f2f6fa; font-size: 16px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.cv-ghost-btn:hover { background: rgba(255,255,255,0.2); }

.cv-call-center {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; text-align: center; padding: 8px 0;
}
.cv-call-avatar-wrap { position: relative; margin-bottom: 12px; }
.cv-call-avatar {
    width: 96px; height: 96px; border-radius: 22%; font-size: 46px;
    background: linear-gradient(135deg, #07c160, #10b981);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35); position: relative; z-index: 1;
}
/* 说话时头像外圈呼吸（微信来电那种节奏） */
.cv-call-avatar-wrap.speaking::after,
.cv-call-avatar-wrap.thinking::after {
    content: ''; position: absolute; inset: -10px; border-radius: 26%;
    border: 2px solid rgba(7,193,96,0.55); animation: cvBreath 1.6s ease-out infinite;
}
.cv-call-avatar-wrap.thinking::after { border-color: rgba(120,170,255,0.55); }
@keyframes cvBreath {
    0% { transform: scale(0.94); opacity: 0.85; }
    100% { transform: scale(1.14); opacity: 0; }
}

.cv-call-name { font-size: 19px; font-weight: 600; letter-spacing: 0.5px; }
.cv-call-timer { font-size: 15px; color: rgba(255,255,255,0.72); font-variant-numeric: tabular-nums; }
.cv-call-state { font-size: 13px; color: rgba(255,255,255,0.62); min-height: 18px; }
.cv-call-caption {
    margin-top: 14px; max-width: 92%; font-size: 14px; line-height: 1.6;
    color: rgba(255,255,255,0.86); min-height: 22px;
}
.cv-call-caption.idle { color: rgba(255,255,255,0.4); }
.cv-call-task {
    margin-top: 10px; max-width: 92%; font-size: 12px; line-height: 1.55;
    color: rgba(255,255,255,0.5); min-height: 16px;
}

.cv-call-log {
    background: rgba(255,255,255,0.06); border-radius: 14px; padding: 12px;
    margin-bottom: 12px; max-height: 42vh; overflow: hidden; display: flex; flex-direction: column;
}
.cv-call-log-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 13px; font-weight: 600; margin-bottom: 8px; color: rgba(255,255,255,0.85);
}

.cv-call-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.cv-pill-btn {
    border: none; border-radius: 20px; padding: 8px 16px; font-size: 13px;
    background: rgba(255,255,255,0.14); color: #f2f6fa; cursor: pointer;
}
.cv-pill-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.cv-call-rounds { display: flex; align-items: flex-start; justify-content: center; gap: 34px; }
.cv-round-btn {
    width: 68px; border: none; background: none; color: #eef2f6; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 0;
}
.cv-round-icon {
    width: 68px; height: 68px; border-radius: 50%; font-size: 26px;
    background: rgba(255,255,255,0.16); display: flex; align-items: center; justify-content: center;
    transition: background 0.18s ease, transform 0.12s ease;
}
.cv-round-btn:active .cv-round-icon { transform: scale(0.94); }
.cv-round-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.cv-round-label { font-size: 12px; color: rgba(255,255,255,0.78); }
.cv-round-btn.on .cv-round-icon { background: rgba(255,255,255,0.86); }
.cv-round-danger .cv-round-icon { background: var(--cv-wx-red); transform: rotate(134deg); }
.cv-round-danger:active .cv-round-icon { transform: rotate(134deg) scale(0.94); }
.cv-round-answer .cv-round-icon { background: var(--cv-wx-green); }

/* ==================== 来电（微信来电风格） ==================== */

.cv-incoming {
    position: fixed; inset: 0; z-index: 50; color: #f2f6fa;
    background: radial-gradient(120% 80% at 50% 0%, var(--cv-call-bg-1) 0%, var(--cv-call-bg-2) 62%, #12171c 100%);
    display: flex; flex-direction: column;
    padding: calc(28px + env(safe-area-inset-top)) 22px calc(30px + env(safe-area-inset-bottom));
}
.cv-incoming-inner {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; text-align: center;
}
.cv-incoming-avatar {
    width: 96px; height: 96px; border-radius: 22%; margin-bottom: 14px; font-size: 46px;
    background: linear-gradient(135deg, #07c160, #10b981); color: white;
    display: flex; align-items: center; justify-content: center;
    animation: cvPulse 1.6s infinite;
}
@keyframes cvPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(7,193,96,0.45); }
    50% { transform: scale(1.04); box-shadow: 0 0 0 16px rgba(7,193,96,0); }
}
.cv-incoming-inner h2 { margin: 0; font-size: 21px; }
.cv-incoming-sub { margin: 0; font-size: 13px; color: rgba(255,255,255,0.6); }
.cv-incoming-text {
    margin: 14px 0 0; font-size: 15px; line-height: 1.6; color: rgba(255,255,255,0.9); max-width: 92%;
}
.cv-incoming-brief {
    margin: 8px 0 0; font-size: 12px; line-height: 1.55; color: rgba(255,255,255,0.5); max-width: 92%;
}
.cv-incoming-actions { display: flex; gap: 64px; margin-top: 34px; }

@media (max-width: 380px) {
    .cv-call-rounds { gap: 22px; }
    .cv-round-btn, .cv-round-icon { width: 62px; }
    .cv-round-icon { height: 62px; font-size: 23px; }
    .cv-incoming-actions { gap: 44px; }
}
