.modi-context-root {
  --modi-blue: #176fe5;
  --modi-ink: #13243b;
  position: fixed;
  right: 22px;
  bottom: 78px;
  z-index: 1600;
  font-family: Inter, "Segoe UI", sans-serif;
  color: var(--modi-ink);
}
.modi-context-root[hidden] { display: none; }
.modi-context-launcher {
  position: relative;
  width: 92px;
  height: 92px;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* Тот же Моди, что на сайте: полный персонаж без плашки, плавает и моргает */
.modi-context-launcher .modi-avatar { position: relative; display: block; width: 112px; height: 112px; margin: -10px; pointer-events: none; filter: drop-shadow(0 12px 22px rgba(24,108,238,.28)); animation: modi-ctx-float 6.8s ease-in-out infinite; }
.modi-context-launcher .modi-avatar img { display: block; width: 100%; height: 100%; object-fit: contain; }
.modi-context-launcher .modi-frame-blink { position: absolute; inset: 0; opacity: 0; clip-path: polygon(43% 31%,89% 30%,89% 72%,43% 74%); animation: modi-ctx-blink 7.4s ease-in-out infinite; }
@keyframes modi-ctx-blink { 0%,84%,91%,100% { opacity: 0 } 87%,89% { opacity: 1 } }
@keyframes modi-ctx-float { 0%,100% { transform: translate3d(0,1px,0) rotate(-.7deg) } 30% { transform: translate3d(-3px,-4px,0) rotate(.5deg) } 65% { transform: translate3d(3px,-1px,0) rotate(1deg) } }
@media (prefers-reduced-motion: reduce) { .modi-context-launcher .modi-avatar, .modi-context-launcher .modi-frame-blink { animation: none !important } }
.modi-context-launcher:hover { transform: translateY(-2px); }
.modi-context-root.is-open .modi-context-launcher { display: none; }
.modi-context-root.is-open > .modi-context-launcher { display: none !important; }
.modi-context-panel[hidden], .modi-request[hidden] { display: none !important; }
.modi-context-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(390px, calc(100vw - 28px));
  height: min(660px, calc(100vh - 100px));
  min-width: 320px;
  min-height: 360px;
  max-height: min(660px, calc(100vh - 100px));
  display: grid;
  grid-template-rows: auto auto minmax(90px, 1fr) auto;
  overflow: hidden;
  resize: both;
  border: 1px solid #d8e5f2;
  border-radius: 21px;
  background: rgba(250, 253, 255, .98);
  box-shadow: 0 28px 80px rgba(15, 43, 80, .24);
}
.modi-context-panel[hidden] { display: none; }
.modi-context-head { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-bottom: 1px solid #dde8f3; background: linear-gradient(130deg, #eef7ff, #fff); }
.modi-context-mark { width: 46px; height: 46px; display: grid; place-items: center; overflow: hidden; border-radius: 13px; background: linear-gradient(145deg, #eaf5ff, #fff); }
.modi-context-mark img { width: 52px; height: 52px; max-width: none; object-fit: contain; }
.modi-context-title { min-width: 0; flex: 1; }
.modi-context-title strong, .modi-context-title small { display: block; }
.modi-context-title small { margin-top: 2px; overflow: hidden; color: #687c95; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.modi-context-close { align-self: flex-start; flex: none; width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 1px solid #dbe6f1; border-radius: 10px; background: #fff; color: #52657d; cursor: pointer; }
.modi-context-close svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.modi-context-guide { padding: 13px 15px; border-bottom: 1px solid #e1eaf3; background: #f4f9ff; }
.modi-context-guide p { margin: 0; color: #435a76; font-size: 12px; line-height: 1.5; }
.modi-context-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.modi-context-suggestions button { padding: 6px 8px; border: 1px solid #cfe0f2; border-radius: 9px; background: #fff; color: #1b5fae; font: inherit; font-size: 10px; font-weight: 800; cursor: pointer; }
.modi-context-feed { overflow: auto; padding: 14px; }
.modi-context-message { max-width: 90%; margin: 0 0 10px; padding: 9px 11px; border: 1px solid #dbe7f2; border-radius: 14px 14px 14px 5px; background: #fff; font-size: 12px; line-height: 1.5; white-space: pre-wrap; }
.modi-context-message.user { margin-left: auto; border-color: transparent; border-radius: 14px 14px 5px 14px; background: var(--modi-blue); color: #fff; }
.modi-context-message.error { color: #a32929; background: #fff5f5; }
.modi-context-thinking { min-height: 58px; display: flex; align-items: center; gap: 10px; }
.modi-context-thinking > span:last-child { display: grid; gap: 2px; }
.modi-context-thinking strong { font-size: 12px; }
.modi-context-thinking small { color: #687c95; font-size: 10px; }
.modi-context-spinner { width: 18px; height: 18px; flex: none; border: 2px solid #cfe1f5; border-top-color: var(--modi-blue); border-radius: 50%; animation: modi-context-spin .8s linear infinite; }
@keyframes modi-context-spin { to { transform: rotate(360deg); } }
.modi-context-compose { padding: 12px; border-top: 1px solid #dfe9f3; background: #fff; }
.modi-context-compose textarea { width: 100%; min-height: 64px; max-height: 120px; padding: 10px 11px; resize: vertical; border: 1px solid #cfdae7; border-radius: 12px; color: var(--modi-ink); font: inherit; font-size: 12px; }
.modi-context-compose textarea:focus { outline: 3px solid rgba(23, 111, 229, .14); border-color: var(--modi-blue); }
.modi-context-tools { min-height: 31px; display: flex; align-items: center; gap: 9px; margin-top: 6px; }
.modi-context-tools button { min-height: 30px; display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; border: 1px solid #cfdeed; border-radius: 9px; background: #fff; color: #31506f; font: inherit; font-size: 10px; font-weight: 800; cursor: pointer; }
.modi-context-tools button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.modi-context-tools button.is-listening { border-color: #dc4c4c; background: #fff1f1; color: #b42323; }
.modi-context-tools button:disabled { opacity: .5; cursor: not-allowed; }
.modi-context-tools small { color: #75869a; font-size: 9px; line-height: 1.35; }
.modi-context-actions { display: flex; gap: 7px; margin-top: 8px; }
.modi-context-actions button { min-height: 38px; padding: 0 12px; border: 1px solid #cfdeed; border-radius: 10px; background: #fff; color: #31506f; font: inherit; font-size: 11px; font-weight: 800; cursor: pointer; }
.modi-context-actions button.primary { flex: 1; border-color: var(--modi-blue); background: var(--modi-blue); color: #fff; }
.modi-context-actions button:disabled { opacity: .55; cursor: wait; }
.modi-request { display: grid; gap: 9px; margin-top: 10px; padding: 12px; border: 1px solid #cfe0f2; border-radius: 13px; background: #f7fbff; }
.modi-request[hidden] { display: none; }
.modi-request strong { font-size: 12px; }
.modi-request textarea { min-height: 76px; background: #fff; }
.modi-request small { min-height: 16px; color: #62758d; font-size: 10px; line-height: 1.4; }
.modi-guide-target {
  position: relative !important;
  z-index: 2101 !important;
  outline: 4px solid #2f8cff !important;
  outline-offset: 5px !important;
  border-radius: 8px;
  box-shadow: 0 0 0 9px rgba(47, 140, 255, .18), 0 12px 34px rgba(16, 62, 116, .28) !important;
  animation: modi-guide-pulse 1.5s ease-in-out infinite;
}
.modi-guide-tip {
  position: fixed;
  z-index: 2300;
  width: min(340px, calc(100vw - 24px));
  padding: 16px;
  border: 1px solid #bfd9f5;
  border-radius: 16px;
  background: #fff;
  color: #13243b;
  box-shadow: 0 22px 64px rgba(13, 44, 82, .3);
  font-family: Inter, "Segoe UI", sans-serif;
}
.modi-guide-kicker { margin-bottom: 5px; color: #176fe5; font-size: 10px; font-weight: 900; letter-spacing: .055em; text-transform: uppercase; }
.modi-guide-tip strong { display: block; font-size: 16px; line-height: 1.3; }
.modi-guide-tip p { margin: 7px 0 0; color: #526983; font-size: 12px; line-height: 1.5; }
.modi-guide-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 13px; }
.modi-guide-actions button { min-height: 36px; padding: 0 12px; border: 1px solid #ceddec; border-radius: 9px; background: #fff; color: #31506f; font: inherit; font-size: 11px; font-weight: 800; cursor: pointer; }
.modi-guide-actions button.primary { border-color: #176fe5; background: #176fe5; color: #fff; }
.modi-guide-actions span { color: #176fe5; font-size: 10px; font-weight: 800; text-align: right; }
@keyframes modi-guide-pulse { 0%, 100% { outline-color: #2f8cff; } 50% { outline-color: #77c7ff; } }
@media (prefers-reduced-motion: reduce) { .modi-guide-target, .modi-context-spinner { animation: none; } }
@media (max-width: 620px) {
  .modi-context-root { right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); }
  .modi-context-panel { position: fixed; inset: 8px; width: auto; height: auto; min-width: 0; min-height: 0; max-height: none; resize: none; border-radius: 18px; }
  .modi-guide-tip { width: calc(100vw - 24px); }
}

