.ks-guide {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  display: flex;
  max-width: calc(100vw - 24px);
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  color: #162033;
  font-family: "Plus Jakarta Sans", "Outfit", system-ui, sans-serif;
}

.ks-guide[dir="rtl"] {
  right: 20px;
  left: auto;
  align-items: flex-end;
  font-family: Vazirmatn, "Noto Sans Arabic", Tahoma, sans-serif;
}

.ks-guide-panel {
  width: min(430px, calc(100vw - 24px));
  height: min(650px, calc(100svh - 108px));
  min-height: 470px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 26px;
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 30px 90px rgba(15, 23, 42, .24), 0 0 0 1px rgba(255, 255, 255, .72) inset;
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  transform-origin: bottom right;
  animation: ksGuideIn .24s cubic-bezier(.2, .8, .2, 1);
}

.ks-guide[dir="rtl"] .ks-guide-panel { transform-origin: bottom right; }
.ks-guide-panel[hidden] { display: none !important; }
.dark .ks-guide-panel { border-color: rgba(255, 255, 255, .11); background: rgba(7, 13, 24, .97); color: #e5edf8; box-shadow: 0 32px 100px rgba(0, 0, 0, .56); }

.ks-guide-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid rgba(148, 163, 184, .18);
  background: radial-gradient(circle at 0 0, rgba(16, 185, 129, .12), transparent 48%), linear-gradient(135deg, rgba(248, 250, 252, .96), rgba(240, 253, 250, .72));
}

.dark .ks-guide-head { border-color: rgba(255, 255, 255, .08); background: radial-gradient(circle at 0 0, rgba(16, 185, 129, .18), transparent 48%), #0b1422; }
.ks-guide-brand { width: 43px; height: 43px; display: grid; place-items: center; overflow: hidden; border-radius: 14px; background: linear-gradient(145deg, #064e3b, #10b981); box-shadow: 0 10px 24px rgba(5, 150, 105, .22); }
.ks-guide-brand img { width: 34px; height: 34px; object-fit: contain; }
.ks-guide-identity { min-width: 0; }
.ks-guide-identity h3 { overflow: hidden; margin: 0; color: #0f172a; font-size: 13px; font-weight: 850; text-overflow: ellipsis; white-space: nowrap; }
.dark .ks-guide-identity h3 { color: #f8fafc; }
.ks-guide-identity p { display: flex; align-items: center; gap: 6px; margin: 3px 0 0; color: #64748b; font-size: 9.5px; font-weight: 700; }
.ks-guide-identity p i { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, .11); }

.ks-guide-language select { height: 34px; border: 1px solid #dbe4ef; border-radius: 11px; background: rgba(255, 255, 255, .9); padding: 0 8px; color: #334155; font: 800 10px inherit; outline: none; cursor: pointer; }
.dark .ks-guide-language select { border-color: rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .06); color: #e2e8f0; }
.ks-guide-icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 11px; background: rgba(148, 163, 184, .12); color: #64748b; cursor: pointer; }
.ks-guide-icon-button:hover { background: rgba(16, 185, 129, .1); color: #059669; }
.ks-guide-icon-button svg { width: 17px; height: 17px; }

.ks-guide-messages { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 14px 8px; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: rgba(16, 185, 129, .45) transparent; }
.ks-guide-messages::-webkit-scrollbar { width: 6px; }
.ks-guide-messages::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(16, 185, 129, .38); }
.ks-guide-message { display: flex; margin-bottom: 12px; }
.ks-guide-message.is-user { justify-content: flex-end; }
.ks-guide[dir="rtl"] .ks-guide-message.is-user { justify-content: flex-start; }
.ks-guide-bubble { max-width: 86%; border: 1px solid rgba(148, 163, 184, .18); border-radius: 7px 18px 18px 18px; background: #f4f7fb; padding: 11px 13px; color: #334155; font-size: 11.5px; line-height: 1.85; white-space: pre-wrap; }
.ks-guide[dir="rtl"] .ks-guide-bubble { border-radius: 18px 7px 18px 18px; text-align: right; }
.ks-guide-message.is-user .ks-guide-bubble { border-color: transparent; border-radius: 18px 7px 18px 18px; background: linear-gradient(135deg, #047857, #10b981); color: #fff; box-shadow: 0 10px 24px rgba(5, 150, 105, .18); }
.ks-guide[dir="rtl"] .ks-guide-message.is-user .ks-guide-bubble { border-radius: 7px 18px 18px 18px; }
.dark .ks-guide-bubble { border-color: rgba(255, 255, 255, .08); background: rgba(255, 255, 255, .055); color: #dbe6f3; }
.ks-guide-answer-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 9px; border: 1px solid rgba(16, 185, 129, .24); border-radius: 10px; padding: 6px 9px; color: #047857; font-size: 10px; font-weight: 850; text-decoration: none; }
.dark .ks-guide-answer-link { color: #6ee7b7; }
.ks-guide-answer-link svg { width: 13px; height: 13px; }

.ks-guide-typing { display: inline-flex; align-items: center; gap: 4px; min-width: 48px; }
.ks-guide-typing i { width: 6px; height: 6px; border-radius: 50%; background: #10b981; animation: ksGuideTyping 1s infinite ease-in-out; }
.ks-guide-typing i:nth-child(2) { animation-delay: .13s; }
.ks-guide-typing i:nth-child(3) { animation-delay: .26s; }

.ks-guide-suggestions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  max-height: 252px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 9px 14px 11px;
  scrollbar-color: rgba(16, 185, 129, .45) transparent;
  scrollbar-width: thin;
}
.ks-guide-suggestions::before {
  content: attr(data-label);
  position: sticky;
  top: -9px;
  z-index: 2;
  display: block;
  margin: -9px -2px 1px;
  padding: 9px 2px 7px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .99) 72%, rgba(255, 255, 255, 0));
  color: #64748b;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .08em;
  text-align: start;
  text-transform: uppercase;
}
.dark .ks-guide-suggestions::before { background: linear-gradient(180deg, rgba(7, 13, 24, .99) 72%, rgba(7, 13, 24, 0)); color: #94a3b8; }
.ks-guide-suggestions::-webkit-scrollbar { width: 6px; }
.ks-guide-suggestions::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(16, 185, 129, .38); }
.ks-guide-suggestions button {
  position: relative;
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(16, 185, 129, .19);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(16, 185, 129, .075), rgba(20, 184, 166, .035));
  padding: 8px 34px 8px 11px;
  color: #047857;
  font: 800 9.5px/1.55 inherit;
  text-align: left;
  white-space: normal;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  animation: ksGuideSuggestionIn .34s var(--ks-suggestion-delay, 0ms) cubic-bezier(.2, .8, .2, 1) forwards;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease, transform .2s ease;
}
.ks-guide-suggestions button::after {
  content: "→";
  position: absolute;
  top: 50%;
  right: 12px;
  font-size: 14px;
  line-height: 1;
  transform: translateY(-50%);
  transition: transform .2s ease;
}
.ks-guide-suggestions button:hover {
  border-color: rgba(16, 185, 129, .42);
  background: linear-gradient(135deg, rgba(16, 185, 129, .14), rgba(20, 184, 166, .07));
  box-shadow: 0 8px 22px rgba(5, 150, 105, .09);
  transform: translateY(-1px);
}
.ks-guide-suggestions button:hover::after { transform: translate(3px, -50%); }
.ks-guide[dir="rtl"] .ks-guide-suggestions button {
  padding: 8px 11px 8px 34px;
  text-align: right;
}
.ks-guide[dir="rtl"] .ks-guide-suggestions button::after {
  content: "←";
  right: auto;
  left: 12px;
}
.ks-guide[dir="rtl"] .ks-guide-suggestions button:hover::after { transform: translate(-3px, -50%); }
.dark .ks-guide-suggestions button { color: #6ee7b7; }
.ks-guide.has-conversation .ks-guide-suggestions { max-height: 158px; }

.ks-guide-compose { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; margin: 0 14px; border: 1px solid #d9e3ee; border-radius: 17px; background: #fff; padding: 7px; box-shadow: 0 8px 26px rgba(15, 23, 42, .05); }
.ks-guide-compose:focus-within { border-color: #10b981; box-shadow: 0 0 0 4px rgba(16, 185, 129, .09); }
.dark .ks-guide-compose { border-color: rgba(255, 255, 255, .1); background: #09111f; }
.ks-guide-compose textarea { width: 100%; max-height: 110px; min-height: 38px; resize: none; border: 0; background: transparent; padding: 8px 7px; color: #172033; font: 500 11.5px/1.7 inherit; outline: none; }
.dark .ks-guide-compose textarea { color: #f8fafc; }
.ks-guide-compose textarea::placeholder { color: #94a3b8; }
.ks-guide-compose button { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 13px; background: linear-gradient(145deg, #047857, #10b981); color: #fff; cursor: pointer; box-shadow: 0 8px 20px rgba(5, 150, 105, .22); }
.ks-guide-compose button:disabled { cursor: wait; opacity: .55; }
.ks-guide-compose button svg { width: 17px; height: 17px; }
.ks-guide-note { margin: 8px 14px 12px; color: #94a3b8; font-size: 8.5px; line-height: 1.5; text-align: center; }

.ks-guide-launcher { position: relative; display: inline-flex; min-height: 55px; align-items: center; justify-content: center; gap: 9px; overflow: visible; border: 1px solid rgba(255, 255, 255, .24); border-radius: 18px; background: linear-gradient(135deg, #065f46, #10b981); padding: 0 18px; color: #fff; box-shadow: 0 18px 48px rgba(5, 100, 75, .34); cursor: pointer; font: 850 11.5px inherit; }
.ks-guide-launcher:hover { transform: translateY(-2px); box-shadow: 0 22px 56px rgba(5, 100, 75, .4); }
.ks-guide-launcher > svg { width: 21px; height: 21px; }
.ks-guide-launcher-orbit { position: absolute; inset: -5px; border: 1px solid rgba(52, 211, 153, .45); border-radius: 22px; animation: ksGuidePulse 2.2s infinite; pointer-events: none; }

@keyframes ksGuideIn { from { opacity: 0; transform: translateY(12px) scale(.975); } to { opacity: 1; transform: none; } }
@keyframes ksGuideSuggestionIn { to { opacity: 1; transform: translateY(0); } }
@keyframes ksGuideTyping { 0%, 65%, 100% { transform: translateY(0); opacity: .34; } 32% { transform: translateY(-4px); opacity: 1; } }
@keyframes ksGuidePulse { 0%, 100% { opacity: .7; transform: scale(1); } 55% { opacity: 0; transform: scale(1.12); } }

@media (max-width: 600px) {
  .ks-guide, .ks-guide[dir="rtl"] { right: 12px; bottom: 12px; left: auto; align-items: flex-end; }
  .ks-guide-panel {
    width: calc(100vw - 24px);
    height: min(680px, calc(100dvh - 86px));
    min-height: 0;
    border-radius: 23px;
    grid-template-rows: auto minmax(138px, 1fr) auto auto auto;
  }
  .ks-guide-messages {
    min-height: 138px;
    padding: 12px 11px 7px;
    border-bottom: 1px solid rgba(148, 163, 184, .14);
    box-shadow: 0 10px 24px -24px rgba(15, 23, 42, .7) inset;
  }
  .dark .ks-guide-messages { border-color: rgba(255, 255, 255, .07); }
  .ks-guide-suggestions { max-height: min(202px, 31dvh); padding: 7px 11px 9px; }
  .ks-guide-suggestions::before { top: -7px; margin: -7px -1px 1px; padding: 8px 1px 6px; }
  .ks-guide.has-conversation .ks-guide-suggestions { max-height: min(126px, 19dvh); }
  .ks-guide:has(.ks-guide-compose:focus-within) .ks-guide-suggestions {
    max-height: 0;
    padding-block: 0;
    border: 0;
    overflow: hidden;
  }
  .ks-guide-bubble { max-width: 92%; font-size: 11px; line-height: 1.78; }
  .ks-guide-compose { margin-inline: 11px; }
  .ks-guide-note { margin: 6px 11px 8px; }
  .ks-guide-head { grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 7px; padding: 11px; }
  .ks-guide-brand { width: 38px; height: 38px; }
  .ks-guide-language select { width: 56px; padding: 0 5px; }
  .ks-guide-launcher { width: 55px; padding: 0; border-radius: 18px; }
  .ks-guide-launcher span:last-child { display: none; }
}

@media (max-width: 600px) and (max-height: 560px) {
  .ks-guide-panel {
    height: calc(100dvh - 76px);
    grid-template-rows: auto minmax(96px, 1fr) auto auto auto;
  }
  .ks-guide-messages { min-height: 96px; }
  .ks-guide-suggestions { max-height: 128px; }
  .ks-guide.has-conversation .ks-guide-suggestions { max-height: 88px; }
  .ks-guide-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ks-guide-panel, .ks-guide-launcher, .ks-guide-launcher-orbit, .ks-guide-typing i, .ks-guide-suggestions button { animation: none !important; transition: none !important; opacity: 1; transform: none; }
}
