:root {
  color-scheme: dark;
  --bg: #070708;
  --bg-elevated: #111114;
  --bg-surface: #16161b;
  --bg-hover: #1e1e24;
  --fg: #f5f5f7;
  --fg-muted: #9a9aa6;
  --fg-dim: #666672;
  --line: #24242b;
  --line-strong: #34343e;
  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, 0.14);
  --accent-glow: rgba(139, 92, 246, 0.32);
  --warn: #f59e0b;
  --danger: #ef4444;
  --success: #22c55e;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.hidden {
  display: none !important;
}

/* ===== Главная оболочка ===== */
.app {
  height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.topbar {
  height: 60px;
  flex: none;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(7, 7, 8, 0.92);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.top-left,
.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  color: var(--fg);
  font-size: 18px;
  transition: background 0.18s, border-color 0.18s;
}

.icon-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.8px;
  color: var(--fg);
}

.brand-logo {
  display: block;
  object-fit: contain;
  border-radius: 50%;
  background: #000;
}

.logo-header {
  width: 26px;
  height: 26px;
  box-shadow: 0 0 12px var(--accent-glow);
}

.logo-medium {
  width: 58px;
  height: 58px;
  box-shadow: 0 0 20px var(--accent-glow);
}

.logo-large {
  width: 88px;
  height: 88px;
  padding: 12px;
  box-shadow: 0 0 36px var(--accent-glow);
}

.logo-hero {
  width: 78px;
  height: 78px;
  padding: 12px;
  box-shadow: 0 0 36px var(--accent-glow);
  animation: logoPulse 3.2s ease-in-out infinite;
}

.logo-animated {
  animation: logoPulse 2.4s ease-in-out infinite, markHue 7s linear infinite;
}

@keyframes logoPulse {
  0%, 100% {
    transform: scale(0.96);
    box-shadow: 0 0 22px rgba(139, 92, 246, 0.25);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 42px rgba(139, 92, 246, 0.52);
  }
}

@keyframes markHue {
  0% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(28deg); }
  100% { filter: hue-rotate(0deg); }
}

.top-action,
.pill-badge {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  color: var(--fg);
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.18s, border-color 0.18s;
}

.top-action:hover,
.pill-badge.clickable:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.pill-badge {
  color: var(--fg-muted);
  font-size: 12px;
}

/* ===== Тело приложения: боковая панель + рабочая область ===== */
.app-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
  position: relative;
}

.sidebar {
  width: 272px;
  flex: none;
  border-right: 1px solid var(--line);
  background: #0a0a0c;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: width 0.22s ease, opacity 0.22s ease, transform 0.22s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  border-right-width: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar-top {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.sidebar-new-btn {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  color: var(--fg);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: border-color 0.18s, background 0.18s;
}

.sidebar-new-btn:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.sidebar-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.sidebar-empty {
  padding: 16px 10px;
  color: var(--fg-dim);
  font-size: 12px;
  text-align: center;
  line-height: 1.5;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  margin-bottom: 4px;
  transition: background 0.15s;
}

.chat-item:hover {
  background: var(--bg-hover);
}

.chat-item.active {
  background: var(--accent-soft);
}

.chat-item-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 8px 8px;
  font-size: 13px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-del {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: var(--radius-sm);
  color: var(--fg-dim);
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.chat-item:hover .chat-item-del,
.chat-item.active .chat-item-del {
  opacity: 1;
}

.chat-item-del:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  flex: none;
}

.sidebar-user {
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.18s;
}

.sidebar-user:hover {
  border-color: var(--accent);
}

.sidebar-user span {
  font-weight: 500;
  font-size: 13px;
}

.sidebar-user small {
  color: var(--fg-muted);
  font-size: 11px;
}

.sidebar-backdrop {
  display: none;
}

/* ===== Рабочая область чата ===== */
.chat-workspace {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.chat-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  position: relative;
  padding: 32px 20px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.welcome {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.welcome-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.welcome-inner h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.4px;
}

.welcome-sub {
  margin: 0;
  color: var(--fg-muted);
  font-size: 14px;
}

.messages {
  width: min(780px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.message {
  max-width: 100%;
  font-size: 15px;
  line-height: 1.7;
  color: var(--fg);
}

.message.user {
  align-self: flex-end;
  max-width: 82%;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  padding: 12px 16px;
  border-radius: 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.assistant {
  align-self: stretch;
}

.assistant-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.logo-stage {
  width: 22px;
  height: 22px;
  padding: 2px;
  box-shadow: 0 0 12px var(--accent-glow);
}

.message.assistant.is-generating .logo-stage {
  animation: logoPulse 1.8s ease-in-out infinite;
}

.assistant-model-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
}

.message-content {
  overflow-wrap: anywhere;
  line-height: 1.72;
}

.message-content p {
  margin: 0 0 10px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content ul,
.message-content ol {
  margin: 8px 0 12px;
  padding-left: 22px;
}

.message-content h1,
.message-content h2,
.message-content h3 {
  margin: 16px 0 8px;
  font-weight: 600;
  line-height: 1.35;
}

.message-content h1 { font-size: 19px; }
.message-content h2 { font-size: 17px; }
.message-content h3 { font-size: 15px; }

.message-content code.inline-code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 6px;
}

/* Блок кода */
.code-block {
  margin: 12px 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: #0c0c0f;
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #141419;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--fg-muted);
}

.code-lang {
  font-family: "JetBrains Mono", monospace;
  text-transform: lowercase;
  font-size: 11px;
  color: var(--fg-muted);
}

.copy-code-btn {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  color: var(--fg);
  font-size: 11px;
  transition: border-color 0.15s, background 0.15s;
}

.copy-code-btn:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #ececf1;
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 2px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounceDot 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounceDot {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.msg-action-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--fg-muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.msg-action-btn:hover {
  color: var(--fg);
  border-color: var(--accent);
  background: var(--bg-hover);
}

.msg-action-btn.selected {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.msg-action-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===== Нижнее поле ввода (всегда внизу) ===== */
.composer-wrap {
  width: min(820px, calc(100% - 32px));
  flex: none;
  margin: 0 auto;
  padding: 8px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.context-warning {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.1);
  color: #fcd34d;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.context-warning.critical {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.queue-banner {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  font-size: 12px;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: logoPulse 1.4s infinite;
}

.link-btn {
  margin-left: auto;
  color: var(--fg);
  text-decoration: underline;
  font-size: 12px;
}

.input-shell {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  padding: 12px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s;
}

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

.input-shell textarea {
  width: 100%;
  resize: none;
  min-height: 28px;
  max-height: 180px;
  outline: 0;
  line-height: 1.55;
  color: var(--fg);
}

.input-shell textarea::placeholder {
  color: var(--fg-dim);
}

.input-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.composer-controls,
.composer-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.select-wrap {
  position: relative;
}

.select-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--radius-pill);
  color: var(--fg-muted);
  font-size: 13px;
  transition: color 0.15s, background 0.15s;
}

.select-trigger:hover,
.select-trigger[aria-expanded="true"] {
  color: var(--fg);
  background: var(--bg-hover);
}

.chevron {
  font-size: 13px;
  transition: transform 0.15s;
}

.select-trigger[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.select-separator {
  width: 1px;
  height: 14px;
  background: var(--line-strong);
}

.select-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  min-width: 220px;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  background: #141418;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.75);
  z-index: 30;
}

.select-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--fg-muted);
  text-align: left;
}

.select-menu button:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.select-menu button.selected {
  background: var(--accent-soft);
  color: var(--fg);
}

.select-menu small {
  font-size: 11px;
  color: var(--fg-dim);
}

.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  color: var(--fg-muted);
  font-size: 12px;
  transition: all 0.18s;
}

.tool-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-button.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Круговой индикатор контекста */
.context-meter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--bg-surface);
  font-size: 11px;
  color: var(--fg-muted);
}

.context-ring {
  width: 20px;
  height: 20px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 3.5;
}

.ring-fill {
  fill: none;
  stroke: var(--fg);
  stroke-width: 3.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s ease, stroke 0.25s ease;
}

.context-meter.warn .ring-fill { stroke: var(--warn); }
.context-meter.warn { color: #fcd34d; border-color: rgba(245, 158, 11, 0.45); }

.context-meter.critical .ring-fill { stroke: var(--danger); }
.context-meter.critical { color: #fca5a5; border-color: rgba(239, 68, 68, 0.5); }

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--fg);
  color: #000;
  display: grid;
  place-items: center;
  transition: transform 0.15s, background 0.15s;
}

.send-btn:hover {
  background: #d8c8ff;
  transform: translateY(-1px);
}

.send-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.send-btn.is-stop {
  background: var(--accent-soft);
  color: var(--fg);
  border: 1px solid var(--accent);
}

.send-btn.is-stop svg {
  fill: currentColor;
}

.composer-footer-note {
  text-align: center;
  font-size: 11px;
  color: var(--fg-dim);
}

/* ===== Модальные окна и полноэкранные состояния ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.gate-box,
.modal-card {
  width: min(420px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 30px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  position: relative;
}

.profile-box {
  width: min(560px, 100%);
  align-items: stretch;
  text-align: left;
  max-height: 86vh;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 22px;
  color: var(--fg-muted);
}

.modal-subtitle {
  margin: -6px 0 4px;
  color: var(--fg-muted);
  font-size: 13px;
}

.login-box form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-box input {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.btn-primary {
  padding: 11px 22px;
  border-radius: var(--radius-pill);
  background: var(--fg);
  color: #000;
  font-weight: 600;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: #dcd0ff;
}

.btn-outline {
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-outline:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.error-text {
  color: #fca5a5;
  font-size: 12px;
  min-height: 16px;
}

.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.profile-header h2 {
  margin: 4px 0 0;
  font-size: 20px;
}

.kicker {
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.badge {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  font-size: 12px;
}

.profile-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metric-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 12px;
  color: var(--fg-muted);
}

.funpay-banner {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.profile-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.tab-btn {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  color: var(--fg-muted);
  font-size: 12px;
}

.tab-btn.active {
  background: var(--bg-hover);
  color: var(--fg);
}

.profile-history {
  overflow-y: auto;
  max-height: 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-row {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

/* Полноэкранные экраны */
.full-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 16px;
}

.full-screen h1 {
  margin: 0;
  font-size: 24px;
}

.full-screen p {
  margin: 0;
  max-width: 480px;
  color: var(--fg-muted);
}

.maintenance-eta {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.maintenance-login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.maintenance-login-wrap small {
  color: var(--fg-dim);
  font-size: 12px;
}

/* ===== Панель CEO ===== */
.admin {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 28px max(24px, calc((100% - 1160px) / 2)) 48px;
  background: var(--bg);
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.admin-toolbar h1 {
  margin: 4px 0 0;
  font-size: 24px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.admin-tabs button {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  color: var(--fg-muted);
  font-size: 13px;
}

.admin-tabs button.selected {
  color: var(--fg);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.admin-content {
  padding: 20px 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.stat-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card span {
  font-size: 12px;
  color: var(--fg-muted);
}

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

.admin-section {
  margin-bottom: 26px;
}

.admin-section h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.admin-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.admin-content input,
.admin-content select,
.admin-content textarea {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  font-size: 13px;
}

.admin-content button {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  font-size: 12px;
}

.admin-content button:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.admin-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-content th,
.admin-content td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.admin-content th {
  color: var(--fg-muted);
  font-weight: 500;
  background: var(--bg-elevated);
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--fg);
  color: #000;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-weight: 500;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
}

/* ===== Адаптация под мобильные устройства ===== */
@media (max-width: 768px) {
  .topbar {
    padding: 0 12px;
  }

  .sidebar {
    position: fixed;
    top: 60px;
    bottom: 0;
    left: 0;
    z-index: 35;
    width: 272px;
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: 272px;
    transform: translateX(-100%);
    opacity: 1;
  }

  .sidebar-backdrop:not(.hidden) {
    display: block;
    position: fixed;
    inset: 60px 0 0 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 30;
  }

  .composer-wrap {
    width: calc(100% - 20px);
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .message.user {
    max-width: 92%;
  }

  .profile-metrics {
    grid-template-columns: 1fr;
  }
}

.message.user .message-actions {
  justify-content: flex-end;
  margin-top: 6px;
}

.msg-edit-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  justify-content: center;
  opacity: 0.65;
  transition: opacity 0.15s, border-color 0.15s, color 0.15s;
}

.message.user:hover .msg-edit-btn,
.msg-edit-btn:hover {
  opacity: 1;
}

/* ===== Плавные анимации интерфейса HIGHWITS AI ===== */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes stopPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.welcome-inner {
  animation: fadeSlideUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.message {
  animation: msgIn 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.select-menu {
  animation: menuIn 0.16s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.modal-card,
.gate-box {
  animation: modalIn 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.toast {
  animation: toastIn 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

#newChatTop {
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), background 0.18s, border-color 0.18s;
}

#newChatTop:hover {
  transform: rotate(90deg);
}

.sidebar-new-btn,
.top-action,
.btn-primary,
.btn-outline,
.msg-action-btn,
.tool-button {
  transition: transform 0.16s ease, background 0.18s, border-color 0.18s, box-shadow 0.18s, color 0.18s;
}

.sidebar-new-btn:active,
.top-action:active,
.btn-primary:active,
.btn-outline:active,
.send-btn:active {
  transform: scale(0.96);
}

.chat-item {
  transition: background 0.18s ease, transform 0.18s ease;
}

.chat-item:hover {
  transform: translateX(3px);
}

.send-btn.is-stop {
  animation: stopPulse 1.6s ease-in-out infinite;
}

.input-shell {
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
}

.input-shell:focus-within {
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

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