:root {
  --guide-edge: max(22px, env(safe-area-inset-right));
  --guide-bottom: max(20px, env(safe-area-inset-bottom));
  --guide-launcher-bottom: calc(var(--guide-bottom) + 68px);
  --guide-dialog-bottom: calc(var(--guide-bottom) + 133px);
}

.guide-launcher {
  position: fixed;
  inset-inline-end: var(--guide-edge);
  bottom: var(--guide-launcher-bottom);
  z-index: 81;
  display: flex;
  align-items: center;
  border: 1px solid #9c643d;
  border-radius: 28px;
  background: #1e2224;
  color: #fff;
  box-shadow: 0 4px 13px #14151432;
}

.guide-trigger,
.guide-cycle {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: 750 .875rem/1.2 var(--industrial-font, sans-serif);
}

.guide-trigger { gap: 7px; padding: 5px 8px 5px 5px; border-radius: 27px 0 0 27px; }
.guide-cycle { width: 45px; padding: 0; border-inline-start: 1px solid #ffffff42; border-radius: 0 27px 27px 0; color: #ffbd81; }
.guide-cycle svg { flex: none; }
.guide-portrait {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border: 1px solid #df9f65;
  border-radius: 50%;
  background: #493423;
}
.guide-portrait img { display: block; width: 100%; height: 100%; object-fit: cover; }
.guide-launcher[data-assistant="0"] .guide-portrait img {
  position: absolute;
  top: -180.2%;
  left: -62.8%;
  width: 219.1%;
  max-width: none;
  height: auto;
}

body:has(.guide-launcher:not([hidden])) { padding-bottom: calc(var(--guide-dialog-bottom) - 3px); }

.guide-dialog {
  position: fixed;
  z-index: 82;
  inset: auto var(--guide-edge) var(--guide-dialog-bottom) auto;
  display: grid;
  grid-template-columns: clamp(46px, 18vw, 82px) minmax(0, 1fr);
  align-items: end;
  gap: 6px;
  width: min(395px, calc(100% - var(--guide-edge) - 12px));
  pointer-events: none;
}

.guide-launcher[hidden], .guide-dialog[hidden], .guide-entry[hidden] { display: none; }
.guide-character { width: 100%; height: auto; max-height: 172px; object-fit: contain; object-position: bottom; filter: drop-shadow(0 3px 5px #221b193b); }
.guide-character:not([src]) { visibility: hidden; }
/* Match the standing figure's scale without moving the speech bubble. */
.guide-character[data-easter-egg="dance"][src*="/guide-tatiana-dance"] {
  transform-origin: right bottom;
  transform: translateX(4px) scaleX(1.27);
}
.guide-bubble {
  box-sizing: border-box;
  max-height: min(340px, calc(100vh - var(--guide-dialog-bottom) - 10px));
  max-height: min(340px, calc(100dvh - var(--guide-dialog-bottom) - 10px));
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 9px;
  border: 1px solid #d5b9a2;
  border-radius: 15px;
  background: #fff9f1;
  color: #26211d;
  box-shadow: 0 6px 25px #33241b32;
  font: 580 .875rem/1.43 var(--industrial-font, sans-serif);
  pointer-events: auto;
}

.guide-line { display: flex; gap: 4px; align-items: start; }
#guide-text { flex: 1; min-width: 0; margin: 2px 0 7px; overflow-wrap: anywhere; }
.guide-close {
  flex: none;
  width: 44px;
  min-height: 44px;
  margin: -5px -5px 0 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #5e4c3d;
  font: 600 1.45rem/1 sans-serif;
  cursor: pointer;
}
.guide-entry, .guide-actions, .guide-video-intro { margin-top: 5px; }
.guide-video-intro { margin-top: 0; }
.guide-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
.guide-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.guide-entry input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 6px;
  border: 1px solid #c49b7c;
  border-radius: 7px;
  background: #fff;
  color: #241d18;
  font: 600 1rem/1.2 var(--industrial-font, sans-serif);
}
.guide-entry input[aria-invalid="true"] { border-color: #a2281b; box-shadow: inset 0 0 0 1px #a2281b; }
.guide-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.guide-actions:empty { display: none; }
.guide-video-link, .guide-submit, .guide-actions > * {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid #bd9a7d;
  border-radius: 8px;
  background: #fffdf8;
  color: #362617;
  font: 750 .815rem/1.21 var(--industrial-font, sans-serif);
  text-decoration: none;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.guide-video-link { gap: 7px; }
.guide-video-link::before { content: ""; width: 0; border: 6px solid transparent; border-right: 0; border-left: 9px solid currentColor; }
.guide-actions .guide-callback, .guide-submit { background: #ffae65; border-color: #be722f; color: #2b1b10; }
.guide-launcher button:focus-visible, .guide-bubble :is(a, button, input):focus-visible { outline: 2px solid #986029; outline-offset: -3px; }

@media (hover: hover) {
  .guide-launcher button:hover, .guide-bubble :is(a, button):hover { background: #ffe063; color: #2e2016; }
}
.guide-launcher button:active, .guide-bubble :is(a, button):active { background: #fa9a46; color: #2e2016; }

@media (max-width: 760px) {
  :root {
    --guide-edge: max(12px, env(safe-area-inset-right));
    --guide-bottom: max(12px, env(safe-area-inset-bottom));
    --guide-launcher-bottom: calc(var(--guide-bottom) + 62px);
    --guide-dialog-bottom: calc(var(--guide-bottom) + 124px);
  }
  .guide-dialog { width: min(350px, calc(100% - var(--guide-edge) - 12px)); }
}

@media (prefers-reduced-motion: no-preference) {
  .guide-dialog:not([hidden]) { animation: guide-arrival 180ms ease-out both; }
  @keyframes guide-arrival { from { transform: translateY(5px); opacity: 0; } }

  .guide-character[data-easter-egg] { transform-origin: 50% 96%; }
  .guide-character[data-easter-egg="fist"] { animation: guide-fist 1.25s ease-in-out; }
  .guide-character[data-easter-egg="bow"] { animation: guide-bow 1.25s ease-in-out; }

  @keyframes guide-fist {
    16%, 53% { transform: translateY(-3px) rotate(-6deg); }
    32%, 72% { transform: translateY(-1px) rotate(3deg); }
  }
  @keyframes guide-bow {
    35%, 61% { transform: translateY(2px) rotate(8deg) scaleY(.94); }
  }
}

@media print { .guide-launcher, .guide-dialog { display: none !important; } }
