:root {
  color-scheme: dark;
  --bg: #0b0a0f;
  --surface-1: #111016;
  --surface-2: #17151d;
  --surface-3: #1d1a24;
  --surface-hover: #211e28;
  --surface-active: #262130;
  --border: #2b2832;
  --border-strong: #3a3544;
  --text: #f3f0f6;
  --text-secondary: #b5aebb;
  --text-muted: #8c8494;
  --accent: #8b70e8;
  --accent-hover: #9b82ed;
  --accent-pressed: #765bcf;
  --accent-soft: #201a35;
  --success: #57b994;
  --success-soft: #12261f;
  --warning: #d9aa5b;
  --warning-soft: #2a2114;
  --danger: #de7080;
  --danger-soft: #2a171c;
  --info: #77a8dd;
  --shadow-menu: 0 16px 44px rgba(0, 0, 0, 0.34);
  --shadow-modal: 0 28px 80px rgba(0, 0, 0, 0.48);
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --sidebar-width: 288px;
  --admin-nav-width: 244px;
  --content-width: 920px;
  --control-height: 42px;
  --ease: 160ms ease;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
textarea,
select {
  margin: 0;
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a {
  color: inherit;
}

svg {
  display: block;
}

::selection {
  background: rgba(139, 112, 232, 0.34);
  color: #fff;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: #3b3742;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: #4b4653;
  background-clip: padding-box;
}

.hidden {
  display: none !important;
}

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

.eyebrow {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.brand-large {
  font-size: 19px;
}

.brand-mark {
  position: relative;
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  overflow: hidden;
  border-radius: 9px;
  background: var(--accent);
}

.brand-mark::before,
.brand-mark::after {
  display: none;
}

.brand-mark i {
  display: none;
}

.brand-mark svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Authentication */

.auth-page {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(420px, 1.05fr) minmax(420px, 0.95fr);
  overflow: auto;
  background: var(--bg);
}

.auth-visual {
  position: relative;
  min-height: 620px;
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: clamp(36px, 5vw, 68px);
  border-right: 1px solid var(--border);
  background: var(--surface-1);
}

.auth-copy {
  width: min(660px, 100%);
  margin: clamp(58px, 10vh, 112px) 0 0;
  padding: 0;
}

.auth-kicker,
.auth-form-head > span {
  display: block;
  margin-bottom: 11px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.auth-copy h1 {
  max-width: 660px;
  margin: 0;
  color: var(--text);
  font-size: clamp(38px, 4.2vw, 54px);
  font-weight: 650;
  line-height: 1.04;
  letter-spacing: -0.055em;
}

.auth-copy h1 em {
  color: var(--text);
  font-style: normal;
  font-weight: inherit;
}

.auth-copy p {
  max-width: 560px;
  margin: 24px 0 0;
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.7;
}

.auth-orb {
  display: none;
}

.auth-note {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}

.auth-note > svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-note > span,
.auth-note b,
.auth-note small {
  display: block;
}

.auth-note b {
  color: var(--text-secondary);
  font-weight: 650;
}

.auth-note small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.auth-feature-list {
  display: grid;
  gap: 12px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.auth-feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.auth-feature-list li > span {
  width: 32px;
  height: 32px;
  display: grid;
  flex: 0 0 32px;
  place-items: center;
  border: 1px solid #49415e;
  border-radius: 9px;
  background: var(--accent-soft);
  color: #bbaaf0;
}

.auth-feature-list svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-feature-list b,
.auth-feature-list small {
  display: block;
}

.auth-feature-list b {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.auth-feature-list small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.auth-product-preview {
  width: min(600px, 100%);
  margin-top: 34px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
}

.preview-head {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
}

.preview-head > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.preview-head b {
  flex: 1;
  color: var(--text);
  font-weight: 600;
}

.preview-head small {
  color: var(--text-muted);
  font-size: 11px;
}

.preview-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px 2px;
}

.preview-message > i {
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface-2);
}

.preview-message.assistant > i {
  border-color: #4b4163;
  background: var(--accent-soft);
}

.preview-message > span {
  min-width: 0;
  flex: 1;
}

.preview-message b,
.preview-message em {
  display: block;
}

.preview-message b {
  margin-bottom: 7px;
  color: var(--text-secondary);
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
}

.preview-message em {
  width: 72%;
  height: 6px;
  margin-top: 5px;
  border-radius: 999px;
  background: #302d35;
}

.preview-message em:nth-of-type(2) {
  width: 92%;
}

.preview-message em:nth-of-type(3) {
  width: 54%;
}

.preview-composer {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px;
  padding: 6px 7px 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--text-muted);
  font-size: 11px;
}

.preview-composer span {
  flex: 1;
}

.preview-composer i {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-style: normal;
}

.auth-form-wrap {
  min-height: 620px;
  display: grid;
  place-items: center;
  padding: clamp(28px, 5vw, 64px);
  background: var(--bg);
}

.auth-form {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface-1);
}

.auth-form h2 {
  margin: 0 0 7px;
  color: var(--text);
  font-size: 30px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.auth-form > div > p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
}

.auth-form-head p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
}

.login-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mobile-brand {
  display: none;
}

.form-foot {
  margin: 0;
  color: var(--text-muted) !important;
  font-size: 12px;
  line-height: 1.55;
  text-align: center;
}

/* Shared controls */

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  flex: 0 0 40px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  transition: color var(--ease), background var(--ease), border-color var(--ease);
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:hover {
  border-color: var(--border);
  background: var(--surface-hover);
  color: var(--text);
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: var(--control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  transition: color var(--ease), background var(--ease), border-color var(--ease);
}

.primary-button > svg,
.secondary-button > svg,
.danger-button > svg,
.text-button > svg,
.inline-action > svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.primary-button:active {
  border-color: var(--accent-pressed);
  background: var(--accent-pressed);
}

.secondary-button {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-secondary);
}

.secondary-button:hover {
  border-color: #50495c;
  background: var(--surface-hover);
  color: var(--text);
}

.danger-button {
  border: 1px solid #593038;
  background: var(--danger-soft);
  color: #f09aa7;
}

.danger-button:hover {
  border-color: #80404c;
  background: #321a20;
  color: #ffc0c9;
}

.text-button {
  min-height: 32px;
  padding: 4px 7px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.text-button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.inline-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 550;
}

.field input,
.field textarea,
.field select,
.form-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  outline: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  transition: border-color var(--ease), background var(--ease);
}

.field input::placeholder,
.field textarea::placeholder,
.form-input::placeholder {
  color: #756e7d;
}

.field input:hover,
.field textarea:hover,
.field select:hover,
.form-input:hover {
  border-color: #504a59;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.form-input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(139, 112, 232, 0.18);
  outline-offset: 0;
}

.field textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.55;
}

.field small {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
}

.input-action {
  position: relative;
  display: flex;
}

.input-action input {
  padding-right: 48px;
}

.input-action .icon-button {
  position: absolute;
  top: 2px;
  right: 2px;
}

.password-toggle {
  border-radius: var(--radius-sm);
}

.notice {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.notice.error {
  border-color: #5a3038;
  background: var(--danger-soft);
  color: #f0a2ad;
}

.notice.success {
  border-color: #285444;
  background: var(--success-soft);
  color: #8dd5b8;
}

/* Main application shell */

.app-shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  overflow: hidden;
  background: var(--bg);
}

.sidebar {
  position: relative;
  z-index: 40;
  width: var(--sidebar-width);
  height: 100%;
  display: flex;
  flex: 0 0 var(--sidebar-width);
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  border-right: 1px solid var(--border);
  background: var(--surface-1);
}

.sidebar-head {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 12px;
}

.new-chat-button {
  position: relative;
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  transition: background var(--ease), border-color var(--ease);
}

.new-chat-button:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.new-chat-button > b {
  flex: 1;
  font-weight: 650;
  text-align: left;
}

.new-chat-button.loading .new-chat-icon {
  animation: spin 0.8s linear infinite;
}

.new-chat-icon {
  width: 24px;
  height: 24px;
  display: grid;
  flex: 0 0 24px;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.12);
}

.new-chat-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.shortcut {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

kbd,
.new-chat-button kbd {
  min-width: 21px;
  height: 21px;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.12);
  color: inherit;
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
}

.sidebar-search {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 8px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text-muted);
  transition: border-color var(--ease);
}

.sidebar-search:focus-within {
  border-color: var(--accent);
}

.sidebar-search > span,
.sidebar-search > svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--text-muted);
  font-size: 17px;
  text-align: center;
}

.sidebar-search > svg,
.search-clear svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-search input {
  width: 100%;
  min-width: 0;
  padding: 9px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.sidebar-search input::placeholder {
  color: var(--text-muted);
}

.search-clear {
  width: 28px;
  height: 28px;
  display: grid;
  flex: 0 0 28px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
}

.search-clear:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.search-clear svg {
  width: 14px;
  height: 14px;
}

.sidebar-label,
.chat-group-label,
.nav-group-label {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 5px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.065em;
  text-transform: uppercase;
}

.refresh-button {
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  font-size: 16px;
}

.chat-lists {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.chat-list {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1px 2px 8px 0;
}

.chat-group {
  margin-bottom: 8px;
}

.chat-group .chat-group-label {
  position: sticky;
  z-index: 1;
  top: 0;
  background: var(--surface-1);
}

.chat-row {
  position: relative;
  min-height: 48px;
  display: flex;
  align-items: center;
  margin: 2px 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  transition: background var(--ease), border-color var(--ease);
}

.chat-row:hover {
  border-color: var(--border);
  background: var(--surface-hover);
}

.chat-row.active {
  border-color: #433b5d;
  background: var(--accent-soft);
}

.chat-row.active::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: -1px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.chat-row.pending {
  opacity: 0.68;
}

.chat-row.busy {
  background: var(--surface-2);
}

.chat-row.pending .chat-item {
  cursor: wait;
}

.chat-item {
  width: 100%;
  min-width: 0;
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  padding: 8px 6px 8px 9px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
}

.chat-item:hover {
  color: var(--text);
}

.chat-bubble {
  width: 25px;
  height: 25px;
  display: grid;
  flex: 0 0 25px;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-3);
  color: var(--text-muted);
}

.chat-row.active .chat-bubble {
  background: #2d2640;
  color: #b8a5f4;
}

.chat-bubble svg,
.folder-icon svg,
.chat-quick-action svg,
.chat-menu-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-copy {
  min-width: 0;
  display: block;
  flex: 1;
  overflow: hidden;
}

.chat-copy b,
.chat-item b {
  display: block;
  overflow: hidden;
  color: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-copy small,
.chat-item small {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-quick-action,
.chat-menu-button,
.chat-menu-trigger {
  position: relative;
  width: 34px;
  height: 34px;
  display: grid;
  flex: 0 0 34px;
  place-items: center;
  margin-right: 5px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  opacity: 0.72;
  transition: color var(--ease), background var(--ease), border-color var(--ease), opacity var(--ease);
}

.chat-row:hover .chat-quick-action,
.chat-row:hover .chat-menu-button,
.chat-row:hover .chat-menu-trigger,
.chat-quick-action:hover,
.chat-menu-button:hover,
.chat-menu-trigger:hover,
.chat-quick-action:focus-visible,
.chat-menu-button:focus-visible,
.chat-menu-trigger:focus-visible,
[aria-expanded="true"].chat-menu-trigger {
  border-color: var(--border-strong);
  background: var(--surface-3);
  color: var(--text);
  opacity: 1;
}

.chat-menu-wrap {
  position: relative;
  display: flex;
  align-items: center;
  align-self: stretch;
}

.chat-menu-trigger svg,
.chat-menu-item svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-quick-action::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 60;
  right: calc(100% + 7px);
  bottom: 50%;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-3);
  color: var(--text);
  font-size: 11px;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  box-shadow: var(--shadow-menu);
  opacity: 0;
  visibility: hidden;
  transform: translateY(50%);
  pointer-events: none;
}

.chat-quick-action:hover::after,
.chat-quick-action:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.chat-context-menu {
  position: absolute;
  z-index: 70;
  top: calc(100% - 2px);
  right: 5px;
  min-width: 176px;
  display: grid;
  padding: 5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-shadow: var(--shadow-menu);
}

.chat-context-menu.open,
.chat-context-menu.visible {
  display: grid;
}

.chat-context-menu button,
.chat-menu-item {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: left;
}

.chat-context-menu button:hover,
.chat-menu-item:hover,
.chat-menu-item:focus-visible {
  background: var(--surface-hover);
  color: var(--text);
}

.chat-context-menu button.danger {
  color: #ed909d;
}

.archive-section {
  flex: 0 0 auto;
  margin-top: 4px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
}

.archive-folder {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: left;
}

.archive-folder:hover,
.archive-folder.open {
  border-color: var(--border);
  background: var(--surface-hover);
  color: var(--text);
}

.archive-folder span:nth-child(2) {
  flex: 1;
  font-weight: 600;
}

.archive-folder b {
  min-width: 23px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.archive-folder i {
  color: var(--text-muted);
  font-style: normal;
  transition: transform var(--ease);
}

.archive-chevron {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--ease);
}

.archive-folder.open .archive-chevron {
  transform: rotate(180deg);
}

.archive-folder.open i {
  transform: rotate(180deg);
}

.folder-icon {
  width: 20px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}

.archive-list {
  max-height: 34vh;
  overflow-y: auto;
  padding: 3px 0 5px;
}

.archive-list .chat-bubble {
  background: var(--surface-2);
}

.empty-list {
  width: 100%;
  padding: 28px 16px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.empty-list.compact {
  padding: 14px 10px;
}

.sidebar-bottom {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.side-nav,
.account-card {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: left;
}

.side-nav:hover,
.account-card:hover {
  border-color: var(--border);
  background: var(--surface-hover);
  color: var(--text);
}

.side-nav span:nth-child(2),
.account-card span:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.side-nav b {
  padding: 2px 5px;
  border: 1px solid #4b4263;
  border-radius: 5px;
  color: #b8a7ed;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.side-nav > svg,
.account-card > svg {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.account-card > svg {
  color: var(--text-muted);
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  flex: 0 0 34px;
  place-items: center;
  border: 1px solid #4a405e;
  border-radius: 9px;
  background: var(--accent-soft);
  color: #c5b6f4;
  font-size: 12px;
  font-weight: 700;
}

.account-card b,
.account-card small {
  display: block;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-card b {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.account-card small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.sidebar-scrim {
  position: fixed;
  z-index: 35;
  inset: 0;
  display: none;
  border: 0;
  background: rgba(4, 3, 7, 0.68);
}

.admin-scrim {
  background: rgba(4, 3, 7, 0.72);
}

/* Chat workspace and top bar */

.workspace {
  position: relative;
  min-width: 0;
  height: 100%;
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  position: relative;
  z-index: 20;
  min-height: 68px;
  display: flex;
  flex: 0 0 68px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: max(0px, env(safe-area-inset-top)) 22px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.topbar-primary,
.topbar-context {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.topbar-context {
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.current-chat-title {
  max-width: min(42vw, 520px);
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-subline {
  max-width: min(42vw, 520px);
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-subline > span {
  flex: 0 0 auto;
}

.topbar-subline .model-picker-wrap {
  min-width: 0;
  border: 0;
  background: transparent;
}

.topbar-subline .model-picker-wrap:hover {
  background: transparent;
}

.topbar-subline .model-picker-wrap select {
  min-height: 24px;
  padding-top: 1px;
  padding-bottom: 1px;
  color: var(--text-secondary);
  font-size: 11px;
}

.model-picker-wrap {
  position: relative;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  transition: border-color var(--ease), background var(--ease);
}

.model-picker-wrap:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  margin-left: 12px;
  border-radius: 50%;
  background: var(--success);
}

.model-picker-wrap select {
  max-width: 280px;
  min-height: 40px;
  padding: 8px 31px 8px 0;
  border: 0;
  outline: 0;
  appearance: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.model-picker-wrap .chevron {
  position: absolute;
  right: 10px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--text-muted);
  font-size: 11px;
  pointer-events: none;
}

.topbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.balance-pill {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 12px;
  transition: border-color var(--ease), background var(--ease);
}

.balance-pill:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.balance-pill b {
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.balance-add {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--accent-soft);
  color: #bbaaf2;
  font-size: 12px;
  font-style: normal;
  line-height: 1;
}

.balance-add svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.topbar-icon-button {
  width: 40px;
  height: 40px;
  border-color: var(--border);
  background: var(--surface-1);
}

.topbar-icon-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.chat-stage {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

/* Empty chat */

.welcome {
  width: min(800px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  margin: 0 auto;
  padding: 40px 24px 84px;
  text-align: left;
}

.welcome-symbol {
  display: none;
}

.welcome-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-1);
  color: #b5a6e6;
}

.welcome-mark svg,
.welcome-note svg,
.prompt-grid button > span svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.welcome h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(34px, 4vw, 44px);
  font-weight: 650;
  line-height: 1.12;
  letter-spacing: -0.045em;
}

.welcome h1 em {
  color: var(--text);
  font-style: normal;
  font-weight: inherit;
}

.welcome > p {
  margin: 13px 0 26px;
  color: var(--text-secondary);
  font-size: 15px;
}

.prompt-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.prompt-grid button {
  position: relative;
  min-height: 112px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  color: var(--text-secondary);
  text-align: left;
  transition: border-color var(--ease), background var(--ease);
}

.prompt-grid button:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.prompt-grid button > span {
  position: absolute;
  top: 13px;
  right: 13px;
  color: var(--text-muted);
  font-size: 16px;
}

.prompt-grid b {
  display: block;
  margin-top: 23px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.prompt-grid small {
  display: block;
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.welcome-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 12px;
}

.welcome-note svg {
  width: 16px;
  height: 16px;
}

.boot-error {
  width: min(460px, 100%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  padding: 18px;
  border: 1px solid #67353f;
  border-radius: var(--radius-lg);
  background: var(--danger-soft);
}

.boot-error b {
  color: var(--text);
  font-size: 15px;
}

.boot-error span {
  color: #d99aa4;
  font-size: 13px;
  line-height: 1.5;
}

.boot-error .secondary-button {
  margin-top: 7px;
}

/* Messages */

.messages {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 34px max(24px, calc((100% - var(--content-width)) / 2)) 126px;
  scroll-behavior: smooth;
}

.message {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 14px;
  margin: 0 0 34px;
}

.message-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
}

.message.user .message-avatar {
  border-color: #4c4169;
  background: var(--accent-soft);
  color: #c7baf1;
}

.message-head {
  min-height: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.message-head b {
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.message-head time,
.message-meta {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.message-meta {
  margin-top: 7px;
}

.conversation-state {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: var(--text-muted);
  text-align: center;
}

.conversation-state i {
  width: 24px;
  height: 24px;
  margin-bottom: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.conversation-state b {
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
}

.conversation-state span {
  max-width: 440px;
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.conversation-state .secondary-button {
  margin-top: 16px;
}

.conversation-state.error::before {
  content: "!";
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  margin-bottom: 13px;
  border: 1px solid #5a3038;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 16px;
  font-weight: 700;
}

.stream-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #b9a9ed;
  font-size: 11px;
  line-height: 1.2;
}

.stream-cursor {
  width: 2px;
  height: 1.05em;
  display: inline-block;
  margin-left: 3px;
  border-radius: 1px;
  background: var(--accent);
  vertical-align: -0.15em;
  animation: cursor-blink 0.9s steps(1) infinite;
}

.message-body {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #e5e1e8;
  font-size: 16px;
  line-height: 1.72;
}

.message-body > :first-child {
  margin-top: 0;
}

.message-body > :last-child {
  margin-bottom: 0;
}

.message-body p {
  margin: 0 0 14px;
}

.message-body h1,
.message-body h2,
.message-body h3,
.message-body h4,
.message-body h5,
.message-body h6 {
  margin: 1.45em 0 0.55em;
  color: var(--text);
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.message-body h1 {
  font-size: 1.55em;
}

.message-body h2 {
  font-size: 1.34em;
}

.message-body h3 {
  font-size: 1.18em;
}

.message-body h4,
.message-body h5,
.message-body h6 {
  font-size: 1em;
}

.message-body ul,
.message-body ol {
  margin: 9px 0 16px;
  padding-left: 24px;
}

.message-body li {
  margin: 5px 0;
  padding-left: 2px;
}

.message-body li::marker {
  color: #a993ed;
}

.message-body blockquote {
  margin: 16px 0;
  padding: 11px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-1);
  color: var(--text-secondary);
}

.message-body hr {
  height: 1px;
  margin: 22px 0;
  border: 0;
  background: var(--border);
}

.message-body a {
  color: #aa98eb;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.message-body a:hover {
  color: #c1b3f1;
}

.message-body strong,
.message-body b {
  color: var(--text);
  font-weight: 650;
}

.message-body em {
  color: #d4ceda;
}

.message-body del {
  color: var(--text-muted);
}

.message-body img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.message-body code {
  padding: 2px 5px;
  border: 1px solid #3a3445;
  border-radius: 5px;
  background: var(--surface-2);
  color: #c7b7f2;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88em;
}

.message-body pre {
  max-width: 100%;
  overflow: auto;
  margin: 15px 0 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #08070b;
  color: #ddd8e2;
  font: 13px/1.6 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.message-body pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
}

.code-block {
  max-width: 100%;
  overflow: hidden;
  margin: 15px 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #08070b;
}

.code-toolbar {
  min-height: 39px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px 6px 13px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.code-toolbar button {
  min-height: 27px;
  padding: 4px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.code-toolbar button:hover,
.code-toolbar button.copied {
  border-color: #564d65;
  background: var(--surface-hover);
  color: var(--text);
}

.copy-code {
  white-space: nowrap;
}

.message-body .code-block pre {
  margin: 0;
  padding: 17px;
  border: 0;
  border-radius: 0;
}

.table-scroll {
  max-width: 100%;
  overflow: auto;
  margin: 15px 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.message-body table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  background: var(--surface-1);
  font-size: 13px;
  line-height: 1.5;
}

.message-body th,
.message-body td {
  padding: 10px 12px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  text-align: left;
  vertical-align: top;
}

.message-body th:last-child,
.message-body td:last-child {
  border-right: 0;
}

.message-body tr:last-child td {
  border-bottom: 0;
}

.message-body th {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 650;
  white-space: nowrap;
}

.message-body tbody tr:hover td {
  background: var(--surface-hover);
}

.thinking {
  position: relative;
  isolation: isolate;
  width: max-content;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 9px;
  overflow: visible;
  border: 1px solid rgba(154, 122, 232, 0.14);
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 130%, rgba(139, 92, 246, 0.13), transparent 62%),
    rgba(22, 17, 31, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.thinking i {
  --thinking-delay: 0ms;
  position: relative;
  z-index: 1;
  width: 7px;
  height: 7px;
  display: block;
  flex: 0 0 7px;
  border-radius: 50%;
  color: #b89cff;
  background: currentColor;
  box-shadow: 0 0 0 0 rgba(166, 128, 255, 0);
  transform-origin: center bottom;
  animation: thinking-dot 1.2s cubic-bezier(0.45, 0, 0.2, 1) var(--thinking-delay) infinite both;
  will-change: opacity, transform, box-shadow;
}

.thinking i::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid currentColor;
  border-radius: inherit;
  opacity: 0;
  transform: scale(0.45);
  animation: thinking-dot-halo 1.2s ease-out var(--thinking-delay) infinite both;
  pointer-events: none;
}

.thinking i:nth-child(1) {
  --thinking-delay: -0.24s;
}

.thinking i:nth-child(2) {
  --thinking-delay: -0.12s;
}

.thinking i:nth-child(3) {
  --thinking-delay: 0s;
}

.message-actions {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 7px;
  opacity: 0;
  transition: opacity var(--ease);
}

.message:hover .message-actions,
.message:focus-within .message-actions,
.message.streaming .message-actions {
  opacity: 1;
}

.message-actions button,
.copy-message {
  min-width: 30px;
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
}

.message-actions button svg,
.copy-message svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.copy-message {
  display: inline-flex;
  gap: 6px;
}

.message-actions button:hover,
.copy-message:hover {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.message.interrupted {
  padding: 13px 14px;
  border: 1px solid #584632;
  border-radius: var(--radius-lg);
  background: #17130f;
}

.message-interrupted {
  display: grid;
  gap: 3px;
  margin-top: 11px;
  padding: 9px 11px;
  border: 1px solid #584632;
  border-radius: var(--radius-sm);
  background: #17130f;
  color: #d9b779;
  font-size: 12px;
  line-height: 1.45;
}

.message-interrupted b {
  color: #e8c786;
  font-size: 12px;
  font-weight: 650;
}

.message-interrupted span {
  color: #bda678;
}

.message-inline-error {
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid #5a3038;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: #efa0ab;
  font-size: 13px;
  line-height: 1.5;
}

.message-files {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 310px));
  gap: 8px;
  margin-top: 13px;
}

.attachment-card {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--text-secondary);
  text-decoration: none;
  transition: border-color var(--ease), background var(--ease);
}

.attachment-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.file-icon {
  width: 36px;
  height: 36px;
  display: grid;
  flex: 0 0 36px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-secondary);
}

.file-icon svg,
.file-download svg,
.upload-chip button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.attachment-card.sheet .file-icon,
.upload-chip.sheet .file-icon {
  border-color: #315c4c;
  background: #11221c;
  color: #75c6a6;
}

.attachment-card.pdf .file-icon,
.upload-chip.pdf .file-icon {
  border-color: #63343c;
  background: #251519;
  color: #e38a98;
}

.attachment-card.image .file-icon,
.upload-chip.image .file-icon {
  border-color: #344f68;
  background: #121e29;
  color: #80acd4;
}

.attachment-card.archive .file-icon,
.upload-chip.archive .file-icon {
  border-color: #625039;
  background: #241d14;
  color: #d8b477;
}

.attachment-card.document .file-icon,
.upload-chip.document .file-icon {
  border-color: #494163;
  background: #1b1830;
  color: #aca0dc;
}

.file-copy,
.upload-copy {
  min-width: 0;
  display: block;
  flex: 1;
}

.file-copy b,
.upload-copy b {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-copy small,
.upload-copy small {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.25;
}

.file-state {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.file-state::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.file-state.ready {
  color: var(--success);
}

.file-state.unsupported {
  color: var(--warning);
}

.file-state.error {
  color: var(--danger);
}

.file-download {
  width: 30px;
  height: 30px;
  display: grid;
  flex: 0 0 30px;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.attachment-card:hover .file-download {
  background: var(--surface-3);
  color: var(--text);
}

.scroll-bottom {
  position: absolute;
  z-index: 12;
  right: max(24px, calc((100% - var(--content-width)) / 2));
  bottom: 18px;
  width: auto;
  min-width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  place-items: center;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-secondary);
  box-shadow: var(--shadow-menu);
}

.scroll-bottom svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scroll-bottom span {
  font-size: 12px;
  font-weight: 600;
}

.scroll-bottom:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* Composer */

.composer-zone {
  position: relative;
  z-index: 15;
  flex: 0 0 auto;
  padding: 10px max(24px, calc((100% - var(--content-width)) / 2)) max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid transparent;
  background: var(--bg);
}

.archive-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 9px;
  padding: 10px 12px;
  border: 1px solid #4b405f;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-size: 13px;
}

.archive-notice button {
  min-height: 34px;
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid #594d70;
  border-radius: var(--radius-sm);
  background: #2a2340;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.archive-notice button:hover {
  border-color: #6a5d83;
  background: #332b4c;
}

.archive-notice > span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.archive-notice > span svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 2px 8px;
}

.upload-chip {
  min-width: 215px;
  max-width: 310px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--text-secondary);
}

.upload-chip.loading {
  opacity: 0.74;
}

.upload-chip .file-icon {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
  border-radius: var(--radius-sm);
}

.upload-chip button {
  width: 30px;
  height: 30px;
  display: grid;
  flex: 0 0 30px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
}

.upload-chip button:hover {
  background: var(--danger-soft);
  color: #eb8d99;
}

.upload-chip.has-error {
  border-color: #67353f;
}

.upload-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #49434f;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.composer {
  min-height: 62px;
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  transition: border-color var(--ease), background var(--ease);
}

.composer:focus-within {
  border-color: var(--accent);
}

.composer.submitting {
  border-color: #554a70;
}

.composer textarea {
  min-width: 0;
  max-height: 190px;
  flex: 1;
  resize: none;
  padding: 11px 5px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: var(--text-muted);
}

.attach-button,
.send-button {
  width: 42px;
  height: 42px;
  display: grid;
  flex: 0 0 42px;
  place-items: center;
  padding: 0;
  border-radius: var(--radius-md);
}

.attach-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
}

.attach-button:hover {
  border-color: var(--border);
  background: var(--surface-hover);
  color: var(--text);
}

.attach-button svg,
.send-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.send-button {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 19px;
  font-weight: 700;
}

.send-button:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.send-button:disabled {
  border-color: var(--border);
  background: var(--surface-3);
  color: var(--text-muted);
}

.send-button.loading {
  color: transparent;
}

.send-button.loading::after {
  content: "";
  position: absolute;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.36);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.composer-right {
  display: flex;
  align-self: flex-end;
  align-items: center;
  gap: 5px;
}

.composer-right > span {
  color: var(--text-muted);
  font-size: 11px;
}

.web-search-toggle {
  height: 42px;
  display: inline-flex;
  align-self: flex-end;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: border-color var(--ease), background-color var(--ease), color var(--ease), box-shadow var(--ease);
}

.web-search-toggle svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.web-search-toggle span {
  display: block;
  line-height: 1;
  transform: translateY(-0.25px);
}

.web-search-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.web-search-toggle.active {
  border-color: #51466b;
  background: var(--accent-soft);
  color: #c2b3f0;
  box-shadow: inset 0 0 0 1px rgba(139, 112, 232, 0.08);
}

.composer-media-button {
  width: 42px;
  height: 42px;
  display: grid;
  flex: 0 0 42px;
  align-self: flex-end;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  transition: border-color var(--ease), background var(--ease), color var(--ease), transform var(--ease);
}

.composer-media-button:hover { border-color: var(--border); background: var(--surface-hover); color: var(--text); }
.composer-media-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.composer-media-button.recording { border-color: rgba(239, 91, 116, .6); background: rgba(145, 37, 58, .2); color: #ff879c; animation: media-recording 1.25s ease-in-out infinite; }
.composer-media-button.processing { color: #bda6e9; }
.composer-media-button:disabled { opacity: .45; cursor: not-allowed; }
.composer-media-button.unavailable:not(:disabled) { opacity: .58; color: var(--text-muted); }
.composer-media-button.unavailable:not(:disabled):hover { opacity: 1; color: var(--text-secondary); }

@keyframes media-recording { 50% { box-shadow: 0 0 0 5px rgba(239, 91, 116, .09); transform: scale(.96); } }

.voice-recording-panel {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 8px;
  padding: 9px 10px 9px 13px;
  border: 1px solid rgba(239, 91, 116, .34);
  border-radius: var(--radius-lg);
  background: linear-gradient(100deg, rgba(106, 29, 48, .16), var(--surface-1) 42%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.voice-recording-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
  background: #f05b75;
  box-shadow: 0 0 0 5px rgba(240, 91, 117, .1);
  animation: voice-recording-dot 1.2s ease-in-out infinite;
}

.voice-recording-copy {
  min-width: 104px;
  display: grid;
  gap: 2px;
}

.voice-recording-copy b { color: var(--text); font-size: 12px; font-weight: 650; }
.voice-recording-copy small { color: #f08a9c; font-variant-numeric: tabular-nums; font-size: 11px; }

.voice-level-meter {
  min-width: 90px;
  height: 32px;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  overflow: hidden;
}

.voice-level-meter i {
  width: 3px;
  height: 4px;
  flex: 0 0 3px;
  border-radius: 999px;
  background: linear-gradient(to top, #8f6fe6, #ef7087);
  opacity: .48;
  transition: height 70ms linear, opacity 70ms linear;
}

.voice-recording-action {
  min-height: 36px;
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}

.voice-recording-action:hover { border-color: var(--border-strong); color: var(--text); }
.voice-recording-action.stop { border-color: rgba(239, 91, 116, .42); background: rgba(145, 37, 58, .18); color: #ff9aac; }
.voice-recording-panel.processing { border-color: rgba(139, 112, 232, .35); background: linear-gradient(100deg, rgba(91, 62, 145, .14), var(--surface-1) 42%); }
.voice-recording-panel.processing .voice-recording-dot { background: #9e82ef; box-shadow: 0 0 0 5px rgba(158, 130, 239, .1); animation: spin .9s linear infinite; border: 2px solid rgba(198, 180, 234, .25); border-top-color: #c6b4ea; }
.voice-recording-panel.processing .voice-recording-copy small { color: var(--text-muted); }
.voice-recording-panel.processing .voice-level-meter i { height: 4px !important; opacity: .24 !important; }
.voice-recording-panel.processing .voice-recording-action { display: none; }

@keyframes voice-recording-dot { 50% { transform: scale(.72); opacity: .7; } }

.image-attachment { min-width: 0; max-width: 720px; grid-column: 1 / -1; margin: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-1); }
.image-attachment a { display: block; background: #09080c; }
.image-attachment img { width: 100%; max-height: 680px; display: block; object-fit: contain; }
.image-attachment figcaption { display: flex; justify-content: space-between; gap: 12px; padding: 9px 11px; color: var(--text-secondary); font-size: 12px; }
.image-attachment figcaption span { color: var(--text-muted); white-space: nowrap; }

.audio-attachment { min-width: min(100%, 320px); max-width: 560px; display: grid; gap: 9px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-1); }
.audio-attachment > div { min-width: 0; display: flex; align-items: center; gap: 9px; }
.audio-attachment > div > span:last-child { min-width: 0; display: grid; gap: 2px; }
.audio-attachment b { overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.audio-attachment small { color: var(--text-muted); font-size: 11px; }
.audio-attachment audio { width: 100%; height: 34px; }

.media-operation-status { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border: 1px solid rgba(135, 102, 194, .28); border-radius: var(--radius-md); background: rgba(91, 62, 145, .1); color: #c6b4ea; font-size: 12px; }
.media-operation-status i { width: 15px; height: 15px; flex: 0 0 15px; border: 2px solid rgba(198, 180, 234, .3); border-top-color: #c6b4ea; border-radius: 50%; animation: spin .8s linear infinite; }
.admin-standalone-media { margin-top: 24px; }
.admin-standalone-media .panel-title > div { display: grid; gap: 4px; }
.admin-standalone-media .panel-title > div > span { color: var(--muted); font-size: 12px; }
.media-visual svg { fill: none; stroke: currentColor; }
.model-badge.media { border-color: rgba(67, 142, 178, .3); background: rgba(36, 101, 132, .12); color: #8fc9e4; }

.composer-hint {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 4px 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.composer-hint kbd {
  min-width: 0;
  height: auto;
  padding: 1px 4px;
  border-color: var(--border-strong);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 11px;
}

.composer-hint i {
  color: #5f5966;
  font-style: normal;
}

/* Drag and drop */

.drop-overlay {
  position: absolute;
  z-index: 90;
  inset: 10px;
  display: grid;
  place-items: center;
  border: 2px dashed #685b83;
  border-radius: var(--radius-xl);
  background: rgba(11, 10, 15, 0.94);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--ease), visibility var(--ease);
}

.drop-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.workspace.drag-active .composer {
  border-color: var(--accent);
}

.drop-card {
  width: min(440px, calc(100% - 32px));
  padding: 30px 26px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  text-align: center;
}

.drop-card > span {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  border: 1px solid #51476a;
  border-radius: 13px;
  background: var(--accent-soft);
  color: #b9aaea;
  font-size: 24px;
}

.drop-card > span svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop-card b {
  display: block;
  color: var(--text);
  font-size: 17px;
  font-weight: 650;
}

.drop-card small {
  display: block;
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

/* Admin shell */

.admin-space {
  min-width: 0;
  height: 100%;
  display: flex;
  flex: 1;
  overflow: hidden;
  background: var(--bg);
}

.admin-nav {
  position: relative;
  z-index: 50;
  width: var(--admin-nav-width);
  height: 100%;
  display: flex;
  flex: 0 0 var(--admin-nav-width);
  flex-direction: column;
  padding: max(18px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
  border-right: 1px solid var(--border);
  background: var(--surface-1);
}

.admin-title {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 17px;
}

.admin-title > div {
  min-width: 0;
}

.admin-title b,
.admin-title small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-title b {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.admin-title small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.admin-nav nav {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
}

.admin-nav nav button,
.back-to-chat {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 550;
  text-align: left;
}

.admin-nav nav button:hover,
.admin-nav nav button.active,
.back-to-chat:hover {
  border-color: var(--border);
  background: var(--surface-hover);
  color: var(--text);
}

.admin-nav nav button.active {
  border-color: #433b5d;
  background: var(--accent-soft);
}

.admin-nav nav button.active::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--accent);
}

.admin-nav nav button > span {
  width: 20px;
  color: var(--text-muted);
  text-align: center;
}

.admin-nav nav button > svg,
.back-to-chat > svg {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.admin-nav nav button.active > svg,
.admin-nav nav button:hover > svg,
.back-to-chat:hover > svg {
  stroke: currentColor;
}

.admin-nav nav button.active > span {
  color: #b8a7ee;
}

.nav-group-label {
  margin-top: 10px;
}

.back-to-chat {
  margin-top: 10px;
  padding-top: 10px;
  border-top-color: var(--border);
  border-radius: var(--radius-md);
}

.admin-mobile-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 12px;
}

.admin-main {
  min-width: 0;
  height: 100%;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.admin-topbar {
  min-height: 76px;
  display: flex;
  flex: 0 0 76px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.admin-topbar h1 {
  margin: 0;
  color: var(--text);
  font-size: 24px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.admin-topbar .eyebrow {
  margin-bottom: 2px;
  font-size: 11px;
}

.admin-context {
  display: block;
  margin-bottom: 2px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.admin-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 12px;
}

.live-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.account-mini {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 7px 3px 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
}

.account-mini:hover {
  border-color: var(--border);
  background: var(--surface-1);
  color: var(--text);
}

.account-mini .avatar {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
  border-radius: var(--radius-sm);
}

.account-mini > span:nth-child(2) {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-mini > svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.admin-content {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 28px 30px 56px;
}

.admin-section-head {
  min-height: 54px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.admin-section-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 22px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.admin-section-head p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat-card,
.panel,
.settings-card,
.model-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.stat-card {
  min-width: 0;
  padding: 17px;
}

.stat-card small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.stat-card strong {
  display: block;
  margin: 11px 0 5px;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(23px, 2.3vw, 30px);
  font-weight: 650;
  line-height: 1.12;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-card span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.stat-card.accent {
  border-color: #443b5e;
  background: var(--accent-soft);
}

.stat-card.accent strong {
  color: #d0c5f2;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
  gap: 14px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.dashboard-recent {
  margin-top: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 17px;
}

.panel-title b {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.panel-title span {
  color: var(--text-muted);
  font-size: 12px;
}

.bar-chart {
  height: 210px;
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 14px 0 25px;
  border-bottom: 1px solid var(--border);
}

.bar-col {
  position: relative;
  height: 100%;
  display: flex;
  flex: 1;
  align-items: flex-end;
}

.bar-col i {
  width: 100%;
  min-height: 2px;
  display: block;
  border-radius: 3px 3px 0 0;
  background: #655496;
  transition: background var(--ease);
}

.bar-col:hover i {
  background: var(--accent);
}

.bar-col span {
  position: absolute;
  bottom: -21px;
  left: 50%;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1;
  transform: translateX(-50%);
}

.top-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.top-row b {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-row span {
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.top-row i {
  position: relative;
  height: 4px;
  grid-column: 1 / -1;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.top-row i::after {
  content: "";
  width: var(--width);
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--accent);
}

/* Admin tables */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 13px;
}

.toolbar .form-input {
  max-width: 360px;
}

.model-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 220px;
}

.model-toolbar .form-input {
  max-width: none;
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.data-table {
  width: 100%;
  min-width: 780px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface-1);
  font-size: 13px;
  line-height: 1.42;
}

.data-table th {
  position: sticky;
  z-index: 2;
  top: 0;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.055em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  min-height: 48px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: var(--surface-hover);
}

.data-table td b {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.data-table td small {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}

.table-user {
  display: flex;
  align-items: center;
  gap: 9px;
}

.table-user > span:last-child {
  min-width: 0;
}

.table-user .avatar {
  width: 31px;
  height: 31px;
  flex-basis: 31px;
  border-radius: var(--radius-sm);
}

.table-user small {
  display: block;
  max-width: 220px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status.active,
.status.success {
  background: var(--success-soft);
  color: #75c8a6;
}

.status.error,
.status.blocked {
  background: var(--danger-soft);
  color: #e58794;
}

.status.pending {
  background: var(--warning-soft);
  color: #ddb66f;
}

.status.pending.processing {
  background: rgba(116, 82, 176, 0.15);
  color: #c5adef;
}

.status.pending.streaming {
  background: rgba(47, 126, 96, 0.14);
  color: #8fd6bc;
}

.status.pending.processing::before {
  animation: status-pulse 1.15s ease-in-out infinite;
}

.status.pending.streaming::before {
  box-shadow: 0 0 0 3px rgba(83, 188, 148, 0.11);
}

.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.table-actions button {
  min-width: 34px;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
}

.table-actions button:hover {
  border-color: var(--border);
  background: var(--surface-hover);
  color: var(--text);
}

.table-actions button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Model catalog */

.model-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.model-card {
  min-width: 0;
  padding: 16px;
}

.model-card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.model-card-head > div:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.model-icon {
  width: 36px;
  height: 36px;
  display: grid;
  flex: 0 0 36px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.model-icon svg,
.model-badge svg,
.settings-inline-note > span svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.model-badge svg {
  width: 13px;
  height: 13px;
  margin-right: 4px;
}

.model-card h3 {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-card small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 13px;
}

.model-badge,
.feature-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.model-badge.alias {
  border-color: #48405e;
  background: var(--accent-soft);
  color: #b9abe8;
}

.model-badge.web {
  border-color: #3c5266;
  background: #131e28;
  color: #89b2d7;
}

.feature-pill {
  letter-spacing: 0.04em;
}

.model-prices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}

.model-prices div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.model-prices span,
.model-prices b {
  display: block;
}

.model-prices span {
  color: var(--text-muted);
  font-size: 11px;
}

.model-prices b {
  margin-top: 3px;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
}

.model-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 11px;
}

.model-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.model-card-actions .text-button {
  padding-inline: 6px;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  display: inline-block;
  flex: 0 0 40px;
}

.toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle i {
  position: absolute;
  inset: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-3);
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease);
}

.toggle i::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--ease), background var(--ease);
}

.toggle input:checked + i {
  border-color: var(--accent);
  background: var(--accent);
}

.toggle input:checked + i::before {
  background: #fff;
  transform: translateX(18px);
}

.toggle input:focus-visible + i {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Settings and forms */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-card {
  min-width: 0;
  padding: 20px;
}

.settings-card.wide {
  grid-column: 1 / -1;
}

.web-search-settings {
  min-width: 0;
}

.settings-card h3 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
}

.settings-card > p,
.settings-card-title p {
  margin: 0 0 17px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.settings-card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 17px;
}

.settings-card-title h3 {
  margin-bottom: 4px;
}

.settings-card-title p {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.form-grid .wide,
.modal-actions.wide {
  grid-column: 1 / -1;
}

.checkbox-field {
  min-height: 58px;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  cursor: pointer;
}

.checkbox-field:hover {
  border-color: var(--border-strong);
}

.checkbox-field input {
  width: 17px;
  height: 17px;
  min-height: 0;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.checkbox-field b,
.checkbox-field small {
  display: block;
}

.checkbox-field b {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.checkbox-field small {
  margin-top: 3px;
}

.settings-inline-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.settings-inline-note > span {
  width: 30px;
  height: 30px;
  display: grid;
  flex: 0 0 30px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-secondary);
}

.settings-inline-note p {
  min-width: 0;
  flex: 1;
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.settings-inline-note .secondary-button {
  flex: 0 0 auto;
}

.settings-test-button {
  margin-top: 12px;
}

.s3-field {
  min-width: 0;
}

.balance-preview {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 13px;
}

.balance-preview b {
  color: var(--text);
  font-weight: 650;
}

.profile-logout {
  margin-top: 20px;
}

.model-access-section {
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.model-access-section h3 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.model-access-section > p {
  margin: 5px 0 13px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.model-access-list {
  display: grid;
  gap: 8px;
}

.model-access-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 140px 120px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.model-access-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-access-row .form-input {
  min-height: 38px;
  padding: 7px 9px;
  font-size: 12px;
}

.model-access-row {
  min-height: 44px;
}

.model-access-row > span {
  color: var(--text-secondary);
  font-size: 13px !important;
}

.money-input {
  position: relative;
  display: flex;
  align-items: center;
}

.money-input input {
  padding-right: 44px;
}

.money-input b {
  position: absolute;
  right: 13px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Modal, loader and toasts */

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 3, 7, 0.74);
}

.modal-card {
  position: relative;
  width: min(640px, 100%);
  max-height: min(780px, calc(100vh - 40px));
  max-height: min(780px, calc(100dvh - 40px));
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--surface-1);
  box-shadow: var(--shadow-modal);
}

.modal-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 22px;
}

.modal-close:hover {
  border-color: var(--border);
  background: var(--surface-hover);
  color: var(--text);
}

.modal-close svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.modal-card h2 {
  margin: 0 44px 5px 0;
  color: var(--text);
  font-size: 23px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.modal-lead {
  margin: 0 0 21px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.modal-lead code {
  display: inline-block;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: #bcaef0;
  font: 12px/1.35 "SFMono-Regular", Consolas, monospace;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.modal-actions .primary-button {
  min-width: 116px;
}

.confirm-visual {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-bottom: 15px;
  border: 1px solid #4a405f;
  border-radius: 12px;
  background: var(--accent-soft);
  color: #bbaaf0;
}

.confirm-visual svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.confirm-copy {
  max-width: 500px;
}

.loader {
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.loader i {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.admin-load-error {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}

.admin-load-error b {
  color: var(--text);
  font-size: 15px;
}

.admin-load-error .secondary-button {
  margin-top: 10px;
}

.toast-stack {
  position: fixed;
  z-index: 200;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  width: min(360px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: var(--shadow-menu);
  animation: toast-in 0.16s ease-out;
}

.toast-message {
  min-width: 0;
  padding: 2px 0;
  overflow-wrap: anywhere;
}

.toast-close {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin: -3px -5px -3px 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
}

.toast-close:hover {
  border-color: var(--border);
  background: var(--surface-hover);
  color: var(--text);
}

.toast-close svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.toast.error {
  border-color: #67353f;
  background: var(--danger-soft);
  color: #f0a3ae;
}

/* Motion */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes thinking-dot {
  0%, 58%, 100% {
    opacity: 0.34;
    transform: translate3d(0, 0, 0) scale(0.82);
    box-shadow: 0 0 0 0 rgba(166, 128, 255, 0);
  }
  24% {
    opacity: 1;
    transform: translate3d(0, -5px, 0) scale(1.16);
    box-shadow: 0 5px 13px 1px rgba(166, 128, 255, 0.36);
  }
  38% {
    opacity: 0.72;
    transform: translate3d(0, 1px, 0) scale(0.92);
  }
}

@keyframes thinking-dot-halo {
  0%, 17%, 100% {
    opacity: 0;
    transform: scale(0.45);
  }
  24% {
    opacity: 0.32;
    transform: scale(0.72);
  }
  48% {
    opacity: 0;
    transform: scale(1.35);
  }
}

@keyframes thinking-dot-reduced {
  0%, 100% {
    opacity: 0.42;
  }
  50% {
    opacity: 1;
  }
}

@keyframes cursor-blink {
  50% {
    opacity: 0.2;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

/* Medium screens */

@media (max-width: 1100px) {
  :root {
    --sidebar-width: 272px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .admin-content {
    padding-inline: 24px;
  }
}

@media (max-width: 900px) {
  .auth-page {
    grid-template-columns: minmax(0, 1fr) minmax(390px, 0.9fr);
  }

  .auth-copy h1 {
    font-size: 44px;
  }

  .auth-note {
    flex-direction: column;
    gap: 6px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-card.wide {
    grid-column: auto;
  }

  .admin-nav {
    width: 220px;
    flex-basis: 220px;
  }
}

/* Phone and tablet drawer layout */

@media (max-width: 760px) {
  :root {
    --content-width: 100%;
  }

  .mobile-only {
    display: inline-grid !important;
  }

  .app-shell,
  .admin-space,
  .workspace {
    height: 100vh;
    height: 100dvh;
  }

  .auth-page {
    display: block;
    overflow-y: auto;
  }

  .auth-visual {
    display: none;
  }

  .auth-form-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  }

  .auth-form {
    padding: 24px;
  }

  .mobile-brand {
    display: flex;
    margin-bottom: 12px;
  }

  .sidebar,
  .admin-nav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(88vw, 320px);
    height: 100vh;
    height: 100dvh;
    flex-basis: auto;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
  }

  .sidebar.open,
  .admin-nav.open {
    transform: translateX(0);
  }

  .sidebar-scrim {
    display: block;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
  }

  .sidebar-scrim.open,
  .sidebar-scrim.visible {
    opacity: 1;
    visibility: visible;
  }

  .app-shell:has(> .sidebar.open) > #sidebar-scrim,
  .admin-space:has(> .admin-nav.open) > .admin-scrim {
    opacity: 1;
    visibility: visible;
  }

  .topbar {
    min-height: calc(62px + env(safe-area-inset-top));
    flex-basis: calc(62px + env(safe-area-inset-top));
    gap: 8px;
    padding: env(safe-area-inset-top) 10px 0;
  }

  .topbar-primary {
    flex: 1;
    overflow: hidden;
  }

  .topbar-context {
    flex: 1;
    overflow: hidden;
  }

  .current-chat-title,
  .topbar-subline {
    max-width: 100%;
  }

  .model-picker-wrap select {
    max-width: 135px;
  }

  .topbar-actions {
    gap: 4px;
  }

  .balance-pill {
    padding-inline: 9px;
  }

  .balance-pill > span {
    display: none;
  }

  .topbar-icon-button {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .welcome {
    justify-content: flex-start;
    padding: 10vh 16px 44px;
  }

  .welcome h1 {
    font-size: 34px;
  }

  .prompt-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .prompt-grid button {
    min-height: 82px;
    padding: 12px 14px;
  }

  .prompt-grid b {
    margin-top: 11px;
  }

  .messages {
    padding: 24px 14px 104px;
  }

  .message {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 11px;
    margin-bottom: 28px;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  .message-body {
    font-size: 15px;
    line-height: 1.68;
  }

  .message-actions {
    opacity: 1;
  }

  .message.interrupted {
    padding: 11px;
  }

  .message-files {
    grid-template-columns: minmax(0, 1fr);
  }

  .model-access-row {
    grid-template-columns: 1fr;
  }

  .model-access-name {
    padding: 2px 2px 4px;
  }

  .composer-zone {
    padding: 8px 9px max(9px, env(safe-area-inset-bottom));
  }

  .composer {
    min-height: 58px;
    border-radius: 13px;
  }

  .composer textarea {
    padding-inline: 3px;
    font-size: 15px;
  }

  .attach-button,
  .send-button,
  .composer-media-button,
  .web-search-toggle {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .web-search-toggle {
    justify-content: center;
    padding: 0;
  }

  .web-search-toggle span {
    display: none;
  }

  .voice-recording-panel {
    gap: 8px;
    padding-inline: 10px;
  }

  .voice-recording-copy {
    min-width: 48px;
  }

  .voice-recording-copy b {
    display: none;
  }

  .voice-level-meter {
    gap: 2px;
  }

  .voice-recording-action {
    min-height: 34px;
    padding-inline: 8px;
  }

  .composer-hint {
    justify-content: flex-end;
    padding-right: 2px;
  }

  .composer-hint > span:first-child {
    display: none;
  }

  .scroll-bottom {
    right: 14px;
  }

  .chat-quick-action::after {
    display: none;
  }

  .archive-list {
    max-height: 30vh;
  }

  .admin-topbar {
    min-height: calc(66px + env(safe-area-inset-top));
    flex-basis: calc(66px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 14px 0;
  }

  .admin-topbar h1 {
    font-size: 21px;
  }

  .admin-head-actions .live-status {
    display: none;
  }

  .account-mini {
    max-width: 130px;
    overflow: hidden;
  }

  .admin-content {
    padding: 20px 12px 44px;
  }

  .admin-section-head {
    align-items: flex-start;
  }

  .stats-grid {
    gap: 9px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-card strong {
    font-size: 24px;
  }

  .table-wrap {
    border-radius: var(--radius-md);
  }

  .data-table {
    min-width: 720px;
  }

  .model-cards {
    grid-template-columns: 1fr;
  }

  .model-toolbar {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .wide,
  .modal-actions.wide {
    grid-column: auto;
  }

  .settings-inline-note {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .settings-inline-note p {
    min-width: calc(100% - 44px);
  }

  .settings-inline-note .secondary-button {
    width: 100%;
  }

  .model-access-row {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    width: 100%;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    padding: 22px 16px max(18px, env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .toast-stack {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
  }

  .toast {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .shortcut {
    display: none;
  }

  .auth-form {
    padding: 0;
    border: 0;
    background: transparent;
  }

  .topbar {
    padding-inline: 8px;
  }

  #rename-chat {
    display: none;
  }

  .model-picker-wrap select {
    max-width: 112px;
  }

  .status-dot {
    margin-left: 9px;
  }

  .balance-pill {
    max-width: 96px;
  }

  .balance-pill b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .welcome {
    padding-top: 8vh;
  }

  .welcome h1 {
    font-size: 31px;
  }

  .welcome > p {
    font-size: 14px;
  }

  .archive-notice {
    align-items: flex-start;
    flex-direction: column;
  }

  .archive-notice button {
    width: 100%;
  }

  .upload-chip {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .composer-right > span {
    display: none;
  }

  .admin-section-head {
    flex-direction: column;
    gap: 12px;
  }

  .admin-section-head > .primary-button,
  .admin-section-head > .secondary-button,
  .admin-section-head > .button-row {
    width: 100%;
  }

  .button-row {
    align-items: stretch;
  }

  .button-row > * {
    flex: 1;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .model-foot {
    align-items: flex-start;
    flex-direction: column;
  }

  .model-card-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .modal-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .modal-actions > * {
    width: 100%;
  }

  .account-mini {
    width: 38px;
    padding: 3px;
    font-size: 0;
  }
}

@media (max-width: 390px) {
  .model-picker-wrap {
    max-width: 122px;
  }

  .model-picker-wrap select {
    max-width: 92px;
    font-size: 12px;
  }

  .topbar-actions .topbar-icon-button {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .balance-pill {
    max-width: 78px;
    padding-inline: 7px;
  }

  .prompt-grid small {
    display: none;
  }
}

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

  /* Keep the waiting state understandable without spatial movement.  The
     staggered opacity wave is deliberately slow and is safe for users who
     ask the OS to reduce motion. */
  .thinking i {
    animation: thinking-dot-reduced 1.8s ease-in-out var(--thinking-delay) infinite both !important;
    transform: none !important;
    box-shadow: none !important;
    will-change: opacity;
  }

  .thinking i::after {
    animation: none !important;
    opacity: 0 !important;
  }
}

@media (forced-colors: active) {
  .brand-mark,
  .send-button,
  .primary-button,
  .new-chat-button,
  .status-dot,
  .live-status i {
    forced-color-adjust: none;
  }

  .chat-row.active,
  .admin-nav nav button.active,
  .model-picker-wrap,
  .composer {
    border-color: Highlight;
  }
}

/* Rich message typography and code presentation (1.6) */
.message-body {
  color: #e7e3eb;
  font-size: 16px;
  line-height: 1.72;
  letter-spacing: -0.008em;
}

.message-body > :first-child,
.message-body > section:first-child > :first-child {
  margin-top: 0;
}

.message-body > :last-child,
.message-body > section:last-child > :last-child {
  margin-bottom: 0;
}

.message-body p {
  margin: 0 0 15px;
}

.message-body h1,
.message-body h2,
.message-body h3,
.message-body h4,
.message-body h5,
.message-body h6 {
  margin: 1.55em 0 0.58em;
  color: #f5f2f7;
  font-weight: 700;
  line-height: 1.24;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.message-body h1 { font-size: 28px; }
.message-body h2 { font-size: 23px; }
.message-body h3 { font-size: 19px; }
.message-body h4 { font-size: 17px; }
.message-body h5 {
  font-size: 15px;
  letter-spacing: -0.012em;
}
.message-body h6 {
  color: var(--text-secondary);
  font-size: 13px;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.message-body ul,
.message-body ol {
  margin: 10px 0 17px;
  padding-left: 26px;
}

.message-body li {
  margin: 6px 0;
  padding-left: 3px;
}

.message-body li::marker {
  color: #aa8ff2;
  font-weight: 600;
}

.message-body li > p {
  margin: 0;
}

.message-body li > ul,
.message-body li > ol {
  margin: 5px 0 6px;
}

.message-body ul ul { list-style-type: circle; }
.message-body ul ul ul { list-style-type: square; }
.message-body ol ol { list-style-type: lower-alpha; }
.message-body ol ol ol { list-style-type: lower-roman; }

.message-body .contains-task-list {
  padding-left: 3px;
  list-style: none;
}

.message-body .contains-task-list > li:not(.task-list-item) {
  position: relative;
  padding-left: 27px;
}

.message-body .contains-task-list > li:not(.task-list-item)::before {
  content: '•';
  position: absolute;
  top: 0;
  left: 7px;
  color: #aa8ff2;
  font-weight: 700;
}

.message-body .task-list-item {
  position: relative;
  padding-left: 27px;
  list-style: none;
}

.message-body .task-list-item-checkbox {
  position: absolute;
  top: 0.32em;
  left: 0;
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent);
  pointer-events: none;
}

.message-body .task-list-item-checkbox:disabled { opacity: 1; }

.message-body blockquote {
  margin: 18px 0;
  padding: 13px 16px;
  border: 0;
  border-left: 3px solid #9b79f0;
  border-radius: 0 9px 9px 0;
  background: #14121a;
  color: #cfc8d6;
}

.message-body blockquote blockquote {
  margin: 12px 0 2px;
  border-left-color: #5e566c;
  background: #191620;
}

.message-body blockquote > :last-child {
  margin-bottom: 0;
}

.message-body hr {
  height: 1px;
  margin: 28px 0;
  border: 0;
  background: var(--border);
}

.message-body a {
  color: #b19af5;
  text-decoration-color: rgba(177, 154, 245, 0.52);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--ease), text-decoration-color var(--ease);
}

.message-body a:hover {
  color: #c9b9fa;
  text-decoration-color: currentColor;
}

.message-body strong {
  color: #f4f0f7;
  font-weight: 700;
}

.message-body em,
.message-body i { color: #dad4df; }
.message-body del,
.message-body s { color: #8c8494; }
.message-body u { text-underline-offset: 3px; }
.message-body sub,
.message-body sup { line-height: 0; }

.message-body mark {
  padding: 0.08em 0.25em;
  border-radius: 4px;
  background: rgba(226, 174, 78, 0.2);
  color: #f6dda8;
}

.message-body kbd {
  display: inline-block;
  min-width: 1.75em;
  padding: 1px 6px 2px;
  border: 1px solid #4b4554;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #18161d;
  box-shadow: 0 1px 0 #08070a;
  color: #e9e4ed;
  font: 600 0.78em/1.55 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: nowrap;
}

.message-body details {
  margin: 17px 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #111016;
}

.message-body summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-weight: 650;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.message-body summary::-webkit-details-marker { display: none; }
.message-body summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}
.message-body summary::before {
  content: '';
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-right: 1.5px solid #a996d9;
  border-bottom: 1.5px solid #a996d9;
  transform: rotate(-45deg);
  transition: transform var(--ease);
}
.message-body details[open] > summary::before { transform: rotate(45deg); }
.message-body details[open] > summary { border-bottom: 1px solid var(--border); }
.message-body details > :not(summary) { margin-right: 14px; margin-left: 14px; }
.message-body details > :last-child { margin-bottom: 14px; }

.message-body .image-link {
  display: block;
  margin: 18px 0;
  text-decoration: none;
}

.message-body .markdown-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(70vh, 720px);
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0a090d;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
}

.message-body .image-link:hover .markdown-image {
  border-color: #514763;
}

.message-body .image-fallback {
  min-height: 62px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px dashed #46404f;
  border-radius: var(--radius-md);
  background: #121017;
  color: var(--text-secondary);
}

.message-body .image-fallback b { color: var(--text); font-size: 13px; }
.message-body .image-fallback small { color: var(--text-muted); }

.message-body img.remote-image-pending,
.message-body img.image-stream-pending { display: none; }

.message-body .image-stream-placeholder,
.message-body .remote-image-card {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 17px 0;
  padding: 12px 13px 12px 15px;
  border: 1px solid #393342;
  border-radius: var(--radius-md);
  background: #121017;
}

.message-body .image-stream-placeholder {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
}

.message-body .image-stream-placeholder b,
.message-body .remote-image-copy b {
  color: #ece7f0;
  font-size: 13px;
}

.message-body .image-stream-placeholder small,
.message-body .remote-image-copy small {
  display: block;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-body .remote-image-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.message-body .remote-image-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.message-body .remote-image-actions button,
.message-body .remote-image-actions a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: 1px solid #443b51;
  border-radius: 7px;
  background: #1b1722;
  color: #d5cddd;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
}

.message-body .remote-image-actions button:hover,
.message-body .remote-image-actions a:hover {
  border-color: #66547e;
  background: #241d2e;
  color: #f1ebf5;
}

.message-body code {
  padding: 2px 5px;
  border: 1px solid #3b3545;
  border-radius: 5px;
  background: #18151e;
  color: #cbbaf7;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875em;
  font-variant-ligatures: none;
  overflow-wrap: anywhere;
}

.message-body pre,
.message-body .code-block pre {
  direction: ltr;
  tab-size: 4;
  text-align: left;
}

.message-body pre code,
.message-body .code-block pre code {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #e3dfe8;
  font-size: inherit;
  line-height: inherit;
  overflow-wrap: normal;
  white-space: pre;
  word-break: normal;
  word-spacing: normal;
  word-wrap: normal;
  text-shadow: none;
}

.message-body .code-block {
  max-width: 100%;
  overflow: hidden;
  margin: 17px 0 20px;
  border: 1px solid #302c37;
  border-radius: 11px;
  background: #09080d;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}

.message-body .code-toolbar {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 6px 7px 6px 14px;
  border-bottom: 1px solid #302c37;
  background: #121017;
  color: #a69bad;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.message-body .code-language {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-body .code-language-note {
  color: #9a91a3;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.message-body .code-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}

.message-body .code-toolbar button {
  min-height: 29px;
  padding: 4px 9px;
  border: 1px solid #383241;
  border-radius: 6px;
  background: #19161f;
  color: #c8c0cf;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
}

.message-body .code-toolbar button:hover,
.message-body .code-toolbar button.copied,
.message-body .code-toolbar button[aria-pressed="true"] {
  border-color: #5a4d70;
  background: #221c2d;
  color: #f0eaf5;
}

.message-body .code-block pre {
  max-width: 100%;
  overflow: auto;
  margin: 0;
  padding: 18px;
  border: 0;
  border-radius: 0;
  background: #09080d;
  color: #e3dfe8;
  font: 13.5px/1.68 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  scrollbar-color: #3b3545 transparent;
}

.message-body .code-block.wrap-code pre { overflow-x: hidden; }
.message-body .code-block.wrap-code pre code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message-body .code-block.highlight-unavailable .code-language::after {
  content: ' · текст';
  color: var(--text-muted);
  font-weight: 500;
  text-transform: none;
}

.message-body .token.comment,
.message-body .token.prolog,
.message-body .token.doctype,
.message-body .token.cdata { color: #847b90; font-style: italic; }
.message-body .token.punctuation { color: #c8c2d1; }
.message-body .token.namespace { opacity: 0.78; }
.message-body .token.property,
.message-body .token.tag,
.message-body .token.constant,
.message-body .token.symbol,
.message-body .token.deleted { color: #f38ba8; }
.message-body .token.boolean,
.message-body .token.number { color: #f5c27a; }
.message-body .token.selector,
.message-body .token.attr-name,
.message-body .token.string,
.message-body .token.char,
.message-body .token.builtin,
.message-body .token.inserted { color: #a6e3a1; }
.message-body .token.operator,
.message-body .token.entity,
.message-body .token.url,
.message-body .language-css .token.string,
.message-body .style .token.string { color: #89dceb; }
.message-body .token.atrule,
.message-body .token.attr-value,
.message-body .token.keyword { color: #c792ea; }
.message-body .token.function,
.message-body .token.function-variable { color: #82aaff; }
.message-body .token.class-name,
.message-body .token.type-definition { color: #89dceb; }
.message-body .token.regex,
.message-body .token.important,
.message-body .token.variable { color: #fab387; }
.message-body .token.parameter { color: #f2cdcd; }
.message-body .token.bold,
.message-body .token.important { font-weight: 700; }
.message-body .token.italic { font-style: italic; }
.message-body .token.entity { cursor: help; }

.message-body .table-scroll {
  max-width: 100%;
  overflow: auto;
  margin: 18px 0 21px;
  border: 1px solid #302c37;
  border-radius: 11px;
  background: #111016;
  scrollbar-color: #3b3545 transparent;
}

.message-body .table-scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.message-body table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  background: #111016;
  font-size: 13.5px;
  line-height: 1.52;
}

.message-body th,
.message-body td {
  padding: 11px 14px;
  border-right: 1px solid #302c37;
  border-bottom: 1px solid #302c37;
  color: #ccc5d2;
  text-align: left;
  vertical-align: top;
}

.message-body th {
  background: #191720;
  color: #f0ebf3;
  font-weight: 700;
  white-space: nowrap;
}

.message-body th:last-child,
.message-body td:last-child { border-right: 0; }
.message-body tr:last-child td { border-bottom: 0; }
.message-body tbody tr:hover td { background: #17141d; }
.message-body th.align-center,
.message-body td.align-center { text-align: center; }
.message-body th.align-right,
.message-body td.align-right { text-align: right; }
.message-body th.align-left,
.message-body td.align-left { text-align: left; }

.message-body .math-inline {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  vertical-align: -0.08em;
}

.message-body .math-block {
  max-width: 100%;
  overflow-x: auto;
  margin: 18px 0 21px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #111016;
  text-align: center;
  scrollbar-color: #3b3545 transparent;
}

.message-body .math-block:focus-visible,
.message-body .code-block pre:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.message-body .math-source,
.message-body .math-error {
  color: #d9b0b8;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: pre-wrap;
}

.message-body .katex { color: #f0ebf3; font-size: 1.06em; }
.message-body .katex-display { margin: 0; }
.message-body .math-block .katex-display {
  width: max-content;
  min-width: 100%;
}

.message-body .footnotes {
  margin-top: 30px;
  padding-top: 2px;
  color: #a9a1b0;
  font-size: 13px;
  line-height: 1.6;
}

.message-body .footnotes-sep {
  margin: 0 0 17px;
}

.message-body .footnotes ol {
  margin-bottom: 0;
  padding-left: 22px;
}

.message-body .footnote-ref {
  margin-left: 1px;
  font-size: 0.76em;
  line-height: 0;
}

.message-body .footnote-ref a,
.message-body .footnote-backref {
  border-radius: 4px;
  color: #b7a0f4;
  text-decoration: none;
}

.message-body .footnote-backref {
  margin-left: 5px;
  font-size: 1.08em;
}

@media (max-width: 760px) {
  .message-body {
    font-size: 15px;
    line-height: 1.68;
  }

  .message-body h1 { font-size: 24px; }
  .message-body h2 { font-size: 20px; }
  .message-body h3 { font-size: 18px; }
  .message-body h4 { font-size: 16px; }
  .message-body h5 { font-size: 15px; }
  .message-body h6 { font-size: 12.5px; }

  .message-body ul,
  .message-body ol { padding-left: 22px; }

  .message-body .code-toolbar {
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 7px 8px 7px 12px;
  }

  .message-body .code-language-note {
    order: 3;
    width: 100%;
  }

  .message-body .code-toolbar button { min-height: 38px; }
  .message-body .code-block pre { padding: 15px; font-size: 13px; }
  .message-body .math-block { padding: 13px 12px; text-align: left; }
  .message-body th,
  .message-body td { padding: 10px 12px; }

  .message-body .remote-image-card {
    align-items: stretch;
    flex-direction: column;
  }

  .message-body .remote-image-actions {
    width: 100%;
  }

  .message-body .remote-image-actions button,
  .message-body .remote-image-actions a {
    min-height: 40px;
    flex: 1 1 50%;
  }
}

@media (max-width: 430px) {
  .message-body .code-toolbar { gap: 7px; }
  .message-body .code-actions { margin-left: auto; }
  .message-body .code-block pre { padding: 14px 12px; }
}

/* Parallel chat activity and clipboard attachments (1.7) */
.chat-activity {
  display: flex !important;
  align-items: center;
  gap: 6px;
}

.chat-activity span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-activity i {
  width: 8px;
  height: 8px;
  display: grid;
  flex: 0 0 8px;
  place-items: center;
  border-radius: 50%;
  font-style: normal;
}

.chat-activity.generating {
  color: #b9a9ed;
}

.chat-activity.generating i {
  width: 10px;
  height: 10px;
  flex-basis: 10px;
  border: 2px solid rgba(139, 112, 232, 0.28);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.chat-activity.ready {
  color: #77c9aa;
}

.chat-activity.ready i {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(87, 185, 148, 0.12);
}

.chat-activity.error {
  color: #ee929f;
}

.chat-activity.error i {
  width: 12px;
  height: 12px;
  flex-basis: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}

.chat-activity.error i::before {
  content: "!";
}

.chat-row.generating .chat-bubble {
  background: var(--accent-soft);
  color: #b9a9ed;
}

.chat-row.unread .chat-copy b {
  color: var(--text);
  font-weight: 700;
}

.chat-menu-item:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.toast.has-action {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.toast-action {
  min-height: 40px;
  padding: 5px 10px;
  border: 1px solid #51466b;
  border-radius: 7px;
  background: var(--accent-soft);
  color: #d8ccfa;
  font-size: 12px;
  font-weight: 650;
}

.toast-action:hover {
  border-color: #6b5a8e;
  background: #2a2140;
  color: #f3eeff;
}

@media (max-width: 760px) {
  #composer-shortcuts {
    max-width: 100%;
    text-align: right;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-activity.generating i {
    border-color: var(--accent);
    animation: none !important;
  }
}

@media (forced-colors: active) {
  .chat-activity i {
    border: 1px solid CurrentColor;
    forced-color-adjust: auto;
  }
}

/* Workspace organization, projects and richer controls — v1.8 */

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.chat-lists {
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.chat-list {
  min-height: auto;
  flex: 0 0 auto;
  overflow: visible;
  padding-right: 0;
}

.history-label {
  position: sticky;
  z-index: 5;
  top: 0;
  margin-top: 5px;
  background: linear-gradient(180deg, var(--surface-1) 82%, transparent);
}

.projects-section {
  flex: 0 0 auto;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

.projects-label {
  padding-right: 4px;
}

.project-add-button {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border-color: transparent;
  color: var(--text-muted);
}

.project-add-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
  color: var(--text);
}

.project-add-button svg,
.project-row svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project-group {
  position: relative;
  margin: 2px 0 4px;
  padding: 2px;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: border-color var(--ease), background var(--ease), box-shadow var(--ease);
}

.project-group.open {
  border-color: rgba(108, 83, 153, 0.22);
  background: rgba(36, 27, 52, 0.34);
}

.project-row {
  position: relative;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.project-toggle {
  min-width: 0;
  min-height: 42px;
  display: flex;
  flex: 1;
  align-items: center;
  gap: 9px;
  padding: 6px 4px 6px 7px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
}

.project-toggle:hover,
.project-toggle:focus-visible {
  background: var(--surface-hover);
  color: var(--text);
}

.project-folder {
  position: relative;
  width: 27px;
  height: 27px;
  display: grid;
  flex: 0 0 27px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--project-color) 45%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--project-color) 16%, transparent);
  color: var(--project-color);
}

.project-copy {
  min-width: 0;
  display: block;
  flex: 1;
}

.project-copy b,
.project-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-copy b {
  color: inherit;
  font-size: 12.5px;
  font-weight: 680;
}

.project-copy small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10.5px;
}

.project-chevron {
  width: 14px !important;
  height: 14px !important;
  color: var(--text-muted);
  transition: transform var(--ease);
}

.project-group.open .project-chevron {
  transform: rotate(180deg);
}

.project-quick-add,
.project-menu-trigger {
  width: 29px;
  height: 29px;
  display: grid;
  flex: 0 0 29px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  opacity: 0;
}

.project-row:hover .project-quick-add,
.project-row:hover .project-menu-trigger,
.project-quick-add:focus-visible,
.project-menu-trigger:focus-visible,
.project-menu-trigger[aria-expanded="true"] {
  opacity: 1;
}

.project-quick-add:hover,
.project-menu-trigger:hover,
.project-menu-trigger[aria-expanded="true"] {
  border-color: var(--border-strong);
  background: var(--surface-3);
  color: var(--text);
}

.project-menu-wrap {
  position: relative;
  display: flex;
}

.project-context-menu {
  top: calc(100% + 2px);
  right: 0;
  min-width: 205px;
}

.chat-context-menu.drop-up {
  top: auto;
  bottom: calc(100% - 2px);
}

.project-context-menu.drop-up {
  top: auto;
  bottom: calc(100% + 2px);
}

.project-chat-list {
  position: relative;
  margin: 1px 0 3px 14px;
  padding-left: 8px;
  border-left: 1px solid rgba(133, 102, 193, 0.28);
}

.project-chat-list .chat-row {
  min-height: 46px;
}

.project-chat-list .chat-bubble {
  width: 23px;
  height: 23px;
  flex-basis: 23px;
  background: transparent;
}

.chat-row[draggable="true"] .chat-bubble {
  cursor: grab;
}

.chat-row.processing .chat-activity { color: #bda8e9; }
.chat-row.streaming .chat-activity { color: #86cfb4; }
.chat-row.streaming .chat-activity i {
  border: 0;
  background: #68c39f;
  box-shadow: 0 0 0 3px rgba(104, 195, 159, .12);
  animation: status-pulse 1.1s ease-in-out infinite;
}

.chat-row.dragging {
  opacity: 0.36;
}

.chat-row.drag-before::after,
.chat-row.drag-after::after {
  content: "";
  position: absolute;
  z-index: 8;
  right: 7px;
  left: 7px;
  height: 2px;
  border-radius: 999px;
  background: #a881ff;
  box-shadow: 0 0 12px rgba(168, 129, 255, 0.75);
}

.chat-row.drag-before::after { top: -2px; }
.chat-row.drag-after::after { bottom: -2px; }

.project-group.drag-over,
.history-label.drag-over {
  border-color: #7955be;
  background: rgba(106, 70, 170, 0.17);
  box-shadow: inset 0 0 0 1px rgba(169, 129, 255, 0.18);
}

body.dragging-chat .chat-row[draggable="true"] {
  cursor: grabbing;
}

.chat-hover-card {
  position: fixed;
  z-index: 160;
  padding: 14px;
  border: 1px solid #44375b;
  border-radius: 14px;
  background: rgba(24, 18, 35, 0.98);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(156, 110, 255, 0.04);
  color: var(--text-secondary);
  pointer-events: none;
  backdrop-filter: blur(18px);
}

.chat-tooltip-head {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.chat-tooltip-head > span {
  width: 27px;
  height: 27px;
  display: grid;
  flex: 0 0 27px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: #bfa8f7;
}

.chat-tooltip-head svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.chat-tooltip-head b {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.chat-tooltip-meta,
.chat-tooltip-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 9px;
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 10.5px;
}

.chat-tooltip-meta span:not(:last-child)::after {
  content: "·";
  margin-left: 9px;
}

.chat-tooltip-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #c7b4f5;
  font-size: 11px;
  font-weight: 650;
}

.chat-tooltip-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chat-hover-card p {
  display: -webkit-box;
  margin: 11px 0 0;
  overflow: hidden;
  color: #c7c0d0;
  font-size: 12px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.chat-tooltip-foot {
  padding-top: 9px;
  border-top: 1px solid var(--border);
}

/* Custom model selector */

.topbar-subline {
  max-width: none;
  overflow: visible;
}

.model-selector {
  position: relative;
}

.model-selector-trigger {
  min-width: 210px;
  max-width: min(360px, 42vw);
  min-height: 35px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 9px 5px 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
}

.model-selector-trigger:hover,
.model-selector.open .model-selector-trigger {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.model-selector-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.model-selector-symbol {
  width: 26px;
  height: 26px;
  display: grid;
  flex: 0 0 26px;
  place-items: center;
  border: 1px solid #493766;
  border-radius: 8px;
  background: linear-gradient(145deg, #2f2145, #20172f);
  color: #b998f2;
}

.model-selector-symbol svg,
.model-selector .chevron,
.model-selector-search svg,
.model-option-check svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.model-selector-symbol svg { width: 15px; height: 15px; }

.model-selector-copy {
  min-width: 0;
  display: block;
  flex: 1;
}

.model-selector-copy small,
.model-selector-copy b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-selector-copy small {
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.06em;
  line-height: 1.1;
  text-transform: uppercase;
}

.model-selector-copy b {
  margin-top: 2px;
  color: inherit;
  font-size: 11.5px;
  font-weight: 680;
  line-height: 1.15;
}

.model-selector-trigger > .chevron {
  position: static;
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  color: var(--text-muted);
  transition: transform var(--ease);
}

.model-selector.open .model-selector-trigger > .chevron {
  transform: rotate(180deg);
}

.model-selector-menu {
  position: absolute;
  z-index: 180;
  top: calc(100% + 8px);
  left: 0;
  width: min(360px, calc(100vw - 28px));
  padding: 8px;
  border: 1px solid #44375b;
  border-radius: 15px;
  background: rgba(23, 17, 34, 0.985);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px);
}

.model-selector-search {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-muted);
}

.model-selector-search:focus-within { border-color: #6e52a1; }
.model-selector-search svg { width: 16px; height: 16px; }
.model-selector-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }

.model-selector-options {
  max-height: min(390px, 56vh);
  overflow-y: auto;
  padding-top: 7px;
}

.model-option {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
}

.model-option:hover,
.model-option:focus-visible {
  border-color: var(--border);
  background: var(--surface-hover);
  color: var(--text);
}

.model-option.selected {
  border-color: rgba(134, 93, 208, 0.38);
  background: rgba(96, 63, 151, 0.17);
}

.model-option-mark {
  width: 32px;
  height: 32px;
  display: grid;
  flex: 0 0 32px;
  place-items: center;
  border: 1px solid #493761;
  border-radius: 10px;
  background: linear-gradient(145deg, #302143, #20162e);
  color: #c5a7f7;
  font-size: 12px;
  font-weight: 750;
}

.model-option-copy { min-width: 0; display: block; flex: 1; }
.model-option-copy b,
.model-option-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-option-copy b { color: inherit; font-size: 12.5px; font-weight: 680; }
.model-option-copy small { margin-top: 4px; color: var(--text-muted); font-size: 10.5px; }
.model-option-check { width: 19px; height: 19px; display: grid; place-items: center; color: #b390f0; opacity: 0; }
.model-option.selected .model-option-check { opacity: 1; }
.model-option-check svg { width: 17px; height: 17px; stroke-width: 2.2; }
.model-option-empty { padding: 22px 12px; color: var(--text-muted); font-size: 12px; text-align: center; }

/* Project context and destructive actions */

.project-context-bar {
  width: min(920px, calc(100% - 32px));
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 auto 8px;
  padding: 7px 9px 7px 11px;
  border: 1px solid color-mix(in srgb, var(--project-color) 36%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--project-color) 7%, var(--surface-1));
}

.project-context-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--project-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--project-color) 15%, transparent);
}

.project-context-copy { min-width: 0; display: block; flex: 1; }
.project-context-copy small,
.project-context-copy b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-context-copy small { color: var(--text-muted); font-size: 10px; }
.project-context-copy b { margin-top: 2px; color: var(--text-secondary); font-size: 11.5px; }
.project-context-bar button { min-height: 28px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text-secondary); font-size: 10.5px; }
.project-context-bar button:hover { border-color: var(--border-strong); color: var(--text); }

.danger-hover:hover,
.danger-hover:focus-visible {
  border-color: rgba(224, 93, 116, 0.44) !important;
  background: rgba(137, 48, 67, 0.16) !important;
  color: #f29aaa !important;
}

.confirm-visual.danger {
  border-color: rgba(225, 91, 116, 0.38);
  background: rgba(147, 49, 68, 0.14);
  color: #ef8d9f;
}

.confirm-visual.project-visual {
  border-color: #574078;
  background: #251936;
  color: #c09afa;
}

#confirm-dialog-form .modal-actions kbd {
  margin-left: 6px;
  border-color: rgba(255,255,255,.2);
  background: rgba(0,0,0,.13);
}

.deletion-choices {
  display: grid;
  gap: 8px;
  margin: 18px 0 4px;
}

.deletion-choices label {
  min-height: 62px;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-1);
  cursor: pointer;
}

.deletion-choices label:hover { border-color: var(--border-strong); background: var(--surface-2); }
.deletion-choices label:has(input:checked) { border-color: #7050a3; box-shadow: inset 0 0 0 1px rgba(149, 102, 226, .16); }
.deletion-choices label.danger-choice:has(input:checked) { border-color: rgba(221, 84, 109, .55); background: rgba(121, 41, 57, .12); }
.deletion-choices input { margin-top: 4px; accent-color: var(--accent); }
.deletion-choices span { display: block; }
.deletion-choices b,
.deletion-choices small { display: block; }
.deletion-choices b { color: var(--text); font-size: 13px; }
.deletion-choices small { margin-top: 4px; color: var(--text-muted); font-size: 11px; line-height: 1.4; }

.project-colors {
  padding: 0;
  border: 0;
}

.project-colors legend { margin-bottom: 8px; color: var(--text-secondary); font-size: 12px; font-weight: 620; }
.project-colors > div { display: flex; flex-wrap: wrap; gap: 9px; }
.project-colors label { cursor: pointer; }
.project-colors input { position: absolute; opacity: 0; }
.project-colors label span { width: 28px; height: 28px; display: block; border: 2px solid transparent; border-radius: 50%; background: var(--swatch); box-shadow: inset 0 0 0 3px #15101e; transition: transform var(--ease), border-color var(--ease); }
.project-colors input:checked + span { border-color: #fff; transform: scale(1.1); }
.project-colors input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Message lifecycle and controls */

.stream-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  border: 1px solid rgba(135, 102, 194, .28);
  border-radius: 999px;
  background: rgba(91, 62, 145, .1);
  color: #bda6e9;
  font-size: 10px;
  font-weight: 650;
}

.stream-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.stream-status.processing i { animation: status-pulse 1.15s ease-in-out infinite; }
.stream-status.streaming { color: #8fd6bc; border-color: rgba(76, 175, 137, .25); background: rgba(47, 126, 96, .1); }
.stream-status.streaming i { box-shadow: 0 0 0 3px rgba(83, 188, 148, .11); }

@keyframes status-pulse {
  0%, 100% { opacity: .35; transform: scale(.78); }
  50% { opacity: 1; transform: scale(1); }
}

.message-actions {
  flex-wrap: wrap;
  gap: 5px;
}

.message-actions button[data-message-action="delete"],
.message-actions button[data-message-action="delete-from"] {
  color: var(--text-muted);
}

.message-actions button[data-message-action="delete"]:hover,
.message-actions button[data-message-action="delete-from"]:hover {
  border-color: rgba(225, 91, 116, .32);
  background: rgba(136, 45, 64, .12);
  color: #ef91a2;
}

.message-actions button[data-message-action="delete"] svg,
.message-actions button[data-message-action="delete-from"] svg,
.danger-hover svg,
.danger-button svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-preview-button,
.upload-remove-button {
  width: 27px !important;
  height: 27px !important;
  display: grid !important;
  flex: 0 0 27px;
  place-items: center;
  padding: 0 !important;
}

.upload-preview-button svg,
.upload-remove-button svg { width: 14px; height: 14px; }
.upload-preview-button { color: #bca3eb !important; }

/* Admin project oversight */

.workspace-health {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 10px;
  margin: -4px 0 18px;
}

.workspace-health > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(20, 15, 29, 0.7);
}

.workspace-health > div.is-live {
  border-color: rgba(101, 190, 154, 0.25);
  background: rgba(40, 104, 79, 0.08);
}

.workspace-health > div.is-warning {
  border-color: rgba(232, 137, 154, 0.32);
  background: rgba(139, 55, 76, 0.1);
}

.workspace-health-icon {
  width: 29px;
  height: 29px;
  display: grid;
  flex: 0 0 29px;
  place-items: center;
  border: 1px solid #43325d;
  border-radius: 9px;
  background: #251a35;
  color: #b89ae9;
}

.workspace-health-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace-health small,
.workspace-health b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-health small { color: var(--text-muted); font-size: 10.5px; }
.workspace-health b { margin-top: 2px; color: var(--text); font-size: 13px; }

.compact-stats { margin-bottom: 18px; }
.admin-project-name { display: flex; align-items: center; gap: 9px; min-width: 160px; }
.admin-project-name i { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 3px; background: var(--project-color); box-shadow: 0 0 0 4px color-mix(in srgb, var(--project-color) 13%, transparent); }
.project-context-preview { max-width: 280px; display: -webkit-box; overflow: hidden; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.table-actions button.danger:hover { color: #ef91a2; background: rgba(136, 45, 64, .12); }
.admin-context-full { max-height: min(55vh, 560px); overflow: auto; padding: 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text-secondary); font: 12px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-chat-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-right: 34px; }
.admin-chat-modal-head .modal-lead { margin-bottom: 0; }
.admin-chat-modal-head .danger-button { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; }
.admin-chat-modal-head .danger-button svg { width: 16px; height: 16px; }
.admin-chat-messages { margin-top: 24px; }
.admin-message-actions { opacity: 1; visibility: visible; }
.modal-loader { min-height: 180px; }

.research-activity {
  width: min(720px, 100%);
  margin: 2px 0 18px;
  overflow: hidden;
  border: 1px solid rgba(139, 108, 214, .24);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(24, 19, 32, .96), rgba(15, 13, 20, .96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
}

.research-activity > summary {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.research-activity > summary::-webkit-details-marker { display: none; }

.research-activity-icon {
  width: 32px;
  height: 32px;
  display: grid;
  flex: 0 0 32px;
  place-items: center;
  border: 1px solid rgba(154, 122, 232, .27);
  border-radius: 10px;
  background: rgba(112, 78, 178, .13);
  color: #bba4ef;
}

.research-activity-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.research-activity.active .research-activity-icon {
  animation: research-icon-pulse 1.45s ease-in-out infinite;
}

.research-activity-title {
  min-width: 0;
  display: block;
  flex: 1 1 auto;
}

.research-activity-title b,
.research-activity-title small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.research-activity-title b {
  color: #e7e0f2;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.research-activity-title small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}

.research-activity-chevron {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  margin: 0 4px 4px 8px;
  border-right: 1.5px solid #867b91;
  border-bottom: 1.5px solid #867b91;
  transform: rotate(45deg);
  transition: transform var(--ease);
}

.research-activity[open] .research-activity-chevron {
  margin-bottom: -4px;
  transform: rotate(225deg);
}

.research-steps {
  max-height: 286px;
  overflow: auto;
  padding: 3px 14px 12px 17px;
  border-top: 1px solid rgba(114, 94, 145, .14);
}

.research-step {
  position: relative;
  min-height: 43px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0 4px;
}

.research-step:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 25px;
  bottom: -10px;
  left: 5px;
  width: 1px;
  background: rgba(128, 107, 161, .27);
}

.research-step-marker {
  position: relative;
  z-index: 1;
  width: 11px;
  height: 11px;
  display: grid;
  flex: 0 0 11px;
  place-items: center;
  margin-top: 4px;
  border: 1px solid #66527f;
  border-radius: 50%;
  background: #17121f;
}

.research-step.active .research-step-marker {
  border-color: #a587e5;
  background: #a587e5;
  box-shadow: 0 0 0 4px rgba(154, 122, 232, .1);
  animation: status-pulse 1.15s ease-in-out infinite;
}

.research-step.done .research-step-marker::after {
  content: "";
  width: 4px;
  height: 2px;
  margin-top: -1px;
  border-left: 1.5px solid #ad9ad1;
  border-bottom: 1.5px solid #ad9ad1;
  transform: rotate(-45deg);
}

.research-step-copy {
  min-width: 0;
  display: block;
  flex: 1 1 auto;
}

.research-step-copy b,
.research-step-copy a,
.research-step-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.research-step-copy b,
.research-step-copy a {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
}

.research-step-copy a:hover { color: #c1b3f1; text-decoration: underline; }

.research-step-copy small {
  margin-top: 2px;
  color: #777080;
  font-size: 10.5px;
  line-height: 1.35;
}

.research-step-count {
  flex: 0 0 auto;
  padding-top: 2px;
  color: #716979;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

@keyframes research-icon-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(154, 122, 232, 0); }
  50% { box-shadow: 0 0 0 5px rgba(154, 122, 232, .08); }
}

@media (max-width: 900px) {
  .chat-hover-card { display: none !important; }
  .model-selector-trigger { min-width: 170px; max-width: 36vw; }
  .project-context-bar { width: calc(100% - 24px); }
  .admin-chat-modal-head { flex-direction: column; }
}

@media (max-width: 760px) {
  .workspace-health { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .model-selector-trigger { min-width: 0; max-width: min(48vw, 230px); }
  .model-selector-symbol { display: none; }
  .model-selector-menu { position: fixed; top: 62px; right: 10px; left: 10px; width: auto; }
  .project-quick-add,
  .project-menu-trigger { opacity: 1; }
  .project-context-bar { margin-bottom: 6px; }
  .project-context-copy small { display: none; }
  .message-actions { opacity: 1; visibility: visible; }
}

@media (max-width: 520px) {
  .workspace-health { grid-template-columns: 1fr; }
  .model-selector-copy small { display: none; }
  .model-selector-trigger { min-height: 32px; padding: 4px 5px; }
  .model-selector-copy b { margin-top: 0; }
  .project-context-bar { width: calc(100% - 16px); }
  .project-context-bar button { font-size: 0; }
  .project-context-bar button::after { content: "Изменить"; font-size: 10px; }
  .admin-chat-modal-head .danger-button span { display: none; }
  .research-activity { border-radius: 11px; }
  .research-activity > summary { padding: 9px 10px; }
  .research-steps { max-height: 240px; padding-right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .status.pending.processing::before { animation: none; }
  .stream-status.processing i { animation: none; }
  .research-activity.active .research-activity-icon,
  .research-step.active .research-step-marker { animation: none; }
}
