/* =========================================================
   Quick Transfer - 主题
   配色沿用「h9学堂线路页」：深蓝底 + 琥珀橙主色 + 顶部双色光晕
   默认深色，右上角可切换浅色（记住选择）
   ========================================================= */

:root {
    /* 背景与光晕 */
    --bg-0: #0a0e1c;
    --bg-1: #0f1526;
    --bg-2: #131a30;
    --glow-main: rgba(249, 168, 61, .14);
    --glow-acc: rgba(64, 120, 255, .12);

    /* 卡片 */
    --card-top: rgba(255, 255, 255, .06);
    --card-bottom: rgba(255, 255, 255, .02);
    --card-border: rgba(255, 255, 255, .10);
    --bar-bg: rgba(255, 255, 255, .05);

    /* 文字 */
    --text: #f5f7ff;
    --muted: rgba(255, 255, 255, .62);

    /* 主色 */
    --accent: #f9a83d;
    --accent-soft: rgba(249, 168, 61, .16);
    --accent-border: rgba(249, 168, 61, .30);
    --btn-text: #2a1a05;

    /* 气泡 */
    --bubble-mine-1: #ffc96b;
    --bubble-mine-2: #f9a83d;
    --bubble-mine-text: #2a1a05;

    /* 输入控件 */
    --field-bg: rgba(255, 255, 255, .05);
    --field-border: rgba(255, 255, 255, .12);
    --header-bg: rgba(15, 21, 38, .72);
    --footer-bg: rgba(15, 21, 38, .78);

    /* 其它 */
    --copy-bg: rgba(255, 255, 255, .12);
    --copy-text: rgba(245, 247, 255, .82);
    --shimmer: rgba(255, 255, 255, .16);
    --overlay-bg: rgba(4, 6, 14, .94);
    --toast-bg: rgba(10, 14, 28, .92);
    --toast-border: rgba(255, 255, 255, .12);
    --scroll-thumb: rgba(255, 255, 255, .18);
    --danger: #ff6b6b;

    --radius: 18px;
    --shadow: 0 8px 24px rgba(0, 0, 0, .35);
    --glow-btn: 0 4px 14px -6px rgba(249, 168, 61, .45);
}

html[data-theme="light"] {
    --bg-0: #edf1f8;
    --bg-1: #f5f7fc;
    --bg-2: #ffffff;
    --glow-main: rgba(224, 127, 18, .10);
    --glow-acc: rgba(64, 120, 255, .06);

    --card-top: #ffffff;
    --card-bottom: #fbfcfe;
    --card-border: rgba(15, 23, 42, .10);
    --bar-bg: rgba(15, 23, 42, .04);

    --text: #171d2e;
    --muted: #5b6577;

    --accent: #e07f12;
    --accent-soft: rgba(224, 127, 18, .12);
    --accent-border: rgba(224, 127, 18, .35);
    --btn-text: #2a1a05;

    --bubble-mine-1: #ffd28a;
    --bubble-mine-2: #e07f12;
    --bubble-mine-text: #2a1a05;

    --field-bg: #ffffff;
    --field-border: rgba(15, 23, 42, .12);
    --header-bg: rgba(255, 255, 255, .80);
    --footer-bg: rgba(255, 255, 255, .86);

    --copy-bg: rgba(15, 23, 42, .06);
    --copy-text: #5b6577;
    --shimmer: rgba(255, 255, 255, .55);
    --overlay-bg: rgba(10, 14, 28, .93);
    --toast-bg: rgba(23, 29, 46, .92);
    --toast-border: rgba(255, 255, 255, .14);
    --scroll-thumb: rgba(15, 23, 42, .18);
    --danger: #e04141;

    --shadow: 0 14px 32px -14px rgba(15, 23, 42, .22);
}

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

html, body { height: 100%; overflow: hidden; }

body {
    font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont,
                 'Segoe UI', Roboto, system-ui, sans-serif;
    color: var(--text);
    background:
        radial-gradient(900px 420px at 50% -140px, var(--glow-main), transparent 62%),
        radial-gradient(700px 460px at 88% 10%, var(--glow-acc), transparent 60%),
        linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 46%, var(--bg-2) 100%);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    transition: background .35s ease, color .35s ease;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* 通用渐变按钮（沿用参考页 CTA 的观感）
   这里把页面上所有主操作按钮一起并进去，不用改 HTML/JS */
.cta,
.gate-btn,
#send-btn,
.send-imgs-btn {
    background: linear-gradient(135deg, var(--bubble-mine-1), var(--accent));
    color: var(--btn-text);
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 800;
    letter-spacing: .5px;
    cursor: pointer;
    box-shadow: var(--glow-btn);
    transition: transform .25s ease, box-shadow .25s ease, filter .25s ease;
}
.cta:hover { transform: translateY(-1px); filter: saturate(1.08); }
.cta:active { transform: translateY(0); opacity: .9; }

/* ==================== 口令遮罩 ==================== */
.gate {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    background:
        radial-gradient(700px 380px at 50% 10%, var(--glow-main), transparent 62%),
        linear-gradient(180deg, var(--bg-0), var(--bg-1));
}
.gate.hidden { display: none; }

.gate-box {
    width: 100%;
    max-width: 340px;
    text-align: center;
    padding: 32px 28px;
    border-radius: var(--radius);
    border: 1px solid var(--card-border);
    background: linear-gradient(180deg, var(--card-top), var(--card-bottom));
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.gate-icon { font-size: 40px; margin-bottom: 12px; }
.gate-title { font-size: 17px; font-weight: 700; margin-bottom: 18px; color: var(--text); }

#gate-input {
    width: 100%;
    border: 1px solid var(--field-border);
    background: var(--field-bg);
    color: var(--text);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 16px;
    outline: none;
    text-align: center;
    font-family: inherit;
    transition: border-color .25s ease, box-shadow .25s ease;
}
#gate-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.gate-btn { width: 100%; margin-top: 12px; padding: 12px; font-size: 16px; border-radius: 12px; }
.gate-err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ==================== 顶部 ==================== */
#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    padding-top: env(safe-area-inset-top, 0px);
    height: 54px;
    flex-shrink: 0;
    z-index: 10;
    background: var(--header-bg);
    border-bottom: 1px solid var(--card-border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.header-left { display: flex; align-items: center; gap: 9px; }
.logo {
    font-size: 18px;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 11px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    color: var(--accent);
}
.title-wrap { display: flex; flex-direction: column; line-height: 1.2; }
.title { font-size: 16px; font-weight: 800; letter-spacing: .5px; color: var(--text); }
.sub-title { font-size: 11px; color: var(--muted); }

.header-right { display: flex; align-items: center; gap: 8px; }

.status-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: #ff5f57;
    flex-shrink: 0;
    transition: background .3s, box-shadow .3s;
}
.status-dot.ok { background: #28c840; box-shadow: 0 0 8px rgba(40, 200, 64, .7); }
.status-dot.loading { background: #febc2e; box-shadow: 0 0 8px rgba(254, 188, 46, .6); }

.icon-btn {
    background: var(--field-bg);
    border: 1px solid var(--field-border);
    color: var(--text);
    width: 32px; height: 32px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    transition: border-color .25s ease, color .25s ease, background .25s ease;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn:active { transform: scale(.94); }

/* ==================== 消息区 ==================== */
.messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    -webkit-overflow-scrolling: touch;
}
.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 3px; }

.msg-row { display: flex; max-width: 100%; }
/* 仅新消息播放入场动画，加载历史时不播，避免整屏晃动 */
.msg-row.anim { animation: in 0.22s ease; }
@keyframes in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.msg-row.mine  { justify-content: flex-end; }
.msg-row.other { justify-content: flex-start; }

.msg-col { display: flex; flex-direction: column; max-width: 76%; }
.msg-row.mine .msg-col { align-items: flex-end; }
.msg-row.other .msg-col { align-items: flex-start; }

.bubble {
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
    border: 1px solid transparent;
}
.msg-row.mine .bubble {
    background: linear-gradient(135deg, var(--bubble-mine-1), var(--bubble-mine-2));
    color: var(--bubble-mine-text);
    border-bottom-right-radius: 5px;
    box-shadow: var(--glow-btn);
}
.msg-row.other .bubble {
    background: linear-gradient(180deg, var(--card-top), var(--card-bottom));
    border-color: var(--card-border);
    color: var(--text);
    border-bottom-left-radius: 5px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.bubble .text { white-space: pre-wrap; }

.bubble.img-bubble {
    padding: 4px;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
}

/* 占位盒：宽高由 JS 按图片真实比例算好，图片加载不会撑开布局 */
.img-wrap {
    position: relative;
    border-radius: 13px;
    overflow: hidden;
    background: var(--bar-bg);
    cursor: zoom-in;
    box-sizing: border-box;
}
.img-wrap + .img-wrap { margin-top: 4px; }
.img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity .22s ease;
}
.img-wrap.loaded img { opacity: 1; }

/* 加载中的微光提示 */
.img-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, var(--shimmer), transparent);
    animation: shimmer 1.3s infinite;
}
.img-wrap.loaded::before { display: none; }
@keyframes shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.msg-row.mine .bubble.img-bubble .img-wrap  { border: 2px solid var(--accent); }
.msg-row.other .bubble.img-bubble .img-wrap { border: 1px solid var(--card-border); }

.msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--muted);
    margin-top: 3px;
    padding: 0 4px;
}

/* 单条消息的删除入口：默认很淡，鼠标设备上悬停才显现（手机常显，方便点） */
.del-btn {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: 11px;
    color: var(--muted);
    cursor: pointer;
    transition: color .2s ease, opacity .2s ease;
}
.del-btn:hover { color: var(--danger); }
.del-btn.confirm { color: var(--danger); font-weight: 800; }
.del-btn:disabled { cursor: default; }
@media (hover: hover) {
    .del-btn { opacity: 0; }
    .msg-row:hover .del-btn { opacity: .85; }
    .del-btn:hover, .del-btn.confirm { opacity: 1; }
}

.copy-btn {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    background: var(--copy-bg);
    border: none;
    border-radius: 8px;
    padding: 3px 10px;
    cursor: pointer;
    font-family: inherit;
    color: var(--copy-text);
}
.msg-row.mine .copy-btn { color: rgba(42, 26, 5, .88); background: rgba(0, 0, 0, .10); }
.copy-btn:active { opacity: .75; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--muted);
    gap: 10px;
    text-align: center;
    padding: 40px 24px;
}
.empty-state .icon { font-size: 44px; opacity: .9; }
.empty-state .hint { font-size: 13.5px; line-height: 1.9; }

/* ==================== 输入区 ==================== */
#input-area {
    background: var(--footer-bg);
    border-top: 1px solid var(--card-border);
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
    z-index: 10;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.input-row { display: flex; align-items: flex-end; gap: 7px; }

.upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: 12px;
    background: var(--field-bg);
    border: 1px solid var(--field-border);
    cursor: pointer;
    color: var(--muted);
    flex-shrink: 0;
    transition: border-color .25s ease, color .25s ease;
}
.upload-btn:hover { border-color: var(--accent); color: var(--accent); }
.upload-btn input { display: none; }

#text-input {
    flex: 1;
    border: 1px solid var(--field-border);
    background: var(--field-bg);
    color: var(--text);
    border-radius: 19px;
    padding: 9px 15px;
    font-size: 15px;
    resize: none;
    max-height: 110px;
    line-height: 1.4;
    outline: none;
    font-family: inherit;
    transition: border-color .25s ease, box-shadow .25s ease;
}
#text-input::placeholder { color: var(--muted); }
#text-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

#send-btn {
    border-radius: 19px;
    padding: 0 18px;
    height: 38px;
    font-size: 15px;
    flex-shrink: 0;
    font-weight: 800;
    letter-spacing: .5px;
}

/* ==================== 待发图片预览 ==================== */
.preview-area {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    align-items: center;
    padding: 8px;
    background: var(--bar-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
}
.preview-area.hidden { display: none; }

.preview-item {
    position: relative;
    width: 58px; height: 58px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--card-border);
}
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item .rm {
    position: absolute;
    top: 2px; right: 2px;
    width: 18px; height: 18px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
    border: none;
    line-height: 1;
}

.send-imgs-btn { padding: 8px 15px; border-radius: 14px; font-size: 14px; }

/* ==================== 图片查看器 ==================== */
.img-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    cursor: zoom-out;
    animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.img-overlay img {
    max-width: 96%;
    max-height: 96%;
    object-fit: contain;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    left: 50%;
    bottom: 90px;
    transform: translateX(-50%);
    background: var(--toast-bg);
    border: 1px solid var(--toast-border);
    color: #fff;
    padding: 9px 18px;
    border-radius: 999px;
    font-size: 13.5px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 4000;
    animation: toastIn .2s ease;
    pointer-events: none;
}
@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 480px) {
    .msg-col { max-width: 82%; }
}

/* 尊重系统「减少动效」设置 */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
