
:root {
  --bg: #0a0a0a;
  --bg-2: #0e0e0e;
  --sidebar: #0c0c0c;
  --surface: #111111;
  --surface-2: #171717;
  --hover: #1c1c1c;
  --border: #212121;
  --border-2: #2e2e2e;
  --text: #ededed;
  --muted: #a1a1a1;
  --faint: #626262;
  --accent: #ededed;
  --accent-fg: #0a0a0a;
  --danger: #e5484d;
  --user-bubble: #171717;
  --line: rgba(255, 255, 255, 0.045);
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 16px 48px rgba(0, 0, 0, 0.6);
  --radius: 12px;
  --font: 'Geist', 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --mono: 'Geist Mono', 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #fafafa;
  --bg-2: #f4f4f4;
  --sidebar: #f5f5f5;
  --surface: #ffffff;
  --surface-2: #f2f2f2;
  --hover: #ebebeb;
  --border: #e4e4e4;
  --border-2: #d4d4d4;
  --text: #0a0a0a;
  --muted: #555555;
  --faint: #8f8f8f;
  --accent: #0a0a0a;
  --accent-fg: #fafafa;
  --user-bubble: #f0f0f0;
  --line: rgba(0, 0, 0, 0.05);
  --shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 16px 48px rgba(0, 0, 0, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}

body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 9999; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme='light'] body::after { opacity: .025; }

button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
::selection { background: var(--text); color: var(--bg); }
:focus-visible { outline: 1px solid var(--text); outline-offset: 2px; }

* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; }

.icon { width: 18px; height: 18px; flex: none; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }

.ic, .ic-text { display: inline-flex; align-items: center; gap: 4px; vertical-align: -2px; }
.ic .icon, .ic-text .icon { width: 13px; height: 13px; }

.grid-bg {
  position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px; background-position: center center;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 30%, transparent 100%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 30%, transparent 100%);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px; border-radius: 8px; font-weight: 500; font-size: 14px;
  background: var(--surface); border: 1px solid var(--border-2); transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--hover); border-color: var(--faint); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--muted); border-color: var(--muted); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(229, 72, 77, .1); border-color: rgba(229, 72, 77, .5); }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 7px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--faint); transition: .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.active { color: var(--text); }

.input {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border-2);
  background: var(--bg-2); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--faint); }
.input:focus { border-color: var(--text); box-shadow: 0 0 0 3px var(--line); }
textarea.input { resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.6; }

.logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--text); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.logo svg { width: 17px; height: 17px; }

kbd {
  font-family: var(--mono); font-size: 11px; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border-2); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px;
}

.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface); border: 1px solid var(--border-2); padding: 10px 14px 10px 30px; border-radius: 10px;
  box-shadow: var(--shadow); max-width: 360px; font-size: 14px; position: relative; animation: toastIn .25s cubic-bezier(.2, .8, .2, 1);
}
.toast::before { content: ''; position: absolute; left: 13px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.toast.ok::before { background: var(--text); }
.toast.error::before { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.modal-bg {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .7); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 500; padding: 16px; animation: fade .15s;
}
.modal {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px; box-shadow: var(--shadow);
  width: 100%; max-width: 440px; padding: 22px; display: flex; flex-direction: column; gap: 14px; animation: pop .18s cubic-bezier(.2, .8, .2, 1);
}
.modal.wide { max-width: 900px; max-height: 90vh; }
.modal h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; padding-top: 4px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }

.auth-page {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px;
  position: relative; overflow: hidden;
}
.auth-page::before {
  content: ''; position: absolute; width: 900px; height: 500px; left: 50%; top: 42%; transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, .06), transparent 65%); pointer-events: none;
}
:root[data-theme='light'] .auth-page::before { background: radial-gradient(ellipse at center, rgba(0, 0, 0, .04), transparent 65%); }
.auth-card {
  position: relative; width: 100%; max-width: 380px; padding: 30px 26px 26px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 16px; box-shadow: var(--shadow);
}

.auth-card::before, .auth-card::after {
  content: ''; position: absolute; width: 14px; height: 14px; border: 1px solid var(--faint); pointer-events: none;
}
.auth-card::before { top: -6px; left: -6px; border-right: none; border-bottom: none; }
.auth-card::after { bottom: -6px; right: -6px; border-left: none; border-top: none; }
.auth-head { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; text-align: center; }
.auth-head .logo { width: 46px; height: 46px; border-radius: 12px; margin-bottom: 6px; }
.auth-head .logo svg { width: 25px; height: 25px; }
.auth-head h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.03em; }
.auth-head p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint);
  display: inline-flex; align-items: center; gap: 8px;
}
.eyebrow::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--text); box-shadow: 0 0 0 3px var(--line); }
.tabs { display: flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; margin-bottom: 18px; }
.tabs button { flex: 1; padding: 7px; border-radius: 6px; color: var(--faint); font-weight: 500; font-size: 14px; transition: .15s; }
.tabs button:hover { color: var(--muted); }
.tabs button.active { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--border-2); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.form .btn-primary { padding: 11px; margin-top: 4px; font-size: 14px; font-weight: 600; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; text-align: center; }
.auth-foot { position: relative; margin-top: 22px; font-family: var(--mono); font-size: 11px; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; }

.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

.sidebar {
  width: 264px; flex: none; background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; transition: margin-left .25s ease, transform .25s ease;
}
.app.collapsed .sidebar { margin-left: -264px; }
.sb-head { display: flex; align-items: center; gap: 10px; padding: 14px 10px 12px 14px; }
.sb-head .title { font-weight: 650; font-size: 14px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.02em; }
.new-chat {
  margin: 2px 10px 10px; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border-2); background: var(--surface); font-weight: 500; font-size: 14px; transition: .15s;
}
.new-chat:hover { border-color: var(--faint); background: var(--hover); }
.new-chat .icon { width: 16px; height: 16px; }
.new-chat kbd { margin-left: auto; }
.sb-search { margin: 0 10px 6px; position: relative; }
.sb-search .icon { position: absolute; left: 10px; top: 8px; width: 15px; color: var(--faint); }
.sb-search input { width: 100%; padding: 6px 10px 6px 32px; border-radius: 8px; border: 1px solid transparent; background: transparent; outline: none; font-size: 13px; }
.sb-search input::placeholder { color: var(--faint); }
.sb-search input:focus { border-color: var(--border-2); background: var(--bg-2); }
.chat-list { flex: 1; overflow-y: auto; padding: 0 6px 12px; }
.chat-group { font-family: var(--mono); font-size: 10.5px; color: var(--faint); letter-spacing: .12em; text-transform: uppercase; padding: 16px 10px 6px; }
.chat-item {
  display: flex; align-items: center; gap: 4px; padding: 7px 10px; border-radius: 7px; cursor: pointer;
  color: var(--muted); font-size: 13.5px; position: relative;
}
.chat-item:hover { background: var(--hover); color: var(--text); }
.chat-item.active { background: var(--surface-2); color: var(--text); }
.chat-item .name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .acts { display: none; gap: 2px; }
.chat-item:hover .acts, .chat-item.active .acts { display: flex; }
.chat-item .acts button { width: 22px; height: 22px; border-radius: 5px; color: var(--faint); display: flex; align-items: center; justify-content: center; }
.chat-item .acts button:hover { color: var(--text); background: var(--border-2); }
.chat-item .acts .icon { width: 13px; height: 13px; }
.chat-empty { color: var(--faint); font-size: 13px; text-align: center; padding: 28px 8px; line-height: 1.5; }

.sb-foot { border-top: 1px solid var(--border); padding: 8px; position: relative; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 7px; border-radius: 8px; width: 100%; text-align: left; }
.user-card:hover { background: var(--hover); }
.avatar {
  width: 30px; height: 30px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text);
  font-weight: 600; font-family: var(--mono); font-size: 13px; display: flex; align-items: center; justify-content: center; flex: none; text-transform: uppercase;
}
.user-card .info { flex: 1; min-width: 0; line-height: 1.35; }
.user-card .login { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .role { font-size: 11px; color: var(--faint); font-family: var(--mono); letter-spacing: .02em; }
.menu {
  position: absolute; bottom: calc(100% - 2px); left: 8px; right: 8px; background: var(--surface);
  border: 1px solid var(--border-2); border-radius: 10px; box-shadow: var(--shadow); padding: 5px; z-index: 50; animation: pop .12s;
}
.menu button, .menu a {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 6px; color: var(--muted); font-size: 13.5px; text-decoration: none;
}
.menu .icon { width: 16px; height: 16px; }
.menu button:hover, .menu a:hover { background: var(--hover); color: var(--text); }
.menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; min-height: 54px; border-bottom: 1px solid transparent; }
.topbar .chat-title { font-weight: 550; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; color: var(--muted); }
.badge {
  font-family: var(--mono); font-size: 11px; padding: 3px 8px; border-radius: 6px; color: var(--muted);
  border: 1px solid var(--border-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--text); }

.server-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px 5px 10px; border-radius: 8px;
  border: 1px solid var(--border-2); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--text); transition: .15s;
}
.server-btn:hover { border-color: var(--faint); background: var(--hover); }
.server-btn .icon { width: 15px; height: 15px; color: var(--muted); }
.server-btn .icon:last-child { width: 13px; height: 13px; color: var(--faint); }
.server-btn.unset { color: var(--muted); border-style: dashed; }
.limit-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 8px; font-size: 13px;
  color: var(--muted); border: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.limit-badge:hover { background: var(--hover); }
.limit-badge .icon { width: 14px; height: 14px; color: var(--faint); }
.limit-badge b { color: var(--text); font-weight: 600; }
.limit-badge.low b { color: var(--text); }
.limit-badge.low { border-color: var(--faint); }
.limit-badge.is-out { color: var(--danger); border-color: rgba(229, 72, 77, .4); }
.limit-badge.is-out b { color: var(--danger); }
.limit-badge.is-out .icon { color: var(--danger); }
.server-list {display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.server-opt input { position: absolute; opacity: 0; pointer-events: none; }
.server-opt span {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border-2);
  cursor: pointer; font-size: 14px; transition: .15s;
}
.server-opt span .icon { width: 16px; height: 16px; color: var(--faint); }
.server-opt span:hover { background: var(--hover); }
.server-opt input:checked + span { border-color: var(--text); background: var(--surface-2); }
.server-opt input:checked + span .icon { color: var(--text); }
.server-opt input:focus-visible + span { outline: 1px solid var(--text); outline-offset: 2px; }

.messages { flex: 1; overflow-y: auto; }
.messages-inner { max-width: 780px; margin: 0 auto; padding: 8px 24px 48px; }

.empty {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 20px; text-align: center; position: relative;
}
.empty > *:not(.grid-bg) { position: relative; }
.empty .logo { width: 52px; height: 52px; border-radius: 14px; margin-bottom: 8px; box-shadow: 0 0 0 6px var(--line), 0 0 0 12px var(--line); }
.empty .logo svg { width: 27px; height: 27px; }
.empty h2 { margin: 2px 0 0; font-size: 32px; font-weight: 650; letter-spacing: -0.04em; line-height: 1.15; }
.empty p { margin: 0; color: var(--muted); max-width: 470px; font-size: 15px; }
.suggests {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin-top: 22px; width: 100%; max-width: 640px;
  border: 1px solid var(--border-2); border-radius: 12px; overflow: hidden; background: var(--surface);
}
.suggest {
  text-align: left; padding: 14px 16px; font-size: 13px; color: var(--faint); transition: background .15s;
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: baseline;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.suggest:nth-child(2n) { border-right: none; }
.suggest:nth-last-child(-n+2) { border-bottom: none; }
.suggest .num { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.suggest b { display: block; color: var(--text); font-weight: 550; font-size: 14px; }
.suggest:hover { background: var(--hover); }
.suggest:hover .num { color: var(--text); }

.msg { display: flex; gap: 14px; padding: 16px 0; animation: msgIn .3s cubic-bezier(.2, .8, .2, 1); }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } }
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user-bubble); border: 1px solid var(--border); padding: 9px 15px; border-radius: 16px 16px 4px 16px; max-width: 78%;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg.user .voice-tag { display: inline-flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin-bottom: 2px; }
.msg.user .voice-tag .icon { width: 11px; height: 11px; }
.msg.ai .ava { width: 28px; height: 28px; border-radius: 7px; flex: none; margin-top: 1px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2); }
.msg.ai .ava svg { width: 15px; height: 15px; }
.msg.ai .body { flex: 1; min-width: 0; }
.msg-tools { display: flex; gap: 2px; margin-top: 6px; opacity: 0; transition: .15s; align-items: center; }
.msg:hover .msg-tools, .msg-tools.show { opacity: 1; }
.msg-tools button { width: 28px; height: 28px; border-radius: 6px; color: var(--faint); display: flex; align-items: center; justify-content: center; }
.msg-tools button:hover { background: var(--hover); color: var(--text); }
.msg-tools .icon { width: 14px; height: 14px; }
.msg-tools .meta { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-left: 6px; }

.md { word-wrap: break-word; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { margin: 20px 0 8px; line-height: 1.3; letter-spacing: -0.02em; font-weight: 650; }
.md h1 { font-size: 21px; } .md h2 { font-size: 18px; } .md h3 { font-size: 16px; } .md h4 { font-size: 15px; }
.md ul, .md ol { padding-left: 22px; margin: 0 0 12px; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--faint); }
.md strong { color: var(--text); font-weight: 650; }
.md blockquote {
  margin: 10px 0 14px; padding: 8px 14px; border-left: 2px solid var(--text); background: var(--surface);
  border-radius: 0 8px 8px 0; color: var(--text); font-size: 14.5px;
}
.md blockquote p { margin: 4px 0; }
.md code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--bg-2); border: 1px solid var(--border-2); padding: 12px 14px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; border: none; padding: 0; }
.md table { border-collapse: collapse; margin: 10px 0 14px; display: block; overflow-x: auto; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border-2); padding: 6px 10px; text-align: left; }
.md th { background: var(--surface-2); font-weight: 600; }
.md hr { border: none; border-top: 1px dashed var(--border-2); margin: 18px 0; }

.note {
  position: relative; margin: 16px 0 6px; padding: 12px 14px 12px 18px; border: 1px solid var(--border-2); border-radius: 10px;
  background: repeating-linear-gradient(-45deg, transparent 0 7px, var(--line) 7px 8px), var(--surface);
}
.note::before { content: ''; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 3px; border-radius: 10px 0 0 10px; background: var(--text); }
.note-head {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .16em; color: var(--bg); background: var(--text); padding: 2px 8px 2px 6px; border-radius: 4px; margin-bottom: 8px;
}
.note-head .icon { width: 12px; height: 12px; }
.note-body { text-transform: uppercase; font-weight: 550; font-size: 13.5px; letter-spacing: .02em; color: var(--text); line-height: 1.55; }
.note-body p { margin: 2px 0; }
.note-body blockquote { border: none; background: none; padding: 0; margin: 0; }

.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .15; } 40% { opacity: 1; } }
.cursor::after { content: ''; display: inline-block; width: 7px; height: 15px; background: var(--text); margin-left: 3px; vertical-align: -2px; animation: caret 1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.msg-error { color: var(--danger); background: rgba(229, 72, 77, .06); border: 1px solid rgba(229, 72, 77, .3); padding: 8px 12px; border-radius: 8px; font-size: 13.5px; margin-top: 8px; }

.composer-wrap { padding: 0 24px 14px; position: relative; }
.composer-wrap::before { content: ''; position: absolute; left: 0; right: 0; top: -40px; height: 40px; background: linear-gradient(transparent, var(--bg)); pointer-events: none; }
.composer {
  max-width: 780px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px;
  padding: 8px 8px 8px 16px; display: flex; align-items: flex-end; gap: 4px; transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--faint); box-shadow: 0 0 0 4px var(--line); }
.composer textarea {
  flex: 1; border: none; outline: none; background: none; resize: none; max-height: 220px; min-height: 24px;
  padding: 7px 0; line-height: 1.5; font-size: 15px;
}
.composer textarea::placeholder { color: var(--faint); }
.c-btn { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex: none; transition: .15s; color: var(--faint); }
.c-btn:hover { background: var(--hover); color: var(--text); }
.c-btn .icon { width: 18px; height: 18px; }
.send-btn { background: var(--accent); color: var(--accent-fg); }
.send-btn:hover { background: var(--muted); color: var(--accent-fg); }
.send-btn:disabled { background: var(--surface-2); color: var(--faint); cursor: default; }
.mic-btn { user-select: none; -webkit-user-select: none; touch-action: none; }
.mic-btn.rec { background: var(--accent); color: var(--accent-fg); animation: pulse 1.3s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(237, 237, 237, .35); } 100% { box-shadow: 0 0 0 14px rgba(237, 237, 237, 0); } }
.voice-draft {
  max-width: 780px; margin: 0 auto 8px; display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px;
  background: var(--surface); border: 1px dashed var(--border-2); border-radius: 10px; font-size: 13px; color: var(--muted);
  animation: pop .15s;
}
.voice-draft .icon { width: 15px; height: 15px; color: var(--text); flex: none; }
.voice-draft .vd-text { flex: 1; min-width: 0; }
.vd-btn { padding: 5px 10px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.vd-btn:hover { background: var(--hover); color: var(--text); }
.vd-btn.vd-send { background: var(--accent); color: var(--accent-fg); }
.vd-btn.vd-send:hover { background: var(--muted); }
.hint { max-width: 780px; margin: 9px auto 0; text-align: center; font-size: 11.5px; color: var(--faint); }

.ptt {
  position: absolute; left: 50%; bottom: 104px; transform: translateX(-50%); z-index: 40;
  background: var(--surface); border: 1px solid var(--border-2); box-shadow: var(--shadow); border-radius: 14px;
  padding: 14px 16px; width: min(540px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 10px; animation: pttIn .2s cubic-bezier(.2, .8, .2, 1);
}
@keyframes pttIn { from { opacity: 0; transform: translate(-50%, 8px); } }
.ptt-top { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 3px rgba(229, 72, 77, .2); animation: caret 1s infinite; }
.ptt-time { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--text); }
.wave { display: flex; align-items: center; gap: 3px; height: 32px; }
.wave i { flex: 1; background: var(--text); border-radius: 2px; height: 3px; transition: height .08s; min-width: 2px; opacity: .85; }
.ptt-text { font-size: 15px; min-height: 22px; color: var(--text); }
.ptt-text .interim { color: var(--faint); }

.only-mobile { display: none; }
.scrim { display: none; }
@media (max-width: 860px) {
  .only-mobile { display: inline-flex; }
  .sidebar { position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; transform: translateX(-100%); margin-left: 0 !important; }
  .app.sb-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .app.sb-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 55; }
  .desk-only { display: none !important; }
  .suggests { grid-template-columns: 1fr; }
  .suggest { border-right: none !important; border-bottom: 1px solid var(--border) !important; }
  .suggest:last-child { border-bottom: none !important; }
  .empty h2 { font-size: 26px; }
  .messages-inner { padding: 8px 14px 30px; }
  .composer-wrap { padding: 0 10px 10px; }
  .msg.user .bubble { max-width: 90%; }
  .hint { display: none; }
}

.admin { display: flex; min-height: 100vh; }
.admin-nav {
  width: 232px; flex: none; background: var(--sidebar); border-right: 1px solid var(--border); padding: 14px 8px;
  display: flex; flex-direction: column; gap: 1px; position: sticky; top: 0; height: 100vh;
}
.admin-nav .sb-head { padding: 0 6px 16px; }
.admin-nav .nav-label { font-family: var(--mono); font-size: 10.5px; color: var(--faint); letter-spacing: .12em; text-transform: uppercase; padding: 4px 10px 6px; }
.admin-nav button, .admin-nav a.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--muted); font-size: 13.5px; font-weight: 500; text-align: left; text-decoration: none; position: relative;
}
.admin-nav .icon { width: 16px; height: 16px; }
.admin-nav button:hover, .admin-nav a.nav-link:hover { background: var(--hover); color: var(--text); }
.admin-nav button.active { background: var(--surface-2); color: var(--text); }
.admin-nav .spacer { flex: 1; }
.admin-main { flex: 1; min-width: 0; padding: 32px 36px 60px; max-width: 1200px; }
.admin-main h1 { margin: 0 0 4px; font-size: 26px; font-weight: 650; letter-spacing: -0.035em; }
.admin-main .sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.admin-main code { font-family: var(--mono); font-size: 12.5px; }
.cards {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-bottom: 16px;
  border: 1px solid var(--border-2); border-radius: var(--radius); overflow: hidden; background: var(--border);
}
.cards .card { border: none; border-radius: 0; margin: 0 1px 1px 0; }
.card { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius); padding: 16px 18px; }
.card .k { color: var(--faint); font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.card .v { font-size: 28px; font-weight: 600; margin-top: 6px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.card .v small { font-size: 12px; color: var(--faint); font-weight: 500; letter-spacing: 0; }
.panel { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 14px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel h3 .icon { width: 16px; height: 16px; color: var(--faint); }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .input { max-width: 320px; padding: 7px 12px; }
.table-wrap { overflow-x: auto; padding: 0; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-weight: 500; color: var(--faint); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 10px 14px; border-bottom: 1px solid var(--border-2); background: var(--bg-2); }
table.t td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: none; }
table.t tbody tr:hover td { background: var(--hover); }
table.t td:last-child { width: 1%; white-space: nowrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; padding: 2px 8px; border-radius: 5px;
  font-weight: 500; border: 1px solid var(--border-2); color: var(--muted); white-space: nowrap;
}
.pill::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.super { background: var(--text); color: var(--bg); border-color: var(--text); }
.pill.role-admin { color: var(--text); border-color: var(--faint); }
.pill.user { color: var(--faint); }
.pill.banned { color: var(--danger); border-color: rgba(229, 72, 77, .4); }
.pill.ok { color: var(--text); }
.pill.wait { color: var(--muted); border-style: dashed; }
.nav-count {
  margin-left: auto; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--text); color: var(--bg);
  font-family: var(--mono); font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 18px; text-align: center; }
.empty-state .icon { width: 28px; height: 28px; color: var(--faint); margin-bottom: 4px; }
.pending-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 8px; font-size: 13px; white-space: nowrap;
  color: var(--muted); border: 1px dashed var(--border-2);
}
.pending-badge .icon { width: 14px; height: 14px; color: var(--faint); }
.more-btn { width: 30px; height: 30px; }
.more-btn .icon { width: 16px; height: 16px; }
.dd-menu {
  position: fixed; z-index: 400; min-width: 210px; background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 10px; box-shadow: var(--shadow); padding: 5px; animation: pop .12s;
}
.dd-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 6px; font-size: 13.5px; color: var(--muted); text-align: left;
}
.dd-menu button .icon { width: 15px; height: 15px; }
.dd-menu button:hover { background: var(--hover); color: var(--text); }
.dd-menu button.danger { color: var(--danger); }
.dd-menu button.danger:hover { background: rgba(229, 72, 77, .1); }
.dd-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.lim { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.lim-out { color: var(--danger); }
.lim-form { display: flex; flex-direction: column; gap: 6px; }
.lim-opt, .lim-check {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-2); border-radius: 9px;
  cursor: pointer; font-size: 14px; flex-wrap: wrap;
}
.lim-opt:hover { background: var(--hover); }
.lim-opt:has(input[type=radio]:checked) { border-color: var(--text); background: var(--surface-2); }
.lim-check { border-style: dashed; color: var(--muted); margin-top: 4px; }
.lim-num { width: 120px; padding: 6px 10px; margin-left: auto; font-family: var(--mono); }
.lim-opt input[type=radio], .lim-check input { accent-color: var(--text); width: 15px; height: 15px; margin: 0; }
.acts-row {display: flex; gap: 6px; flex-wrap: nowrap; justify-content: flex-end; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar i { width: 100%; background: var(--border-2); border-radius: 3px 3px 1px 1px; min-height: 2px; transition: background .15s; }
.bars .bar:last-child i, .bars .bar:hover i { background: var(--text); }
.bars .bar span { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.bars .bar b { font-family: var(--mono); font-size: 10.5px; color: var(--muted); font-weight: 500; }
.rules-grid { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
.file-list { display: flex; flex-direction: column; gap: 1px; max-height: 60vh; overflow: auto; }
.file-group + .file-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.file-group-h { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; padding: 2px 9px 6px; }
.file-group-h .icon { width: 14px; height: 14px; color: var(--faint); }
.file-group-h .faint { margin-left: auto; font-family: var(--mono); font-size: 11px; font-weight: 400; }
select.input { appearance: none; cursor: pointer; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.file-item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 7px; cursor: pointer; font-size: 13.5px; color: var(--muted); }
.file-item .icon { width: 15px; height: 15px; color: var(--faint); }
.file-item:hover { background: var(--hover); color: var(--text); }
.file-item.active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-2); }
.file-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .faint { font-family: var(--mono); font-size: 11px; }
.dropzone {
  border: 1px dashed var(--border-2); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--faint); font-size: 13px;
  transition: .15s; cursor: pointer; background: var(--surface);
}
.dropzone .icon { color: var(--muted); margin-bottom: 4px; }
.dropzone:hover { border-color: var(--faint); color: var(--muted); }
.dropzone.over { border-color: var(--text); border-style: solid; color: var(--text); background: var(--hover); }
.editor { min-height: 52vh; width: 100%; }
.log-item { border-bottom: 1px solid var(--border); padding: 14px 0; }
.log-item:first-child { padding-top: 0; }
.log-item:last-child { border-bottom: none; padding-bottom: 0; }
.log-q { font-weight: 550; }
.log-a { color: var(--muted); font-size: 13px; margin-top: 4px; white-space: pre-wrap; max-height: 4.8em; overflow: hidden; cursor: pointer; }
.log-a.open { max-height: none; }
.log-meta { font-family: var(--mono); font-size: 11px; color: var(--faint); display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; align-items: center; }
.log-meta b { color: var(--text); font-weight: 600; }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 0; font-size: 14px; }
.kv > div { padding: 9px 0; border-bottom: 1px solid var(--border); }
.kv > div:nth-last-child(-n+2) { border-bottom: none; }
.kv div:nth-child(odd) { color: var(--faint); font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding-top: 11px; }
.kv code { font-size: 13px; word-break: break-all; }
.search-res { border: 1px solid var(--border-2); border-radius: 8px; padding: 10px 12px; margin-top: 8px; font-size: 13px; }
.search-res pre { white-space: pre-wrap; margin: 6px 0 0; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.chat-view { overflow-y: auto; max-height: 65vh; display: flex; flex-direction: column; gap: 6px; }
.chat-view .cm { padding: 8px 12px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--border); font-size: 13.5px; white-space: pre-wrap; }
.chat-view .cm.user { background: var(--surface-2); }
.chat-view .cm .r { font-family: var(--mono); font-size: 10.5px; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 2px; }
details summary { cursor: pointer; padding: 6px 0; }
input[type='checkbox'] { accent-color: var(--text); }
@media (max-width: 860px) {
  .admin { flex-direction: column; }
  .admin-nav { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--border); }
  .admin-nav .sb-head { width: 100%; }
  .admin-nav .spacer, .admin-nav .nav-label { display: none; }
  .admin-main { padding: 20px 16px 40px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rules-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv > div:nth-child(odd) { border-bottom: none; padding-bottom: 0; }
}
