.paya-guide {
  --guide-edge: max(1.25rem, env(safe-area-inset-left), env(safe-area-inset-right));
  --guide-bottom: max(1.25rem, env(safe-area-inset-bottom));
  --guide-launch-size: 64px;
  --guide-accent: #a41733;
  --guide-link: #a41733;
  --guide-focus: #68686f;
}

body[data-theme=dark] .paya-guide {
  --guide-link: #ff91a5;
  --guide-focus: #a8a8af;
}

.paya-guide-launch,
.paya-guide-panel {
  position: fixed;
  inset: auto;
  inset-inline-end: var(--guide-edge);
  z-index: 38;
}

.paya-guide-launch,
.paya-guide-back,
.paya-guide-close,
.paya-guide-send {
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  border-radius: 50%;
}

.paya-guide-launch {
  inset-block-end: var(--guide-bottom);
  inline-size: var(--guide-launch-size);
  block-size: var(--guide-launch-size);
  border: 1px solid #ffffff45;
  background: linear-gradient(155deg, #b41c3c, #96112b);
  color: #fff;
  box-shadow: 0 2px 6px #12121630, 0 9px 24px #12121636;
}

@media (hover: hover) {
  .paya-guide-launch:hover { box-shadow: 0 3px 8px #12121639, 0 12px 27px #12121645; }
}

@media (prefers-reduced-motion: no-preference) {
  .paya-guide-launch { transition: box-shadow .18s ease; }
}

.paya-guide svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.paya-guide-launch svg { width: 30px; height: 30px; }

.paya-guide-panel {
  inset-block-end: calc(var(--guide-bottom) + var(--guide-launch-size) + 12px);
  width: min(23.5rem, calc(100% - 2 * var(--guide-edge)));
  max-width: none;
  block-size: min(34rem, calc(100dvh - var(--guide-bottom) - var(--guide-launch-size) - 24px));
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  background: var(--bg);
  box-shadow: 0 16px 52px #1010142c;
}

.paya-guide-panel[open] { display: flex; flex-direction: column; }
.paya-guide-panel [hidden] { display: none; }

.paya-guide-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 16px 13px;
  border-bottom: 1px solid var(--line);
}

.paya-guide-header h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: -.025em;
}

.paya-guide-heading { flex: 1; min-inline-size: 0; }
.paya-guide-heading h2:focus { outline: none; }

.paya-guide-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: .8125rem;
  line-height: 1.5;
}

.paya-guide-back,
.paya-guide-close {
  width: 44px;
  height: 44px;
  color: var(--ink);
}

.paya-guide :is(.paya-guide-back, .paya-guide-close):hover { background: var(--surface); }
.paya-guide :is(.paya-guide-back, .paya-guide-close, .paya-guide-send) svg { width: 19px; height: 19px; }
[dir=rtl] .paya-guide-back svg { scale: -1 1; }

.paya-guide-home,
.paya-guide-log {
  flex: 1 1 auto;
  min-block-size: 0;
  padding: 16px;
  overflow: auto;
}

.paya-guide-intro {
  margin: 0 0 15px;
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.6;
}

.paya-guide-resume {
  display: block;
  min-block-size: 44px;
  margin-block: 0 12px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--guide-link);
  font-size: .875rem;
  text-align: start;
}

.paya-guide-resume:hover { background: var(--surface); }

.paya-guide-log {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.paya-guide-log:focus-visible {
  outline: 2px solid var(--guide-focus);
  outline-offset: -2px;
}

.paya-guide-message {
  flex: none;
  max-width: 94%;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--surface);
  font-size: .875rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.paya-guide-message p { white-space: pre-line; }
.paya-guide-message.is-question { align-self: flex-end; background: var(--guide-accent); color: #fff; }
.paya-guide-message a { display: inline-block; margin-top: 5px; color: var(--guide-link); text-decoration: underline; text-underline-offset: .15em; }

.paya-guide-pending { color: var(--muted); font-size: .8125rem; }

.paya-guide-suggestions-label {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 600;
}

.paya-guide-suggestions {
  display: grid;
  gap: 6px;
}
.paya-guide-suggestions button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: .8125rem;
  line-height: 1.35;
  text-align: start;
}

.paya-guide-suggestions button::after {
  content: "";
  flex: none;
  inline-size: 6px;
  block-size: 6px;
  margin-inline-end: 2px;
  border-block-start: 1px solid var(--muted);
  border-inline-end: 1px solid var(--muted);
  rotate: 45deg;
}

[dir=rtl] .paya-guide-suggestions button::after { rotate: -45deg; }
.paya-guide-suggestions button:hover { background: var(--surface); border-color: var(--muted); }

.paya-guide-form { flex: none; margin: 0; padding: 10px 15px 0; border-top: 1px solid var(--line); }
.paya-guide-compose { display: flex; align-items: center; gap: 7px; }
.paya-guide-compose input {
  flex: 1;
  min-width: 0;
  width: 100%;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-size: 1rem;
}
.paya-guide-compose input::placeholder { color: var(--muted); text-align: start; }
.paya-guide-send { width: 44px; height: 44px; background: var(--guide-accent); color: #fff; }
.paya-guide-send:disabled { opacity: .65; }
.paya-guide-human {
  flex: none;
  align-self: center;
  display: grid;
  place-items: center;
  min-height: 42px;
  margin-inline: 15px;
  padding-inline: 4px;
  color: var(--guide-link);
  font-size: .8125rem;
}
.paya-guide-human:hover { text-decoration: underline; }
.paya-guide :is(a, button):focus-visible { outline: 2px solid var(--guide-focus); outline-offset: 2px; }

@media (max-height: 550px) {
  .paya-guide-panel { inset-block-end: var(--guide-bottom); block-size: calc(100dvh - 2 * var(--guide-bottom)); }
}

@media print {
  .paya-guide { display: none; }
}

html[lang=fa] .paya-guide-compose input:placeholder-shown {
  direction: rtl;
  text-align: right;
}
