﻿.chat-widget.guide-widget {
  right: calc(clamp(32px, 5.1vw, 92px) + env(safe-area-inset-right, 0px));
  bottom: calc(clamp(48px, 7dvh, 66px) + env(safe-area-inset-bottom, 0px));
}
.guide-widget .chat-toggle { width: 54px; height: 54px; }
@media (max-width: 480px) {
  .chat-widget.guide-widget {
    right: calc(18px + env(safe-area-inset-right, 0px));
    bottom: calc(clamp(68px, 12dvh, 96px) + env(safe-area-inset-bottom, 0px));
  }
  .guide-widget .chat-toggle { width: 50px; height: 50px; }
}
.guide-widget:has(dialog[open]) > :is(.chat-toggle, .chat-greeting),
body:has(#quote-dialog[open]) .guide-widget { visibility: hidden; }
#guide-panel {
  position: fixed; inset: auto max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) auto;
  margin: 0; width: min(340px, calc(100vw - 32px)); height: min(420px, calc(100dvh - 32px));
  padding: 20px; border: 0; border-radius: 12px; background: var(--paper); color: var(--ink);
  box-shadow: 0 16px 48px #20251f50; overflow: auto;
}
#guide-panel[open] { display: flex; flex-direction: column; }
#guide-panel::backdrop { background: transparent; }
#guide-title { font: 24px var(--serif); align-self: center; }
#guide-log { flex: 1; min-height: 56px; overflow: auto; overscroll-behavior: contain; padding-block: 16px; overflow-wrap: anywhere; }
#guide-log > button { margin-block: 8px; }
#guide-prompts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-block: 4px 12px; }
#guide-prompts button, #guide-log > button { font-size: 12px; }
#guide-form input {
  flex: 1; min-width: 0; padding: 10px; background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: 4px; font: 16px var(--sans);
}
#guide-panel .guide-info { margin-top: 6px; color: var(--muted); font-size: 12px; }

#guide-panel .chat-heading { padding-bottom: 15px; border-bottom: 1px solid var(--line); }
#guide-panel .chat-caption { font: 15px var(--serif); color: var(--rust); margin-bottom: 4px; }
#guide-title { font: 20px/1.4 var(--serif); }
#guide-log .chat-welcome { font: 19px/1.5 var(--serif); }
#guide-log .chat-message { border: 0; padding: 0; margin-top: 14px; max-width: 88%; }
#guide-log .chat-message.user { margin-left: auto; }
#guide-log .chat-message.user p { background: var(--olive); color: var(--theme-button-label); border-radius: 14px 14px 4px 14px; padding: 8px 12px; margin: 0; line-height: 1.6; }
#guide-log .chat-message.assistant p { background: var(--theme-secondary); color: var(--theme-ink-readable); border-radius: 14px 14px 14px 4px; padding: 8px 12px; margin: 4px 0 0; line-height: 1.6; }
#guide-log > button { margin-block: 10px; }

#guide-panel { width: min(350px, calc(100vw - 32px)); height: min(480px, calc(100dvh - 32px)); padding: 0; border: 1px solid var(--theme-border); border-radius: 16px; background: var(--theme-popup); overflow: hidden; }
#guide-panel .guide-header { display: flex; align-items: center; gap: 11px; flex: none; padding: 16px; border-bottom: 1px solid var(--theme-divider); }
#guide-panel .guide-avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }
#guide-panel .guide-identity { flex: 1; min-width: 0; }
#guide-panel #guide-title { font: 20px/1.25 var(--serif); }
#guide-panel .guide-identity p { margin: 3px 0 0; color: var(--theme-muted-readable); font-size: 11px; line-height: 1.3; }
#guide-panel #guide-close { width: 36px; height: 36px; flex: none; background: var(--theme-secondary); }
#guide-panel #guide-log { padding: 18px 16px; }
#guide-log .guide-welcome { max-width: 88%; padding: 10px 13px; background: var(--theme-surface); color: var(--theme-ink-readable); border-radius: 15px 15px 15px 4px; font-size: 13px; line-height: 1.65; }
#guide-log .guide-welcome p + p { margin-top: 6px; }
#guide-log .chat-message.user p { background: var(--theme-button); color: var(--theme-button-label); line-height: 1.65; }
#guide-panel #guide-prompts { gap: 8px; margin: 0; padding: 0 16px 12px; }
#guide-panel #guide-prompts button { padding: 6px 10px; border: 1px solid var(--theme-border); border-radius: 18px; color: var(--theme-alternate-readable); background: var(--theme-popup); font-size: 11px; line-height: 1.4; text-align: left; }
#guide-panel #guide-prompts button:hover { background: var(--theme-secondary); }
#guide-panel #guide-form { display: flex; align-items: center; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--theme-divider); }
#guide-panel #guide-form input { flex: 1; min-width: 0; padding: 10px 13px; background: var(--theme-input); color: var(--theme-ink-readable); border: 1px solid transparent; border-radius: 22px; font: 16px var(--sans); }
#guide-panel #guide-form input:focus-visible { outline: 2px solid var(--theme-button); outline-offset: 1px; }
#guide-panel #guide-form button { margin: 0; flex: none; padding: 10px 14px; border-radius: 20px; background: var(--theme-button); color: var(--theme-button-label); }
#guide-panel button:disabled { opacity: .55; }

.guide-widget > .chat-greeting { animation: letter-greeting 8s ease-in-out infinite; }
#guide-panel #guide-prompts { flex-wrap: wrap; overflow: visible; }
#guide-panel #guide-prompts button { flex: 0 1 auto; white-space: normal; }
@media (prefers-reduced-motion: reduce) { .guide-widget > .chat-greeting { animation: none; } }

#guide-panel #guide-prompts[hidden] { display: none; }
