.story-guide-open {
  display: block;
  margin: 14px auto 0;
  min-height: 44px;
  font-size: 13px;
}

.story-guide {
  --story-tint: color-mix(in srgb, var(--accent) 14%, var(--bg));
  --story-panel: color-mix(in srgb, var(--accent) 8%, var(--secondary));
  --story-edge: color-mix(in srgb, var(--accent) 32%, var(--border));
  position: fixed;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  color: var(--text);
  background: radial-gradient(ellipse at 50% 62%, var(--story-tint), var(--bg) 84%);
  overscroll-behavior: contain;
}

.story-guide::backdrop { background: var(--bg); }
.story-guide [hidden] { display: none !important; }
.story-guide button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.story-guide-content {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: min(100%, 480px);
  min-height: 100%;
  margin: auto;
  padding: 8px clamp(18px, 6vw, 32px) calc(14px + var(--safe-bottom));
}

.story-guide-progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.story-guide-progress button {
  display: grid;
  align-items: center;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.story-guide-progress button::after {
  content: '';
  height: 3px;
  border-radius: 4px;
  background: linear-gradient(var(--link), var(--link)) left center / 0% 100% no-repeat, var(--border);
  transition: background-size .24s ease;
}
.story-guide-progress button[data-complete]::after,
.story-guide-progress button[aria-current]::after { background-size: 100% 100%; }
.story-guide-progress button[aria-current]::after { background-image: linear-gradient(var(--text), var(--text)); }
.story-guide-controls { display: flex; justify-content: space-between; margin-top: -5px; }
.story-guide-controls .icon-button { width: 44px; height: 44px; color: var(--muted); }
.story-guide-controls [data-story-back]:disabled,
.story-guide[data-native-back="true"] [data-story-back] { visibility: hidden; }

.story-slide { display: flex; flex: 1; flex-direction: column; touch-action: pan-y; }
.story-scene {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 174px;
}
.story-scene::before {
  content: '';
  z-index: -1;
  position: absolute;
  width: min(62%, 210px);
  aspect-ratio: 1;
  max-height: 88%;
  border: 1px solid var(--story-edge);
  border-radius: 50%;
  box-shadow: 0 0 0 16px color-mix(in srgb, var(--accent) 6%, transparent),
    0 0 0 34px color-mix(in srgb, var(--accent) 4%, transparent);
}
.story-copy { padding-top: 7px; }
.story-copy h2 { margin: 0; font-size: clamp(22px, 6vw, 31px); line-height: 1.13; letter-spacing: -.025em; }
.story-copy h2:focus { outline: none; }
.story-copy p { margin: 8px 0 0; font-size: clamp(14px, 4vw, 16px); line-height: 1.42; }
.story-guide-actions { margin-top: 20px; }
.story-guide-actions .primary-button { min-height: 48px; margin: 0; border-radius: 26px; }
.story-guide-actions .text-action { display: block; min-height: 44px; margin: 0 auto; }

.story-paper, .story-demo {
  border: 1px solid var(--story-edge);
  background: var(--story-panel);
  box-shadow: 0 12px 22px color-mix(in srgb, var(--text) 12%, transparent);
}
.story-paper {
  grid-area: 1 / 1;
  width: 124px;
  padding: 13px;
  border-radius: 16px;
  transform: translate(var(--x, 0), var(--y, 0)) rotate(var(--rotation, 0deg));
  animation: story-paper-in .46s cubic-bezier(.18,.75,.28,1) var(--delay, 0ms) both;
}
.story-paper b, .story-initial, .story-avatars span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
}
.story-paper b .action-icon { width: 17px; height: 17px; }
.story-paper > span, .story-bubble span { display: block; height: 4px; margin-top: 7px; border-radius: 5px; background: var(--story-edge); }
.story-paper > span:last-child, .story-bubble span:last-child { width: 68%; }
.story-scattered .story-paper:nth-child(1) { --x: -59px; --y: -31px; --rotation: -13deg; }
.story-scattered .story-paper:nth-child(2) { --x: 56px; --y: -7px; --rotation: 11deg; --delay: 75ms; }
.story-scattered .story-paper:nth-child(3) { --x: -23px; --y: 43px; --rotation: -4deg; --delay: 145ms; }
.story-stack { display: grid; transform: rotate(-5deg); }
.story-feed .story-paper { width: 161px; }
.story-feed .story-paper:nth-child(1) { --x: 17px; --y: -27px; --rotation: 10deg; }
.story-feed .story-paper:nth-child(2) { --x: 4px; --y: -13px; --rotation: -3deg; --delay: 70ms; }
.story-feed .story-paper:nth-child(3) { --delay: 140ms; }

.story-demo {
  width: min(100%, 260px);
  padding: 11px 13px;
  border-radius: 15px;
  font-size: 13px;
  animation: story-reveal .42s cubic-bezier(.18,.75,.28,1) both;
}
.story-avatars { display: flex; gap: 4px; margin-bottom: 4px; }
.story-avatars span:nth-child(2) { background: var(--link); color: var(--bg); }
.story-avatars span:nth-child(3) { background: var(--bg); color: var(--link); }
.story-bubble {
  width: 69%;
  margin-top: 7px;
  padding: 4px 10px 8px;
  border-radius: 9px;
  background: var(--bg);
  animation: story-reveal .34s .14s both;
}
.story-bubble + .story-bubble { margin-left: auto; background: var(--story-tint); animation-delay: .24s; }
.story-digest-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.story-digest-row b, .story-search-result b { color: var(--link); }
.story-excerpt {
  color: var(--muted);
  margin-top: 5px;
  font-size: 12px;
  transform-origin: top;
  animation: story-expand .35s .19s both;
}
.story-search-demo { display: grid; gap: 8px; width: min(100%, 237px); }
.story-query, .story-search-result { display: flex; align-items: center; gap: 9px; }
.story-search-result { animation-delay: .15s; }
.story-search-result b { margin-left: auto; font-size: 18px; }
.story-magnifier { position: relative; width: 12px; height: 12px; margin: 0 4px; border: 2px solid var(--link); border-radius: 50%; }
.story-magnifier::after { content: ''; position: absolute; width: 6px; height: 2px; background: var(--link); right: -5px; bottom: -3px; transform: rotate(45deg); }
.story-guide .story-copy { animation: story-copy-in .24s ease-out both; --slide-offset: 10px; }
.story-guide[data-direction="back"] .story-copy { --slide-offset: -10px; }

@keyframes story-paper-in {
  from { opacity: 0; transform: translate(calc(var(--x, 0px) * 1.15), calc(var(--y, 0px) + 14px)) rotate(var(--rotation, 0deg)) scale(.94); }
}
@keyframes story-reveal { from { opacity: 0; transform: translateY(13px); } }
@keyframes story-copy-in { from { opacity: 0; transform: translateX(var(--slide-offset)); } }
@keyframes story-expand { from { opacity: 0; transform: scaleY(.35); } }

@media (prefers-reduced-motion: reduce) {
  .story-guide *, .story-guide *::after { animation: none !important; transition: none !important; }
}
