/* Load after the existing site styles. Scoped to this widget. */
.miki-ai-guide {
  --guide-bg: #151927;
  --guide-surface: #1d2233;
  --guide-line: #343c56;
  --guide-text: #f1f1f8;
  --guide-muted: #aab3cc;
  --guide-accent: #9d75f5;
  position: fixed;
  z-index: 1600;
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(92px + env(safe-area-inset-bottom));
  font: 13px/1.45 system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--guide-text);
  pointer-events: none;
}

.miki-ai-guide *, .miki-ai-guide *::before, .miki-ai-guide *::after { box-sizing: border-box; }
.miki-ai-guide [hidden] { display: none !important; }

.miki-ai-guide button,
.miki-ai-guide textarea {
  font: inherit;
}

.miki-ai-guide button { cursor: pointer; }
.miki-ai-guide button:disabled { cursor: wait; opacity: .58; }
.miki-ai-guide :focus-visible { outline: 2px solid #c7afff; outline-offset: 3px; }

.miki-ai-guide__launcher {
  display: block;
  margin-left: auto;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid #7651c4;
  border-radius: 14px;
  background: #31244f;
  color: #f5efff;
  font-weight: 700 !important;
  white-space: nowrap;
  box-shadow: 0 10px 32px rgba(0, 0, 0, .38);
  pointer-events: auto;
}

.miki-ai-guide__launcher:hover { background: #413066; }

.miki-ai-guide__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  display: flex;
  flex-direction: column;
  width: min(322px, calc(100vw - 20px));
  max-height: min(440px, calc(100dvh - 165px));
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--guide-line);
  border-radius: 14px;
  background: var(--guide-bg);
  color: var(--guide-text);
  box-shadow: 0 22px 65px rgba(0, 0, 0, .56);
  pointer-events: auto;
}

.miki-ai-guide__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 6px;
}

.miki-ai-guide__title { margin: 0; font-size: 13px; line-height: 1.2; color: var(--guide-text); }
.miki-ai-guide__header-actions { display: flex; align-items: center; gap: 4px; }
.miki-ai-guide__clear,
.miki-ai-guide__close {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--guide-surface);
  color: var(--guide-muted);
  font-size: 18px !important;
  line-height: 1 !important;
}
.miki-ai-guide__clear:hover:not(:disabled), .miki-ai-guide__close:hover { color: var(--guide-text); background: #30374d; }
.miki-ai-guide__hint { margin: 0; padding: 0 12px 8px; color: var(--guide-muted); font-size: 11px; }
.miki-ai-guide__quick-prompts { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 12px 9px; }
.miki-ai-guide__quick {
  min-height: 27px;
  padding: 4px 8px;
  border: 1px solid #544477;
  border-radius: 8px;
  background: #242036;
  color: #e6dbff;
  font-size: 11px !important;
}
.miki-ai-guide__quick:hover { background: #302747; }
.miki-ai-guide__sections { padding: 7px 12px; border-block: 1px solid var(--guide-line); color: var(--guide-muted); font-size: 11px; }
.miki-ai-guide__sections summary { width: fit-content; cursor: pointer; color: #c9afff; }
.miki-ai-guide__section-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin-top: 8px; }
.miki-ai-guide__section-links a { padding: 5px 7px; border-radius: 6px; background: var(--guide-surface); color: var(--guide-text); text-decoration: none; }
.miki-ai-guide__section-links a:hover { background: #30374d; }
.miki-ai-guide__messages { flex: 1 1 auto; min-height: 0; max-height: 255px; overflow-y: auto; padding: 9px 10px 2px; }
.miki-ai-guide__message { margin: 0 0 7px; padding: 7px 9px; border: 1px solid var(--guide-line); border-radius: 10px; background: var(--guide-surface); font-size: 12px; }
.miki-ai-guide__message--user { margin-left: 28px; background: #29233e; border-color: #514077; }
.miki-ai-guide__sender { display: block; margin-bottom: 2px; font-size: 10px; color: #c9afff; }
.miki-ai-guide__body { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.miki-ai-guide__links { display: flex; flex-wrap: wrap; gap: 5px; margin: 7px 0 0; padding: 0; list-style: none; }
.miki-ai-guide__links a { display: inline-block; padding: 3px 7px; border: 1px solid #544477; border-radius: 7px; color: #d3beff; text-decoration: none; overflow-wrap: anywhere; }
.miki-ai-guide__links a:hover { background: #302747; }
.miki-ai-guide__cards { display: grid; gap: 5px; margin-top: 7px; }
.miki-ai-guide__card { display: grid; gap: 2px; padding: 6px 7px; border: 1px solid #544477; border-radius: 8px; background: #171a2a; }
.miki-ai-guide__card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 5px; }
.miki-ai-guide__card-title { color: #d3beff; font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.miki-ai-guide__card-title:hover { text-decoration: underline; }
.miki-ai-guide__card-image { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 5px; object-fit: contain; background: #101320; }
.miki-ai-guide__card-meta { color: var(--guide-muted); font-size: 10px; overflow-wrap: anywhere; }
.miki-ai-guide__card-price { color: var(--guide-text); font-size: 10px; overflow-wrap: anywhere; }
.miki-ai-guide__card-warning { color: #e6bf82; font-size: 10px; overflow-wrap: anywhere; }
.miki-ai-guide__sources { display: grid; gap: 5px; margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--guide-line); }
.miki-ai-guide__sources-title { color: var(--guide-muted); font-size: 10px; font-weight: 700; }
.miki-ai-guide__source { display: grid; gap: 1px; overflow-wrap: anywhere; }
.miki-ai-guide__source a, .miki-ai-guide__source span { color: #d3beff; text-decoration: none; }
.miki-ai-guide__source a:hover { text-decoration: underline; }
.miki-ai-guide__source small { color: var(--guide-muted); font-size: 10px; }
.miki-ai-guide__status { margin: 0; padding: 4px 11px 0; color: var(--guide-muted); font-size: 10px; }
.miki-ai-guide__status:empty { display: none; }
.miki-ai-guide__form { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px 3px; }
.miki-ai-guide__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.miki-ai-guide__question {
  display: block;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  min-height: 36px;
  max-height: 90px;
  resize: vertical;
  padding: 8px 9px;
  border: 1px solid var(--guide-line);
  border-radius: 9px;
  background: #0e1220;
  color: var(--guide-text);
}
/* The site shell's `.miki-pulse textarea` sets 112px and otherwise wins by
   specificity, even though this single-line composer is capped at 90px. */
.miki-pulse .miki-ai-guide__question { min-height: 36px; }
.miki-ai-guide__question::placeholder { color: #818ba5; }
.miki-ai-guide__controls { display: flex; align-items: flex-end; }
.miki-ai-guide__shortcut { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.miki-ai-guide__send { flex: 0 0 auto; min-height: 36px; padding: 6px 9px; border: 0; border-radius: 8px; background: var(--guide-accent); color: #160f2c; font-size: 11px !important; font-weight: 700 !important; }
.miki-ai-guide__send:hover:not(:disabled) { background: #b18aff; }
.miki-ai-guide__privacy { display: block; padding: 0 11px 8px; color: #8490a8; font-size: 9px; }

.miki-ai-guide__panel--compressed .miki-ai-guide__hint,
.miki-ai-guide__panel--compressed .miki-ai-guide__quick-prompts,
.miki-ai-guide__panel--compressed .miki-ai-guide__sections { display: none; }
.miki-ai-guide__panel--compressed .miki-ai-guide__header { padding-bottom: 3px; }
.miki-ai-guide__panel--compressed .miki-ai-guide__messages { max-height: none; min-height: 40px; }
.miki-ai-guide__panel--compressed .miki-ai-guide__form { padding-top: 4px; padding-bottom: 1px; }
.miki-ai-guide__panel--compressed .miki-ai-guide__privacy { padding-bottom: 4px; font-size: 8px; }

@media (max-width: 760px) {
  .miki-ai-guide { right: max(10px, env(safe-area-inset-right)); bottom: calc(140px + env(safe-area-inset-bottom)); }
  .miki-ai-guide__panel { max-height: calc(100dvh - 210px - env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
  .miki-ai-guide__panel { width: calc(100vw - 20px); }
}

@media (max-width: 380px) and (max-height: 640px) {
  /* Reserve the short viewport for dialogue and the send form. Quick prompts
     remain available before the first message; links stay in each answer. */
  .miki-ai-guide__hint,
  .miki-ai-guide__sections { display: none; }
}

@media (max-height: 420px) {
  /* Keep the launcher left of the bottom-right music button and page counter. */
  .miki-ai-guide {
    right: calc(120px + env(safe-area-inset-right));
    bottom: calc(56px + env(safe-area-inset-bottom));
  }
  .miki-ai-guide__panel {
    right: -108px;
    max-height: calc(100dvh - 110px - env(safe-area-inset-bottom));
    min-height: 0;
  }
  .miki-ai-guide__hint { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .miki-ai-guide__launcher { transition: background-color .15s ease, transform .15s ease; }
  .miki-ai-guide__launcher:hover { transform: translateY(-2px); }
}
