:root {
  --bg: #131520;
  --sidebar: #1c2030;
  --panel: #1e2231;
  --panel-strong: #282d41;
  --raised: #30364c;
  --ink: #f1f1f9;
  --text: #e0e1ef;
  --muted: #a9aec4;
  --line: #343a52;
  --line-strong: #505875;
  --brand: #b9afff;
  --brand-strong: #e3ddff;
  --brand-soft: #34305b;
  --warn: #f2c993;
  --danger: #f4adb0;
  --shadow: 0 22px 60px #07091266;
  --stage-light: #29284c;
  --stage-side: #213754;
  --rail: #1b1e2b;
  --chat-wall: #1a1d2a;
  --chat-header: #202435;
  --bubble: #252a3d;
  --own-bubble: #332e56;
  --own-line: #4f4777;
  --action: #a99af9;
  --action-hover: #c0b4ff;
  --action-ink: #201945;
  --online: #87dbb8;
  --warning-surface: #392930;
  --warning-border: #613c47;
  --scrim: #080a16a6;
}

:root[data-theme="light"] {
  --bg: #edf0f8;
  --sidebar: #f5f5fb;
  --panel: #fcfcff;
  --panel-strong: #ececfa;
  --raised: #e3e4f2;
  --ink: #24263b;
  --text: #34384c;
  --muted: #616681;
  --line: #dfe2ef;
  --line-strong: #c7cbe0;
  --brand: #594dc7;
  --brand-strong: #4838af;
  --brand-soft: #eae5ff;
  --warn: #815415;
  --danger: #a2344c;
  --shadow: 0 22px 60px #37346823;
  --stage-light: #dfdcf8;
  --stage-side: #dde9ff;
  --rail: #eff0f8;
  --chat-wall: #fafbff;
  --chat-header: #fdfdff;
  --bubble: #eef0f8;
  --own-bubble: #e9e4ff;
  --own-line: #dbd1ff;
  --action: #594dc7;
  --action-hover: #4b3db7;
  --action-ink: #fff;
  --online: #207b57;
  --control-border: #ccd0e5;
  --warning-surface: #fff0f2;
  --warning-border: #efccd3;
  --scrim: #23233f70;
}

body {
  background: radial-gradient(ellipse at 12% 0%, var(--stage-light), transparent 48%),
    radial-gradient(ellipse at 98% 77%, var(--stage-side), transparent 51%), var(--bg);
}

.app, .app[data-inspector-collapsed="true"] {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  width: min(100%, 1640px);
  margin-inline: auto;
  padding: 13px clamp(15px, 2.4vw, 42px) 18px;
  gap: 11px;
  --nav-width: clamp(340px, 30vw, 417px);
  --app-gutter: clamp(22px, 3vw, 44px);
  --transcript: 870px;
  overflow: clip;
}

.app-chrome, .app-brand, .app-chrome__actions { display: flex; align-items: center; }
.app-chrome {
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 3px 7px;
}
.app-brand { min-width: 0; gap: 10px; white-space: nowrap; }
.app-brand .brand-mark { width: 32px; height: 32px; }
.app-brand strong { font-size: 16px; letter-spacing: -.018em; }
.app-brand strong span { margin-left: 3px; color: var(--muted); font-weight: 550; }
.app-chrome__actions { gap: clamp(12px, 2vw, 26px); }
.chrome-help { color: var(--muted); font-size: 12px; text-decoration: none; white-space: nowrap; }
.chrome-help:hover { color: var(--brand-strong); }
.app-chrome .theme-control select { height: 32px; border-radius: 8px; padding-inline: 8px; }
.app-chrome .status-line {
  min-width: 70px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  background: var(--panel);
}
.app-chrome .live-dot { border-radius: 50%; }
.app-chrome .live-dot.is-online { background: var(--online); box-shadow: 0 0 0 3px color-mix(in srgb, var(--online) 15%, transparent); }

.chat-frame {
  position: relative;
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  isolation: isolate;
  border: 1px solid var(--line);
  border-radius: 19px;
  box-shadow: var(--shadow);
  background: var(--chat-wall);
}

#room-sidebar {
  --agent-rail-width: clamp(99px, 8.3vw, 121px);
  display: grid;
  grid-template-columns: var(--agent-rail-width) minmax(0, 1fr);
  border-radius: 18px 0 0 18px;
  background: var(--sidebar);
}

.agent-roster {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 15px 7px 9px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 18px 0 0 18px;
  background: var(--rail);
  scrollbar-width: thin;
}
.agent-rail__top { display: grid; justify-items: center; gap: 11px; margin-bottom: 3px; padding: 0 3px; }
.agent-rail__top h2 {
  width: 100%;
  border-top: 1px solid var(--line);
  padding-top: 11px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 730;
  text-align: center;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.agent-rail__top .profile-entry {
  display: grid;
  width: 100%;
  justify-items: center;
  padding: 3px 1px;
  gap: 5px;
  border: 1px solid transparent;
  background: transparent;
  text-align: center;
}
.agent-rail__top .profile-entry:hover { background: var(--panel-strong); }
#my-profile-name { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 650; }
#my-profile-avatar .avatar { width: 37px; height: 37px; border-radius: 11px; }
.agent-list { flex: none; gap: 3px; padding: 0; }
.agent-list .empty { text-align: center; font-size: 11px; padding: 6px 2px; }
.agent-item { position: relative; }
.agent-item__details {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 6px;
  padding: 9px 2px 8px;
  text-align: center;
}
.agent-item__portrait { position: relative; display: block; }
.agent-item__portrait .avatar { width: 41px; height: 41px; border-radius: 13px; }
.agent-item__portrait i {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--rail);
  border-radius: 50%;
  background: var(--muted);
}
.agent-item__portrait[data-health="good"] i { background: var(--online); }
.agent-item__portrait[data-health="warn"] i { background: #c98c38; }
.agent-item__portrait[data-health="danger"] i { background: #e66880; }
.agent-item__body { width: 100%; justify-items: center; gap: 4px; }
.agent-item__body strong { max-width: 100%; font-size: 11px; font-weight: 690; }
.agent-item__body .agent-health {
  max-width: 100%;
  border-radius: 5px;
  padding: 2px 4px;
  background: color-mix(in srgb, currentColor 10%, var(--rail));
  line-height: 1.2;
  font-size: 9.5px;
  font-weight: 650;
  white-space: nowrap;
}
.agent-item__body .agent-health--good { color: var(--online); }
.agent-item__body .agent-health .presence, .agent-item__meta { display: none; }
.agent-item__join { position: absolute; top: 5px; right: 2px; width: 23px; min-width: 23px; height: 23px; min-height: 23px; margin: 0; border-radius: 7px; background: var(--panel); }
.agent-rail__add {
  display: grid;
  justify-items: center;
  gap: 5px;
  width: 100%;
  margin-top: 7px;
  padding: 7px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
}
.agent-rail__add span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--brand);
  font-size: 20px;
  font-weight: 450;
}
.agent-rail__add:hover { background: var(--panel-strong); }
.agent-roster__error { padding: 4px 0; font-size: 10px; }

.room-browser { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.room-browser .sidebar__header { gap: 6px; min-height: 66px; padding: 0 14px 0 17px; border: 0; }
.room-browser .sidebar__header h2 { margin-right: auto; font-size: 20px; letter-spacing: -.025em; white-space: nowrap; }
.room-add { border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--brand); font-size: 20px; }
.sidebar__controls { padding: 0 12px 11px; }
.room-search input { height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.sidebar__body { padding: 0 9px 10px; scrollbar-width: thin; }
.room-list { gap: 3px; }
.room-list .empty { padding: 14px 8px; }
.room-item {
  grid-template-columns: auto minmax(0, 1fr) auto;
  display: grid;
  gap: 9px;
  min-height: 62px;
  width: 100%;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
}
.room-item:not(.is-active):hover { background: var(--panel-strong); }
.room-item.is-active { border-color: var(--own-line); background: var(--own-bubble); }
.room-emblem {
  --emblem: #8472dd;
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  border: 1px solid color-mix(in srgb, var(--emblem) 30%, var(--line));
  border-radius: 11px;
  background: linear-gradient(150deg, color-mix(in srgb, var(--emblem) 25%, var(--panel)), color-mix(in srgb, var(--emblem) 13%, var(--panel)));
  color: color-mix(in srgb, var(--emblem) 54%, var(--ink));
  font-size: 16px;
  font-weight: 720;
  flex: none;
}
.room-emblem[data-tone="1"] { --emblem: #608edb; }
.room-emblem[data-tone="2"] { --emblem: #41a58a; }
.room-emblem[data-tone="3"] { --emblem: #d58a54; }
.room-emblem[data-tone="4"] { --emblem: #cd7898; }
.room-item__content { gap: 3px; }
.room-item__content strong { font-size: 13px; font-weight: 690; }
.room-item__preview { font-size: 11.5px; }
.room-item__side { display: grid; justify-items: end; align-content: center; align-self: stretch; gap: 3px; }
.room-item__side time { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.room-item__unread { min-width: 17px; padding: 0 4px; border-radius: 5px; background: var(--action); color: var(--action-ink); }
#approval-inbox { padding-bottom: 6px; }
.approval-entry { display: flex; min-height: 43px; padding: 6px 7px; }
.approval-entry__mark { background: var(--warning-surface); border-radius: 6px; }
.room-browser .sidebar__footer { padding: 9px 11px; grid-template-columns: minmax(0, 1fr) auto; }
.room-browser .friends-entry { min-width: 0; padding-inline: 6px; background: transparent; border-color: transparent; }
.room-browser .friends-entry:hover { background: var(--panel-strong); }
.room-browser #logout { white-space: nowrap; justify-self: end; padding-inline: 5px; }

#listener-alert {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 7px;
  width: 100%;
  margin: 1px 0 9px;
  padding: 9px 8px;
  border: 1px solid var(--warning-border);
  border-radius: 10px;
  background: var(--warning-surface);
  color: var(--danger);
}
#listener-alert:hover { background: color-mix(in srgb, var(--danger) 11%, var(--warning-surface)); }
.listener-alert__text { display: grid; gap: 2px; min-width: 0; }
.listener-alert__text strong { font-size: 11.5px; line-height: 1.2; }
.listener-alert__text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }

.workspace { border-radius: 0 18px 18px 0; overflow: clip; background: var(--chat-wall); }
.workspace__header { gap: 9px; min-height: 70px; padding: 10px var(--app-gutter); background: var(--chat-header); }
.workspace__identity { gap: 11px; }
.workspace__header h1 { color: var(--ink); font-size: clamp(17px, 1.65vw, 23px); line-height: 1.2; letter-spacing: -.027em; }
.workspace__meta { display: flex; gap: 8px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.workspace__meta > :first-child { flex: none; }
.workspace__meta #room-purpose:not([hidden])::before { content: "·"; margin-right: 8px; }
.workspace__actions { gap: 6px; }
.workspace__actions :is(.button, .icon-button) { border-radius: 8px; white-space: nowrap; }
#toggle-rooms { position: relative; }
#room-drawer-unread {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 14px;
  padding-inline: 2px;
  border: 1px solid var(--chat-header);
  border-radius: 5px;
  background: var(--action);
  color: var(--action-ink);
  font: 700 9px/13px system-ui, sans-serif;
  text-align: center;
}
#toggle-inspector { display: flex; min-height: 31px; width: auto; gap: 6px; padding-inline: 8px; border: 1px solid var(--line); font-size: 11px; }
#toggle-inspector[aria-expanded="true"] { background: var(--brand-soft); color: var(--brand-strong); }
#toggle-inspector[data-pending="true"]::after { border-radius: 50%; }
#new-task:hover, #invite-member:hover { background: var(--panel-strong); }
.timeline { scrollbar-width: thin; }
.timeline__content { padding: 23px 0 13px; }
.timeline__date, .timeline__unread { font-size: 11px; }
.timeline__date { gap: 15px; margin-bottom: 20px; }
.timeline__unread { margin: 9px 0 20px; }
.empty-state__mark { width: 58px; height: 58px; border: 1px solid var(--own-line); border-radius: 15px; color: var(--brand); background: var(--brand-soft); }
.message { gap: 10px; margin-bottom: 17px; }
.message .avatar { width: 36px; height: 36px; border-radius: 11px; }
.message__body { display: flex; flex-direction: column; align-items: start; max-width: min(100% - 47px, 690px); }
.message__header { margin: 0 0 5px; gap: 7px; }
.message__header strong { font-size: 13px; }
.message__header time { font-size: 10.5px; }
.message__role { border-radius: 5px; padding: 1px 5px; background: var(--panel-strong); color: var(--brand-strong); font-size: 10px; }
.message__bubble { min-width: 0; max-width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 3px 13px 13px 13px; background: var(--bubble); }
.message__text { font-size: 14px; line-height: 1.66; }
.message__quote { max-width: 100%; display: grid; gap: 2px; margin: 0 0 7px; padding: 1px 0 1px 8px; border-left: 2px solid var(--brand); color: var(--muted); font-size: 11px; }
.message__quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message--own { justify-content: flex-end; }
.message--own > :first-child { order: 1; }
.message--own .message__body { align-items: end; }
.message--own .message__header { justify-content: flex-end; }
.message--own .message__bubble { border-color: var(--own-line); border-radius: 13px 3px 13px 13px; background: var(--own-bubble); }
.message--result .message__text { border-left: 2px solid var(--brand); padding-left: 9px; }
.message--system { opacity: .85; }
.message--system .message__bubble { background: transparent; }
.message__receipt { margin-top: 2px; min-height: 20px; padding: 0 4px; font-size: 10px; }

.composer {
  position: relative;
  gap: 2px;
  width: min(var(--transcript), calc(100% - 2 * var(--app-gutter)));
  margin: 7px auto 16px;
  padding: 9px 10px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  box-shadow: 0 5px 15px color-mix(in srgb, var(--ink) 4%, transparent);
  background: var(--panel);
}
.composer:focus-within { border-color: var(--brand); }
.composer textarea { min-height: 42px; padding-inline: 3px; font-size: 13px; }
.composer__footer { padding-top: 4px; }
.composer__error { padding: 2px 3px; overflow-wrap: anywhere; }
.composer__mention { border-radius: 6px; }
#send-message, :root[data-theme="light"] #send-message {
  min-height: 31px;
  border: 0;
  border-radius: 7px;
  padding-inline: 9px;
  background: var(--action);
  color: var(--action-ink);
}
#send-message:hover:not(:disabled), :root[data-theme="light"] #send-message:hover:not(:disabled) { background: var(--action-hover); }

@media (min-width: 961px) {
  .app:not([data-inspector-collapsed="true"]) .chat-frame {
    grid-template-columns: var(--nav-width) minmax(0, 1fr) clamp(224px, 23vw, 336px);
  }
  .app:not([data-inspector-collapsed="true"]) .workspace { border-radius: 0; }
  .inspector {
    border-radius: 0 18px 18px 0;
    background: var(--panel);
  }
}
.inspector__tabs { background: var(--panel-strong); }
.inspector__section { scrollbar-width: thin; }
.task { border-radius: 9px; }
.task__actions .button { border-radius: 6px; }

.dialog {
  width: min(462px, calc(100vw - 26px));
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  scrollbar-width: thin;
}
.dialog::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
.dialog--wide { width: min(650px, calc(100vw - 26px)); }
.dialog > form { padding: 17px 20px 15px; }
.dialog__header {
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
  padding: 9px 17px;
}
.dialog > form > .dialog__header { margin: -17px -20px 3px; }
.dialog__header h2 { font-size: 17px; letter-spacing: -.02em; }
.dialog__header .icon-button { border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.dialog .field input:not([type="file"]), .dialog .field textarea, .dialog .field select, #agent-platform-search { border-radius: 8px; background: var(--chat-header); }
.dialog__actions { border-top: 1px solid var(--line); padding-top: 11px; }
.dialog .button { border-radius: 7px; }
.dialog .button--primary { border-color: transparent; background: var(--action); color: var(--action-ink); }
.dialog .button--primary:hover:not(:disabled) { background: var(--action-hover); }
.profile-dialog { width: min(492px, calc(100vw - 26px)); }
.profile-card { border-radius: 11px; background: linear-gradient(120deg, var(--brand-soft), var(--chat-header) 76%); padding: 12px; }
#profile-form .profile-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 11px 15px;
}
#profile-form .profile-card .field { grid-column: 2; }
#profile-form .profile-card__avatar { grid-row: span 2; }
#profile-form .profile-upload { grid-column: 2; }
.profile-card__avatar .avatar { border-radius: 16px; }
.profile-social__switch { background: var(--panel-strong); border-radius: 8px; padding: 8px; }
.friends-content section { border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; background: var(--chat-header); }
.friends-list li:last-child { border-bottom: 0; }
.receipt-dialog { width: min(620px, calc(100vw - 26px)); }
.receipt-dialog__groups { gap: 10px; }
.receipt-group { border-radius: 10px; overflow: hidden; }
.receipt-group h3 { color: var(--brand-strong); font-size: 13px; }
.agent-platform-picker { border-radius: 10px; background: var(--panel-strong); }
.agent-platform-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.agent-platform-option {
  flex-direction: column;
  min-height: 72px;
  justify-content: center;
  border-radius: 9px;
  background: var(--chat-header);
  text-align: center;
  padding: 6px;
}
.agent-platform-option .avatar { width: 29px; height: 29px; }
.agent-platform-option--custom { flex-direction: row; min-height: 37px; }
.agent-platform-option[aria-pressed="true"] { background: var(--brand-soft); }
.invite-result { border-radius: 9px; }

@media (max-width: 1040px) {
  .inspector-label, .workspace__meta #room-purpose { display: none; }
  .workspace__actions #invite-member { font-size: 0; padding: 0 7px; }
  .workspace__actions #invite-member::before { content: "邀请"; font-size: 11px; }
}

@media (max-width: 960px) {
  .app, .app[data-inspector-collapsed="true"] { --nav-width: 311px; --app-gutter: 17px; }
  .chat-frame { isolation: auto; }
  #room-sidebar { --agent-rail-width: 97px; }
  .inspector { background: var(--panel); }
}

@media (max-width: 720px) {
  .app, .app[data-inspector-collapsed="true"] { --app-gutter: 12px; padding: 0; gap: 0; }
  .app-chrome { padding: 5px 12px; min-height: 48px; border-bottom: 1px solid var(--line); }
  .app-brand { gap: 6px; }
  .app-brand .brand-mark { width: 25px; height: 25px; }
  .app-brand strong { font-size: 13px; }
  .app-chrome__actions { gap: 7px; }
  .app-chrome .theme-control label, .chrome-help, .app-chrome .status-line { display: none; }
  .app-chrome .theme-control select { height: 27px; font-size: 11px; }
  .chat-frame { grid-template-columns: minmax(0, 1fr); border: 0; border-radius: 0; box-shadow: none; isolation: auto; }
  .workspace { border-radius: 0; }
  #room-sidebar { display: none; position: fixed; inset: 0 auto 0 0; z-index: 5; border-radius: 0; width: min(360px, calc(100% - 36px)); box-shadow: var(--shadow); }
  .app[data-drawer="rooms"] #room-sidebar { display: grid; }
  #close-rooms, #toggle-rooms { display: grid; }
  #close-rooms { margin-left: 0; }
  .agent-roster { border-radius: 0; }
  .workspace__header { min-height: 55px; padding: 6px 10px; }
  .workspace__identity, .workspace__actions { gap: 5px; }
  .workspace__header .room-emblem { width: 30px; height: 30px; font-size: 13px; border-radius: 8px; }
  .workspace__header h1 { font-size: 15px; }
  .workspace__meta { font-size: 9px; }
  #new-task { font-size: 11px; padding-inline: 5px; }
  #toggle-inspector { padding-inline: 5px; }
  .timeline__content { padding-top: 16px; }
  .message { gap: 7px; }
  .message .avatar { width: 29px; height: 29px; border-radius: 8px; }
  .message__body { max-width: calc(100% - 37px); }
  .message__text { font-size: 12.5px; }
  .composer { margin-bottom: max(9px, env(safe-area-inset-bottom)); }
  #composer-hint { display: none; }
}
@media (max-width: 470px) {
  .agent-platform-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workspace__header .room-emblem { display: none; }
}

@media (max-width: 380px) {
  #profile-form .profile-card { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  #profile-form .profile-card .field, #profile-form .profile-upload { grid-column: 1; width: 100%; }
  #profile-form .profile-card__avatar { grid-row: auto; }
}
