/* ============================================================
   PARUS AI — стили Mini App (референс: мобильный ChatGPT, iOS)
   ============================================================ */

/* ---------- Токены ---------- */
:root {
  --bg: #f4f4f6;
  --bg-elev: #ffffff;
  --bg-sheet: #ffffff;
  --bg-settings: #f2f2f7;
  --text: #0d0d0d;
  --text-2: #8e8e93;
  --text-3: #c6c6cb;
  --line: rgba(0, 0, 0, 0.08);
  --bubble: #e9e9eb;
  --chip: #f1f1f3;
  --brand: #5856d6;
  --danger: #ff3b30;
  --code-bg: #f7f7f8;
  --code-head: #ececf1;
  --send-bg: #0d0d0d;
  --send-fg: #ffffff;
  --scrim: rgba(0, 0, 0, 0.4);
  --attach-scrim: rgba(248, 248, 250, 0.45);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 14px rgba(0, 0, 0, 0.06);
  --shadow-2: 0 10px 44px rgba(0, 0, 0, 0.18);
  --sbw: min(84vw, 340px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.12);
}

[data-accent="purple"]  { --accent: #af52de; --accent-soft: rgba(175, 82, 222, 0.13); }
[data-accent="green"]   { --accent: #34c759; --accent-soft: rgba(52, 199, 89, 0.14); }
[data-accent="orange"]  { --accent: #ff9500; --accent-soft: rgba(255, 149, 0, 0.14); }
[data-accent="pink"]    { --accent: #ff2d55; --accent-soft: rgba(255, 45, 85, 0.12); }
[data-accent="graphite"]{ --accent: #6b6b70; --accent-soft: rgba(107, 107, 112, 0.14); }

[data-theme="dark"] {
  --bg: #212121;
  --bg-elev: #2f2f2f;
  --bg-sheet: #2b2b2b;
  --bg-settings: #181818;
  --text: #ececec;
  --text-2: #9b9b9b;
  --text-3: #5a5a5e;
  --line: rgba(255, 255, 255, 0.09);
  --bubble: #323232;
  --chip: #3a3a3a;
  --code-bg: #171717;
  --code-head: #2c2c2c;
  --send-bg: #ececec;
  --send-fg: #0d0d0d;
  --scrim: rgba(0, 0, 0, 0.55);
  --attach-scrim: rgba(16, 16, 16, 0.45);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 10px 44px rgba(0, 0, 0, 0.55);
}

/* ---------- База ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; padding: 0; overscroll-behavior: none; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; padding: 0; color: inherit; }
button:active { opacity: 0.7; }
textarea, input { font-family: inherit; }
.flex-1 { flex: 1; }
[hidden] { display: none !important; }
svg { display: block; }

/* ---------- Круглые кнопки ---------- */
.circle-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-elev); box-shadow: var(--shadow-1);
  display: grid; place-items: center; color: var(--text); flex-shrink: 0;
}

/* ============================================================
   ОСНОВНОЙ ЭКРАН
   ============================================================ */
#screen-main {
  position: fixed; inset: 0;
  height: var(--tg-viewport-height, 100dvh);
  display: flex; flex-direction: column;
  background: var(--bg);
  z-index: 10;
  transition: transform 0.36s cubic-bezier(0.25, 0.9, 0.3, 1), border-radius 0.36s;
  will-change: transform;
}
body.sb-open #screen-main {
  transform: translateX(var(--sbw));
  border-radius: 26px;
  overflow: hidden;
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.14);
}
#main-scrim { position: absolute; inset: 0; z-index: 60; background: transparent; }

/* ---------- Верхняя панель ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 10px) 14px 8px;
  flex-shrink: 0;
}
#model-pill {
  height: 44px; border-radius: 22px;
  background: var(--bg-elev); box-shadow: var(--shadow-1);
  display: flex; align-items: center; gap: 7px; padding: 0 17px;
  font-size: 17px; font-weight: 600; color: var(--brand);
  max-width: 60vw;
}
#model-pill .sparkle { display: grid; place-items: center; }
#model-pill-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Лента чата ---------- */
#chat-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 2px 16px 10px;
  scrollbar-width: none;
}
#chat-scroll::-webkit-scrollbar { display: none; }

#empty-state {
  min-height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding-bottom: 4px;
}
#empty-state.center { justify-content: center; }

#temp-banner { text-align: center; max-width: 340px; margin: 0 auto; padding-bottom: 40px; }
#temp-banner h3 { font-size: 20px; font-weight: 650; margin: 0 0 10px; }
#temp-banner p { font-size: 15.5px; line-height: 1.5; color: var(--text-2); margin: 0; }

.suggestion {
  display: flex; align-items: center; gap: 16px;
  padding: 13px 2px; font-size: 17px; color: var(--text);
  text-align: left; width: 100%;
}
.suggestion .ic { width: 26px; height: 26px; color: var(--text); opacity: 0.9; flex-shrink: 0; }

/* ---------- Сообщения ---------- */
#messages { padding-top: 6px; }
.msg { margin: 5px 0; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.msg.user .bubble {
  background: var(--bubble); color: var(--text);
  border-radius: 22px; padding: 10px 16px;
  max-width: 84%; font-size: 17px; line-height: 1.42;
  white-space: pre-wrap; word-break: break-word;
  user-select: text; -webkit-user-select: text;
}
.msg.user .u-imgs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msg.user .u-imgs img { max-width: 170px; max-height: 170px; border-radius: 16px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--chip); border-radius: 14px; padding: 9px 13px;
  font-size: 14px; color: var(--text); max-width: 230px;
}
.file-chip .ic { width: 18px; color: var(--text-2); flex-shrink: 0; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msg.assistant { padding: 6px 0 2px; }
.typing-dot {
  width: 11px; height: 11px; border-radius: 50%; background: var(--text);
  margin: 8px 2px; animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.82); } }

.gen-img { border-radius: 18px; max-width: min(100%, 340px); display: block; margin: 8px 0; }

/* ---------- Markdown ---------- */
.md { font-size: 17px; line-height: 1.55; word-wrap: break-word; user-select: text; -webkit-user-select: text; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1 { font-size: 21px; margin: 18px 0 10px; }
.md h2 { font-size: 19px; margin: 16px 0 8px; }
.md h3, .md h4 { font-size: 17.5px; margin: 14px 0 6px; }
.md ul, .md ol { margin: 10px 0 12px; padding-left: 24px; }
.md li { margin: 5px 0; }
.md li::marker { color: var(--text-2); }
.md blockquote { border-left: 3px solid var(--text-3); margin: 12px 0; padding: 2px 0 2px 14px; color: var(--text-2); }
.md a { color: var(--accent); text-decoration: none; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.md img { max-width: 100%; border-radius: 14px; }
.md code { background: var(--chip); border-radius: 6px; padding: 2px 6px; font-size: 14.5px;
  font-family: "SF Mono", ui-monospace, Consolas, Menlo, monospace; }
.md pre code { background: none; padding: 0; font-size: 13.5px; }
.md table { border-collapse: collapse; margin: 12px 0; display: block; overflow-x: auto; font-size: 15px; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; }
.md th { background: var(--chip); font-weight: 600; }

.codeblock { margin: 12px 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--code-bg); }
.codeblock-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 6px 5px 14px; background: var(--code-head);
  font-size: 12.5px; color: var(--text-2);
}
.codeblock-copy { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); padding: 5px 9px; border-radius: 8px; }
.codeblock pre { margin: 0; padding: 12px 14px; overflow-x: auto; line-height: 1.5; }

/* источники веб-поиска */
.sources-row { display: flex; gap: 8px; overflow-x: auto; margin: 10px 0 2px; scrollbar-width: none; }
.sources-row::-webkit-scrollbar { display: none; }
.source-chip {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  background: var(--chip); border-radius: 16px; padding: 7px 13px;
  font-size: 13px; color: var(--text-2); white-space: nowrap;
}
.source-chip .ic { width: 14px; }

/* действия под ответом */
.msg-actions { display: flex; gap: 2px; margin-top: 6px; }
.msg-actions button { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--text-2); }

/* карточка ошибки */
.error-card {
  background: rgba(255, 59, 48, 0.07); border: 1px solid rgba(255, 59, 48, 0.22);
  border-radius: 16px; padding: 13px 15px; margin: 8px 0; font-size: 15px;
}
.error-card .retry { margin-top: 8px; color: var(--accent); font-weight: 600; font-size: 15px; display: flex; gap: 6px; align-items: center; }

/* кнопка вниз */
#scroll-down {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 108px; width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg-elev); box-shadow: var(--shadow-1);
  display: grid; place-items: center; color: var(--text); z-index: 20;
}

/* ============================================================
   КОМПОЗЕР
   ============================================================ */
#composer {
  flex-shrink: 0; padding: 6px 12px calc(var(--safe-bottom) + 12px);
  background: linear-gradient(to top, var(--bg) 78%, transparent);
  position: relative; z-index: 45; /* выше блюра меню вложений — как в оригинале */
}
#chips-row { display: flex; gap: 8px; padding: 2px 6px 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent-soft); color: var(--accent);
  padding: 8px 13px; border-radius: 18px; font-size: 14.5px; font-weight: 550;
}
.chip .ic { width: 17px; }
.chip .rm { display: grid; place-items: center; width: 18px; height: 18px; }

#previews-row { display: flex; gap: 10px; padding: 2px 6px 10px; flex-wrap: wrap; }
.preview-thumb { position: relative; width: 64px; height: 64px; }
.preview-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 14px; }
.preview-rm {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px;
  border-radius: 50%; background: rgba(20, 20, 22, 0.85); color: #fff;
  display: grid; place-items: center; border: 2px solid var(--bg);
}
.preview-file { position: relative; }
.preview-file .preview-rm { top: -9px; right: -9px; }

.input-pill {
  display: flex; align-items: flex-end;
  background: var(--bg-elev); border-radius: 30px; box-shadow: var(--shadow-1);
  padding: 7px 7px 7px 5px; min-height: 60px;
}
#btn-attach { width: 46px; height: 46px; display: grid; place-items: center; color: var(--text); flex-shrink: 0; }
#input {
  flex: 1; border: none; outline: none; background: transparent; resize: none;
  font-size: 17px; line-height: 22px; padding: 12px 2px; margin: 0;
  color: var(--text); max-height: 134px; min-width: 0;
}
#input::placeholder { color: #9a9aa1; }
[data-theme="dark"] #input::placeholder { color: #8a8a8e; }
#btn-mic { width: 42px; height: 46px; display: grid; place-items: center; color: var(--text); opacity: 0.9; flex-shrink: 0; }
#btn-send {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; margin-left: 2px;
  display: grid; place-items: center; transition: background 0.18s, color 0.18s;
}
#btn-send.mode-voice { background: var(--accent); color: #fff; }
#btn-send.mode-send, #btn-send.mode-stop { background: var(--send-bg); color: var(--send-fg); }
#btn-send.mode-disabled { background: var(--chip); color: var(--text-3); }

/* ============================================================
   ПОПАП ВЛОЖЕНИЙ
   ============================================================ */
#attach-scrim {
  position: absolute; inset: 0; z-index: 40;
  background: var(--attach-scrim);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  opacity: 0; transition: opacity 0.22s;
}
#attach-scrim.show { opacity: 1; }
#attach-pop {
  position: absolute; z-index: 50; left: 16px;
  bottom: calc(var(--safe-bottom) + 92px);
  width: 296px; background: var(--bg-elev); border-radius: 30px;
  padding: 14px 10px; box-shadow: var(--shadow-2);
  transform-origin: 15% 100%;
  transform: scale(0.5); opacity: 0;
  transition: transform 0.26s cubic-bezier(0.2, 1.1, 0.3, 1), opacity 0.18s;
}
#attach-pop.show { transform: scale(1); opacity: 1; }
#attach-pop button {
  display: flex; align-items: center; gap: 18px; width: 100%;
  padding: 9px 12px; font-size: 19px; color: var(--text);
}
#attach-pop .ic {
  width: 46px; height: 46px; border-radius: 50%; background: var(--chip);
  display: grid; place-items: center; flex-shrink: 0;
}

/* ============================================================
   БОКОВОЕ МЕНЮ
   ============================================================ */
#sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--sbw);
  height: var(--tg-viewport-height, 100dvh);
  display: flex; flex-direction: column;
  padding-top: calc(var(--safe-top) + 8px);
  z-index: 5; visibility: hidden;
}
body.sb-open #sidebar, body.sb-anim #sidebar { visibility: visible; }

.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 20px 4px; }
.sb-head h1 { font-size: 31px; font-weight: 700; letter-spacing: -0.4px; margin: 0; }
.sb-search-btn { width: 42px; height: 42px; }

.sb-search { display: flex; align-items: center; gap: 10px; padding: 8px 16px 6px; }
.sb-search-field {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--chip); border-radius: 12px; padding: 9px 12px;
}
.sb-search-field .ic { width: 18px; color: var(--text-2); }
#search-input { flex: 1; border: none; outline: none; background: none; font-size: 16.5px; color: var(--text); min-width: 0; }
#search-cancel { color: var(--accent); font-size: 16.5px; flex-shrink: 0; }

.sb-scroll { flex: 1; overflow-y: auto; padding-bottom: 120px; scrollbar-width: none; }
.sb-scroll::-webkit-scrollbar { display: none; }

.sb-nav button {
  display: flex; align-items: center; gap: 18px; width: 100%;
  padding: 12px 20px; font-size: 19px; color: var(--text); text-align: left;
}
.sb-nav .ic { width: 26px; height: 26px; flex-shrink: 0; }

.sb-recent-title { font-size: 20px; font-weight: 700; margin: 0; padding: 20px 20px 6px; }
.chat-row {
  display: flex; align-items: center; width: 100%;
  padding: 12.5px 20px; font-size: 17px; color: var(--text); text-align: left;
}
.chat-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row.active { background: var(--chip); }
.sb-empty { padding: 14px 20px; color: var(--text-2); font-size: 15.5px; }

.sb-footer {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px calc(var(--safe-bottom) + 18px);
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  pointer-events: none;
}
.sb-footer > * { pointer-events: auto; }
#btn-new-chat {
  display: flex; align-items: center; gap: 10px;
  height: 54px; padding: 0 25px; border-radius: 27px;
  background: var(--accent); color: #fff; font-size: 18px; font-weight: 600;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 40%, transparent);
}
#btn-new-chat .ic { width: 22px; height: 22px; }
#btn-settings { width: 48px; height: 48px; }

/* ============================================================
   ШТОРКИ / МОДАЛКИ / ТОСТЫ
   ============================================================ */
.layer-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 70; opacity: 0; transition: opacity 0.25s; }
.layer-scrim.show { opacity: 1; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 71;
  background: var(--bg-sheet); border-radius: 24px 24px 0 0;
  transform: translateY(105%); transition: transform 0.33s cubic-bezier(0.25, 0.9, 0.3, 1);
  max-height: 88dvh; display: flex; flex-direction: column;
  padding-bottom: calc(var(--safe-bottom) + 10px);
}
.sheet.show { transform: none; }
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--text-3); margin: 9px auto 4px; flex-shrink: 0; }
.sheet-title { font-size: 17px; font-weight: 650; text-align: center; padding: 8px 16px 6px; }
.sheet-body { overflow-y: auto; padding: 6px 16px 14px; }

/* строки экшен-меню */
.as-row {
  display: flex; align-items: center; gap: 15px; width: 100%;
  padding: 14px 8px; font-size: 17.5px; color: var(--text); text-align: left;
  border-radius: 12px;
}
.as-row .ic { width: 24px; height: 24px; flex-shrink: 0; }
.as-row.danger { color: var(--danger); }

/* модель */
.model-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 6px; text-align: left; }
.model-row + .model-row { border-top: 1px solid var(--line); }
.model-info { flex: 1; min-width: 0; }
.model-name { font-size: 17px; font-weight: 590; }
.model-tag { font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
.model-check { width: 24px; color: var(--accent); visibility: hidden; }
.model-row.sel .model-check { visibility: visible; }
.sheet-note { text-align: center; font-size: 13px; color: var(--text-2); padding: 10px 16px 4px; }

/* кнопки в шторках */
.sheet-btn {
  display: block; width: 100%; padding: 15px; border-radius: 16px;
  background: var(--send-bg); color: var(--send-fg);
  font-size: 17px; font-weight: 600; text-align: center; margin-top: 10px;
}
.sheet-btn.danger { background: var(--danger); color: #fff; }
.sheet-btn.plain { background: var(--chip); color: var(--text); }

.sheet-input {
  width: 100%; border: none; outline: none; background: var(--chip);
  border-radius: 14px; padding: 14px 16px; font-size: 17px; color: var(--text);
}
textarea.sheet-input { min-height: 110px; resize: none; line-height: 1.45; }
.sheet-label { font-size: 13.5px; color: var(--text-2); margin: 14px 4px 7px; }

/* переключатель */
.switch { width: 51px; height: 31px; border-radius: 16px; background: var(--text-3); position: relative; transition: background 0.2s; flex-shrink: 0; }
.switch .knob {
  position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.25); transition: left 0.2s;
}
.switch.on { background: var(--accent); }
.switch.on .knob { left: 22px; }

/* полноэкранные модалки */
.modal {
  position: fixed; inset: 0; z-index: 80; background: var(--bg-settings);
  transform: translateY(100%); transition: transform 0.34s cubic-bezier(0.25, 0.9, 0.3, 1);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.modal.show { transform: none; }
.modal-head {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center;
  padding: calc(var(--safe-top) + 12px) 16px 8px; pointer-events: none;
}
.modal-head > * { pointer-events: auto; }
.modal-title { font-size: 20px; font-weight: 700; margin: 0 auto 0 6px; }
.modal-close { margin-left: auto; }
.modal-body { padding: 0 0 calc(var(--safe-bottom) + 30px); }

/* ---------- Настройки ---------- */
.set-avatar { width: 96px; height: 96px; margin: 4px auto 12px; position: relative; }
.set-avatar img, .set-avatar .initials { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.set-avatar .initials { background: #7d8b8f; color: #fff; font-size: 36px; font-weight: 600; display: grid; place-items: center; }
.set-avatar .pencil {
  position: absolute; right: -4px; bottom: -2px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg-elev); box-shadow: var(--shadow-1); display: grid; place-items: center; color: var(--text);
}
.set-name { text-align: center; font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.set-label { font-size: 19px; font-weight: 700; margin: 26px 20px 10px; }
.card { background: var(--bg-elev); border-radius: 18px; margin: 0 16px; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 58px; padding: 8px 16px; font-size: 17px; color: var(--text);
  text-align: left; position: relative;
}
.row:not(:last-child)::after {
  content: ""; position: absolute; left: 54px; right: 0; bottom: 0; height: 1px; background: var(--line);
}
.row > .ic { width: 26px; height: 26px; color: var(--text); flex-shrink: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .val { margin-left: auto; color: var(--text-2); font-size: 16.5px; display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.row .chev { color: var(--text-3); flex-shrink: 0; }
.row .sub { font-size: 15px; color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.brand { color: var(--brand); font-weight: 600; }
.row.brand > .ic { color: var(--brand); }
.accent-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); }

/* сетка цветов */
.accent-grid { display: flex; gap: 16px; justify-content: center; padding: 18px 0 10px; flex-wrap: wrap; }
.accent-cell { width: 46px; height: 46px; border-radius: 50%; position: relative; display: grid; place-items: center; }
.accent-cell.sel::after { content: ""; position: absolute; inset: -6px; border: 2.5px solid var(--text); border-radius: 50%; }
.accent-cell svg { color: #fff; }

/* память */
.mem-row { display: flex; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); font-size: 16px; }
.mem-row span { flex: 1; user-select: text; -webkit-user-select: text; }
.mem-row button { color: var(--text-2); width: 32px; height: 32px; display: grid; place-items: center; }
.mem-add { display: flex; gap: 10px; margin-top: 12px; }
.mem-add input { flex: 1; }
.mem-add button {
  width: 50px; height: 50px; border-radius: 14px; background: var(--send-bg);
  color: var(--send-fg); display: grid; place-items: center; flex-shrink: 0;
}

/* ---------- Библиотека ---------- */
.lib-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 10px 16px; }
.lib-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; }
.empty-note { text-align: center; color: var(--text-2); font-size: 15.5px; padding: 60px 30px; line-height: 1.5; }
.empty-note .ic { width: 44px; height: 44px; margin: 0 auto 14px; opacity: 0.5; }

/* ---------- Проекты ---------- */
.proj-list { padding: 6px 16px; }
.proj-row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: var(--bg-elev); border-radius: 16px; padding: 15px 16px;
  margin-bottom: 10px; font-size: 17px; color: var(--text); text-align: left;
}
.proj-row .ic { width: 24px; color: var(--text); }
.proj-row .cnt { margin-left: auto; color: var(--text-2); font-size: 15px; }
.proj-new {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  width: 100%; padding: 15px; border-radius: 16px; border: 1.5px dashed var(--text-3);
  color: var(--text-2); font-size: 16.5px; margin-top: 4px;
}

/* ---------- Просмотр изображения ---------- */
.viewer { position: fixed; inset: 0; z-index: 95; background: rgba(0, 0, 0, 0.93); display: grid; place-items: center; }
.viewer img { max-width: 94vw; max-height: 82vh; border-radius: 8px; }
.viewer .modal-close { position: absolute; top: calc(var(--safe-top) + 12px); right: 16px; }

/* ---------- Тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 100px); z-index: 120;
  transform: translate(-50%, 16px); opacity: 0;
  background: rgba(28, 28, 30, 0.94); color: #fff;
  padding: 11px 19px; border-radius: 22px; font-size: 15px;
  max-width: 86vw; text-align: center;
  transition: transform 0.25s, opacity 0.25s;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
[data-theme="dark"] .toast { background: rgba(240, 240, 240, 0.96); color: #111; }

/* планшет/десктоп: ограничение ширины контента чата */
@media (min-width: 700px) {
  #chat-scroll, #composer { padding-left: max(16px, calc((100vw - 720px) / 2)); padding-right: max(16px, calc((100vw - 720px) / 2)); }
}
