:root {
  --bg: #0f1420; --panel: #171e2e; --panel2: #1e2740; --border: #2a3550;
  --text: #e6ebf5; --muted: #8a94ab; --accent: #3d7eff; --in: #232d45; --out: #2f6fed;
  --ok: #34c98e; --warn: #e5a94e; --err: #ef5b6b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }
.hidden { display: none !important; }
button { cursor: pointer; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 16px; font-size: 14px; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.wide { width: 100%; }
.btn-link { color: var(--accent); text-decoration: none; font-size: 13px; padding: 4px 8px; }
.error { color: var(--err); font-size: 13px; margin-top: 8px; min-height: 18px; }
input, textarea { background: var(--panel2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 10px 12px; font-size: 14px; width: 100%; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

#login { height: 100%; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 32px; width: 320px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 22px; }
.login-card .sub { color: var(--muted); font-size: 13px; }

header { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border); }
header .brand { font-size: 17px; font-weight: 700; }
.device-bar { color: var(--muted); font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; align-items: center; gap: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.on { background: var(--ok); } .dot.off { background: var(--err); }

main { display: flex; height: calc(100% - 53px); }
aside { width: 320px; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.search { padding: 10px; }
.thread-list { flex: 1; overflow-y: auto; list-style: none; }
.thread-list li { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.thread-list li:hover { background: var(--panel2); }
.thread-list li.active { background: var(--panel2); border-left: 3px solid var(--accent); }
.thread-top { display: flex; justify-content: space-between; align-items: baseline; }
.thread-addr { font-weight: 600; }
.thread-time { color: var(--muted); font-size: 12px; }
.thread-preview { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 270px; }
.thread-unread { background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }

.thread-pane { flex: 1; display: flex; flex-direction: column; }
.thread-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
#threadTitle { font-size: 16px; font-weight: 600; }
#threadStatus { color: var(--muted); font-size: 12px; }
.message-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 72%; padding: 9px 12px; border-radius: 12px; word-break: break-word; white-space: pre-wrap; }
.msg.in { align-self: flex-start; background: var(--in); border-bottom-left-radius: 3px; }
.msg.out { align-self: flex-end; background: var(--out); border-bottom-right-radius: 3px; }
.msg-meta { font-size: 11px; color: rgba(255,255,255,.65); margin-top: 4px; text-align: right; }
.msg-meta .st { margin-left: 6px; }
.msg-meta .st.pending { color: var(--warn); }
.msg-meta .st.delivered { color: var(--ok); }
.msg-meta .st.failed { color: var(--err); }
.empty { color: var(--muted); text-align: center; padding: 40px; }
.composer { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); }
.composer textarea { flex: 1; resize: none; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: 400px; display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
