  #barsiWidgetRoot *, #barsiWidgetRoot *::before, #barsiWidgetRoot *::after { box-sizing: border-box; margin: 0; padding: 0; }

  /* ── Lock страницы хоста, когда виджет открыт ──────────────────────────────
     Виджет занимает весь viewport на мобилке, поэтому хост-страница под ним
     должна быть полностью заморожена: нельзя скроллить, ничего не должно
     двигаться или "выскакивать" когда юзер тянет палец по чату.
     JS (toggleWidget → lockPageScroll/unlockPageScroll) ставит
     position:fixed + top:-scrollY на body, плюс эти классы для надёжности. */
  html.barsi-scroll-locked,
  body.barsi-scroll-locked {
    overflow: hidden !important;
    overscroll-behavior: none !important;
    touch-action: none;
  }
  /* Внутренние скролл-зоны виджета: не проскроллить хост-страницу через
     "оверскролл" когда упёрлись в край чата. */
  #barsiWidgetRoot .chat-messages,
  #barsiWidgetRoot .sections,
  #barsiWidgetRoot .history-items {
    overscroll-behavior: contain;
  }

  /* FAB trigger button */
  #barsiWidgetRoot .fab {
    position: relative;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #21467d 0%, #3a7bd5 100%);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(33,70,125,0.5);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 1;
  }
  #barsiWidgetRoot .fab:hover { transform: scale(1.08); box-shadow: 0 6px 32px rgba(13,86,196,0.7); }


  /* ── FAB wrapper ── */
  #barsiWidgetRoot .fab-wrapper {
    position: fixed;
    bottom: 24px;
    right: 20px;
    z-index: 9998;
  }

  /* ── AI Smart Bubble ── */
  #barsiWidgetRoot .smart-bubble {
    position: absolute;
    bottom: calc(100% + 14px);
    right: 0;
    width: 244px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.94);
    transform-origin: bottom right;
    transition: opacity 0.35s ease, transform 0.4s cubic-bezier(0.34,1.4,0.64,1);
    filter: drop-shadow(0 8px 28px rgba(15,26,46,0.32));
  }
  #barsiWidgetRoot .smart-bubble.visible {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
  }
  #barsiWidgetRoot .smart-bubble.hiding {
    opacity: 0;
    transform: translateY(8px) scale(0.94);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
  }

  /* Dark AI card */
  #barsiWidgetRoot .sb-inner {
    background: linear-gradient(145deg, #0f1f3d 0%, #162a4a 60%, #1a2f52 100%);
    border-radius: 16px 16px 16px 16px;
    border: 1px solid rgba(58,123,213,0.28);
    padding: 14px 36px 13px 15px;
    overflow: hidden;
    position: relative;
  }

  /* Thought bubble — 3 dots bottom-right toward Barsi icon */
  #barsiWidgetRoot .smart-bubble::before {
    content: '';
    position: absolute;
    bottom: -12px;
    right: 18px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #162a4a;
    border: 1px solid rgba(58,123,213,0.35);
    box-shadow:
      10px 9px 0 -2px #162a4a,
      10px 9px 0 -1px rgba(58,123,213,0.28),
      18px 17px 0 -3.5px #162a4a,
      18px 17px 0 -2.5px rgba(58,123,213,0.22);
    z-index: 1;
  }

  /* Animated border glow */
  #barsiWidgetRoot .sb-inner::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(58,123,213,0.6) 0%, rgba(99,179,237,0.2) 50%, rgba(58,123,213,0.5) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: borderRotate 4s linear infinite;
  }
  @keyframes borderRotate {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
  }

  /* Subtle scan-line texture */
  #barsiWidgetRoot .sb-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(58,123,213,0.025) 3px,
      rgba(58,123,213,0.025) 4px
    );
    pointer-events: none;
    border-radius: inherit;
  }

  /* Top status bar */
  #barsiWidgetRoot .sb-status {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 8px;
  }
  #barsiWidgetRoot .sb-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74,222,128,0.7);
    animation: sbDotPulse 2s ease-in-out infinite;
    flex-shrink: 0;
  }
  @keyframes sbDotPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(74,222,128,0.7); }
    50%       { opacity: 0.65; box-shadow: 0 0 2px rgba(74,222,128,0.3); }
  }
  #barsiWidgetRoot .sb-label {
    font-family: 'Roboto', sans-serif;
    font-size: 8.5px;
    font-weight: 600;
    color: rgba(99,179,237,0.75);
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  /* Message text with typing cursor */
  #barsiWidgetRoot .sb-text {
    font-family: 'Roboto', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.92);
    line-height: 1.45;
    position: relative;
    z-index: 1;
    min-height: 19px;
  }
  #barsiWidgetRoot .sb-cursor {
    display: inline-block;
    width: 2px;
    height: 13px;
    background: rgba(99,179,237,0.85);
    vertical-align: text-bottom;
    margin-left: 1px;
    border-radius: 1px;
    animation: sbCursor 0.8s step-end infinite;
  }
  @keyframes sbCursor { 50% { opacity: 0; } }

  /* CTA row */
  #barsiWidgetRoot .sb-cta {
    margin-top: 9px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
  }
  #barsiWidgetRoot .sb-cta-text {
    font-size: 10.5px;
    font-weight: 600;
    color: rgba(99,179,237,0.7);
    letter-spacing: 0.02em;
  }
  #barsiWidgetRoot .sb-arrow {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(58,123,213,0.3);
    border: 1px solid rgba(58,123,213,0.45);
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, transform 0.15s;
  }
  #barsiWidgetRoot .smart-bubble:hover .sb-arrow {
    background: rgba(58,123,213,0.55);
    transform: translateX(2px);
  }
  #barsiWidgetRoot .sb-arrow svg { width: 10px; height: 10px; color: rgba(99,179,237,0.9); }

  /* AI glow shimmer sweeping across */
  #barsiWidgetRoot .sb-shimmer {
    position: absolute;
    top: 0; left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99,179,237,0.06), transparent);
    animation: sbShimmer 3.5s ease-in-out infinite;
    pointer-events: none;
  }
  @keyframes sbShimmer {
    0%   { left: -60%; }
    100% { left: 120%; }
  }

  /* Close button */
  #barsiWidgetRoot .smart-bubble-close {
    position: absolute;
    top: 8px; right: 8px;
    width: 20px; height: 20px;
    border: none; background: rgba(255,255,255,0.06);
    cursor: pointer;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.3);
    padding: 0;
    transition: background 0.15s, color 0.15s;
    z-index: 2;
  }
  #barsiWidgetRoot .smart-bubble-close:hover { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.7); }
  #barsiWidgetRoot .smart-bubble-close svg { width: 9px; height: 9px; }

  /* Notification dot on FAB */
  #barsiWidgetRoot .fab-notif {
    position: absolute;
    top: -2px; right: -2px;
    width: 12px; height: 12px;
    background: radial-gradient(circle, #60a5fa 0%, #3a7bd5 100%);
    border-radius: 50%;
    border: 2px solid #0f1a2e;
    box-shadow: 0 0 8px rgba(58,123,213,0.8);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.3s, transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
  }
  #barsiWidgetRoot .fab-notif.show { opacity: 1; transform: scale(1); }

  /* Hide when widget open */
  #barsiWidgetRoot .fab-wrapper.widget-open .smart-bubble { opacity: 0 !important; pointer-events: none !important; transition: opacity 0.2s ease !important; }
  #barsiWidgetRoot .fab-wrapper.widget-open .fab-notif { opacity: 0 !important; }



  
  /* Overlay */
  #barsiWidgetRoot .overlay {
    position: fixed; inset: 0;
    background: rgba(5,12,28,0.55);
    backdrop-filter: blur(3px);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s ease;
  }
  #barsiWidgetRoot .overlay.open { opacity: 1; pointer-events: all; }

  /* Widget panel */
  #barsiWidgetRoot .widget {
    position: fixed;
    bottom: 20px; right: 20px;
    width: 420px;
    max-width: calc(100vw - 40px);
    height: calc(100vh - 40px);
    max-height: calc(100vh - 40px);
    background: #ffffff;
    border-radius: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(120%);
    transition: transform 0.55s cubic-bezier(0.22,1,0.36,1);
    box-shadow: 0 8px 60px rgba(5,12,28,0.25);
  }
  #barsiWidgetRoot .widget.open { transform: translateY(0); }

  /* Header */
  /* Chat mode header switching */
  #barsiWidgetRoot .widget.chat-mode .header-left { display: none; }
  #barsiWidgetRoot .back-btn { display: none; }
  #barsiWidgetRoot .widget.chat-mode .back-btn {
    display: flex; align-items: center; gap: 8px;
    background: none; border: none; cursor: pointer;
    font-family: 'Roboto', sans-serif;
    font-size: 14px; font-weight: 600; color: #21467d;
    padding: 0;
  }
  #barsiWidgetRoot .back-btn svg { width: 20px; height: 20px; }
  #barsiWidgetRoot .back-btn:hover { opacity: 0.7; }

  #barsiWidgetRoot .header {
    padding: 20px 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
  }
  #barsiWidgetRoot .header-left { display: flex; align-items: center; gap: 18px; }
  #barsiWidgetRoot .avatar {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, #21467d, #3a7bd5);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Roboto', sans-serif;
    color: white; font-size: 13px; font-weight: 700;
    letter-spacing: -0.5px;
    overflow: hidden;
    flex-shrink: 0;
  }
  #barsiWidgetRoot .avatar img { width: 100%; height: 100%; object-fit: cover; }
  #barsiWidgetRoot .header-title { font-family: 'Roboto', sans-serif; font-size: 15px; font-weight: 700; color: #0f1a2e; }
  #barsiWidgetRoot .header-sub { font-size: 12px; color: #7a8aa0; margin-top: 1px; }

#barsiWidgetRoot .online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.7);
  margin-right: 4px;
  animation: sbDotPulse 2s ease-in-out infinite;
}

  /* Mobile-only topbar */
  #barsiWidgetRoot .mobile-topbar { display: none; }
  @media (max-width: 600px) {
    #barsiWidgetRoot .mobile-topbar {
      display: flex;
      justify-content: flex-end;
      padding: 10px 0 0;
    }
  }
  #barsiWidgetRoot .header-actions { display: flex; gap: 6px; align-items: center; }
  #barsiWidgetRoot .icon-btn {
    width: 36px; height: 36px;
    background: #f2f4f8;
    border: none; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: #4a5568; transition: background 0.15s;
  }
  #barsiWidgetRoot .icon-btn:hover { background: #e2e8f0; }
  #barsiWidgetRoot .icon-btn svg { width: 18px; height: 18px; }

  /* Hero greeting area */
  #barsiWidgetRoot .hero {
    padding: 36px 20px 20px;
    text-align: center;
    flex-shrink: 0;
    border-bottom: none;
  }
  #barsiWidgetRoot .hero-title { font-family: 'Roboto', sans-serif; font-size: 18px; font-weight: 700; color: #0f1a2e; margin-bottom: 4px; }
  #barsiWidgetRoot .hero-sub-text { font-size: 13.5px; color: #7a8aa0; }
  #barsiWidgetRoot .hero-more {
    display: inline-block; margin-top: 12px;
    font-size: 12px; font-weight: 600; color: #21467d;
    background: #e8eef8; border-radius: 20px;
    padding: 5px 14px; text-decoration: none;
    transition: background 0.15s, color 0.15s;
  }
  #barsiWidgetRoot .hero-more:hover { background: #21467d; color: white; }

  /* Sections */
  #barsiWidgetRoot .sections {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px 0;
    scrollbar-width: none;
    display: flex;
    flex-direction: column;
    gap: 24px;
  }
  #barsiWidgetRoot .sections::-webkit-scrollbar { display: none; }

  #barsiWidgetRoot .section-label {
    font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
    text-transform: uppercase; color: #a0aec0; margin-bottom: 10px; margin-top: 18px;
  }
  #barsiWidgetRoot .section-label:first-child { margin-top: 0; }

  /* History chips */
  #barsiWidgetRoot .chips { display: flex; flex-wrap: wrap; gap: 8px; }
  #barsiWidgetRoot .chip {
    background: #f2f4f8;
    border: none;
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 13px; color: #2d3748;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
  }
  #barsiWidgetRoot .chip:hover { background: #e2e8f0; transform: translateY(-1px); }

  /* Quick action cards.
     grid-auto-flow: dense — чтобы последний highlight-блок (full-width)
     не оставлял пустой ячейки в сетке, когда обычных кнопок нечётное число. */
  #barsiWidgetRoot .cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-flow: dense;
    gap: 8px;
  }
  #barsiWidgetRoot .card {
    background: #f7f9fc;
    border: 1.5px solid #e8ecf4;
    border-radius: 14px;
    padding: 10px 10px;
    cursor: pointer;
    display: flex; flex-direction: column; gap: 6px;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
    text-align: left; text-decoration: none;
  }
  #barsiWidgetRoot .card:hover { border-color: #21467d; background: #eaf0f8; transform: translateY(-2px); }
  #barsiWidgetRoot .card-highlight {
    background: linear-gradient(135deg, #21467d, #3a7bd5) !important;
    border-color: transparent !important;
  }
  #barsiWidgetRoot .card-highlight:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(33,70,125,0.4); }
  #barsiWidgetRoot .card-icon-solid { background: #21467d !important; }
  #barsiWidgetRoot .card-icon {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, #21467d, #3a7bd5);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  #barsiWidgetRoot .card-icon svg { width: 15px; height: 15px; fill: white; }
  #barsiWidgetRoot .card-icon-highlight { background: rgba(255,255,255,0.2) !important; }
  #barsiWidgetRoot .card-label { font-size: 11.5px; font-weight: 600; color: #0f1a2e; line-height: 1.3; }
  #barsiWidgetRoot .card-label-highlight { color: white !important; }
  #barsiWidgetRoot .card-beta {
    font-size: 10px; color: #21467d; font-weight: 600;
    background: #dce7f5; border-radius: 4px; padding: 1px 5px; width: fit-content;
  }

  /* Input area */
  #barsiWidgetRoot .input-area { padding: 10px 16px 18px; flex-shrink: 0; }
  #barsiWidgetRoot .input-box {
    border: 1.5px solid #d6dff0; border-radius: 14px;
    overflow: hidden; transition: border-color 0.2s, box-shadow 0.2s; background: #fff;
  }
  #barsiWidgetRoot .input-box:focus-within { border-color: #21467d; box-shadow: 0 0 0 3px rgba(33,70,125,0.1); }
  #barsiWidgetRoot .input-field {
    width: 100%; padding: 12px 16px 4px;
    border: none; outline: none; resize: none;
    font-family: 'Roboto', sans-serif;
    /* 16px обязателен: при меньшем размере iOS Safari авто-зумит страницу
       при фокусе на textarea (поле визуально раздувается). 16px — магический
       минимум, ниже которого срабатывает auto-zoom. */
    font-size: 16px; color: #0f1a2e;
    background: transparent; min-height: 48px; max-height: 100px; line-height: 1.5;
  }
  #barsiWidgetRoot .input-field::placeholder { color: #a0aec0; }
  #barsiWidgetRoot .input-footer { display: flex; align-items: center; justify-content: space-between; padding: 4px 10px 10px; }
  #barsiWidgetRoot .input-icons { display: flex; gap: 4px; }
  #barsiWidgetRoot .ii {
    width: 34px; height: 34px; border-radius: 50%;
    border: 1.5px solid #d6dff0; background: transparent;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: #21467d; transition: background 0.15s;
  }
  #barsiWidgetRoot .ii:hover { background: #e8eef8; }
  #barsiWidgetRoot .ii svg { width: 16px; height: 16px; }
  #barsiWidgetRoot .send-btn {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, #21467d, #3a7bd5);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 10px rgba(33,70,125,0.4);
    transition: transform 0.15s, box-shadow 0.15s; flex-shrink: 0;
  }
  #barsiWidgetRoot .send-btn:hover { transform: scale(1.06); box-shadow: 0 4px 16px rgba(33,70,125,0.55); }
  #barsiWidgetRoot .send-btn svg { width: 17px; height: 17px; fill: white; margin-left: 2px; }

  /* Chat messages view */
  #barsiWidgetRoot .chat-view {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
  }
  #barsiWidgetRoot .chat-messages {
    flex: 1; overflow-y: auto;
    padding: 16px 20px;
    display: flex; flex-direction: column; gap: 14px;
    scrollbar-width: none;
  }
  #barsiWidgetRoot .chat-messages::-webkit-scrollbar { display: none; }
  #barsiWidgetRoot .msg { display: flex; flex-direction: column; max-width: 85%; animation: msgIn 0.25s ease; }
  @keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  #barsiWidgetRoot .msg.user { align-self: flex-end; align-items: flex-end; }
  #barsiWidgetRoot .msg.bot { align-self: flex-start; align-items: flex-start; }
  #barsiWidgetRoot .bubble {
    padding: 11px 16px; border-radius: 18px;
    font-size: 14px; line-height: 1.5;
  }
  #barsiWidgetRoot .msg.user .bubble { background: linear-gradient(135deg, #21467d, #3a7bd5); color: white; border-radius: 18px 18px 4px 18px; }
  #barsiWidgetRoot .msg.bot .bubble { background: #f2f4f8; color: #0f1a2e; border-radius: 18px 18px 18px 4px; }
  #barsiWidgetRoot .bubble a { color: #2563eb !important; text-decoration: underline !important; word-break: break-all; }
  #barsiWidgetRoot .typing { display: flex; align-items: center; gap: 4px; padding: 14px 16px; background: #f2f4f8; border-radius: 18px 18px 18px 4px; }

  /* Product cards inside bot replies (ported from comparisson) */
  #barsiWidgetRoot .msg.bot .bot-products {
    display: flex; flex-direction: column; gap: 8px;
    margin-top: 10px; width: 100%; max-width: 100%;
  }
  #barsiWidgetRoot .bot-product {
    display: flex; gap: 10px; align-items: center;
    padding: 10px; border-radius: 14px;
    background: #ffffff; border: 1px solid #e2e8f0;
    text-decoration: none !important; color: inherit;
    transition: border-color 0.15s, transform 0.12s;
  }
  #barsiWidgetRoot .bot-product:hover { border-color: #3a7bd5; transform: translateY(-1px); }
  #barsiWidgetRoot .bot-product-img {
    width: 56px; height: 56px; flex: 0 0 56px;
    border-radius: 10px; object-fit: cover;
    background: #f2f4f8;
  }
  #barsiWidgetRoot .bot-product-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  #barsiWidgetRoot .bot-product-name {
    font-size: 13px; font-weight: 600; line-height: 1.35;
    color: #0f1a2e;
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
  }
  #barsiWidgetRoot .bot-product-meta {
    font-size: 12px; color: #64748b; line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 1; line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
  }
  #barsiWidgetRoot .bot-product-price {
    font-size: 14px; font-weight: 700; color: #1d4ed8;
    margin-top: 2px;
  }
  #barsiWidgetRoot .dot { width: 7px; height: 7px; border-radius: 50%; background: #a0aec0; animation: bounce 1.2s infinite; }
  #barsiWidgetRoot .dot:nth-child(2) { animation-delay: 0.2s; }
  #barsiWidgetRoot .dot:nth-child(3) { animation-delay: 0.4s; }
  @keyframes bounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }

  #barsiWidgetRoot .notice { font-size: 11px; color: #a0aec0; text-align: center; padding: 8px 0 4px; }

  /* View toggle states */
  #barsiWidgetRoot .home-view { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
  #barsiWidgetRoot .widget.chat-mode .home-view { display: none; }
  #barsiWidgetRoot .widget.chat-mode .chat-view { display: flex; }

  /* History modal */
  #barsiWidgetRoot .history-view {
    position: absolute; inset: 0;
    background: white;
    border-radius: 24px;
    z-index: 10;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    display: flex; flex-direction: column;
    padding: 20px;
  }
  #barsiWidgetRoot .history-view.open { transform: translateX(0); }
  #barsiWidgetRoot .history-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
  #barsiWidgetRoot .history-title { font-family: 'Roboto', sans-serif; font-size: 16px; font-weight: 700; color: #0f1a2e; }
  #barsiWidgetRoot .history-items { flex: 1; overflow-y: auto; scrollbar-width: none; }
  #barsiWidgetRoot .history-date { font-size: 11px; color: #a0aec0; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 10px; }
  #barsiWidgetRoot .history-item {
    padding: 12px 4px; border-bottom: 1px solid #f0f2f7;
    font-size: 14px; color: #0f1a2e; cursor: pointer;
    transition: color 0.15s;
    display: flex; align-items: center; gap: 10px;
    border-radius: 8px;
  }
  #barsiWidgetRoot .history-item:hover { color: #21467d; }
  #barsiWidgetRoot .history-item-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #barsiWidgetRoot .history-item-del {
    flex-shrink: 0;
    width: 22px; height: 22px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #a0aec0;
    display: none;
    align-items: center; justify-content: center;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    padding: 0;
  }
  #barsiWidgetRoot .history-item-del svg { width: 13px; height: 13px; }
  #barsiWidgetRoot .history-item-del:hover { color: #4a5568; background: #f0f2f7; }
  #barsiWidgetRoot .history-edit-mode .history-item-del { display: flex; }
  #barsiWidgetRoot .history-edit-mode .history-item { cursor: default; color: #0f1a2e; }
  #barsiWidgetRoot .history-edit-mode .history-item:hover { color: #0f1a2e; }
  #barsiWidgetRoot .icon-btn.edit-active { background: #e8eef8; color: #21467d; }
  #barsiWidgetRoot .history-delete-all {
    display: none;
    margin-top: 16px;
    width: 100%;
    padding: 10px;
    background: #fee2e2;
    color: #ef4444;
    border: none;
    border-radius: 10px;
    font-family: 'Roboto', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
  }
  #barsiWidgetRoot .history-delete-all:hover { background: #fca5a5; }

  /* ── MOBILE STYLES ── */
  @media (max-width: 600px) {

    /* Hide overlay on mobile — not needed */
    #barsiWidgetRoot .overlay { display: none !important; }

    /* FAB остаётся видимой и на мобилке: иначе на host-страницах (без нашего
       bottom nav) у пользователя вообще нет кнопки открыть виджет.
       bottom: 90px — чтобы не наезжать на host-nav (tepsey.com, play.tepsey.com
       имеют свой bottom-navbar ~72px высотой + небольшой зазор). */
    #barsiWidgetRoot .fab-wrapper {
      bottom: calc(90px + env(safe-area-inset-bottom, 0px));
      right: 16px;
    }

    /* Widget на мобилке — fullscreen-overlay.
       Просто position: fixed + inset: 0 + 100dvh (dynamic viewport height).
       meta viewport=interactive-widget=resizes-content (iOS 16.4+) заставляет
       Safari уменьшать layout viewport при открытии клавиатуры, и 100dvh
       автоматически становится размером "без клавиатуры" — input остаётся
       над клавиатурой сам собой, без JS-костылей с --barsi-vh. */
    #barsiWidgetRoot .widget {
      position: fixed;
      top: 0; right: 0; bottom: 0; left: 0;
      width: 100vw;
      max-width: 100vw;
      height: 100vh;
      height: 100dvh;
      max-height: 100vh;
      max-height: 100dvh;
      border-radius: 0;
      transform: scale(0.97);
      opacity: 0;
      transition: transform 0.4s cubic-bezier(0.22,1,0.36,1), opacity 0.3s ease;
      box-shadow: none;
      z-index: 10050;
      pointer-events: none;
    }
    #barsiWidgetRoot .widget.open {
      transform: scale(1);
      opacity: 1;
      pointer-events: all;
    }

    /* No drag handle */
    #barsiWidgetRoot .widget::before { display: none; }

    /* Header visible on mobile */
    #barsiWidgetRoot .header { display: flex; }

    /* Hero */
    #barsiWidgetRoot .hero { padding: 12px 20px 10px; }
    #barsiWidgetRoot .hero-title { font-size: 17px; line-height: 1.25; margin-bottom: 3px; }
    #barsiWidgetRoot .hero-sub-text { font-size: 12px; }
    #barsiWidgetRoot .hero-more { display: none; }

    /* Sections */
    #barsiWidgetRoot .sections { padding: 0 16px 0; gap: 14px; }

    /* Cards: 2 columns */
    #barsiWidgetRoot .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    #barsiWidgetRoot .card { padding: 12px 10px; border-radius: 14px; }
    #barsiWidgetRoot .card-icon { width: 28px; height: 28px; border-radius: 8px; }
    #barsiWidgetRoot .card-icon svg { width: 14px; height: 14px; }
    #barsiWidgetRoot .card-label { font-size: 12px; }

    /* Chips: wrap to multiple lines on mobile */
    #barsiWidgetRoot .chips {
      flex-wrap: wrap;
      overflow-x: visible;
      margin: 0;
      padding-left: 0;
      padding-right: 0;
      gap: 8px;
    }
    #barsiWidgetRoot .chip { font-size: 13px; padding: 8px 14px; flex-shrink: unset; }

    /* Input: отступ снизу = только safe-area (для iPhone с home indicator).
       Раньше было 75px — это был запас под host-нижнюю-навигацию, которой на
       сторонних сайтах нет, и она визуально обрезала нижнюю часть чата. */
    #barsiWidgetRoot .input-area {
      padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    }
    #barsiWidgetRoot .input-box { border-radius: 14px; }
    /* font-size: 16px — необходимый минимум, чтобы iOS Safari НЕ зумил страницу
       при фокусе на input/textarea. При меньшем значении срабатывает
       автозум (страница подскакивает в масштабе). */
    #barsiWidgetRoot .input-field { font-size: 16px; min-height: 28px; padding: 7px 12px 4px; }
    #barsiWidgetRoot .input-footer { padding: 4px 8px 10px; }
    #barsiWidgetRoot .ii { width: 20px; height: 20px; }
    #barsiWidgetRoot .ii svg { width: 10px; height: 10px; }
    #barsiWidgetRoot .send-btn { width: 36px; height: 36px; }
    #barsiWidgetRoot .send-btn svg { width: 15px; height: 15px; }

    /* Chat */
    #barsiWidgetRoot .chat-messages { padding: 14px 16px; gap: 12px; }
    #barsiWidgetRoot .msg { max-width: 88%; }
    #barsiWidgetRoot .bubble { font-size: 14.5px; padding: 11px 15px; }
    #barsiWidgetRoot .notice { font-size: 11.5px; padding: 6px 16px 2px; }
    #barsiWidgetRoot .back-btn { font-size: 14px; }
    #barsiWidgetRoot .back-btn svg { width: 22px; height: 22px; }

    /* Header на мобилке:
       - sticky top:0 → не уезжает при scroll чата
       - белый фон + тонкий разделитель → не смешивается с bubble первого
         сообщения пользователя (раньше казалось что "сообщение прячется за
         экран" — на самом деле оно скроллилось под невидимый header)
       - padding-top учитывает notch iOS / status bar Android. */
    #barsiWidgetRoot .header {
      position: sticky;
      top: 0;
      z-index: 3;
      background: #ffffff;
      padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 10px;
      border-bottom: 1px solid #e8ecf4;
      min-height: calc(56px + env(safe-area-inset-top, 0px));
      display: flex !important;
      align-items: center;
    }
    /* В chat-mode порядок: [Назад]  [история]  [X] */
    #barsiWidgetRoot .widget.chat-mode .header {
      display: flex !important;
      padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 10px;
    }
    #barsiWidgetRoot .widget.chat-mode .header .icon-btn { width: 34px; height: 34px; }
    #barsiWidgetRoot .widget.chat-mode .header .icon-btn svg { width: 16px; height: 16px; }
    /* Кнопка "Назад" — крупнее и заметнее на мобилке */
    #barsiWidgetRoot .widget.chat-mode .back-btn {
      display: flex !important;
      font-size: 15px;
      padding: 8px 12px 8px 8px;
      margin-left: -8px;
      color: #21467d;
      background: transparent;
    }
    #barsiWidgetRoot .widget.chat-mode .back-btn svg {
      width: 22px; height: 22px; flex-shrink: 0;
    }

    /* History */
    #barsiWidgetRoot .history-view { padding: 16px; border-radius: 0; }
    #barsiWidgetRoot .history-title { font-size: 16px; }
    #barsiWidgetRoot .history-item { font-size: 15px; padding: 14px 4px; }
    #barsiWidgetRoot .history-item-del { width: 26px; height: 26px; }
  }

  /* Small phones (≤390px) */
  @media (max-width: 390px) {
    #barsiWidgetRoot .hero-title { font-size: 18px; }
    #barsiWidgetRoot .cards { gap: 8px; }
    #barsiWidgetRoot .card { padding: 12px 10px; }
    #barsiWidgetRoot .card-label { font-size: 12px; }
    #barsiWidgetRoot .chip { font-size: 13px; padding: 8px 13px; }
  }

  /* Tablet (601–900px) */
  @media (min-width: 601px) and (max-width: 900px) {
    #barsiWidgetRoot .widget { width: 400px; height: calc(100vh - 60px); max-height: 680px; }
    #barsiWidgetRoot .hero-title { font-size: 17px; }
  }

  /* ── Mobile bottom nav — Liquid Glass ── */
  #barsiWidgetRoot .mobile-nav {
    display: none;
  }
  @media (max-width: 600px) {
    #barsiWidgetRoot .mobile-nav {
      display: flex;
      position: fixed;
      bottom: 12px; left: 12px; right: 12px;
      height: 56px;
      /* Liquid glass effect */
      background: rgba(255, 255, 255, 0.55);
      backdrop-filter: blur(24px) saturate(180%);
      -webkit-backdrop-filter: blur(24px) saturate(180%);
      border: 1px solid rgba(255, 255, 255, 0.7);
      border-radius: 20px;
      box-shadow:
        0 8px 32px rgba(15, 26, 46, 0.12),
        0 2px 8px rgba(15, 26, 46, 0.06),
        inset 0 1px 0 rgba(255,255,255,0.8);
      z-index: 10001;
      align-items: center;
      justify-content: space-around;
      padding: 0 4px;
      overflow: visible;
    }
    #barsiWidgetRoot .mobile-nav-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 3px;
      flex: 1;
      padding: 6px 2px;
      background: none;
      border: none;
      cursor: pointer;
      color: #8a9ab5;
      transition: color 0.2s, transform 0.15s;
      font-family: 'Roboto', sans-serif;
      font-size: 9px;
      font-weight: 500;
      -webkit-tap-highlight-color: transparent;
      border-radius: 16px;
    }
    #barsiWidgetRoot .mobile-nav-item svg { width: 18px; height: 18px; }
    #barsiWidgetRoot .mobile-nav-item.active { color: #21467d; }
    #barsiWidgetRoot .mobile-nav-item:active { transform: scale(0.92); }

    /* ── Liquid Eyes sliding pill indicator ── */
    #barsiWidgetRoot .nav-liquid-pill {
      position: absolute;
      height: 54px;
      border-radius: 18px;
      background: rgba(33, 70, 125, 0.08);
      border: 1px solid rgba(33, 70, 125, 0.1);
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
      transition:
        left 0.45s cubic-bezier(0.34, 1.4, 0.64, 1),
        width 0.45s cubic-bezier(0.34, 1.4, 0.64, 1),
        opacity 0.25s ease;
      pointer-events: none;
      z-index: 0;
      opacity: 0;
      top: 50%;
      transform: translateY(-50%);
    }
    #barsiWidgetRoot .nav-liquid-pill.visible { opacity: 1; }
    #barsiWidgetRoot .nav-liquid-pill::after {
      content: '';
      position: absolute;
      top: 2px; left: 10px; right: 10px; height: 35%;
      background: linear-gradient(180deg, rgba(255,255,255,0.45) 0%, transparent 100%);
      border-radius: 10px 10px 0 0;
    }

    /* Barsi AI — Apple Liquid Glass style, integrated in nav */
    #barsiWidgetRoot .mobile-nav-item.barsi-btn {
      position: relative;
      top: 0;
    }
    #barsiWidgetRoot .nav-barsi-icon {
      width: 28px; height: 28px;
      border-radius: 9px;
      background: linear-gradient(145deg, #2a5299, #3a7bd5);
      display: flex; align-items: center; justify-content: center;
      box-shadow:
        0 2px 8px rgba(33,70,125,0.35),
        inset 0 1px 0 rgba(255,255,255,0.3);
      transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s;
      border: 1px solid rgba(255,255,255,0.4);
    }
    #barsiWidgetRoot .mobile-nav-item.barsi-btn.active .nav-barsi-icon {
      background: linear-gradient(145deg, #1a3a7a, #2a5faa);
      box-shadow: 0 2px 12px rgba(33,70,125,0.5), inset 0 1px 0 rgba(255,255,255,0.25);
    }
    #barsiWidgetRoot .mobile-nav-item.barsi-btn:active .nav-barsi-icon {
      transform: scale(0.88);
    }
    #barsiWidgetRoot .mobile-nav-barsi-label {
      color: #8a9ab5;
      font-weight: 500;
      font-size: 10px;
    }
    #barsiWidgetRoot .mobile-nav-item.barsi-btn.active .mobile-nav-barsi-label {
      color: #21467d;
      font-weight: 600;
    }
    /* Liquid highlight shimmer on nav */
    #barsiWidgetRoot .mobile-nav::before {
      content: '';
      position: absolute;
      top: 0; left: 10%; right: 10%;
      height: 1px;
      background: linear-gradient(90deg, transparent, rgba(255,255,255,0.9), transparent);
      border-radius: 50%;
    }
  }

