/* ========================================================================
   Nexus · nexus.zurea.ru
   Studio Soft — мягкие скругления, тёплый кремовый фон, шалфейный акцент.
   Шрифты: Plus Jakarta Sans (UI/body) + Fraunces (display) + JetBrains Mono.
   ======================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #F4EEE2;
  --bg-2:         #ECE4D2;
  --surface:      #FBF6EB;
  --surface-2:    #F2EBDB;
  --surface-3:    #E5DDC8;

  --ink:          #1A1814;
  --ink-2:        #4D453B;
  --ink-3:        #807565;
  --ink-soft:     #A89C88;

  --rule:         #DBCFB5;
  --rule-2:       #E8DFC8;

  --primary:      #5F7E63;
  --primary-deep: #44604A;
  --primary-soft: rgba(95, 126, 99, 0.10);

  --accent:       #C9885A;
  --accent-deep:  #A36D43;
  --accent-soft:  rgba(201, 136, 90, 0.12);

  --user:         #1F1B14;
  --user-text:    #FBF6EB;

  --danger:       #B7553F;
  --danger-soft:  rgba(183, 85, 63, 0.12);

  --shadow-xs:    0 1px 2px rgba(31, 27, 20, 0.04);
  --shadow-sm:    0 1px 3px rgba(31, 27, 20, 0.05), 0 4px 12px -6px rgba(31, 27, 20, 0.08);
  --shadow-md:    0 2px 6px rgba(31, 27, 20, 0.06), 0 12px 32px -10px rgba(31, 27, 20, 0.18);
  --shadow-lg:    0 8px 24px -4px rgba(31, 27, 20, 0.12), 0 20px 60px -12px rgba(31, 27, 20, 0.28);
  --shadow-focus: 0 0 0 3px var(--primary-soft);

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 22px;
  --r-bubble: 16px;
  --r-pill: 999px;

  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-ui:      'Plus Jakarta Sans', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg:           #16130E;
  --bg-2:         #1E1A12;
  --surface:      #221D14;
  --surface-2:    #2A241A;
  --surface-3:    #322B1F;

  --ink:          #EDE2CC;
  --ink-2:        #B8AA90;
  --ink-3:        #877B66;
  --ink-soft:     #5E5446;

  --rule:         #382F23;
  --rule-2:       #463C2D;

  --primary:      #8AA88B;
  --primary-deep: #6F8C70;
  --primary-soft: rgba(138, 168, 139, 0.14);

  --accent:       #D69E70;
  --accent-deep:  #B7855B;
  --accent-soft:  rgba(214, 158, 112, 0.14);

  --user:         #EDE2CC;
  --user-text:    #16130E;

  --danger:       #D67462;
  --danger-soft:  rgba(214, 116, 98, 0.14);

  --shadow-xs:    0 1px 2px rgba(0,0,0,0.4);
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.4), 0 4px 12px -6px rgba(0,0,0,0.5);
  --shadow-md:    0 2px 8px rgba(0,0,0,0.45), 0 14px 36px -10px rgba(0,0,0,0.7);
  --shadow-lg:    0 8px 24px -4px rgba(0,0,0,0.55), 0 20px 60px -12px rgba(0,0,0,0.8);
  --shadow-focus: 0 0 0 3px var(--primary-soft);
}

html, body { height: 100%; }
html { color-scheme: light dark; }

body {
  font-family: var(--font-ui);
  font-size: 15.5px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.4s ease, color 0.3s ease;
  font-feature-settings: 'kern', 'ss01', 'cv11';
}

.display {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.smallcaps {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink-3);
}
.mono { font-family: var(--font-mono); }

.hidden { display: none !important; }

/* ===== Каркас ===== */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
}

/* ===== Сайдбар ===== */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 18px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 4px 0;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--surface);
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; gap: 2px; }
.brand-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.brand-sub {
  font-size: 0.62rem;
  color: var(--ink-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  font-weight: 500;
}

.section-label {
  display: flex;
  align-items: center;
  padding: 14px 18px 6px;
  font-size: 0.62rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--ink-3);
  font-weight: 600;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}
.chat-list::-webkit-scrollbar { width: 6px; }
.chat-list::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  user-select: none;
  transition: background 0.18s, color 0.18s;
}
.chat-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.chat-item.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 2px 0 0 var(--primary);
}
.chat-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item-delete {
  background: none;
  border: none;
  color: var(--ink-3);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
  font-family: var(--font-mono);
}
.chat-item:hover .chat-item-delete { opacity: 1; }
.chat-item-delete:hover {
  color: var(--danger);
  background: var(--danger-soft);
}
.chat-list-empty {
  padding: 14px 18px;
  color: var(--ink-3);
  font-size: 13px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Профиль внизу сайдбара */
.profile-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--rule);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  text-align: left;
  width: 100%;
  font-family: var(--font-ui);
}
.profile-pill:hover {
  background: var(--surface);
  border-color: var(--ink-soft);
}
.profile-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--surface);
  font-weight: 600;
  font-size: 12px;
  font-family: var(--font-mono);
  letter-spacing: 0;
  overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-meta { flex: 1; overflow: hidden; }
.profile-name {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-state {
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
}
.profile-state.synced { color: var(--primary); }
.profile-state.offline { color: var(--ink-3); }

/* ===== Главный столбец ===== */
.main { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: relative;
}

.icon-btn {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--rule); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn svg { width: 18px; height: 18px; }
#sidebarToggle { display: none; }

.topbar-title {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 16px;
  color: var(--ink);
  font-weight: 600;
}
.topbar-title .display {
  font-size: 21px;
  letter-spacing: -0.015em;
}
.topbar-title .pillar {
  width: 1px; height: 18px;
  background: var(--rule);
  align-self: center;
}
.topbar-title .tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.status {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--rule);
  cursor: help;
  user-select: none;
  white-space: nowrap;
  letter-spacing: 0.04em;
  transition: all 0.2s ease;
}
.status:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

/* ===== Сообщения ===== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 30px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }

.message {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  animation: msgIn 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-content {
  padding: 12px 16px;
  border-radius: var(--r-bubble);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: 15.5px;
  line-height: 1.55;
  position: relative;
}

.message.user { align-items: flex-end; }
.message.user .message-content {
  background: var(--user);
  color: var(--user-text);
  border-radius: var(--r-bubble) var(--r-bubble) 4px var(--r-bubble);
  max-width: 76%;
  box-shadow: var(--shadow-xs);
}

.message.bot .message-content {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-bubble) var(--r-bubble) var(--r-bubble) 4px;
  max-width: 88%;
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-xs);
}
.message.bot .message-content:empty { display: none; }

.message.system { align-items: center; }
.message.system .message-content {
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 12.5px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--primary-soft);
  box-shadow: none;
  max-width: none;
}
[data-theme="dark"] .message.system .message-content { color: var(--primary); }

.message-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--rule);
  font-weight: 500;
}

/* «Размышления» — обособленный «черновой» блок: курсив, dashed-рамка,
   приглушённый цвет, меньший кегль. Сворачивается при появлении ответа. */
.message-thinking {
  align-self: flex-start;
  max-width: 80%;
  padding: 9px 14px 11px;
  margin: 0 0 8px 12px;
  background: linear-gradient(180deg, rgba(201, 136, 90, 0.06), rgba(201, 136, 90, 0.02));
  border: 1px dashed rgba(201, 136, 90, 0.55);
  border-left: 3px solid var(--accent);
  border-radius: 4px 12px 12px 4px;
  color: var(--ink-3);
  font-size: 13px;
  font-style: italic;
  font-weight: 400;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  cursor: pointer;
  user-select: text;
  position: relative;
  overflow: hidden;
  max-height: 1200px;
  transition:
    max-height 360ms cubic-bezier(.4, 0, .2, 1),
    padding 240ms ease,
    margin 240ms ease,
    opacity 220ms ease,
    border-color 220ms ease;
}
.message-thinking::before {
  content: '✦ Размышления';
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 6px;
  font-style: normal;
}
.message-thinking .thinking-body {
  display: block;
}
.message-thinking.collapsed {
  max-height: 26px;
  padding-top: 5px;
  padding-bottom: 5px;
  opacity: 0.6;
  border-color: rgba(201, 136, 90, 0.30);
}
.message-thinking.collapsed::before {
  content: '✦ Размышления — нажмите чтобы развернуть';
  margin-bottom: 0;
}
.message-thinking.collapsed .thinking-body {
  visibility: hidden;
}
.message-thinking:hover:not(.collapsed) {
  border-color: rgba(201, 136, 90, 0.85);
}

/* Пока идёт сам этап размышления — основной ответ скрыт, а под текстом
   мыслей мигает каретка-курсор. */
.message.bot.thinking-active .message-content { display: none; }
.message.bot.thinking-active .message-thinking .thinking-body::after {
  content: '';
  display: inline-block;
  width: 5px; height: 0.95em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--accent);
  opacity: 0.6;
  animation: caret 1s steps(2) infinite;
  border-radius: 1px;
}
.message.bot.streaming:not(.thinking-active) .message-content:not(:empty)::after {
  content: '';
  display: inline-block;
  width: 6px; height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--primary);
  opacity: 0.65;
  animation: caret 1s steps(2) infinite;
  border-radius: 1px;
}
@keyframes caret { 50% { opacity: 0; } }

/* ===== Empty state ===== */
.empty-state {
  margin: auto;
  text-align: center;
  padding: 28px 24px;
  max-width: 600px;
  color: var(--ink-2);
  animation: msgIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.empty-state h2 {
  font-family: var(--font-display);
  font-size: 46px;
  font-weight: 600;
  font-variation-settings: 'opsz' 96, 'SOFT' 30;
  color: var(--ink);
  margin-bottom: 10px;
  letter-spacing: -0.025em;
  line-height: 1.06;
}
.empty-state h2 em {
  font-style: italic;
  font-weight: 500;
  color: var(--primary);
}
.empty-state p {
  font-size: 16px;
  font-weight: 450;
  color: var(--ink-2);
  max-width: 440px;
  margin: 0 auto;
  line-height: 1.5;
}
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 28px;
}
.suggestion-chip {
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 8px 14px;
  border-radius: var(--r-pill);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink-2);
  font-family: var(--font-ui);
  font-weight: 500;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.15s;
}
.suggestion-chip:hover {
  background: var(--bg);
  border-color: var(--primary);
  color: var(--primary-deep);
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

/* ===== Typing ===== */
.typing {
  padding: 0 22px 6px;
  color: var(--ink-3);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}
.typing i { font-style: normal; margin-left: 4px; }
.typing span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--primary);
  animation: bounce 1.4s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* ===== Composer ===== */
.composer {
  padding: 10px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 808px;
  width: 100%;
  margin: 0 auto;
  position: relative;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}
.tool-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 10px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  transition: background 0.16s, border-color 0.16s, color 0.16s, transform 0.12s;
  user-select: none;
}
.tool-toggle:hover {
  background: var(--surface-2);
  border-color: var(--ink-soft);
  color: var(--ink);
}
.tool-toggle:active { transform: translateY(1px); }
.tool-toggle.on {
  background: var(--primary);
  color: var(--surface);
  border-color: var(--primary);
}
.tool-toggle.on:hover { background: var(--primary-deep); border-color: var(--primary-deep); }
.tool-ico {
  font-family: var(--font-mono);
  font-weight: 600;
  line-height: 1;
  font-size: 13px;
}

.composer-frame {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.composer-frame:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow-sm);
}

#input {
  flex: 1;
  resize: none;
  max-height: 220px;
  min-height: 30px;
  padding: 8px 0;
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15.5px;
  font-weight: 450;
  line-height: 1.5;
  outline: none;
}
#input::placeholder { color: var(--ink-3); }

.send-btn {
  width: 38px; height: 38px;
  padding: 0;
  border-radius: var(--r-pill);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== Кнопки ===== */
.btn {
  padding: 9px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.18s, border-color 0.18s, color 0.18s, opacity 0.15s, transform 0.12s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: var(--primary);
  color: var(--surface);
  border-color: var(--primary);
}
.btn.primary:hover { background: var(--primary-deep); border-color: var(--primary-deep); }
.btn.primary:disabled { background: var(--primary); border-color: var(--primary); }

.btn.accent {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
}
.btn.accent:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }

.btn.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}
.btn.danger:hover { background: var(--danger); color: var(--surface); }

.btn.full { width: 100%; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.large { padding: 12px 22px; font-size: 15px; }

/* ===== Модалки ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(20, 17, 12, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fadeIn 0.22s ease;
}
[data-theme="dark"] .modal { background: rgba(0, 0, 0, 0.74); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal.hidden { display: none; }

.modal-content {
  background: var(--surface);
  padding: 30px 32px 26px;
  border-radius: var(--r-xl);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--rule);
  animation: modalIn 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal-content.wide { max-width: 560px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.modal-eyebrow .smallcaps { color: var(--primary-deep); }
[data-theme="dark"] .modal-eyebrow .smallcaps { color: var(--primary); }

.modal-content h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  font-variation-settings: 'opsz' 60, 'SOFT' 30;
  color: var(--ink);
  letter-spacing: -0.015em;
  line-height: 1.18;
  margin-bottom: 14px;
}
.modal-content p {
  margin-bottom: 12px;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.55;
}
.modal-content .muted { font-size: 13px; color: var(--ink-3); }

.features {
  list-style: none;
  margin: 18px 0 14px;
  padding: 14px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.features li {
  padding: 5px 0;
  font-size: 14px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
}
.features li .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.checkbox-row {
  display: flex; gap: 10px;
  margin: 14px 0 4px;
  align-items: flex-start;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink-2);
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  transition: border-color 0.2s, background 0.2s;
  line-height: 1.45;
}
.checkbox-row:hover { border-color: var(--primary); }
.checkbox-row input {
  margin-top: 3px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--primary);
  width: 14px; height: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.modal-footnote {
  text-align: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}

/* Auth modal — провайдеры */
.auth-providers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 18px 0 12px;
}
.auth-provider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--ink);
  font: inherit;
  font-family: var(--font-ui);
  font-size: 14.5px;
  font-weight: 600;
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
}
.auth-provider:hover {
  background: var(--surface-2);
  border-color: var(--ink-soft);
}
.auth-provider:active { transform: translateY(1px); }
.auth-provider .provider-icon {
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.auth-provider.google .provider-icon { color: #DB4437; }
.auth-provider.telegram .provider-icon { color: #2AA0DA; }
.auth-provider.email .provider-icon { color: var(--accent); }
.auth-provider.anonymous .provider-icon { color: var(--ink-3); }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  color: var(--ink-3);
  font-size: 12px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.13em;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule);
}

/* Settings */
.settings-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--rule);
  margin: -8px -32px 18px;
  padding: 0 24px;
}
.settings-tab {
  background: none;
  border: none;
  padding: 10px 12px;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.18s, border-color 0.18s;
}
.settings-tab:hover { color: var(--ink-2); }
.settings-tab.active {
  color: var(--ink);
  border-bottom-color: var(--primary);
}
.settings-pane { display: none; }
.settings-pane.active { display: block; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.field-hint {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.4;
}
.field input, .field textarea, .field select {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field input.mono { font-family: var(--font-mono); font-size: 12.5px; }
.field textarea { resize: vertical; min-height: 80px; font-family: var(--font-mono); font-size: 12px; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row .toggle-info { flex: 1; }
.toggle-row .toggle-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.toggle-row .toggle-desc {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 2px;
  line-height: 1.45;
}
.switch {
  width: 40px; height: 22px;
  background: var(--rule);
  border-radius: var(--r-pill);
  border: none;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(18px); }

/* Tier hint */
.tier-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 22px 0;
  padding: 10px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--ink-2);
}
.tier-hint-text { flex: 1; line-height: 1.4; }
.tier-hint-btn {
  background: var(--accent);
  color: var(--surface);
  border: 1px solid var(--accent);
  padding: 6px 12px;
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s;
}
.tier-hint-btn:hover { background: var(--accent-deep); }
.tier-hint-close {
  background: none;
  border: none;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
}
.tier-hint-close:hover { color: var(--ink); background: var(--surface); }

/* ===== Адаптив ===== */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  #sidebarToggle { display: inline-flex; }
  .topbar { padding: 12px 14px; gap: 8px; }
  .topbar-title .display { font-size: 19px; }
  .topbar-title .pillar, .topbar-title .tag { display: none; }
  .messages { padding: 22px 14px 16px; gap: 14px; }
  .empty-state h2 { font-size: 38px; }
  .composer { padding: 8px 14px 14px; }
  .modal-content { padding: 24px 22px 22px; }
  .modal-content h2 { font-size: 24px; }
  .settings-tabs { margin: -8px -22px 18px; padding: 0 16px; overflow-x: auto; }
}

@media (max-width: 480px) {
  .empty-state h2 { font-size: 32px; }
  .messages { padding: 18px 12px 14px; }
  .message.user .message-content { max-width: 86%; }
  .status { font-size: 11px; padding: 5px 10px; }
}

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