/* ===== Tokens — 浅色 ===== */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #eef0f4;
    --surface-3: #e4e7ed;
    --border: #e2e5ea;
    --text: #1a1c1e;
    --text-2: #5a6068;
    --text-3: #9aa0a8;
    --primary: #2563eb;
    --primary-hover: #1d56d4;
    --primary-soft: rgba(37,99,235,0.07);
    --green: #1a9e6e;
    --green-soft: rgba(26,158,110,0.1);
    --red: #dc3545;
    --radius: 8px;
    --radius-sm: 6px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== Tokens — 深色 ===== */
[data-theme="dark"] {
    --bg: #181a1e;
    --surface: #202225;
    --surface-2: #272a30;
    --surface-3: #31343b;
    --border: #383b42;
    --text: #e8eaed;
    --text-2: #9ba0a8;
    --text-3: #6b7178;
    --primary: #5b8def;
    --primary-hover: #6b9bff;
    --primary-soft: rgba(91,141,239,0.1);
    --green: #2ecc8f;
    --green-soft: rgba(46,204,143,0.1);
    --red: #ef5350;
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Microsoft Yahei", "PingFang SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
}
button, input { font-family: inherit; color: inherit; border: none; background: none; }
button { cursor: pointer; }
svg { display: block; flex-shrink: 0; }
input { -webkit-appearance: none; appearance: none; }
.hidden { display: none !important; }
/* HTML hidden 属性与 class 统一处理，避免旧缓存样式导致折叠面板无法收起 */
[hidden] { display: none !important; }

/* ===== Layout ===== */
#app {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-bottom: var(--safe-bottom);
}

/* ===== Header ===== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 52px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    gap: 0.5rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 0.4rem; min-width: 0; flex-shrink: 0; }

.logo {
    width: 26px; height: 26px;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.logo svg { width: 15px; height: 15px; }

.title { font-size: 1rem; font-weight: 600; white-space: nowrap; }

.page-slogan {
    text-align: center;
    font-size: .88rem;
    color: var(--text-2);
    font-weight: 400;
    padding: 0.6rem 1rem 0.2rem;
    margin: 0;
}

/* Tab 切换 */
.header-tabs {
    position: absolute;
    /* 桌面端：主内容区 (main) 在左侧 (100vw - 200px QR) 内居中，中心点 = 50vw - 120px */
    left: calc(50% - 120px);
    transform: translateX(-50%);
    display: flex;
    flex-shrink: 0;
    gap: 0.25rem;
}
@media (max-width: 768px) {
    .header-tabs {
        /* 移动端 QR 隐藏，main 全宽居中 */
        left: 50%;
    }
}
.tab {
    padding: 0.35rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-2);
    border-radius: 4px;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.tab.active { background: var(--surface-2); color: var(--primary); font-weight: 600; box-shadow: inset 0 0 0 1px var(--primary); }
[data-theme="dark"] .tab.active { background: var(--surface-3); }

.header-right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.status { display: flex; align-items: center; gap: 0.3rem; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.status.connected .status-dot { background: var(--green); }
.status.connecting .status-dot { background: var(--primary); animation: blink 1.2s infinite; }
.status.error .status-dot { background: var(--red); }
.status.lan_only .status-dot { background: var(--yellow, #f59e0b); }
.status-text { font-size: 0.8rem; color: var(--text-2); }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

.header-btn {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-2);
    transition: color .15s, background .15s;
}
.header-btn:hover { color: var(--text); background: var(--surface-2); }
.header-btn svg { width: 17px; height: 17px; }

/* ===== Main ===== */
.main {
    flex: 1;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: calc(52px + 1.25rem) 1rem 2rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.mode-panel { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

/* ===== Section ===== */
.section { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    height: 24px;
}

.section-title { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }

.count-badge {
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 99px;
    min-width: 20px;
    text-align: center;
}

.text-btn {
    font-size: 0.82rem;
    color: var(--text-2);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    transition: color .15s;
    flex-shrink: 0;
}
.text-btn:hover { color: var(--primary); }

.section-actions { display: flex; align-items: center; gap: 0.35rem; }
.refresh-btn {
    width: 26px; height: 26px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3);
    transition: color .15s, background .15s;
}
.refresh-btn:hover { color: var(--primary); background: var(--surface-2); }
.refresh-btn:active { transform: scale(0.9); }
.refresh-btn svg { width: 14px; height: 14px; }
.refresh-btn.spinning svg { animation: spin 0.6s ease; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ===== Device View Tabs (局域网 / 房间) ===== */
.device-view-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.2rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    margin: 0.5rem 0 0.4rem;
}
.device-view-tab {
    flex: 1;
    padding: 0.38rem;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.device-view-tab:hover:not(.disabled) { color: var(--text); }
.device-view-tab.active {
    background: var(--surface);
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.device-view-tab.disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== Room active tip ===== */
.room-active-tip {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.4rem 0.2rem 0.1rem;
    line-height: 1.4;
}

/* ===== Device Grid ===== */
.device-scroll {
    overflow-y: auto;
    max-height: 300px;
    margin: 0 -0.2rem;
    padding: 0.15rem 0.2rem;
    -webkit-overflow-scrolling: touch;
}
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
    min-height: 48px;
}

/* 无头像设备卡片 */
.device-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.device-card:hover { border-color: var(--primary); background: var(--surface-2); }
.device-card.selected { border-color: var(--primary); background: var(--primary-soft); }

.device-name {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    max-width: 100%;
}

.device-meta {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    color: var(--text-3);
}
.device-meta-ip {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}
.device-meta-dot {
    width: 3px; height: 3px;
    border-radius: 50%;
    background: var(--text-3);
    flex-shrink: 0;
}
.device-meta-status {
    color: var(--green);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 1.25rem 1rem;
    color: var(--text-3);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-state svg { width: 24px; height: 24px; margin: 0 auto 0.4rem; opacity: 0.3; }
.empty-state p { font-size: 0.78rem; color: var(--text-2); }
.empty-state.small { padding: 0.85rem; }
.empty-state.small p { font-size: 0.72rem; }

/* WiFi 搜索雷达动画 */
.wifi-scan {
    position: relative;
    width: 40px;
    height: 40px;
    margin: 0 auto 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.wifi-scan svg {
    width: 24px; height: 24px;
    margin: 0;
    color: var(--primary);
    opacity: 0.5;
    z-index: 1;
    animation: wifiBreathe 2s ease-in-out infinite;
}
.wifi-scan-ring {
    position: absolute;
    top: 50%; left: 50%;
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 1.5px solid var(--primary);
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
    animation: wifiPulse 2.4s ease-out infinite;
}
.wifi-scan-ring:nth-child(2) { animation-delay: 0.8s; }
@keyframes wifiPulse {
    0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0.5; }
    100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
}
@keyframes wifiBreathe {
    0%, 100% { opacity: 0.35; }
    50%      { opacity: 0.75; }
}
.empty-hint { font-size: 0.7rem; color: var(--text-3); margin-top: 0.2rem; }

/* ===== Dropzone ===== */
.dropzone {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    color: var(--text-2);
    background: var(--surface);
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.dropzone svg { width: 22px; height: 22px; color: var(--text-3); }
.dropzone:hover svg { color: var(--primary); }
.dropzone-main { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.dropzone-sub { font-size: 0.68rem; color: var(--text-3); }

/* ===== File Queue ===== */
.file-queue { display: flex; flex-direction: column; gap: 0.25rem; }

.file-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.55rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 0;
}

.file-icon {
    width: 22px; height: 22px;
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--text-2);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.file-icon svg { width: 11px; height: 11px; }

.file-info { flex: 1; min-width: 0; }
.file-info-name {
    font-size: 0.76rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-info-size { font-size: 0.64rem; color: var(--text-3); font-variant-numeric: tabular-nums; }

.file-remove {
    width: 20px; height: 20px;
    border-radius: 4px;
    color: var(--text-3);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: color .15s, background .15s;
}
.file-remove:hover { color: var(--red); background: rgba(220,53,69,0.08); }
.file-remove svg { width: 10px; height: 10px; }

/* ===== Send Bar ===== */
.send-bar {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.55rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.target-display { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.target-label { font-size: 0.62rem; color: var(--text-3); }
.target-name {
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.send-btn {
    display: flex; align-items: center; gap: 0.25rem;
    padding: 0.4rem 0.85rem;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    transition: background .15s, transform .08s;
    flex-shrink: 0;
}
.send-btn:hover { background: var(--primary-hover); }
.send-btn:active { transform: scale(0.97); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.send-btn svg { width: 12px; height: 12px; }

/* ===== 接收模式 Hero ===== */
.recv-hero {
    text-align: center;
    padding: 2rem 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}
.recv-hero-icon-wrap {
    position: relative;
    width: 56px;
    height: 56px;
}
.recv-hero-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid var(--primary-soft);
    animation: ringPulse 2.5s ease-out infinite;
    z-index: 0;
}
@keyframes ringPulse {
    0% { transform: scale(0.8); opacity: 0; border-color: var(--primary); }
    50% { opacity: 0.5; }
    100% { transform: scale(1.8); opacity: 0; border-color: var(--primary); }
}
.recv-hero-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: transparent;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.recv-hero-icon svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}
.recv-hero-text { font-size: 0.92rem; font-weight: 600; color: var(--text); margin: 0; }
.recv-hero-sub { font-size: 0.74rem; color: var(--text-3); margin: 0; }

/* 微信浏览器顶部提醒横幅 */
.wechat-banner {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.7rem;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: var(--radius-sm);
    margin-bottom: 0.6rem;
    font-size: 0.75rem;
    color: #856404;
    animation: fadeInUp 0.35s ease;
}
.wechat-banner-icon { flex-shrink: 0; font-size: 0.85rem; }
.wechat-banner-text { flex: 1; min-width: 0; }
.wechat-banner-btn {
    flex-shrink: 0;
    padding: 0.25rem 0.55rem;
    background: #856404;
    color: #fff;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    white-space: nowrap;
    transition: opacity .15s;
}
.wechat-banner-btn:hover { opacity: 0.85; }
.wechat-banner-btn:active { opacity: 0.7; }

/* ===== Receive List ===== */
.receive-list { display: flex; flex-direction: column; gap: 0.25rem; }

.recv-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.55rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 0;
}

.recv-item-icon {
    width: 26px; height: 26px;
    border-radius: 5px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.recv-item-icon svg { width: 13px; height: 13px; }

.recv-item-info { flex: 1; min-width: 0; }
.recv-item-name {
    font-size: 0.76rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.recv-item-meta {
    font-size: 0.62rem;
    color: var(--text-3);
    display: flex;
    gap: 0.25rem;
    align-items: center;
}
.recv-item-meta span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recv-item-status {
    font-size: 0.62rem;
    padding: 0.08rem 0.35rem;
    border-radius: 3px;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
}
.recv-item-status.waiting { background: var(--surface-2); color: var(--text-3); }
.recv-item-status.downloading { background: var(--primary-soft); color: var(--primary); }
.recv-item-status.saved { background: var(--green-soft); color: var(--green); }

.recv-item-action {
    padding: 0.25rem 0.55rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--primary);
    color: #fff;
    flex-shrink: 0;
    transition: background .15s;
}
.recv-item-action:hover { background: var(--primary-hover); }

/* ===== Overlay & Modal ===== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.modal {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: 18px 18px 0 0;
    padding: 1.1rem 1rem 1rem;
    padding-bottom: calc(1.1rem + var(--safe-bottom));
    box-shadow: 0 -8px 40px rgba(0,0,0,0.25);
    animation: slideUp .28s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(100%); opacity: .6; } to { transform: translateY(0); opacity: 1; } }

/* 桌面端居中卡片式弹窗 */
@media (min-width: 640px) {
    .overlay { align-items: center; }
    .modal {
        border-radius: 18px;
        max-width: 360px;
        padding: 1.25rem;
        animation: modalPop .26s cubic-bezier(0.16, 1, 0.3, 1);
    }
    @keyframes modalPop { from { transform: scale(.94) translateY(8px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
}

/* 进度弹窗始终居中（不跟随移动端底部弹出） */
#progressOverlay { align-items: center; }
#progressOverlay .modal {
    border-radius: 18px;
    animation: modalPop .26s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 接收请求 / 文件过大弹窗始终居中 */
#receiveOverlay, #sizeLimitOverlay { align-items: center; }
#receiveOverlay .modal, #sizeLimitOverlay .modal {
    border-radius: 18px;
    animation: modalPop .26s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 设置 / 关于弹窗始终居中 */
#settingsOverlay, #aboutOverlay { align-items: center; }
#settingsOverlay .modal, #aboutOverlay .modal {
    border-radius: 18px;
    animation: modalPop .26s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}
.modal-head h3 { font-size: 0.88rem; font-weight: 700; }

.close-btn {
    width: 26px; height: 26px;
    border-radius: 50%;
    color: var(--text-2);
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    transition: color .15s, background .15s, transform .15s;
}
.close-btn:hover { color: var(--text); background: var(--border); transform: rotate(90deg); }
.close-btn svg { width: 13px; height: 13px; }

/* Settings */
.setting-row { margin-bottom: 0.65rem; }
.setting-row:last-child { margin-bottom: 0; }
.setting-row-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.setting-value {
    font-size: 0.78rem;
    color: var(--text-2);
}
.setting-row-link {
    text-align: center;
    margin-top: 0.35rem;
}
.setting-link {
    font-size: 0.78rem;
    color: var(--text-2);
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    transition: color .15s, background .15s;
}
.setting-link:hover { color: var(--primary); background: var(--surface-2); }
.modal-foot {
    margin-top: 0.85rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

.about-modal {
    position: relative;
    padding: 1.5rem 1.6rem 1.4rem;
    min-width: 320px;
    max-width: 360px;
    --about-accent: #6366f1;
    --about-accent-soft: rgba(99, 102, 241, 0.1);
}
.about-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: color .15s, background .15s;
}
.about-close:hover { color: var(--text); background: var(--surface-2); transform: rotate(90deg); }
.about-close svg { width: 16px; height: 16px; }

/* About */
.about-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.9rem;
}
.about-desc {
    font-size: 0.82rem;
    color: var(--text-2);
    line-height: 1.6;
    max-width: 280px;
    margin: 0;
}
.about-version {
    margin-top: 0.2rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--about-accent, #6366f1);
    background: var(--about-accent-soft, rgba(99,102,241,0.1));
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    letter-spacing: 0.02em;
    text-decoration: none;
    transition: background .15s, transform .15s;
}
.about-version:hover { background: rgba(99,102,241,0.18); transform: translateY(-1px); }
.setting-label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-2);
    margin-bottom: 0.25rem;
    font-weight: 600;
}
.setting-input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.55rem;
    font-size: 0.8rem;
    transition: border-color .15s;
}
.setting-input:focus { outline: none; border-color: var(--primary); }

.theme-switch { display: flex; gap: 0.25rem; }
.theme-opt {
    flex: 1;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 0.76rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.theme-opt:hover:not(.active) { color: var(--text); background: var(--surface-3); }
.theme-opt.active { background: var(--primary); color: #fff; }
.theme-opt.active:hover { background: var(--primary-hover); }

/* Receive Modal */
.receive-icon, .progress-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 0.5rem;
}
.receive-icon svg, .progress-icon svg { width: 18px; height: 18px; }

.receive-info { text-align: center; margin-bottom: 0.65rem; }
.receive-from { font-size: 0.82rem; color: var(--text-2); margin-bottom: 0.35rem; }
.receive-from strong { color: var(--text); }
.receive-file {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.55rem;
    text-align: left;
}
.receive-file-name {
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.receive-file-size { font-size: 0.66rem; color: var(--text-3); }

.receive-actions { display: flex; gap: 0.35rem; }

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    transition: background .15s, transform .08s;
    text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary { background: var(--surface-2); color: var(--text-2); }
.btn-secondary:hover { color: var(--text); }

/* Progress Modal */
.progress-info { text-align: center; margin-bottom: 0.65rem; }
.progress-name {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.progress-status { font-size: 0.7rem; color: var(--text-2); text-align: center; }
.progress-status.done { color: var(--green); font-weight: 600; }
.progress-actions { display: flex; gap: 0.35rem; margin-top: 0.2rem; }
#progressDone { flex: 1; }

.progress-bar-wrap { margin-bottom: 0.65rem; }
.progress-bar {
    height: 4px;
    background: var(--surface-2);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.25rem;
}
.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    border-radius: 2px;
    transition: width .2s;
}
.progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.66rem;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: calc(5rem + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    width: calc(100% - 1.5rem);
    max-width: 340px;
    pointer-events: none;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    animation: toastIn .25s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.toast.out { animation: toastOut .15s forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(-5px); } }
.toast-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.toast.success .toast-dot { background: var(--green); }
.toast.error .toast-dot { background: var(--red); }
.toast.info .toast-dot { background: var(--primary); }

/* ===== Center Toast（居中浮窗提醒：发送/接收关键节点反馈）===== */
.center-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s, transform .25s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
    max-width: calc(100vw - 2rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.center-toast-show {
    opacity: 1;
}
.center-toast.center-toast-error {
    border-color: rgba(239,68,68,0.3);
}
.center-toast.center-toast-success {
    border-color: rgba(34,197,94,0.3);
}

/* ===== Self Bar（底部设备名）===== */
.self-bar {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.6rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    margin-top: 10px;
}
.self-bar svg { width: 14px; height: 14px; color: var(--text-3); flex-shrink: 0; }
.self-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-3);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}
.self-divider {
    width: 1px;
    height: 14px;
    background: var(--border);
    flex-shrink: 0;
}
.self-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}
.copy-url-btn {
    width: 30px; height: 30px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3);
    flex-shrink: 0;
    transition: color .15s, background .15s, transform .08s;
}
.copy-url-btn:hover { color: var(--primary); background: var(--surface-2); }
.copy-url-btn:active { transform: scale(0.92); }
.copy-url-btn svg { width: 14px; height: 14px; }
.copy-url-btn.copied { color: var(--green); }

/* ===== Preview Modal（媒体预览）===== */
#previewOverlay {
    align-items: center;
    padding: 1rem;
}
.preview-modal {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border-radius: 12px;
    padding: 1rem;
    animation: scaleIn .25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}
.preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}
.preview-name {
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.preview-content {
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.preview-content img {
    width: 100%;
    max-height: 55vh;
    object-fit: contain;
    display: block;
    -webkit-user-select: none;
    user-select: none;
}
.preview-content video {
    width: 100%;
    max-height: 50vh;
    display: block;
}
.preview-actions {
    display: flex;
    justify-content: center;
    margin-top: 0.75rem;
}
.preview-save-btn {
    padding: 0.5rem 1.5rem;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    transition: background .15s;
}
.preview-save-btn:hover { background: var(--primary-hover); }
.preview-save-btn:active { transform: scale(0.96); }
.preview-hint {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-3);
    margin-top: 0.5rem;
}
.preview-unsupported {
    flex-direction: column;
    gap: 0.4rem;
    padding: 2rem 1rem;
    color: #fff;
    text-align: center;
}
.preview-unsupported p { font-size: 0.88rem; font-weight: 600; }
.preview-unsupported span { font-size: 0.74rem; opacity: 0.6; }

.setting-danger-btn {
    width: 100%;
    padding: 0.55rem;
    border-radius: var(--radius-sm);
    background: rgba(220,53,69,0.08);
    color: var(--red);
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(220,53,69,0.35);
    transition: background .15s, border-color .15s;
}
.setting-danger-btn:hover { background: rgba(220,53,69,0.15); border-color: rgba(220,53,69,0.55); }

.setting-link-btn {
    width: 100%;
    padding: 0.55rem;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--accent, #3b82f6);
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: center;
    transition: background .15s, border-color .15s;
}
.setting-link-btn:hover { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.35); }

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--surface-3);
    border-radius: 11px;
    transition: background .2s;
    cursor: pointer;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* 公网互传面板 */
.room-body { display: flex; flex-direction: column; gap: 0.75rem; }

/* 跨网络互传折叠面板 */
.room-collapse {
    margin: 0.25rem 0;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
}
.room-collapse-head {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-2);
    transition: background .15s, color .15s;
}
.room-collapse-head:hover { color: var(--primary); }
.room-collapse-head.expanded .room-collapse-arrow { transform: rotate(180deg); }
.room-collapse-arrow {
    width: 14px; height: 14px;
    transition: transform .2s;
    flex-shrink: 0;
    color: var(--text-3);
}
.room-collapse-hint {
    margin-left: auto;
    font-size: 0.68rem;
    font-weight: 400;
    color: var(--text-3);
}
.room-collapse-body {
    padding: 0.5rem 0.7rem 0.65rem;
    border-top: 1px solid var(--border);
}
.room-idle, .room-active {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.net-cap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    line-height: 1.5;
    padding: 0.45rem 0.55rem;
    border-radius: var(--radius-sm, 6px);
    background: rgba(59,130,246,0.08);
    color: var(--text-2);
    margin-bottom: 0.1rem;
}
.net-cap-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: var(--text-3);
}
.net-cap[data-level="ok"] { background: rgba(34,197,94,0.12); }
.net-cap[data-level="ok"] .net-cap-dot { background: #22c55e; }
.net-cap[data-level="warn"] { background: rgba(234,179,8,0.14); }
.net-cap[data-level="warn"] .net-cap-dot { background: #eab308; }

/* 头部常驻网络能力 pill（折叠时也能看到能否直连）*/
.net-cap-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
    padding: 0.12rem 0.4rem;
    border-radius: 999px;
    font-size: 0.64rem;
    font-weight: 500;
    line-height: 1;
    background: rgba(59,130,246,0.1);
    color: var(--text-2);
    white-space: nowrap;
    transition: background .2s, color .2s;
}
.net-cap-pill .net-cap-dot { width: 6px; height: 6px; }
.net-cap-pill[data-level="ok"] { background: rgba(34,197,94,0.14); color: #16a34a; }
.net-cap-pill[data-level="ok"] .net-cap-dot { background: #22c55e; }
.net-cap-pill[data-level="warn"] { background: rgba(234,179,8,0.16); color: #ca8a04; }
.net-cap-pill[data-level="warn"] .net-cap-dot { background: #eab308; }
.net-cap-pill[data-level="error"] { background: rgba(239,68,68,0.14); color: #dc2626; }
.net-cap-pill[data-level="error"] .net-cap-dot { background: #ef4444; }
/* 头部已有 pill 时，弱化原 hint 文字位置 */
.room-collapse-head .room-collapse-hint { margin-left: 0.4rem; }

.room-hint {
    font-size: 0.72rem;
    color: var(--text-3);
    text-align: center;
    line-height: 1.6;
    padding: 0.1rem 0;
}
.room-divider {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.68rem;
    color: var(--text-3);
    margin: 0.1rem 0;
}
.room-divider::before, .room-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.room-action-row { display: flex; gap: 0.4rem; }
.room-action-row .room-code-input { flex: 1; }
.room-action-row .room-btn-join { flex: none; padding: 0.5rem 0.9rem; }
.room-code-input {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-align: center;
    color: var(--text);
    transition: border-color .15s;
}
.room-code-input:focus { outline: none; border-color: var(--primary); }
.room-code-input::placeholder { font-size: 0.78rem; letter-spacing: 0; font-weight: 400; color: var(--text-3); }
.room-btns { display: flex; gap: 0.4rem; }
.room-btn {
    flex: 1;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    transition: background .15s, transform .08s;
    text-align: center;
}
.room-btn:active { transform: scale(0.97); }
.room-btn-create { background: var(--primary); color: #fff; }
.room-btn-create:hover { background: var(--primary-hover); }
.room-btn-join { background: var(--surface-2); color: var(--text-2); }
.room-btn-join:hover { color: var(--text); }
.room-code-display {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.65rem;
}
.room-code-label { font-size: 0.72rem; color: var(--text-3); flex-shrink: 0; }
.room-code-value {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--primary);
    text-align: center;
}
.room-code-copy {
    width: 28px; height: 28px;
    border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3);
    transition: color .15s, background .15s;
    flex-shrink: 0;
}
.room-code-copy:hover { color: var(--primary); background: var(--surface-3); }
.room-code-copy svg { width: 13px; height: 13px; }
.room-code-copy.copied { color: var(--green); }
.room-device-list { display: flex; flex-direction: column; gap: 0.25rem; max-height: 200px; overflow-y: auto; }
.room-device-list-title { font-size: 0.7rem; color: var(--text-muted); margin: 0.2rem 0.1rem 0.1rem; }
.room-device-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.5rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    cursor: default;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s;
}
.room-device-item:not(.is-self) { cursor: pointer; }
.room-device-item:not(.is-self):hover { background: var(--primary-soft); }
.room-device-item.selected {
    background: var(--primary-soft);
    border-color: var(--primary);
}
.room-device-item-icon {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.room-device-item-icon svg { width: 12px; height: 12px; }
.room-device-item-name { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-device-item-badge {
    font-size: 0.62rem;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-weight: 600;
    background: var(--green-soft);
    color: var(--green);
    flex-shrink: 0;
}
.room-device-item-pick {
    font-size: 0.62rem;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-weight: 600;
    color: var(--primary);
    background: transparent;
    flex-shrink: 0;
}
.room-leave-btn {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(220,53,69,0.08);
    color: var(--red);
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
    transition: background .15s;
}
.room-leave-btn:hover { background: rgba(220,53,69,0.15); }


::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== Responsive ===== */
@media (max-width: 520px) {
    .header { padding: 0 0.7rem; height: 48px; gap: 0.3rem; }
    .title { font-size: 0.92rem; }
    .page-slogan { font-size: .82rem; padding: 0.5rem 0.8rem 0.1rem; }
    .recv-hero { gap: 22px; }
    .logo { width: 22px; height: 22px; }
    .logo svg { width: 13px; height: 13px; }
    .tab { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
    .header-btn { width: 28px; height: 28px; }
    .header-btn svg { width: 15px; height: 15px; }

    .main { padding: calc(48px + 1rem) 0.7rem 1.5rem; }

    .device-card { padding: 0.5rem 0.65rem; }
    .device-name { font-size: 0.82rem; }
    .device-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.4rem; }
    .device-scroll { max-height: 260px; }

    .dropzone { padding: 1.1rem 0.8rem; }
    .dropzone svg { width: 22px; height: 22px; }
    .dropzone-main { font-size: 0.82rem; }
    .dropzone-sub { font-size: 0.7rem; }

    .file-item { padding: 0.5rem 0.6rem; gap: 0.45rem; }
    .file-icon { width: 22px; height: 22px; }

    .send-bar { padding: 0.45rem 0.6rem; gap: 0.45rem; }
    .send-btn { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

    .recv-item { padding: 0.5rem 0.6rem; gap: 0.45rem; }
    .recv-item-icon { width: 26px; height: 26px; }

    .recv-hero { padding: 1.5rem 1rem 1rem; }
    .recv-hero-icon-wrap,
    .recv-hero-ring,
    .recv-hero-icon { width: 52px; height: 52px; }

    .modal { padding: 0.85rem 0.7rem; }
    .toast-container { width: calc(100% - 1rem); }
    .preview-hint { font-size: 0.75rem; }
}

@media (max-width: 360px) {
    .header { padding: 0 0.5rem; height: 44px; }
    .title { display: none; }
    .page-slogan { font-size: .78rem; padding: 0.4rem 0.6rem 0; }
    .recv-hero { gap: 20px; }
    .tab { padding: 0.25rem 0.55rem; font-size: 0.76rem; }
    .main { padding: calc(44px + 0.85rem) 0.55rem 1.25rem; }
    .device-grid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); }
}

/* ===== PC 端二维码侧边栏 ===== */
.qr-sidebar { display: none; }

.qr-card {
    width: 180px;
    padding: 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
[data-theme="dark"] .qr-card {
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.qr-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.15rem;
}
.qr-desc {
    font-size: 0.65rem;
    color: var(--text-3);
    margin: 0 0 0.5rem;
    line-height: 1.35;
}
.qr-img {
    display: block;
    margin: 0 auto 0.4rem;
    width: 150px;
    height: 150px;
    border-radius: 6px;
    padding: 4px;
    box-sizing: border-box;
    border: 1px solid var(--border);
}
.qr-hint {
    font-size: 0.6rem;
    color: var(--text-3);
    margin: 0;
}

@media (min-width: 1024px) {
    #app {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        gap: 1.5rem;
        padding-top: 1rem;
    }
    .header {
        width: 100%;
        flex-basis: 100%;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 100;
    }
    .main {
        flex: 0 1 640px;
        padding-top: calc(52px + 1rem);
        margin: 0;
    }
    .qr-sidebar {
        display: block;
        flex: 0 0 auto;
        padding-top: calc(52px + 6rem);
    }
}