.guide-launcher {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 5px 4px 9px;
  border: 1px solid var(--ink);
  border-radius: 30px;
  background: var(--ink);
  color: var(--paper-bright);
  box-shadow: 0 8px 26px rgb(17 18 16 / 12%);
  font-size: 12px;
  letter-spacing: .04em;
  cursor: pointer;
  transition: opacity 160ms ease, transform 160ms ease;
}
.guide-launcher[aria-expanded="true"] { opacity: 0; pointer-events: none; transform: translateY(8px); }
.guide-pet {
  position: relative;
  display: block;
  overflow: hidden;
}
.guide-pet--launcher {
  flex: 0 0 22px;
  width: 22px;
  height: 28px;
  filter: invert(1);
}
.guide-pet--header {
  flex: 0 0 20px;
  width: 20px;
  height: 25px;
}
.guide-pet--avatar {
  flex: 0 0 24px;
  width: 24px;
  height: 30px;
  margin-top: 1px;
}
.guide-pet-fallback,
.guide-pet > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.guide-pet-fallback { transition: opacity 160ms ease; }
.guide-pet.is-lottie-ready .guide-pet-fallback { opacity: 0; }
.guide-launcher-arrow {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgb(255 255 255 / 34%);
  border-radius: 50%;
  font-size: 16px;
}
.guide-launcher:hover .guide-launcher-arrow { background: var(--paper); color: var(--ink); }

.guide-dialog {
  position: fixed;
  z-index: 31;
  inset: auto 20px 20px auto;
  width: min(clamp(320px, 29vw, 370px), calc(100% - 32px));
  height: auto;
  max-width: none;
  max-height: calc(100dvh - 40px);
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-bright);
  color: var(--ink);
  box-shadow: 0 18px 64px rgb(17 18 16 / 17%);
}
.guide-dialog.is-active {
  width: min(clamp(360px, 34vw, 480px), calc(100% - 32px));
  height: clamp(460px, 72dvh, 680px);
  max-height: calc(100dvh - 40px);
}
.guide-dialog::backdrop { background: transparent; }
.guide-shell { display: flex; flex-direction: column; min-height: 0; }
.guide-dialog.is-active .guide-shell { height: 100%; }

.guide-header {
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  align-items: center;
  min-height: 50px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.guide-identity { display: flex; align-items: center; gap: 9px; min-width: 0; }
.guide-header h2 { margin: 0; font-size: 12px; font-weight: 650; letter-spacing: .08em; }
.guide-actions { display: flex; align-items: center; gap: 6px; }
.guide-actions button { border: 0; background: transparent; color: inherit; cursor: pointer; }
.guide-reset { display: none; min-height: 36px; padding: 6px 8px; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.guide-dialog.is-active .guide-reset { display: block; }
.guide-close { width: 36px; min-height: 36px; font-size: 23px; line-height: 1; }

.guide-scroll { position: relative; min-height: 0; padding: 16px 16px 10px; }
.guide-dialog.is-active .guide-scroll { flex: 1; overflow: auto; overscroll-behavior: contain; padding: 18px 18px 16px; scrollbar-width: thin; }
.guide-welcome[hidden] { display: none; }
.guide-intro { margin: 0; font-size: 16px; line-height: 1.5; }
.guide-log:empty { display: none; }
.guide-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.guide-suggestion {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: transparent;
  color: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.guide-suggestion:hover { background: var(--paper); }

.guide-footer { flex: 0 0 auto; padding: 8px 12px 12px; background: var(--paper-bright); }
.guide-dialog.is-active .guide-footer { border-top: 1px solid var(--line-soft); }
.guide-context { display: none; margin: 0 0 7px 4px; color: #62635d; font-size: 12px; }
.guide-dialog.is-active .guide-context { display: block; }
.guide-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
}
.guide-input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  resize: none;
  padding: 7px 0 5px;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
}
.guide-input::placeholder { color: #686962; }
.guide-input:focus { outline-offset: 3px; }
.guide-send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--paper-bright);
  background: var(--ink);
  font-size: 20px;
  cursor: pointer;
}
.guide-send:disabled { opacity: .26; cursor: default; }

.guide-turn { margin-bottom: 24px; overflow-wrap: anywhere; }
.guide-answer-row { display: flex; align-items: flex-start; gap: 10px; }
.guide-response { flex: 1; min-width: 0; }
.guide-speaker { display: block; margin-bottom: 8px; color: #62635d; font-size: 12px; letter-spacing: .08em; }
.guide-user { display: flex; justify-content: flex-end; margin-bottom: 20px; }
.guide-user p {
  max-width: 84%;
  margin: 0;
  padding: 9px 11px;
  border-radius: 10px 10px 2px 10px;
  background: var(--paper);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.guide-answer { margin: 0 0 12px; font-size: 15px; line-height: 1.65; }
.guide-results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.guide-result-link { min-width: 0; }
.guide-result-link img { width: 100%; aspect-ratio: 1.25; object-fit: cover; border-radius: 5px; }
.guide-result-link strong { display: block; margin-top: 7px; font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guide-result-arrow { display: none; }
.guide-source { display: inline-block; margin-top: 2px; color: #555650; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }

.guide-dialog :focus-visible, .guide-launcher:focus-visible { outline: 2px solid #616a52; outline-offset: 3px; }
#full-archive { scroll-margin-top: 96px; }

@media (max-width: 600px) {
  .guide-launcher { right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); }
  .guide-dialog { inset: auto 14px max(14px, env(safe-area-inset-bottom)) auto; width: min(340px, calc(100% - 28px)); max-height: calc(100dvh - 28px); }
  .guide-dialog.is-active { inset: auto 8px max(8px, env(safe-area-inset-bottom)) 8px; width: calc(100% - 16px); height: clamp(360px, 76dvh, 540px); max-height: calc(100dvh - 16px); }
  .guide-close, .guide-send { min-width: 44px; min-height: 44px; }
  .guide-send { height: 44px; }
  .guide-suggestion { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .guide-launcher { transition: none; }
  .guide-pet-fallback { transition: none; }
}
