.guide-chat {
  --guide-edge: 20px;
  --guide-right: calc(var(--guide-edge) + env(safe-area-inset-right, 0px));
  --guide-bottom: calc(var(--guide-edge) + env(safe-area-inset-bottom, 0px));
}

.guide-chat button { font: inherit; cursor: pointer; }
.guide-chat button:disabled { cursor: wait; opacity: .55; }
.guide-launch,
.guide-send {
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid transparent;
  font-weight: 700 !important;
}
.guide-launch:hover,
.guide-send:hover { background: var(--accent-hover); }
.guide-launch {
  position: fixed;
  right: var(--guide-right);
  bottom: var(--guide-bottom);
  z-index: 76;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 9px 15px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
}

.guide-chat dialog {
  position: fixed;
  inset: auto var(--guide-right) var(--guide-bottom) auto;
  margin: 0;
  padding: 0;
  width: min(440px, calc(100% - 2 * var(--guide-edge) - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  height: min(620px, calc(100dvh - 2 * var(--guide-edge) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  max-width: none;
  max-height: none;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.guide-chat dialog[open] { display: flex; flex-direction: column; }
.guide-chat dialog::backdrop { background: #09142466; }
.guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.guide-head h2 { margin: 0; font-size: 18px; }
.guide-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.guide-close {
  flex: 0 0 44px;
  min-height: 44px;
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 22px !important;
}
.guide-log { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 16px; overflow: auto; overscroll-behavior: contain; }
.guide-message { flex: none; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.guide-question { align-self: flex-end; max-width: 92%; background: var(--gold-soft); color: var(--gold-ink); }
.guide-message h3 { margin: 0 0 6px; font-size: 15px; }
.guide-message ol { margin: 0; padding-left: 20px; }
.guide-message ul { margin: 0; padding: 0; list-style: none; }
.guide-message li + li { margin-top: 6px; }
.guide-chapter { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }
.guide-chapter h4 { margin: 0 0 6px; font-size: 14px; color: var(--ink); }
.guide-source { margin: 9px 0 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.guide-prompts { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.guide-prompts button {
  min-height: 38px;
  padding: 5px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  font-size: 13px;
  text-align: left;
}
.guide-prompts button:hover { border-color: var(--focus); }
.guide-foot { padding: 12px 16px 9px; border-top: 1px solid var(--line); }
.guide-form { display: flex; gap: 8px; }
.guide-form input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.guide-form input::placeholder { color: var(--muted); }
.guide-send { padding: 6px 13px; border-radius: 8px; }
.guide-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 8px; font-size: 11px; color: var(--muted); margin-top: 3px; }
.guide-reset { background: none; color: var(--muted); border: 0; padding: 5px 0; min-height: 36px; text-decoration: underline; }

@media (max-width: 520px) {
  .guide-chat { --guide-edge: 10px; }
  .guide-chat dialog { height: min(640px, calc(100dvh - 20px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))); }
  .guide-head, .guide-log, .guide-foot { padding-inline: 12px; }
  .guide-prompts button { min-height: 44px; }
}
