:root {
  --bg: #0b141a; --panel: #111b21; --panel2: #202c33; --line: #222d34; --text: #e9edef; --muted: #8696a0;
  --accent: #00a884; --out: #005c4b; --danger: #f15c6d; --warn: #d29922; --wall: #0b141a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* shared controls */
button:not(.icon):not(.send):not(.chat-item):not(.rail-btn) { padding: 8px 16px; background: var(--accent); color: #04140a; border: 0; border-radius: 8px; font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent !important; color: var(--text) !important; border: 1px solid var(--line) !important; }
button.danger { background: transparent !important; color: var(--danger) !important; border: 1px solid var(--danger) !important; }
button.icon { width: 36px; height: 36px; padding: 0; background: transparent; border: 0; border-radius: 50%; color: var(--muted); font-size: 18px; line-height: 1; }
button.icon:hover { background: var(--panel2); color: var(--text); }
label { display: block; margin-bottom: 14px; color: var(--muted); }
label input:not([type="checkbox"]), label textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; background: var(--panel2); border: 1px solid transparent; border-radius: 8px; }
textarea { resize: vertical; }
label.check { display: flex; align-items: center; gap: 8px; }
.hint, .msg, .counter { color: var(--muted); font-size: 13px; }
.counter { display: block; text-align: right; margin-top: 2px; }
.msg.error { color: var(--danger); } .msg.ok { color: var(--accent); }
.warn { color: var(--warn); border-left: 3px solid var(--warn); padding-left: 10px; }
.row { display: flex; gap: 10px; }
.spacer { flex: 1; }

/* login */
#view-login { min-height: 100%; display: grid; place-items: center; padding: 16px; background: linear-gradient(#00a884 0 130px, var(--bg) 130px); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 12px; padding: 28px; box-shadow: 0 8px 30px #0008; }
.login-card h1 { margin: 8px 0 0; font-size: 22px; text-align: center; }
.login-card .hint { text-align: center; margin: 4px 0 18px; }
.login-card button[type="submit"] { width: 100%; padding: 11px; }
.logo { width: 52px; height: 52px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #04140a; font-weight: 800; font-size: 24px; }
.logo.big { width: 88px; height: 88px; font-size: 40px; }

/* app shell */
.app { display: grid; grid-template-columns: 72px minmax(280px, 380px) 1fr; height: 100dvh; width: 100%; background: var(--panel); }
.bar { display: flex; align-items: center; gap: 8px; height: 60px; padding: 0 12px; background: var(--panel2); flex: none; }
.bar h2 { margin: 0; font-size: 16px; }
.avatar { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: #6a7175; color: #fff; font-weight: 700; }
.avatar.me { background: var(--accent); color: #04140a; }
.badge { padding: 2px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.badge.on { background: #0b3d2e; color: #25d366; }
.badge.off { background: #44202a; color: var(--danger); }

/* sidebar */
.sidebar { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--panel); }
.search { padding: 8px 12px; } .search input { width: 100%; padding: 8px 12px; background: var(--panel2); border: 0; border-radius: 8px; }
.newchat { display: flex; gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.newchat input { flex: 1; min-width: 0; padding: 8px 12px; background: var(--panel2); border: 0; border-radius: 8px; }
.chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.chat-item { display: flex; width: 100%; gap: 12px; align-items: center; padding: 10px 14px; background: transparent; border: 0; border-bottom: 1px solid var(--line); color: inherit; text-align: left; }
.chat-item:hover { background: #1a252c; } .chat-item.active { background: var(--panel2); }
.chat-item .mid { flex: 1; min-width: 0; }
.chat-item .top { display: flex; justify-content: space-between; gap: 8px; }
.chat-item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .time { color: var(--muted); font-size: 12px; flex: none; }
.chat-item .last { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-note { color: var(--muted); text-align: center; padding: 24px; }

/* main */
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--wall); }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.welcome { align-items: center; justify-content: center; text-align: center; gap: 4px; padding: 24px; }
.welcome h2 { margin: 12px 0 0; font-weight: 400; font-size: 28px; }
.who { min-width: 0; margin-left: 4px; } .who .name { font-weight: 600; } .who .sub { color: var(--muted); font-size: 12px; }
.back { display: none; }
.messages { flex: 1; overflow-y: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 4px;
  background-color: var(--wall); background-image: radial-gradient(#ffffff08 1px, transparent 1px); background-size: 18px 18px; }
.day { align-self: center; margin: 10px 0 4px; padding: 3px 12px; background: var(--panel2); color: var(--muted); font-size: 12px; border-radius: 8px; }
.bubble { align-self: flex-end; max-width: min(75%, 560px); padding: 6px 9px 4px; background: var(--out); border-radius: 8px 0 8px 8px; box-shadow: 0 1px 1px #0006; }
.bubble .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .meta { display: flex; justify-content: flex-end; gap: 4px; color: #ffffff99; font-size: 11px; margin-top: 1px; }
.bubble.fail { background: #5a2530; } .bubble.fail .meta { color: #ffb3bd; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; background: var(--panel2); }
.composer textarea { flex: 1; max-height: 140px; padding: 10px 14px; background: #2a3942; border: 0; border-radius: 22px; resize: none; }
.send { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: var(--accent); color: #04140a; font-size: 18px; }
#send-result { margin: 0; padding: 0 14px 6px; background: var(--panel2); min-height: 0; }
#send-result:empty { display: none; }

/* pages (status / blast) */
.page-body { flex: 1; overflow-y: auto; padding: 20px; max-width: 640px; width: 100%; }
#qr-img { background: #fff; padding: 8px; border-radius: 8px; display: block; margin-bottom: 12px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
progress { width: 100%; margin-top: 14px; }
#blast-log { list-style: none; padding: 0; margin: 10px 0 0; max-height: 240px; overflow: auto; font-size: 13px; font-family: ui-monospace, monospace; }
#blast-log li.err { color: var(--danger); }

/* mobile: one pane at a time */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .app:not(.show-main) .main { display: none; }
  .app.show-main .sidebar { display: none; }
  .back { display: grid; }
  .messages { padding: 12px 10px; }
  .bubble { max-width: 88%; }
}
.bubble.in { align-self: flex-start; background: var(--panel2); border-radius: 0 8px 8px 8px; }
.bubble.in .meta { color: var(--muted); }
.account-row { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--panel); }
.account-row label { margin: 0; font-size: 12px; white-space: nowrap; }
select { flex: 1; min-width: 0; padding: 7px 10px; background: var(--panel2); color: var(--text); border: 0; border-radius: 8px; font: inherit; }
.acct-card { background: var(--panel2); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.acct-card .head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acct-card .head strong { font-size: 15px; }
.acct-card .num { color: var(--muted); font-size: 13px; }
.acct-card .actions { display: flex; gap: 8px; margin-top: 10px; }
.acct-card .actions button { padding: 5px 12px !important; font-size: 13px; }
.acct-card img { background: #fff; padding: 8px; border-radius: 8px; display: block; margin-top: 10px; }
.newchat.add { padding: 0; background: transparent; border: 0; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.row > label { flex: 1; }
#blast-quota.low { color: var(--warn); }
.me-name { color: var(--muted); font-size: 12px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h3 { margin: 4px 0 12px; font-size: 15px; }
.acct-card .num.owner { font-style: italic; }
.acct-card.disabled { opacity: .6; }
button.icon i { font-size: 16px; }
.send i { font-size: 17px; margin-left: -2px; }
.page-body.wide { max-width: 900px; }
.doc-section { margin-bottom: 30px; }
.doc-section h3 { padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.doc-section p, .doc-section li { color: var(--text); }
.doc-section ul { padding-left: 20px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
h4.endpoint { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; font-size: 15px; }
.method { padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; color: #04140a; }
.method.post { background: #25d366; } .method.get { background: #53bdeb; }
.doc-table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: 13px; }
.doc-table th { text-align: left; color: var(--muted); font-weight: 600; }
.doc-table th, .doc-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.codeblock { position: relative; margin: 8px 0 12px; }
.codeblock pre { margin: 0; padding: 14px; background: #0b141a; border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; }
.codeblock .copy { position: absolute; top: 6px; right: 6px; padding: 3px 10px !important; font-size: 12px; }
.doc-tabbar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.doc-tabbar .tab { padding: 4px 12px !important; font-size: 13px; }
.doc-tabbar .tab.active { background: var(--panel2) !important; border-color: var(--accent) !important; }
.key-new { background: var(--panel2); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.key-new input { flex: 1; font-family: ui-monospace, monospace; padding: 9px 12px; background: var(--bg); border: 0; border-radius: 8px; }

/* left icon rail */
.rail { display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: 10px 0; background: var(--panel2); border-right: 1px solid var(--line); min-height: 0; }
.rail-top, .rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.rail-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 58px; padding: 8px 0; background: transparent; border: 0; border-radius: 10px; color: var(--muted); font-size: 10px; }
.rail-btn i { font-size: 19px; }
.rail-btn:hover { background: #2a3942; color: var(--text); }
.rail-btn.active { background: #2a3942; color: var(--accent); }
.rail .avatar { width: 34px; height: 34px; font-size: 15px; margin-bottom: 2px; }
.rail .me-name { max-width: 64px; margin-bottom: 4px; text-align: center; }
.sidebar .bar h2 { font-size: 18px; }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .app > .rail { grid-row: 2; flex-direction: row; justify-content: space-around; padding: 4px 6px; border-right: 0; border-top: 1px solid var(--line); }
  .app > .sidebar, .app > .main { grid-row: 1; }
  .rail-top { flex-direction: row; justify-content: space-around; }
  .rail-bottom { flex-direction: row; width: auto; }
  .rail-bottom .avatar, .rail-bottom .me-name { display: none; }
  .rail-btn { width: 52px; }
  .app.show-main > .rail { display: none; }
}

/* queue */
.rail-btn { position: relative; }
.rail-badge { position: absolute; top: 2px; right: 6px; min-width: 16px; padding: 0 4px; border-radius: 999px; background: var(--accent); color: #04140a; font-size: 10px; line-height: 16px; text-align: center; }
.queue-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin: 6px 0 10px; }
.queue-filters select { flex: none; }
.queue-actions { margin-bottom: 8px; }
.queue-actions button { padding: 6px 12px !important; font-size: 13px; }
.qinfo { background: var(--panel2); border-left: 3px solid var(--warn); border-radius: 6px; padding: 8px 12px; margin-bottom: 8px; font-size: 13px; }
.qbatch { background: var(--panel2); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.qbatch .head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.qbatch progress { margin-top: 8px; }
.qbatch .stop { color: var(--danger); font-size: 13px; margin: 6px 0 0; }
.queue-list { list-style: none; padding: 0; margin: 0; }
.queue-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.queue-list .who { font-weight: 600; }
.queue-list .who small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.queue-list .txt { grid-column: 2; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.queue-list .err { grid-column: 2; color: var(--danger); font-size: 12px; }
.queue-list .acts { grid-column: 3; grid-row: 1 / span 2; display: flex; gap: 6px; }
.queue-list .acts button { padding: 4px 10px !important; font-size: 12px; }
.qs { display: inline-block; min-width: 82px; text-align: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.qs.pending { background: #3a3320; color: #e3b341; }
.qs.processing { background: #12344a; color: #53bdeb; }
.qs.sent { background: #0b3d2e; color: #25d366; }
.qs.failed { background: #44202a; color: var(--danger); }
.qs.cancelled { background: #2a3942; color: var(--muted); }
@media (max-width: 760px) { .queue-list li { grid-template-columns: 1fr; } .queue-list .txt, .queue-list .err, .queue-list .acts { grid-column: 1; grid-row: auto; } }
.method.delete { background: #f15c6d; }

/* Login SSO UNWIM */
.login-or { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; color: var(--muted, #8a94a6); font-size: 12px; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: .3; }
.btn-sso { display: block; width: 100%; box-sizing: border-box; padding: 11px; text-align: center; text-decoration: none; border-radius: 8px; border: 1px solid currentColor; color: inherit; font-weight: 600; }
.btn-sso:hover, .btn-sso:focus-visible { background: #ffffff14; }

.lang-btn { font-weight: 700; font-size: 12px; letter-spacing: .5px; }
.login-card { position: relative; }
.login-lang { position: absolute; top: 12px; right: 12px; background: transparent; border: 1px solid #8a94a655; color: var(--muted, #8a94a6); border-radius: 6px; padding: 4px 8px; cursor: pointer; }
