/* Boostra GPT chat — Figma Obuchat-Designs 4838 (live specs) */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f9f9f9;
  --sidebar-bg: #f2f2f7;
  --surface: #ffffff;
  --text: #1b2559;
  --muted: #909090;
  --border: rgba(23, 23, 82, 0.12);
  --sidebar-active: #e5e5ed;
  --digest-sidebar-highlight: rgba(214, 186, 228, 0.4);
  --link: #0029ff;
  --send-idle: #afaeb6;
  --send-active: #1b2559;
  --user-bubble: #f2f2f7;
  --telegram-bg: #e8f2ff;
  --telegram-border: rgba(123, 154, 194, 0.12);
  --sidebar-w: 310px;
  --chat-max: 722px;
  --radius-chip: 20px;
  --radius-composer: 32px;
  --shadow-composer: 0 4px 14px rgba(0, 0, 0, 0.06);
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: Inter, "Plus Jakarta Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  height: 100dvh;
  max-width: none;
  margin: 0;
  padding: 0;
  gap: 0;
  background: var(--bg);
}

/* ── Sidebar ── */
.sidebar {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
  width: var(--sidebar-w);
  padding: 32px 24px 10px;
  background: var(--sidebar-bg);
  border: none;
  border-radius: 0 32px 32px 0;
  box-shadow: none;
  position: relative;
  z-index: 10;
  overflow: visible;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: Raleway, "Plus Jakarta Sans", sans-serif;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.05;
  padding: 12px 8px 24px;
  margin: 0;
  color: var(--text);
}

.brand__star {
  width: 29px;
  height: 29px;
  flex-shrink: 0;
  display: block;
}

.brand__logo {
  height: 20px;
  width: 85px;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
}

.brand span {
  color: var(--text);
  background: none;
  -webkit-text-fill-color: currentColor;
}

.new-chat {
  display: flex;
  align-items: center;
  width: 100%;
  cursor: pointer;
  padding: 8px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-family: "Plus Jakarta Sans", Inter, sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 30px;
  gap: 10px;
  color: var(--text);
}

.new-chat:hover {
  background: rgba(27, 37, 89, 0.04);
}

.new-chat svg,
.new-chat__icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--text);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.sidebar-nav-digest {
  position: relative;
}

.sidebar-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: "Plus Jakarta Sans", Inter, sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 30px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.sidebar-nav-item:hover {
  background: rgba(27, 37, 89, 0.04);
}

.sidebar-nav-item.is-active {
  background: var(--sidebar-active);
}

.sidebar-nav-item--digest.is-highlighted {
  background: var(--digest-sidebar-highlight);
}

.sidebar-nav-item.has-unread {
  padding-right: 28px;
}

.sidebar-nav-item.has-unread::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4d4f;
}

.sidebar-nav-item__icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: block;
}

.sidebar-divider {
  height: 1px;
  margin: 12px 0 0;
  background: var(--border);
}

.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-top: 10px;
  gap: 4px;
}

.chat-list-empty,
.chat-list-loading {
  margin: 8px;
  font-size: 13px;
  color: var(--muted);
}

.chat-item {
  position: relative;
  display: block;
  width: 100%;
  flex-shrink: 0;
  cursor: pointer;
  border: none;
  font: inherit;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 8px;
  border-radius: 8px;
  font-family: "Plus Jakarta Sans", Inter, sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 30px;
  color: var(--text);
  background: transparent;
}

.chat-item:hover:not(.is-active) {
  background: rgba(27, 37, 89, 0.04);
}

.chat-item.is-active {
  background: var(--sidebar-active);
  color: var(--text);
  font-weight: 500;
}

.chat-item.is-active:hover {
  background: var(--sidebar-active);
}

.chat-item--digest.is-highlighted,
.chat-item--digest.has-unread {
  background: var(--digest-sidebar-highlight);
}

.chat-item.has-unread {
  padding-right: 28px;
}

.chat-item.has-unread::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4d4f;
}

.settings-btn {
  display: flex;
  align-items: center;
  width: 100%;
  cursor: pointer;
  border: none;
  font: inherit;
  text-align: left;
  margin-top: auto;
  padding: 8px;
  border-radius: 10px;
  font-family: "Plus Jakarta Sans", Inter, sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 30px;
  color: var(--text);
  gap: 10px;
  background: transparent;
}

.settings-btn:hover {
  background: rgba(27, 37, 89, 0.04);
}

.settings-btn svg {
  width: 24px;
  height: 24px;
}

.sidebar-foot {
  padding: 0 8px;
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

/* ── Main ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 8px 16px;
  border: none;
  background: transparent;
}

.menu-toggle {
  display: none;
  flex-shrink: 0;
  position: relative;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: var(--surface);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.menu-toggle img {
  display: block;
  width: 26px;
  height: 26px;
}

.menu-toggle.has-unread::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4d4f;
  border: 2px solid var(--surface);
  box-sizing: content-box;
}

.header-new-chat {
  display: none;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  margin-left: auto;
  padding: 8px;
  border: none;
  border-radius: 0;
  background: var(--surface);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.header-new-chat img {
  display: block;
  width: 32px;
  height: 32px;
}

.menu-toggle span,
.menu-toggle span::before,
.menu-toggle span::after {
  display: none;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.sidebar-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.btn-chat-close {
  margin-left: auto;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}

.btn-chat-close:hover {
  background: rgba(27, 37, 89, 0.06);
}

body.is-pwa-installed .btn-chat-close {
  display: none;
}

/* ── Digest alert (popover у вкладки «Дайджест дня») ── */
.digest-alert {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  position: absolute;
  left: calc(100% + 16px);
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  width: 222px;
  padding: 12px 32px 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  box-shadow: var(--shadow-composer);
  box-sizing: border-box;
  z-index: 20;
}

.digest-alert.is-visible {
  display: flex;
}

.digest-alert__btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}

.digest-alert__icon {
  width: 29px;
  height: 29px;
  line-height: 1;
}

.digest-alert__text {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text);
}

.digest-alert__text strong {
  font-weight: 400;
}

.digest-alert__action {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--link);
}

.digest-alert__close {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.digest-alert__close:hover {
  color: var(--text);
  background: rgba(27, 37, 89, 0.04);
}

/* ── Start screen ── */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  max-width: var(--chat-max);
  width: 100%;
  margin: 0 auto;
  padding: 8px 16px 24px;
  gap: 22px;
}

.main.is-start-screen {
  justify-content: center;
  align-items: stretch;
  overflow: visible;
}

.main.is-start-screen .messages {
  flex: 0 1 auto;
  justify-content: center;
  align-items: center;
  max-width: none;
  width: 100%;
  padding: 0;
  overflow: visible;
  min-height: 0;
}

.main.is-start-screen .composer {
  flex: 0 0 auto;
  background: transparent;
  padding-top: 12px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.start-screen {
  display: none;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  max-width: var(--chat-max);
  margin: 0 auto;
  padding: 0;
  overflow: visible;
  gap: 12px;
}

.main.is-start-screen .start-screen {
  display: flex;
}

.main.is-start-screen .messages > .msg,
.main.is-start-screen .messages > .boot-loading,
.main.is-start-screen .messages > .boot-error {
  display: none;
}

.start-screen__title,
.start-screen__subtitle {
  display: none;
}

.start-screen__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 32px;
  padding: 12px 8px 0;
}

.start-screen__brand-star {
  width: 29px;
  height: 29px;
  flex-shrink: 0;
  display: block;
}

.start-screen__brand-logo {
  height: 20px;
  width: auto;
  display: block;
}

.start-screen__brand-gpt {
  font-family: Raleway, "Plus Jakarta Sans", sans-serif;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.05;
  color: var(--text);
}

.start-screen__suggestions-outer {
  --start-col-left: max(16px, (100vw - var(--sidebar-w) - var(--chat-max)) / 2);
  width: 100vw;
  margin-left: calc(50% - 50vw - var(--sidebar-w) / 2);
  position: relative;
  z-index: 1;
  overflow: visible;
  box-sizing: border-box;
}

.start-screen__suggestions {
  --start-col-left: max(16px, (100vw - var(--sidebar-w) - var(--chat-max)) / 2);
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 16px 4px 0;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  box-sizing: border-box;
  cursor: grab;
  touch-action: pan-x;
}

.start-screen__suggestions.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.start-screen__suggestions.is-dragging .suggestion-chip {
  pointer-events: none;
}

.start-screen__suggestions-lead {
  flex: 0 0 calc(var(--sidebar-w) + var(--start-col-left));
  width: calc(var(--sidebar-w) + var(--start-col-left));
  height: 1px;
  pointer-events: none;
}

.start-screen__suggestions::-webkit-scrollbar {
  display: none;
}

.start-screen__suggestions .suggestion-chip {
  flex: 0 0 auto;
  align-self: flex-start;
  max-width: 400px;
  min-width: min(347px, 80vw);
  min-height: 48px;
  height: auto;
  padding: 12px 16px;
  border-radius: var(--radius-chip);
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: Inter, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text);
  box-shadow: none;
  white-space: normal;
  text-align: left;
  box-sizing: border-box;
}

/* ── Bubbles ── */
.msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 100%;
}

.msg--user {
  justify-content: flex-end;
}

.msg--typing .dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.msg--typing .dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: chat-blink 1.2s infinite ease-in-out;
}

.msg--typing .dots span:nth-child(2) { animation-delay: 0.15s; }
.msg--typing .dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-blink {
  0%, 80%, 100% { opacity: 0.35; }
  40% { opacity: 1; }
}

.bubble--user-reply {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: min(280px, 100%);
}

.user-reply-quote {
  margin: 0;
  padding: 8px 10px;
  border-left: 3px solid rgba(27, 37, 89, 0.2);
  border-radius: 6px;
  background: rgba(242, 242, 247, 0.8);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.user-reply-text {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
}

.avatar {
  display: none;
}

.bubble {
  width: fit-content;
  padding: 16px;
  border-radius: 12px;
  font-family: Inter, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.4;
  max-width: min(560px, 85%);
}

.msg--user .bubble {
  margin-left: auto;
  background: var(--user-bubble);
  border: none;
  border-radius: 12px 12px 0 12px;
}

.bubble--bot {
  background: transparent;
  border: none;
  box-shadow: none;
  padding-left: 0;
  padding-right: 0;
  max-width: var(--chat-max);
}

.bubble--bot.md p { margin: 0 0 0.65em; }
.bubble--bot.md p:last-child { margin-bottom: 0; }
.bubble--bot.md h1, .bubble--bot.md h2, .bubble--bot.md h3 {
  margin: 0.75em 0 0.4em;
  font-size: 1em;
  font-weight: 600;
}
.bubble--bot.md ul, .bubble--bot.md ol {
  margin: 0.4em 0;
  padding-left: 1.25em;
}
.bubble--bot.md li { margin: 0.2em 0; }
.bubble--bot.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: #f3f4f6;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.bubble--bot.md pre {
  margin: 0.5em 0;
  padding: 10px 12px;
  background: #1f2937;
  color: #f9fafb;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
}
.bubble--bot.md pre code { background: none; padding: 0; color: inherit; }
.bubble--bot.md blockquote {
  margin: 0.5em 0;
  padding-left: 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.bubble--bot.md a { color: var(--link); text-decoration: none; }
.bubble--bot.md a:hover { text-decoration: underline; }
.bubble--bot.md strong { font-weight: 600; }
.bubble--bot.md em { font-style: italic; }

.msg-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
}

.msg-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 0;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.msg-action:hover {
  background: rgba(23, 23, 82, 0.06);
  color: var(--text);
}

.msg-action.is-active {
  color: var(--text);
  background: rgba(23, 23, 82, 0.08);
}

.msg-action.is-active[data-action="like"] {
  color: #059669;
}

.msg-action.is-active[data-action="dislike"] {
  color: #dc2626;
}

.msg-action svg,
.msg-action .msg-action__icon {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
  margin: 0;
  pointer-events: none;
}

.msg-action .msg-action__icon--filled {
  display: none;
}

.msg-action.is-active .msg-action__icon--outline {
  display: none;
}

.msg-action.is-active .msg-action__icon--filled {
  display: block;
}

.msg-action.is-copied {
  color: #059669;
}

.boot-loading {
  color: var(--muted);
  font-size: 14px;
  padding: 16px;
}

.boot-error {
  color: #b91c1c;
  font-size: 14px;
}

.kb-suggests { margin-top: 12px; }
.kb-suggests-caption {
  font-size: 12.5px;
  color: var(--text);
  opacity: 0.6;
  margin-bottom: 7px;
}
.kb-suggests-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.kb-suggests-chips .suggestion-chip {
  font-size: 12.5px;
  padding: 6px 11px;
}

/* ── Telegram banner ── */
.telegram-banner-wrap {
  flex-shrink: 0;
  display: none;
  justify-content: center;
  width: 100%;
  max-width: var(--chat-max);
  margin: 0 auto;
  padding: 0 16px 12px;
  box-sizing: border-box;
}

.telegram-banner-wrap:has(.telegram-banner.is-visible) {
  display: flex;
}

.telegram-banner {
  display: none;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
  max-width: 70vw;
  padding: 12px 16px;
  background: var(--telegram-bg);
  border: 1px solid var(--telegram-border);
  border-radius: var(--radius-chip);
  box-sizing: border-box;
}

.telegram-banner.is-visible {
  display: flex;
}

.telegram-banner__icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.telegram-banner__link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  color: inherit;
  text-decoration: none;
}

.telegram-banner__link:hover .telegram-banner__action {
  text-decoration: underline;
}

.telegram-banner__content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.telegram-banner__title {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text);
}

.telegram-banner__desc {
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text);
}

.telegram-banner__action {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--link);
}

.telegram-banner__close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  line-height: 0;
}

.telegram-banner__close img {
  display: block;
  width: 24px;
  height: 24px;
}

/* ── Composer ── */
.composer {
  position: relative;
  z-index: 3;
  flex-shrink: 0;
  padding: 11px 16px 24px;
  border: none;
  background: linear-gradient(to top, var(--bg) 89.27%, rgba(249, 249, 249, 0));
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.composer-inner {
  max-width: var(--chat-max);
  width: 100%;
  margin: 0 auto;
}

.suggestions {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.suggestions.is-visible {
  display: flex;
}

.suggestions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reply-context-bar {
  display: none;
  margin-bottom: 10px;
}

.reply-context-bar.is-visible {
  display: block;
}

.reply-context {
  position: relative;
  padding: 10px 36px 10px 12px;
  border-radius: 10px;
  background: #f2f2f7;
  border-left: 3px solid var(--text);
}

.reply-context__label {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.reply-context__text {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reply-context__close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}

.main.is-start-screen .chat-header {
  display: none;
}

@media (max-width: 768px) {
  .main.is-start-screen {
    justify-content: flex-start;
  }

  .main.is-start-screen .chat-header {
    display: flex;
    width: 100%;
    align-self: stretch;
  }

  .main.is-start-screen .messages {
    flex: 0 1 auto;
    margin-top: auto;
    justify-content: center;
    min-height: 0;
  }

  .main.is-start-screen .composer {
    margin-bottom: auto;
  }

  .start-screen__suggestions-outer {
    --start-col-left: max(16px, (100vw - var(--chat-max)) / 2);
    width: 100vw;
    margin-left: calc(50% - 50vw);
  }

  .start-screen__suggestions-lead {
    flex-basis: var(--start-col-left);
    width: var(--start-col-left);
  }

  .start-screen__suggestions {
    --start-col-left: max(16px, (100vw - var(--chat-max)) / 2);
    padding-right: 16px;
  }

  .start-screen__suggestions .suggestion-chip {
    max-width: 80vw;
    min-width: min(280px, calc(100vw - 48px));
    flex: 0 0 auto;
  }

  .suggestions-list .suggestion-chip {
    max-width: 80vw;
    min-width: 0;
    flex: 0 0 auto;
  }
}

.main.is-start-screen .composer .suggestions {
  display: none !important;
}

.suggestions-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 8px;
}

.suggestion-chip {
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  background: var(--surface);
  font: inherit;
  font-size: 15px;
  font-weight: 400;
  padding: 12px 16px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.suggestion-chip:hover:not(:disabled) {
  border-color: var(--border);
  background: #fafafa;
  color: var(--text);
}

.suggestion-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.composer-row {
  display: flex;
  gap: 24px;
  align-items: flex-end;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-composer);
  box-shadow: var(--shadow-composer);
}

.composer-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  position: relative;
  /* Совпадает с высотой кнопок: при flex-end текст «Транскрибирую» не прилипает вниз */
  min-height: 48px;
}

#messageInput {
  flex: 1;
  width: 100%;
  min-height: 48px;
  max-height: 200px;
  padding: 14px 12px;
  border: none;
  border-radius: 0;
  background: transparent;
  resize: none;
  font-family: Inter, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 20px;
  color: var(--text);
  box-sizing: border-box;
  /* Убирает лишние внутренние отступы form-control на iOS */
  -webkit-appearance: none;
  appearance: none;
}

#messageInput:focus {
  outline: none;
  box-shadow: none;
}

#messageInput::placeholder {
  color: var(--muted);
}

#messageInput:disabled {
  opacity: 0.6;
}

/* Однострочный режим: line-height = height — вертикальный центр на iOS */
#messageInput.is-composer-single {
  height: 48px !important;
  min-height: 48px;
  max-height: 48px;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  line-height: 48px !important;
  overflow: hidden;
}

.composer-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.btn-mic {
  display: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  min-width: 48px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #f4f4f4;
  color: var(--text);
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
}

.composer-row.is-voice-enabled .btn-mic {
  display: inline-flex;
}

.btn-mic:hover:not(:disabled) {
  filter: brightness(0.97);
}

.btn-mic:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-mic__icon {
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.btn-mic__icon--mic {
  display: flex;
  width: 24px;
  height: 24px;
}

.btn-mic__icon--mic img {
  width: 16px;
  height: 21px;
  display: block;
}

.btn-mic__icon--stop {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #fff;
}

.composer-row.is-recording .btn-mic {
  background: var(--send-active);
}

.composer-row.is-recording .btn-mic__icon--mic {
  display: none;
}

.composer-row.is-recording .btn-mic__icon--stop {
  display: block;
}

.composer-recording,
.composer-transcribing {
  display: none;
  flex: 1;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  margin: 0;
  padding: 0 12px;
  box-sizing: border-box;
}

.composer-row.is-recording .composer-recording {
  display: flex;
  gap: 16px;
}

.composer-row.is-recording #messageInput,
.composer-row.is-transcribing #messageInput {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  inset: 0;
  width: auto;
  height: auto !important;
  min-height: 0;
  max-height: none;
  padding: 0 !important;
  margin: 0;
  overflow: hidden;
  z-index: -1;
}

.composer-row.is-transcribing .composer-transcribing {
  display: flex;
  align-items: center;
  justify-content: center;
}

.composer-recording__timer {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: Inter, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--muted);
  white-space: nowrap;
}

.composer-recording__wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: min(407px, 42vw);
  height: 42px;
  flex-shrink: 0;
}

.composer-recording__wave span {
  display: block;
  width: 4px;
  border-radius: 4px;
  background: var(--send-active);
  animation: composer-wave 1.1s ease-in-out infinite;
}

.composer-recording__wave span:nth-child(1) { height: 10px; animation-delay: 0s; }
.composer-recording__wave span:nth-child(2) { height: 16px; animation-delay: 0.05s; }
.composer-recording__wave span:nth-child(3) { height: 10px; animation-delay: 0.1s; }
.composer-recording__wave span:nth-child(4) { height: 26px; animation-delay: 0.15s; }
.composer-recording__wave span:nth-child(5) { height: 22px; animation-delay: 0.2s; }
.composer-recording__wave span:nth-child(6) { height: 16px; animation-delay: 0.25s; }
.composer-recording__wave span:nth-child(7) { height: 10px; animation-delay: 0.3s; }
.composer-recording__wave span:nth-child(8) { height: 26px; animation-delay: 0.35s; }
.composer-recording__wave span:nth-child(9) { height: 16px; animation-delay: 0.4s; }
.composer-recording__wave span:nth-child(10) { height: 22px; animation-delay: 0.45s; }
.composer-recording__wave span:nth-child(11) { height: 14px; animation-delay: 0.5s; }
.composer-recording__wave span:nth-child(12) { height: 22px; animation-delay: 0.55s; }
.composer-recording__wave span:nth-child(13) { height: 16px; animation-delay: 0.6s; }
.composer-recording__wave span:nth-child(14) { height: 10px; animation-delay: 0.65s; }

@keyframes composer-wave {
  0%,
  100% {
    transform: scaleY(0.55);
  }
  50% {
    transform: scaleY(1);
  }
}

.composer-transcribing {
  font-family: Inter, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--muted);
  text-align: center;
}

.composer-transcribing__label {
  display: inline;
}

/* Фиксированная ширина под «...», чтобы «Транскрибирую» не прыгало */
.composer-transcribing__dots {
  display: inline-block;
  width: 1.15em;
  text-align: left;
  vertical-align: baseline;
  overflow: hidden;
  white-space: nowrap;
}

.composer-transcribing__dots span {
  display: inline;
  opacity: 0;
  animation: composer-dot-fade 1.2s infinite;
}

.composer-transcribing__dots span:nth-child(1) {
  animation-delay: 0s;
}
.composer-transcribing__dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.composer-transcribing__dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes composer-dot-fade {
  0%,
  20% {
    opacity: 0;
  }
  40%,
  100% {
    opacity: 1;
  }
}

.composer-voice-error {
  display: none;
  width: 100%;
  margin: 8px 0 0;
  padding: 0 4px;
  font-family: Inter, sans-serif;
  font-size: 12px;
  line-height: 1.35;
  color: #b42318;
  text-align: center;
}

.composer-voice-error.is-visible {
  display: block;
}

.btn-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  min-width: 48px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--send-idle);
  color: #fff;
  flex-shrink: 0;
  cursor: pointer;
}

.btn-send.is-ready:not(:disabled) {
  background: var(--send-active);
}

.btn-send:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-send__label {
  display: none;
}

.btn-send__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.btn-send__icon svg,
.btn-send__icon img {
  width: 14px;
  height: 14px;
}

.disclaimer {
  margin-top: 12px;
  font-family: Inter, sans-serif;
  font-size: 10px;
  font-weight: 200;
  line-height: 1.4;
  letter-spacing: -0.11px;
  color: #000;
  text-align: center;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  .header-new-chat {
    display: flex;
  }

  .sidebar-backdrop {
    display: block;
    background: rgba(174, 174, 174, 0.4);
    backdrop-filter: blur(10px);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 45;
    width: min(310px, 83vw);
    border-radius: 0 32px 32px 0;
    padding-top: max(24px, env(safe-area-inset-top));
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .chat-header {
    min-height: 72px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: none;
    position: relative;
    z-index: 1;
  }

  .btn-chat-close {
    display: none;
  }

  .messages {
    padding: 16px;
  }

  .digest-alert,
  .digest-alert.is-visible {
    display: none !important;
  }

  .sidebar-nav-item--digest.is-highlighted {
    background: transparent;
  }

  .sidebar.is-open .digest-alert {
    left: calc(100% + 12px);
    width: min(222px, calc(100vw - var(--sidebar-w) - 48px));
  }

  .telegram-banner {
    max-width: 90vw;
  }

  .composer {
    padding: 11px 16px max(24px, env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 89.27%, rgba(249, 249, 249, 0));
  }

  /*
   * Mobile + голос (Figma 5014:68566): колонка —
   * placeholder на всю ширину сверху, mic/send снизу справа.
   */
  .composer-row.is-voice-enabled {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 12px;
  }

  .composer-row.is-voice-enabled .composer-field {
    width: 100%;
    min-height: 0;
    align-items: stretch;
  }

  .composer-row.is-voice-enabled #messageInput {
    font-size: 16px;
    line-height: 1.3;
    min-height: 0;
    padding: 8px 12px;
    /* Сброс desktop single-line центрирования */
    height: auto;
  }

  .composer-row.is-voice-enabled #messageInput.is-composer-single {
    height: auto !important;
    min-height: 0;
    max-height: none;
    padding: 8px 12px !important;
    line-height: 1.3 !important;
    overflow: visible;
  }

  .composer-row.is-voice-enabled .composer-actions {
    align-self: flex-end;
    margin-top: 24px;
  }

  /* Без голоса — по-прежнему в ряд (только send) */
  .composer-row:not(.is-voice-enabled) {
    gap: 8px;
    padding: 8px;
  }

  .composer-row:not(.is-voice-enabled) #messageInput {
    font-size: 16px;
    line-height: 20px;
    padding-left: 10px;
    padding-right: 8px;
  }

  .suggestions-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .suggestions-list::-webkit-scrollbar {
    display: none;
  }

  /* Voice: hide mic while typing manually; keep after audio fill */
  .composer-row.is-voice-enabled.is-typing-mobile:not(.is-from-audio):not(.is-recording):not(.is-transcribing)
    .btn-mic {
    display: none;
  }

  .composer-row.is-recording .composer-recording {
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    padding: 8px 12px;
  }

  .composer-row.is-recording .composer-recording__timer {
    flex: 0 0 auto;
    text-align: center;
    width: 100%;
  }

  .composer-row.is-recording .composer-recording__wave {
    width: 82px;
    order: -1;
  }

  .composer-row.is-transcribing .composer-transcribing {
    justify-content: flex-start;
    text-align: left;
    padding: 8px 12px;
    min-height: 0;
  }
}

body.telegram-miniapp .digest-alert,
body.telegram-miniapp .telegram-banner-wrap,
body.telegram-miniapp .telegram-sidebar,
body.telegram-miniapp .a2hs-sidebar,
body.telegram-miniapp .a2hs-toast {
  display: none !important;
}
