: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);
}

/* Login captcha: image + refresh button above a regular field input. */
.captcha-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.captcha-image {
  display: block;
  width: 176px;
  height: 56px;
  flex: 0 0 176px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
  cursor: pointer;
  transition: border-color var(--ease);
}

.captcha-image:hover {
  border-color: #504a59;
}

.captcha-input {
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  font-family: inherit;
  font-weight: 600;
}

.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);
  transition: width 0.2s ease, flex-basis 0.2s ease, padding 0.2s ease, transform 0.2s ease;
}

.sidebar-collapse-button {
  position: absolute;
  z-index: 3;
  top: 22px;
  right: -15px;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  flex-basis: 30px;
  border-color: var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: var(--shadow-menu);
}

.sidebar-collapse-button svg {
  width: 15px;
  height: 15px;
  transition: transform 0.2s ease;
}

@media (min-width: 761px) {
  .sidebar.collapsed {
    width: 72px;
    flex-basis: 72px;
    padding-inline: 10px;
  }

  .sidebar.collapsed .sidebar-collapse-button svg {
    transform: rotate(180deg);
  }

  .sidebar.collapsed .sidebar-head {
    justify-content: center;
    padding-inline: 0;
  }

  .sidebar.collapsed .brand > span:not(.brand-mark),
  .sidebar.collapsed .new-chat-button > b,
  .sidebar.collapsed .new-chat-button .shortcut,
  .sidebar.collapsed .sidebar-search input,
  .sidebar.collapsed .sidebar-search .search-clear,
  .sidebar.collapsed .chat-lists,
  .sidebar.collapsed .side-nav > span,
  .sidebar.collapsed .side-nav > b,
  .sidebar.collapsed .account-card > span:nth-child(2),
  .sidebar.collapsed .account-card > svg {
    display: none !important;
  }

  .sidebar.collapsed .new-chat-button,
  .sidebar.collapsed .sidebar-search,
  .sidebar.collapsed .side-nav,
  .sidebar.collapsed .account-card {
    width: 46px;
    min-width: 46px;
    margin-inline: auto;
    justify-content: center;
  }

  .sidebar.collapsed .new-chat-button {
    padding-inline: 10px;
  }

  .sidebar.collapsed .sidebar-search {
    padding: 0;
    cursor: pointer;
  }

  .sidebar.collapsed .sidebar-bottom {
    margin-top: auto;
  }

  .sidebar.collapsed .side-nav,
  .sidebar.collapsed .account-card {
    padding-inline: 5px;
  }
}

.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.active {
  border-color: rgba(151, 119, 225, .38);
  background: var(--accent-soft);
  color: #c9b8f2;
}

.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);
}

.tts-generation-progress {
  width: min(620px,100%);
  margin-top: 10px;
  padding: 12px 14px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb,var(--accent) 42%,var(--border));
  border-radius: 13px;
  background: linear-gradient(120deg,color-mix(in srgb,var(--accent) 9%,var(--surface-1)),var(--surface-1));
}
.tts-progress-head { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: 10px; }
.tts-progress-head > span:nth-child(2) { display: grid; gap: 2px; min-width: 0; }
.tts-progress-head b { color: var(--text); font-size: 12px; }
.tts-progress-head small,.tts-progress-head time { color: var(--text-muted); font-size: 10px; }
.tts-progress-icon { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid color-mix(in srgb,var(--accent) 42%,var(--border)); border-radius: 10px; color: var(--accent-hover); background: color-mix(in srgb,var(--accent) 14%,transparent); }
.tts-progress-icon svg { width: 17px; height: 17px; }
.tts-progress-track { position: relative; height: 4px; margin-top: 10px; overflow: hidden; border-radius: 99px; background: color-mix(in srgb,var(--accent) 12%,var(--surface-3)); }
.tts-progress-track i { position: absolute; inset: 0 auto 0 -35%; width: 35%; border-radius: inherit; background: linear-gradient(90deg,transparent,var(--accent-soft),var(--accent),transparent); animation: tts-progress-slide 1.35s cubic-bezier(.42,0,.58,1) infinite; }
.tts-generation-progress[data-state="queued"] .tts-progress-track i { animation-duration: 2.1s; opacity: .72; }
.tts-generation-progress[data-state="complete"] .tts-progress-track i { inset: 0; width: 100%; animation: none; background: var(--success); }
.tts-generation-progress[data-state="error"] { border-color: color-mix(in srgb,var(--danger) 52%,var(--border)); }
.tts-generation-progress[data-state="error"] .tts-progress-track i { inset: 0; width: 100%; animation: none; background: var(--danger); }
@keyframes tts-progress-slide { to { transform: translateX(390%); } }

.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 {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 8px 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  transition: border-color var(--ease), background var(--ease);
}

/* 2.8.18: the textarea takes the full width on top; the buttons sit in a
   compact toolbar row below it, so long text is never squeezed. */
.composer textarea {
  min-width: 0;
  min-height: 44px;
  max-height: 190px;
  width: 100%;
  flex: 1;
  resize: none;
  padding: 10px 4px 2px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 42px;
}

.composer-toolbar .composer-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

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

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

/* The old duplicate textarea block was removed in 2.8.18; the new
   layout rules are above near the .composer-toolbar rules. */

.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 {
  width: min(100%, 520px);
  min-width: min(100%, 340px);
  overflow: hidden;
  border: 1px solid rgba(145,111,207,.24);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(28,22,39,.96), rgba(15,13,20,.98));
  box-shadow: 0 12px 32px rgba(0,0,0,.16), inset 0 1px rgba(255,255,255,.025);
}
.audio-attachment audio { display: none; }
.audio-file-head { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 11px 12px 9px; }
.audio-file-icon {
  width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center;
  border: 1px solid rgba(167,127,239,.34); border-radius: 10px;
  background: linear-gradient(145deg, rgba(129,83,211,.3), rgba(75,48,122,.17)); color: #c9b0f6;
}
.audio-file-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.audio-file-copy { min-width: 0; flex: 1; display: grid; gap: 2px; }
.audio-file-copy b { overflow: hidden; color: var(--text); font-size: 12.5px; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.audio-file-copy small { color: var(--text-muted); font-size: 10.5px; }
.audio-download,
.audio-controls button {
  display: grid; place-items: center; border: 1px solid transparent; color: var(--text-secondary);
  transition: color .16s ease, border-color .16s ease, background .16s ease, transform .16s ease;
}
.audio-download { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px; }
.audio-download:hover { border-color: rgba(151,116,216,.28); background: rgba(130,91,201,.12); color: #d8c5fa; }
.audio-download svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.audio-controls {
  min-width: 0; display: grid; gap: 8px; padding: 10px 11px 11px;
  border-top: 1px solid rgba(145,111,207,.12); background: rgba(7,6,10,.22);
}
.audio-controls button { padding: 0; background: transparent; }
.audio-main-controls { min-width: 0; display: grid; grid-template-columns: 38px minmax(0,1fr); align-items: center; gap: 11px; }
.audio-extra-controls { min-width: 0; display: flex; align-items: center; gap: 6px; padding-left: 49px; }
.audio-play {
  width: 38px; height: 38px; border-color: rgba(170,131,240,.4) !important; border-radius: 50%;
  background: linear-gradient(145deg, #8d63dc, #6842ac) !important; color: #fff !important;
  box-shadow: 0 5px 16px rgba(104,66,172,.28);
}
.audio-play:hover { transform: translateY(-1px); box-shadow: 0 7px 20px rgba(104,66,172,.4); }
.audio-play:active { transform: scale(.96); }
.audio-play svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.audio-skip { width: auto; min-width: 52px; height: 28px; padding: 0 7px !important; border-radius: 8px; }
.audio-skip:hover,.audio-speed:hover,.audio-volume:hover { border-color: rgba(151,116,216,.22); background: rgba(130,91,201,.1); color: #d8c5fa; }
.audio-skip span { font-size: 9.5px; font-weight: 700; letter-spacing: -.15px; white-space: nowrap; }
.audio-timeline { min-width: 0; display: grid; gap: 5px; }
.audio-progress,.audio-volume-range {
  --audio-progress: 0%; width: 100%; height: 16px; margin: 0; appearance: none; -webkit-appearance: none;
  outline: none; cursor: pointer; background: transparent;
}
.audio-progress::-webkit-slider-runnable-track {
  height: 4px; border-radius: 99px;
  background: linear-gradient(90deg, #a97cf1 0 var(--audio-progress), rgba(204,187,221,.19) var(--audio-progress) 100%);
}
.audio-progress::-moz-range-track { height: 4px; border-radius: 99px; background: rgba(204,187,221,.19); }
.audio-progress::-moz-range-progress { height: 4px; border-radius: 99px; background: #a97cf1; }
.audio-progress::-webkit-slider-thumb {
  width: 13px; height: 13px; margin-top: -4.5px; appearance: none; -webkit-appearance: none;
  border: 2px solid #17121f; border-radius: 50%; background: #c9a9ff; box-shadow: 0 0 0 3px rgba(169,124,241,.12);
}
.audio-progress::-moz-range-thumb { width: 10px; height: 10px; border: 2px solid #17121f; border-radius: 50%; background: #c9a9ff; }
.audio-time { display: flex; justify-content: space-between; color: var(--text-muted); font: 9.5px/1 ui-monospace,SFMono-Regular,Consolas,monospace; }
.audio-speed { min-width: 36px; height: 30px; padding: 0 6px !important; border-radius: 8px; font-size: 10.5px; font-weight: 720; }
.audio-volume-wrap { min-width: 0; display: flex; flex: 1; align-items: center; justify-content: flex-end; gap: 5px; margin-left: auto; }
.audio-volume { width: 30px; height: 30px; border-radius: 8px; }
.audio-volume svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.audio-volume-range { --audio-volume:100%; width: min(78px,100%); min-width: 44px; height: 14px; }
.audio-volume-range::-webkit-slider-runnable-track { height: 3px; border-radius: 99px; background: linear-gradient(90deg,#a97cf1 0 var(--audio-volume),rgba(204,187,221,.16) var(--audio-volume) 100%); }
.audio-volume-range::-moz-range-track { height: 3px; border-radius: 99px; background: rgba(204,187,221,.16); }
.audio-volume-range::-moz-range-progress { height: 3px; background: #a97cf1; }
.audio-volume-range::-webkit-slider-thumb { width: 10px; height: 10px; margin-top: -3.5px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 50%; background: #c9a9ff; }
.audio-volume-range::-moz-range-thumb { width: 9px; height: 9px; border: 0; border-radius: 50%; background: #c9a9ff; }
.audio-status { display: none; padding: 0 12px 9px 57px; color: var(--text-muted); font-size: 10px; }
.audio-attachment:not(.ready) .audio-status,.audio-attachment.audio-error .audio-status { display: block; }
.audio-attachment.buffering .audio-play svg { opacity: 0; }
.audio-attachment.buffering .audio-play::after { content: ''; position: absolute; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .75s linear infinite; }
.audio-attachment.buffering .audio-play { position: relative; }
.audio-attachment.playing { border-color: rgba(162,119,238,.38); box-shadow: 0 12px 34px rgba(0,0,0,.19), 0 0 26px rgba(118,75,190,.08); }
.audio-attachment.playing .audio-file-icon { color: #decaff; box-shadow: 0 0 18px rgba(143,96,220,.14); }
.audio-attachment.audio-error { border-color: rgba(219,86,112,.34); }
.audio-attachment.audio-error .audio-status { color: #f0a0b0; }
@media (max-width: 520px) {
  .audio-attachment { min-width: 0; border-radius: 13px; }
  .audio-controls { gap: 8px; padding: 9px 10px 10px; }
  .audio-main-controls { gap: 10px; }
  .audio-extra-controls { gap: 4px; padding-left: 48px; }
  .audio-skip { min-width: 46px; padding-inline: 5px !important; }
  .audio-speed { min-width: 32px; padding-inline: 4px !important; }
  .audio-volume-range { width: min(62px,100%); min-width: 38px; }
  .audio-file-head { padding: 10px; }
  .audio-volume-wrap { gap: 3px; }
}

.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; }
.image-chat-progress { width: min(100%, 520px); padding: 13px 14px; }
.image-chat-progress > span { min-width: 0; display: grid; gap: 3px; }
.image-chat-progress b { color: var(--text); font-size: 13px; font-weight: 650; }
.image-chat-progress small { color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.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;
}

.toast.warning {
  border-color: #6a5326;
  background: var(--warning-soft);
  color: #e6c383;
}

/* Persistent composer warning: the current model's power is limited by the balance. */
.power-warning {
  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(--warning) 36%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--warning) 7%, var(--surface-1));
}

.power-warning svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  fill: none;
  stroke: var(--warning);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.power-warning span {
  min-width: 0;
  flex: 1;
  color: #e6c383;
  font-size: 13px;
  line-height: 1.45;
}

/* 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-collapse-button {
    display: none !important;
  }

  .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;
  max-width: none;
  overflow: visible;
  vertical-align: baseline;
}

.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);
}

.chat-context-menu.viewport-menu {
  position: fixed;
  z-index: 170;
  right: auto;
  bottom: auto;
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.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; }

/* Realtime administration and protected database browser */
.monitor-heading p { display: flex; align-items: center; gap: 7px; }
.monitor-live-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--success) 12%, transparent);
  animation: monitor-pulse 1.8s ease-in-out infinite;
}
.monitor-meter { height: 5px; margin-top: 13px; overflow: hidden; border-radius: 99px; background: var(--surface-3); }
.monitor-meter i { display: block; width: var(--monitor-value); height: 100%; border-radius: inherit; background: var(--success); transition: width .35s ease; }
.monitor-meter.warning i { background: #d6a34b; }
.monitor-meter.danger i { background: var(--danger); }
.monitor-health { grid-template-columns: repeat(4,minmax(0,1fr)); margin-bottom: 14px; }
.monitor-table { min-width: 820px; }
.monitor-grid { grid-template-columns: minmax(0,1.15fr) minmax(300px,.85fr); margin-top: 14px; }
.monitor-job-list,.monitor-error-list { display: grid; gap: 9px; }
.monitor-job-list article,.monitor-error-list article { min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--bg); }
.monitor-job-list article { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px 12px; }
.monitor-job-list article > div { display: grid; gap: 3px; }
.monitor-job-list b,.monitor-error-list b { overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.monitor-job-list small,.monitor-error-list span { color: var(--text-muted); font-size: 10px; }
.monitor-job-list .monitor-meter { grid-column: 1/-1; margin: 0; }
.monitor-job-list p,.monitor-error-list p { grid-column: 1/-1; overflow: hidden; margin: 0; color: var(--text-secondary); font-size: 11px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.monitor-error-list article { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 9px; }

.database-gate { width: min(580px,100%); margin: 6vh auto 0; padding: 28px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface-1); text-align: center; }
.database-gate .confirm-visual { margin: 0 auto 17px; }
.database-gate h2 { margin: 0; color: var(--text); font-size: 22px; }
.database-gate > p { margin: 10px auto 22px; color: var(--text-muted); font-size: 13px; line-height: 1.6; }
.database-unlock-form { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 10px; text-align: left; }
.database-unlock-form .primary-button { min-height: 42px; }
.database-gate .settings-inline-note { margin-top: 18px; text-align: left; }
.database-table-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.database-table-card { min-width: 0; display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 13px; border: 1px solid var(--border); border-radius: 12px; color: var(--text-secondary); background: var(--surface-1); text-align: left; }
.database-table-card:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.database-table-card > span { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; color: #bca7eb; background: var(--accent-soft); }
.database-table-card > span svg { width: 18px; height: 18px; fill: none; stroke: currentColor; }
.database-table-card > div { min-width: 0; display: grid; gap: 3px; }
.database-table-card b,.database-table-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.database-table-card b { color: var(--text); font-size: 13px; }
.database-table-card small,.database-table-card i { color: var(--text-muted); font-size: 10px; font-style: normal; }
.database-back { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 7px; }
.database-back svg { width: 15px; height: 15px; }
.database-columns { display: flex; gap: 7px; margin-bottom: 13px; padding-bottom: 3px; overflow-x: auto; }
.database-columns > span { min-width: max-content; display: grid; gap: 2px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); }
.database-columns b { color: var(--text); font-size: 11px; }
.database-columns small { color: var(--text-muted); font: 9px/1.3 ui-monospace,monospace; }
.database-rows { max-height: calc(100vh - 300px); }
.database-rows .data-table { width: max-content; min-width: 100%; }
.database-rows td { max-width: 380px; }
.database-cell { display: block; max-width: 360px; overflow: hidden; font: 11px/1.45 ui-monospace,SFMono-Regular,Consolas,monospace; text-overflow: ellipsis; white-space: pre; }
.database-null { color: var(--text-muted); font: italic 11px ui-monospace,monospace; }
@keyframes monitor-pulse { 50% { opacity:.45; transform:scale(.8); } }

@media (max-width: 1100px) {
  .monitor-health { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .database-table-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 720px) {
  .monitor-grid { grid-template-columns: 1fr; }
  .monitor-health,.database-table-grid { grid-template-columns: 1fr; }
  .database-unlock-form { grid-template-columns: 1fr; }
  .database-gate { margin-top: 0; padding: 20px; }
}
.modal-loader { min-height: 180px; }

.research-activity {
  position: relative;
  isolation: isolate;
  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);
}

.model-reasoning {
  position: relative;
  isolation: isolate;
  width: min(720px, 100%);
  margin: 2px 0 18px;
  overflow: hidden;
  border: 1px solid rgba(124, 109, 160, .24);
  border-radius: 13px;
  background: rgba(18, 15, 24, .9);
}

.research-activity > summary,
.research-activity > .research-steps,
.model-reasoning > summary,
.model-reasoning > .model-reasoning-scroll {
  position: relative;
  z-index: 1;
}

.research-activity > summary > :not(.live-panel-glow),
.model-reasoning > summary > :not(.live-panel-glow) {
  position: relative;
  z-index: 1;
}

.live-panel-glow {
  position: absolute;
  z-index: 0;
  inset: 0 auto 0 0;
  width: 24%;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(185, 139, 250, .22), rgba(124, 82, 192, .09), transparent);
  filter: blur(2px);
  transform: translate3d(-145%, 0, 0) skewX(-16deg);
  mix-blend-mode: screen;
}

.model-reasoning > summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.model-reasoning > summary::-webkit-details-marker { display: none; }
.model-reasoning-icon {
  width: 31px;
  height: 31px;
  display: grid;
  flex: 0 0 31px;
  place-items: center;
  border: 1px solid rgba(154, 122, 232, .25);
  border-radius: 9px;
  background: rgba(112, 78, 178, .12);
  color: #bba4ef;
}
.model-reasoning-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.model-reasoning-title { min-width: 0; flex: 1 1 auto; }
.model-reasoning > summary b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-reasoning > summary b { color: #d8d0e4; font-size: 13px; font-weight: 650; }
.model-reasoning > summary > i {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-right: 1.5px solid #81758f;
  border-bottom: 1.5px solid #81758f;
  transform: rotate(45deg);
  transition: transform .18s ease;
}
.model-reasoning[open] > summary > i { transform: rotate(225deg); }
.model-reasoning.active .model-reasoning-icon { animation: research-icon-pulse 1.45s ease-in-out infinite; }
.model-reasoning-scroll {
  max-height: min(340px, 42vh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  border-top: 1px solid rgba(124, 109, 160, .16);
  background: linear-gradient(180deg, rgba(11, 9, 16, .18), rgba(11, 9, 16, .38));
  scrollbar-color: #55436e transparent;
}
.model-reasoning-text {
  min-height: 48px;
  padding: 12px 16px 16px;
  color: #aaa1b5;
  font: 13px/1.65 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

.assistant-work-status {
  position: relative;
  isolation: isolate;
  width: min(720px, 100%);
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 2px 0 18px;
  padding: 12px 14px;
  overflow: hidden;
  border: 1px solid rgba(139, 108, 214, .27);
  border-radius: 13px;
  background: linear-gradient(115deg, rgba(22, 18, 30, .99) 0%, rgba(43, 29, 61, .94) 42%, rgba(28, 21, 39, .99) 68%, rgba(22, 18, 30, .99) 100%);
  background-size: 260% 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045), 0 10px 30px rgba(9, 5, 16, .16);
  animation: assistant-work-shimmer 3.2s ease-in-out infinite, assistant-work-breathe 2.4s ease-in-out infinite;
}

.assistant-work-status::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  width: 34%;
  background: linear-gradient(90deg, transparent, rgba(190, 148, 255, .09), transparent);
  transform: skewX(-18deg) translateX(-170%);
  animation: assistant-work-sweep 2.35s ease-in-out infinite;
  pointer-events: none;
}

.assistant-work-beam {
  position: absolute;
  z-index: 0;
  inset: 0 auto 0 0;
  width: 28%;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(215, 184, 255, .16), transparent);
  transform: translateX(-190%) skewX(-18deg);
  mix-blend-mode: screen;
}

.assistant-work-status::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 25px;
  top: 50%;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(154, 111, 231, .13);
  filter: blur(10px);
  transform: translate(-50%, -50%);
  animation: assistant-work-aura 1.8s ease-in-out infinite;
  pointer-events: none;
}

.assistant-work-copy { min-width: 0; flex: 1 1 auto; }
.assistant-work-status b,
.assistant-work-status small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assistant-work-status b { color: #e9e2f4; font-size: 13px; font-weight: 650; }
.assistant-work-status small { margin-top: 4px; color: var(--text-muted); font-size: 11px; }

.assistant-work-spinner {
  position: relative;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
    rgba(218, 197, 255, .98) 0deg,
    rgba(184, 143, 242, .62) 18deg,
    transparent 38deg 252deg,
    rgba(126, 86, 194, .2) 276deg,
    rgba(164, 116, 231, .72) 316deg,
    #dac5ff 356deg,
    rgba(218, 197, 255, .98) 360deg);
  box-shadow: 0 0 16px rgba(156, 112, 232, .25);
  animation: assistant-work-spin 1.05s linear infinite;
}
.assistant-work-spinner::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #181320;
  box-shadow: inset 0 0 0 1px rgba(192, 159, 246, .11);
}
.assistant-work-spinner i {
  position: absolute;
  z-index: 1;
  top: -1px;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #dac5ff;
  box-shadow: 0 0 6px #c7a3ff, 0 0 11px rgba(170, 119, 244, .68);
  transform: translateX(-50%);
}

.assistant-work-dots { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 4px; }
.assistant-work-dots i { width: 5px; height: 5px; border-radius: 50%; background: #bea2ef; box-shadow: 0 0 7px rgba(190, 151, 249, .38); animation: assistant-work-dot 1.15s ease-in-out infinite; }
.assistant-work-dots i:nth-child(2) { animation-delay: .14s; }
.assistant-work-dots i:nth-child(3) { animation-delay: .28s; }

@keyframes assistant-work-spin { to { transform: rotate(360deg); } }
@keyframes assistant-work-shimmer { 0%, 100% { background-position: 100% 0; } 50% { background-position: 0 0; } }
@keyframes assistant-work-dot { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }
@keyframes assistant-work-sweep { 0%, 20% { transform: skewX(-18deg) translateX(-170%); } 72%, 100% { transform: skewX(-18deg) translateX(430%); } }
@keyframes assistant-work-breathe { 0%, 100% { border-color: rgba(139, 108, 214, .27); } 50% { border-color: rgba(177, 134, 241, .48); } }
@keyframes assistant-work-aura { 0%, 100% { opacity: .5; transform: translate(-50%, -50%) scale(.82); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.18); } }

/* Safe client-rendered interactive charts from strict JSON data. */
.interactive-artifact {
  --artifact-border: rgba(137,108,202,.3);
  width: min(980px, 100%);
  margin: 18px 0;
  overflow: hidden;
  border: 1px solid var(--artifact-border);
  border-radius: 16px;
  color: #e8e2f0;
  background: linear-gradient(145deg,rgba(21,17,29,.99),rgba(11,9,16,.99));
  box-shadow: 0 18px 42px rgba(2,1,6,.2),inset 0 1px 0 rgba(255,255,255,.035);
  text-align: left;
}
.interactive-artifact button,.interactive-artifact input,.interactive-artifact select,.interactive-artifact textarea { font: inherit; }
.artifact-head { min-height: 60px; display: flex; align-items: center; gap: 11px; padding: 10px 13px; border-bottom: 1px solid rgba(137,108,202,.2); background: rgba(69,45,101,.08); }
.artifact-icon { width: 34px; height: 34px; display: grid; flex: 0 0 34px; place-items: center; border: 1px solid rgba(164,123,236,.3); border-radius: 10px; color: #cbb3fb; background: rgba(116,76,185,.15); font-weight: 700; }
.artifact-heading { min-width: 0; display: grid; flex: 1; gap: 2px; }
.artifact-heading b,.artifact-heading small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact-heading b { color: #f0eaf6; font-size: 14px; }
.artifact-heading small { color: #958aa3; font-size: 10.5px; }
.artifact-actions,.artifact-toolbar,.compare-controls,.slides-nav { display: flex; align-items: center; gap: 6px; }
.artifact-actions { flex: 0 0 auto; }
.artifact-actions button,.artifact-toolbar button,.compare-controls button,.slides-nav button {
  min-height: 31px; padding: 0 10px; border: 1px solid rgba(145,110,213,.28); border-radius: 8px; color: #cdbfe1; background: rgba(112,77,170,.1); font-size: 10px; cursor: pointer;
}
.artifact-actions button:hover,.artifact-toolbar button:hover,.compare-controls button:hover,.slides-nav button:hover { color: #fff; border-color: #8060b9; background: rgba(119,80,183,.22); }
.artifact-body { position: relative; min-height: 120px; }
.interactive-artifact-loading,.interactive-artifact-error { min-height: 130px; display: grid; place-content: center; gap: 6px; padding: 20px; border: 1px solid rgba(132,105,190,.25); border-radius: 13px; color: var(--text-muted); background: var(--surface-1); text-align: center; }
.interactive-artifact-stream .interactive-artifact-loading { grid-template-columns: 38px auto; grid-template-areas: "spinner title" "spinner text"; align-items: center; justify-content: center; column-gap: 12px; background: radial-gradient(circle at 20% 20%,rgba(128,86,203,.13),transparent 42%),var(--surface-1); }
.interactive-artifact-loading>i { grid-area: spinner; width: 34px; height: 34px; border: 3px solid rgba(150,111,220,.16); border-top-color: #a779f1; border-right-color: #7d55bd; border-radius: 50%; box-shadow: 0 0 16px rgba(142,94,222,.2); animation: artifact-stream-spin .8s linear infinite; }
.interactive-artifact-loading>b { grid-area: title; color: #eee7f7; text-align: left; }.interactive-artifact-loading>span { grid-area: text; font-size: 10.5px; text-align: left; }
@keyframes artifact-stream-spin { to { transform: rotate(360deg); } }
.interactive-artifact-error b { color: #e7dff2; }.interactive-artifact-error span { font-size: 11px; }
.interactive-artifact.is-expanded { position: fixed; z-index: 1500; inset: 14px; width: auto; margin: 0; display: flex; flex-direction: column; background: #0e0b13; }
.interactive-artifact.is-expanded .artifact-body { min-height: 0; flex: 1; overflow: auto; }
.artifact-toolbar { justify-content: space-between; padding: 10px 13px; border-bottom: 1px solid rgba(137,108,202,.14); }
.artifact-search { width: min(360px,75%); min-height: 34px; padding: 0 11px; border: 1px solid rgba(145,110,213,.24); border-radius: 9px; color: #e7e0ef; outline: none; background: rgba(5,4,8,.4); }
.artifact-search:focus { border-color: #8864c7; box-shadow: 0 0 0 3px rgba(126,87,197,.12); }
.artifact-count { color: #93879f; font-size: 10.5px; }
.artifact-table-wrap { max-height: 480px; overflow: auto; }
.artifact-data-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.artifact-data-table th { position: sticky; z-index: 2; top: 0; padding: 0; background: #181220; }
.artifact-data-table th button { width: 100%; padding: 10px 12px; border: 0; color: #ded4ea; background: transparent; text-align: left; white-space: nowrap; cursor: pointer; }
.artifact-data-table td { max-width: 360px; padding: 9px 12px; border-top: 1px solid rgba(137,108,202,.11); color: #bcb2c7; vertical-align: top; overflow-wrap: anywhere; }
.artifact-data-table tr:hover td { background: rgba(116,79,175,.07); }.artifact-data-table td.is-number { text-align: right; font-variant-numeric: tabular-nums; }
.artifact-graph-stage { position: relative; height: min(580px,68vh); overflow: auto; overscroll-behavior: contain; background-color: #100c16; background-image: radial-gradient(rgba(150,116,213,.17) 1px,transparent 1px),radial-gradient(circle at 50% 45%,rgba(116,75,180,.07),transparent 45%); background-size: 24px 24px,100% 100%; scrollbar-color: #624a83 transparent; }
.artifact-graph-stage svg { max-width: none; display: block; margin: auto; transition: width .18s ease,height .18s ease; }
.artifact-edge { fill: none; stroke: #71667d; stroke-width: 1.8; vector-effect: non-scaling-stroke; }.artifact-graph-stage marker path { fill: #71667d; }.artifact-edge-label { fill: #a69aad; font: 10px Inter,system-ui,sans-serif; paint-order: stroke; stroke: #100d15; stroke-width: 5px; }
.artifact-node { cursor: pointer; filter: drop-shadow(0 10px 16px rgba(0,0,0,.3)); outline: none; }.artifact-node rect { fill-opacity: .17; stroke-width: 1.6; vector-effect: non-scaling-stroke; }.artifact-node text { fill: #f2ecf8; font: 650 12px Inter,system-ui,sans-serif; pointer-events: none; }.artifact-node:hover rect,.artifact-node:focus rect { fill-opacity: .3; stroke-width: 2.6; }.artifact-node.is-root rect { fill-opacity: .32; stroke-width: 2.5; }.artifact-node.is-root text { font-size: 13px; }
.artifact-graph-details { position: sticky; z-index: 3; left: 12px; bottom: 12px; width: min(440px,calc(100% - 24px)); display: none; grid-template-columns: 1fr auto; gap: 5px 10px; padding: 12px 13px; border: 1px solid rgba(158,120,222,.38); border-radius: 12px; background: rgba(16,12,22,.96); box-shadow: 0 14px 34px rgba(0,0,0,.4); }.artifact-graph-details.visible { display: grid; }.artifact-graph-details p { grid-column: 1/-1; margin: 0; color: #aca1b7; font-size: 11px; }.artifact-graph-details button { grid-column: 2; grid-row: 1; border: 0; color: #a99cb6; background: transparent; cursor: pointer; }
.artifact-timeline { display: grid; gap: 1px; padding: 12px; }.timeline-row { display: grid; grid-template-columns: minmax(170px,34%) 1fr; align-items: center; gap: 14px; min-height: 66px; padding: 8px; border-radius: 10px; }.timeline-row:hover { background: rgba(115,78,174,.07); }.timeline-copy { display: grid; gap: 3px; }.timeline-copy b { font-size: 12px; }.timeline-copy small { color: #958a9f; font-size: 10px; }.timeline-copy p { margin: 3px 0 0; color: #ada2b8; font-size: 10.5px; }.timeline-track { position: relative; height: 34px; border-radius: 9px; background: rgba(113,85,146,.1); }.timeline-bar { position: absolute; top: 8px; height: 18px; min-width: 7px; overflow: hidden; border-radius: 6px; opacity: .84; }.timeline-bar i { display: block; height: 100%; background: rgba(255,255,255,.25); }
.artifact-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px; padding: 16px; }.artifact-field { display: grid; align-content: start; gap: 7px; color: #c6bbd1; font-size: 11px; }.artifact-field:has(textarea),.artifact-field:has(.artifact-options),.artifact-form>.artifact-primary { grid-column: 1/-1; }.artifact-field input,.artifact-field select,.artifact-field textarea { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid rgba(146,111,211,.25); border-radius: 9px; color: #eee8f4; outline: none; background: #0f0c14; resize: vertical; }.artifact-field input:focus,.artifact-field select:focus,.artifact-field textarea:focus { border-color: #8761c7; box-shadow: 0 0 0 3px rgba(130,91,196,.11); }.artifact-options { display: flex; flex-wrap: wrap; gap: 8px; }.artifact-options label { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border: 1px solid rgba(146,111,211,.2); border-radius: 8px; background: rgba(110,72,172,.07); }.artifact-range { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }.artifact-range output { min-width: 46px; color: #c8b2ee; text-align: right; font-variant-numeric: tabular-nums; }
.artifact-primary { min-height: 39px; padding: 0 15px; border: 1px solid #7650ba; border-radius: 10px; color: #fff; background: linear-gradient(135deg,#7854bd,#5d3d96); cursor: pointer; }.artifact-primary:hover { filter: brightness(1.12); }
.artifact-results { display: grid; grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); gap: 10px; padding: 0 16px 16px; }.artifact-result { display: grid; gap: 5px; padding: 12px; border: 1px solid rgba(144,108,207,.19); border-radius: 11px; background: rgba(109,73,167,.07); }.artifact-result small { color: #978b9f; }.artifact-result b { color: #d9c7f7; font-size: 18px; }.artifact-result b.artifact-result-error { color: #e98b9b; font-size: 12px; }
.artifact-board-frame { display: grid; min-width: 0; }.board-summary { display: grid; grid-template-columns: auto minmax(120px,240px) auto; align-items: center; gap: 12px; padding: 12px 14px 4px; }.board-summary>div:first-child { display: grid; }.board-summary span { color: #8f8499; font-size: 9.5px; }.board-summary strong { color: #cdb9ee; font-size: 11px; }.board-progress { height: 7px; overflow: hidden; border-radius: 999px; background: rgba(128,91,184,.13); }.board-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#7651bc,#45b98d); transition: width .25s ease; }
.artifact-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(245px,1fr); gap: 11px; padding: 12px; overflow-x: auto; }.board-column { position: relative; min-height: 300px; padding: 10px; overflow: hidden; border: 1px solid rgba(139,106,198,.2); border-radius: 14px; background: linear-gradient(180deg,color-mix(in srgb,var(--lane-color) 7%,transparent),rgba(72,47,101,.035) 90px); transition: border-color .16s ease,background .16s ease; }.board-column:before { content:""; position:absolute; inset:0 0 auto; height:2px; background:var(--lane-color); opacity:.75; }.board-column.is-drop-target { border-color: color-mix(in srgb,var(--lane-color) 70%,#fff); background-color: rgba(127,88,192,.12); }.board-column>header { display: flex; align-items: center; gap: 9px; padding: 4px 4px 12px; }.board-column>header i { width: 10px; height: 10px; flex:0 0 auto; border-radius: 50%; background:var(--lane-color); box-shadow:0 0 11px color-mix(in srgb,var(--lane-color) 60%,transparent); }.board-column>header div { min-width:0; display:grid; }.board-column>header small { color: #8e8299; font-size:9px; }.board-card-list { display:grid; align-content:start; gap:9px; min-height:220px; }.board-empty { display:grid; place-items:center; min-height:90px; border:1px dashed rgba(145,111,207,.17); border-radius:11px; color:#706779; font-size:10px; }.board-card { display: grid; gap: 9px; padding: 11px; border: 1px solid rgba(145,111,207,.21); border-radius: 11px; background: linear-gradient(145deg,#18131f,#120e18); box-shadow: 0 8px 18px rgba(0,0,0,.16); transition: transform .16s ease,opacity .16s ease,border-color .16s ease; }.board-card:hover { transform:translateY(-2px); border-color:rgba(157,119,224,.4); }.board-card.is-dragging { opacity:.42; transform:scale(.98); }.board-card-head { display:flex; align-items:flex-start; gap:8px; }.board-card-head b { flex:1; }.board-drag { color:#62596b; letter-spacing:-2px; cursor:grab; user-select:none; }.board-card p { margin: 0; color: #a69bab; font-size: 10.5px; line-height:1.45; }.board-tags { display: flex; flex-wrap: wrap; gap: 4px; }.board-tags span { padding: 3px 6px; border:1px solid rgba(148,108,215,.14); border-radius: 999px; color: #baa6dc; background: rgba(126,85,195,.13); font-size: 8.5px; }.board-card-footer { display:flex; align-items:center; gap:7px; padding-top:7px; border-top:1px solid rgba(145,111,207,.1); }.board-card-footer small { color:#786e81; }.board-move { min-width:0; flex:1; min-height: 28px; padding:0 7px; border: 1px solid rgba(145,111,207,.2); border-radius: 7px; color: #bcb0c8; background: #0e0b13; font-size: 9.5px; }
.artifact-quiz { display: grid; gap: 13px; padding: 16px; }.quiz-overview { display:grid; grid-template-columns:auto minmax(100px,1fr); align-items:center; gap:9px 13px; }.quiz-overview>span { color:#cfc4da; font-size:10px; font-weight:650; }.quiz-progress { height:7px; overflow:hidden; border-radius:999px; background:rgba(137,98,199,.13); }.quiz-progress i { display:block; height:100%; border-radius:inherit; background:linear-gradient(90deg,#7d59c3,#aa7be7); transition:width .22s ease; }.quiz-dots { grid-column:1/-1; display:flex; flex-wrap:wrap; gap:5px; }.quiz-dot { width:28px; height:28px; padding:0; border:1px solid rgba(145,111,207,.18); border-radius:8px; color:#8f8499; background:rgba(91,63,132,.06); cursor:pointer; }.quiz-dot.answered { color:#c5b3e3; border-color:rgba(151,111,222,.34); }.quiz-dot.active { color:#fff; border-color:#8b66cc; background:rgba(128,86,197,.25); box-shadow:0 0 0 3px rgba(128,86,197,.09); }.quiz-dot.correct { color:#87d4b4; border-color:rgba(64,181,131,.4); }.quiz-dot.wrong { color:#ef9cab; border-color:rgba(222,90,116,.4); }.quiz-question { display: grid; gap: 9px; margin: 0; padding: 18px; border: 1px solid rgba(145,111,207,.2); border-radius: 14px; background:linear-gradient(145deg,rgba(117,80,177,.07),rgba(8,6,11,.1)); }.quiz-question legend { width:100%; padding: 6px 0 9px; color: #eee7f5; font-weight: 680; font-size: 14px; line-height:1.45; }.quiz-kind { color:#8e8299; font-size:9.5px; }.quiz-option { display: grid; grid-template-columns:30px 1fr; gap: 9px; align-items: center; padding: 10px 12px; border:1px solid transparent; border-radius: 10px; color: #c4b9ce; background: rgba(110,75,163,.065); cursor: pointer; transition:border-color .15s ease,background .15s ease,transform .15s ease; }.quiz-option:hover { color: #fff; border-color:rgba(150,110,217,.25); background: rgba(116,79,177,.14); transform:translateX(2px); }.quiz-option:has(input:checked) { color:#fff; border-color:#7854b6; background:rgba(124,83,191,.2); }.quiz-option input { position:absolute; opacity:0; pointer-events:none; }.quiz-option i { width:28px; height:28px; display:grid; place-items:center; border:1px solid rgba(149,112,210,.25); border-radius:8px; color:#a998b8; background:#120e18; font-style:normal; font-size:10px; }.quiz-option.is-answer { border-color:rgba(67,190,137,.48); background:rgba(48,157,108,.11); }.quiz-option.is-mistake { border-color:rgba(221,89,116,.5); background:rgba(191,66,90,.1); }.quiz-nav { display:flex; justify-content:space-between; gap:9px; }.quiz-nav button { min-height:38px; padding:0 15px; border:1px solid rgba(145,110,213,.28); border-radius:10px; color:#cdbfe1; background:rgba(112,77,170,.1); cursor:pointer; }.quiz-nav button:disabled { opacity:.35; cursor:default; }.quiz-explanation { display:grid; gap:3px; margin-top:5px; padding:10px 12px; border-radius:9px; color:#bfb3cb; background:rgba(111,78,155,.11); font-size:10.5px; }.quiz-explanation.is-correct { border-left:3px solid #4cba8b; }.quiz-explanation.is-wrong { border-left:3px solid #df667f; }.quiz-score { display:flex; align-items:center; gap:12px; padding:12px 14px; border:1px solid rgba(145,111,207,.18); border-radius:11px; background:rgba(111,78,155,.09); }.quiz-score strong { color:#cfb2ff; font-size:22px; }.quiz-score div { color:#bfb3cb; font-size:11px; }
.compare-controls { padding: 10px 12px 0; }.artifact-compare { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; padding: 12px; }.compare-panel,.compare-diff { min-width: 0; padding: 12px; border: 1px solid rgba(145,111,207,.17); border-radius: 11px; background: rgba(8,6,11,.35); }.compare-panel { display: grid; gap: 8px; }.compare-panel pre { margin: 0; color: #b8adbf; font: 11.5px/1.65 Inter,system-ui,sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; }.compare-diff { grid-column: 1/-1; font: 11.5px/1.6 ui-monospace,monospace; }.compare-diff div { padding: 2px 7px; white-space: pre-wrap; }.compare-diff .added { color: #9bd6bb; background: rgba(48,157,108,.11); }.compare-diff .removed { color: #eca3ae; background: rgba(191,66,90,.1); }.compare-diff .same { color: #82788a; }
.artifact-variants { display: grid; grid-template-columns: repeat(auto-fit,minmax(210px,1fr)); gap: 9px; padding: 12px; }.variant-card { display: flex; align-items: flex-start; gap: 9px; padding: 12px; border: 1px solid rgba(145,111,207,.18); border-radius: 11px; background: rgba(106,72,158,.055); cursor: pointer; }.variant-card:has(input:checked) { border-color: #7955b7; background: rgba(116,78,179,.14); box-shadow: inset 0 0 0 1px rgba(151,109,218,.12); }.variant-card input { margin-top: 3px; }.variant-copy { min-width: 0; display: grid; gap: 5px; }.variant-copy small { color: #958a9f; }.variant-copy ul { display: grid; gap: 3px; margin: 2px 0 0; padding: 0; list-style: none; color: #aaa0b3; font-size: 10px; }.variant-pros li { color: #8ecdb0; }.variant-cons li { color: #dfa0aa; }.variant-preview { display: grid; gap: 8px; margin: 0 12px 12px; padding: 12px; border: 1px solid rgba(145,111,207,.15); border-radius: 11px; }.variant-preview article+article { padding-top: 10px; border-top: 1px solid rgba(145,111,207,.14); }.variant-preview h3,.variant-preview p { margin: 0; }.variant-preview p { margin-top: 5px; color: #b4a9bd; white-space: pre-wrap; }.variant-actions { display: flex; justify-content: flex-end; padding: 0 12px 12px; }
.artifact-map-frame { position:relative; }.artifact-map { height: min(540px,65vh); min-height: 360px; background: #17131d; }.artifact-map-status { position:absolute; z-index:500; inset:50% auto auto 50%; width:min(310px,calc(100% - 32px)); display:none; gap:5px; padding:14px 16px; border:1px solid rgba(160,121,222,.35); border-radius:12px; color:#b6aabd; background:rgba(17,13,23,.95); box-shadow:0 14px 34px rgba(0,0,0,.35); text-align:center; transform:translate(-50%,-50%); }.artifact-map-status.visible { display:grid; }.artifact-map-status b { color:#eee7f6; }.artifact-map-status span { font-size:10.5px; }.artifact-map-status a { color:#c49dfc; font-size:10.5px; }.artifact-map-note { display: block; padding: 7px 12px; color: #817689; font-size: 9px; }.artifact-map-pin-wrap { background: transparent; border: 0; }.artifact-map-pin { width: 20px; height: 20px; display: block; border: 3px solid white; border-radius: 50% 50% 50% 0; background: var(--pin); box-shadow: 0 5px 12px rgba(0,0,0,.4); transform: rotate(-45deg); }.artifact-map-popup { display: grid; gap: 4px; min-width: 130px; color: #24202a; }.artifact-map-popup p { margin: 0; }.interactive-artifact .leaflet-control-attribution { font-size: 9px; }
.artifact-document { width: min(760px,calc(100% - 24px)); min-height: 420px; margin: 12px auto; padding: clamp(26px,6vw,58px); border-radius: 3px; color: #26222a; background: #f8f6fa; box-shadow: 0 12px 34px rgba(0,0,0,.24); }.document-block { margin-bottom: 18px; }.document-block h3 { margin: 0 0 7px; color: #422c69; }.document-content { min-height: 1.2em; white-space: pre-wrap; line-height: 1.65; outline: none; }.document-content[contenteditable=true]:focus { box-shadow: 0 0 0 2px rgba(126,83,196,.22); background: rgba(128,83,199,.05); }.kind-quote .document-content { padding-left: 14px; border-left: 3px solid #8056c2; font-style: italic; }.kind-callout { padding: 12px; border-radius: 9px; background: #eee8f6; }
.slides-viewport { min-height: 420px; display: grid; place-items: center; padding: 18px; background: #09070c; }.artifact-slide { aspect-ratio: 16/9; width: min(760px,100%); display: flex; flex-direction: column; justify-content: center; gap: 13px; padding: 7%; border: 1px solid color-mix(in srgb,var(--accent) 45%,#333); border-radius: 6px; color: #f1edf5; background: radial-gradient(circle at 85% 15%,color-mix(in srgb,var(--accent) 20%,transparent),transparent 38%),linear-gradient(145deg,#1b1524,#0d0a12); box-shadow: 0 18px 48px rgba(0,0,0,.3); }.artifact-slide>small { color: var(--accent); }.artifact-slide h2 { margin: 0; font-size: clamp(22px,4vw,42px); line-height: 1.08; }.artifact-slide h3 { margin: 0; color: #c9bdd4; font-weight: 400; }.artifact-slide p,.artifact-slide ul { margin: 0; color: #c2b8ca; line-height: 1.55; }.slides-nav { justify-content: center; padding: 9px; }.slides-counter { min-width: 70px; color: #9c90a7; text-align: center; font-size: 10px; }.slides-thumbs { display: flex; gap: 6px; padding: 0 10px 10px; overflow-x: auto; }.slide-thumb { max-width: 150px; padding: 7px 9px; overflow: hidden; border: 1px solid rgba(142,108,205,.18); border-radius: 7px; color: #9c91a6; background: transparent; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }.slide-thumb.active { color: #fff; border-color: #7954b5; background: rgba(117,78,182,.17); }
.annotation-stage { position: relative; min-height: 380px; display: grid; place-items: center; overflow: hidden; background: repeating-conic-gradient(#17131e 0 25%,#131019 0 50%) 0/22px 22px; }.annotation-stage img { max-width: 100%; max-height: 640px; object-fit: contain; }.annotation-placeholder { color: #776d80; }.annotation-mark { position: absolute; display: grid; place-items: center; padding: 0; border: 2px solid var(--mark); border-radius: 5px; color: white; background: color-mix(in srgb,var(--mark) 14%,transparent); box-shadow: 0 0 0 1px rgba(0,0,0,.5); font-weight: 700; cursor: help; }.annotation-mark.type-point { border-radius: 50%; background: var(--mark); transform: translate(-50%,-50%); }.annotation-legend { display: grid; gap: 7px; padding: 11px; }.annotation-legend>div { display: grid; grid-template-columns: 24px auto 1fr; align-items: center; gap: 8px; }.annotation-legend i { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 7px; font-style: normal; }.annotation-legend span { color: #9f94a9; font-size: 10.5px; }
.artifact-sources { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(260px,.75fr); gap: 1px; background: rgba(139,107,202,.15); }.artifact-sources>section { min-width: 0; padding: 14px; background: #110e17; }.artifact-sources h3 { margin: 0 0 10px; font-size: 13px; }.source-claims article,.source-list article { margin-bottom: 8px; padding: 10px; border: 1px solid rgba(143,109,204,.16); border-radius: 9px; }.source-claims p,.source-list p { margin: 0; color: #b6acbf; font-size: 11px; }.source-refs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }.source-refs a,.source-list a { color: #bfa2f2; font-size: 10px; }.source-list article { display: grid; gap: 4px; }.source-list small { color: #786f80; font-size: 9px; }
.dashboard-metrics { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 9px; padding: 12px; }.dashboard-metric { position: relative; display: grid; gap: 5px; padding: 13px; overflow: hidden; border: 1px solid rgba(142,108,203,.18); border-radius: 11px; background: rgba(104,72,153,.06); }.dashboard-metric:before { content:""; position:absolute; inset:0 auto 0 0; width:3px; background:var(--metric); }.dashboard-metric small { color: #958a9f; }.dashboard-metric b { font-size: 20px; }.dashboard-metric span { color: #b6a5d3; font-size: 10px; }.dashboard-metric.good span { color:#68c9a2; }.dashboard-metric.bad span { color:#e98092; }.dashboard-metric.warn span { color:#e7ac65; }.dashboard-widgets { display: grid; grid-template-columns: repeat(auto-fit,minmax(240px,1fr)); gap: 9px; padding: 0 12px 12px; }.dashboard-widget { padding: 12px; border: 1px solid rgba(142,108,203,.17); border-radius: 11px; }.dashboard-widget h3 { margin: 0 0 10px; font-size: 12px; }.dashboard-widget p,.dashboard-widget ul { margin: 0; color: #afa4ba; font-size: 11px; }.dashboard-progress { height: 8px; margin-top: 8px; overflow: hidden; border-radius: 5px; background: rgba(130,98,166,.13); }.dashboard-progress i { display:block;height:100%;border-radius:inherit; }
.artifact-empty { min-height: 260px; display:grid;place-items:center;color:#8f8499; }

.interactive-chart {
  width: min(900px, 100%);
  margin: 18px 0;
  overflow: hidden;
  border: 1px solid rgba(132, 105, 190, .3);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(20, 16, 28, .98), rgba(12, 10, 17, .98));
  box-shadow: 0 16px 36px rgba(4, 2, 8, .18), inset 0 1px 0 rgba(255,255,255,.035);
}
.interactive-chart-head { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 13px 11px 16px; border-bottom: 1px solid rgba(132,105,190,.2); }
.interactive-chart-heading { min-width: 0; display: grid; gap: 3px; }
.interactive-chart-heading b,.interactive-chart-heading small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.interactive-chart-heading b { color: #eee9f6; font-size: 14px; }
.interactive-chart-heading small { color: var(--text-muted); font-size: 10.5px; }
.interactive-chart-actions { display: flex; flex: 0 0 auto; gap: 6px; }
.interactive-chart-actions button { min-height: 31px; padding: 0 10px; border: 1px solid rgba(139,108,214,.28); border-radius: 8px; color: #c9bbdf; background: rgba(111,76,171,.09); font-size: 10px; }
.interactive-chart-actions button:hover,.interactive-chart-actions button.active { border-color: #7152a6; color: #fff; background: rgba(116,78,181,.2); }
.interactive-chart-stage { position: relative; min-height: 310px; padding: 9px 12px 0; }
.interactive-chart-stage svg { width: 100%; height: auto; display: block; overflow: visible; }
.interactive-chart-loading,.interactive-chart-error { min-height: 130px; display: grid; place-content: center; gap: 6px; padding: 20px; border: 1px solid rgba(132,105,190,.25); border-radius: 13px; color: var(--text-muted); background: var(--surface-1); text-align: center; }
.interactive-chart-error b { color: #e7dff2; }
.interactive-chart-error span { font-size: 11px; }
.chart-grid line { stroke: rgba(154,137,181,.13); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-grid text,.chart-axis-label,.chart-axis-title { fill: #8f849e; font: 11px Inter,system-ui,sans-serif; }
.chart-axis-title { fill: #aaa0b8; font-size: 12px; }
.chart-line { stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 4px rgba(155,123,234,.18)); }
.chart-area { opacity: .13; }
.chart-point { stroke: #17111f; stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-pie-slice { stroke: #17111f; stroke-width: 2; transition: filter .16s ease, opacity .16s ease; }
.chart-pie-slice:hover { filter: brightness(1.18) drop-shadow(0 0 8px rgba(180,140,242,.25)); }
.chart-pie-center { fill: #15111d; stroke: rgba(154,122,232,.22); }
.chart-pie-total { fill: #e5dcef; font: 700 18px Inter,system-ui,sans-serif; }
.chart-empty { fill: #8f849e; font: 13px Inter,system-ui,sans-serif; }
.interactive-chart-hit { cursor: crosshair; }
.interactive-chart-tooltip { position: absolute; z-index: 4; min-width: 120px; max-width: 210px; display: grid; gap: 3px; padding: 8px 10px; border: 1px solid rgba(176,137,238,.42); border-radius: 9px; color: #ece6f5; background: rgba(19,14,27,.96); box-shadow: 0 10px 28px rgba(0,0,0,.35); font-size: 10.5px; pointer-events: none; }
.interactive-chart-tooltip[hidden] { display: none; }
.interactive-chart-tooltip span { color: #b6aac4; }
.interactive-chart-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 12px; padding: 2px 14px 13px; }
.interactive-chart-legend-item { display: inline-flex; align-items: center; gap: 6px; padding: 4px 7px; border: 0; border-radius: 7px; color: #bdb2ca; background: transparent; font-size: 10.5px; }
.interactive-chart-legend-item:hover { color: #fff; background: rgba(128,91,191,.12); }
.interactive-chart-legend-item i { width: 8px; height: 8px; border-radius: 50%; background: var(--chart-color); box-shadow: 0 0 7px color-mix(in srgb,var(--chart-color) 55%,transparent); }
.interactive-chart-legend-item.is-hidden { opacity: .38; text-decoration: line-through; }
.interactive-chart-table { max-height: 280px; overflow: auto; border-top: 1px solid rgba(132,105,190,.18); }
.interactive-chart-table[hidden] { display: none; }
.interactive-chart-table table { width: 100%; border-collapse: collapse; font-size: 11px; }
.interactive-chart-table th,.interactive-chart-table td { padding: 8px 11px; border-bottom: 1px solid rgba(132,105,190,.11); color: #ada3b9; text-align: right; white-space: nowrap; }
.interactive-chart-table th:first-child,.interactive-chart-table td:first-child { text-align: left; }
.interactive-chart-table th { position: sticky; top: 0; color: #ddd4e9; background: #17121f; }
.interactive-chart.is-expanded { position: fixed; z-index: 1200; inset: 18px; width: auto; margin: 0; display: flex; flex-direction: column; background: #0f0c14; }
.interactive-chart.is-expanded .interactive-chart-stage { min-height: 0; flex: 1 1 auto; display: grid; place-items: center; overflow: auto; }
.interactive-chart.is-expanded .interactive-chart-stage svg { max-width: min(1400px,100%); max-height: calc(100vh - 150px); }

/* Cohesive visual system for safe interactive answers. */
.interactive-artifact,.interactive-chart { width:min(980px,100%); border-color:rgba(145,112,209,.3); background:linear-gradient(155deg,#15111d,#0d0a12 68%); box-shadow:0 18px 46px rgba(0,0,0,.24),inset 0 1px 0 rgba(255,255,255,.035); }
.artifact-head,.interactive-chart-head { background:linear-gradient(90deg,rgba(123,83,190,.105),rgba(64,44,89,.035)); }
.artifact-actions button,.artifact-toolbar button,.compare-controls button,.slides-nav button,.interactive-chart-actions button { transition:border-color .16s ease,background .16s ease,color .16s ease,transform .16s ease; }
.artifact-actions button:hover,.artifact-toolbar button:hover,.compare-controls button:hover,.slides-nav button:hover,.interactive-chart-actions button:hover { transform:translateY(-1px); }

/* Charts */
.interactive-chart-stage { min-height:330px; padding:12px 14px 0; background:radial-gradient(circle at 50% 0,rgba(123,83,190,.045),transparent 48%); }
.chart-grid line { stroke:rgba(178,160,202,.11); }.chart-grid text,.chart-axis-label { fill:#998da7;font-size:10.5px; }.chart-axis-title { fill:#b9aac8;font-weight:600; }
.chart-value-label { fill:#cfc3da; font:600 9.5px Inter,system-ui,sans-serif; paint-order:stroke; stroke:#100c16; stroke-width:4px; }
.chart-pie-label { fill:#fff; font:700 11px Inter,system-ui,sans-serif; pointer-events:none; paint-order:stroke; stroke:rgba(13,10,18,.65); stroke-width:3px; }
.chart-line { stroke-width:2.6; }.chart-area { opacity:.09; }.chart-point { r:4; }
.interactive-chart-legend { padding:4px 14px 15px; }.interactive-chart-legend-item { border:1px solid transparent; }.interactive-chart-legend-item:hover { border-color:rgba(143,105,206,.18); }.interactive-chart-legend-item i { width:9px;height:9px; }

/* Data table */
.artifact-toolbar { min-height:52px; padding:9px 13px; background:rgba(7,5,10,.18); }.artifact-search { min-height:36px; background:#0d0a12; }
.artifact-data-table th { background:#181220; box-shadow:0 1px rgba(145,111,207,.13); }.artifact-data-table th button { padding:11px 13px; font-weight:650; }.artifact-data-table tbody tr:nth-child(even) td { background:rgba(103,71,151,.035); }.artifact-data-table td { height:43px; padding:10px 13px; }.artifact-data-table td>span { display:inline-flex; align-items:center; min-height:22px; }
.artifact-data-table td.is-number { text-align:right; }.artifact-data-table td.is-number>span { justify-content:flex-end;width:100%;font-variant-numeric:tabular-nums; }.artifact-data-table td.is-date>span { color:#b9aeca; font-variant-numeric:tabular-nums; }
.artifact-data-table td.table-status>span { min-width:46px; justify-content:center; padding:3px 8px; border-radius:999px; font-size:9.5px; font-weight:650; }.artifact-data-table td.table-status.is-yes>span { color:#7ed5ad;background:rgba(53,173,119,.12); }.artifact-data-table td.table-status.is-no>span { color:#aaa0b4;background:rgba(135,119,152,.1); }.artifact-data-table td.is-empty>span { color:#6f6577; }

/* Graphs */
.artifact-graph-stage { border-top:1px solid rgba(144,110,207,.1); background-color:#0f0c15; background-image:radial-gradient(rgba(151,116,213,.14) 1px,transparent 1px),radial-gradient(circle at 50% 38%,rgba(117,77,181,.08),transparent 52%); }
.artifact-node rect { fill-opacity:.2; }.artifact-node.is-root rect { fill-opacity:.38; }.artifact-node text { font-size:13px; }.artifact-edge { stroke:#887c94;stroke-width:1.65; }.artifact-edge-label { fill:#c0b3ca;font-size:10.5px; }

/* Timeline and Gantt */
.artifact-timeline.is-events { position:relative; display:grid; gap:0; padding:18px 20px 20px; }.artifact-timeline.is-events:before { content:""; position:absolute; top:28px; bottom:28px; left:154px; width:1px; background:linear-gradient(transparent,rgba(152,116,216,.42) 8%,rgba(152,116,216,.42) 92%,transparent); }
.timeline-event { position:relative; display:grid; grid-template-columns:112px 28px 1fr; align-items:center; gap:12px; min-height:92px; }.timeline-event>time { color:#9f92ab; font-size:10px; text-align:right; font-variant-numeric:tabular-nums; }.timeline-rail { position:relative; z-index:1; display:grid; place-items:center; }.timeline-rail i { width:12px;height:12px;border:3px solid #130f1a;border-radius:50%; }.timeline-event-card { display:grid; grid-template-columns:auto 1fr; gap:4px 10px; padding:13px 15px; border:1px solid rgba(143,109,204,.16); border-radius:12px; background:linear-gradient(135deg,rgba(115,78,171,.08),rgba(10,8,14,.2)); }.timeline-event-card>small { color:#796b87;font-size:9px; }.timeline-event-card>b { font-size:12.5px; }.timeline-event-card>p { grid-column:1/-1; margin:2px 0 0;color:#aaa0b5;font-size:10.5px; }.timeline-event-card>.timeline-status { grid-column:1/-1;justify-self:start; }
.artifact-timeline.is-gantt { display:grid;gap:4px;padding:14px 16px 18px; }.gantt-scale { display:grid;grid-template-columns:1fr auto 1fr;align-items:center;margin-left:min(34%,260px);padding:0 3px 7px;color:#8f8399;font-size:10.5px; }.gantt-scale span:last-child{text-align:right}.gantt-scale b{color:#b1a4bb;font-size:10.5px;font-weight:600}.artifact-timeline.is-gantt .timeline-row { grid-template-columns:minmax(230px,34%) 1fr; min-height:68px; padding:7px 4px; }.artifact-timeline.is-gantt .timeline-copy>b { font-size:13px; }.timeline-meta { display:flex;align-items:center;gap:7px;margin-top:5px;color:#a99eaf;font-size:10.5px; }.timeline-status { display:inline-flex;align-items:center;padding:3px 7px;border-radius:999px;color:#c1aedc;background:rgba(123,83,187,.16);font-size:9.5px;text-transform:lowercase; }.artifact-timeline.is-gantt .timeline-track { height:36px;background:rgba(108,81,139,.11);box-shadow:inset 0 0 0 1px rgba(145,111,207,.05); }.artifact-timeline.is-gantt .timeline-bar { top:7px;height:22px;min-width:22px;display:flex;align-items:center;justify-content:flex-end;overflow:visible;border-radius:7px;box-shadow:0 5px 14px rgba(0,0,0,.16); }.timeline-bar i { position:absolute;inset:0 auto 0 0;border-radius:inherit;background:rgba(255,255,255,.18); }.timeline-bar em { position:relative;z-index:1;padding-right:7px;color:#fff;font-size:9.5px;font-style:normal;text-shadow:0 1px 2px rgba(0,0,0,.45); }

/* Forms and calculators */
.artifact-form { gap:16px;padding:18px; }.artifact-field { gap:8px;color:#cfc4d8; }.artifact-field>span:first-child { color:#b9aec3;font-size:10.5px;font-weight:550; }.artifact-field input,.artifact-field select,.artifact-field textarea { min-height:42px;border-color:rgba(151,116,215,.24);background:#0d0a12;transition:border-color .16s ease,box-shadow .16s ease; }.artifact-field textarea { line-height:1.55; }.artifact-field input[type=range] { min-height:20px;padding:0;border:0;accent-color:#9069d8;background:transparent; }.artifact-range { grid-template-columns:1fr 48px;gap:12px; }.artifact-range output { display:grid;place-items:center;min-height:30px;border:1px solid rgba(148,111,211,.2);border-radius:8px;color:#d8c2fa;background:rgba(113,75,173,.1);font-weight:650; }
.artifact-options label { position:relative;min-width:48px;justify-content:center;padding:9px 11px;cursor:pointer; }.artifact-options label input { position:absolute;opacity:0;pointer-events:none; }.artifact-options label i { width:14px;height:14px;border:1px solid #6d6277;border-radius:50%;background:#15111c;box-shadow:inset 0 0 0 3px #15111c; }.artifact-options label:has(input:checked) { border-color:#805dbd;color:#fff;background:rgba(123,82,188,.18); }.artifact-options label:has(input:checked) i { border-color:#9a72df;background:#9a72df; }
.artifact-field.is-checkbox { position:relative;grid-column:1/-1;display:grid;grid-template-columns:22px 1fr;align-items:center;gap:10px;padding:11px 12px;border:1px solid rgba(147,111,209,.17);border-radius:10px;background:rgba(104,71,153,.045);cursor:pointer; }.artifact-field.is-checkbox>span { grid-column:2;grid-row:1;color:#c7bacf; }.artifact-field.is-checkbox input { position:absolute;opacity:0;pointer-events:none; }.artifact-checkbox-mark { grid-column:1;grid-row:1;width:18px;height:18px;border:1px solid #71647d;border-radius:5px;background:#100d15; }.artifact-field.is-checkbox:has(input:checked) { border-color:rgba(116,189,151,.35); }.artifact-field.is-checkbox:has(input:checked) .artifact-checkbox-mark { border-color:#52bb91;background:#52bb91;box-shadow:inset 0 0 0 4px #100d15; }
.artifact-primary { min-height:42px;background:linear-gradient(135deg,#8059c5,#6540a3);box-shadow:0 8px 18px rgba(77,44,128,.17); }.artifact-primary:disabled { opacity:.42;cursor:not-allowed;box-shadow:none; }.artifact-result { min-height:82px;justify-content:center;padding:14px 16px;background:linear-gradient(145deg,rgba(117,79,177,.09),rgba(9,7,12,.2)); }.artifact-result b { font-size:20px; }

/* Board and quiz */
.board-summary { grid-template-columns:minmax(130px,auto) minmax(140px,1fr) auto;padding:14px 16px 2px; }.artifact-board { padding:14px; }.board-column { min-height:285px; }.board-card-footer { opacity:.82; }.board-card:hover .board-card-footer { opacity:1; }
.artifact-quiz { padding:18px; }.quiz-question { padding:18px 20px; }.quiz-question h3 { margin:0 0 5px;color:#eee7f5;font-size:15px;line-height:1.45; }.quiz-kind { order:2; }.quiz-option { min-height:50px; }.quiz-score[hidden],.variant-preview[hidden] { display:none; }

/* Compare and variants */
.compare-controls { padding:12px 14px 0; }.compare-controls button.active { color:#fff;border-color:#805ebd;background:rgba(119,80,183,.22); }.artifact-compare { gap:12px;padding:12px 14px 15px; }.compare-panel { position:relative;gap:11px;padding:16px;overflow:hidden; }.compare-panel:before { content:"";position:absolute;inset:0 auto 0 0;width:3px;background:#8058c5; }.compare-panel:nth-child(2):before { background:#4ebc98; }.compare-panel>b { font-size:14px; }.compare-panel pre { padding:12px;border:1px solid rgba(144,108,207,.14);border-radius:9px;background:rgba(5,4,8,.26);line-height:1.75; }
.artifact-variants { gap:11px;padding:14px; }.variant-card { position:relative;display:grid;grid-template-columns:20px 1fr;gap:10px;min-height:170px;padding:14px; }.variant-card>input { position:absolute;opacity:0;pointer-events:none; }.variant-check { width:17px;height:17px;border:1px solid #6f6379;border-radius:5px;background:#100d15; }.variant-card:has(input:checked) .variant-check { border-color:#9b72df;background:#9b72df;box-shadow:inset 0 0 0 4px #17111f; }.variant-copy { gap:7px; }.variant-copy b { font-size:14px; }.variant-copy ul { gap:5px;margin-top:4px; }.variant-copy li:before { display:inline-block;width:14px;font-weight:800; }.variant-pros li:before { content:"+";color:#5dcc9c; }.variant-cons li:before { content:"−";color:#ec8698; }.variant-preview { margin:0 14px 12px;padding:12px 14px; }.variant-preview article { display:grid;gap:5px; }.variant-preview small { color:#9d82c7;font-size:9px;text-transform:uppercase;letter-spacing:.04em; }.variant-actions { align-items:center;justify-content:space-between;gap:12px;padding:0 14px 14px; }.variant-actions>span { color:#817589;font-size:9.5px; }

/* Map */
.artifact-map { min-height:430px; }.artifact-map .leaflet-tile { max-width:none!important;border:0!important;border-radius:0!important;box-shadow:none!important;filter:none!important;outline:0!important; }.artifact-map .leaflet-tile-pane,.artifact-map .leaflet-layer { border:0!important; }.artifact-map .leaflet-control-zoom a { color:#7f5ac0;background:#fff; }.artifact-map-pin { border-width:2px;box-shadow:0 6px 16px rgba(0,0,0,.42); }.artifact-map-note { background:rgba(7,5,10,.28); }

/* Document and slides */
.artifact-document { position:relative;width:min(780px,calc(100% - 32px));min-height:480px;margin:16px auto;padding:56px clamp(34px,7vw,72px) 60px;border-radius:5px;background:linear-gradient(#fbfafd,#f6f3f9);box-shadow:0 18px 42px rgba(0,0,0,.28); }.document-paper-meta { display:flex;justify-content:space-between;gap:12px;margin-bottom:34px;padding-bottom:11px;border-bottom:1px solid #ddd5e6;color:#72539f;font-size:9px;letter-spacing:.08em;text-transform:uppercase; }.document-paper-meta small { color:#998da2;letter-spacing:0;text-transform:none; }.document-block { margin-bottom:22px; }.document-block h3 { margin-bottom:9px;font-size:18px; }.document-content { color:#342d39;line-height:1.72; }.kind-quote { margin:25px 0;padding:16px 18px;border-left:4px solid #8056c2;border-radius:0 10px 10px 0;background:#211a2b; }.kind-quote h3 { color:#c9a9f2; }.kind-quote .document-content { padding:0;border:0;color:#f4eef8;font-size:15px; }.kind-callout { padding:15px 17px;border:1px solid #e1d8ec;border-left:4px solid #8056c2;background:#eee8f6; }.document-checklist { display:grid;gap:9px;margin:0;padding:0;list-style:none; }.document-checklist label { display:flex;align-items:center;gap:9px;color:#3b3440; }.document-checklist input { width:17px;height:17px;accent-color:#7650ba; }.document-checklist input:checked+span { color:#7b7180;text-decoration:line-through; }
.slides-viewport { min-height:440px;padding:20px;background:radial-gradient(circle at 50% 0,rgba(119,78,184,.09),transparent 42%),#09070c; }.artifact-slide { position:relative;isolation:isolate;overflow:hidden;padding:8%;border-color:color-mix(in srgb,var(--accent) 55%,#333);background:linear-gradient(135deg,#191321 0%,#0d0a12 72%); }.slide-orb { position:absolute;z-index:-1;right:-10%;top:-35%;width:52%;aspect-ratio:1;border-radius:50%;background:radial-gradient(circle,color-mix(in srgb,var(--accent) 38%,transparent),transparent 68%);filter:blur(2px); }.slide-number { align-self:flex-start;padding:4px 8px;border:1px solid color-mix(in srgb,var(--accent) 35%,transparent);border-radius:999px;background:color-mix(in srgb,var(--accent) 10%,transparent); }.artifact-slide h2 { max-width:78%;font-size:clamp(28px,5vw,48px); }.artifact-slide h3,.artifact-slide p,.artifact-slide ul { max-width:72%; }.slides-nav { padding:10px 14px; }.slides-progress { width:min(220px,35vw);height:5px;overflow:hidden;border-radius:999px;background:rgba(126,89,181,.14); }.slides-progress i { display:block;height:100%;border-radius:inherit;background:linear-gradient(90deg,#7651ba,#a875e6);transition:width .2s ease; }.slides-thumbs { padding:0 12px 12px; }.slide-thumb { min-height:36px; }

/* Sources, annotations and dashboard */
.artifact-sources { grid-template-columns:minmax(0,1.15fr) minmax(280px,.85fr); }.artifact-sources>section { padding:16px; }.source-claims article,.source-list article { padding:12px;border-radius:11px;background:rgba(104,70,153,.045); }.source-refs a { display:inline-flex;padding:3px 7px;border-radius:999px;background:rgba(121,81,185,.13);text-decoration:none; }.source-list article>a { font-weight:650; }.source-list small { color:#9b88b2; }
.annotation-stage { min-height:420px; }.annotation-legend { grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:8px;padding:13px; }.annotation-legend>div { padding:9px;border:1px solid rgba(143,108,204,.14);border-radius:9px;background:rgba(105,72,156,.045); }
.dashboard-metrics { gap:11px;padding:14px; }.dashboard-metric { min-height:112px;align-content:center;padding:16px; }.dashboard-metric:before { width:4px; }.dashboard-metric b { font-size:22px; }.dashboard-widgets { grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:11px;padding:0 14px 14px; }.dashboard-widget { min-height:112px;padding:15px;background:linear-gradient(145deg,rgba(105,72,156,.055),rgba(8,6,11,.15)); }.dashboard-widget h3 { margin-bottom:12px;font-size:12.5px; }.dashboard-widget li { margin:6px 0; }.dashboard-progress { height:9px; }
.compare-panel>small { color:#87779a;font-size:8.5px;text-transform:uppercase;letter-spacing:.08em; }.dashboard-status { display:flex;align-items:center;gap:9px;color:#d9d0e2; }.dashboard-status i { width:10px;height:10px;border:2px solid rgba(255,255,255,.25);border-radius:50%;box-shadow:0 0 10px currentColor; }.dashboard-status b { font-size:13px; }

@media (max-width: 700px) {
  .interactive-artifact.is-expanded { inset: 5px; }
  .artifact-head { align-items: flex-start; }.artifact-heading { padding-top: 3px; }.artifact-actions { flex-wrap: wrap; justify-content: flex-end; }
  .artifact-form { grid-template-columns: 1fr; }.artifact-field,.artifact-form>.artifact-primary { grid-column: 1; }
  .artifact-compare,.artifact-sources { grid-template-columns: 1fr; }.artifact-graph-stage.is-mindmap { height:480px!important; }.artifact-graph-stage.is-diagram { height:380px!important; }.timeline-row { grid-template-columns: 1fr; gap: 5px; }.artifact-map { min-height: 330px; }
  .artifact-document { width: calc(100% - 12px); margin: 6px; padding: 24px 19px; }.slides-viewport { min-height: 300px; padding: 7px; }.artifact-slide { padding: 9%; }
  .interactive-chart-head { align-items: flex-start; }
  .interactive-chart-stage { min-height: 245px; padding-inline: 2px; overflow-x: auto; }
  .interactive-chart-stage svg { min-width: 620px; }
  .interactive-chart-actions button { padding-inline: 7px; }
  .interactive-chart.is-expanded { inset: 6px; }
  .artifact-timeline.is-events:before { left:33px; }.timeline-event { grid-template-columns:28px 1fr;gap:8px; }.timeline-event>time { grid-column:2;text-align:left; }.timeline-rail { grid-column:1;grid-row:1/3; }.timeline-event-card { grid-column:2; }.artifact-timeline.is-gantt .timeline-row { grid-template-columns:1fr; }.gantt-scale { margin-left:0; }.board-summary { grid-template-columns:1fr auto; }.board-progress { grid-column:1/-1;grid-row:2; }.variant-actions { align-items:stretch;flex-direction:column; }.artifact-slide h2,.artifact-slide h3,.artifact-slide p,.artifact-slide ul { max-width:92%; }.slides-progress { width:100px; }
}

.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;
}

/* Personal file library */
.files-space {
  min-width: 0;
  height: 100%;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.files-topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px clamp(18px, 3vw, 42px);
  border-bottom: 1px solid var(--border);
  background: rgba(13, 11, 18, .92);
}
.files-topbar > div { min-width: 0; flex: 1 1 auto; }
.files-topbar > div > span { display: block; color: var(--text-muted); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
.files-topbar h1 { margin: 3px 0 0; color: var(--text); font-size: 24px; line-height: 1.1; }
.files-back { min-height: 38px; display: inline-flex; align-items: center; gap: 8px; }
.files-back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.files-content {
  width: 100%;
  max-width: 1500px;
  min-height: 0;
  margin: 0 auto;
  padding: 24px clamp(18px, 3vw, 42px) 42px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.files-overview { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.files-overview > div { min-width: 0; padding: 15px 17px; border: 1px solid var(--border); border-radius: 13px; background: linear-gradient(145deg,var(--surface-1),rgba(28,22,38,.72)); }
.files-overview span,.files-overview b { display: block; }
.files-overview span { color: var(--text-muted); font-size: 11px; }
.files-overview b { margin-top: 5px; overflow: hidden; color: var(--text); font-size: 20px; text-overflow: ellipsis; white-space: nowrap; }

.files-toolbar { display: flex; align-items: end; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-1); }
.files-search { min-width: 220px; min-height: 42px; display: flex; flex: 1 1 420px; align-items: center; gap: 9px; padding: 0 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-0); }
.files-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.files-search > svg,.files-search button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.files-search > svg { color: var(--text-muted); }
.files-search input { min-width: 0; flex: 1 1 auto; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 12px; }
.files-search button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; background: transparent; color: var(--text-muted); }
.files-select { min-width: 150px; display: grid; gap: 5px; }
.files-select > span { padding-left: 2px; color: var(--text-muted); font-size: 10px; }
.files-select select { height: 42px; padding: 0 32px 0 11px; border: 1px solid var(--border); border-radius: 10px; outline: 0; background: var(--surface-0); color: var(--text-secondary); font: inherit; font-size: 12px; }
.files-select select:focus { border-color: var(--accent); }
.files-view-toggle { height: 42px; display: flex; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-0); }
.files-view-toggle button { width: 36px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--text-muted); }
.files-view-toggle button.active { background: var(--accent-soft); color: #c4b2f3; }
.files-view-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.files-results-head { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.files-results-head b { color: var(--text); font-size: 14px; }
.files-results-head span { color: var(--text-muted); font-size: 11px; }

.files-library { display: grid; grid-template-columns: repeat(auto-fill,minmax(230px,1fr)); gap: 13px; }
.files-library.list { display: grid; grid-template-columns: 1fr; gap: 8px; }
.file-library-card { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-1); transition: transform var(--ease),border-color var(--ease),background var(--ease); }
.file-library-card:hover { border-color: rgba(151,119,225,.5); background: var(--surface-hover); transform: translateY(-1px); }
.file-library-preview { position: relative; width: 100%; aspect-ratio: 16/10; display: grid; place-items: center; overflow: hidden; border: 0; border-bottom: 1px solid var(--border); background: radial-gradient(circle at 50% 35%,rgba(113,76,174,.13),transparent 62%),#0b0910; color: #a996d5; }
.file-library-preview img { width: 100%; height: 100%; object-fit: cover; transition: transform .24s ease; }
.file-library-card:hover .file-library-preview img { transform: scale(1.025); }
.file-library-preview > svg { width: 48px; height: 48px; fill: none; stroke: currentColor; stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }
.file-library-badge { position: absolute; right: 9px; bottom: 9px; max-width: calc(100% - 18px); padding: 4px 7px; overflow: hidden; border: 1px solid rgba(255,255,255,.1); border-radius: 6px; background: rgba(9,7,12,.82); color: #c2b7d1; font-size: 9px; font-weight: 700; letter-spacing: .05em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; backdrop-filter: blur(8px); }
.file-library-copy { min-width: 0; padding: 12px 13px 9px; }
.file-library-copy b,.file-library-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-library-copy b { color: var(--text); font-size: 12.5px; }
.file-library-copy small { margin-top: 5px; color: var(--text-muted); font-size: 10.5px; }
.file-library-origin { min-width: 0; display: flex; align-items: center; gap: 6px; margin-top: 7px; color: #8f829d; font-size: 10.5px; }
.file-library-origin svg { width: 13px; height: 13px; flex: 0 0 13px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.file-library-origin span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-library-actions { display: flex; gap: 6px; padding: 0 10px 10px; }
.file-library-actions button,.file-library-actions a { min-width: 0; min-height: 34px; display: inline-flex; flex: 1 1 0; align-items: center; justify-content: center; gap: 6px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-secondary); font: inherit; font-size: 10.5px; text-decoration: none; }
.file-library-actions button:hover,.file-library-actions a:hover { border-color: #55466b; background: var(--accent-soft); color: #cbbbf0; }
.file-library-actions svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.files-library.list .file-library-card { display: grid; grid-template-columns: 76px minmax(0,1fr) auto; align-items: center; }
.files-library.list .file-library-preview { width: 76px; height: 66px; aspect-ratio: auto; border: 0; border-right: 1px solid var(--border); }
.files-library.list .file-library-preview > svg { width: 30px; height: 30px; }
.files-library.list .file-library-badge { display: none; }
.files-library.list .file-library-copy { padding: 9px 13px; }
.files-library.list .file-library-actions { min-width: 260px; padding: 8px 10px; }
.files-empty { grid-column: 1/-1; min-height: 320px; display: grid; place-items: center; padding: 30px; border: 1px dashed var(--border); border-radius: 14px; color: var(--text-muted); text-align: center; }
.files-empty > div { max-width: 420px; }
.files-empty svg { width: 46px; height: 46px; margin-bottom: 14px; fill: none; stroke: #7f6b9f; stroke-width: 1.35; }
.files-empty b,.files-empty span { display: block; }
.files-empty b { color: var(--text-secondary); font-size: 15px; }
.files-empty span { margin-top: 6px; font-size: 11.5px; line-height: 1.55; }
.files-loader { grid-column: 1/-1; min-height: 300px; display: grid; place-items: center; color: var(--text-muted); }
.files-loader > div { display: grid; justify-items: center; gap: 10px; }
.files-loader i { width: 28px; height: 28px; border: 2px solid rgba(151,119,225,.18); border-top-color: #9777e1; border-radius: 50%; animation: spin .8s linear infinite; }
.files-pagination { display: flex; justify-content: center; gap: 6px; padding: 24px 0 0; }
.files-pagination button { min-width: 36px; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text-secondary); font: inherit; font-size: 11px; }
.files-pagination button.active { border-color: var(--accent); background: var(--accent-soft); color: #d0c1f4; }
.files-pagination button:disabled { opacity: .4; }

/* Project workspace and independent file organization */
#files-title:focus { outline: none; }
.project-open[aria-current="page"] { background: var(--accent-soft); color: var(--text); border-radius: 9px; }
.project-expand { flex: 0 0 28px; width: 28px; height: 32px; display: grid; place-items: center; padding: 4px; border: 0; border-radius: 7px; background: transparent; color: var(--text-muted); }
.project-expand:hover { background: var(--surface-hover); color: var(--text); }
.project-expand .project-chevron { margin: 0; width: 16px; height: 16px; }
.project-workspace-head { margin-bottom: 20px; }
.project-workspace-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.project-workspace-head p { max-width: 800px; color: var(--text-muted); font-size: 12px; line-height: 1.7; margin: 15px 0 22px; }
.project-tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--border); }
.project-tabs button { display: flex; align-items: center; gap: 10px; padding: 13px 18px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-muted); font: inherit; }
.project-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.project-tabs button span { padding: 2px 7px; border-radius: 6px; background: var(--accent-soft); font-size: 11px; }
.project-chat-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-bottom: 18px; }
.project-chat-tools .files-search { flex: 1 1 240px; max-width: 540px; }
.project-archive-filter { color: var(--text-muted); font-size: 12px; }
.project-workspace-chats { display: grid; grid-template-columns: repeat(auto-fill,minmax(300px,1fr)); gap: 14px; }
.project-chat-card { min-width: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-1); overflow: hidden; }
.project-chat-card:hover { border-color: var(--accent); }
.project-chat-open { display: flex; align-items: flex-start; gap: 12px; width: 100%; min-height: 115px; text-align: left; padding: 18px; border: 0; background: transparent; color: var(--text); font: inherit; }
.project-chat-open > svg { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 1.6; color: var(--text-muted); }
.project-chat-open > span { flex: 1; min-width: 0; display: grid; gap: 8px; }
.project-chat-open b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-chat-open small { color: var(--text-muted); font-size: 10px; line-height: 1.5; }
.project-chat-open span span { color: var(--text-secondary); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.project-chat-actions { display: flex; flex-wrap: wrap; gap: 5px; padding: 10px 12px; border-top: 1px solid var(--border); }
.project-chat-actions button { padding: 5px 7px; border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); font: inherit; font-size: 11px; }
.project-chat-actions button:hover { background: var(--surface-hover); color: var(--text); }
.project-chat-actions button:disabled { opacity: .4; }
.files-selection-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 15px; font-size: 12px; color: var(--text-muted); }
.files-selection-bar label { display: flex; align-items: center; gap: 7px; }
.files-selection-bar .secondary-button { padding: 7px 12px; min-height: 32px; font-size: 11px; }
.file-library-card { position: relative; }
.file-library-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.file-select { position: absolute; z-index: 1; top: 10px; left: 10px; display: grid; place-items: center; padding: 6px; border-radius: 7px; background: var(--surface-1); border: 1px solid var(--border); cursor: pointer; }
.file-select input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.files-library.list .file-select { top: 8px; left: 8px; padding: 3px; }
.project-items-list { max-height: min(45vh,400px); overflow-y: auto; margin: 15px 0; border: 1px solid var(--border); border-radius: 12px; }
.project-item-option { display: flex; gap: 12px; align-items: center; padding: 12px 15px; border-bottom: 1px solid var(--border); cursor: pointer; }
.project-item-option:last-child { border-bottom: 0; }
.project-item-option:hover { background: var(--surface-hover); }
.project-item-option > span { display: grid; min-width: 0; gap: 5px; }
.project-item-option b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.project-item-option small { font-size: 11px; color: var(--text-muted); }
.project-items-pagination { display: flex; gap: 15px; align-items: center; justify-content: center; font-size: 12px; }
@media (max-width: 1000px) {
  .files-toolbar { flex-wrap: wrap; }
  .files-toolbar .files-search { flex-basis: 100%; }
  .files-select { min-width: 0; flex: 1 1 140px; }
  .files-select select { width: 100%; min-width: 0; }
}
@media (max-width: 600px) {
  .project-workspace-chats { grid-template-columns: minmax(0,1fr); }
  .project-workspace-actions > .primary-button,.project-workspace-actions > .secondary-button { flex: 1 1 40%; padding: 10px; }
  .project-workspace-actions .icon-button { margin-left: auto; }
  .files-topbar h1 { overflow-wrap: anywhere; font-size: 21px; line-height: 1.25; }
  .files-selection-bar { gap: 10px; }
  .project-expand { min-height: 36px; }
}

/* 2.9.0 «Озвучивание текста» */
.voiceover-space {
  min-width: 0;
  height: 100%;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.voiceover-content {
  width: 100%;
  max-width: 860px;
  min-height: 0;
  margin: 0 auto;
  padding: 24px clamp(18px, 3vw, 42px) 42px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 16px;
  align-content: start;
}
.voiceover-tool.panel,.voiceover-history.panel { padding: 20px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-1); }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title b { color: var(--text); font-size: 15px; }
.panel-title span { display: block; margin-top: 3px; color: var(--text-muted); font-size: 11px; }
.voiceover-form { display: grid; gap: 12px; }
.voiceover-form textarea { width: 100%; min-height: 132px; resize: vertical; padding: 12px 13px; border: 1px solid var(--border); border-radius: 10px; outline: 0; background: var(--surface-0); color: var(--text); font: inherit; font-size: 13px; line-height: 1.55; }
.voiceover-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.voiceover-controls { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.voiceover-voice-field.wide { display: block; }
.voiceover-voices { display: flex; flex-wrap: wrap; gap: 8px; }
.voice-chip { display: inline-flex; align-items: stretch; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-0); overflow: hidden; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.voice-chip:hover { border-color: #55466b; }
.voice-chip.active { border-color: rgba(170,131,240,.55); background: linear-gradient(145deg, rgba(141,99,220,.16), rgba(104,66,172,.1)); box-shadow: 0 6px 18px rgba(104,66,172,.14); }
.voice-chip-select { display: grid; gap: 2px; padding: 8px 12px; border: 0; background: transparent; color: var(--text-secondary); font: inherit; text-align: left; cursor: pointer; }
.voice-chip-select b { color: var(--text); font-size: 12.5px; line-height: 1.2; }
.voice-chip-select small { color: var(--text-muted); font-size: 9.5px; }
.voice-chip.active .voice-chip-select b { color: #d9c8fb; }
.voice-chip-sample { width: 38px; display: grid; place-items: center; gap: 0; border: 0; border-left: 1px solid var(--border); background: rgba(141,99,220,.07); color: #b79ae8; cursor: pointer; }
.voice-chip-sample:hover { background: rgba(141,99,220,.16); color: #d9c8fb; }
.voice-chip-sample svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.voice-chip-sample .voice-eq { display: none; align-items: flex-end; gap: 2px; height: 14px; }
.voice-chip-sample .voice-eq i { width: 3px; border-radius: 2px; background: currentColor; animation: voice-eq-bounce .9s ease-in-out infinite; }
.voice-chip-sample .voice-eq i:nth-child(1) { height: 6px; animation-delay: 0s; }
.voice-chip-sample .voice-eq i:nth-child(2) { height: 12px; animation-delay: .18s; }
.voice-chip-sample .voice-eq i:nth-child(3) { height: 8px; animation-delay: .36s; }
.voice-chip-sample .voice-eq i:nth-child(4) { height: 11px; animation-delay: .54s; }
.voice-chip-sample.playing { background: linear-gradient(145deg, #8d63dc, #6842ac); color: #fff; }
.voice-chip-sample.playing svg { display: none; }
.voice-chip-sample.playing .voice-eq { display: flex; }
@keyframes voice-eq-bounce { 0%, 100% { transform: scaleY(.55); } 50% { transform: scaleY(1.25); } }
.voiceover-result-note { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: #b9e3b9; font-size: 11.5px; }
.voiceover-result-note svg { width: 16px; height: 16px; fill: none; stroke: #7fd07f; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.voiceover-item .audio-attachment { border: 0; padding: 10px 12px; }
.voiceover-item-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 0 12px 10px; }
.voiceover-ttl { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-0); color: var(--text-muted); font-size: 10.5px; white-space: nowrap; }
.voiceover-ttl.soon { border-color: rgba(224,141,90,.45); background: rgba(224,141,90,.1); color: #eab98f; }
.voiceover-item-foot .voiceover-delete { color: #e79a9a; }
.voiceover-item-foot .voiceover-delete:hover { color: #f2b8b8; }
.voiceover-request-text { margin: 0 12px 12px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface-0); color: var(--text-secondary); font: 12px/1.6 ui-monospace,SFMono-Regular,Consolas,monospace; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow-y: auto; }
/* 2.9.4: balance pill + retention hint inside full-screen toolbars */
.files-topbar .balance-pill { flex: 0 0 auto; }
.files-retention-hint { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10.5px; }
.voiceover-meta { display: grid; gap: 3px; flex: 1 1 160px; color: var(--text-muted); font-size: 11px; }
.voiceover-meta #voiceover-price { color: #cbbbf0; font-weight: 600; }
#voiceover-submit { min-height: 42px; display: inline-flex; align-items: center; gap: 8px; }
#voiceover-submit svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#voiceover-submit:disabled { opacity: .5; cursor: not-allowed; }
.voiceover-player { width: 100%; min-width: 200px; max-width: 340px; height: 38px; }
.voiceover-result-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-0); }
.voiceover-result-meta { min-width: 0; flex: 1 1 200px; display: grid; gap: 3px; }
.voiceover-result-meta b { color: var(--text); font-size: 12.5px; word-break: break-word; }
.voiceover-result-meta small { color: var(--text-muted); font-size: 11px; }
.voiceover-history-list { display: grid; gap: 10px; }
.voiceover-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 11px 13px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-0); }
.voiceover-item.failed { border-style: dashed; opacity: .75; }
.voiceover-item-copy { min-width: 0; flex: 1 1 190px; }
.voiceover-item-copy b { display: block; overflow: hidden; color: var(--text); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.voiceover-item-copy small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10.5px; }
.admin-audio-cell { min-width: 220px; max-width: 280px; }
.admin-audio-cell audio { width: 100%; height: 34px; }

@media (max-width: 640px) {
  .voiceover-controls { align-items: stretch; flex-direction: column; }
  .voiceover-voice-field { max-width: none; }
  .voiceover-result-card,.voiceover-item { align-items: stretch; flex-direction: column; }
  .voiceover-player { max-width: none; }
}

.message.message-highlight { animation: file-message-highlight 2.4s ease-out; }
@keyframes file-message-highlight { 0%,30% { background: rgba(126,87,200,.16); box-shadow: 0 0 0 12px rgba(126,87,200,.08); } 100% { background: transparent; box-shadow: 0 0 0 0 transparent; } }

@media (max-width: 1050px) {
  .files-toolbar { flex-wrap: wrap; }
  .files-search { flex-basis: 100%; }
  .files-select { flex: 1 1 180px; }
  .files-overview { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .files-topbar { min-height: 64px; padding: 10px 12px; }
  .files-topbar h1 { font-size: 20px; }
  .files-back span { display: none; }
  .files-content { padding: 14px 10px 28px; }
  .files-overview { gap: 8px; }
  .files-overview > div { padding: 12px; }
  .files-overview b { font-size: 16px; }
  .files-toolbar { padding: 9px; }
  .files-select { min-width: 0; flex-basis: calc(50% - 5px); }
  .files-view-toggle { width: 100%; }
  .files-view-toggle button { flex: 1 1 50%; }
  .files-library { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .file-library-copy { padding: 10px; }
  .file-library-actions { flex-direction: column; }
  .files-library.list .file-library-card { grid-template-columns: 62px minmax(0,1fr); }
  .files-library.list .file-library-preview { width: 62px; height: 62px; grid-row: 1; }
  .files-library.list .file-library-actions { grid-column: 1/-1; min-width: 0; flex-direction: row; padding-top: 0; }
}

@media (max-width: 460px) {
  .files-library { grid-template-columns: 1fr; }
  .files-overview { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@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,
  .model-reasoning.active .model-reasoning-icon,
  .research-step.active .research-step-marker { animation: none; }
  .assistant-work-status {
    animation-duration: 3.2s, 2.4s !important;
    animation-iteration-count: infinite, infinite !important;
  }
  .assistant-work-status::before {
    animation-duration: 2.35s !important;
    animation-iteration-count: infinite !important;
  }
  .assistant-work-status::after {
    animation-duration: 1.8s !important;
    animation-iteration-count: infinite !important;
  }
  .assistant-work-spinner {
    animation-duration: .9s !important;
    animation-iteration-count: infinite !important;
  }
  .assistant-work-dots i {
    animation-duration: 1.15s !important;
    animation-iteration-count: infinite !important;
  }
}
/* All five resource levels remain accessible on narrow screens. */
.composer-power-row{display:flex;align-items:center;gap:10px;padding:8px 2px 0;border-top:1px solid var(--border,rgba(150,130,180,.18));margin-top:7px;font-size:12px;color:var(--muted,#a59bb5)}
#response-power{display:flex;gap:4px;align-items:center}
#response-power button{width:28px;height:26px;display:flex;align-items:center;padding:0 2px;border:0;background:transparent;border-radius:5px;cursor:pointer}
#response-power button span{height:7px;width:100%;border-radius:3px;background:rgba(150,130,180,.22);transition:background .15s}
#response-power button.filled span{background:var(--accent,#9571e8)}
#response-power button[aria-checked="true"] span{box-shadow:0 0 0 2px rgba(166,134,235,.25)}
#response-power button:focus-visible{outline:2px solid var(--accent,#9571e8);outline-offset:1px}
#response-power-label{color:var(--text,#e8e1f1);min-width:65px}
.power-help{cursor:help;margin-left:auto}
.power-help .sr-only{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}
.research-activity-title small:has([data-elapsed-start]){white-space:normal;overflow:visible}
.model-reasoning-title small{display:block;color:var(--text-muted);font-size:11px;margin-top:2px}
@media(max-width:480px){.composer-power-row{gap:7px}#response-power button{width:24px}}

/* Available funds and temporary holds are separate amounts. */
.balance-pill:has(.balance-reserved){display:grid;grid-template-columns:minmax(0,1fr) auto;gap:3px 7px;text-align:left;max-width:none;flex-shrink:0}
.balance-pill>.balance-main{display:flex;align-items:center;gap:7px;grid-column:1}
.balance-pill .balance-reserved{grid-column:1;color:var(--text-muted);font-size:10px;white-space:nowrap}
.balance-pill:has(.balance-reserved) .balance-add{grid-column:2;grid-row:1 / 3}
.chat-reservation{margin:0 0 8px;color:var(--text-secondary);font-size:12px;line-height:1.5}
.admin-channel-filter{display:flex;align-items:center;flex-wrap:wrap;gap:12px;margin-bottom:20px}
.admin-channel-filter label{display:flex;align-items:center;gap:10px;font-weight:600}
.admin-channel-filter select{padding:9px 30px 9px 12px;border:1px solid var(--border);border-radius:8px;background:var(--surface-1);color:var(--text)}
.admin-channel-filter small{color:var(--text-muted)}
.request-channel{display:inline-block;border:1px solid var(--border);border-radius:6px;padding:3px 7px;font-size:11px;white-space:nowrap}
.request-channel.api{background:var(--accent-soft);color:#c9b4ff;border-color:var(--accent)}
.request-channel+small{display:block;margin-top:5px;max-width:180px;overflow-wrap:anywhere}
@media(max-width:480px){.balance-pill>.balance-main>span{display:none}.balance-pill .balance-reserved{font-size:10px}.admin-channel-filter{gap:8px}.chat-reservation{font-size:11px}}
