/* 本地聊天（messenger.html）：像 LINE 的三欄畫面——功能列、清單、對話，右邊可以展開聊天室資訊 */
:root { color-scheme: light dark; --fs: 14px;
  --green: #06c755; --green-d: #05a948; --bg: #fff; --bg2: #f5f7fa; --bg3: #e9edf3; --line: #e3e7ee; --text: #1f2933; --muted: #7b8794;
  --rail: #233042; --rail-hover: #2f3f55; --bub-me: #8de055; --bub-me-t: #12320a; --bub-other: #fff; --bub-other-t: #1f2933; --chat-bg: #dce5f0;
  --danger: #e5484d; --link: #1a6ee0; --sel: #e8f7ee; --shadow: 0 8px 30px rgba(15, 30, 60, .18); --warn-bg: #fff4d6; --warn-t: #7a5b00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #1b2430; --bg2: #212c3a; --bg3: #2a3646; --line: #2f3b4c; --text: #e6ebf2; --muted: #8b98a9; --rail: #141c26; --rail-hover: #222d3b;
  --bub-me: #2a9d57; --bub-me-t: #fff; --bub-other: #2c3849; --bub-other-t: #e6ebf2; --chat-bg: #151d28; --link: #6ea8ff; --sel: #21382c; --shadow: 0 8px 30px rgba(0, 0, 0, .5); --warn-bg: #3d3414; --warn-t: #f2d675; } }
:root[data-theme="dark"] {
  --bg: #1b2430; --bg2: #212c3a; --bg3: #2a3646; --line: #2f3b4c; --text: #e6ebf2; --muted: #8b98a9; --rail: #141c26; --rail-hover: #222d3b;
  --bub-me: #2a9d57; --bub-me-t: #fff; --bub-other: #2c3849; --bub-other-t: #e6ebf2; --chat-bg: #151d28; --link: #6ea8ff; --sel: #21382c; --shadow: 0 8px 30px rgba(0, 0, 0, .5); --warn-bg: #3d3414; --warn-t: #f2d675; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg2); color: var(--text); font: var(--fs)/1.5 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.ico { width: 20px; height: 20px; flex: none; }
code { font-family: ui-monospace, Menlo, monospace; font-size: .92em; background: var(--bg3); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.grow { flex: 1; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(120, 130, 145, .35); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }

/* ---- 通用元件 ---- */
.btn { height: 34px; padding: 0 16px; border: 1px solid var(--line); background: var(--bg); border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 500; }
.btn:hover { background: var(--bg3); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-d); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.big { height: 42px; font-size: 1.05em; border-radius: 11px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { border: none; background: none; color: var(--link); padding: 0; display: inline-flex; align-items: center; gap: 4px; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); }
.link.center { display: flex; margin: 8px auto 0; }
.icon-btn { width: 34px; height: 34px; border: none; background: none; border-radius: 9px; display: inline-grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--bg3); color: var(--text); }
.icon-btn.on { color: var(--green); background: var(--sel); }
.icon-btn:disabled { opacity: .4; }
.spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -3px; }
.spin.white { border-color: rgba(255, 255, 255, .4); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.av { --s: 40px; width: var(--s); height: var(--s); border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 600; font-size: calc(var(--s) * .42); flex: none; overflow: hidden; user-select: none; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av.grp { grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 1px; background: var(--bg); padding: 0; place-items: stretch; }
.av.grp i { display: grid; place-items: center; font-style: normal; font-size: calc(var(--s) * .26); }
.av.s { background: var(--bg3); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #b8c0cc; display: inline-block; flex: none; }
.dot.ok { background: var(--green); } .dot.fail { background: var(--danger); } .dot.checking { background: #e0a82e; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---- 登入畫面 ---- */
.login { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; overflow: auto;
  background: radial-gradient(1000px 500px at 50% -10%, rgba(6, 199, 85, .18), transparent), var(--bg2); }
.login-card { width: 420px; max-width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 30px 30px 22px; box-shadow: var(--shadow); }
.brand { text-align: center; margin-bottom: 18px; }
.brand .logo, .about .logo { width: 56px; height: 56px; border-radius: 16px; background: var(--green); color: #fff; display: inline-grid; place-items: center; }
.brand .logo .ico, .about .logo .ico { width: 30px; height: 30px; }
.brand h1 { margin: 10px 0 2px; font-size: 1.7em; }
.brand p { margin: 0; color: var(--muted); font-size: .92em; }
.field-label { font-size: .85em; color: var(--muted); margin: 14px 0 6px; display: block; }
.seg { display: flex; gap: 6px; background: var(--bg2); padding: 4px; border-radius: 12px; }
.seg button { flex: 1; border: none; background: none; border-radius: 9px; padding: 8px 6px 7px; display: flex; flex-direction: column; align-items: center; gap: 0; position: relative; line-height: 1.25; }
.seg button small { color: var(--muted); font-size: .76em; }
.seg button .dot { position: absolute; top: 8px; right: 9px; }
.seg button.on { background: var(--bg); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); outline: 2px solid var(--green); outline-offset: -2px; }
.seg.sm { display: inline-flex; } .seg.sm button { flex-direction: row; padding: 6px 14px; min-width: 64px; justify-content: center; white-space: nowrap; }
.server-note { font-size: .82em; color: var(--muted); margin: 7px 2px 0; word-break: break-all; }
.weblogin { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; margin-top: 14px; font-size: .9em; }
.weblogin.checking, .weblogin.none { background: var(--bg2); color: var(--muted); }
.weblogin.none .ico { color: var(--muted); }
.weblogin.found { background: var(--sel); border: 1px solid rgba(6, 199, 85, .4); }
.weblogin .wl-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; } .weblogin small { color: var(--muted); }
#loginForm input[type=text], #loginForm input[type=email], #loginForm input:not([type]), #loginForm input[type=password], .pw input { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--bg); outline: none; }
#loginForm input:focus, .form-grid input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(6, 199, 85, .18); }
.pw { position: relative; } .pw input { padding-right: 42px; } .pw .icon-btn { position: absolute; right: 3px; top: 3px; }
.btn.google { width: 100%; margin-top: 14px; background: #fff; color: #1f2933; border: 1px solid #d3d9e2; font-weight: 600; gap: 10px; }
.btn.google:hover { background: #f5f7fa; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.google { background: #2c3849; color: #e6ebf2; border-color: #3a4a60; } }
:root[data-theme="dark"] .btn.google { background: #2c3849; color: #e6ebf2; border-color: #3a4a60; }
.notice { display: flex; gap: 8px; align-items: flex-start; background: var(--warn-bg); color: var(--warn-t); padding: 9px 12px; border-radius: 10px; margin-top: 10px; font-size: .88em; } .notice .ico { margin-top: 2px; width: 17px; height: 17px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .82em; margin: 16px 0 0; } .or::before, .or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.check { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; color: var(--muted); font-size: .9em; }
.form-error { display: flex; gap: 8px; align-items: flex-start; background: #fdecec; color: #b4232a; padding: 9px 12px; border-radius: 10px; margin: 10px 0; font-size: .9em; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .form-error { background: #4a2326; color: #ffb3b6; } }
:root[data-theme="dark"] .form-error { background: #4a2326; color: #ffb3b6; }
.form-error .ico { margin-top: 2px; }
#loginBtn { width: 100%; margin-top: 8px; }
.alt { text-align: center; margin-top: 14px; font-size: .9em; }
.login-foot { margin-top: 16px; color: var(--muted); font-size: .84em; display: flex; align-items: center; gap: 6px; } .login-foot .ico { width: 15px; height: 15px; }

/* ---- 主畫面骨架 ---- */
.shell { height: 100vh; display: grid; grid-template-columns: 68px 330px minmax(0, 1fr) auto; background: var(--bg); }
.rail { background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 14px 0 12px; gap: 6px; }
.rail-me { border: none; background: none; padding: 0; margin-bottom: 10px; border-radius: 50%; }
.rail-me:hover .av { box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); }
.rail-btn { width: 46px; height: 46px; border: none; background: none; border-radius: 13px; color: #9fb0c6; display: grid; place-items: center; position: relative; }
.rail-btn .ico { width: 25px; height: 25px; }
.rail-btn:hover { background: var(--rail-hover); color: #fff; }
.rail-btn.on { background: var(--rail-hover); color: var(--green); }
.rbadge { position: absolute; top: 3px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font: 700 11px/18px sans-serif; text-align: center; font-style: normal; }
.rlock { position: absolute; bottom: 2px; right: -1px; font: 600 9px/12px sans-serif; background: #e0a82e; color: #3d2e00; padding: 0 3px; border-radius: 4px; font-style: normal; }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.list-pane { border-right: 1px solid var(--line); }
.main-pane { background: var(--chat-bg); position: relative; }
.pane-head { display: flex; align-items: center; padding: 16px 14px 8px 18px; }
.pane-head h2 { margin: 0; font-size: 1.35em; flex: 1; } .pane-head h2 small { color: var(--muted); font-weight: 400; font-size: .7em; }
.head-actions { display: flex; gap: 2px; align-items: center; }
.searchbox { display: flex; align-items: center; gap: 8px; margin: 4px 14px 8px; padding: 0 10px; height: 36px; background: var(--bg2); border-radius: 10px; border: 1px solid transparent; color: var(--muted); }
.searchbox .ico { width: 17px; height: 17px; } .searchbox input { flex: 1; border: none; background: none; outline: none; min-width: 0; height: 100%; color: var(--text); }
.searchbox:focus-within { border-color: var(--green); background: var(--bg); }
.tabs { display: flex; gap: 6px; padding: 2px 14px 8px; }
.tabs button { border: none; background: var(--bg2); border-radius: 15px; padding: 4px 13px; color: var(--muted); font-size: .92em; }
.tabs button.on { background: var(--green); color: #fff; } .tabs button i { font-style: normal; background: var(--danger); color: #fff; border-radius: 8px; padding: 0 5px; font-size: .8em; margin-left: 2px; }
.conv-list { flex: 1; overflow-y: auto; padding-bottom: 12px; }
.conv { display: flex; gap: 12px; align-items: center; padding: 10px 14px; cursor: pointer; position: relative; }
.conv:hover { background: var(--bg2); } .conv.active { background: var(--sel); }
.conv.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--green); }
.conv .mid { flex: 1; min-width: 0; } .conv .top { display: flex; align-items: center; gap: 6px; }
.conv .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.conv .cnt { color: var(--muted); font-size: .82em; } .conv .flag { color: var(--muted); display: inline-flex; } .conv .flag .ico { width: 14px; height: 14px; }
.conv .preview { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92em; }
.conv .preview .who { color: var(--muted); } .typing-text { color: var(--green); }
.conv .end { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; min-width: 38px; }
.conv .end time { color: var(--muted); font-size: .8em; }
.badge { background: var(--green); color: #fff; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font: 600 12px/20px sans-serif; text-align: center; }
.badge.mute { background: #aab4c2; }
.tag { font-size: .72em; background: #fff1d6; color: #8a5a00; border-radius: 5px; padding: 0 5px; }
.sec-title { padding: 12px 18px 4px; font-size: .82em; color: var(--muted); display: flex; align-items: center; gap: 6px; font-weight: 600; position: sticky; top: 0; background: var(--bg); z-index: 1; } .sec-title .ico { width: 15px; height: 15px; }
.sec-title small { font-weight: 400; }
.conv.skel .av { background: var(--bg3); } .conv.skel i { display: block; height: 11px; border-radius: 6px; background: var(--bg3); margin: 6px 0; } .conv.skel .l1 { width: 55%; } .conv.skel .l2 { width: 85%; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .empty-ico { width: 54px; height: 54px; border-radius: 50%; background: var(--bg3); display: grid; place-items: center; } .empty .empty-ico .ico { width: 26px; height: 26px; }
.empty.big { flex: 1; justify-content: center; } .empty.big h3 { margin: 0; color: var(--text); } .empty.big p { margin: 0; }
.empty-ico.lg { width: 84px !important; height: 84px !important; background: rgba(255, 255, 255, .5) !important; } .empty-ico.lg .ico { width: 40px; height: 40px; }
.empty.small { padding: 22px; } .empty p { margin: 0; }
.loading { padding: 30px; text-align: center; color: var(--muted); }

/* ---- 對話 ---- */
.chat-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px 9px 16px; background: var(--bg); border-bottom: 1px solid var(--line); min-height: 60px; }
.chat-head .who { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; cursor: pointer; }
.chat-head .who > div { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; } .chat-head .who b { font-size: 1.08em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .who small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { display: none; }
.searchbar { display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 16px; background: var(--bg); border-bottom: 1px solid var(--line); color: var(--muted); }
.searchbar input { flex: 1; border: none; background: var(--bg2); height: 32px; border-radius: 8px; padding: 0 10px; outline: none; } .searchbar .count { font-size: .85em; min-width: 70px; text-align: right; }
.banner .bn { display: flex; align-items: center; gap: 8px; padding: 7px 16px; font-size: .88em; }
.bn.warn { background: var(--warn-bg); color: var(--warn-t); } .bn.demo { background: #e6f0ff; color: #234b8a; justify-content: space-between; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bn.demo { background: #1f3250; color: #a9c8ff; } }
:root[data-theme="dark"] .bn.demo { background: #1f3250; color: #a9c8ff; }
.bn .icon-btn { width: 24px; height: 24px; }
.msgs-wrap { flex: 1; min-height: 0; position: relative; display: flex; }
.msgs { flex: 1; overflow-y: auto; padding: 10px 18px 14px; scroll-behavior: auto; }
.jump { position: absolute; right: 18px; bottom: 14px; border: none; background: var(--bg); color: var(--green); border-radius: 18px; height: 36px; padding: 0 14px 0 10px; display: flex; align-items: center; gap: 4px; box-shadow: var(--shadow); font-weight: 600; }
.day, .sys, .unread-divider { display: flex; justify-content: center; margin: 14px 0 8px; }
.day span, .sys span { background: rgba(60, 75, 95, .38); color: #fff; font-size: .8em; padding: 2px 12px; border-radius: 12px; }
.sys { margin: 8px 0; } .sys span { background: rgba(60, 75, 95, .28); }
.unread-divider { position: relative; margin: 14px 0; } .unread-divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid rgba(120, 130, 145, .4); }
.unread-divider span { position: relative; background: var(--chat-bg); color: var(--muted); font-size: .82em; padding: 0 12px; }
.load-more { display: block; margin: 4px auto 10px; border: none; background: rgba(255, 255, 255, .6); border-radius: 14px; padding: 5px 16px; color: var(--muted); }
.row { display: flex; gap: 8px; margin-top: 2px; position: relative; padding: 1px 0; }
.row.first { margin-top: 10px; }
.row.mine { justify-content: flex-end; }
.av-col { width: 36px; flex: none; }
.col { max-width: min(72%, 620px); min-width: 0; display: flex; flex-direction: column; }
.row.mine .col { align-items: flex-end; }
.name { font-size: .82em; color: var(--muted); margin: 0 0 2px 4px; }
.line { display: flex; align-items: flex-end; gap: 6px; }
.content { min-width: 0; display: flex; flex-direction: column; gap: 3px; } .row.mine .content { align-items: flex-end; }
.bubble { padding: 8px 12px; border-radius: 16px; background: var(--bub-other); color: var(--bub-other-t); word-break: break-word; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0, 0, 0, .05); line-height: 1.5; }
.row.other.first .content > .bubble:first-child { border-top-left-radius: 4px; } .row.mine.first .content > .bubble:first-child { border-top-right-radius: 4px; }
.row.mine .bubble { background: var(--bub-me); color: var(--bub-me-t); }
.bubble a { color: var(--link); text-decoration: underline; overflow-wrap: anywhere; } .row.mine .bubble a { color: inherit; }
.bubble .mention { color: #0b6bcb; font-weight: 600; background: rgba(26, 110, 224, .1); border-radius: 4px; padding: 0 2px; } .row.mine .bubble .mention { color: inherit; background: rgba(255, 255, 255, .35); }
.bubble.deleted { background: transparent; box-shadow: none; border: 1px dashed rgba(120, 130, 145, .55); color: var(--muted); font-style: italic; padding: 5px 12px; }
.bubble.cap { margin-top: 2px; }
.bubble.dots { display: inline-flex; gap: 4px; padding: 11px 14px; } .bubble.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; } .bubble.dots i:nth-child(2) { animation-delay: .15s; } .bubble.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.quote { border-left: 3px solid rgba(0, 0, 0, .25); padding: 1px 8px; margin: 0 0 5px; font-size: .88em; opacity: .85; cursor: pointer; display: flex; flex-direction: column; max-width: 320px; } .quote b { font-weight: 600; } .quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; flex-direction: column; align-items: flex-end; font-size: .72em; color: var(--muted); white-space: nowrap; line-height: 1.25; flex: none; gap: 1px; } .row.other .meta { align-items: flex-start; }
.meta .read { color: var(--muted); } .meta .sending .ico { width: 14px; height: 14px; } .meta .failed { border: none; background: none; color: var(--danger); padding: 0; } .meta .failed .ico { width: 20px; height: 20px; }
.row.sending .bubble, .row.sending .media { opacity: .6; } .row.failed .bubble { background: #fbdede; color: #7a1c20; }
.tools { display: none; align-self: center; gap: 0; } .row:hover .tools { display: flex; } .tools .icon-btn { width: 28px; height: 28px; background: var(--bg); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); margin: 0 2px; } .tools .ico { width: 15px; height: 15px; }
.row.hit .bubble { outline: 2px solid #f5a524; } .row.flash .bubble { animation: flash 1.4s; } mark { background: #ffe066; color: #222; border-radius: 3px; padding: 0 1px; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 4px rgba(245, 165, 36, .6); } }
.media { display: grid; gap: 3px; border-radius: 14px; overflow: hidden; width: 280px; max-width: 100%; position: relative; }
.media.g1 { grid-template-columns: 1fr; } .media.g2 { grid-template-columns: 1fr 1fr; } .media.g3 { grid-template-columns: 1fr 1fr 1fr; } .media.g4 { grid-template-columns: 1fr 1fr; }
.thumb { position: relative; overflow: hidden; cursor: zoom-in; background: var(--bg3); aspect-ratio: 4 / 3; } .media.g1 .thumb { aspect-ratio: auto; max-height: 360px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; } .thumb:hover img { transform: scale(1.04); }
.thumb .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, .25); } .thumb .play .ico { width: 38px; height: 38px; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0, 0, 0, .15); } .progress i { display: block; height: 100%; background: var(--green); transition: width .15s; }
.bubble.filecard { display: flex; align-items: center; gap: 10px; min-width: 240px; padding: 10px 10px 10px 12px; position: relative; overflow: hidden; }
.fico { width: 40px; height: 40px; border-radius: 9px; color: #fff; display: grid; place-items: center; font: 700 11px/1 sans-serif; flex: none; } .fico.sm { width: 34px; height: 34px; font-size: 10px; }
.finfo { flex: 1; min-width: 0; display: flex; flex-direction: column; } .finfo b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; font-weight: 600; } .finfo small { opacity: .7; }
.row.mine .bubble.filecard .icon-btn { color: inherit; }
.typing-row { min-height: 4px; }

/* 輸入區 */
.composer { background: var(--bg); border-top: 1px solid var(--line); position: relative; padding: 8px 12px 12px; }
.comp-row { display: flex; align-items: flex-end; gap: 6px; }
.comp-tools { display: flex; } .comp-tools .icon-btn { width: 36px; height: 38px; }
#input { flex: 1; resize: none; border: 1px solid var(--line); background: var(--bg2); border-radius: 12px; padding: 8px 12px; outline: none; max-height: 140px; line-height: 1.5; overflow-y: auto; }
#input:focus { border-color: var(--green); background: var(--bg); }
.send { width: 38px; height: 38px; border: none; border-radius: 12px; background: var(--bg3); color: var(--muted); display: grid; place-items: center; flex: none; }
.send.on { background: var(--green); color: #fff; } .send:disabled { cursor: default; }
.replybar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; margin-bottom: 8px; background: var(--bg2); border-left: 3px solid var(--green); border-radius: 8px; color: var(--muted); }
.replybar > div { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; } .replybar b { color: var(--text); font-size: .9em; } .replybar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9em; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 8px; }
.chip { display: flex; align-items: center; gap: 8px; background: var(--bg2); border-radius: 10px; padding: 5px 4px 5px 6px; flex: none; max-width: 240px; } .chip img { width: 38px; height: 38px; border-radius: 7px; object-fit: cover; }
.chip > div { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; } .chip b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88em; } .chip small { color: var(--muted); font-size: .78em; } .chip .icon-btn { width: 24px; height: 24px; }
.emoji-panel { position: absolute; left: 12px; bottom: 62px; width: 330px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); z-index: 20; padding: 8px; }
.etabs { display: flex; gap: 4px; margin-bottom: 6px; } .etabs button { border: none; background: none; border-radius: 8px; padding: 3px 10px; color: var(--muted); } .etabs button.on { background: var(--sel); color: var(--green); }
.egrid { display: grid; grid-template-columns: repeat(8, 1fr); max-height: 190px; overflow-y: auto; } .egrid button { border: none; background: none; font-size: 22px; height: 38px; border-radius: 8px; } .egrid button:hover { background: var(--bg3); }
.drop-hint { position: absolute; inset: 0; background: rgba(6, 199, 85, .12); border: 3px dashed var(--green); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--green); font-size: 1.2em; z-index: 30; pointer-events: none; }
.drop-hint .ico { width: 44px; height: 44px; }

/* ---- 右邊：聊天室資訊 ---- */
.drawer { width: 330px; background: var(--bg); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.d-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 6px 18px; font-size: 1.1em; }
.d-tabs { display: flex; padding: 0 14px; border-bottom: 1px solid var(--line); } .d-tabs button { border: none; background: none; padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; } .d-tabs button.on { color: var(--green); border-color: var(--green); font-weight: 600; }
.d-body { flex: 1; overflow-y: auto; padding: 14px; }
.d-card { text-align: center; padding: 6px 0 12px; } .d-card h3 { margin: 10px 0 2px; } .d-card p { margin: 0; color: var(--muted); }
.d-actions { display: flex; justify-content: center; gap: 22px; padding: 6px 0 14px; border-bottom: 1px solid var(--line); }
.d-actions button { border: none; background: none; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: .85em; } .d-actions button .ico { width: 42px; height: 42px; padding: 10px; background: var(--bg2); border-radius: 50%; } .d-actions button.on { color: var(--green); } .d-actions button.on .ico { background: var(--sel); }
.d-title { display: flex; align-items: center; gap: 6px; font-weight: 600; margin: 16px 0 6px; } .d-title small { color: var(--muted); font-weight: 400; flex: 1; } .d-title .link { font-weight: 400; font-size: .9em; }
.mem { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 10px; cursor: pointer; } .mem:hover { background: var(--bg2); } .mem > div { display: flex; flex-direction: column; line-height: 1.3; } .mem small { color: var(--muted); } .mem em { font-style: normal; font-size: .75em; background: var(--sel); color: var(--green); border-radius: 5px; padding: 0 5px; }
.d-fields { margin-top: 14px; display: grid; gap: 10px; } .d-fields div, .pf-fields div, .kv { display: flex; flex-direction: column; line-height: 1.35; } .d-fields small, .pf-fields small, .kv small { color: var(--muted); }
.d-danger { margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line); }
.d-note { display: flex; gap: 8px; background: var(--bg2); border-radius: 10px; padding: 9px 11px; color: var(--muted); font-size: .88em; margin-bottom: 12px; } .d-note .ico { width: 17px; height: 17px; margin-top: 2px; }
.m-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; } .m-grid .thumb { aspect-ratio: 1; border-radius: 6px; }
.f-item, .l-item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; } .f-item > div, .l-item > div { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; } .f-item b, .l-item b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; } .f-item small, .l-item small { color: var(--muted); }
.l-item { color: var(--link); } .l-item .ico { color: var(--muted); }

/* ---- 聯絡人、設定 ---- */
.profile, .settings { flex: 1; overflow-y: auto; background: var(--bg2); padding: 40px 24px; }
.pf-card { max-width: 440px; margin: 0 auto; background: var(--bg); border-radius: 20px; padding: 30px; text-align: center; box-shadow: 0 2px 10px rgba(0, 0, 0, .06); }
.pf-card h2 { margin: 12px 0 2px; } .pf-card h2 small { color: var(--muted); font-weight: 400; } .pf-card p { margin: 0; color: var(--muted); }
.pf-card .status { margin: 12px auto 0; background: var(--bg2); border-radius: 12px; padding: 6px 14px; display: inline-block; font-size: .92em; }
.pf-actions { margin: 20px 0; } .pf-fields { display: grid; gap: 12px; text-align: left; border-top: 1px solid var(--line); padding-top: 16px; }
.settings { padding-top: 28px; } .settings > h2 { max-width: 560px; margin: 0 auto 14px; } .set-card { max-width: 560px; margin: 0 auto 16px; background: var(--bg); border-radius: 16px; padding: 18px 20px; box-shadow: 0 2px 10px rgba(0, 0, 0, .05); }
.set-list .set-item { padding: 13px 16px; } .set-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--bg2); display: grid; place-items: center; color: var(--green); } .set-item > .ico { color: var(--muted); width: 16px; height: 16px; }
.pf-avatar { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; } .form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: .85em; color: var(--muted); }
.form-grid input { height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 0 11px; background: var(--bg); color: var(--text); outline: none; } .form-grid input:disabled { background: var(--bg2); color: var(--muted); }
.set-actions { margin-top: 16px; display: flex; gap: 8px; }
.row-switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; } .row-switch:last-child { border: none; } .row-switch > div { display: flex; flex-direction: column; } .row-switch small { color: var(--muted); }
.switch { position: relative; width: 44px; height: 26px; flex: none; } .switch input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; } .switch i { position: absolute; inset: 0; background: #b8c0cc; border-radius: 13px; transition: .15s; } .switch i::after { content: ''; position: absolute; width: 22px; height: 22px; background: #fff; border-radius: 50%; left: 2px; top: 2px; transition: .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); } .switch input:checked + i { background: var(--green); } .switch input:checked + i::after { transform: translateX(18px); }
.row-block { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.preview-box { background: var(--chat-bg); border-radius: 12px; padding: 14px; margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.kv { flex-direction: row; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); } .kv small { width: 92px; } .kv b { flex: 1; font-weight: 500; } .mono { font-family: ui-monospace, Menlo, monospace; font-size: .9em; word-break: break-all; }
.about { display: flex; align-items: center; gap: 14px; } .about > div:last-child { display: flex; flex-direction: column; } .about small { color: var(--muted); }

/* ---- 浮層 ---- */
.ctx { position: fixed; z-index: 100; min-width: 170px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 5px; }
.ctx button { display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none; padding: 8px 12px; border-radius: 8px; text-align: left; } .ctx button:hover { background: var(--bg3); } .ctx button.danger { color: var(--danger); } .ctx button:disabled { opacity: .4; } .ctx .ico { width: 17px; height: 17px; } .ctx hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }
.modal { position: fixed; inset: 0; background: rgba(10, 20, 35, .45); display: grid; place-items: center; z-index: 90; }
.dialog { width: 380px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px); overflow: auto; background: var(--bg); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); } .dialog.wide { width: 460px; } .dialog h3 { margin: 0 0 8px; font-size: 1.15em; }
.dlg-body { color: var(--muted); margin: 0 0 18px; } .dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.nc-list { max-height: 320px; overflow-y: auto; margin: 4px -6px; } .nc-row { display: flex; align-items: center; gap: 12px; padding: 7px 8px; border-radius: 10px; cursor: pointer; } .nc-row:hover { background: var(--bg2); } .nc-row > div { display: flex; flex-direction: column; line-height: 1.3; } .nc-row small { color: var(--muted); } .nc-row input { accent-color: var(--green); width: 17px; height: 17px; margin: 0; }
.nc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; } .chip-sm { background: var(--sel); color: var(--green-d); border-radius: 13px; padding: 2px 4px 2px 11px; font-size: .88em; } .chip-sm button { border: none; background: none; color: inherit; font-size: 1.1em; padding: 0 5px; }
.nc-title { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 0 11px; margin-top: 10px; background: var(--bg); outline: none; }
#toasts { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 200; pointer-events: none; }
.toast { background: rgba(31, 41, 51, .94); color: #fff; padding: 9px 16px; border-radius: 12px; font-size: .92em; box-shadow: var(--shadow); max-width: 80vw; animation: tin .2s; } .toast.err { background: #b4232a; } .toast.ok { background: #1c8a4a; } .toast.out { opacity: 0; transition: opacity .35s; }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }
#lightbox { position: fixed; inset: 0; background: rgba(8, 12, 18, .94); z-index: 150; display: flex; flex-direction: column; color: #fff; }
.lb-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; } .lb-top .icon-btn { color: #cfd8e3; } .lb-top .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; } .lb-info { display: flex; flex-direction: column; line-height: 1.3; } .lb-info small { color: #9aa7b8; }
.lb-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 70px; } .lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lb-video { width: min(640px, 80%); aspect-ratio: 16 / 9; background: #000; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; } .lb-video .ico { width: 60px; height: 60px; } .lb-video p { margin: 0; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: none; background: rgba(255, 255, 255, .14); color: #fff; display: grid; place-items: center; } .lb-nav:hover { background: rgba(255, 255, 255, .26); } .lb-nav:disabled { opacity: .25; } .lb-nav.prev { left: 14px; } .lb-nav.next { right: 14px; }
.lb-cap { text-align: center; padding: 10px 0 16px; color: #9aa7b8; font-size: .9em; }

/* ---- 窄視窗：清單跟對話二選一，資訊欄蓋在上面 ---- */
@media (max-width: 1100px) { .drawer { position: absolute; right: 0; top: 0; bottom: 0; z-index: 40; box-shadow: var(--shadow); } .shell { position: relative; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 56px minmax(0, 1fr); } .rail-btn { width: 40px; height: 40px; }
  .shell .main-pane { display: none; } .shell[data-show="main"] .list-pane { display: none; } .shell[data-show="main"] .main-pane { display: flex; grid-column: 2; }
  .back { display: inline-grid; } .col { max-width: 84%; } .profile .back, .settings .back { position: absolute; left: 10px; top: 10px; } .form-grid { grid-template-columns: 1fr; }
  .drawer { width: min(330px, 92vw); }
}

/* ---- 真的伺服器：語音訊息、加密提示、裝置與加密 ---- */
.bubble.locked { font-style: italic; color: var(--muted); }
.bubble.voice { display: flex; align-items: center; gap: 8px; padding: 6px 10px; } .bubble.voice audio { height: 34px; max-width: 220px; } .bubble.voice small { color: var(--muted); }
.meta .edited { font-size: .72em; color: var(--muted); }
video.lb-video { display: block; max-width: 86%; max-height: 80%; width: auto; aspect-ratio: auto; }
.bn .link { margin-left: auto; white-space: nowrap; }
.tag.ok { background: #dcf5e3; color: #17663a; } .tag.warn { background: #fff1d6; color: #8a5a00; } .tag.err { background: #fde2e2; color: #9b1c1c; }
.btn.sm { height: 28px; padding: 0 11px; font-size: .88em; border-radius: 7px; }
.dev-help { margin: 10px 0 14px; line-height: 1.55; }
.dev-list { display: flex; flex-direction: column; gap: 8px; }
.dev { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; flex-wrap: wrap; }
.dev > div:first-child { flex: 1; min-width: 160px; display: flex; flex-direction: column; } .dev b em { font-style: normal; font-size: .75em; background: var(--bg3); border-radius: 5px; padding: 0 5px; margin-left: 4px; }
.dev small { color: var(--muted); }
.dev-btns { display: flex; gap: 6px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tag.ok { background: #1f4a30; color: #b6efc9; } :root:not([data-theme="light"]) .tag.warn { background: #4a3a14; color: #f3d9a0; } :root:not([data-theme="light"]) .tag.err { background: #5a2323; color: #f7c3c3; } }
:root[data-theme="dark"] .tag.ok { background: #1f4a30; color: #b6efc9; } :root[data-theme="dark"] .tag.warn { background: #4a3a14; color: #f3d9a0; } :root[data-theme="dark"] .tag.err { background: #5a2323; color: #f7c3c3; }
.d-members .mem .icon-btn { margin-left: auto; width: 28px; height: 28px; opacity: .6; } .d-members .mem:hover .icon-btn { opacity: 1; }

/* ---- 貼圖 ---- */
.sticker { display: flex; flex-direction: column; gap: 4px; align-items: inherit; }
.sticker img { width: 128px; height: 128px; object-fit: contain; display: block; }
.row.mine .sticker { align-items: flex-end; } .row.other .sticker { align-items: flex-start; }
.row.sending .sticker img { opacity: .55; }
.sticker-quote { font-size: .85em; padding: 4px 9px; }
.sticker-panel { width: 340px; }
.stabs { display: flex; gap: 4px; margin-bottom: 6px; overflow-x: auto; padding-bottom: 2px; }
.stabs button { flex: none; width: 38px; height: 38px; border: 1px solid transparent; background: none; border-radius: 9px; padding: 3px; display: grid; place-items: center; color: var(--muted); font-size: 20px; }
.stabs button.on { background: var(--sel); border-color: var(--green); }
.stabs button img { width: 100%; height: 100%; object-fit: contain; }
.stabs button.store { border: 1px dashed var(--line); }
.sgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; max-height: 232px; overflow-y: auto; }
.sgrid button { border: none; background: none; border-radius: 10px; padding: 4px; aspect-ratio: 1; } .sgrid button:hover { background: var(--bg3); }
.sgrid img { width: 100%; height: 100%; object-fit: contain; display: block; }
.st-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; } .chip { border: 1px solid var(--line); background: none; border-radius: 14px; padding: 2px 11px; color: var(--muted); } .chip.on { background: var(--sel); color: var(--green); border-color: var(--green); }
.st-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.st-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.st-cover { width: 56px; height: 56px; flex: none; border-radius: 10px; background: var(--bg2); display: grid; place-items: center; overflow: hidden; } .st-cover img { width: 100%; height: 100%; object-fit: contain; }
.st-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; } .st-meta small { color: var(--muted); }
.st-done { color: var(--muted); font-size: .9em; }
