/* =========================================================================
   AgentChat — Telegram 风格、人类 + AI 群聊界面
   原生 CSS，无外部字体 / 图片 / CDN。配色以白底、蓝色主色、轻阴影为主。
   ========================================================================= */

:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f8faff;
  --panel-3: #eef3fc;
  --chat-bg: #f7f9fd;
  --primary: #2f7cf6;
  --primary-strong: #1f6ae0;
  --primary-soft: #eaf2ff;
  --text: #172033;
  --text-soft: #3e4a63;
  --muted: #7b849a;
  --muted-2: #a2aabc;
  --border: #e7ebf3;
  --border-strong: #d8dfeb;
  --danger: #e5484d;
  --danger-soft: #fff0f0;
  --success: #28a56b;
  --success-soft: #e8f8f0;
  --warning: #d98a21;
  --warning-soft: #fff7e8;
  --agent: #7c5cf3;
  --agent-soft: #f1edff;
  --invite-bg: linear-gradient(155deg, #edf4ff 0%, #f7faff 56%, #ffffff 100%);
  --shadow-xs: 0 1px 2px rgba(23, 32, 51, 0.04);
  --shadow-sm: 0 1px 3px rgba(23, 32, 51, 0.05), 0 8px 24px rgba(23, 32, 51, 0.04);
  --shadow-md: 0 8px 28px rgba(23, 32, 51, 0.09), 0 2px 8px rgba(23, 32, 51, 0.04);
  --shadow-lg: 0 24px 64px rgba(23, 32, 51, 0.18), 0 4px 16px rgba(23, 32, 51, 0.06);
  --ring: 0 0 0 3px rgba(47, 124, 246, 0.16);
  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --sidebar-w: 290px;
  --right-w: 304px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1420;
    --panel: #151d2c;
    --panel-2: #1a2436;
    --panel-3: #202c40;
    --chat-bg: #101827;
    --primary: #4d8df7;
    --primary-strong: #6ba1ff;
    --primary-soft: #1c2f4d;
    --text: #e8edf7;
    --text-soft: #c6cfdf;
    --muted: #8e9ab1;
    --muted-2: #6c7890;
    --border: #263247;
    --border-strong: #33425b;
    --danger: #ff6b70;
    --danger-soft: #3a1d22;
    --success: #4fd39b;
    --success-soft: #153428;
    --warning: #f2b45b;
    --warning-soft: #3a2c17;
    --agent: #a993ff;
    --agent-soft: #2a2345;
    --invite-bg: linear-gradient(155deg, #1c2f4d 0%, #172338 56%, #151d2c 100%);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.24), 0 8px 24px rgba(0, 0, 0, 0.16);
    --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.34), 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.26);
    --ring: 0 0 0 3px rgba(77, 141, 247, 0.24);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- base */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body.app-body { overflow: hidden; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; }

::selection { background: rgba(47, 124, 246, 0.2); }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
}

.is-hidden { display: none !important; }
.mobile-only { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); background-clip: padding-box; }

/* ------------------------------------------------------------- controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease,
    transform 0.16s ease, box-shadow 0.16s ease;
  user-select: none;
}
.btn .icon { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #3b87f8, var(--primary));
  box-shadow: 0 4px 14px rgba(47, 124, 246, 0.24);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #2f7cf6, var(--primary-strong));
  box-shadow: 0 6px 18px rgba(47, 124, 246, 0.3);
}
.btn-soft {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: transparent;
}
.btn-soft:hover:not(:disabled) { background: rgba(47, 124, 246, 0.16); }
.btn-ghost {
  color: var(--text-soft);
  border-color: var(--border);
  background: var(--panel);
}
.btn-ghost:hover:not(:disabled) { background: var(--panel-2); border-color: var(--border-strong); }
.btn-danger { color: #fff; background: var(--danger); }
.btn-danger:hover:not(:disabled) { filter: brightness(0.95); }
.btn-danger-soft { color: var(--danger); background: var(--danger-soft); }
.btn-sm { min-height: 32px; padding: 0 11px; border-radius: 10px; font-size: 12.5px; gap: 5px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-block { width: 100%; }
.btn-loading { pointer-events: none; opacity: 0.7; }

.icon-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  color: var(--muted);
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.icon-btn:hover:not(:disabled) { background: var(--panel-3); color: var(--text); }
.icon-btn:active:not(:disabled) { transform: scale(0.95); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn .icon { width: 19px; height: 19px; }
.icon-btn-sm { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn-sm .icon { width: 16px; height: 16px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-label .optional {
  color: var(--muted);
  font-weight: 400;
  font-size: 11.5px;
}
.field-help { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.form-hint { font-size: 12px; color: var(--primary); line-height: 1.5; }
.form-error {
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.5;
  border: 1px solid rgba(229, 72, 77, 0.14);
}
.form-success {
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12.5px;
  line-height: 1.5;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 13px;
  width: 17px;
  height: 17px;
  color: var(--muted-2);
  pointer-events: none;
}
.input-wrap input {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px 10px 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}
.input-wrap input::placeholder { color: var(--muted-2); }
.input-wrap input:hover { border-color: var(--border-strong); }
.input-wrap input:focus { border-color: var(--primary); box-shadow: var(--ring); }

.field > input,
.field > select,
.field > textarea,
.form-select,
.form-input {
  width: 100%;
  min-height: 42px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.field > textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.field > input:focus,
.field > select:focus,
.field > textarea:focus,
.form-select:focus,
.form-input:focus {
  border-color: var(--primary);
  box-shadow: var(--ring);
}

/* --------------------------------------------------------------- toasts */
.toast-stack {
  position: fixed;
  z-index: 300;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--panel);
  box-shadow: var(--shadow-md);
  animation: toast-in 0.22s cubic-bezier(0.22, 0.9, 0.3, 1.1);
  overflow: hidden;
}
.toast.is-leaving { animation: toast-out 0.18s ease forwards; }
.toast-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
}
.toast-icon .icon { width: 16px; height: 16px; }
.toast-success .toast-icon { background: var(--success-soft); color: var(--success); }
.toast-error .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast-message .toast-icon { background: var(--primary-soft); color: var(--primary); }
.toast-text { min-width: 0; flex: 1; padding-top: 3px; }
.toast-title { display: block; font-size: 12px; font-weight: 700; margin-bottom: 2px; color: var(--text); }
.toast-message-text {
  display: block;
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.toast-close { color: var(--muted); margin-top: 2px; }
.toast-close:hover { color: var(--text); background: var(--panel-3); }
.toast-close .icon { width: 14px; height: 14px; }

/* --------------------------------------------------------------- boot */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 34%, rgba(47, 124, 246, 0.12), transparent 42%),
    var(--bg);
}
.boot-inner { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px; }
.boot-logo { border-radius: 19px; box-shadow: 0 18px 44px rgba(47, 124, 246, 0.24); }
.boot-brand { margin-top: 16px; font-size: 23px; font-weight: 750; letter-spacing: -0.02em; }
.boot-spinner {
  width: 22px;
  height: 22px;
  margin-top: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
.boot-message { margin-top: 12px; color: var(--muted); font-size: 13px; }
.boot-error { margin-top: 20px; display: flex; gap: 8px; }

/* --------------------------------------------------------------- auth */
.auth-screen {
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(430px, 0.92fr);
  background: var(--panel);
  overflow: hidden;
}
.auth-visual {
  position: relative;
  overflow: hidden;
  color: #f2f8ff;
  background:
    linear-gradient(145deg, #194fbb 0%, #2f7cf6 52%, #5b9cff 100%);
}
.auth-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 26px 26px, 78px 78px, 78px 78px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent 88%);
  pointer-events: none;
}
.auth-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(10px);
  pointer-events: none;
}
.auth-glow-a {
  width: 520px;
  height: 520px;
  right: -180px;
  top: -180px;
  background: radial-gradient(circle, rgba(145, 210, 255, 0.38), transparent 68%);
}
.auth-glow-b {
  width: 460px;
  height: 460px;
  left: -170px;
  bottom: -180px;
  background: radial-gradient(circle, rgba(18, 52, 139, 0.58), transparent 68%);
}
.auth-visual-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: clamp(28px, 4vh, 52px) clamp(30px, 5vw, 72px);
  display: flex;
  flex-direction: column;
}
.auth-brand { display: flex; align-items: center; gap: 13px; }
.auth-brand img { border-radius: 13px; box-shadow: 0 10px 26px rgba(9, 37, 100, 0.26); }
.auth-brand-copy { display: flex; flex-direction: column; gap: 2px; }
.auth-brand-copy strong { font-size: 18px; letter-spacing: -0.01em; }
.auth-brand-copy span { font-size: 11.5px; color: rgba(255, 255, 255, 0.68); letter-spacing: 0.06em; }
.auth-headline {
  margin-top: clamp(38px, 7vh, 78px);
  font-size: clamp(36px, 4.1vw, 56px);
  line-height: 1.16;
  letter-spacing: -0.035em;
  font-weight: 760;
}
.auth-lead {
  margin-top: 20px;
  max-width: 430px;
  font-size: 14.5px;
  line-height: 1.8;
  color: rgba(239, 247, 255, 0.76);
}
.auth-feature-list {
  list-style: none;
  margin-top: clamp(30px, 5vh, 48px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 430px;
}
.auth-feature-list li { display: flex; gap: 13px; align-items: flex-start; }
.feature-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
}
.feature-icon .icon { width: 19px; height: 19px; }
.auth-feature-list li div { display: flex; flex-direction: column; gap: 3px; padding-top: 1px; }
.auth-feature-list strong { font-size: 13.5px; font-weight: 650; }
.auth-feature-list span { font-size: 12.5px; color: rgba(238, 246, 255, 0.65); line-height: 1.5; }
.auth-orbit { position: absolute; right: -12px; bottom: 120px; width: 240px; height: 190px; pointer-events: none; }
.orbit-chip {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(12px);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 26px rgba(10, 40, 110, 0.18);
  white-space: nowrap;
}
.orbit-chip .icon { width: 14px; height: 14px; }
.orbit-chip-a { right: 18px; top: 12px; animation: float-a 7s ease-in-out infinite; }
.orbit-chip-b { left: 0; top: 80px; animation: float-b 8.5s ease-in-out infinite; }
.orbit-chip-c { right: 34px; bottom: 4px; animation: float-a 9s ease-in-out infinite reverse; }
.auth-visual-foot {
  margin-top: auto;
  padding-top: 28px;
  font-size: 11.5px;
  color: rgba(238, 246, 255, 0.5);
  letter-spacing: 0.06em;
}
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background:
    radial-gradient(circle at 72% 16%, rgba(47, 124, 246, 0.07), transparent 34%),
    var(--bg);
  overflow-y: auto;
}
.auth-panel-inner { width: min(430px, 100%); display: flex; flex-direction: column; align-items: center; }
.auth-card {
  width: 100%;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow-md);
}
.auth-card-head { display: flex; align-items: center; gap: 13px; }
.auth-card-logo { border-radius: 13px; box-shadow: 0 6px 16px rgba(47, 124, 246, 0.22); }
.auth-card-head h2 { font-size: 21px; letter-spacing: -0.02em; }
.auth-card-head p { margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin: 24px 0 22px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 13px;
}
.auth-tab {
  height: 34px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.16s ease;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.is-active {
  color: var(--primary);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-submit { margin-top: 2px; min-height: 44px; font-size: 14px; }
.auth-help { font-size: 11.5px; line-height: 1.6; color: var(--muted); }
.auth-legal {
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}
.auth-legal a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.auth-legal a:hover { color: var(--primary); }
.auth-legal span { opacity: 0.7; }

/* ------------------------------------------------------------- main grid */
.main-screen { height: 100dvh; overflow: hidden; }
.main-layout {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--right-w);
  background: var(--bg);
  overflow: hidden;
  transition: grid-template-columns 0.22s ease;
}
.main-layout.view-agents,
.main-layout.view-settings { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.main-layout.view-agents .right-panel,
.main-layout.view-settings .right-panel { display: none; }
.main-layout.right-collapsed { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.main-layout.right-collapsed .right-panel { display: none; }

/* -------------------------------------------------------------- sidebar */
.sidebar {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  z-index: 30;
  transition: transform 0.24s cubic-bezier(0.22, 0.9, 0.3, 1);
}
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 12px;
}
.brand-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border-radius: 12px;
  text-align: left;
}
.brand-button img { border-radius: 11px; box-shadow: 0 5px 14px rgba(47, 124, 246, 0.2); }
.brand-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brand-copy strong { font-size: 17px; font-weight: 750; letter-spacing: -0.025em; }
.brand-copy small { font-size: 10.5px; color: var(--muted); letter-spacing: 0.04em; }
.side-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 0 12px 12px;
}
.side-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 36px;
  padding: 0 4px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.side-nav-item .icon { width: 16px; height: 16px; }
.side-nav-item:hover { background: var(--panel-2); color: var(--text); }
.side-nav-item.is-active { background: var(--primary-soft); color: var(--primary); }
.nav-badge {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: inline-grid;
  place-items: center;
  border-radius: 99px;
  background: var(--primary);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
}
.sidebar-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 2px 10px 14px; }
.side-view { display: flex; flex-direction: column; gap: 10px; }
.side-search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 2px 2px 0;
}
.side-search .icon {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--muted-2);
  pointer-events: none;
}
.side-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.side-search input::placeholder { color: var(--muted-2); }
.side-search input:focus { background: var(--panel); border-color: var(--primary); box-shadow: var(--ring); }
.side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 2px; }
.side-actions .btn { min-width: 0; padding: 0 6px; }
.side-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px 2px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.side-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: 99px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}
.room-list { display: flex; flex-direction: column; gap: 2px; }
.room-item {
  position: relative;
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 9px;
  border-radius: 13px;
  text-align: left;
  transition: background-color 0.15s ease;
}
.room-item:hover { background: var(--panel-2); }
.room-item.is-active { background: var(--primary-soft); }
.room-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 13px;
  bottom: 13px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.room-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #6ea6ff, #2f7cf6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}
.room-icon .icon { width: 20px; height: 20px; stroke-width: 2; }
.room-item-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.room-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.room-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}
.room-time { flex: 0 0 auto; font-size: 10px; color: var(--muted-2); }
.room-item-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.room-preview {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.35;
}
.room-preview .preview-sender { color: var(--text-soft); }
.room-side-meta { flex: 0 0 auto; display: flex; align-items: center; gap: 5px; }
.room-member-count { font-size: 9.5px; color: var(--muted-2); }
.unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: 99px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(47, 124, 246, 0.25);
}
.room-empty {
  padding: 22px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.room-empty .icon { width: 28px; height: 28px; color: var(--muted-2); margin-bottom: 4px; display: block; margin-inline: auto; }
.side-note { padding: 2px 7px 8px; color: var(--muted); font-size: 11.5px; line-height: 1.65; }
.mini-agent-list { display: flex; flex-direction: column; gap: 2px; }
.mini-agent {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  border-radius: 11px;
  text-align: left;
  transition: background-color 0.15s ease;
}
.mini-agent:hover { background: var(--panel-2); }
.mini-agent .avatar { width: 30px; height: 30px; font-size: 11px; }
.mini-agent-info { min-width: 0; display: flex; flex-direction: column; gap: 1px; flex: 1; }
.mini-agent-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-agent-tag { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-empty { padding: 18px 8px; text-align: center; color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; }
.settings-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 12.5px;
  text-align: left;
}
.settings-nav button:hover { background: var(--panel-2); }
.settings-nav button.is-active { background: var(--primary-soft); color: var(--primary); }
.settings-nav .icon { width: 17px; height: 17px; color: var(--muted); }
.settings-nav button.is-active .icon { color: var(--primary); }
.side-note-card {
  margin: 10px 4px 0;
  padding: 12px;
  border-radius: 13px;
  background: var(--agent-soft);
  color: var(--agent);
}
.side-note-card .icon { width: 17px; height: 17px; }
.side-note-card p { margin-top: 6px; font-size: 11.5px; line-height: 1.6; color: var(--text-soft); }

.sidebar-foot {
  flex: 0 0 auto;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.self-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.self-card:hover { border-color: var(--border-strong); background: var(--panel); }
.self-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.self-info strong { font-size: 12.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.self-info small { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.self-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
  flex: 0 0 auto;
}
.self-logout { width: 30px; height: 30px; border-radius: 8px; }
.self-logout .icon { width: 15px; height: 15px; }

/* --------------------------------------------------------------- avatar */
.avatar {
  --avatar-bg: linear-gradient(135deg, #7eb3ff, #2f7cf6);
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--avatar-bg);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  user-select: none;
  overflow: visible;
}
.avatar-initial { line-height: 1; transform: translateY(0.02em); }
.avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 50%;
  background: var(--panel-3);
}
.avatar.has-photo .avatar-initial { visibility: hidden; }
.avatar .ai-corner { z-index: 2; }
.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar-md { width: 38px; height: 38px; font-size: 14px; }
.avatar-lg { width: 48px; height: 48px; font-size: 17px; }
.avatar-xl { width: 64px; height: 64px; font-size: 23px; }
.avatar .ai-corner {
  position: absolute;
  right: -3px;
  bottom: -2px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel);
  color: var(--agent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.avatar .ai-corner .icon { width: 9px; height: 9px; stroke-width: 2.2; }
.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted-2);
}
.status-dot.is-online { background: var(--success); box-shadow: 0 0 0 2.5px var(--success-soft); }
.status-dot.is-thinking { background: var(--primary); box-shadow: 0 0 0 2.5px var(--primary-soft); animation: dot-pulse 1.4s ease-in-out infinite; }
.status-dot.is-error { background: var(--danger); box-shadow: 0 0 0 2.5px var(--danger-soft); }
.status-dot.is-offline { background: var(--muted-2); }

/* -------------------------------------------------------------- chat col */
.center-column { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--chat-bg); }
.chat-view {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--chat-bg);
}
.chat-header {
  flex: 0 0 auto;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.chat-head-main { min-width: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.chat-title-row { min-width: 0; display: flex; align-items: center; gap: 7px; }
.chat-hash {
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
}
.chat-title {
  min-width: 0;
  max-width: min(46vw, 480px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.chat-subtitle {
  min-width: 0;
  padding-left: 32px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
}
.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.conn-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.conn-pill.is-connected { color: var(--success); background: var(--success-soft); }
.conn-pill.is-connecting { color: var(--warning); background: var(--warning-soft); }
.conn-pill.is-connecting .conn-dot { animation: dot-pulse 1.2s ease-in-out infinite; }
.conn-pill.is-disconnected { color: var(--danger); background: var(--danger-soft); }
.chat-head-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.chat-head-actions .icon-btn { width: 38px; height: 38px; }

/* ---------------------------------------------------------- search bar */
.search-bar {
  position: relative;
  flex: 0 0 auto;
  padding: 9px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 25;
}
.search-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 6px 0 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-bar-inner:focus-within { border-color: var(--primary); box-shadow: var(--ring); background: var(--panel); }
.search-bar-icon { width: 16px; height: 16px; color: var(--muted-2); }
.search-bar-inner input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
}
.search-bar-inner input::placeholder { color: var(--muted-2); }
.search-count { font-size: 11px; color: var(--muted); white-space: nowrap; }
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 20px;
  right: 20px;
  max-height: min(440px, 60vh);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow-md);
  z-index: 30;
  animation: pop-in 0.16s ease;
}
.search-result {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  text-align: left;
  transition: background-color 0.13s ease;
}
.search-result:hover { background: var(--panel-2); }
.search-result-main { min-width: 0; flex: 1; }
.search-result-head { display: flex; align-items: center; gap: 7px; margin-bottom: 2px; }
.search-result-name { font-size: 12px; font-weight: 650; color: var(--text); }
.search-result-time { font-size: 10px; color: var(--muted-2); }
.search-result-text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.search-result mark { background: rgba(47, 124, 246, 0.18); color: var(--primary); border-radius: 3px; padding: 0 1px; }
.search-empty { padding: 24px 16px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.7; }
.search-empty .icon { display: block; margin: 0 auto 6px; width: 24px; height: 24px; color: var(--muted-2); }
.search-loading { display: flex; justify-content: center; padding: 18px; }

/* ------------------------------------------------------------- chat body */
.chat-body { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.chat-placeholder {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px 24px 90px;
}
.placeholder-art { position: relative; width: 116px; height: 116px; display: grid; place-items: center; margin-bottom: 22px; }
.placeholder-art img { position: relative; z-index: 1; border-radius: 22px; box-shadow: 0 18px 40px rgba(47, 124, 246, 0.24); }
.placeholder-halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 124, 246, 0.18), transparent 68%);
  animation: breathe 4.5s ease-in-out infinite;
}
.chat-placeholder h2 { font-size: 22px; letter-spacing: -0.025em; }
.chat-placeholder > p {
  max-width: 460px;
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--muted);
}
.placeholder-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: center; margin-top: 22px; }
.placeholder-tip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 24px !important;
  padding: 7px 12px;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 11.5px !important;
  color: var(--muted) !important;
}
.placeholder-tip .icon { width: 14px; height: 14px; color: var(--agent); }
.chat-view.is-empty .message-scroller,
.chat-view.is-empty .composer-zone,
.chat-view.is-empty .scroll-bottom { display: none; }
.chat-view:not(.is-empty) .chat-placeholder { display: none; }

.message-scroller {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  padding: 22px 22px 16px;
}
.message-stream {
  width: min(100%, 980px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100%;
  justify-content: flex-end;
  padding-bottom: 2px;
}
.chat-loading { display: flex; flex-direction: column; gap: 16px; padding: 20px 14px; }
.chat-loading-row { display: flex; gap: 10px; align-items: flex-start; }
.chat-loading-row.is-own { flex-direction: row-reverse; }
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--panel-3);
  border-radius: 8px;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
@media (prefers-color-scheme: dark) {
  .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent); }
}
.skeleton-avatar { width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; }
.skeleton-bubble { height: 58px; border-radius: 14px; width: min(320px, 62vw); }
.chat-loading-row.is-own .skeleton-bubble { width: min(230px, 50vw); }
.skeleton-bubble.short { height: 36px; width: min(180px, 36vw); }

/* ------------------------------------------------------------ messages */
.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 0 4px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  user-select: none;
}
.date-divider::before,
.date-divider::after {
  content: "";
  flex: 1;
  max-width: 220px;
  height: 1px;
  background: var(--border);
}
.date-chip {
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.message-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
  position: relative;
  animation: message-in 0.18s ease both;
}
.message-row.is-own { flex-direction: row-reverse; }
.message-row.is-continuation { margin-top: -8px; }
.message-row.is-continuation .msg-avatar { visibility: hidden; height: 0; width: 38px; }
.message-row.is-continuation .msg-meta { display: none; }
.msg-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--avatar-bg, linear-gradient(135deg, #8eb9ff, #2f7cf6));
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  user-select: none;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.msg-avatar .avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 50%;
  background: var(--panel-3);
}
.msg-avatar.has-photo .avatar-initial { visibility: hidden; }
.msg-avatar .ai-corner {
  position: absolute;
  right: -3px;
  bottom: -2px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel);
  color: var(--agent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  z-index: 2;
}
.msg-avatar .ai-corner .icon { width: 9px; height: 9px; stroke-width: 2.2; }
.msg-main {
  min-width: 0;
  max-width: min(68%, 680px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: relative;
}
.message-row.is-own .msg-main { align-items: flex-end; }
.msg-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0 5px 4px;
  font-size: 11px;
  line-height: 1.3;
  color: var(--muted);
}
.message-row.is-own .msg-meta { justify-content: flex-end; }
.msg-sender { font-size: 12px; font-weight: 650; color: var(--text-soft); }
.msg-tag { color: var(--muted); font-size: 10.5px; }
.msg-kind {
  padding: 0 5px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  border-radius: 5px;
  background: var(--agent-soft);
  color: var(--agent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.msg-kind.is-human { background: var(--panel-3); color: var(--muted); }
.msg-time { font-size: 10px; color: var(--muted-2); }
.msg-bubble {
  position: relative;
  min-width: 42px;
  max-width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 5px 16px 16px 16px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  box-shadow: var(--shadow-xs);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.message-row.is-own .msg-bubble {
  border-color: transparent;
  border-radius: 16px 5px 16px 16px;
  background: linear-gradient(135deg, #3a85f8, #2f7cf6);
  color: #fff;
  box-shadow: 0 5px 16px rgba(47, 124, 246, 0.2);
}
.message-row.is-agent .msg-bubble { border-top-color: color-mix(in srgb, var(--agent) 30%, var(--border)); }
.message-row.is-own.is-agent .msg-bubble { border-color: transparent; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-text:empty { display: none; }
.msg-text + .msg-files { margin-top: 7px; }
.msg-text strong { font-weight: 700; }
.msg-text em { font-style: italic; }
.msg-text del { text-decoration: line-through; opacity: 0.75; }
.msg-text .md-p { margin: 0; }
.msg-text .md-p + .md-p { margin-top: 6px; }
.msg-text .md-heading { margin: 8px 0 4px; font-weight: 700; line-height: 1.35; }
.msg-text .md-heading:first-child { margin-top: 0; }
.msg-text .md-h1 { font-size: 1.35em; }
.msg-text .md-h2 { font-size: 1.22em; }
.msg-text .md-h3 { font-size: 1.12em; }
.msg-text .md-h4 { font-size: 1.05em; }
.msg-text .md-h5, .msg-text .md-h6 { font-size: 1em; }
.msg-text .md-list { margin: 5px 0; padding-left: 1.35em; }
.msg-text .md-list:first-child { margin-top: 0; }
.msg-text .md-list:last-child { margin-bottom: 0; }
.msg-text .md-list li { margin: 1px 0; }
.msg-text .md-list li::marker { color: var(--muted); }
.msg-text .md-quote {
  margin: 6px 0;
  padding: 2px 0 2px 10px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-soft);
}
.msg-text .md-quote:first-child { margin-top: 0; }
.msg-text .md-quote:last-child { margin-bottom: 0; }
.msg-text .md-hr { border: 0; border-top: 1px solid var(--border); margin: 8px 0; }
.msg-text .math-inline {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  vertical-align: middle;
  white-space: normal;
}
.msg-text .math-inline .katex { font-size: 1em; }
.msg-text .md-math-block {
  margin: 8px 0;
  max-width: 100%;
  overflow-x: auto;
}
.msg-text .md-math-block:first-child { margin-top: 0; }
.msg-text .md-math-block:last-child { margin-bottom: 0; }
.msg-text .md-math-block .katex { font-size: 1.05em; }
.msg-text .md-math-block .katex-display { margin: 0; }
.msg-text .md-math-block math[display="block"] {
  display: block;
  margin: 0 auto;
}
.msg-text .math-fallback {
  white-space: pre-wrap;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.9em;
  overflow-wrap: anywhere;
}
.msg-text .md-table-wrap {
  margin: 7px 0;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
}
.msg-text .md-table-wrap:first-child { margin-top: 0; }
.msg-text .md-table-wrap:last-child { margin-bottom: 0; }
.msg-text .md-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92em;
  line-height: 1.45;
}
.msg-text .md-table th,
.msg-text .md-table td {
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.msg-text .md-table th:last-child,
.msg-text .md-table td:last-child { border-right: 0; }
.msg-text .md-table tbody tr:last-child td { border-bottom: 0; }
.msg-text .md-table th { background: var(--panel-2); font-weight: 600; }
.msg-text .md-table .md-align-center { text-align: center; }
.msg-text .md-table .md-align-right { text-align: right; }
.message-row.is-own .msg-text .md-table-wrap {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
}
.message-row.is-own .msg-text .md-table th,
.message-row.is-own .msg-text .md-table td {
  border-right-color: rgba(255, 255, 255, 0.22);
  border-bottom-color: rgba(255, 255, 255, 0.22);
}
.message-row.is-own .msg-text .md-table th { background: rgba(255, 255, 255, 0.14); }
.msg-text > .code-block:first-child { margin-top: 0; }
.msg-text > .code-block:last-child { margin-bottom: 0; }
.message-row.is-own .msg-text .md-quote {
  border-left-color: rgba(255, 255, 255, 0.55);
  color: rgba(255, 255, 255, 0.92);
}
.message-row.is-own .msg-text .md-hr { border-top-color: rgba(255, 255, 255, 0.35); }
.message-row.is-own .msg-text del { opacity: 0.8; }
.msg-text code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--panel-3);
  color: var(--primary-strong);
  font-family: var(--mono);
  font-size: 0.88em;
  border: 1px solid var(--border);
}
.message-row.is-own .msg-text code {
  background: rgba(255, 255, 255, 0.17);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.12);
}
.code-block {
  margin: 7px 0;
  border-radius: 11px;
  background: #141b2a;
  color: #e8eef9;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  max-width: 100%;
}
.code-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 9.5px;
  color: #9eaac2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.code-block pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
  color: #e8eef9;
}
.code-block code, .message-row.is-own .code-block code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.msg-text a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  overflow-wrap: anywhere;
}
.message-row.is-own .msg-text a { color: #fff; text-decoration-color: rgba(255, 255, 255, 0.6); }
.mention-chip {
  display: inline;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 650;
  font-size: 0.92em;
  border: 1px solid rgba(47, 124, 246, 0.1);
  white-space: nowrap;
}
.message-row.is-own .mention-chip {
  background: rgba(255, 255, 255, 0.19);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.08);
}
.mention-chip.is-all { background: var(--agent-soft); color: var(--agent); border-color: rgba(124, 92, 243, 0.12); }
.message-row.is-own .mention-chip.is-all { background: rgba(255, 255, 255, 0.19); color: #fff; }
.msg-reply {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  padding: 5px 9px;
  margin-bottom: 6px;
  border-left: 3px solid var(--primary);
  border-radius: 7px;
  background: rgba(47, 124, 246, 0.065);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.14s ease;
}
.msg-reply:hover { background: rgba(47, 124, 246, 0.11); }
.msg-reply strong { color: var(--primary); font-size: 11px; font-weight: 650; }
.msg-reply span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-soft);
}
.message-row.is-own .msg-reply { border-left-color: rgba(255, 255, 255, 0.7); background: rgba(255, 255, 255, 0.13); color: rgba(255, 255, 255, 0.8); }
.message-row.is-own .msg-reply strong { color: #fff; }
.message-row.is-own .msg-reply span { color: rgba(255, 255, 255, 0.86); }
.msg-files { display: flex; flex-direction: column; gap: 7px; }
.msg-files:first-child { margin-top: 0; }
.msg-image-button {
  display: block;
  max-width: 100%;
  border: none;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-3);
  cursor: zoom-in;
  line-height: 0;
}
.msg-image {
  display: block;
  max-width: 100%;
  max-height: 290px;
  width: auto;
  height: auto;
  object-fit: cover;
  border-radius: 10px;
}
.file-card {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 190px;
  max-width: 330px;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}
.file-card:hover { background: var(--panel); border-color: var(--border-strong); text-decoration: none; }
.message-row.is-own .file-card {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.message-row.is-own .file-card:hover { background: rgba(255, 255, 255, 0.2); }
.file-card-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
}
.file-card-icon .icon { width: 18px; height: 18px; }
.message-row.is-own .file-card-icon { background: rgba(255, 255, 255, 0.17); color: #fff; }
.file-card-info { min-width: 0; display: flex; flex-direction: column; gap: 1px; flex: 1; }
.file-card-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: inherit;
}
.file-card-meta { font-size: 10px; color: var(--muted); }
.message-row.is-own .file-card-meta { color: rgba(255, 255, 255, 0.7); }
.file-card-dl { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; color: var(--muted); flex: 0 0 auto; }
.file-card-dl .icon { width: 14px; height: 14px; }
.file-card:hover .file-card-dl { background: var(--panel-3); color: var(--primary); }
.message-row.is-own .file-card-dl { color: rgba(255, 255, 255, 0.85); }
.message-row.is-own .file-card:hover .file-card-dl { background: rgba(255, 255, 255, 0.15); color: #fff; }
.msg-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
  opacity: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
  transition: opacity 0.14s ease;
}
.message-row:hover .msg-actions,
.message-row:focus-within .msg-actions { opacity: 1; height: auto; pointer-events: auto; }
.msg-action {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  box-shadow: var(--shadow-xs);
  transition: color 0.13s ease, background-color 0.13s ease;
}
.msg-action:hover { color: var(--primary); background: var(--primary-soft); }
.msg-action.is-danger:hover { color: var(--danger); background: var(--danger-soft); }
.msg-action .icon { width: 13px; height: 13px; }
.message-row.is-highlighted .msg-bubble { animation: message-flash 1.6s ease; }
.message-row.is-system-row { justify-content: center; }
.system-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: min(82%, 640px);
  padding: 5px 12px;
  border-radius: 99px;
  background: rgba(123, 132, 154, 0.11);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  line-height: 1.5;
  border: 1px solid transparent;
  overflow-wrap: anywhere;
}
.system-pill .icon { width: 13px; height: 13px; flex: 0 0 auto; }
.message-row.is-system-row.is-continuation { margin-top: -8px; }
.load-more-row { display: flex; justify-content: center; padding: 2px 0 10px; }
.load-more-row .btn { color: var(--muted); background: var(--panel); }
.message-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  min-height: 220px;
  color: var(--muted);
  text-align: center;
  font-size: 12.5px;
  line-height: 1.7;
  padding: 30px;
}
.message-empty .icon { width: 30px; height: 30px; color: var(--muted-2); margin-bottom: 4px; }
.message-empty strong { color: var(--text-soft); font-size: 14px; }

/* scroll-to-bottom */
.scroll-bottom {
  position: absolute;
  z-index: 8;
  right: 22px;
  bottom: 16px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel);
  color: var(--text-soft);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transition: transform 0.15s ease, background-color 0.15s ease;
  animation: pop-in 0.16s ease;
}
.scroll-bottom:hover { transform: translateY(-1px); background: var(--panel-2); }
.scroll-bottom .icon { width: 18px; height: 18px; }
.scroll-unread {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 99px;
  background: var(--primary);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  border: 2px solid var(--chat-bg);
}

/* -------------------------------------------------------------- composer */
.composer-zone {
  position: relative;
  z-index: 9;
  flex: 0 0 auto;
  padding: 8px 22px max(10px, env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.composer-zone.is-disabled { display: none; }
.typing-line {
  min-height: 21px;
  padding: 0 4px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-size: 11.5px;
  line-height: 1.4;
}
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.typing-dots i {
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: currentColor;
  animation: typing-bounce 1.1s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: 0.14s; }
.typing-dots i:nth-child(3) { animation-delay: 0.28s; }
.reply-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
  padding: 7px 8px 7px 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel-2);
}
.reply-mark { width: 3px; align-self: stretch; border-radius: 3px; background: var(--primary); flex: 0 0 auto; }
.reply-content { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.reply-content strong { font-size: 11px; color: var(--primary); font-weight: 650; }
.reply-content span {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-progress {
  margin-bottom: 7px;
  padding: 8px 10px;
  border-radius: 11px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.upload-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.upload-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--text-soft); }
.upload-percent { font-size: 10.5px; color: var(--primary); font-weight: 650; }
.upload-track { height: 3px; border-radius: 99px; background: var(--border); overflow: hidden; }
.upload-bar { height: 100%; width: 0; border-radius: inherit; background: var(--primary); transition: width 0.18s ease; }
.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 5px 6px 5px 7px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}
.composer:focus-within { border-color: var(--primary); box-shadow: var(--ring); background: var(--panel); }
.composer-attach { margin-bottom: 1px; width: 36px; height: 36px; color: var(--muted); }
.composer-attach:hover { color: var(--primary); background: var(--primary-soft); }
.composer-input-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.composer-input {
  width: 100%;
  min-height: 36px;
  max-height: calc(1.55em * 8 + 18px);
  padding: 8px 4px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  resize: none;
  overflow-y: auto;
}
.composer-input::placeholder { color: var(--muted-2); }
.send-btn {
  width: 37px;
  height: 37px;
  flex: 0 0 auto;
  margin-bottom: 1px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #3a85f8, var(--primary));
  color: #fff;
  box-shadow: 0 4px 12px rgba(47, 124, 246, 0.24);
  transition: transform 0.14s ease, opacity 0.14s ease, box-shadow 0.14s ease;
}
.send-btn:hover:not(:disabled) { transform: translateY(-1px) scale(1.03); box-shadow: 0 6px 15px rgba(47, 124, 246, 0.3); }
.send-btn:active:not(:disabled) { transform: scale(0.96); }
.send-btn:disabled { background: var(--border); color: var(--muted-2); box-shadow: none; cursor: default; }
.send-btn .icon { width: 17px; height: 17px; transform: translate(-1px, 1px); }
.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 17px;
  padding: 4px 5px 0;
}
.composer-hint { font-size: 10px; color: var(--muted-2); }
.char-count { font-size: 10px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.char-count.is-near { color: var(--warning); }

/* mention autocomplete */
.mention-popover {
  position: absolute;
  left: -2px;
  bottom: calc(100% + 9px);
  z-index: 45;
  width: min(350px, calc(100vw - 52px));
  max-height: 306px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow-md);
  animation: pop-in 0.14s ease;
}
.mention-head {
  padding: 5px 8px 6px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  border-radius: 9px;
  text-align: left;
  color: var(--text);
}
.mention-item:hover,
.mention-item.is-active { background: var(--primary-soft); }
.mention-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.mention-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-tag { font-size: 10.5px; color: var(--muted); }
.mention-kind {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}
.mention-kind.is-agent { background: var(--agent-soft); color: var(--agent); }
.mention-kind.is-all { background: var(--primary-soft); color: var(--primary); }
.mention-empty { padding: 14px 10px; text-align: center; color: var(--muted); font-size: 11.5px; }

/* -------------------------------------------------------------- right */
.right-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 30;
  transition: transform 0.24s cubic-bezier(0.22, 0.9, 0.3, 1);
}
.right-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  flex: 0 0 auto;
}
.right-content { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.right-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  padding: 13px;
  box-shadow: var(--shadow-xs);
}
.right-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.right-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
}
.right-card-title .icon { width: 14px; height: 14px; color: var(--muted-2); }
.right-card-count { font-size: 10.5px; color: var(--muted-2); }
.invite-card { background: var(--invite-bg); border-color: rgba(47, 124, 246, 0.16); }
.invite-code-row { display: flex; align-items: center; gap: 8px; }
.invite-code {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--primary);
  line-height: 1.55;
  user-select: all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.invite-code-placeholder { font-size: 12px; letter-spacing: 0; color: var(--muted); font-family: var(--font); }
.invite-copy-btn {
  flex: 0 0 auto;
  height: 31px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 9px;
  border: 1px solid rgba(47, 124, 246, 0.22);
  background: var(--panel);
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 600;
}
.invite-copy-btn:hover { background: var(--primary-soft); }
.invite-copy-btn .icon { width: 13px; height: 13px; }
.invite-hint { margin-top: 7px; font-size: 10.5px; line-height: 1.6; color: var(--muted); }
.invite-actions { display: flex; gap: 6px; margin-top: 9px; }
.invite-actions .btn { flex: 1; min-width: 0; padding: 0 6px; }
.invite-actions .icon { width: 14px; height: 14px; }
.member-list { display: flex; flex-direction: column; gap: 1px; margin: 0 -4px; }
.member-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 6px;
  border-radius: 10px;
  text-align: left;
  transition: background-color 0.14s ease;
}
.member-row:hover { background: var(--panel-2); }
.member-row .avatar { width: 32px; height: 32px; font-size: 11.5px; }
.member-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.member-name-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.member-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.member-badge {
  flex: 0 0 auto;
  height: 14px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.member-badge.is-ai { background: var(--agent-soft); color: var(--agent); }
.member-badge.is-owner { background: var(--warning-soft); color: var(--warning); }
.member-sub { display: flex; align-items: center; gap: 6px; min-width: 0; }
.member-tag {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  color: var(--muted);
}
.member-state { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 3px; font-size: 9px; color: var(--muted); }
.member-state.is-thinking { color: var(--primary); }
.member-state.is-offline { color: var(--muted-2); }
.member-state.is-error { color: var(--danger); }
.member-queued { flex: 0 0 auto; font-size: 9px; color: var(--primary); background: var(--primary-soft); padding: 0 4px; border-radius: 4px; }
.member-row .status-dot { width: 6px; height: 6px; }
.member-actions { display: flex; gap: 4px; margin-top: 10px; }
.member-actions .btn { flex: 1; padding: 0 5px; }
.member-actions .icon { width: 14px; height: 14px; }
.right-empty { padding: 18px 8px; text-align: center; color: var(--muted); font-size: 11.5px; line-height: 1.7; }
.right-empty .icon { width: 24px; height: 24px; color: var(--muted-2); display: block; margin: 0 auto 5px; }
.right-loading { display: flex; justify-content: center; padding: 24px; }
.file-list { display: flex; flex-direction: column; gap: 1px; margin: 0 -4px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px;
  border-radius: 9px;
  transition: background-color 0.14s ease;
}
.file-row:hover { background: var(--panel-2); }
.file-row-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-3);
  color: var(--muted);
  overflow: hidden;
}
.file-row-icon .icon { width: 15px; height: 15px; }
.file-row-icon img { width: 100%; height: 100%; object-fit: cover; }
.file-row-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.file-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; font-weight: 550; color: var(--text); }
.file-row-size { font-size: 9.5px; color: var(--muted); }
.file-row-dl { width: 28px; height: 28px; border-radius: 7px; color: var(--muted); display: grid; place-items: center; flex: 0 0 auto; }
.file-row-dl:hover { color: var(--primary); background: var(--primary-soft); }
.file-row-dl .icon { width: 14px; height: 14px; }
.room-info-list { display: flex; flex-direction: column; gap: 8px; }
.room-info-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; font-size: 11px; line-height: 1.5; }
.room-info-line dt { color: var(--muted); flex: 0 0 auto; }
.room-info-line dd { margin: 0; color: var(--text-soft); text-align: right; overflow-wrap: anywhere; }
.room-info-line dd.mono { font-family: var(--mono); font-size: 10px; }
.right-panel-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 22px; text-align: center; color: var(--muted); }
.right-panel-empty .icon { width: 34px; height: 34px; color: var(--muted-2); margin-bottom: 10px; }
.right-panel-empty p { font-size: 12px; line-height: 1.7; }
.right-panel-foot { padding: 12px 14px; border-top: 1px solid var(--border); flex: 0 0 auto; }
.right-panel-foot .btn { width: 100%; }
.right-skeleton { display: flex; flex-direction: column; gap: 12px; padding: 14px; }

/* ------------------------------------------------------------- pages */
.page-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(22px, 3.4vw, 44px) clamp(18px, 3.8vw, 52px) 60px;
  background:
    radial-gradient(circle at 92% -4%, rgba(47, 124, 246, 0.05), transparent 30%),
    var(--bg);
}
.page-inner { width: min(1040px, 100%); margin: 0 auto; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 26px; }
.page-heading { min-width: 0; }
.page-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.page-kicker .icon { width: 14px; height: 14px; }
.page-title { font-size: clamp(24px, 2.4vw, 31px); letter-spacing: -0.03em; line-height: 1.2; }
.page-desc { margin-top: 8px; max-width: 640px; font-size: 13px; line-height: 1.75; color: var(--muted); }
.page-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 170px;
  max-width: 340px;
}
.page-search .icon { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--muted-2); }
.page-search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
}
.page-search input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.page-toolbar-meta { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  padding: 15px 17px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow-xs);
}
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--muted); font-weight: 600; }
.stat-label .icon { width: 14px; height: 14px; }
.stat-value { margin-top: 6px; font-size: 24px; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; }
.stat-sub { margin-top: 4px; font-size: 10.5px; color: var(--muted-2); }
.agent-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.agent-card {
  position: relative;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--panel);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}
.agent-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.agent-card-head { display: flex; align-items: flex-start; gap: 11px; }
.agent-card-head .avatar { width: 44px; height: 44px; font-size: 16px; }
.agent-card-title { min-width: 0; flex: 1; }
.agent-card-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.agent-card-name strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-card-tag { margin-top: 2px; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.agent-status-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 99px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 650;
}
.agent-status-pill.is-online { background: var(--success-soft); color: var(--success); }
.agent-status-pill.is-thinking { background: var(--primary-soft); color: var(--primary); }
.agent-status-pill.is-error { background: var(--danger-soft); color: var(--danger); }
.agent-status-pill.is-offline { background: var(--panel-3); color: var(--muted-2); }
.agent-status-pill .status-dot { width: 5px; height: 5px; box-shadow: none; }
.agent-meta { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 10.5px; color: var(--muted); }
.agent-meta span { display: inline-flex; align-items: center; gap: 4px; }
.agent-meta .icon { width: 12px; height: 12px; }
.agent-card-actions { display: flex; align-items: center; gap: 6px; margin-top: 14px; padding-top: 11px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.agent-card-actions .btn { padding: 0 9px; }
.agent-card-actions .spacer { flex: 1; }
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 52px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: 18px;
  background: var(--panel);
}
.empty-state-art {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--primary-soft);
  color: var(--primary);
  margin-bottom: 14px;
}
.empty-state-art .icon { width: 27px; height: 27px; }
.empty-state h3 { font-size: 16px; letter-spacing: -0.01em; }
.empty-state p { margin-top: 7px; max-width: 420px; font-size: 12.5px; line-height: 1.7; color: var(--muted); }
.empty-state .btn { margin-top: 16px; }
.page-loading { display: flex; flex-direction: column; gap: 12px; }
.page-loading .skeleton { height: 100px; border-radius: 16px; }
.loading-block { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 0; color: var(--muted); font-size: 12.5px; }
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}
.spinner-sm { width: 14px; height: 14px; border-width: 1.8px; }

/* settings */
.settings-stack { width: min(820px, 100%); display: flex; flex-direction: column; gap: 16px; }
.settings-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  scroll-margin-top: 24px;
}
.settings-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.settings-card-head h2 { font-size: 15px; letter-spacing: -0.01em; }
.settings-card-head p { margin-top: 4px; font-size: 11.5px; line-height: 1.6; color: var(--muted); }
.settings-card-head > .icon { width: 18px; height: 18px; color: var(--muted-2); margin-top: 2px; }
.settings-card-body { padding: 20px; }
.settings-form { display: flex; flex-direction: column; gap: 16px; }
.settings-form-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.settings-form-row .field { flex: 1; min-width: 200px; }
.profile-row { display: flex; align-items: center; gap: 16px; }
.profile-preview { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 0 0 auto; }
.profile-preview small { font-size: 9.5px; color: var(--muted); }
.avatar-upload-actions { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.avatar-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.avatar-crop-body { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.avatar-crop-frame {
  width: min(300px, 72vw);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--panel-3);
  box-shadow: inset 0 0 0 1px var(--border);
  touch-action: none;
}
.avatar-crop-canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.avatar-crop-canvas.is-dragging { cursor: grabbing; }
.avatar-crop-note { margin: 0; font-size: 11.5px; line-height: 1.6; color: var(--muted); text-align: center; }
.avatar-crop-zoom { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 320px; font-size: 12px; color: var(--muted); }
.avatar-crop-range { flex: 1; min-width: 0; accent-color: var(--primary); }
.avatar-crop-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; width: 100%; }
.agent-access-body { display: flex; flex-direction: column; gap: 10px; }
.agent-access-list { display: flex; flex-direction: column; gap: 8px; }
.agent-access-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  cursor: pointer;
}
.agent-access-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.agent-access-info strong { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-access-info span { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }
.agent-access-check { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--primary); }
.agent-access-foot { display: flex; align-items: center; justify-content: flex-end; width: 100%; }
.color-swatches { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--border);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.color-swatch:hover { transform: scale(1.08); }
.color-swatch.is-active { box-shadow: 0 0 0 2px var(--primary); transform: scale(1.06); }
.color-input {
  width: 34px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}
.profile-actions { display: flex; align-items: center; gap: 8px; }
.settings-actions-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.danger-zone { border-color: rgba(229, 72, 77, 0.24); }
.danger-zone .settings-card-head { background: var(--danger-soft); }
.api-example { display: flex; flex-direction: column; gap: 12px; }
.code-panel {
  position: relative;
  border-radius: 13px;
  background: #141b2a;
  color: #e8eef9;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.code-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 11px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 10px;
  color: #9eaac2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.code-panel-head .icon-btn { width: 26px; height: 26px; color: #9eaac2; border-radius: 6px; }
.code-panel-head .icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.code-panel-head .icon { width: 13px; height: 13px; }
.code-panel pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.68;
  white-space: pre;
  tab-size: 2;
}
.endpoint-list { display: flex; flex-direction: column; gap: 7px; margin-top: 13px; }
.endpoint-line { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.endpoint-method {
  width: 48px;
  flex: 0 0 auto;
  padding: 1px 0;
  border-radius: 5px;
  text-align: center;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--success);
  background: var(--success-soft);
}
.endpoint-method.post { color: var(--primary); background: var(--primary-soft); }
.endpoint-method.patch { color: var(--warning); background: var(--warning-soft); }
.endpoint-path { font-family: var(--mono); font-size: 10.5px; color: var(--text-soft); overflow-wrap: anywhere; }
.docs-callout {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  margin-top: 16px;
  border-radius: 13px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.docs-callout .icon { width: 20px; height: 20px; color: var(--primary); flex: 0 0 auto; }
.docs-callout div { flex: 1; min-width: 0; }
.docs-callout strong { display: block; font-size: 12px; }
.docs-callout p { margin-top: 2px; font-size: 11px; color: var(--muted); line-height: 1.5; }
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.about-item { padding: 12px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--border); }
.about-item span { display: block; font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.about-item strong { display: block; margin-top: 3px; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.about-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.token-meta { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }
.token-meta .icon { width: 15px; height: 15px; color: var(--primary); }
.token-meta code { font-family: var(--mono); color: var(--text-soft); }
.settings-divider { height: 1px; background: var(--border); margin: 2px 0; }

/* ------------------------------------------------------------- popover */
.popover {
  position: fixed;
  z-index: 200;
  min-width: 196px;
  max-width: 300px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--panel);
  box-shadow: var(--shadow-md);
  animation: pop-in 0.14s ease;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 34px;
  padding: 0 9px;
  border-radius: 8px;
  color: var(--text-soft);
  font-size: 12.5px;
  text-align: left;
  white-space: nowrap;
}
.menu-item:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.menu-item .icon { width: 15px; height: 15px; color: var(--muted); }
.menu-item:hover .icon { color: var(--primary); }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger .icon { color: var(--danger); }
.menu-item.is-danger:hover { background: var(--danger-soft); }
.menu-divider { height: 1px; margin: 5px 4px; background: var(--border); }
.menu-label { padding: 5px 9px 3px; font-size: 9px; color: var(--muted-2); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.member-popover { min-width: 248px; padding: 13px; }
.member-pop-head { display: flex; align-items: center; gap: 10px; }
.member-pop-head .avatar { width: 42px; height: 42px; font-size: 15px; }
.member-pop-head div { min-width: 0; }
.member-pop-head strong { display: block; font-size: 13.5px; }
.member-pop-head span { display: block; margin-top: 1px; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.member-pop-meta { display: flex; flex-direction: column; gap: 5px; margin: 12px 0; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.member-pop-meta div { display: flex; justify-content: space-between; gap: 12px; font-size: 10.5px; }
.member-pop-meta span { color: var(--muted); }
.member-pop-meta strong { font-weight: 600; color: var(--text-soft); text-align: right; }
.member-pop-actions { display: flex; flex-direction: column; gap: 4px; }

/* ---------------------------------------------------------------- modal */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 22, 38, 0.46);
  backdrop-filter: blur(4px);
  animation: fade-in 0.18s ease;
}
.modal-container { position: relative; z-index: 1; width: 100%; display: flex; justify-content: center; pointer-events: none; }
.modal {
  pointer-events: auto;
  width: min(520px, 100%);
  max-height: min(88dvh, 820px);
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.2s cubic-bezier(0.22, 0.9, 0.3, 1);
  overflow: hidden;
}
.modal.is-wide { width: min(620px, 100%); }
.modal.is-narrow { width: min(420px, 100%); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.modal-head-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
}
.modal-head-icon .icon { width: 18px; height: 18px; }
.modal-title-wrap { flex: 1; min-width: 0; padding-top: 1px; }
.modal-title { font-size: 16px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.35; }
.modal-subtitle { margin-top: 4px; font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.modal-close { flex: 0 0 auto; color: var(--muted); }
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px 20px; }
.modal-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}
.modal-foot .btn { min-width: 86px; }
.modal-form { display: flex; flex-direction: column; gap: 15px; }
.modal-note { font-size: 11.5px; line-height: 1.65; color: var(--muted); }
.modal-loading { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 30px 12px; color: var(--muted); font-size: 12px; }
.inline-error { margin-top: 2px; }
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.tabs .tab {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
}
.tabs .tab .icon { width: 14px; height: 14px; }
.tabs .tab:hover { color: var(--text); }
.tabs .tab.is-active { color: var(--primary); background: var(--panel); box-shadow: var(--shadow-xs); }
.agent-choice-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 230px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel-2);
}
.agent-choice {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  border-radius: 8px;
  text-align: left;
  transition: background-color 0.13s ease;
}
.agent-choice:hover { background: var(--panel); }
.agent-choice.is-selected { background: var(--primary-soft); }
.agent-choice .avatar { width: 28px; height: 28px; font-size: 10.5px; }
.agent-choice-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.agent-choice-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-choice-tag { font-size: 10px; color: var(--muted); }
.agent-choice-check {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  background: var(--panel);
  color: transparent;
}
.agent-choice.is-selected .agent-choice-check { background: var(--primary); border-color: var(--primary); color: #fff; }
.agent-choice-check .icon { width: 11px; height: 11px; stroke-width: 2.6; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-soft); cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--primary); }
.code-input {
  width: 100%;
  height: 58px;
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: 13px;
  background: var(--bg);
  color: var(--primary);
  font-family: var(--mono);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.code-input:focus { border-color: var(--primary); background: var(--panel); box-shadow: var(--ring); }
.code-input::placeholder { color: var(--muted-2); font-size: 16px; letter-spacing: 0.05em; font-weight: 500; }
.agent-pick-list { display: flex; flex-direction: column; gap: 3px; max-height: 290px; overflow-y: auto; margin-top: 4px; }
.agent-pick {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  text-align: left;
  transition: background-color 0.13s ease, border-color 0.13s ease;
}
.agent-pick:hover { background: var(--panel-2); border-color: var(--border); }
.agent-pick .avatar { width: 32px; height: 32px; font-size: 11.5px; }
.agent-pick-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.agent-pick-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-pick-tag { font-size: 10px; color: var(--muted); }
.agent-pick .btn { flex: 0 0 auto; }
.modal-empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.7; }
.modal-empty .icon { display: block; width: 28px; height: 28px; margin: 0 auto 8px; color: var(--muted-2); }
.invite-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  margin-bottom: 15px;
  border: 1px solid rgba(47, 124, 246, 0.16);
  border-radius: 12px;
  background: var(--invite-bg);
}
.invite-inline .icon { width: 18px; height: 18px; color: var(--primary); flex: 0 0 auto; }
.invite-inline div { flex: 1; min-width: 0; }
.invite-inline strong { display: block; font-family: var(--mono); letter-spacing: 0.16em; font-size: 13px; color: var(--primary); }
.invite-inline small { display: block; margin-top: 1px; font-size: 10px; color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.warning-box {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border-radius: 11px;
  background: var(--warning-soft);
  color: var(--text-soft);
  border: 1px solid rgba(217, 138, 33, 0.18);
  font-size: 11.5px;
  line-height: 1.65;
}
.warning-box .icon { width: 16px; height: 16px; color: var(--warning); flex: 0 0 auto; margin-top: 1px; }
.warning-box.is-danger { background: var(--danger-soft); border-color: rgba(229, 72, 77, 0.18); }
.warning-box.is-danger .icon { color: var(--danger); }
.token-box {
  position: relative;
  margin-top: 12px;
  padding: 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.token-value {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-all;
  user-select: all;
  padding-right: 40px;
}
.token-copy { position: absolute; right: 8px; top: 8px; }
.confirm-content { padding: 2px 0; }
.confirm-content p { color: var(--text-soft); font-size: 13px; line-height: 1.75; }
.confirm-content .warning-box { margin-top: 12px; }
.modal-success-icon {
  width: 52px;
  height: 52px;
  margin: 4px auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
}
.modal-success-icon .icon { width: 25px; height: 25px; }

/* -------------------------------------------------------------- lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 52px 24px 20px;
  background: rgba(8, 13, 23, 0.9);
  backdrop-filter: blur(6px);
  animation: fade-in 0.16s ease;
}
.lightbox-stage { max-width: min(92vw, 1300px); max-height: calc(100dvh - 140px); display: flex; align-items: center; justify-content: center; }
.lightbox-stage img { max-width: 100%; max-height: calc(100dvh - 140px); border-radius: 12px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); object-fit: contain; }
.lightbox-close { position: absolute; top: 18px; right: 18px; color: #fff; background: rgba(255, 255, 255, 0.1); }
.lightbox-close:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
.lightbox-close .icon { width: 20px; height: 20px; }
.lightbox-foot { display: flex; align-items: center; gap: 16px; margin-top: 14px; color: rgba(255, 255, 255, 0.74); font-size: 11.5px; }
.lightbox-name { max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-foot .btn { color: #fff; border-color: rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08); }
.lightbox-foot .btn:hover { background: rgba(255, 255, 255, 0.16); }

/* ------------------------------------------------------------ drawers */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(13, 22, 38, 0.4);
  backdrop-filter: blur(2px);
  animation: fade-in 0.18s ease;
}
.drawer-backdrop.is-visible { display: block; }

/* --------------------------------------------------------------- docs */
.docs-body {
  overflow: auto;
  background:
    radial-gradient(circle at 100% 0%, rgba(47, 124, 246, 0.07), transparent 30%),
    var(--bg);
  min-height: 100dvh;
}
.docs-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.docs-topbar-inner {
  width: min(1240px, 100%);
  margin: 0 auto;
  min-height: 62px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.docs-brand { display: flex; align-items: center; gap: 9px; color: var(--text); }
.docs-brand:hover { text-decoration: none; }
.docs-brand img { border-radius: 10px; }
.docs-brand strong { font-size: 15px; letter-spacing: -0.02em; }
.docs-brand span { font-size: 10px; color: var(--muted); padding-left: 2px; }
.docs-top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.docs-layout {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 30px 24px 80px;
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  gap: 34px;
  align-items: start;
}
.docs-side { position: sticky; top: 88px; }
.docs-side-title {
  padding: 0 10px 9px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.docs-nav { display: flex; flex-direction: column; gap: 3px; }
.docs-nav button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 11px;
  border-radius: 11px;
  color: var(--text-soft);
  text-align: left;
  font-size: 12.5px;
  border: 1px solid transparent;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.docs-nav button .icon { width: 16px; height: 16px; color: var(--muted); }
.docs-nav button:hover { background: var(--panel); border-color: var(--border); }
.docs-nav button.is-active { background: var(--primary-soft); color: var(--primary); border-color: rgba(47, 124, 246, 0.08); }
.docs-nav button.is-active .icon { color: var(--primary); }
.docs-nav small { display: block; font-size: 10px; font-weight: 400; color: var(--muted); margin-top: 1px; }
.docs-side-card {
  margin-top: 20px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--panel);
}
.docs-side-card strong { display: flex; align-items: center; gap: 5px; font-size: 11px; }
.docs-side-card strong .icon { width: 13px; height: 13px; color: var(--primary); }
.docs-side-card p { margin-top: 5px; font-size: 10.5px; line-height: 1.65; color: var(--muted); }
.docs-side-card a { font-size: 10.5px; display: inline-flex; align-items: center; gap: 4px; margin-top: 7px; }
.docs-side-card a .icon { width: 11px; height: 11px; }
.doc-shell {
  min-width: 0;
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.doc-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 10.5px;
}
.doc-topline .doc-current { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; min-width: 0; }
.doc-topline #doc-meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.doc-topline .icon { width: 13px; height: 13px; color: var(--primary); flex: 0 0 auto; }
.doc-content { padding: clamp(24px, 4vw, 48px); font-size: 14px; line-height: 1.78; color: var(--text-soft); max-width: 900px; }
.doc-content h1,
.doc-content h2,
.doc-content h3,
.doc-content h4,
.doc-content h5,
.doc-content h6 { color: var(--text); line-height: 1.35; letter-spacing: -0.02em; scroll-margin-top: 84px; }
.doc-content h1 { font-size: 29px; margin: 0 0 18px; }
.doc-content h2 { font-size: 21px; margin: 36px 0 13px; padding-top: 5px; border-top: 1px solid var(--border); }
.doc-content h3 { font-size: 17px; margin: 27px 0 9px; }
.doc-content h4 { font-size: 14.5px; margin: 22px 0 7px; }
.doc-content h5 { font-size: 13px; margin: 18px 0 6px; }
.doc-content h6 { font-size: 12px; margin: 16px 0 6px; color: var(--muted); }
.doc-content p { margin: 0 0 13px; }
.doc-content ul,
.doc-content ol { margin: 0 0 15px; padding-left: 24px; }
.doc-content li { margin: 4px 0; }
.doc-content li > ul,
.doc-content li > ol { margin: 4px 0 2px; }
.doc-content a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.doc-content strong { color: var(--text); font-weight: 700; }
.doc-content blockquote {
  margin: 15px 0;
  padding: 10px 15px;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 0 10px 10px 0;
  color: var(--text-soft);
}
.doc-content blockquote p:last-child { margin-bottom: 0; }
.doc-content hr { border: none; height: 1px; background: var(--border); margin: 28px 0; }
.doc-content code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--panel-3);
  color: var(--primary-strong);
  font-family: var(--mono);
  font-size: 0.86em;
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.doc-content pre {
  margin: 0 0 17px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #141b2a;
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow-x: auto;
  line-height: 1.65;
}
.doc-content pre code {
  padding: 0;
  background: none;
  border: none;
  color: #e8eef9;
  font-size: 12px;
  overflow-wrap: normal;
  white-space: pre;
}
.doc-code-wrap { margin: 0 0 17px; border-radius: 12px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.06); }
.doc-code-wrap pre { margin: 0; border: none; border-radius: 0; }
.doc-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
  padding: 4px 8px 4px 14px;
  background: #101725;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.doc-code-lang {
  padding: 0;
  background: none;
  border: none;
  color: #8f9bb3;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--mono);
}
.doc-code-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border-radius: 6px;
  color: #a8b3c7;
  font-size: 10px;
  line-height: 1.3;
  white-space: nowrap;
  transition: background-color 0.14s ease, color 0.14s ease;
}
.doc-code-copy:hover { background: rgba(255, 255, 255, 0.08); color: #eef3fb; }
.doc-code-copy:focus-visible { outline: 2px solid #6ba1ff; outline-offset: 1px; }
.doc-code-copy .icon { width: 12px; height: 12px; }
.doc-code-copy.is-copied { color: #73e3a5; }
.doc-content .doc-task-item { list-style: none; margin-left: -22px; }
.doc-content .doc-task-item > input[type="checkbox"] {
  width: 13px;
  height: 13px;
  margin: 0 5px 0 0;
  vertical-align: -1px;
  accent-color: var(--primary);
}
.doc-image-alt { color: var(--muted); font-style: italic; }
.doc-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 18px;
  font-size: 12.5px;
  line-height: 1.6;
  display: block;
  overflow-x: auto;
}
.doc-content thead { background: var(--panel-2); }
.doc-content th,
.doc-content td { border: 1px solid var(--border); padding: 8px 11px; text-align: left; vertical-align: top; }
.doc-content th { color: var(--text); font-weight: 650; white-space: nowrap; }
.doc-content td { color: var(--text-soft); }
.doc-content tbody tr:nth-child(even) { background: color-mix(in srgb, var(--panel-2) 65%, transparent); }
.doc-content img { max-width: 100%; border-radius: 10px; }
.doc-loading { padding: 42px clamp(24px, 4vw, 48px); display: flex; flex-direction: column; gap: 13px; }
.doc-loading-line { height: 16px; border-radius: 5px; }
.doc-error {
  margin: clamp(24px, 5vw, 56px);
  padding: 38px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: 16px;
  background: var(--panel-2);
}
.doc-error-art {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: var(--warning-soft);
  color: var(--warning);
  margin-bottom: 14px;
}
.doc-error-art .icon { width: 26px; height: 26px; }
.doc-error h2 { font-size: 18px; color: var(--text); }
.doc-error p { margin-top: 8px; max-width: 440px; font-size: 12.5px; line-height: 1.75; color: var(--muted); }
.doc-error-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.doc-footer-note { margin-top: 22px; padding: 0 4px; font-size: 10.5px; color: var(--muted-2); text-align: center; }

/* ------------------------------------------------------------ animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(4px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-4px) scale(0.98); } }
@keyframes message-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes breathe { 0%, 100% { transform: scale(0.92); opacity: 0.7; } 50% { transform: scale(1.08); opacity: 1; } }
@keyframes dot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-3px); opacity: 1; } }
@keyframes float-a { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes float-b { 0%, 100% { transform: translateY(0) translateX(0); } 50% { transform: translateY(7px) translateX(5px); } }
@keyframes message-flash {
  0%, 100% { box-shadow: var(--shadow-xs); }
  20%, 55% { box-shadow: 0 0 0 3px rgba(47, 124, 246, 0.3), var(--shadow-sm); }
}

/* ----------------------------------------------------------- responsive */
@media (max-width: 1240px) {
  :root { --sidebar-w: 276px; --right-w: 286px; }
  .chat-title { max-width: min(34vw, 400px); }
}

@media (max-width: 1040px) {
  :root { --sidebar-w: 262px; --right-w: 274px; }
  .msg-main { max-width: 74%; }
  .auth-orbit { display: none; }
  .agent-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .mobile-only { display: inline-flex !important; }
  .main-layout,
  .main-layout.view-agents,
  .main-layout.view-settings,
  .main-layout.right-collapsed { display: grid; grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 88vw);
    z-index: 60;
    transform: translateX(-102%);
    box-shadow: var(--shadow-lg);
    border-right: none;
    visibility: hidden;
  }
  .sidebar.is-open { transform: none; visibility: visible; }
  .right-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(340px, 92vw);
    z-index: 60;
    transform: translateX(102%);
    box-shadow: var(--shadow-lg);
    border-left: none;
    visibility: hidden;
  }
  .right-panel.is-open { transform: none; visibility: visible; }
  .right-panel-head { display: flex; }
  .center-column { height: 100dvh; }
  .chat-header { padding: 10px 12px; gap: 7px; }
  .chat-title { max-width: min(47vw, 440px); }
  .chat-head-actions { gap: 0; }
  .chat-head-actions .icon-btn { width: 34px; height: 34px; }
  .message-scroller { padding: 16px 14px 12px; }
  .msg-main { max-width: 78%; }
  .composer-zone { padding: 7px 12px max(8px, env(safe-area-inset-bottom)); }
  .composer-foot { padding-inline: 4px; }
  .search-bar { padding: 8px 12px; }
  .search-results { left: 12px; right: 12px; }
  .auth-screen { grid-template-columns: 1fr; overflow-y: auto; height: auto; min-height: 100dvh; }
  .auth-visual { display: none; }
  .auth-panel { min-height: 100dvh; padding: 24px 18px; }
  .page-view { padding: 22px 18px 50px; }
  .page-header { flex-direction: column; gap: 14px; }
  .page-actions { width: 100%; }
  .docs-layout { grid-template-columns: 1fr; padding: 20px 16px 60px; gap: 16px; }
  .docs-side { position: static; }
  .docs-side-title { display: none; }
  .docs-nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .docs-nav button { flex: 0 0 auto; width: auto; padding: 8px 12px; white-space: nowrap; }
  .docs-nav small { display: none; }
  .docs-side-card { display: none; }
  .docs-topbar-inner { padding: 0 16px; }
  .doc-content { padding: 24px 20px; }
  .docs-brand span { display: none; }
}

@media (max-width: 640px) {
  .sidebar { width: 100%; max-width: 100%; }
  .right-panel { width: 100%; max-width: 100%; }
  .chat-header { min-height: 62px; padding: 8px 10px; }
  .chat-title-row { gap: 6px; }
  .chat-hash { width: 22px; height: 22px; font-size: 13px; border-radius: 7px; }
  .chat-title { font-size: 15px; max-width: 42vw; }
  .chat-subtitle { padding-left: 28px; font-size: 10.5px; }
  .conn-pill { height: 19px; padding: 0 6px; font-size: 9px; }
  .chat-head-actions .icon-btn { width: 32px; height: 32px; }
  .chat-head-actions .icon-btn .icon { width: 18px; height: 18px; }
  .msg-main { max-width: 82%; }
  .msg-avatar { width: 32px; height: 32px; font-size: 12px; }
  .message-row { gap: 7px; }
  .message-row.is-continuation .msg-avatar { width: 32px; }
  .msg-bubble { font-size: 13.5px; padding: 8px 11px; border-radius: 5px 14px 14px 14px; }
  .message-row.is-own .msg-bubble { border-radius: 14px 5px 14px 14px; }
  .msg-meta { margin-bottom: 3px; }
  .msg-sender { font-size: 11.5px; }
  .msg-kind { display: none; }
  .message-scroller { padding: 12px 10px 10px; }
  .message-stream { gap: 12px; }
  .date-divider::before, .date-divider::after { max-width: 80px; }
  .msg-actions { opacity: 1; height: auto; pointer-events: auto; margin-top: 2px; }
  .page-title { font-size: 24px; }
  .stats-row, .stat-row { grid-template-columns: 1fr; gap: 8px; }
  .stat-card { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; }
  .stat-value { margin-top: 0; font-size: 20px; }
  .stat-label { font-size: 11px; }
  .stat-sub { display: none; }
  .settings-card-head, .settings-card-body { padding: 15px; }
  .profile-row { align-items: flex-start; gap: 12px; }
  .settings-form-row { flex-direction: column; align-items: stretch; }
  .settings-form-row .field { min-width: 0; }
  .about-grid { grid-template-columns: 1fr; }
  .modal-root { padding: 12px; align-items: flex-end; }
  .modal { max-height: 92dvh; border-radius: 19px; }
  .modal-head { padding: 16px 16px 13px; }
  .modal-body { padding: 15px 16px; }
  .modal-foot { padding: 11px 16px max(12px, env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; min-width: 0; }
  .form-row { grid-template-columns: 1fr; }
  .toast-stack { top: max(10px, env(safe-area-inset-top)); right: 10px; left: 10px; width: auto; }
  .auth-card { padding: 24px 20px; border-radius: 20px; }
  .auth-panel { padding: 18px 14px; }
  .auth-card-head h2 { font-size: 19px; }
  .placeholder-actions { flex-direction: column; width: 100%; max-width: 290px; }
  .placeholder-actions .btn { width: 100%; }
  .chat-placeholder { padding: 24px 16px 70px; }
  .chat-placeholder h2 { font-size: 19px; }
  .scroll-bottom { right: 12px; bottom: 10px; }
  .composer { border-radius: 17px; }
  .composer-hint { font-size: 9px; }
  .mention-popover { width: calc(100vw - 30px); }
  .invite-code { font-size: 19px; letter-spacing: 0.15em; }
  .right-content { padding: 12px; }
  .docs-layout { padding: 14px 10px 50px; }
  .docs-topbar-inner { min-height: 56px; gap: 8px; }
  .docs-top-right { gap: 5px; }
  .docs-top-right .docs-raw-link { display: none; }
  .docs-return { min-height: 30px; padding: 0 9px; font-size: 11.5px; }
  .doc-content { padding: 20px 16px; font-size: 13.5px; }
  .doc-content h1 { font-size: 24px; }
  .doc-content h2 { font-size: 19px; margin-top: 28px; }
  .doc-topline { padding: 9px 16px; }
  .doc-error { margin: 16px; padding: 28px 18px; }
  .lightbox { padding: 52px 12px 16px; }
  .lightbox-name { max-width: 50vw; }
}

@media (max-height: 700px) and (min-width: 901px) {
  .auth-headline { margin-top: 34px; font-size: clamp(32px, 3.5vw, 44px); }
  .auth-feature-list { margin-top: 24px; gap: 13px; }
  .auth-orbit { display: none; }
  .auth-card { padding: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
