/* ==========================================================================
   小智数字人 · Apple 风格主题
   --------------------------------------------------------------------------
   设计语言：Apple Human Interface Guidelines（深色优先）
   - 材质：saturate(180%) blur() 半透明毛玻璃
   - 圆角：连续圆角 10 / 14 / 20 / 26px
   - 字体：SF Pro（-apple-system / BlinkMacSystemFont）→ 苹方 → 微软雅黑
   - 色彩：系统蓝 #0A84FF / 绿 #30D158 / 红 #FF453A / 橙 #FF9F0A
   - 交互：弹性缩放 + 系统曲线过渡，尊重「减弱动态效果」

   加载顺序：必须在 index.css 之后引入，本文件只做覆盖，不改动 DOM 与 JS。
   ========================================================================== */

:root {
    color-scheme: dark;

    /* —— 字体 —— */
    --sf-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
        "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
        "Segoe UI", sans-serif;
    --sf-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

    /* —— 系统色 —— */
    --ios-blue: #0a84ff;
    --ios-blue-deep: #0071e3;
    --ios-green: #30d158;
    --ios-red: #ff453a;
    --ios-orange: #ff9f0a;
    --ios-yellow: #ffd60a;
    --ios-teal: #64d2ff;
    --ios-gray: #8e8e93;

    /* —— 语义标签色（HIG Label Colors） —— */
    --label-1: rgba(255, 255, 255, 0.98);
    --label-2: rgba(235, 235, 245, 0.62);
    --label-3: rgba(235, 235, 245, 0.34);

    /* —— 材质与分隔线 —— */
    --material-thin: rgba(28, 28, 30, 0.58);
    --material: rgba(28, 28, 30, 0.74);
    --material-thick: rgba(28, 28, 30, 0.9);
    --fill-1: rgba(118, 118, 128, 0.16);
    --fill-2: rgba(118, 118, 128, 0.24);
    --fill-3: rgba(118, 118, 128, 0.34);
    --hairline: 0.5px solid rgba(255, 255, 255, 0.12);
    --separator: rgba(84, 84, 88, 0.62);

    /* —— 圆角 —— */
    --r-xs: 8px;
    --r-s: 10px;
    --r-m: 14px;
    --r-l: 18px;
    --r-xl: 22px;
    --r-2xl: 28px;
    --r-pill: 999px;

    /* —— 阴影 —— */
    --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.28);
    --shadow-2: 0 10px 30px rgba(0, 0, 0, 0.36);
    --shadow-3: 0 24px 70px rgba(0, 0, 0, 0.52);
    --inner-highlight: inset 0 0.5px 0 rgba(255, 255, 255, 0.16);

    /* —— 动画曲线 —— */
    --ease-ios: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-spring: cubic-bezier(0.34, 1.32, 0.64, 1);

    /* —— 安全区（刘海屏 / 手势条） —— */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    /* 控制栏高度，供聊天区 / 进度条避让 */
    --controlbar-h: 96px;
}

/* ==========================================================================
   1. 基础与排版
   ========================================================================== */

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

body {
    font-family: var(--sf-font);
    font-size: 15px;
    line-height: 1.45;
    letter-spacing: -0.01em;
    background-color: #000;
    height: 100vh;
    height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
    color: var(--label-1);
}

/* 触控目标统一关闭双击缩放带来的高亮 */
button,
a,
input,
select,
textarea {
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

button {
    touch-action: manipulation;
}

/* 可访问性：键盘焦点环使用系统蓝 */
:focus-visible {
    outline: 3px solid rgba(10, 132, 255, 0.65);
    outline-offset: 2px;
}

::selection {
    background: rgba(10, 132, 255, 0.45);
    color: #fff;
}

/* ==========================================================================
   2. 背景
   ========================================================================== */

.background-overlay {
    background:
        radial-gradient(120% 80% at 50% 0%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.58) 100%),
        linear-gradient(180deg, rgba(0, 0, 0, 0.24) 0%, rgba(0, 0, 0, 0.5) 100%);
    backdrop-filter: saturate(120%) blur(2px);
    -webkit-backdrop-filter: saturate(120%) blur(2px);
}

/* ==========================================================================
   3. 连接状态胶囊
   ========================================================================== */

.status-indicator {
    top: calc(14px + var(--safe-top));
    padding: 7px 14px 7px 12px;
    gap: 7px;
    border-radius: var(--r-pill);
    background: var(--material);
    border: var(--hairline);
    box-shadow: var(--shadow-1), var(--inner-highlight);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    font-size: 13px;
    font-weight: 590;
    letter-spacing: -0.01em;
    color: var(--label-1);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--ios-gray);
    box-shadow: 0 0 0 3px rgba(142, 142, 147, 0.16);
    animation: apple-status-breathe 2.4s var(--ease-ios) infinite;
}

.status-connected {
    background-color: var(--ios-green);
    box-shadow: 0 0 0 3px rgba(48, 209, 88, 0.18), 0 0 10px rgba(48, 209, 88, 0.7);
}

.status-connecting {
    background-color: var(--ios-orange);
    box-shadow: 0 0 0 3px rgba(255, 159, 10, 0.18), 0 0 10px rgba(255, 159, 10, 0.7);
}

.status-disconnected {
    background-color: var(--ios-red);
    box-shadow: 0 0 0 3px rgba(255, 69, 58, 0.18), 0 0 10px rgba(255, 69, 58, 0.6);
}

@keyframes apple-status-breathe {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* ==========================================================================
   4. 底部控制栏（核心组件）
   ========================================================================== */

.control-bar {
    left: 50%;
    bottom: calc(20px + var(--safe-bottom));
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 12px 18px;
    border-radius: var(--r-2xl);
    background: var(--material);
    border: var(--hairline);
    box-shadow: var(--shadow-2), var(--inner-highlight);
    backdrop-filter: saturate(180%) blur(26px);
    -webkit-backdrop-filter: saturate(180%) blur(26px);
    z-index: 1000;
    transition: box-shadow 0.3s var(--ease-ios), background 0.3s var(--ease-ios);
}

.control-btn {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--fill-2);
    border: 0.5px solid rgba(255, 255, 255, 0.14);
    color: var(--label-1);
    box-shadow: var(--inner-highlight);
    transition:
        transform 0.24s var(--ease-spring),
        background-color 0.2s var(--ease-ios),
        box-shadow 0.2s var(--ease-ios),
        opacity 0.2s var(--ease-ios);
    will-change: transform;
}

.control-btn:hover {
    background: var(--fill-3);
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.32), var(--inner-highlight);
}

.control-btn:active {
    transform: scale(0.93);
    transition-duration: 0.1s;
}

.control-btn:disabled {
    background: rgba(118, 118, 128, 0.12);
    color: var(--label-3);
    box-shadow: none;
    transform: none;
    opacity: 0.7;
}

.control-btn:disabled:hover {
    background: rgba(118, 118, 128, 0.12);
    transform: none;
    box-shadow: none;
}

.control-btn .btn-icon {
    width: 25px;
    height: 25px;
    margin-bottom: 3px;
}

.control-btn .btn-text {
    font-size: 11px;
    font-weight: 590;
    letter-spacing: -0.01em;
    color: var(--label-2);
}

.control-btn:not(:disabled) .btn-text {
    color: var(--label-2);
}

/* —— 拨号：主操作，系统蓝实心 —— */
.dial-btn {
    background: linear-gradient(180deg, #1f95ff 0%, var(--ios-blue-deep) 100%);
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow:
        0 8px 22px rgba(10, 132, 255, 0.42),
        inset 0 0.5px 0 rgba(255, 255, 255, 0.4);
}

.dial-btn:hover {
    background: linear-gradient(180deg, #2ea0ff 0%, #0a7ae8 100%);
    box-shadow:
        0 10px 28px rgba(10, 132, 255, 0.55),
        inset 0 0.5px 0 rgba(255, 255, 255, 0.45);
}

.dial-btn .btn-icon {
    color: #fff;
}

.dial-btn .btn-text {
    color: rgba(255, 255, 255, 0.92);
}

/* 通话中 / 挂断：系统红 */
.dial-btn.dial-active {
    background: linear-gradient(180deg, #ff5a4f 0%, #e0342b 100%);
    box-shadow:
        0 8px 22px rgba(255, 69, 58, 0.46),
        inset 0 0.5px 0 rgba(255, 255, 255, 0.35);
}

.dial-btn.dial-active:hover {
    background: linear-gradient(180deg, #ff6b61 0%, #ea3b32 100%);
}

/* —— 录音：系统红 + 呼吸环 —— */
.control-btn.recording {
    background: linear-gradient(180deg, #ff5a4f 0%, #e0342b 100%);
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow:
        0 8px 22px rgba(255, 69, 58, 0.42),
        inset 0 0.5px 0 rgba(255, 255, 255, 0.35);
    animation: apple-recording-ring 1.8s var(--ease-ios) infinite;
}

.control-btn.recording:hover {
    background: linear-gradient(180deg, #ff6b61 0%, #ea3b32 100%);
}

@keyframes apple-recording-ring {
    0% { box-shadow: 0 0 0 0 rgba(255, 69, 58, 0.55), 0 8px 22px rgba(255, 69, 58, 0.42); }
    70% { box-shadow: 0 0 0 14px rgba(255, 69, 58, 0), 0 8px 22px rgba(255, 69, 58, 0.2); }
    100% { box-shadow: 0 0 0 0 rgba(255, 69, 58, 0), 0 8px 22px rgba(255, 69, 58, 0.2); }
}

/* —— 摄像头：开启状态用系统蓝 —— */
#cameraBtn.camera-active {
    background: linear-gradient(180deg, #1f95ff 0%, var(--ios-blue-deep) 100%);
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0 8px 22px rgba(10, 132, 255, 0.4), inset 0 0.5px 0 rgba(255, 255, 255, 0.35);
}

#cameraBtn.camera-active:hover {
    background: linear-gradient(180deg, #2ea0ff 0%, #0a7ae8 100%);
}

#cameraBtn.camera-active .btn-text {
    color: rgba(255, 255, 255, 0.92);
}

/* ==========================================================================
   5. 聊天消息（iMessage 风格气泡）
   ========================================================================== */

/* 红包生成 HUD 出现时，聊天面板自动上移避让（面板样式与气泡由 index.css 控制） */
body.progress-active .chat-container {
    bottom: calc(var(--controlbar-h) + 134px + var(--safe-bottom));
}

/* .chat-stream 的尺寸与滚动由 index.css 统一控制（微信风格面板） */

/* .message-bubble 的配色/尺寸由 index.css 控制（白底 AI 泡 / 绿底用户泡） */

/* AI 气泡配色（白底）由 index.css 控制 */

/* 用户气泡配色（绿底）由 index.css 控制 */

/* 系统提示气泡由 index.css 控制 */

/* 图片气泡样式由 index.css 控制 */

.chat-image {
    border-radius: var(--r-xs);
}

.chat-image-caption {
    font-size: 11px;
    color: var(--label-2);
    text-shadow: none;
}

.chat-download-link {
    border-radius: var(--r-s);
    background: rgba(255, 69, 58, 0.86);
    border: 0.5px solid rgba(255, 255, 255, 0.16);
}

.chat-download-link:hover {
    background: rgba(255, 82, 71, 0.96);
}

/* 输入框：iOS 搜索框质感 */
.chat-ipt input {
    height: 42px;
    padding: 0 16px;
    border-radius: var(--r-pill);
    background: var(--fill-2);
    border: 0.5px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    color: var(--label-1);
    font-size: 15px;
    box-shadow: var(--inner-highlight);
    transition: background 0.2s var(--ease-ios), border-color 0.2s var(--ease-ios), box-shadow 0.2s var(--ease-ios);
}

.chat-ipt input::placeholder {
    color: var(--label-3);
}

.chat-ipt input:focus {
    outline: none;
    background: rgba(118, 118, 128, 0.32);
    border-color: rgba(10, 132, 255, 0.9);
    box-shadow: 0 0 0 3.5px rgba(10, 132, 255, 0.26);
}

/* ==========================================================================
   6. 弹窗 / 设置面板（iOS 表单风格）
   ========================================================================== */

.modal {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: saturate(140%) blur(14px);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    padding: 16px;
}

.modal-content {
    width: 100%;
    max-width: 520px;
    max-height: 84dvh;
    background: var(--material-thick);
    border: var(--hairline);
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-3), var(--inner-highlight);
    backdrop-filter: saturate(180%) blur(28px);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
    overflow: hidden;
    animation: apple-sheet-in 0.34s var(--ease-spring);
}

.settings-modal {
    max-width: 700px;
    max-height: 88dvh;
}

@keyframes apple-sheet-in {
    from {
        opacity: 0;
        transform: scale(0.94) translateY(14px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 18px 22px;
    background: transparent;
    border-bottom: var(--hairline);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 680;
    letter-spacing: -0.022em;
    color: var(--label-1);
}

.close-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--fill-2);
    color: var(--label-2);
    font-size: 17px;
    line-height: 1;
    border: none;
    transition: background 0.2s var(--ease-ios), color 0.2s var(--ease-ios), transform 0.15s var(--ease-ios);
}

.close-btn:hover {
    background: var(--fill-3);
    color: var(--label-1);
}

.close-btn:active {
    transform: scale(0.9);
}

.modal-body {
    padding: 20px 22px 24px;
    max-height: calc(84dvh - 68px);
}

.settings-modal .modal-body {
    max-height: calc(88dvh - 68px);
}

/* —— 分段控件（Segmented Control）—— */
.settings-tabs {
    display: flex;
    gap: 2px;
    padding: 3px;
    margin-bottom: 20px;
    border: none;
    border-radius: var(--r-s);
    background: var(--fill-2);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.settings-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    flex: 1 0 auto;
    padding: 8px 14px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--label-2);
    font-size: 13px;
    font-weight: 590;
    letter-spacing: -0.01em;
    white-space: nowrap;
    transition: background 0.2s var(--ease-ios), color 0.2s var(--ease-ios), box-shadow 0.2s var(--ease-ios);
}

.tab-btn:hover:not(.active) {
    background: rgba(118, 118, 128, 0.18);
    color: var(--label-1);
}

.tab-btn.active {
    color: #fff;
    background: rgba(99, 99, 102, 0.92);
    border-bottom-color: transparent;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.32), inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
}

/* —— 分组表单 —— */
.config-panel,
.mcp-tools-container {
    background: var(--fill-1);
    border: var(--hairline);
    border-radius: var(--r-m);
    padding: 14px;
}

.config-row {
    gap: 12px;
    margin-bottom: 12px;
}

.config-item label,
.input-group label {
    margin-bottom: 6px;
    color: var(--label-2);
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: -0.005em;
}

.config-item input,
.config-item textarea,
.input-group input,
.input-group textarea {
    width: 100%;
    padding: 11px 13px;
    border-radius: var(--r-s);
    background: var(--fill-2);
    border: 0.5px solid rgba(255, 255, 255, 0.08);
    color: var(--label-1);
    font-size: 15px;
    box-shadow: var(--inner-highlight);
    transition: border-color 0.2s var(--ease-ios), box-shadow 0.2s var(--ease-ios), background 0.2s var(--ease-ios);
}

.config-item textarea,
.input-group textarea {
    min-height: 96px;
    border-radius: var(--r-s);
    line-height: 1.5;
}

.config-item input::placeholder,
.config-item textarea::placeholder,
.input-group input::placeholder,
.input-group textarea::placeholder {
    color: var(--label-3);
}

.config-item input:focus,
.config-item textarea:focus,
.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: rgba(10, 132, 255, 0.95);
    box-shadow: 0 0 0 3.5px rgba(10, 132, 255, 0.26);
    background: rgba(118, 118, 128, 0.3);
}

.input-group {
    margin-bottom: 18px;
}

/* —— 下拉选择 —— */
.model-select {
    width: 100%;
    padding: 11px 40px 11px 13px;
    border-radius: var(--r-s);
    background-color: var(--fill-2);
    border: 0.5px solid rgba(255, 255, 255, 0.08);
    color: var(--label-1);
    font-size: 15px;
    font-weight: 500;
    box-shadow: var(--inner-highlight);
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='%238e8e93'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    background-size: 14px 14px;
    transition: border-color 0.2s var(--ease-ios), box-shadow 0.2s var(--ease-ios);
}

.model-select:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.model-select:focus {
    outline: none;
    border-color: rgba(10, 132, 255, 0.95);
    box-shadow: 0 0 0 3.5px rgba(10, 132, 255, 0.26);
}

.model-select option {
    background: #1c1c1e;
    color: var(--label-1);
    padding: 10px;
}

/* —— 按钮 —— */
.btn-primary {
    padding: 10px 20px;
    border-radius: var(--r-pill);
    background: linear-gradient(180deg, #2a9bff 0%, var(--ios-blue-deep) 100%);
    color: #fff;
    border: none;
    font-size: 14.5px;
    font-weight: 620;
    letter-spacing: -0.01em;
    box-shadow: 0 4px 14px rgba(10, 132, 255, 0.34), inset 0 0.5px 0 rgba(255, 255, 255, 0.34);
    transition: transform 0.18s var(--ease-spring), filter 0.2s var(--ease-ios), box-shadow 0.2s var(--ease-ios);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #3ba6ff 0%, #0a7ae8 100%);
    box-shadow: 0 6px 20px rgba(10, 132, 255, 0.44), inset 0 0.5px 0 rgba(255, 255, 255, 0.4);
}

.btn-primary:active {
    transform: scale(0.97);
    filter: brightness(0.94);
}

.btn-secondary {
    padding: 10px 20px;
    border-radius: var(--r-pill);
    background: var(--fill-2);
    color: var(--label-1);
    border: 0.5px solid rgba(255, 255, 255, 0.1);
    font-size: 14.5px;
    font-weight: 590;
    letter-spacing: -0.01em;
    transition: transform 0.18s var(--ease-spring), background 0.2s var(--ease-ios);
}

.btn-secondary:hover {
    background: var(--fill-3);
}

.btn-secondary:active {
    transform: scale(0.97);
}

.background-btn {
    padding: 10px 16px;
    border-radius: var(--r-s);
    background: var(--fill-2);
    border: 0.5px solid rgba(255, 255, 255, 0.08);
    color: var(--label-1);
    font-size: 14.5px;
    font-weight: 500;
    box-shadow: var(--inner-highlight);
    transition: background 0.2s var(--ease-ios), transform 0.18s var(--ease-spring);
}

.background-btn:hover {
    background: var(--fill-3);
}

.background-btn:active {
    transform: scale(0.98);
}

.background-btn .btn-icon {
    width: 18px;
    height: 18px;
    fill: var(--label-2);
}

.modal-actions {
    gap: 10px;
    margin-top: 20px;
}

/* ==========================================================================
   7. MCP 工具列表
   ========================================================================== */

.mcp-tools-header {
    padding: 0 2px 12px;
    background: transparent;
    border-bottom: var(--hairline);
    margin-bottom: 12px;
}

.mcp-tools-header h3 {
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.mcp-tool-card {
    background: var(--fill-1);
    border: var(--hairline);
    border-radius: var(--r-m);
    padding: 14px 16px;
    margin-bottom: 10px;
    transition: background 0.2s var(--ease-ios), border-color 0.2s var(--ease-ios);
}

.mcp-tool-card:hover {
    background: var(--fill-2);
    border-color: rgba(255, 255, 255, 0.16);
    transform: none;
}

.mcp-tool-name {
    font-size: 15px;
    font-weight: 620;
    letter-spacing: -0.012em;
    color: var(--label-1);
}

.mcp-tool-description {
    font-size: 13px;
    line-height: 1.45;
    color: var(--label-2);
    margin-top: 4px;
}

.mcp-tool-info-label,
.mcp-tool-info-value {
    font-size: 12px;
    color: var(--label-2);
}

.mcp-edit-btn,
.mcp-delete-btn,
.properties-btn-primary,
.mcp-property-delete-btn {
    border-radius: var(--r-pill);
    font-weight: 560;
    transition: background 0.2s var(--ease-ios), transform 0.16s var(--ease-spring), filter 0.2s;
}

.mcp-edit-btn {
    background: rgba(10, 132, 255, 0.2);
    color: #6fc0ff;
}

.mcp-edit-btn:hover {
    background: rgba(10, 132, 255, 0.32);
}

.mcp-delete-btn,
.mcp-property-delete-btn {
    background: rgba(255, 69, 58, 0.18);
    color: #ff8d86;
}

.mcp-delete-btn:hover,
.mcp-property-delete-btn:hover {
    background: rgba(255, 69, 58, 0.3);
}

.properties-btn-primary {
    background: rgba(10, 132, 255, 0.2);
    color: #6fc0ff;
}

.properties-btn-primary:hover {
    background: rgba(10, 132, 255, 0.32);
}

.mcp-edit-btn:active,
.mcp-delete-btn:active,
.properties-btn-primary:active,
.mcp-property-delete-btn:active {
    transform: scale(0.96);
}

.mcp-property-card {
    background: var(--fill-1);
    border: var(--hairline);
    border-radius: var(--r-s);
}

.mcp-empty-state {
    color: var(--label-3);
    font-size: 13px;
}

/* ==========================================================================
   8. 红包生成进度（iOS HUD）
   ========================================================================== */

.rp-progress {
    bottom: calc(var(--controlbar-h) + 18px + var(--safe-bottom));
    width: min(420px, calc(100vw - 36px));
    padding: 13px 16px 14px;
    border-radius: var(--r-l);
    background: var(--material-thick);
    border: 0.5px solid rgba(255, 255, 255, 0.14);
    box-shadow: var(--shadow-2), var(--inner-highlight);
    backdrop-filter: saturate(180%) blur(26px);
    -webkit-backdrop-filter: saturate(180%) blur(26px);
    color: var(--label-1);
}

.rp-progress-title {
    font-size: 13.5px;
    font-weight: 620;
    letter-spacing: -0.012em;
}

.rp-progress-timer {
    color: var(--ios-yellow);
    font-size: 12px;
    font-weight: 560;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

.rp-progress-icon {
    border-radius: 3.5px;
    background: linear-gradient(160deg, #ff6a52, #c8102e);
    box-shadow: 0 0 10px rgba(255, 80, 60, 0.45);
}

.rp-lamp {
    height: 8px;
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, 0.1);
}

.rp-lamp.lit {
    background: linear-gradient(90deg, var(--ios-orange), var(--ios-red));
    box-shadow: 0 0 10px rgba(255, 120, 60, 0.6);
}

.rp-progress.is-running .rp-lamp::after {
    border-radius: var(--r-pill);
    background: linear-gradient(90deg, rgba(255, 214, 130, 0), #ffe9b8, rgba(255, 214, 130, 0));
    box-shadow: 0 0 12px rgba(255, 214, 130, 0.7);
}

.rp-progress-track {
    height: 4px;
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, 0.1);
}

.rp-progress-fill {
    border-radius: var(--r-pill);
    background: linear-gradient(90deg, var(--ios-orange), var(--ios-yellow));
}

.rp-progress-foot {
    margin-top: 9px;
    font-size: 11px;
    color: var(--label-2);
    letter-spacing: 0;
}

#redPacketProgressHint {
    color: rgba(255, 214, 10, 0.78);
}

.rp-progress.is-done {
    border-color: rgba(48, 209, 88, 0.55);
}

.rp-progress.is-done .rp-lamp {
    background: linear-gradient(90deg, var(--ios-green), #2bbf4f);
}

.rp-progress.is-error {
    border-color: rgba(255, 69, 58, 0.6);
}

.rp-progress.is-error .rp-progress-timer,
.rp-progress.is-error .rp-progress-title {
    color: #ff9a93;
}

/* ==========================================================================
   9. 摄像头 / 照片浮层 / 大图查看
   ========================================================================== */

.camera-container,
.photo-preview-container {
    border-radius: var(--r-m);
    background: var(--material);
    border: var(--hairline);
    box-shadow: var(--shadow-2), var(--inner-highlight);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    top: calc(16px + var(--safe-top));
}

.camera-container {
    left: calc(16px + var(--safe-left));
    width: 176px;
    height: 234px;
}

.photo-preview-container {
    left: calc(208px + var(--safe-left));
    width: 176px;
}

.camera-container.dragging,
.photo-preview-container.dragging {
    border-color: rgba(10, 132, 255, 0.6);
    box-shadow: var(--shadow-3);
}

#cameraVideo {
    background: #0b0b0c;
}

.photo-preview-header {
    padding: 6px 8px 6px 10px;
    font-size: 11.5px;
    font-weight: 560;
    color: var(--label-2);
    background: rgba(255, 255, 255, 0.05);
    border-bottom: var(--hairline);
}

.photo-preview-print {
    border-radius: var(--r-pill);
    background: linear-gradient(180deg, #ff5a4f 0%, #d92b22 100%);
    padding: 3px 11px;
    font-size: 11px;
    font-weight: 590;
    box-shadow: 0 2px 8px rgba(255, 69, 58, 0.36);
}

.photo-preview-close {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--fill-2);
    color: var(--label-2);
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.photo-preview-close:hover {
    background: var(--fill-3);
    color: var(--label-1);
}

.photo-preview-desc {
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--label-2);
    padding: 6px 9px 8px;
}

.image-viewer-overlay {
    background: rgba(0, 0, 0, 0.86);
    backdrop-filter: saturate(140%) blur(12px);
    -webkit-backdrop-filter: saturate(140%) blur(12px);
}

.image-viewer-image {
    border-radius: var(--r-m);
    box-shadow: var(--shadow-3);
}

.image-viewer-download,
.image-viewer-close {
    padding: 9px 18px;
    border-radius: var(--r-pill);
    background: rgba(10, 132, 255, 0.9);
    border: 0.5px solid rgba(255, 255, 255, 0.18);
    font-size: 13.5px;
    font-weight: 590;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.36);
}

.image-viewer-download:hover,
.image-viewer-close:hover {
    background: var(--ios-blue);
}

/* ==========================================================================
   10. 模型加载态
   ========================================================================== */

.loading-char-float {
    font-size: 20px;
    letter-spacing: 2px;
    font-weight: 590;
}

.loading-char-float .main-char {
    color: #f5f5f7;
    text-shadow: 0 0 8px rgba(10, 132, 255, 0.55), 0 0 22px rgba(10, 132, 255, 0.3);
}

.loading-char-float .shadow-char {
    color: rgba(10, 132, 255, 0.28);
}

/* ==========================================================================
   11. 滚动条（覆盖式细滚动条）
   ========================================================================== */

.chat-stream::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.mcp-tools-list::-webkit-scrollbar,
.photo-preview-desc::-webkit-scrollbar {
    width: 6px;
}

.chat-stream::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.mcp-tools-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-stream::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.mcp-tools-list::-webkit-scrollbar-thumb,
.photo-preview-desc::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: var(--r-pill);
}

.chat-stream::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.mcp-tools-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   12. 文件协议警告（iOS 警告卡片）
   ========================================================================== */

.file-protocol-overlay {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: saturate(140%) blur(14px);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
}

#fileProtocolWarning {
    background: var(--material-thick);
    border: var(--hairline);
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-3), var(--inner-highlight);
    backdrop-filter: saturate(180%) blur(28px);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
    padding: 28px;
}

#fileProtocolWarning h2 {
    color: var(--label-1);
    font-size: 21px;
    font-weight: 680;
    letter-spacing: -0.022em;
    text-shadow: none;
}

#fileProtocolWarning p,
#fileProtocolWarning ol {
    color: var(--label-2);
    font-size: 14.5px;
    line-height: 1.55;
}

#fileProtocolWarning strong {
    color: var(--ios-blue);
}

#fileProtocolWarning pre {
    background: var(--fill-1);
    border: var(--hairline);
    border-radius: var(--r-s);
    font-family: var(--sf-mono);
    font-size: 13px;
    color: var(--label-1);
}

/* ==========================================================================
   13. 响应式
   ========================================================================== */

@media (max-width: 600px) {
    :root {
        --controlbar-h: 86px;
    }

    .control-bar {
        gap: 10px;
        padding: 10px 14px;
        border-radius: var(--r-xl);
        bottom: calc(14px + var(--safe-bottom));
    }

    .control-btn {
        width: 54px;
        height: 54px;
    }

    .control-btn .btn-icon {
        width: 22px;
        height: 22px;
        margin-bottom: 2px;
    }

    .control-btn .btn-text {
        font-size: 10px;
    }

    .chat-container {
        right: 12px;
        bottom: calc(var(--controlbar-h) + 18px + var(--safe-bottom));
    }

    .chat-stream {
        width: min(268px, 74vw);
        max-height: 30dvh;
    }

    .message-bubble {
        font-size: 14px;
        max-width: 220px;
    }

    .modal {
        padding: 10px;
    }

    .modal-content {
        max-height: 90dvh;
        border-radius: var(--r-xl);
    }

    .modal-body {
        padding: 16px 16px 20px;
    }

    .modal-header {
        padding: 15px 16px;
    }

    .config-row {
        flex-direction: column;
        gap: 10px;
    }

    .camera-container {
        width: 132px;
        height: 176px;
    }

    .photo-preview-container {
        left: calc(160px + var(--safe-left));
        width: 132px;
    }

    .rp-progress {
        bottom: calc(var(--controlbar-h) + 14px + var(--safe-bottom));
        width: calc(100vw - 24px);
        padding: 11px 13px 12px;
    }
}

@media (max-width: 380px) {
    .control-bar {
        gap: 8px;
        padding: 9px 12px;
    }

    .control-btn {
        width: 50px;
        height: 50px;
    }

    .btn-text {
        display: none;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .chat-container {
        max-height: 60dvh;
    }

    .chat-stream {
        max-height: 22dvh;
    }

    .modal-content {
        max-height: 92dvh;
    }

    .rp-progress {
        bottom: calc(var(--controlbar-h) + 10px + var(--safe-bottom));
    }
}

/* 桌面 / 平板：控件按比例放大，保持视觉平衡 */
@media (min-width: 900px) {
    .control-btn {
        width: 66px;
        height: 66px;
    }

    .control-btn .btn-icon {
        width: 27px;
        height: 27px;
    }

    .control-bar {
        gap: 16px;
        padding: 13px 20px;
    }
}

/* ==========================================================================
   14. 无障碍与降级
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* 不支持 backdrop-filter 的浏览器退回不透明材质，保证可读性 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .control-bar,
    .status-indicator,
    .modal-content,
    .rp-progress,
    .chat-ipt input,
    .camera-container,
    .photo-preview-container,
    #fileProtocolWarning {
        background: #1c1c1e;
    }

    .message-bubble {
        background: #2c2c2e;
    }

    .chat-message.user .message-bubble {
        background: var(--ios-blue-deep);
    }
}
