/* «Asistencia» (js/asistencia.js, SPEC-055): the floating button and its window.
   Site tokens only (style.css). Desktop: a 380 × 560 window above the button, bottom
   right. Under 480 px: the window takes the whole screen above the studio's phone bar,
   whose height js/asistencia.js measures into --assist-bar (0px when there is none).
   44 px touch targets, no sideways scroll at 390 px, no emoji. */

.assist { --assist-bar: 0px; --assist-gap: 16px; }

.assist-launcher {
  position: fixed; z-index: 90;
  right: calc(var(--assist-gap) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--assist-gap) + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; padding: 0 1rem;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink);
  font: inherit; font-size: .9rem; font-weight: 500; box-shadow: var(--sh-md, 0 6px 20px rgba(0, 0, 0, .18)); cursor: pointer;
}
.assist[data-bar="on"] .assist-launcher { bottom: calc(var(--assist-bar) + 12px); }
/* SPEC-070 RF-D3: on the phone (with the studio's bar) the launcher is a round icon, so it covers as
   little of the page as possible; its name stays for screen readers. */
.assist[data-bar="on"] .assist-launcher { width: 44px; height: 44px; padding: 0; justify-content: center; }
.assist[data-bar="on"] .assist-launcher-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.assist-launcher:hover { border-color: var(--gold); }
.assist-launcher:focus-visible, .assist-window :focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.assist-ic { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.assist[data-open] .assist-launcher { border-color: var(--gold); }

.assist-window {
  position: fixed; z-index: 150;
  right: var(--assist-gap); bottom: calc(var(--assist-bar) + var(--assist-gap) + 56px);
  width: min(380px, calc(100vw - 2 * var(--assist-gap)));
  height: min(560px, calc(100vh - var(--assist-bar) - 96px));
  display: flex; flex-direction: column; box-sizing: border-box; overflow: hidden;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink);
  box-shadow: var(--sh-lg, 0 18px 60px rgba(0, 0, 0, .28));
}
.assist-window[hidden] { display: none; }

.assist-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 6px 16px; }
.assist-title { margin: 0; font-family: Fraunces, Georgia, serif; font-weight: 500; font-size: 1.1rem; }
.assist-close {
  display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); font: inherit; font-size: 22px; cursor: pointer;
}
.assist-close:hover { color: var(--ink); }

.assist-tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.assist-tab {
  flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 .5rem; border: 0; border-bottom: 2px solid transparent;
  background: transparent; color: var(--muted); font: inherit; font-size: .9rem; cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.assist-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold); font-weight: 600; }

.assist-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; padding: 12px 16px 14px; gap: .6rem; overflow-wrap: anywhere; }
.assist-panel[hidden] { display: none; }

.assist-note { margin: 0; color: var(--muted); font-size: .82rem; }
.assist-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; padding: .6rem .75rem; border: 1px solid var(--line-2); border-radius: 10px; }
.assist-suggest[hidden] { display: none; }
.assist-suggest-text { margin: 0; font-size: .88rem; flex: 1 1 12rem; }

.assist-log { flex: 1 1 auto; min-height: 6rem; display: flex; flex-direction: column; gap: .5rem; overflow-y: auto; }
.assist-msg { max-width: 88%; padding: .55rem .75rem; border-radius: 12px; font-size: .92rem; line-height: 1.45; }
.assist-msg p { margin: 0; }
.assist-msg--bot { align-self: flex-start; background: var(--surface-2, rgba(127, 127, 127, .08)); border: 1px solid var(--line); }
.assist-msg--user { align-self: flex-end; background: var(--gold-soft, rgba(201, 162, 39, .14)); color: var(--ink); }
.assist-msg--waiting { color: var(--muted); font-style: italic; }
.assist-msg-source { margin-top: .3rem !important; color: var(--muted); font-size: .75rem; }

.assist-ask { display: flex; flex-direction: column; gap: .4rem; }
.assist-ask-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.assist-count { color: var(--muted); font-size: .75rem; }
.assist-input {
  font: inherit; color: inherit; background: transparent; width: 100%; box-sizing: border-box;
  min-height: 44px; padding: .55rem .75rem; border: 1px solid var(--line-2); border-radius: .5rem; resize: vertical;
}
.assist-report { display: flex; flex-direction: column; gap: .75rem; }
.assist-report[hidden] { display: none; }
.assist-field { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; }
.assist-label { font-weight: 500; }
.assist-shot { font: inherit; font-size: .85rem; min-height: 44px; }
.assist-error { margin: 0; color: #c0392b; font-size: .88rem; }
:root[data-theme="dark"] .assist-error { color: #f0a0a0; }
.assist-error[hidden], .assist-done[hidden], .assist-another[hidden] { display: none; }
.assist-done { margin: .25rem 0 0; font-size: .95rem; }

.assist-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 1rem;
  border: 1px solid var(--line-2); border-radius: .5rem; background: transparent; color: var(--ink);
  font: inherit; font-size: .9rem; cursor: pointer;
}
.assist-btn--primary { border-color: var(--gold); background: var(--gold); color: var(--on-gold, #15171a); font-weight: 600; }
.assist-btn:disabled { opacity: .6; cursor: default; }
.assist-report .assist-btn--primary, .assist-another { align-self: flex-start; }

/* Phones: the whole screen above the studio's bottom bar; the button stays above the bar. */
@media (max-width: 479.98px) {
  .assist-launcher-text { font-size: .85rem; }
  .assist-window {
    top: 0; left: 0; right: 0; bottom: var(--assist-bar);
    width: auto; height: auto; border-radius: 0; border-width: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .assist[data-bar="off"] .assist-window { padding-bottom: env(safe-area-inset-bottom, 0px); }
}

@media print { .assist { display: none; } }
