/* ==========================================================================
   YiLink — 设计系统（深色玻璃拟态）
   单一强调色族：signal blue → cyan 渐变（仅用于品牌/连接态/进度）
   语义色：success / warning / danger
   ========================================================================== */

:root {
    --bg-0: #0a0d13;
    --bg-1: #10141d;
    --bg-solid: #151a25;

    --surface: rgba(255, 255, 255, 0.045);
    --surface-2: rgba(255, 255, 255, 0.075);
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);

    --text-1: rgba(240, 244, 255, 0.95);
    --text-2: rgba(240, 244, 255, 0.62);
    --text-3: rgba(240, 244, 255, 0.38);

    --accent: #4f8dff;
    --accent-2: #38d9c0;
    --accent-grad: linear-gradient(135deg, #4f8dff 0%, #38d9c0 100%);
    --accent-soft: rgba(79, 141, 255, 0.14);
    --accent-glow: rgba(79, 141, 255, 0.30);

    --success: #3ecf8e;
    --success-soft: rgba(62, 207, 142, 0.13);
    --warning: #f5b453;
    --danger: #f26d6d;
    --danger-soft: rgba(242, 109, 109, 0.12);

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 10px;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, "Helvetica Neue", sans-serif;
    --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas,
        "Liberation Mono", monospace;

    --shadow-card: 0 12px 40px rgba(3, 6, 12, 0.42);
    --inner-hi: inset 0 1px 0 rgba(255, 255, 255, 0.07);
    --blur: blur(18px) saturate(150%);

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- 基础 ---------- */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-0);
    color: var(--text-1);
    line-height: 1.55;
    min-height: 100dvh;
    padding-bottom: 64px; /* 给日志抽屉留位 */
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* 背景光效：固定层，只做氛围，不参与交互 */
.bg-aurora {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(52rem 34rem at 12% -8%, rgba(79, 141, 255, 0.13), transparent 62%),
        radial-gradient(46rem 32rem at 92% 108%, rgba(56, 217, 192, 0.09), transparent 60%),
        radial-gradient(38rem 26rem at 55% 45%, rgba(79, 141, 255, 0.045), transparent 65%),
        var(--bg-0);
}

.hidden {
    display: none !important;
}

code {
    font-family: var(--font-mono);
}

button {
    font-family: inherit;
}

::selection {
    background: rgba(79, 141, 255, 0.35);
}

/* 细滚动条 */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

/* ---------- 入场动画 ---------- */

@media (prefers-reduced-motion: no-preference) {
    .reveal {
        opacity: 0;
        transform: translateY(14px);
        animation: reveal 0.65s var(--ease-out) forwards;
        animation-delay: calc(var(--reveal-i, 0) * 90ms);
    }

    @keyframes reveal {
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* ---------- 顶栏 ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 24px;
    background: rgba(10, 13, 19, 0.72);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.brand-mark {
    display: inline-flex;
    align-self: center;
}

.brand-name {
    font-size: 1.22rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-sub {
    font-size: 0.8rem;
    color: var(--text-3);
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 状态 pill */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 13px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-2);
    white-space: nowrap;
    transition: border-color 0.25s ease, color 0.25s ease;
}

.pill-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-3);
    flex: none;
    transition: background 0.25s ease;
}

.pill[data-state="connected"] {
    color: var(--success);
    border-color: rgba(62, 207, 142, 0.35);
}

.pill[data-state="connected"] .pill-dot {
    background: var(--success);
    box-shadow: 0 0 8px rgba(62, 207, 142, 0.7);
}

.pill[data-state="connecting"] {
    color: var(--warning);
    border-color: rgba(245, 180, 83, 0.35);
}

.pill[data-state="connecting"] .pill-dot {
    background: var(--warning);
    animation: dot-pulse 1.1s ease-in-out infinite;
}

.pill[data-state="error"] {
    color: var(--danger);
    border-color: rgba(242, 109, 109, 0.4);
}

.pill[data-state="error"] .pill-dot {
    background: var(--danger);
}

@keyframes dot-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* 自动接收 chip */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.chip:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

.chip[data-on="true"] {
    color: var(--accent-2);
    border-color: rgba(56, 217, 192, 0.35);
    background: rgba(56, 217, 192, 0.08);
}

/* 语言选择 */
.lang-select {
    padding: 7px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 0.82rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.lang-select:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

.lang-select option {
    background: var(--bg-solid);
    color: var(--text-1);
}

/* ---------- 图标按钮 ---------- */

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.18s ease;
    flex: none;
    text-decoration: none;
}

.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text-1);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: scale(0.94);
}

.icon-btn-sm {
    width: 28px;
    height: 28px;
    border-radius: 8px;
}

/* ---------- 按钮（.btn 系列为 file-settings.js 等模块的契约类） ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease,
        border-color 0.2s ease, color 0.2s ease, filter 0.2s ease;
    user-select: none;
}

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

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--accent-grad);
    color: #fff;
    box-shadow: 0 4px 18px var(--accent-glow);
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 6px 22px var(--accent-glow);
}

.btn-secondary {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text-1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.11);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-2);
}

.btn-ghost:hover {
    background: var(--surface);
    color: var(--text-1);
}

.btn-danger {
    background: var(--danger-soft);
    border-color: rgba(242, 109, 109, 0.35);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(242, 109, 109, 0.2);
}

.btn-small {
    padding: 7px 13px;
    font-size: 0.82rem;
    border-radius: 8px;
}

/* 独立使用的 .btn-small（file-settings.js 契约：不带 .btn 基类） */
.btn-small:not(.btn) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--text-1);
    transition: all 0.18s ease;
}

.btn-small:not(.btn):hover {
    background: rgba(255, 255, 255, 0.11);
}

.btn-small:not(.btn):disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
}

.btn-close:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

/* ---------- 布局 ---------- */

.layout {
    flex: 1;
    align-self: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 24px 40px;
}

/* 顶部信息条：名片 + 手动连接 + 二维码 */
.top-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
    gap: 20px;
    align-items: stretch;
}

/* ---------- 卡片 ---------- */

.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.03));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card), var(--inner-hi);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    padding: 22px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.card-head h2 {
    font-size: 0.95rem;
    font-weight: 650;
    color: var(--text-1);
    letter-spacing: 0.01em;
}

.card-head h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-2);
}

/* ---------- 表单 ---------- */

.field-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-3);
    letter-spacing: 0.05em;
    margin: 14px 0 7px;
}

.field-label:first-of-type {
    margin-top: 0;
}

.input {
    width: 100%;
    padding: 11px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input::placeholder {
    color: var(--text-3);
}

.input:focus {
    border-color: rgba(79, 141, 255, 0.65);
    background: rgba(255, 255, 255, 0.075);
    box-shadow: 0 0 0 3px rgba(79, 141, 255, 0.16);
}

.input-mono {
    font-family: var(--font-mono);
    letter-spacing: 0.06em;
}

/* ---------- 名片卡 ---------- */

.id-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.id-value {
    flex: 1;
    min-width: 0;
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 二维码面板 */
.qr-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 0;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

@media (prefers-reduced-motion: no-preference) {
    .qr-panel:not(.hidden) {
        animation: qr-in 0.35s var(--ease-out);
    }

    @keyframes qr-in {
        from {
            opacity: 0;
            transform: translateY(-6px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

.qr-box {
    width: 128px;
    height: 128px;
    flex: none;
    background: #fff;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #666;
    font-size: 0.75rem;
    text-align: center;
}

.qr-box canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    padding: 6px;
}

.qr-side {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}

.qr-hint {
    font-size: 0.85rem;
    color: var(--text-2);
}

/* ---------- 连接卡 ---------- */

.connect-form {
    display: flex;
    gap: 10px;
}

.connect-form .input {
    flex: 1;
    min-width: 0;
}

.discovery {
    margin-top: 20px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

.discovery-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.discovery-head h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-2);
}

.peer-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
}

.peer-empty {
    text-align: center;
    color: var(--text-3);
    font-size: 0.85rem;
    padding: 18px 0;
}

.peer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.18s ease;
}

.peer-item:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.peer-info {
    min-width: 0;
}

.peer-id {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    color: var(--text-1);
    letter-spacing: 0.04em;
}

.peer-ip {
    font-size: 0.74rem;
    color: var(--text-3);
    font-family: var(--font-mono);
}

/* ---------- 传输台 ---------- */

.stage-card {
    flex: 1;
    min-height: 380px;
    display: flex;
    flex-direction: column;
}

.stage-peer {
    display: flex;
    align-items: center;
    gap: 10px;
}

.peer-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 13px;
    border-radius: 999px;
    background: var(--success-soft);
    border: 1px solid rgba(62, 207, 142, 0.3);
    font-size: 0.82rem;
    color: var(--success);
}

.peer-chip .pill-dot {
    background: var(--success);
    box-shadow: 0 0 8px rgba(62, 207, 142, 0.7);
}

.peer-chip code {
    letter-spacing: 0.05em;
}

.stage-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    padding: 30px 10px;
}

.stage-view-active {
    justify-content: flex-start;
    text-align: left;
    gap: 16px;
    padding: 4px 0 0;
    align-items: stretch;
}

.stage-illustration {
    color: var(--text-1);
    opacity: 0.75;
    margin-bottom: 6px;
}

.stage-title {
    font-size: 1.06rem;
    font-weight: 650;
    color: var(--text-1);
}

.stage-hint {
    font-size: 0.85rem;
    color: var(--text-3);
    max-width: 34ch;
}

/* 连接中动画 */
.link-anim {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 14px;
}

.link-node {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-grad);
    box-shadow: 0 0 14px var(--accent-glow);
    flex: none;
}

.link-node-remote {
    background: var(--surface-2);
    border: 2px solid var(--border-strong);
    box-shadow: none;
}

.link-beam {
    position: relative;
    width: 130px;
    height: 2px;
    background: var(--border-strong);
    overflow: visible;
}

.link-pulse {
    position: absolute;
    top: 50%;
    left: 0;
    width: 26px;
    height: 2px;
    transform: translateY(-50%);
    background: var(--accent-grad);
    border-radius: 2px;
    box-shadow: 0 0 10px var(--accent-glow);
    animation: beam 1.15s linear infinite;
}

@keyframes beam {
    from {
        left: -26px;
    }

    to {
        left: 130px;
    }
}

#cancel-connect-btn {
    margin-top: 14px;
}

/* ---------- 拖放区 ---------- */

.drop-zone {
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: 34px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: border-color 0.25s ease, background 0.25s ease, transform 0.2s ease;
    outline: none;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(79, 141, 255, 0.07);
}

.drop-zone.drag-over {
    transform: scale(1.01);
    box-shadow: 0 0 0 4px rgba(79, 141, 255, 0.12);
}

.dz-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent);
    transition: transform 0.25s var(--ease-out);
}

.drop-zone:hover .dz-icon,
.drop-zone.drag-over .dz-icon {
    transform: translateY(-3px);
}

.dz-hint {
    font-size: 0.88rem;
    color: var(--text-2);
}

.dz-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------- 批量下载确认提示横幅 ---------- */

.dl-hint-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: rgba(245, 180, 83, 0.12);
    border: 1px solid rgba(245, 180, 83, 0.45);
    color: var(--warning);
    margin-bottom: 12px;
}

.dl-hint-banner svg {
    flex-shrink: 0;
}

.dl-hint-text {
    flex: 1;
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--text-1);
}

/* ---------- 接收请求卡片 ---------- */

.receive-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--accent-soft);
    border: 1px solid rgba(79, 141, 255, 0.35);
}

@media (prefers-reduced-motion: no-preference) {
    .receive-card:not(.hidden) {
        animation: card-in 0.35s var(--ease-out);
    }

    @keyframes card-in {
        from {
            opacity: 0;
            transform: translateY(-8px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

.file-badge {
    width: 42px;
    height: 42px;
    flex: none;
    border-radius: var(--radius-sm);
    background: var(--accent-grad);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.receive-info {
    flex: 1;
    min-width: 0;
}

.receive-name {
    font-weight: 650;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.receive-sub {
    font-size: 0.78rem;
    color: var(--text-2);
    margin-top: 2px;
}

.receive-sep {
    margin: 0 6px;
    color: var(--text-3);
}

.receive-actions {
    display: flex;
    gap: 8px;
    flex: none;
}

/* ---------- 传输列表 ---------- */

.transfer-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.t-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color 0.25s ease;
}

@media (prefers-reduced-motion: no-preference) {
    .t-item {
        animation: card-in 0.3s var(--ease-out);
    }
}

.t-icon {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    color: var(--text-2);
}

.t-item[data-dir="sending"] .t-icon {
    background: var(--accent-soft);
    color: var(--accent);
}

.t-item[data-dir="receiving"] .t-icon {
    background: rgba(56, 217, 192, 0.12);
    color: var(--accent-2);
}

.t-item[data-state="done"] .t-icon {
    background: var(--success-soft);
    color: var(--success);
}

.t-item[data-state="failed"] .t-icon,
.t-item[data-state="rejected"] .t-icon {
    background: var(--danger-soft);
    color: var(--danger);
}

.t-main {
    flex: 1;
    min-width: 0;
}

.t-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
}

.t-name {
    font-size: 0.9rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.t-pct {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-2);
    flex: none;
}

.t-item[data-state="done"] .t-pct {
    color: var(--success);
}

.t-item[data-state="failed"] .t-pct,
.t-item[data-state="rejected"] .t-pct {
    color: var(--danger);
}

.t-bar {
    height: 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.t-fill {
    height: 100%;
    width: 0%;
    border-radius: 6px;
    background: var(--accent-grad);
    transition: width 0.35s ease;
}

.t-item[data-state="done"] .t-fill {
    background: var(--success);
}

.t-item[data-state="failed"] .t-fill,
.t-item[data-state="rejected"] .t-fill {
    background: var(--danger);
}

/* 等待对方接受：不确定进度动画 */
.t-item[data-state="pending"] .t-fill {
    width: 35% !important;
    animation: t-indeterminate 1.2s ease-in-out infinite;
}

@keyframes t-indeterminate {
    0% {
        margin-left: -35%;
    }

    100% {
        margin-left: 100%;
    }
}

.t-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 7px;
    font-size: 0.76rem;
    color: var(--text-3);
    font-family: var(--font-mono);
}

.t-cancel {
    flex: none;
}

/* ---------- 完成卡片 ---------- */

.complete-card {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 16px;
    border-radius: var(--radius-md);
    background: var(--success-soft);
    border: 1px solid rgba(62, 207, 142, 0.32);
}

@media (prefers-reduced-motion: no-preference) {
    .complete-card:not(.hidden) {
        animation: card-in 0.35s var(--ease-out);
    }
}

.complete-check {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 50%;
    background: var(--success);
    color: #06281b;
    display: flex;
    align-items: center;
    justify-content: center;
}

.complete-text {
    flex: 1;
    min-width: 0;
    font-size: 0.86rem;
}

.complete-location {
    color: var(--text-2);
    font-size: 0.78rem;
    margin-top: 2px;
}

/* ---------- 日志抽屉 ---------- */

.log-drawer {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: min(920px, calc(100vw - 24px));
    z-index: 200;
    background: rgba(13, 17, 25, 0.88);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: 0 -8px 30px rgba(3, 6, 12, 0.5);
    overflow: hidden;
}

.log-bar {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    background: transparent;
    border: none;
    color: var(--text-2);
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s ease;
}

.log-bar:hover {
    background: var(--surface);
}

.log-bar-title {
    font-weight: 650;
    color: var(--text-1);
    white-space: nowrap;
}

.log-latest {
    flex: 1;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.log-count {
    flex: none;
    min-width: 20px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-2);
    text-align: center;
}

.log-chevron {
    flex: none;
    transition: transform 0.3s var(--ease-out);
}

.log-drawer.open .log-chevron {
    transform: rotate(180deg);
}

.log-panel {
    max-height: 0;
    transition: max-height 0.35s var(--ease-out);
    overflow: hidden;
    border-top: 1px solid transparent;
}

.log-drawer.open .log-panel {
    max-height: 280px;
    border-top-color: var(--border);
}

.log-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    font-size: 0.78rem;
    color: var(--text-2);
    border-bottom: 1px solid var(--border);
}

.log-content {
    height: 210px;
    overflow-y: auto;
    padding: 10px 16px;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    line-height: 1.7;
}

.log-item {
    display: flex;
    gap: 10px;
    color: var(--text-2);
}

.log-item .timestamp {
    color: var(--text-3);
    flex: none;
}

.log-item.error {
    color: var(--danger);
}

.log-item.warn,
.log-item.warning {
    color: var(--warning);
}

.log-item.success {
    color: var(--success);
}

/* ---------- 模态框（.modal 系列为 file-settings.js 的契约类） ---------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(5, 8, 14, 0.62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-content {
    width: min(430px, 100%);
    max-height: 88vh;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(30, 36, 48, 0.98), rgba(21, 26, 37, 0.98));
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55), var(--inner-hi);
}

@media (prefers-reduced-motion: no-preference) {
    .modal:not(.hidden) .modal-content {
        animation: modal-in 0.28s var(--ease-out);
    }

    @keyframes modal-in {
        from {
            opacity: 0;
            transform: translateY(12px) scale(0.97);
        }

        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 0;
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 650;
}

.modal-body {
    padding: 14px 22px;
    color: var(--text-2);
    font-size: 0.9rem;
    line-height: 1.65;
    word-break: break-word;
    white-space: pre-line;
}

.modal-body p {
    margin: 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 6px 22px 20px;
}

/* 邀请弹窗 */
.invite-content {
    padding: 28px 26px 24px;
    text-align: center;
}

.invite-avatar {
    width: 58px;
    height: 58px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--accent-grad);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px var(--accent-glow);
    text-transform: uppercase;
}

.invite-title {
    font-size: 1.02rem;
    font-weight: 650;
    margin-bottom: 6px;
}

.invite-message {
    color: var(--text-2);
    font-size: 0.88rem;
    margin-bottom: 22px;
    word-break: break-word;
}

.invite-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ---------- 通知（Toast） ---------- */

.notifications {
    position: fixed;
    top: 76px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.notification {
    pointer-events: auto;
    max-width: 340px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: rgba(21, 26, 37, 0.92);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--accent);
    box-shadow: 0 10px 32px rgba(3, 6, 12, 0.5);
    color: var(--text-1);
    font-size: 0.84rem;
    cursor: pointer;
    overflow-wrap: break-word;
}

@media (prefers-reduced-motion: no-preference) {
    .notification {
        animation: toast-in 0.3s var(--ease-out);
    }

    @keyframes toast-in {
        from {
            opacity: 0;
            transform: translateX(24px);
        }

        to {
            opacity: 1;
            transform: translateX(0);
        }
    }
}

.notification.success {
    border-left-color: var(--success);
}

.notification.warning {
    border-left-color: var(--warning);
}

.notification.error {
    border-left-color: var(--danger);
}

/* ---------- file-settings.js 弹窗契约样式 ---------- */

.file-auth-modal {
    width: min(470px, 100%);
}

.auth-settings {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-group>label {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-1);
    cursor: pointer;
}

.setting-group small {
    color: var(--text-3);
    font-size: 0.76rem;
}

.setting-group small.dl-hint-static {
    display: block;
    margin-top: 8px;
    color: var(--warning);
    line-height: 1.5;
}

.setting-group input[type="checkbox"],
.setting-group input[type="radio"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-group>label {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.87rem;
    color: var(--text-2);
    cursor: pointer;
    flex-wrap: wrap;
}

.radio-group>label.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.radio-group .btn-small {
    margin-left: 6px;
}

.browser-support-info {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.browser-support-info small {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.76rem;
}

.support-yes {
    color: var(--success);
}

.support-no {
    color: var(--danger);
}

/* ---------- 响应式 ---------- */

@media (max-width: 1024px) {
    .top-strip {
        grid-template-columns: 1fr 1fr;
    }

    #qr-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 640px) {
    body {
        padding-bottom: 56px;
    }

    .topbar {
        flex-wrap: wrap;
        padding: 12px 16px;
        gap: 10px;
    }

    .topbar-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .brand-sub {
        display: none;
    }

    .layout {
        padding: 16px 14px 32px;
        gap: 14px;
    }

    .top-strip {
        grid-template-columns: 1fr;
    }

    #qr-panel {
        grid-column: auto;
    }

    .card {
        padding: 18px 16px;
    }

    .id-value {
        font-size: 1.2rem;
    }

    .connect-form {
        flex-direction: column;
    }

    .connect-form .btn {
        width: 100%;
    }

    .receive-card {
        flex-wrap: wrap;
    }

    .receive-actions {
        width: 100%;
    }

    .receive-actions .btn {
        flex: 1;
    }

    .qr-panel {
        flex-direction: column;
    }

    .qr-side {
        align-items: center;
    }

    .notifications {
        left: 16px;
        right: 16px;
        top: auto;
        bottom: 66px;
    }

    .notification {
        max-width: none;
    }

    .log-drawer {
        width: calc(100vw - 16px);
    }
}

/* ---------- 无障碍与降级 ---------- */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.001s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001s !important;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .card {
        background: var(--bg-solid);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .topbar,
    .log-drawer,
    .notification {
        background: var(--bg-solid);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .modal-content {
        background: var(--bg-solid);
    }
}

:focus-visible {
    outline: 2px solid rgba(79, 141, 255, 0.7);
    outline-offset: 2px;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.input:focus-visible,
.lang-select:focus-visible {
    outline: none;
}

/* ================================================================
 * 工具标签区（文件 / 消息 / 剪贴板）
 * ================================================================ */

.tool-tabs {
    display: flex;
    gap: 6px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    flex: none;
}

.tool-tab {
    position: relative;
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-2);
    font-size: 0.86rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.tool-tab:hover:not(:disabled) {
    color: var(--text-1);
    background: var(--surface-2);
}

.tool-tab.active {
    color: var(--text-1);
    background: var(--accent-soft);
    box-shadow: var(--inner-hi);
}

.tool-tab:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.tool-badge {
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
}

.tool-panes {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.tool-pane {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
    min-height: 0;
}

/* ---------- 聊天 ---------- */

.chat-log {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 6px 4px;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 78%;
}

.chat-msg.mine {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg.remote {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-bubble {
    padding: 9px 13px;
    border-radius: 13px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-msg.mine .chat-bubble {
    background: var(--accent-grad);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.remote .chat-bubble {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-1);
    border-bottom-left-radius: 4px;
}

.chat-meta {
    margin-top: 3px;
    font-size: 0.68rem;
    color: var(--text-3);
}

.chat-typing {
    font-size: 0.78rem;
    color: var(--text-3);
    font-style: italic;
    flex: none;
}

.chat-input-row {
    display: flex;
    gap: 8px;
    flex: none;
}

.chat-input-row .input {
    flex: 1;
}

.chat-counter {
    font-size: 0.72rem;
    color: var(--text-3);
    text-align: right;
    flex: none;
}

.chat-counter.over {
    color: var(--danger);
}

/* ---------- 聊天图片附件 ---------- */

.chat-hint {
    font-size: 0.72rem;
    color: var(--text-3);
    line-height: 1.4;
    flex: none;
}

.chat-attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    flex: none;
}

.chat-attachment img {
    max-height: 72px;
    max-width: 120px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.chat-attachment .icon-btn {
    flex: none;
}

/* ---------- 聊天图片气泡 ---------- */

.chat-bubble-image {
    padding: 6px;
    max-width: 260px;
}

.chat-image img {
    display: block;
    max-width: 100%;
    max-height: 260px;
    border-radius: 9px;
    cursor: zoom-in;
}

.chat-image-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 6px;
}

.chat-image-actions .btn {
    padding: 4px 10px;
    font-size: 0.76rem;
}

.chat-image-pending {
    padding: 18px 20px;
    font-size: 0.82rem;
    color: var(--text-2);
}

.chat-caption {
    padding: 6px 6px 2px;
    font-size: 0.82rem;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-msg.mine .chat-caption {
    color: rgba(255, 255, 255, 0.92);
}

.chat-bubble-error {
    background: var(--danger-soft) !important;
    color: var(--danger) !important;
    border: 1px solid rgba(242, 109, 109, 0.3);
    padding: 10px 13px;
    font-size: 0.82rem;
}

/* 拖拽图片到聊天区 */
.tool-pane.drag-over {
    outline: 2px dashed rgba(79, 141, 255, 0.55);
    outline-offset: -6px;
    border-radius: var(--radius-md);
}

/* ---------- 图片放大预览 ---------- */

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: rgba(6, 9, 15, 0.82);
    backdrop-filter: blur(4px);
}

.image-lightbox img {
    max-width: 92vw;
    max-height: 88vh;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.image-lightbox-close {
    position: absolute;
    top: 18px;
    right: 20px;
    font-size: 1.6rem;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    line-height: 1;
}
