:root{
  --aiw-z: 999999;
  --aiw-radius: 16px;
  --aiw-shadow: 0 18px 44px rgba(0,0,0,.42);
  --aiw-border: rgba(255,255,255,.10);
  --aiw-bg: #0E0F11;
  --aiw-text: #F3F4F6;
  --aiw-muted: #9CA3AF;
  --aiw-card: rgba(17,24,39,.82);
  --aiw-input-bg: rgba(31,41,55,.92);
  --aiw-input-border: rgba(75,85,99,.9);
  --aiw-note: #F0E68C;
  --aiw-error: #FCA5A5;

  --aiw-primary: var(--electric-blue, #007AFF);
  --aiw-primary-2: var(--neon-mint, #00F2FE);
}

:root[data-theme="light"]{
  --aiw-shadow: 0 12px 30px rgba(15,23,42,.16);
  --aiw-border: rgba(15,23,42,.12);
  --aiw-bg: #FFFFFF;
  --aiw-text: #111827;
  --aiw-muted: #64748B;
  --aiw-card: rgba(248,250,252,.96);
  --aiw-input-bg: #FFFFFF;
  --aiw-input-border: #CBD5E1;
  --aiw-note: #7C5B00;
  --aiw-error: #B42335;
}

.aiw-hidden{ display:none !important; }

.aiw-panel,
.aiw-panel *,
.aiw-panel *::before,
.aiw-panel *::after,
.aiw-launcher,
.aiw-launcher *{
  box-sizing: border-box;
}

.aiw-launcher{
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: var(--aiw-z);
  width: 62px;
  height: 62px;
  border-radius: 999px;
  border: 1px solid var(--aiw-border);
  background: linear-gradient(135deg, var(--aiw-primary), var(--aiw-primary-2));
  box-shadow: var(--aiw-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: transform .12s ease, opacity .12s ease;
}

.aiw-launcher:hover{ transform: translateY(-1px); }
.aiw-launcher:active{ transform: translateY(0px) scale(.98); }

.aiw-launcher__icon{
  width: 28px;
  height: 28px;
  fill: none;
  stroke: rgba(255,255,255,.95);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.aiw-panel{
  position: fixed;
  right: 18px;
  bottom: 86px;
  z-index: var(--aiw-z);
  width: min(420px, calc(100vw - 36px));
  height: min(620px, calc(100vh - 140px));
  border-radius: var(--aiw-radius);
  border: 1px solid var(--aiw-border);
  background: var(--aiw-bg);
  box-shadow: var(--aiw-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform-origin: bottom right;
  transform: translateY(10px) scale(.98);
  opacity: 0;
  pointer-events: none;
  transition: transform .16s ease, opacity .16s ease;
  color-scheme: dark;
}

:root[data-theme="light"] .aiw-panel{
  color-scheme: light;
}

.aiw-panel.is-open{
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.aiw-resize-handle{
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 8px;
  border-radius: 999px;
  cursor: ns-resize;
  background: color-mix(in srgb, var(--aiw-muted) 22%, transparent);
  opacity: .75;
}

.aiw-resize-handle:hover{
  opacity: 1;
  background: color-mix(in srgb, var(--aiw-muted) 34%, transparent);
}

.aiw-header{
  position: relative;
  z-index: 6;
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 18px 12px 12px;
  border-bottom: 1px solid var(--aiw-border);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0));
}

:root[data-theme="light"] .aiw-header{
  background: linear-gradient(180deg, rgba(0,0,0,.02), rgba(0,0,0,0));
}

.aiw-title{
  display:flex;
  flex-direction: column;
  gap: 2px;
}

.aiw-title__name{
  font-weight: 700;
  font-size: 14px;
  color: var(--aiw-text);
}

.aiw-title__hint{
  font-size: 12px;
  color: var(--aiw-muted);
}

.aiw-actions{
  display:flex;
  gap: 8px;
}

.aiw-btn{
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--aiw-border);
  background: var(--aiw-card);
  color: var(--aiw-text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: opacity .12s ease, transform .12s ease;
}

.aiw-btn:hover{ opacity: .92; }
.aiw-btn:active{ transform: scale(.98); }

.aiw-body{
  flex: 1;
  overflow: auto;
  padding: 14px 12px;
}

.aiw-msg{
  display:flex;
  gap: 10px;
  margin-bottom: 10px;
}

.aiw-bubble{
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--aiw-border);
  background: var(--aiw-card);
  color: var(--aiw-text);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.aiw-msg--user{ justify-content: flex-end; }
.aiw-msg--user .aiw-bubble{
  background: linear-gradient(135deg, rgba(37,115,255,.22), rgba(37,115,255,.10));
  border-color: color-mix(in srgb, var(--aiw-primary) 28%, var(--aiw-border));
}

:root[data-theme="light"] .aiw-msg--user .aiw-bubble{
  background: linear-gradient(135deg, rgba(37,115,255,.16), rgba(37,115,255,.08));
}

.aiw-meta{
  margin-top: 2px;
  font-size: 11px;
  color: var(--aiw-muted);
}

.aiw-footer{
  padding: 10px 12px 12px;
  border-top: 1px solid var(--aiw-border);
  background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.03));
}

:root[data-theme="light"] .aiw-footer{
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.02));
}

.aiw-quick-questions{
  column-count: 2;
  column-gap: 6px;
  margin-bottom: 4px;
}

.aiw-quick-question{
  display: block;
  width: 100%;
  break-inside: avoid;
  margin: 0 0 6px;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--aiw-primary) 34%, var(--aiw-border));
  border-radius: 9px;
  background: color-mix(in srgb, var(--aiw-primary) 8%, var(--aiw-card));
  color: var(--aiw-text);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.28;
  text-align: left;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, transform .12s ease, opacity .12s ease;
}

.aiw-quick-question:hover,
.aiw-quick-question:focus-visible{
  border-color: color-mix(in srgb, var(--aiw-primary) 64%, var(--aiw-border));
  background: color-mix(in srgb, var(--aiw-primary) 16%, var(--aiw-card));
}

.aiw-quick-question:focus-visible{
  outline: 2px solid color-mix(in srgb, var(--aiw-primary) 38%, transparent);
  outline-offset: 1px;
}

.aiw-quick-question:active{
  transform: translateY(1px);
}

.aiw-form{
  display:flex;
  gap: 8px;
  align-items: flex-end;
}

.aiw-input{
  flex: 1;
  min-height: 38px;
  max-height: 120px;
  resize: none;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid var(--aiw-input-border);
  background: var(--aiw-input-bg);
  color: var(--aiw-text);
  outline: none;
  font-size: 13px;
  line-height: 1.45;
}

.aiw-input::placeholder{
  color: var(--aiw-muted);
  opacity: 1;
}

.aiw-input:focus{
  border-color: color-mix(in srgb, var(--aiw-primary) 45%, var(--aiw-input-border));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--aiw-primary) 18%, transparent);
}

.aiw-send{
  width: 44px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--aiw-border);
  background: linear-gradient(135deg, var(--aiw-primary), var(--aiw-primary-2));
  box-shadow: 0 8px 16px rgba(37,115,255,.18);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
}

.aiw-send svg{
  width: 18px;
  height: 18px;
  fill: none;
  stroke: rgba(255,255,255,.95);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.aiw-input:disabled,
.aiw-send:disabled,
.aiw-btn:disabled,
.aiw-quick-question:disabled{
  cursor: wait;
  opacity: .58;
}

.aiw-note{
  margin-top: 8px;
  font-size: 12px;
  color: var(--aiw-note);
}

.aiw-note.is-error{
  color: var(--aiw-error);
}

.aiw-badge{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--aiw-border);
  background: var(--aiw-card);
  color: var(--aiw-muted);
  font-size: 11px;
  margin-bottom: 10px;
}

.aiw-typing{
  display:inline-flex;
  gap: 4px;
  align-items:center;
}

.aiw-typing i{
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--aiw-muted);
  opacity: .55;
  animation: aiwDot 1.0s infinite ease-in-out;
}

.aiw-typing i:nth-child(2){ animation-delay: .12s; }
.aiw-typing i:nth-child(3){ animation-delay: .24s; }

@keyframes aiwDot{
  0%, 80%, 100%{ transform: translateY(0); opacity: .45; }
  40%{ transform: translateY(-3px); opacity: .85; }
}

@media (max-width: 480px){
  .aiw-panel{
    right: 10px;
    left: 10px;
    width: auto;
  }
  .aiw-launcher{
    right: 12px;
    bottom: 12px;
  }
}

.aiw-msg--assistant .aiw-bubble .aiw-typing{
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.aiw-msg--assistant .aiw-bubble{
  display: inline-block;
}

.aiw-msg--assistant .aiw-bubble:has(.aiw-typing){
  padding: 10px 14px;
  min-width: 62px;
}

.aiw-bubble--typing{
  padding: 6px 10px;
  line-height: 0.5;
  min-width: 52px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.aiw-bubble--typing .aiw-typing{
  display: flex;
  justify-content: center;
  align-items: center;
  height: 10px;
}

.aiw-bubble--typing .aiw-typing i{
  width: 5px;
  height: 5px;
}

/* Бейдж “сообщение” вместо зелёной точки */
.aiw-launcher__badge{
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 14px rgba(0,0,0,.18);
}

:root[data-theme="light"] .aiw-launcher__badge{
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.45);
}

/* Иконка внутри бейджа */
.aiw-launcher__badge-icon{
  width: 12px;
  height: 12px;
  fill: none;
  stroke: rgba(255,255,255,.95);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
