/* PIXIGHT Talk */
:root {
  --ink: #141826;
  --ink-2: #3b4258;
  --muted: #6b7289;
  --line: #e6e8f0;
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --accent: #4b3df5;
  --accent-ink: #ffffff;
  --accent-soft: #ecebff;
  --mint: #12b886;
  --mint-soft: #e3f8ef;
  --amber: #b7791f;
  --amber-soft: #fdf3e1;
  --red: #d63b4f;
  --red-soft: #fdebee;
  --bubble-theirs: #ffffff;
  --bubble-mine: #4b3df5;
  --shadow: 0 1px 2px rgba(20,24,38,.06), 0 8px 24px rgba(20,24,38,.06);
  --radius: 14px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef0f7;
    --ink-2: #c3c8d8;
    --muted: #8b92a9;
    --line: #262b3d;
    --bg: #0e111b;
    --surface: #161a28;
    --surface-2: #1b2031;
    --accent: #7a6dff;
    --accent-soft: #24214a;
    --mint: #36d6a0;
    --mint-soft: #133328;
    --amber: #e7b04b;
    --amber-soft: #352a14;
    --red: #ff6b7d;
    --red-soft: #3a1a21;
    --bubble-theirs: #20263a;
    --bubble-mine: #6252ff;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; color: inherit; font-size: 1.05rem; text-decoration: none !important; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: url(/assets/icon.svg) center/cover; flex: none; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700; border-radius: 10px; padding: 11px 18px; border: 1px solid transparent; cursor: pointer; text-decoration: none !important; transition: background .15s, border-color .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: .88rem; }
.btn-xs { padding: 4px 9px; font-size: .8rem; border-radius: 7px; }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.form { display: grid; gap: 14px; margin: 18px 0; }
.form label { display: grid; gap: 6px; align-content: start; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.form small { font-weight: 500; color: var(--muted); }
.opt { font-weight: 500; color: var(--muted); }
input, textarea, select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
.check { display: flex !important; grid-template-columns: none; align-items: flex-start; gap: 10px !important; font-weight: 500 !important; }
.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.code-input { font-family: ui-monospace, Menlo, monospace; font-size: 1.15rem; letter-spacing: .12em; text-transform: uppercase; text-align: center; }
.input-sm { padding: 7px 10px; font-size: .88rem; width: auto; }
.input-xs { padding: 5px 8px; font-size: .85rem; width: 70px; }
.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.form-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 10px 0 0; }
.form-inline label { min-width: 120px; }
.form-inline .grow { flex: 1; min-width: 200px; }
.inline-form { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); grid-template-columns: 1fr auto; align-items: end; }

.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 10px; font-weight: 600; font-size: .9rem; }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-success { background: var(--mint-soft); color: var(--mint); }

/* ---------- auth pages ---------- */
.auth-shell { min-height: 100%; display: grid; grid-template-columns: minmax(320px, 440px) 1fr; }
.auth-brand { background: #141826; color: #fff; padding: 36px 40px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-brand::after { content: ""; position: absolute; width: 420px; height: 420px; right: -180px; bottom: -120px; border-radius: 50%; background: radial-gradient(circle, rgba(75,61,245,.55), transparent 65%); pointer-events: none; }
.auth-brand .brand { color: #fff; }
.auth-pitch { position: relative; z-index: 1; }
.auth-pitch h2 { font-size: 2.1rem; font-weight: 800; margin: .2em 0 .6em; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; font-weight: 700; color: #2ee6a8; margin: 0; }
.pitch-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; color: #c3c8d8; }
.pitch-list li { padding-left: 26px; position: relative; }
.pitch-list li::before { content: ""; position: absolute; left: 0; top: 7px; width: 12px; height: 12px; border-radius: 4px; background: #4b3df5; box-shadow: 0 0 0 3px rgba(75,61,245,.3); }
.auth-foot { font-size: .8rem; color: #8b92a9; margin: 0; position: relative; z-index: 1; }
.auth-foot a { color: #c3c8d8; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 520px; }
.switch { text-align: center; color: var(--muted); margin-top: 8px; }
.state { text-align: center; padding: 10px 0; }
.state-icon { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; font-size: 1.7rem; font-weight: 800; margin: 0 auto 18px; }
.state-icon.ok { background: var(--mint-soft); color: var(--mint); }
.state-icon.wait { background: var(--amber-soft); color: var(--amber); }
.state-icon.bad { background: var(--red-soft); color: var(--red); }
.prose { max-width: 680px; }
.prose h2 { margin-top: 1.6em; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: .3em; }

@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { padding: 20px; }
  .auth-pitch, .auth-foot { display: none; }
  .row-2 { grid-template-columns: 1fr; }
}

/* ---------- app shell ---------- */
.page-app { overflow: hidden; }
.app-shell { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 76px 1fr; }
.rail { background: #141826; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 0; }
.rail-brand { margin-bottom: 14px; }
.rail-brand .brand-mark { width: 38px; height: 38px; border-radius: 12px; }
.rail-link { width: 60px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0; border-radius: 12px; color: #8b92a9; font-size: .68rem; font-weight: 600; background: none; border: 0; font-family: inherit; cursor: pointer; text-decoration: none !important; }
.rail-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.rail-link.is-active { color: #fff; background: rgba(122,109,255,.22); }
.rail-bottom { margin-top: auto; }
.app-main { min-width: 0; min-height: 0; overflow: auto; }

/* ---------- chat ---------- */
.chat { height: 100%; display: grid; grid-template-columns: minmax(300px, 380px) 1fr; }
.inbox { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.inbox-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 20px 12px; }
.inbox-head h1 { font-size: 1.45rem; margin-bottom: 4px; }
.my-number { display: flex; align-items: center; gap: 7px; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin: 0; }
.my-number .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 3px var(--mint-soft); }
.my-number.pending { color: var(--amber); }
.inbox .alert { margin: 0 16px 10px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; flex: none; }
.icon-btn:hover { border-color: var(--muted); }
.icon-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.conn-banner { margin: 0 16px 8px; padding: 8px 12px; border-radius: 10px; background: var(--amber-soft); color: var(--amber); font-size: .82rem; font-weight: 600; }
.conv-list { list-style: none; margin: 0; padding: 4px 10px 16px; overflow-y: auto; flex: 1; }
.conv { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 10px; border: 0; background: none; border-radius: 12px; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.conv:hover { background: var(--surface-2); }
.conv.is-active { background: var(--accent-soft); }
.avatar { --h: 250; position: relative; width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .9rem; color: hsl(var(--h) 55% 35%); background: hsl(var(--h) 80% 92%); }
@media (prefers-color-scheme: dark) { .avatar { color: hsl(var(--h) 80% 85%); background: hsl(var(--h) 35% 26%); } }
.avatar .online { position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: var(--mint); border: 2px solid var(--surface); }
.conv-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.conv-top, .conv-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conv-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-top time { font-size: .75rem; color: var(--muted); flex: none; }
.conv-preview { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.is-unread .conv-preview { color: var(--ink); font-weight: 600; }
.conv.is-unread .conv-top time { color: var(--accent); font-weight: 700; }
.unread { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 800; display: grid; place-items: center; }
.chip-sms { flex: none; font-size: .65rem; font-weight: 800; letter-spacing: .06em; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; }
.empty { text-align: center; padding: 40px 24px; }
.empty p { margin: 0 0 4px; }

.thread { display: flex; flex-direction: column; min-height: 0; background: var(--bg); position: relative; }
.thread-placeholder { margin: auto; text-align: center; color: var(--muted); }
.ph-art { width: 120px; height: 90px; margin: 0 auto 16px; border-radius: 18px; background:
  radial-gradient(circle at 78% 22%, var(--mint) 0 9px, transparent 10px),
  linear-gradient(var(--accent-soft), var(--accent-soft)); position: relative; }
.ph-art::after { content: ""; position: absolute; left: 22px; right: 34px; top: 30px; height: 10px; border-radius: 5px; background: var(--accent); opacity: .5; box-shadow: 0 20px 0 -0px rgba(75,61,245,.25); }
.thread-inner { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.thread-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.thread-head .back { display: none; border: 0; }
.thread-title { flex: 1; min-width: 0; }
.thread-title h2 { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-title p { margin: 0; font-size: .82rem; }
.badge { font-size: .72rem; font-weight: 800; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.badge-free { background: var(--mint-soft); color: var(--mint); }
.badge-sms { background: var(--accent-soft); color: var(--accent); }
.messages { flex: 1; overflow-y: auto; padding: 18px 20px 8px; display: flex; flex-direction: column; gap: 2px; outline: none; }
.day-sep { text-align: center; margin: 14px 0 10px; }
.day-sep span { font-size: .72rem; font-weight: 700; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; }
.older-hint { text-align: center; font-size: .75rem; color: var(--muted); padding: 4px; }
.thread-empty { margin: auto; color: var(--muted); }
.msg { display: flex; flex-direction: column; max-width: min(72%, 560px); margin-bottom: 8px; }
.msg.grouped { margin-bottom: 2px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 9px 13px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(20,24,38,.05); }
.theirs .bubble { background: var(--bubble-theirs); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.mine .bubble { background: var(--bubble-mine); color: #fff; border-bottom-right-radius: 6px; }
.mine .bubble a { color: #fff; text-decoration: underline; }
.msg.grouped.theirs .bubble { border-bottom-left-radius: 18px; }
.msg.grouped.mine .bubble { border-bottom-right-radius: 18px; }
.failed .bubble { background: var(--red-soft); color: var(--red); border: 1px solid var(--red); }
.meta { display: flex; gap: 8px; font-size: .72rem; color: var(--muted); margin-top: 3px; padding: 0 4px; }
.st-seen { color: var(--accent); font-weight: 700; }
.st-failed { color: var(--red); font-weight: 700; }
.composer { padding: 10px 16px 14px; background: var(--surface); border-top: 1px solid var(--line); }
.new-to { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.new-to label { font-weight: 700; color: var(--muted); }
.new-to input { flex: 1; }
.new-to select { width: auto; }
.compose-row { display: flex; align-items: flex-end; gap: 10px; }
.compose-row textarea { resize: none; border-radius: 20px; padding: 10px 16px; max-height: 160px; line-height: 1.4; }
.send-btn { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; transition: opacity .15s, transform .1s; }
.send-btn:disabled { opacity: .35; cursor: default; }
.send-btn:not(:disabled):active { transform: scale(.94); }
.send-btn svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.compose-hint { font-size: .75rem; color: var(--muted); margin: 6px 6px 0; min-height: 1em; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .88rem; box-shadow: var(--shadow); z-index: 50; max-width: calc(100vw - 32px); }
.toast.is-error { background: var(--red); color: #fff; }

@media (max-width: 859px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { order: 2; flex-direction: row; justify-content: space-around; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .rail-brand { display: none; }
  .rail-bottom { margin: 0; }
  .chat { grid-template-columns: 1fr; }
  .chat[data-view="list"] .thread { display: none; }
  .chat[data-view="thread"] .inbox { display: none; }
  .page-app:has(.chat[data-view="thread"]) .rail { display: none; }
  .thread-head { padding: 10px 12px; }
  .thread-head .back { display: grid; }
  .messages { padding: 14px 12px 6px; }
  .msg { max-width: 84%; }
  .composer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* ---------- account ---------- */
.page-pad { padding: 28px clamp(16px, 4vw, 40px); max-width: 960px; }
.page-head { margin-bottom: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.cards .card { margin: 0; }
.num-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.num-list li { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.num { font-weight: 800; font-size: 1.1rem; }

/* ---------- admin ---------- */
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.admin-side { background: #141826; color: #c3c8d8; padding: 24px 16px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.admin-side .brand { color: #fff; padding: 0 8px; }
.admin-side nav { display: grid; gap: 2px; }
.admin-side nav a { display: flex; justify-content: space-between; align-items: center; color: #c3c8d8; padding: 9px 12px; border-radius: 10px; font-weight: 600; font-size: .92rem; text-decoration: none; }
.admin-side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.admin-side nav a.is-active { background: rgba(122,109,255,.22); color: #fff; }
.pill { background: #2ee6a8; color: #0b2a20; font-size: .72rem; font-weight: 800; padding: 1px 8px; border-radius: 999px; }
.admin-side-foot { margin-top: auto; display: grid; gap: 8px; padding: 0 12px; font-size: .88rem; }
.admin-side-foot a, .admin-side-foot .link { color: #8b92a9; text-align: left; }
.admin-main { padding: 28px clamp(16px, 3vw, 40px); min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 4px; color: inherit; text-decoration: none !important; box-shadow: var(--shadow); }
.stat.attn { border-color: var(--accent); background: var(--accent-soft); }
.stat-num { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }
.stat-num small { font-size: 1rem; color: var(--muted); font-weight: 700; }
.stat-label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.steps { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs a { padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: .88rem; color: var(--muted); border: 1px solid var(--line); background: var(--surface); text-decoration: none; }
.tabs a.is-active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.tag { display: inline-block; font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.tag.ok { background: var(--mint-soft); color: var(--mint); border-color: transparent; }
.tag.wait { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.tag.bad { background: var(--red-soft); color: var(--red); border-color: transparent; }
.app-cards { display: grid; gap: 14px; }
.app-card header { display: flex; justify-content: space-between; gap: 12px; }
.app-card blockquote { margin: 10px 0 14px; padding: 12px 14px; background: var(--surface-2); border-radius: 10px; border-left: 3px solid var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions form { display: flex; gap: 8px; align-items: center; margin: 0; }
.empty-card { text-align: center; }
.highlight { border-color: var(--mint); }
.code-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-bottom: 12px; }
.code-chip { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; font-weight: 700; }
@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { position: static; height: auto; padding: 14px; gap: 12px; }
  .admin-side nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .admin-side-foot { display: flex; padding: 0 8px; gap: 16px; }
}
