.assistant-sheet {
  height: min(86dvh, 780px);
  max-height: calc(100dvh - max(28px, env(safe-area-inset-top)));
  overflow: hidden;
  font-family: var(--font-ui);
}

.assistant-sheet.active {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}

.assistant-sheet .sheet-handle {
  flex: 0 0 auto;
}

.assistant-sheet .chat-body {
  min-height: 0;
  padding-right: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.assistant-sheet .chat-body::-webkit-scrollbar { width: 8px; }
.assistant-sheet .chat-body::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(20, 93, 91, .22); }

.assistant-composer {
  position: relative;
  z-index: 3;
  padding: 10px 0 2px;
  border-top: 1px solid rgba(64, 86, 76, .1);
  background: #fbfdfb;
}

.assistant-composer-main {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(64, 86, 76, .14);
  border-radius: 22px;
  background: rgba(242, 247, 244, .92);
}

.assistant-composer-tool {
  display: inline-grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #52665c;
  background: rgba(255, 255, 255, .72);
  font-family: var(--font-ui);
  cursor: pointer;
}

.assistant-composer-tool > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.assistant-composer-tool:hover { color: #0b6f6c; background: #fff; }
.assistant-composer-tool.is-recording { color: #fff; background: #b83b3b; animation: assistant-recording-pulse 1.2s ease-in-out infinite; }
@keyframes assistant-recording-pulse { 50% { box-shadow: 0 0 0 7px rgba(184, 59, 59, .14); } }
.assistant-composer-tool:focus-visible { outline: 2px solid #0d8d87; outline-offset: 2px; }
.assistant-composer-tool svg { width: 18px; height: 18px; }
.assistant-composer-main .chat-input { margin: 0; }
.assistant-composer-main .chat-input input { min-height: 42px; border: 0; background: transparent; box-shadow: none; }
.assistant-composer-meta { display: flex; min-height: 20px; margin: 6px 4px 0; justify-content: space-between; gap: 12px; color: #87958e; font-size: 0.5625rem; line-height: 1.35; }
.assistant-composer-meta span { max-width: 52%; }
.assistant-composer-meta small { margin-left: auto; text-align: right; }

.assistant-sheet.is-expanded {
  width: 100vw !important;
  height: 100dvh;
  max-height: 100dvh;
  padding-top: max(10px, env(safe-area-inset-top));
  border-radius: 0;
}

.assistant-conversation-header {
  position: relative;
  z-index: 6;
  display: grid !important;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(64, 86, 76, .09);
  background: rgba(251, 253, 251, .96);
  backdrop-filter: blur(18px);
}

.assistant-mode-dock {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 220px);
  align-items: center;
  gap: 8px;
  padding: 4px 0 10px;
  border-bottom: 1px solid rgba(64, 86, 76, .09);
}

.assistant-mode-dock__buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  padding: 3px;
  border: 1px solid rgba(64, 86, 76, .1);
  border-radius: 15px;
  background: rgba(235, 241, 237, .82);
}

.assistant-mode-dock__buttons button {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 38px;
  padding: 0 11px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 11px;
  color: #63736b;
  background: transparent;
  font: 750 0.75rem/1 var(--font-ui);
  cursor: pointer;
}

.assistant-mode-dock__buttons button.active,
.assistant-mode-dock__buttons button[aria-pressed="true"] {
  color: #f7fffd;
  background: linear-gradient(135deg, #197b74, #105955);
  box-shadow: 0 7px 18px rgba(17, 89, 85, .2);
}

.assistant-mode-dock__buttons button svg { width: 16px; height: 16px; }
.assistant-mode-dock__buttons button em {
  position: absolute;
  top: -4px;
  right: 4px;
  padding: 2px 5px;
  border: 1px solid rgba(183, 141, 65, .42);
  border-radius: 999px;
  color: #765a26;
  background: #f4e7c7;
  font: 800 0.4375rem/1 system-ui, sans-serif;
  font-style: normal;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.assistant-mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(64, 86, 76, .1);
  border-radius: 16px;
  background: rgba(235, 241, 237, .82);
}

.assistant-mode-tabs button {
  position: relative;
  display: inline-flex;
  min-width: 0;
  min-height: 42px;
  padding: 0 9px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 12px;
  color: #63736b;
  background: transparent;
  font: 700 0.6875rem/1 system-ui, sans-serif;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease;
}

.assistant-mode-tabs button:hover { color: #135f5b; background: rgba(255, 255, 255, .72); }
.assistant-mode-tabs button:active { transform: translateY(1px); }
.assistant-mode-tabs button:focus-visible { outline: 2px solid #0d8d87; outline-offset: 2px; }
.assistant-mode-tabs button.active,
.assistant-mode-tabs button[aria-pressed="true"] {
  color: #f8fcfa;
  background: linear-gradient(135deg, #19766f, #115955);
  box-shadow: 0 7px 18px rgba(17, 89, 85, .2);
}
.assistant-mode-tabs button:disabled { opacity: .45; cursor: not-allowed; }
.assistant-mode-tabs button svg { width: 15px; height: 15px; flex: 0 0 auto; }
.assistant-mode-tabs button em {
  position: absolute;
  top: -3px;
  right: 3px;
  padding: 2px 4px;
  border: 1px solid rgba(183, 141, 65, .42);
  border-radius: 999px;
  color: #765a26;
  background: #f4e7c7;
  font: 800 0.4375rem/1 system-ui, sans-serif;
  font-style: normal;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.assistant-mode-tabs button.active em,
.assistant-mode-tabs button[aria-pressed="true"] em { color: #fff4d4; background: rgba(53, 35, 4, .28); }

.assistant-mode-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  min-height: 42px;
  padding: 7px 11px;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(173, 132, 58, .2);
  border-radius: 13px;
  color: #3e4e46;
  background: linear-gradient(110deg, rgba(255, 252, 244, .98), rgba(244, 238, 221, .78));
  text-align: left;
  cursor: pointer;
}
.assistant-mode-settings:hover { border-color: rgba(173, 132, 58, .44); }
.assistant-mode-settings:focus-visible { outline: 2px solid #b58b3d; outline-offset: 2px; }
.assistant-mode-settings > span { display: flex; min-width: 0; align-items: center; gap: 8px; }
.assistant-mode-settings > span svg { width: 15px; height: 15px; color: #9a7432; }
.assistant-mode-settings b { overflow: hidden; font: 750 0.75rem/1.2 system-ui, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.assistant-mode-settings small { color: #87938d; font: 550 0.625rem/1 system-ui, sans-serif; }
.assistant-mode-settings > svg { width: 16px; height: 16px; color: #9aa49f; }

.assistant-mode-status {
  min-height: 0;
  margin: -2px 4px 0;
  color: #8a5a4b;
  font: 550 0.6875rem/1.35 system-ui, sans-serif;
}
.assistant-mode-status:empty { display: none; }

.assistant-conversation-heading {
  min-width: 0;
}

.assistant-conversation-heading span,
.assistant-conversation-heading strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-profile-context {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid rgba(135, 153, 145, .24);
  border-radius: 999px;
  color: #718078;
  background: rgba(255, 255, 255, .58);
  font: 700 0.6875rem/1 system-ui, sans-serif;
}

.assistant-profile-context[aria-pressed="true"] {
  border-color: rgba(183, 141, 65, .58);
  color: #715a2f;
  background: #f4ead2;
}

.assistant-profile-context svg {
  width: 15px;
  height: 15px;
}

.assistant-discussions-backdrop {
  position: absolute;
  inset: 0;
  z-index: 8;
  visibility: hidden;
  opacity: 0;
  background: rgba(17, 27, 23, .32);
  transition: opacity .2s ease, visibility .2s ease;
}

.assistant-discussions {
  position: absolute;
  z-index: 9;
  inset: 0 auto 0 0;
  display: flex;
  width: min(340px, 88%);
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  flex-direction: column;
  color: #24312b;
  background: rgba(248, 250, 248, .98);
  border-right: 1px solid rgba(64, 86, 76, .12);
  box-shadow: 20px 0 60px rgba(22, 37, 30, .18);
  transform: translateX(-104%);
  transition: transform .24s cubic-bezier(.2, .75, .25, 1);
}

.assistant-sheet.discussions-open .assistant-discussions {
  transform: translateX(0);
}

.assistant-sheet.discussions-open .assistant-discussions-backdrop {
  visibility: visible;
  opacity: 1;
}

.assistant-discussions__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.assistant-discussions__header span,
.assistant-discussions__header strong {
  display: block;
}

.assistant-discussions__header span {
  color: #9b7a3c;
  font: 700 0.6875rem/1.2 system-ui, sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.assistant-discussions__header strong {
  margin-top: 4px;
  font: 700 1.375rem/1.1 system-ui, sans-serif;
}

.assistant-discussions__header button,
.assistant-thread-menu {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 12px;
  color: #6f7d76;
  background: transparent;
}

.assistant-new-thread {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 15px;
  border: 1px solid rgba(173, 132, 58, .35);
  border-radius: 14px;
  color: #40341f;
  background: linear-gradient(135deg, #f7efd9, #ead8ae);
  font: 750 0.875rem/1 system-ui, sans-serif;
}

.assistant-thread-list {
  display: flex;
  min-height: 80px;
  margin: 15px -5px 0;
  padding: 0 5px 18px;
  overflow: auto;
  flex: 1;
  flex-direction: column;
  gap: 5px;
}

.assistant-thread-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border-radius: 13px;
}

.assistant-thread-row.active {
  background: #e8eee9;
}

.assistant-thread-select {
  min-width: 0;
  padding: 11px 10px;
  border: 0;
  color: #33433b;
  background: transparent;
  text-align: left;
}

.assistant-thread-select strong,
.assistant-thread-select small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-thread-select strong {
  font: 650 0.875rem/1.25 system-ui, sans-serif;
}

.assistant-thread-select small {
  margin-top: 4px;
  color: #829088;
  font: 500 0.6875rem/1.2 system-ui, sans-serif;
}

.assistant-thread-status {
  min-height: 18px;
  margin: 0 4px 10px;
  color: #8a5a4b;
  font: 500 0.75rem/1.4 system-ui, sans-serif;
}

.assistant-drawer-mode {
  position: relative;
  width: 100%;
  padding: 13px;
  border: 1px solid rgba(64, 86, 76, .11);
  border-radius: 14px;
  color: inherit;
  background: #fff;
}

.assistant-drawer-mode__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.assistant-drawer-mode__heading span {
  color: #8c9992;
  font: 650 0.625rem/1 system-ui, sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.assistant-drawer-mode__heading strong {
  color: #34433c;
  font: 700 0.875rem/1.2 system-ui, sans-serif;
}

.assistant-drawer-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 11px;
  padding: 4px;
  border-radius: 13px;
  background: #edf2ef;
}

.assistant-drawer-modes button {
  position: relative;
  display: inline-flex;
  min-height: 42px;
  padding: 0 9px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 10px;
  color: #66766e;
  background: transparent;
  font: 720 0.75rem/1 system-ui, sans-serif;
}

.assistant-drawer-modes button.active,
.assistant-drawer-modes button[aria-pressed="true"] {
  color: #f8fcfa;
  background: linear-gradient(135deg, #19766f, #115955);
  box-shadow: 0 7px 18px rgba(17, 89, 85, .2);
}

.assistant-drawer-modes button:focus-visible { outline: 2px solid #0d8d87; outline-offset: 2px; }
.assistant-drawer-modes button:disabled { opacity: .46; }
.assistant-drawer-modes button svg { width: 15px; height: 15px; }
.assistant-drawer-modes button em {
  position: absolute;
  top: -5px;
  right: 3px;
  padding: 2px 4px;
  border: 1px solid rgba(183, 141, 65, .42);
  border-radius: 999px;
  color: #765a26;
  background: #f4e7c7;
  font: 800 0.4375rem/1 system-ui, sans-serif;
  font-style: normal;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.assistant-drawer-mode > small {
  display: block;
  margin-top: 8px;
  color: #849089;
  font: 500 0.6875rem/1.35 system-ui, sans-serif;
}

.assistant-drawer-mode .assistant-mode-status { margin: 7px 0 0; }

.assistant-usage-summary {
  min-height: 17px;
  margin: 8px 3px 0;
  color: #829088;
  font: 550 0.6875rem/1.35 system-ui, sans-serif;
}

.assistant-empty-state {
  display: grid;
  min-height: 170px;
  padding: 18px;
  place-content: center;
  text-align: center;
}

.assistant-empty-state strong {
  color: #35453d;
  font-family: var(--font-display);
  font-size: clamp(1.125rem, 3.8vw, 1.375rem);
}

.assistant-empty-state__eyebrow { margin-bottom: 7px; color: var(--aqua-deep); font-size: 0.625rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.assistant-empty-state p {
  max-width: 360px;
  margin: 9px auto 18px;
  color: #7c8982;
  line-height: 1.45;
}

.assistant-empty-prompts {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
}

.assistant-empty-prompts button {
  padding: 9px 12px;
  border: 1px solid rgba(75, 101, 89, .16);
  border-radius: 999px;
  color: #52665c;
  background: #f3f6f3;
  font-family: var(--font-ui);
}

.assistant-consent-dialog {
  position: fixed;
  z-index: 11000;
  inset: 0;
  display: grid;
  padding: 20px;
  place-items: center;
  background: rgba(8, 14, 11, .72);
}

.assistant-consent-dialog__panel {
  width: min(520px, 100%);
  max-height: 90dvh;
  padding: 23px;
  overflow: auto;
  border: 1px solid rgba(205, 169, 96, .7);
  border-radius: 20px;
  color: #f6f1e7;
  background: #19201c;
  box-shadow: 0 26px 80px rgba(0, 0, 0, .46);
}

.assistant-consent-dialog__panel h2 { margin: 0 0 10px; }
.assistant-consent-dialog__panel p { color: #c8d0cb; line-height: 1.5; }
.assistant-consent-dialog__panel label { display: flex; gap: 10px; margin: 18px 0; line-height: 1.45; }
.assistant-consent-dialog__panel a { color: #e7c87c; }
.assistant-consent-dialog__actions { display: flex; justify-content: flex-end; gap: 9px; }
.assistant-consent-dialog__actions button { min-height: 42px; padding: 0 14px; border: 1px solid #b99750; border-radius: 11px; color: #f4eee2; background: transparent; }
.assistant-consent-dialog__actions button:last-child { color: #172019; background: #d8b769; }

.assistant-brain-dialog__intro { margin-bottom: 16px !important; }
.assistant-brain-options { display: grid; gap: 9px; }
.assistant-mode-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid rgba(221, 205, 171, .24);
  border-radius: 13px;
  color: #f4eee2;
  background: rgba(255, 255, 255, .035);
  text-align: left;
}
.assistant-mode-option:hover { border-color: rgba(216, 183, 105, .72); }
.assistant-mode-option.active { border-color: #d8b769; background: rgba(216, 183, 105, .13); }
.assistant-mode-option:disabled { opacity: .45; cursor: not-allowed; }
.assistant-mode-option strong { font: 700 0.875rem/1.25 system-ui, sans-serif; }
.assistant-mode-option small { grid-column: 1 / -1; color: #bfc9c3; font: 500 0.75rem/1.35 system-ui, sans-serif; }
.assistant-mode-option em { align-self: start; color: #dfc47f; font: 650 0.625rem/1.2 system-ui, sans-serif; font-style: normal; letter-spacing: .06em; text-transform: uppercase; }
.assistant-mode-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 16px;
}
.assistant-mode-tools button {
  display: flex;
  min-height: 46px;
  padding: 0 12px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(221, 205, 171, .24);
  border-radius: 12px;
  color: #f4eee2;
  background: rgba(255, 255, 255, .035);
  font: 650 0.75rem/1.2 system-ui, sans-serif;
}
.assistant-mode-tools button:hover { border-color: rgba(216, 183, 105, .72); }
.assistant-mode-tools svg { width: 16px; height: 16px; }
.assistant-mode-tools button:last-child { grid-column: 1 / -1; }
.assistant-brain-dialog__close { margin-top: 16px; }

@media (max-width: 560px) {
  .assistant-sheet {
    width: 100vw !important;
    height: 100dvh;
    max-height: 100dvh;
    padding: max(8px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
    border-radius: 0;
  }
  .assistant-sheet .sheet-handle { margin-bottom: 9px; }
  .assistant-sheet .chat-body { padding: 16px 2px 12px 0; }
  .assistant-mode-tabs {
    display: flex;
    padding-bottom: 5px;
    overflow-x: auto;
    scrollbar-width: none;
    overscroll-behavior-inline: contain;
  }
  .assistant-mode-tabs::-webkit-scrollbar { display: none; }
  .assistant-mode-tabs button { min-width: 84px; padding-inline: 5px; gap: 4px; font-size: 0.625rem; }
  .assistant-mode-settings small { display: none; }
  .assistant-mode-dock { grid-template-columns: minmax(0, 1fr) !important; gap: 5px !important; padding-top: 0 !important; }
  .assistant-mode-dock > div:first-child {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
  }
  .assistant-mode-dock > div:first-child > small { display: none; }
  .assistant-mode-dock__buttons { width: 100% !important; }
  .assistant-mode-dock__buttons button { min-height: 36px; padding-inline: 7px; }
  .assistant-mode-dock__buttons button span { font-size: 0.625rem; }
  .assistant-composer-meta span { display: none; }
  .assistant-composer-meta small { margin: 0; text-align: left; }
  .assistant-expand-button { display: none; }
  .assistant-profile-context span { display: none; }
  .assistant-profile-context { width: 38px; padding: 0; justify-content: center; }
  .assistant-conversation-header { gap: 7px; }
}

@media (min-width: 900px) {
  .assistant-sheet {
    width: min(680px, calc(100vw - 48px)) !important;
  }
  .assistant-discussions {
    width: 330px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .assistant-discussions,
  .assistant-discussions-backdrop,
  .assistant-mode-tabs button { transition: none; }
}

/* One brand type system across every assistant control and message. */
.assistant-sheet,
.assistant-sheet :is(button, input, textarea, select, p, small, span, em) {
  font-family: var(--font-ui) !important;
}

.assistant-sheet :is(
  .assistant-conversation-heading strong,
  .assistant-empty-state strong,
  .assistant-thread-select strong,
  .assistant-mode-option strong,
  .assistant-rich-text h1,
  .assistant-rich-text h2,
  .assistant-rich-text h3
) {
  font-family: var(--font-display) !important;
}

.assistant-sheet.active {
  pointer-events: auto;
}

.assistant-sheet :is(
  .assistant-mode-dock__buttons button,
  .assistant-mode-tabs button,
  .assistant-empty-prompts button,
  .assistant-input-tools button,
  .assistant-mode-tools button,
  .assistant-composer-tool
) {
  min-height: 48px;
  touch-action: manipulation;
  pointer-events: auto;
}

.assistant-sheet :is(.assistant-mode-dock__buttons, .assistant-mode-tabs) {
  border-color: rgba(25, 123, 116, .14);
  background: rgba(231, 244, 240, .92);
}

.assistant-sheet .assistant-composer {
  background: rgba(251, 253, 251, .98);
  backdrop-filter: blur(18px);
}

html[data-theme="dark"] .assistant-sheet {
  color: var(--ink);
  background: #0b2022;
}

html[data-theme="dark"] .assistant-conversation-header {
  border-color: rgba(126, 221, 211, .12);
  background: rgba(8, 27, 29, .96);
}

html[data-theme="dark"] .assistant-sheet :is(
  .assistant-mode-dock__buttons,
  .assistant-mode-tabs,
  .assistant-composer-main,
  .assistant-empty-prompts button,
  .assistant-input-tools button
) {
  color: var(--ink);
  border-color: rgba(126, 221, 211, .16);
  background: rgba(16, 46, 48, .94);
}

html[data-theme="dark"] .assistant-sheet .assistant-composer {
  border-color: rgba(126, 221, 211, .12);
  background: rgba(8, 27, 29, .98);
}

html[data-theme="dark"] .assistant-sheet :is(.assistant-conversation-heading strong, .assistant-empty-state strong) {
  color: #efffFC;
}

html[data-telegram-entry="complete"] body:not(.web-mode):not(.demo-mode) .assistant-sheet.active {
  inset: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: var(--app-viewport-height, 100dvh);
  max-height: var(--app-viewport-height, 100dvh);
  margin: 0 !important;
  padding-top: max(10px, var(--app-safe-top, env(safe-area-inset-top)));
  border-radius: 0;
  transform: none !important;
}

@media (min-width: 900px) {
  html[data-telegram-entry="complete"] body:not(.web-mode):not(.demo-mode) .assistant-sheet.active {
    inset: auto auto 24px 50% !important;
    left: 50% !important;
    width: min(680px, calc(100vw - 48px)) !important;
    height: min(700px, calc(var(--app-viewport-height, 100dvh) - 96px));
    max-height: calc(var(--app-viewport-height, 100dvh) - 96px);
    padding: 14px 20px 16px;
    border: 1px solid rgba(25,123,116,.14);
    border-radius: 28px;
    box-shadow: 0 30px 100px rgba(16,64,64,.28);
    transform: translateX(-50%) !important;
  }

  .assistant-sheet .chat-body {
    padding-top: 16px;
  }
}

/* module=ask; channel=miniapp,web; layer=ui; scenario=assistant.design-20261004 */
.assistant-sheet .assistant-conversation-header {
  grid-template-columns: 44px 40px minmax(0, 1fr) 44px 44px !important;
  gap: clamp(5px, 1.2vw, 12px);
  padding-block: 8px 14px;
  min-width: 0;
}
.assistant-sheet .assistant-conversation-heading { min-width: 0; }
.assistant-sheet .assistant-conversation-heading span { font-size: 1.05rem; font-weight: 750; }
.assistant-sheet .assistant-conversation-heading strong { font-size: .78rem; font-weight: 500; opacity: .76; }
.assistant-sheet .assistant-conversation-header > .icon-button,
.assistant-sheet .assistant-discussions__header button {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 10px;
  flex: 0 0 44px;
  place-items: center;
  touch-action: manipulation;
  border-radius: 15px;
}
.assistant-sheet .assistant-conversation-header > .icon-button svg,
.assistant-sheet .assistant-discussions__header button svg { pointer-events: none; width: 22px; height: 22px; }
.assistant-sheet .assistant-composer-main {
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  border-radius: 25px;
  padding: 8px;
  box-shadow: 0 8px 28px rgba(21, 89, 86, .05);
}
.assistant-sheet .assistant-composer-tool { width: 44px; height: 44px; }
.assistant-sheet .assistant-composer-main .chat-input input { width: 100%; min-width: 0; min-height: 44px; font-size: 1rem; }
.assistant-sheet .chat-input { min-width: 0; }
.assistant-sheet .assistant-mode-dock__buttons button { min-height: 44px; font-size: .84rem; }
.assistant-sheet .assistant-empty-state { border: 0; background: transparent; padding-block: 32px; }
.assistant-sheet .assistant-empty-state strong { font-size: clamp(1.7rem, 4vw, 2.25rem); line-height: 1.13; letter-spacing: -.035em; }
.assistant-sheet .assistant-rich-text { font-size: 1rem; line-height: 1.68; overflow-wrap: anywhere; }
.assistant-sheet .assistant-rich-text :is(h1,h2,h3) { letter-spacing: -.025em; line-height: 1.25; margin-top: 1.2em; }
.assistant-sheet .assistant-rich-text strong { color: var(--ink, #164f4d); font-weight: 750; }
.assistant-sheet .assistant-rich-text blockquote { padding: 12px 18px; border-left: 3px solid #28bbae; background: rgba(38,181,170,.075); border-radius: 0 15px 15px 0; }
.assistant-sheet .assistant-composer-meta { font-size: .7rem; line-height: 1.45; }
#assistant-attachment-status { margin: 8px 5px 0; font-size: .8rem; line-height: 1.45; color: var(--muted, #5b7876); }
#assistant-attachment-status:empty { display: none; }
#assistant-attachment-status.is-error { color: #b94e55; }
.assistant-sheet .assistant-thread-select { min-height: 56px; }
.assistant-sheet .assistant-discussions { gap: 5px; padding: 22px 18px; }
.assistant-sheet #assistant-history-date {
  box-sizing: border-box; width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px;
  color: inherit; border: 1px solid rgba(35,144,137,.2); border-radius: 14px; font: inherit; background: rgba(103,206,196,.07);
}
.assistant-sheet .assistant-discussions:focus-within { outline: none; }
html[data-theme="dark"] .assistant-sheet .assistant-discussions { background: #0c252b; color: #e6f8f6; border-color: #1c4a50; }
html[data-theme="dark"] .assistant-sheet .assistant-composer-tool { color: #bcf1e9; background: #173d44; }
html[data-theme="dark"] .assistant-sheet .assistant-rich-text strong { color: #b4f3e3; }

/* A voice state lives inside the same chat, with no second conversation owner. */
.assistant-sheet:not(.voice-session):is([data-voice-phase="starting"],[data-voice-phase="listening"],[data-voice-phase="transcribing"]) .chat-body {
  display: grid; place-content: center; justify-items: center; gap: 26px; padding: 28px 10px;
}
.assistant-sheet:not(.voice-session):is([data-voice-phase="starting"],[data-voice-phase="listening"],[data-voice-phase="transcribing"]) .chat-body > * { display: none; }
.assistant-sheet:not(.voice-session):is([data-voice-phase="starting"],[data-voice-phase="listening"],[data-voice-phase="transcribing"]) .chat-body::before {
  content: ""; display: block; width: clamp(120px, 27vw, 190px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 26% 20%, #f1fff9 0%, #a9f0df 16%, transparent 40%),
    radial-gradient(circle at 75% 75%, #5b71c8, transparent 57%),
    conic-gradient(from 15deg, #20b9b4, #c4f3eb, #8398e5, #54d7c9, #20b9b4);
  box-shadow: inset 0 0 24px rgba(255,255,255,.55), 0 0 50px rgba(48,193,185,.22), 0 25px 65px rgba(34,92,112,.16);
  animation: epigen-listening-breathe 3s ease-in-out infinite;
}
.assistant-sheet:not(.voice-session)[data-voice-phase="starting"] .chat-body::after { content: "Подключаю микрофон"; }
.assistant-sheet:not(.voice-session)[data-voice-phase="listening"] .chat-body::after { content: "Я слушаю"; }
.assistant-sheet:not(.voice-session)[data-voice-phase="transcribing"] .chat-body::after { content: "Распознаю вашу речь"; }
.assistant-sheet:not(.voice-session):is([data-voice-phase="starting"],[data-voice-phase="listening"],[data-voice-phase="transcribing"]) .chat-body::after {
  color: var(--ink, #164f4d); font-size: 1.5rem; font-weight: 600; letter-spacing: -.025em; text-align: center;
}
@keyframes epigen-listening-breathe { 50% { transform: scale(1.06); filter: hue-rotate(16deg); } }
.assistant-sheet[data-voice-phase="speaking"] #assistant-voice-button {
  color: #075f5b; background: #acf0df; box-shadow: 0 0 0 6px rgba(53,188,172,.12);
}

/* Stronger than the Telegram desktop card rule: expansion must actually expand. */
html body .assistant-sheet.active.is-expanded,
html[data-telegram-entry="complete"] body:not(.web-mode):not(.demo-mode) .assistant-sheet.active.is-expanded {
  position: fixed;
  inset: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: var(--app-viewport-height, 100dvh) !important;
  max-height: var(--app-viewport-height, 100dvh) !important;
  margin: 0 !important;
  padding: max(12px, var(--app-safe-top, env(safe-area-inset-top))) clamp(14px, 5vw, 96px) max(16px, env(safe-area-inset-bottom));
  border-radius: 0;
  transform: none !important;
}
@media (max-width: 560px) {
  .assistant-sheet .assistant-conversation-header { grid-template-columns: 44px 34px minmax(0,1fr) 44px !important; }
  .assistant-sheet .assistant-expand-button { display: none !important; }
  .assistant-sheet .assistant-conversation-header .assistant-emblem { width: 34px; height: 34px; }
  .assistant-sheet .assistant-conversation-heading span { font-size: .98rem; }
  .assistant-sheet .assistant-conversation-heading strong { font-size: .72rem; }
  .assistant-sheet .assistant-mode-dock__buttons button span { font-size: .8rem; }
  .assistant-sheet .assistant-composer-meta { display: block; }
  .assistant-sheet .assistant-composer-meta small { text-align: left; }
  .assistant-sheet .assistant-rich-text { font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .assistant-sheet .chat-body::before, .assistant-sheet .is-recording { animation: none !important; }
}

/* module=ask; channel=miniapp,web; layer=ui; scenario=voice-session */
.assistant-voice-session-stage[hidden] { display: none !important; }
.assistant-sheet.voice-session {
  --voice-aqua: #008f94;
  --voice-shine: #ccffff;
  --voice-gold: #d5aa43;
  --voice-card: var(--surface-glass, rgba(232, 253, 250, .78));
  isolation: isolate;
  color: var(--ink, #123f4b);
  background: radial-gradient(ellipse at 52% 28%, rgba(119, 232, 217, .28), transparent 48%),
    linear-gradient(155deg, #e5f3f1 0%, #c9e6e6 53%, #eff9f2 100%);
}
.assistant-sheet.voice-session::before {
  content: ""; position: absolute; z-index: -1; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle at 18% 27%, rgba(255,255,255,.86) 0 1px, transparent 3px),
    radial-gradient(circle at 79% 64%, rgba(244,220,149,.8) 0 1px, transparent 4px),
    radial-gradient(circle at 61% 19%, rgba(69,224,211,.7) 0 1px, transparent 3px);
  background-size: 103px 137px, 179px 211px, 239px 191px; opacity: .52;
}
.assistant-sheet.voice-session.active {
  grid-template-rows: auto auto minmax(200px, .8fr) minmax(0, 1fr) auto;
}
.assistant-sheet.voice-session :is(
  .assistant-mode-dock, .assistant-discussions-button, .assistant-discussions,
  .assistant-discussions-backdrop, #assistant-history-back, .assistant-empty-state,
  .assistant-empty-prompts, .user-message, #chat-form, #assistant-attach-button,
  #assistant-attachment-status, .assistant-composer-meta > span
) { display: none !important; }
.assistant-sheet.voice-session .assistant-conversation-header {
  grid-template-columns: 40px minmax(0, 1fr) 44px 44px !important;
  background: transparent; border: 0; backdrop-filter: none; padding-bottom: 6px;
}
.assistant-sheet.voice-session .assistant-conversation-heading span {
  color: var(--ink, #123f4b); font-size: clamp(1.3rem, 3.8vw, 1.8rem);
  font-weight: 750; letter-spacing: -.04em;
}
.assistant-sheet.voice-session .assistant-conversation-heading strong { display: none; }
.assistant-sheet.voice-session .assistant-conversation-heading::after {
  content: "Голосовой помощник"; display: block; margin-top: 3px;
  font-size: .85rem; color: var(--muted, #43696e); line-height: 1.35;
}
.assistant-sheet.voice-session .assistant-conversation-header > .icon-button {
  border: 1px solid var(--line-glass, rgba(255,255,255,.75));
  border-radius: 50%; background: var(--voice-card); color: var(--ink, #123f4b);
}
.assistant-sheet.voice-session .assistant-voice-session-stage {
  display: flex; min-height: 0; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; padding: 10px 12px 12px; text-align: center;
}
.assistant-voice-session-stage strong {
  color: var(--ink, #123f4b); font-size: clamp(1.3rem, 3.5vw, 1.65rem);
  line-height: 1.2; letter-spacing: -.025em; font-weight: 750;
}
.assistant-voice-session-stage p {
  max-width: 38ch; margin: 2px 0 0; color: var(--muted, #43696e);
  font-size: .85rem; line-height: 1.4; text-wrap: balance;
}
.assistant-voice-session-orb {
  position: relative; width: clamp(98px, 18dvh, 168px); aspect-ratio: 1; flex-shrink: 0;
  perspective: 550px; transform-style: preserve-3d; border-radius: 50%;
  filter: drop-shadow(0 9px 18px rgba(1,133,139,.18));
}
.assistant-atom-halo {
  position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(185,255,246,.7);
  background: radial-gradient(circle at 28% 22%, rgba(255,255,255,.85), transparent 32%),
    radial-gradient(circle, rgba(131,245,227,.15), rgba(130,242,227,.05) 66%, rgba(222,255,241,.32));
  box-shadow: inset 0 0 20px rgba(229,255,247,.7), 0 0 24px rgba(91,223,210,.25);
}
.assistant-atom-core {
  position: absolute; inset: 35%; border-radius: 50%;
  background: radial-gradient(circle at 33% 25%, #fff 0 7%, #fff6c4 14%, #ffd66c 35%, #d99c23 67%, #fff0a0 91%);
  box-shadow: inset -3px -5px 8px rgba(150,94,0,.22), 0 0 14px #fff6b9, 0 0 36px rgba(238,196,62,.4);
}
.assistant-atom-ring {
  position: absolute; inset: 7%; border: 5px solid transparent; border-radius: 50%;
  background: linear-gradient(135deg, #e6fffc, #38c5c1 25%, #04878c 56%, #a1fff1 82%, #e7fff8) border-box;
  mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  box-shadow: 0 0 7px rgba(179,255,245,.85);
}
.assistant-atom-ring--equator { transform: rotateX(66deg) rotateZ(-15deg); }
.assistant-atom-ring--left {
  transform: rotateZ(-24deg) rotateY(66deg);
  background: linear-gradient(135deg, #ffefb2, #bf9b41 30%, #388f7a 68%, #fff2b4) border-box;
}
.assistant-atom-ring--right { transform: rotateZ(42deg) rotateY(68deg); }
.assistant-voice-wave {
  display: flex; justify-content: center; align-items: center; gap: 4px;
  width: min(240px, 85%); height: 38px; margin-block: 1px 0; flex-shrink: 0;
}
.assistant-voice-wave span {
  display: block; width: 3px; height: var(--bar-height); min-height: 3px; border-radius: 5px;
  background: var(--voice-aqua); opacity: .55; transform: scaleY(.4);
  box-shadow: 0 0 5px rgba(121,243,229,.38);
}
.assistant-sheet.voice-session:is([data-voice-phase="listening"],[data-voice-phase="speaking"]) .assistant-voice-wave span {
  opacity: 1; animation: epigen-voice-wave .95s ease-in-out var(--bar-delay) infinite alternate;
}
.assistant-sheet.voice-session:is([data-voice-phase="starting"],[data-voice-phase="transcribing"],[data-voice-phase="thinking"]) .assistant-atom-halo {
  animation: epigen-atom-breathe 2.4s ease-in-out infinite;
}
.assistant-sheet.voice-session[data-voice-phase="thinking"] .assistant-voice-wave span {
  background: var(--voice-gold); animation: epigen-voice-wave 1.8s ease-in-out var(--bar-delay) infinite alternate;
}
.assistant-sheet.voice-session[data-voice-phase="speaking"] .assistant-atom-core { animation: epigen-atom-breathe 1.9s ease-in-out infinite; }
.assistant-sheet.voice-session .chat-body {
  display: block; min-height: 0; padding: 8px 5px 12px; scroll-padding-block: 14px;
}
.assistant-sheet.voice-session .assistant-message {
  box-sizing: border-box; width: 100%; max-width: 560px; margin: 0 auto 12px;
  padding: clamp(15px, 3vw, 23px); border: 1px solid var(--line-glass, rgba(255,255,255,.85));
  background: var(--voice-card); border-radius: 24px; backdrop-filter: blur(18px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 10px 28px rgba(6,84,92,.09);
  color: var(--ink, #123f4b);
}
.assistant-sheet.voice-session .assistant-message > span,
.assistant-sheet.voice-session .assistant-source { color: var(--muted, #43696e); font-size: .75rem; }
.assistant-sheet.voice-session .assistant-rich-text { font-size: 1rem; line-height: 1.55; }
.assistant-sheet.voice-session .assistant-rich-text :is(h1,h2,h3) {
  margin-block: .25em .65em; color: var(--ink, #123f4b); font-size: 1.18rem;
}
.assistant-sheet.voice-session .assistant-rich-text :is(ul,ol) { padding-left: 1.2em; }
.assistant-sheet.voice-session .assistant-rich-text li { padding-block: 5px; }
.assistant-sheet.voice-session .assistant-message :is(button,[role="button"]) {
  min-height: 44px; max-width: 100%; font-size: .95rem; border-radius: 18px;
  white-space: normal; overflow-wrap: anywhere;
}
.assistant-sheet.voice-session .assistant-composer {
  border-top: 0; padding: 3px 0 max(10px, env(safe-area-inset-bottom));
  background: transparent; backdrop-filter: none;
}
.assistant-sheet.voice-session .assistant-composer-main {
  display: flex; justify-content: center; border: 0; padding: 5px;
  background: transparent; box-shadow: none;
}
.assistant-sheet.voice-session #assistant-voice-button {
  width: 60px; height: 60px; border: 1px solid #bafff4; color: #f2fffb;
  background: radial-gradient(circle at 40% 25%, #36c3c4, #087d89 65%, #005865);
  box-shadow: inset 0 0 9px rgba(203,255,246,.55), 0 0 0 4px rgba(141,244,229,.13), 0 0 25px rgba(4,191,184,.25);
}
.assistant-sheet.voice-session #assistant-voice-button svg { width: 27px; height: 27px; }
.assistant-sheet.voice-session #assistant-voice-button.is-recording { animation: epigen-atom-breathe 2s ease-in-out infinite; }
.assistant-sheet.voice-session #assistant-voice-button:focus-visible { outline: 3px solid var(--voice-aqua); outline-offset: 4px; }
.assistant-sheet.voice-session .assistant-composer-meta { display: block; margin: 4px auto 0; max-width: 42ch; text-align: center; }
.assistant-sheet.voice-session .assistant-composer-meta small {
  display: block; margin: 0; color: var(--muted, #43696e); text-align: center; font-size: .78rem; line-height: 1.4;
}
html[data-theme="dark"] .assistant-sheet.voice-session {
  --voice-aqua: #8ef9ef;
  --voice-gold: #eaca79;
  --voice-card: var(--surface-glass, rgba(6, 52, 66, .81));
  background: radial-gradient(ellipse at 52% 28%, rgba(8,115,121,.37), transparent 52%),
    linear-gradient(155deg, #041d2b, #063545 60%, #061e2c);
}
html[data-theme="dark"] .assistant-sheet.voice-session .assistant-message {
  box-shadow: inset 0 1px 0 rgba(191,255,250,.17), 0 14px 30px rgba(0,0,0,.16);
}
html[data-theme="dark"] .assistant-sheet.voice-session .assistant-rich-text strong { color: #edfffb; }
@keyframes epigen-voice-wave { from { transform: scaleY(.45); } to { transform: scaleY(1.8); } }
@keyframes epigen-atom-breathe { 50% { opacity: .8; filter: brightness(1.15); } }
@media(max-width:560px) {
  .assistant-sheet.voice-session .assistant-conversation-header { grid-template-columns: 34px minmax(0,1fr) 44px !important; }
}
@media(max-height:680px) {
  .assistant-sheet.voice-session.active { grid-template-rows: auto auto minmax(132px,.65fr) minmax(0,1fr) auto; }
  .assistant-sheet.voice-session .assistant-voice-session-stage { gap: 2px; padding: 4px; }
  .assistant-voice-session-orb { width: 76px; }
  .assistant-voice-wave { height: 24px; }
  .assistant-voice-session-stage strong { font-size: 1.15rem; }
  .assistant-voice-session-stage p { font-size: .75rem; }
  .assistant-sheet.voice-session #assistant-voice-button { width: 48px; height: 48px; }
}
@media(prefers-reduced-motion:reduce) {
  .assistant-voice-session-orb *, .assistant-voice-wave span,
  .assistant-sheet.voice-session #assistant-voice-button { animation: none !important; transition: none !important; }
  .assistant-voice-wave span { transform: none; }
}


/* module=diary; channel=miniapp,web; layer=ui; scenario=assistant.confirmed-entry */
.assistant-diary-card { display:grid; gap:12px; padding:18px; border:1px solid var(--line-glass,#75bfb94d); border-radius:22px; background:var(--surface-card,#f2fbf9); color:var(--ink,#173d3a); }
.assistant-diary-card > strong { font-size:clamp(1.0625rem,3.8vw,1.25rem); line-height:1.35; }
.assistant-diary-card > p { margin:0; font-size:1rem; line-height:1.55; overflow-wrap:anywhere; }
.assistant-diary-card .assistant-diary-card__status { color:var(--muted,#5d7774); font-size:.875rem; }
.assistant-diary-card__actions { display:flex; flex-wrap:wrap; gap:10px; }
.assistant-diary-card__actions button { flex:1 1 120px; min-height:48px; padding:11px 15px; border:1px solid var(--line-glass,#75bfb94d); border-radius:14px; color:var(--ink,#173d3a); background:var(--surface-glass,#fff); font:inherit; font-weight:650; }
.assistant-diary-card__actions button:first-child { color:#fff; background:#157c75; border-color:#157c75; }
.assistant-diary-card__actions button:disabled { opacity:.55; cursor:default; }
