/* 50dogs: Shalaby, the Portal guide. Uses the Portal tokens (tokens.css), so light and dark themes follow by themselves.
 * Layers: Team Chat panel is z 60, side drawers 75, modals 90 — Shalaby stays below them (58 / 59). */
.shalaby-root { --shb-gold: var(--gold, #c59b27); --shb-teal: #1f5452; }
.shb-fab {
  position: fixed; inset-inline-end: max(18px, env(safe-area-inset-right, 0px)); bottom: max(18px, env(safe-area-inset-bottom, 0px)); z-index: 58;
  width: 64px; height: 64px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--shb-gold); background: var(--surface, #fffdf8); box-shadow: 0 10px 26px rgba(0,0,0,.22);
  transition: transform .18s ease, box-shadow .18s ease;
}
.shb-fab img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.shb-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 30px rgba(0,0,0,.26); }
.shb-fab:focus-visible { outline: 3px solid var(--shb-gold); outline-offset: 3px; }
.shb-fab.is-open { transform: scale(.9); }
.shb-fab.is-new::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--shb-gold); animation: shb-ping 1.8s ease-out infinite; }
@keyframes shb-ping { 0% { opacity: .9; transform: scale(.92); } 100% { opacity: 0; transform: scale(1.25); } }

.shb-panel {
  position: fixed; inset-inline-end: max(18px, env(safe-area-inset-right, 0px)); bottom: calc(max(18px, env(safe-area-inset-bottom, 0px)) + 76px); z-index: 59;
  width: min(390px, calc(100vw - 24px)); height: min(660px, calc(100vh - 120px)); max-height: calc(100dvh - 120px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface, #fffdf8); color: var(--text, #171512);
  border: 1px solid var(--border, rgba(186,130,19,.35)); border-radius: 18px; box-shadow: 0 18px 48px rgba(0,0,0,.28);
}
.shb-panel[hidden] { display: none; }
.shb-head { display: flex; align-items: center; gap: 2px; padding: 10px 10px 10px 14px; background: var(--sidebar-bg, #0e1111); color: #fff; }
[dir="rtl"] .shb-head { padding: 10px 14px 10px 10px; }
.shb-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.shb-title strong { font-family: 'Oswald', system-ui, sans-serif; font-size: 18px; letter-spacing: .02em; color: var(--shb-gold); }
.shb-title span { font-size: 12px; color: var(--sidebar-text, #d1d5db); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shb-ib { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: var(--sidebar-text, #d1d5db); font-size: 18px; cursor: pointer; }
.shb-ib:hover, .shb-ib[aria-expanded="true"] { background: rgba(255,255,255,.1); color: #fff; }
.shb-ib:focus-visible { outline: 2px solid var(--shb-gold); outline-offset: 1px; }

.shb-stage { position: relative; flex: 0 0 210px; background: radial-gradient(circle at 50% 70%, rgba(197,155,39,.22), transparent 62%), var(--bg, #fbf8f2); border-bottom: 1px solid var(--border, rgba(186,130,19,.35)); overflow: hidden; }
.shb-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; opacity: 0; transition: opacity .3s ease; }
.shb-canvas:active { cursor: grabbing; }
.shb-photo { position: absolute; inset-inline-start: 50%; bottom: 0; height: 92%; width: auto; max-width: none; transform: translateX(-50%); opacity: .95; transition: opacity .3s ease; }
[dir="rtl"] .shb-photo { transform: translateX(50%); }
.shb-stage.is-3d .shb-canvas { opacity: 1; }
.shb-stage.is-3d .shb-photo { opacity: 0; }
.shb-status { position: absolute; inset-inline: 0; top: 8px; margin: 0; text-align: center; font-size: 12px; color: var(--text-soft, #6b655c); }
.shb-stage.is-3d .shb-status:empty { display: none; }
.shb-waves { position: absolute; inset-inline-end: 22%; top: 22%; width: 34px; height: 38px; opacity: 0; pointer-events: none; }
[dir="rtl"] .shb-waves { transform: scaleX(-1); }
.shb-waves span { position: absolute; inset: 0; border: 3px solid transparent; border-inline-end-color: var(--shb-gold); border-radius: 50%; }
.shb-waves span:nth-child(2) { inset: -9px; } .shb-waves span:nth-child(3) { inset: -18px; }
.shb-panel.is-talking .shb-waves { opacity: 1; }
.shb-panel.is-talking .shb-waves span { animation: shb-wave 1s ease-out infinite; }
.shb-panel.is-talking .shb-waves span:nth-child(2) { animation-delay: .15s; } .shb-panel.is-talking .shb-waves span:nth-child(3) { animation-delay: .3s; }
@keyframes shb-wave { 0% { opacity: 0; transform: scale(.6); } 40% { opacity: .9; } 100% { opacity: 0; transform: scale(1.1); } }

.shb-drawer { padding: 12px 14px; border-bottom: 1px solid var(--border, rgba(186,130,19,.35)); background: var(--surface-2, #fff); display: flex; flex-direction: column; gap: 10px; }
.shb-drawer[hidden] { display: none; }
.shb-moves { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.shb-move { min-width: 0; padding: 7px 4px; border: 1px solid var(--border, rgba(186,130,19,.35)); border-radius: 10px; background: var(--surface, #fffdf8); color: var(--text, #171512); font: inherit; font-size: 12px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shb-move:hover { border-color: var(--shb-gold); }
.shb-move.is-on { background: var(--shb-gold); color: var(--on-gold, #111); border-color: var(--shb-gold); }
.shb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.shb-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 12px; }
.shb-field-top { display: flex; justify-content: space-between; gap: 8px; color: var(--text-muted, #665f55); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: 11px; }
.shb-field output { color: var(--gold-ink, #8a5d06); font-variant-numeric: tabular-nums; }
.shb-field input[type="range"] { width: 100%; accent-color: var(--shb-gold); }
.shb-field select { width: 100%; padding: 7px 8px; border: 1px solid var(--border, rgba(186,130,19,.35)); border-radius: 8px; background: var(--surface, #fffdf8); color: var(--text, #171512); font: inherit; font-size: 13px; }
.shb-actions { display: flex; gap: 8px; }
.shb-btn { padding: 7px 14px; border: 0; border-radius: 999px; background: var(--gold-btn, #c59b27); color: var(--on-gold, #111); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.shb-btn.is-ghost { background: transparent; border: 1px solid var(--border, rgba(186,130,19,.35)); color: var(--text, #171512); }
.shb-hint { margin: 0; font-size: 11.5px; color: var(--text-soft, #6b655c); }

.shb-log { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 6px; display: flex; flex-direction: column; gap: 8px; }
.shb-msg { max-width: 88%; padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.shb-msg.is-bot { align-self: flex-start; background: var(--bg, #fbf8f2); border: 1px solid var(--border, rgba(186,130,19,.35)); border-end-start-radius: 4px; }
.shb-msg.is-me { align-self: flex-end; background: var(--sidebar-bg, #0e1111); color: #fff; border-end-end-radius: 4px; }
.shb-note { margin: 0; padding: 0 14px 4px; font-size: 11.5px; color: var(--text-soft, #6b655c); }
.shb-note[hidden] { display: none; }
.shb-chips { display: flex; gap: 6px; padding: 6px 12px; overflow-x: auto; scrollbar-width: thin; }
.shb-chip { flex: 0 0 auto; padding: 5px 11px; border: 1px solid var(--border, rgba(186,130,19,.35)); border-radius: 999px; background: transparent; color: var(--text, #171512); font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.shb-chip:hover { border-color: var(--shb-gold); color: var(--gold-ink, #8a5d06); }
.shb-form { display: flex; gap: 8px; padding: 8px 12px 12px; border-top: 1px solid var(--divider, #eee); }
.shb-form input { flex: 1; min-width: 0; padding: 9px 14px; border: 1px solid var(--border, rgba(186,130,19,.35)); border-radius: 999px; background: var(--surface-2, #fff); color: var(--text, #171512); font: inherit; font-size: 14px; }
.shb-form input:focus-visible, .shb-chip:focus-visible, .shb-move:focus-visible, .shb-btn:focus-visible { outline: 2px solid var(--shb-gold); outline-offset: 2px; }
.shb-send { flex: 0 0 40px; height: 40px; border: 0; border-radius: 50%; background: var(--gold-btn, #c59b27); color: var(--on-gold, #111); font-size: 18px; cursor: pointer; }
.shb-flip { display: inline-block; transform: scaleX(-1); }

/* a drawer (reactions / voice) is open: smaller stage so the chat and the question box stay visible */
.shb-panel.has-drawer .shb-stage { flex-basis: 150px; }
.shb-panel.has-drawer .shb-chips { display: none; }
@media (max-width: 599px) {
  .shb-fab { width: 54px; height: 54px; inset-inline-end: 14px; bottom: max(14px, env(safe-area-inset-bottom, 0px)); }
  .shb-panel { inset-inline: 8px; width: auto; bottom: calc(max(14px, env(safe-area-inset-bottom, 0px)) + 64px); height: calc(100dvh - 96px); max-height: none; border-radius: 16px; }
  .shb-stage { flex-basis: 170px; }
  .shb-panel.has-drawer .shb-stage { flex-basis: 120px; }
  .shb-moves { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .shb-fab, .shb-canvas, .shb-photo { transition: none; }
  .shb-fab.is-new::after, .shb-panel.is-talking .shb-waves span { animation: none; }
}

/* ---------- v.49: the full Shalaby standing on the page ("buddy") ---------- */
.shb-buddy {
  position: fixed; inset-inline-end: max(10px, env(safe-area-inset-right, 0px)); bottom: max(6px, env(safe-area-inset-bottom, 0px)); z-index: 57;
  width: 170px; height: 220px; pointer-events: none;            /* only Shalaby and his buttons take clicks */
}
.shb-buddy[hidden] { display: none; }
.shb-buddy.is-away { visibility: hidden; }
.shb-bhost { position: absolute; inset: 0; pointer-events: none; }
.shb-bhost .shb-canvas { pointer-events: auto; cursor: pointer; opacity: 0; }
.shb-buddy.is-3d .shb-bhost .shb-canvas { opacity: 1; }
.shb-bphoto { position: absolute; inset-inline-start: 50%; bottom: 0; height: 100%; width: auto; max-width: none; transform: translateX(-50%); pointer-events: auto; cursor: pointer; filter: drop-shadow(0 6px 10px rgba(0,0,0,.18)); }
[dir="rtl"] .shb-bphoto { transform: translateX(50%); }
.shb-bphoto[hidden] { display: none; }
.shb-bx {
  position: absolute; pointer-events: auto; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--border, rgba(186,130,19,.35)); background: var(--surface, #fffdf8); color: var(--text, #171512); font-size: 17px;
  box-shadow: 0 4px 12px rgba(0,0,0,.14); opacity: 0; transform: scale(.85); transition: opacity .18s ease, transform .18s ease;
}
.shb-bx.is-talk { inset-inline-start: 0; bottom: 64px; background: var(--gold-btn, #c59b27); color: var(--on-gold, #111); border-color: transparent; }
.shb-bx.is-hide { inset-inline-end: 4px; top: 16px; width: 28px; height: 28px; font-size: 14px; }
.shb-buddy:hover .shb-bx, .shb-buddy:focus-within .shb-bx, .shalaby-root.is-chat .shb-bx { opacity: 1; transform: none; }
@media (hover: none) { .shb-bx { opacity: 1; transform: none; } }
.shb-bx:focus-visible { outline: 2px solid var(--shb-gold); outline-offset: 2px; }
.shb-say {
  position: absolute; inset-inline-end: 34px; bottom: calc(100% - 18px); margin: 0; width: max-content; max-width: 230px;
  padding: 9px 13px; border-radius: 14px; border-end-end-radius: 4px; pointer-events: auto;
  background: var(--surface, #fffdf8); color: var(--text, #171512); border: 1px solid var(--shb-gold); box-shadow: 0 8px 22px rgba(0,0,0,.16);
  font-size: 13.5px; line-height: 1.45; animation: shb-pop .25s ease-out;
}
.shb-say[hidden] { display: none; }
@keyframes shb-pop { from { opacity: 0; transform: translateY(6px) scale(.96); } to { opacity: 1; transform: none; } }
/* the chat opens beside him; his own 3D stage is not needed then */
.shalaby-root.is-buddy .shb-panel { inset-inline-end: calc(max(10px, env(safe-area-inset-right, 0px)) + 172px); bottom: max(18px, env(safe-area-inset-bottom, 0px)); }
.shb-panel.no-stage .shb-stage { display: none; }
.shb-panel.no-stage .shb-waves { display: none; }
@media (max-width: 599px) {
  .shb-buddy { width: 100px; height: 130px; inset-inline-end: 4px; }
  .shb-bx.is-talk { bottom: 34px; width: 30px; height: 30px; font-size: 15px; }
  .shb-bx.is-hide { top: 4px; inset-inline-end: 0; width: 24px; height: 24px; font-size: 12px; }
  .shb-say { max-width: 190px; font-size: 12.5px; inset-inline-end: 20px; }
  .shalaby-root.is-buddy .shb-panel { inset-inline-end: 8px; bottom: calc(max(14px, env(safe-area-inset-bottom, 0px)) + 64px); }
}
@media (prefers-reduced-motion: reduce) { .shb-bx, .shb-say { transition: none; animation: none; } }
@media print { .shalaby-root { display: none; } }

/* owner 31 Oct 2026: answers from the manuals — steps, tip, close topics and where it is in the guide */
.shb-msg .shb-steps { margin: 6px 0 2px; padding-inline-start: 1.3em; }
.shb-msg .shb-steps li { margin: 2px 0; }
.shb-msg .shb-tip { margin: 6px 0 0; padding: 6px 8px; border-radius: 8px; background: rgba(201, 162, 74, .12); font-size: .92em; }
.shb-msg .shb-more { margin: 6px 0 2px; font-size: .9em; opacity: .85; }
.shb-msg .shb-mchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.shb-msg .shb-mchips .shb-chip { flex: 0 1 auto; max-width: 100%; font-size: 12.5px; text-align: start; white-space: normal; }
.shb-msg .shb-ref { margin: 8px 0 0; font-size: 12px; opacity: .72; }

/* owner 31 Oct 2026: easier answers — title, bold screen words, links to the person's own pages, 📍 where to find it */
.shb-msg .shb-ttl { margin: 0 0 4px; font-weight: 700; font-size: 13px; color: var(--gold-ink, #8a5d06); }
.shb-msg strong { font-weight: 700; }
.shb-msg a.shb-link { color: var(--gold-ink, #8a5d06); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.shb-msg a.shb-link:hover, .shb-msg a.shb-link:focus-visible { color: var(--shb-gold, #c9a24a); }
.shb-msg .shb-where { display: flex; gap: 6px; align-items: baseline; margin: 6px 0 0; padding: 6px 8px; border-radius: 8px; background: rgba(201, 162, 74, .10); font-size: .95em; }
.shb-msg .shb-pin { flex: 0 0 auto; }
.shb-msg .shb-wtxt { flex: 1 1 auto; min-width: 0; }
[data-theme="dark"] .shb-msg .shb-ttl, [data-theme="dark"] .shb-msg a.shb-link { color: #e8c46a; }

/* owner 1 Nov 2026: the public website (50dogs.com) — WhatsApp / contact buttons when Shalaby has no answer */
.shb-msg .shb-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.shb-msg .shb-act { display: inline-flex; align-items: center; padding: 6px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; text-decoration: none; border: 1px solid var(--shb-gold, #c9a24a); color: var(--gold-ink, #8a5d06); background: transparent; }
.shb-msg .shb-act.is-wa { background: #25d366; border-color: #25d366; color: #fff; }
.shb-msg .shb-act:hover { filter: brightness(.95); }
.shalaby-root.is-site { font-family: inherit; line-height: 1.5; }
.shalaby-root.is-site .shb-panel, .shalaby-root.is-site .shb-fab { z-index: 2147483000; }
/* website: always bottom-RIGHT (the site's own "How it works" button is bottom-left in every language) */
.shalaby-root.is-site .shb-fab, .shalaby-root.is-site .shb-panel { inset-inline-end: auto; inset-inline-start: auto; right: max(18px, env(safe-area-inset-right, 0px)); left: auto; }
.shalaby-root.is-site .shb-fab { width: 58px; height: 58px; }
.shalaby-root.is-site .shb-panel button, .shalaby-root.is-site .shb-panel input, .shalaby-root.is-site .shb-panel .shb-act { font-family: inherit; text-transform: none; letter-spacing: normal; }
@media (max-width: 599px) {
  .shalaby-root.is-site .shb-fab { right: 12px; bottom: max(14px, env(safe-area-inset-bottom, 0px)); width: 52px; height: 52px; }
  .shalaby-root.is-site .shb-panel { right: 8px; left: 8px; }
}
/* owner 2 Nov 2026: website — the round button brings the full standing Shalaby (bottom-right) with the chat beside him */
.shalaby-root.is-site .shb-buddy { inset-inline-end: auto; inset-inline-start: auto; right: max(10px, env(safe-area-inset-right, 0px)); left: auto; z-index: 2147482999; }
.shalaby-root.is-site .shb-bx, .shalaby-root.is-site .shb-say { display: none; }
.shalaby-root.is-site.is-buddy .shb-panel { right: calc(max(10px, env(safe-area-inset-right, 0px)) + 172px); bottom: max(18px, env(safe-area-inset-bottom, 0px)); }
@media (max-width: 599px) {
  .shalaby-root.is-site .shb-buddy { right: 4px; }
  .shalaby-root.is-site.is-buddy .shb-panel { right: 8px; left: 8px; bottom: max(14px, env(safe-area-inset-bottom, 0px)); height: calc(100dvh - 96px); }
}
/* owner 2 Nov 2026: website — "I'm Shalaby! If you need any help, talk to me." beside the round button, once per visit */
.shalaby-root.is-site .shb-fabsay {
  position: fixed; right: calc(max(18px, env(safe-area-inset-right, 0px)) + 70px); bottom: calc(max(18px, env(safe-area-inset-bottom, 0px)) + 10px); z-index: 2147483000;
  max-width: 240px; padding: 10px 14px; border-radius: 14px; border-end-end-radius: 4px; cursor: pointer; text-align: start;
  background: var(--surface, #fffdf8); color: var(--text, #171512); border: 1px solid var(--shb-gold, #c9a24a); box-shadow: 0 8px 22px rgba(0,0,0,.16);
  font: inherit; font-size: 14px; line-height: 1.45; animation: shb-pop .25s ease-out;
}
[dir="rtl"] .shalaby-root.is-site .shb-fabsay { border-end-end-radius: 14px; border-end-start-radius: 4px; border-bottom-right-radius: 4px; }
.shalaby-root.is-site .shb-fabsay[hidden] { display: none; }
@media (max-width: 599px) {
  .shalaby-root.is-site .shb-fabsay { right: 12px; bottom: calc(max(14px, env(safe-area-inset-bottom, 0px)) + 62px); max-width: 230px; font-size: 13px; border-end-end-radius: 4px; }
}
