:root {
  --green: #00a884; --green-dark: #008069; --green-light: #25d366; --teal-header: #008069;
  --bg: #fff; --panel: #fff; --panel-2: #f0f2f5; --hover: #f5f6f6; --active: #f0f2f5; --border: #e9edef;
  --text: #111b21; --text-2: #667781; --text-3: #8696a0;
  --chat-bg: #efeae2; --bubble-in: #ffffff; --bubble-out: #d9fdd3; --tick-blue: #53bdeb;
  --danger: #ea0038; --warn: #f7b500; --shadow: 0 1px 0.5px rgba(11,20,26,.13);
  --modal-bg: #fff; --input-bg: #fff; --chip: #f0f2f5; --chip-active: #e7fce3; --chip-active-text: #008069;
  --doodle: rgba(0,0,0,.035);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #111b21; --panel: #111b21; --panel-2: #202c33; --hover: #202c33; --active: #2a3942; --border: #222d34;
  --text: #e9edef; --text-2: #8696a0; --text-3: #667781;
  --chat-bg: #0b141a; --bubble-in: #202c33; --bubble-out: #005c4b; --tick-blue: #53bdeb;
  --modal-bg: #202c33; --input-bg: #2a3942; --chip: #202c33; --chip-active: #0a332c; --chip-active-text: #00a884;
  --doodle: rgba(255,255,255,.025); --shadow: 0 1px 0.5px rgba(0,0,0,.4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14.2px/1.4 "Segoe UI", "Helvetica Neue", Helvetica, "Noto Sans Gujarati", "Noto Sans Devanagari", Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: #027eb5; }
svg.i { width: 24px; height: 24px; fill: currentColor; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Login ---------- */
#login { position: fixed; inset: 0; display: grid; place-items: center; background: linear-gradient(var(--teal-header) 0 220px, var(--panel-2) 220px); }
:root[data-theme="dark"] #login { background: linear-gradient(#0a332c 0 220px, var(--bg) 220px); }
.login-card { width: min(420px, 92vw); background: var(--modal-bg); border-radius: 10px; padding: 32px 28px; box-shadow: 0 17px 50px rgba(11,20,26,.19); }
.login-card h1 { margin: 12px 0 4px; font-size: 22px; font-weight: 500; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 44px; height: 44px; }

/* ---------- Layout ---------- */
#app { display: flex; height: 100dvh; overflow: hidden; }
#rail { width: 64px; background: var(--panel-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 4px; }
.rail-btn { position: relative; width: 44px; height: 44px; border-radius: 50%; border: 0; background: none; color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.rail-btn:hover { background: var(--active); }
.rail-btn.active { background: var(--active); color: var(--text); }
.rail-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--green-light); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; }
.rail-spacer { flex: 1; }
.rail-btn[data-tip]:hover::after { content: attr(data-tip); position: absolute; left: 52px; top: 10px; white-space: nowrap; background: #111b21; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 4px; z-index: 50; }

#side { width: 400px; min-width: 300px; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--panel); }
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--panel-2); position: relative; }
#drawer { width: 380px; border-left: 1px solid var(--border); background: var(--panel-2); display: flex; flex-direction: column; overflow: hidden; }

.side-head { height: 60px; padding: 0 16px; display: flex; align-items: center; gap: 6px; }
.side-head h2 { margin: 0; font-size: 22px; font-weight: 700; flex: 1; color: var(--text); }
.icon-btn { width: 40px; height: 40px; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--active); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.search { margin: 0 12px 8px; display: flex; align-items: center; gap: 8px; background: var(--panel-2); border-radius: 8px; padding: 0 12px; height: 36px; }
.search input { border: 0; outline: 0; background: none; flex: 1; min-width: 0; }
.search svg { width: 20px; height: 20px; color: var(--text-2); }
.chips { display: flex; gap: 8px; padding: 2px 12px 8px; overflow-x: auto; scrollbar-width: none; }
.chip { border: 0; background: var(--chip); color: var(--text-2); border-radius: 16px; padding: 6px 12px; white-space: nowrap; cursor: pointer; font-size: 14px; }
.chip.active { background: var(--chip-active); color: var(--chip-active-text); }

.chat-list { flex: 1; overflow-y: auto; }
.chat-item { display: flex; align-items: center; gap: 12px; padding: 0 0 0 12px; cursor: pointer; height: 72px; }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.chat-item .body { flex: 1; min-width: 0; border-bottom: 1px solid var(--border); height: 100%; display: flex; flex-direction: column; justify-content: center; padding-right: 14px; }
.chat-item .top, .chat-item .bot { display: flex; align-items: center; gap: 6px; }
.chat-item .name { flex: 1; font-size: 17px; color: var(--text); }
.chat-item .time { font-size: 12px; color: var(--text-2); }
.chat-item.unread .time { color: var(--green-light); font-weight: 500; }
.chat-item .preview { flex: 1; color: var(--text-2); font-size: 14px; display: flex; align-items: center; gap: 3px; min-width: 0; }
.chat-item .preview svg { width: 16px; height: 16px; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--green-light); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; }
:root[data-theme="dark"] .badge { color: #111b21; }
.lbl-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.avatar { width: 49px; height: 49px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 18px; flex: none; user-select: none; }
.avatar.sm { width: 40px; height: 40px; font-size: 15px; }
.avatar.xl { width: 120px; height: 120px; font-size: 40px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--chip); color: var(--text-2); }
.tag.hot { background: #ffe9e0; color: #c8410b; }
:root[data-theme="dark"] .tag.hot { background: #4a2414; color: #ffb08a; }
.tag.ok { background: #d9fdd3; color: #0a6b4e; }
:root[data-theme="dark"] .tag.ok { background: #0a332c; color: #00d6a3; }
.tag.warn { background: #fff4d6; color: #8a6100; }
:root[data-theme="dark"] .tag.warn { background: #3d3216; color: #f7c948; }
.tag.bad { background: #ffe0e5; color: #b0002a; }
:root[data-theme="dark"] .tag.bad { background: #4a1420; color: #ff8fa3; }

/* ---------- Empty state ---------- */
.empty-main { flex: 1; display: grid; place-items: center; text-align: center; border-bottom: 6px solid var(--green); padding: 24px; }
.empty-main h1 { font-weight: 300; font-size: 32px; margin: 20px 0 10px; }
.empty-main p { color: var(--text-2); max-width: 480px; margin: 0 auto; }

/* ---------- Chat ---------- */
.chat-head { height: 60px; background: var(--panel-2); display: flex; align-items: center; gap: 12px; padding: 0 12px 0 16px; border-left: 1px solid var(--border); cursor: default; flex: none; }
.chat-head .who { flex: 1; min-width: 0; cursor: pointer; }
.chat-head .who .n { font-size: 16px; }
.chat-head .who .s { font-size: 13px; color: var(--text-2); }
.win { font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.win.open { background: var(--chip-active); color: var(--chip-active-text); }
.win.closed { background: #ffe0e5; color: #b0002a; }
:root[data-theme="dark"] .win.closed { background: #4a1420; color: #ff8fa3; }
.messages { flex: 1; overflow-y: auto; padding: 12px 7% 8px; background-color: var(--chat-bg); position: relative;
  background-image: radial-gradient(var(--doodle) 1.4px, transparent 1.6px), radial-gradient(var(--doodle) 1.4px, transparent 1.6px);
  background-size: 28px 28px; background-position: 0 0, 14px 14px; }
.day-sep { text-align: center; margin: 10px 0; }
.day-sep span { background: var(--panel); color: var(--text-2); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; box-shadow: var(--shadow); text-transform: uppercase; }
:root[data-theme="dark"] .day-sep span { background: #182229; }
.msg { display: flex; margin: 2px 0; position: relative; }
.msg.out { justify-content: flex-end; }
.msg.first { margin-top: 10px; }
.bubble { max-width: min(65%, 560px); padding: 6px 7px 8px 9px; border-radius: 7.5px; background: var(--bubble-in); box-shadow: var(--shadow); position: relative; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.out .bubble { background: var(--bubble-out); }
.msg.first.in .bubble { border-top-left-radius: 0; }
.msg.first.out .bubble { border-top-right-radius: 0; }
.msg.first.in .bubble::before, .msg.first.out .bubble::before { content: ""; position: absolute; top: 0; width: 8px; height: 13px; }
.msg.first.in .bubble::before { left: -8px; background: linear-gradient(to bottom left, var(--bubble-in) 50%, transparent 50%); }
.msg.first.out .bubble::before { right: -8px; background: linear-gradient(to bottom right, var(--bubble-out) 50%, transparent 50%); }
.bubble .text { white-space: pre-wrap; }
.bubble .meta { float: right; margin: 6px 0 -4px 10px; font-size: 11px; color: var(--text-2); display: inline-flex; align-items: center; gap: 3px; position: relative; top: 4px; }
.bubble .meta svg { width: 16px; height: 16px; }
.tick-read { color: var(--tick-blue); }
.tick-failed { color: var(--danger); }
.bubble .sender { font-size: 12.5px; font-weight: 500; color: var(--green-dark); margin-bottom: 2px; }
:root[data-theme="dark"] .bubble .sender { color: #06cf9c; }
.bubble .auto { font-size: 11px; color: var(--text-2); }
.bubble img.media, .bubble video.media { display: block; max-width: 330px; width: 100%; max-height: 360px; object-fit: cover; border-radius: 6px; margin: -3px -4px 4px -6px; width: calc(100% + 10px); cursor: pointer; background: rgba(0,0,0,.05); min-height: 80px; }
.bubble audio { width: 260px; max-width: 100%; display: block; }
.doc-card { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.05); border-radius: 6px; padding: 10px; margin: -2px -3px 4px -5px; text-decoration: none; color: inherit; min-width: 220px; }
:root[data-theme="dark"] .doc-card { background: rgba(0,0,0,.2); }
.doc-card .ic { width: 34px; height: 40px; border-radius: 4px; background: #e2574c; color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 700; }
.quote { border-left: 4px solid #06cf9c; background: rgba(0,0,0,.05); border-radius: 6px; padding: 5px 8px; margin: -2px -3px 5px -5px; font-size: 13px; color: var(--text-2); max-height: 64px; overflow: hidden; cursor: pointer; }
.quote b { color: var(--green-dark); display: block; font-weight: 500; font-size: 12.5px; }
.msg.in .quote { border-left-color: #a5b337; }
.ia-buttons { border-top: 1px solid rgba(0,0,0,.08); margin: 6px -7px -8px -9px; display: flex; flex-direction: column; }
.ia-buttons div { text-align: center; color: #027eb5; padding: 9px; border-top: 1px solid rgba(0,0,0,.06); font-size: 14px; }
:root[data-theme="dark"] .ia-buttons div { color: #53bdeb; border-color: rgba(255,255,255,.06); }
.reaction { position: absolute; bottom: -14px; background: var(--panel); border-radius: 12px; padding: 0 5px; font-size: 14px; box-shadow: var(--shadow); line-height: 22px; }
.msg.in .reaction { left: 8px; } .msg.out .reaction { right: 8px; }
.msg.has-reaction { margin-bottom: 16px; }
.msg-menu-btn { position: absolute; top: 2px; right: 2px; width: 26px; height: 22px; border: 0; border-radius: 50%; background: inherit; color: var(--text-2); display: none; cursor: pointer; padding: 0; }
.bubble:hover .msg-menu-btn { display: grid; place-items: center; }
.err-line { color: var(--danger); font-size: 12px; margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.err-line button { border: 0; background: none; color: #027eb5; cursor: pointer; padding: 0; font-size: 12px; }
.flash .bubble { animation: flash 1.2s; }
@keyframes flash { 0%, 60% { filter: brightness(.85); } }

.composer { background: var(--panel-2); padding: 5px 10px; display: flex; align-items: flex-end; gap: 4px; flex: none; position: relative; }
.composer .box { flex: 1; background: var(--input-bg); border-radius: 8px; padding: 9px 12px; display: flex; }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: none; max-height: 140px; min-height: 22px; line-height: 22px; padding: 0; }
.composer .send { color: var(--text-2); }
.composer .send.ready { color: var(--green); }
.reply-bar { background: var(--panel-2); padding: 8px 12px 0; display: flex; gap: 8px; align-items: center; }
.reply-bar .quote { flex: 1; margin: 0; background: var(--input-bg); }
.closed-bar { background: var(--panel-2); padding: 12px 16px; display: flex; align-items: center; gap: 12px; flex: none; }
.closed-bar .t { flex: 1; color: var(--text-2); font-size: 13.5px; }
.popup { position: absolute; bottom: 60px; left: 10px; background: var(--modal-bg); border-radius: 8px; box-shadow: 0 2px 5px rgba(11,20,26,.26), 0 2px 10px rgba(11,20,26,.16); z-index: 30; padding: 8px 0; min-width: 220px; max-height: 60vh; overflow-y: auto; }
.popup .item { display: flex; gap: 12px; align-items: center; padding: 9px 18px; cursor: pointer; }
.popup .item:hover, .popup .item.sel { background: var(--hover); }
.popup .item .ic { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.popup .item .ic svg { width: 20px; height: 20px; }
.emoji-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; padding: 6px; width: 340px; max-width: 92vw; }
.emoji-grid button { border: 0; background: none; font-size: 22px; padding: 4px; border-radius: 6px; cursor: pointer; }
.emoji-grid button:hover { background: var(--hover); }
.qr-pop .item { flex-direction: column; align-items: flex-start; gap: 0; }

/* ---------- Drawer (contact info) ---------- */
.drawer-head { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--panel-2); flex: none; }
.drawer-body { flex: 1; overflow-y: auto; }
.card { background: var(--panel); padding: 14px 20px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(11,20,26,.08); }
.card h4 { margin: 0 0 10px; font-weight: 400; color: var(--text-2); font-size: 14px; }
.card .center { text-align: center; }
.kv { display: flex; gap: 10px; align-items: center; padding: 6px 0; }
.kv label { width: 90px; color: var(--text-2); font-size: 13px; flex: none; }
.kv input, .kv select { flex: 1; min-width: 0; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.media-grid img, .media-grid .doc { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; background: var(--panel-2); display: grid; place-items: center; font-size: 11px; text-align: center; overflow: hidden; cursor: pointer; }
.note { border-left: 3px solid var(--warn); background: var(--panel-2); padding: 6px 10px; border-radius: 4px; margin: 6px 0; font-size: 13.5px; white-space: pre-wrap; }
.note .m { font-size: 11.5px; color: var(--text-2); margin-top: 3px; display: flex; justify-content: space-between; }

/* ---------- Forms ---------- */
input[type=text], input[type=password], input[type=tel], input[type=email], input[type=number], input[type=url], input[type=datetime-local], input[type=time], select, textarea.f {
  background: var(--input-bg); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; outline: 0; width: 100%;
}
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea.f { border-color: #374248; }
input:focus, select:focus, textarea.f:focus { border-color: var(--green); }
textarea.f { resize: vertical; min-height: 80px; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.btn { border: 0; border-radius: 22px; padding: 9px 20px; background: var(--green); color: #fff; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
:root[data-theme="dark"] .btn { color: #111b21; }
.btn:hover { background: var(--green-dark); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: none; color: var(--green-dark); border: 1px solid var(--border); }
:root[data-theme="dark"] .btn.ghost { color: var(--green); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn svg { width: 18px; height: 18px; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #c5cbcf; border-radius: 11px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(16px); }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.toggle-row .grow div:first-child { font-size: 15px; }

/* ---------- Pages ---------- */
.page { flex: 1; overflow-y: auto; background: var(--panel-2); }
.page-head { height: 60px; display: flex; align-items: center; gap: 8px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.page-head h2 { flex: 1; margin: 0; font-size: 20px; font-weight: 600; }
.page-body { padding: 16px; max-width: 1100px; margin: 0 auto; }
.panel { background: var(--panel); border-radius: 10px; padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(11,20,26,.06); }
.panel h3 { margin: 0 0 12px; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--panel); border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 3px rgba(11,20,26,.06); }
.stat .v { font-size: 26px; font-weight: 600; }
.stat .l { color: var(--text-2); font-size: 13px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-weight: 500; color: var(--text-2); padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--hover); }
.table-wrap { overflow-x: auto; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.bar { height: 8px; border-radius: 4px; background: var(--panel-2); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; min-width: 4px; position: relative; }
.chart .col i { display: block; border-radius: 2px 2px 0 0; }
.chart .col:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #111b21; color: #fff; font-size: 11px; padding: 3px 6px; border-radius: 4px; white-space: nowrap; z-index: 4; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.tpl-preview { background: var(--chat-bg); border-radius: 10px; padding: 16px; }
.tpl-preview .bubble { max-width: 100%; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.menu-card { background: var(--panel); border-radius: 10px; padding: 16px; display: flex; gap: 14px; align-items: center; cursor: pointer; border: 0; text-align: left; box-shadow: 0 1px 3px rgba(11,20,26,.06); }
.menu-card:hover { background: var(--hover); }
.menu-card .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; flex: none; }
.menu-card b { display: block; font-weight: 500; font-size: 15px; }
.menu-card span { font-size: 12.5px; color: var(--text-2); }

/* ---------- Modal / toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(11,20,26,.55); display: grid; place-items: center; z-index: 100; padding: 16px; }
:root[data-theme="dark"] .modal-wrap { background: rgba(0,0,0,.7); }
.modal { background: var(--modal-bg); border-radius: 12px; width: min(560px, 100%); max-height: 92dvh; display: flex; flex-direction: column; box-shadow: 0 17px 50px rgba(11,20,26,.3); }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px 22px; }
.modal-head h3 { margin: 0; flex: 1; font-size: 18px; font-weight: 500; }
.modal-body { padding: 4px 22px 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 22px 18px; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #111b21; color: #fff; padding: 11px 18px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.3); max-width: 92vw; pointer-events: auto; cursor: pointer; font-size: 14px; }
:root[data-theme="dark"] .toast { background: #e9edef; color: #111b21; }
.toast.err { background: #b0002a; color: #fff; }
.lightbox { position: fixed; inset: 0; background: rgba(11,20,26,.94); z-index: 150; display: grid; place-items: center; }
.lightbox img, .lightbox video { max-width: 94vw; max-height: 86vh; }
.lightbox .icon-btn { position: absolute; top: 14px; color: #fff; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { background: #fff4d6; color: #5c4400; padding: 10px 16px; font-size: 13.5px; display: flex; gap: 10px; align-items: center; }
:root[data-theme="dark"] .banner { background: #3d3216; color: #f7c948; }
.drop-zone { border: 2px dashed var(--border); border-radius: 10px; padding: 24px; text-align: center; color: var(--text-2); cursor: pointer; }
.drop-zone:hover { border-color: var(--green); }
.steps { display: flex; gap: 6px; margin-bottom: 16px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.steps span.on { background: var(--green); }

/* ---------- Mobile ---------- */
#tabs { display: none; }
@media (max-width: 900px) {
  #rail { display: none; }
  #drawer { position: fixed; inset: 0; width: 100%; z-index: 40; }
  #side { width: 100%; min-width: 0; border: 0; }
  #main { position: fixed; inset: 0; z-index: 20; }
  #app.show-main #side { display: none; }
  #app:not(.show-main) #main { display: none; }
  #app.show-main #tabs { display: none; }
  #tabs { display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 64px; background: var(--panel); border-top: 1px solid var(--border); z-index: 25; padding-bottom: env(safe-area-inset-bottom); }
  #tabs button { flex: 1; border: 0; background: none; color: var(--text-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; position: relative; }
  #tabs button.active { color: var(--text); font-weight: 600; }
  #tabs button.active svg { background: var(--chip-active); color: var(--chip-active-text); border-radius: 14px; padding: 3px 18px; width: 60px; height: 30px; }
  #tabs button svg { padding: 3px 18px; width: 60px; height: 30px; }
  #tabs .dot { position: absolute; top: 4px; left: calc(50% + 8px); background: var(--green-light); color: #fff; border-radius: 9px; font-size: 11px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; }
  .chat-list { padding-bottom: 70px; }
  #side .side-head { background: var(--panel); }
  #side .side-head h2 { color: var(--green-dark); font-size: 22px; }
  :root[data-theme="dark"] #side .side-head h2 { color: var(--text); }
  .messages { padding: 10px 12px 8px; }
  .bubble { max-width: 85%; }
  .chat-head { padding-left: 4px; gap: 6px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .page-body { padding: 12px 10px 90px; }
  .page-head { padding: 0 6px; }
  .modal-wrap { padding: 0; align-items: end; }
  .modal { width: 100%; max-height: 94dvh; border-radius: 16px 16px 0 0; }
  .emoji-grid { grid-template-columns: repeat(8, 1fr); }
  .fab { display: grid !important; }
}
.fab { display: none; position: fixed; right: 16px; bottom: 80px; width: 56px; height: 56px; border-radius: 16px; background: var(--green-light); color: #fff; border: 0; place-items: center; box-shadow: 0 3px 8px rgba(0,0,0,.25); z-index: 26; cursor: pointer; }
:root[data-theme="dark"] .fab { background: #00a884; color: #111b21; }

.secret-input { -webkit-text-security: disc; font-family: monospace; }
