/* The portal help: the opener pill, the "Ask about this" links and the
   slide-over panel. Everything is scoped under .ax-help (the panel root) or
   .ax-help-ask (the links the script adds beside data-help elements), and
   uses the portal's own tokens from admin.css, so the panel follows the
   light and dark themes without any colour of its own.

   Layout
     .ax-help-bar ........ the floating opener at the bottom of the page
     .ax-help-layer ...... the side pane, fixed to the right edge; not modal
     .ax-help-panel ...... head / thread / composer, as grid rows
     .ax-help-msg ........ one turn: .me (the admin), .bot (the help), .sys (a notice)
     .ax-help-meta ....... the quiet "Looked at · Sources" line under a reply
     .ax-help-acts ....... link buttons, quick replies, follow-up chips, thumbs */

/* The opener floats in the bottom-right corner of every page. While the panel
   is open it steps aside: the panel has its own close button in that corner. */
.ax-help-bar{position:fixed;right:max(20px,env(safe-area-inset-right,0px));bottom:max(20px,env(safe-area-inset-bottom,0px));z-index:55;display:flex}
html.help-open .ax-help-bar{display:none}
.ax-help-open{display:inline-flex;align-items:center;gap:8px;min-height:40px;padding:0 16px 0 10px;border-radius:999px;border:1px solid var(--line-strong);background:var(--surface);color:var(--ink);font:inherit;font-size:13px;font-weight:600;cursor:pointer;box-shadow:var(--shadow)}
.ax-help-open .q,.ax-help-head .q{flex:none;width:20px;height:20px;border-radius:50%;background:var(--teal);color:#fff;display:grid;place-items:center;font-family:var(--font-mono);font-size:12px;line-height:1}
.ax-help-open:hover{border-color:var(--teal);color:var(--teal-ink)}
.ax-help-open[aria-expanded="true"]{border-color:var(--teal)}

/* "Ask about this", added beside a Help link or inside a card that carries data-help. */
.ax-help-ask{display:inline-flex;align-items:center;gap:4px;min-height:24px;margin-inline-start:10px;padding:0;border:0;background:none;color:var(--teal);font:inherit;font-size:12.5px;cursor:pointer;white-space:nowrap;text-decoration:none}
.ax-help-ask::before{content:"?";font-family:var(--font-mono);opacity:.8}
.ax-help-ask:hover{color:var(--teal-ink);text-decoration:underline}
.ax-help-ask.block{margin:8px 0 0}

/* The panel: a side pane on the page's right edge, never a modal. The page
   stays usable beside it; on wide screens the page makes room for it. */
.ax-help-layer{position:fixed;top:0;bottom:0;right:0;width:min(420px,100%);z-index:60}
@media (min-width:1200px){
  html.help-open #app{margin-right:420px}
}
/* Room under the last block of a page, so the opener never covers it. */
#app main{padding-bottom:88px}
.ax-help-panel{position:absolute;inset:0;background:var(--surface);border-left:1px solid var(--line);box-shadow:var(--shadow);display:grid;grid-template-rows:auto minmax(0,1fr) auto;color:var(--ink-soft);font-size:13.5px;animation:ax-help-in .2s ease-out}
@keyframes ax-help-in{from{transform:translateX(24px);opacity:0}to{transform:none;opacity:1}}
.ax-help-panel:focus{outline:none}

/* Head and context line. */
.ax-help-head{display:flex;align-items:center;gap:10px;padding:12px 14px;border-bottom:1px solid var(--line)}
.ax-help-head .q{width:26px;height:26px;font-size:13px}
.ax-help-titles{min-width:0;flex:1 1 auto}
.ax-help-titles b{display:block;font-family:var(--font-display);font-weight:600;color:var(--ink);font-size:14px;line-height:1.2}
.ax-help-titles small{display:block;color:var(--muted);font-size:11.5px;line-height:1.3;margin-top:2px}
.ax-help-tools{display:flex;align-items:center;gap:2px;flex:none}
.ax-help-clear,.ax-help-close{min-width:36px;min-height:36px;padding:0 8px;border:0;border-radius:8px;background:none;color:var(--muted);font:inherit;font-size:12.5px;cursor:pointer}
.ax-help-close{font-size:22px;line-height:1}
.ax-help-clear:hover,.ax-help-close:hover{background:var(--surface-2);color:var(--ink)}

/* The thread. */
.ax-help-body{overflow:auto;overscroll-behavior:contain;padding:14px;background:var(--paper)}
.ax-help-thread{display:grid;gap:10px;align-content:start}
.ax-help-msg{max-width:94%;padding:10px 12px;border-radius:14px;line-height:1.5;overflow-wrap:anywhere}
.ax-help-msg.me{justify-self:end;background:var(--surface-2);color:var(--ink);white-space:pre-wrap}
.ax-help-panel[dir="rtl"] .ax-help-msg.me{justify-self:start}
.ax-help-msg.bot{background:var(--surface);border:1px solid var(--line);color:var(--ink-soft)}
.ax-help-msg.bot p{margin:0 0 8px}
.ax-help-msg.bot p:last-child{margin-bottom:0}
.ax-help-msg.bot ul,.ax-help-msg.bot ol{margin:6px 0 0;padding-inline-start:18px}
.ax-help-msg.bot li{margin:3px 0}
.ax-help-msg.bot code{font-family:var(--font-mono);font-size:12px;background:var(--surface-2);padding:1px 4px;border-radius:4px}
.ax-help-msg.bot a{color:var(--teal)}
.ax-help-msg.sys{max-width:100%;background:transparent;border:1px dashed var(--line-strong);color:var(--muted);font-size:12.5px}
.ax-help-msg.sys.notice{border-style:solid;background:var(--teal-soft);color:var(--ink);border-color:transparent}
.ax-help-msg.sys.limit{border-style:solid;background:var(--amber-soft);border-color:transparent;color:var(--ink)}
.ax-help-msg.sys p{margin:0 0 8px}
.ax-help-msg.sys p:last-child{margin:0}
.ax-help-thinking{display:inline-flex;gap:4px;padding:4px 2px;align-items:center}
.ax-help-thinking i{width:6px;height:6px;border-radius:50%;background:var(--muted);animation:ax-help-dot 1s infinite}
.ax-help-thinking i:nth-child(2){animation-delay:.2s}
.ax-help-thinking i:nth-child(3){animation-delay:.4s}
@keyframes ax-help-dot{0%,80%,100%{opacity:.3}40%{opacity:1}}

/* Under a reply: the "Looked at · Sources" line, the link buttons, the chips, the thumbs. */
.ax-help-meta{margin-top:8px;padding-top:8px;border-top:1px solid var(--line);font-size:11.5px;color:var(--muted);display:flex;gap:6px;flex-wrap:wrap;align-items:center}
.ax-help-meta .chip{text-transform:none;letter-spacing:0;font-family:var(--font-body);font-size:11px;padding:2px 8px;white-space:normal}
.ax-help-meta a{color:var(--teal)}
.ax-help-meta .note{flex-basis:100%;font-style:italic}
.ax-help-acts{display:flex;gap:6px;flex-wrap:wrap;margin-top:8px}
.ax-help-acts .btn{min-height:32px;height:auto;padding:4px 10px;white-space:normal;text-align:start;text-decoration:none}
.ax-help-chips{display:flex;flex-wrap:wrap;gap:6px}
.ax-help-chip{border:1px solid var(--line-strong);background:var(--surface);border-radius:999px;min-height:32px;padding:5px 12px;font:inherit;font-size:12.5px;cursor:pointer;color:var(--ink);text-align:start}
.ax-help-chip:hover{border-color:var(--teal);color:var(--teal-ink)}
.ax-help-chip[disabled]{opacity:.5;cursor:default}
.ax-help-rate{display:flex;gap:4px;align-items:center;margin-top:8px;font-size:11.5px;color:var(--muted)}
.ax-help-rate button{min-width:32px;min-height:28px;border:1px solid transparent;border-radius:8px;background:none;color:var(--muted);font:inherit;font-size:12px;cursor:pointer;padding:0 8px}
.ax-help-rate button:hover{background:var(--surface-2);color:var(--ink)}
.ax-help-rate button[aria-pressed="true"]{border-color:var(--teal);color:var(--teal-ink);background:var(--teal-soft)}

/* The composer, pinned at the bottom. */
.ax-help-foot{padding:10px 14px;border-top:1px solid var(--line);display:grid;gap:6px;background:var(--surface);padding-bottom:max(10px,env(safe-area-inset-bottom,0px))}
.ax-help-composer{display:flex;gap:8px;align-items:center}
.ax-help-composer input{flex:1;min-width:0;height:40px;font-size:14px}
.ax-help-composer .btn{height:40px;flex:none}
.ax-help-send{background:var(--teal);border-color:var(--teal);color:#fff}
.ax-help-send:hover{background:var(--teal-ink)}
.ax-help-note{margin:0;font-size:11.5px}
.ax-help-small{margin:0;font-size:11.5px;display:flex;gap:6px;flex-wrap:wrap;align-items:center}
.ax-help-link{border:0;background:none;padding:0;min-height:24px;color:var(--teal);font:inherit;font-size:11.5px;cursor:pointer;text-decoration:underline}
.ax-help-link:hover{color:var(--teal-ink)}
.ax-help-panel.is-busy .ax-help-composer{opacity:.6}
.ax-help-panel.is-closed .ax-help-composer{display:none}

/* Under the menu's breakpoint the opener sits a little closer to the corner. */
@media (max-width:899.98px){
  .ax-help-bar{right:max(16px,env(safe-area-inset-right,0px));bottom:max(16px,env(safe-area-inset-bottom,0px))}
}
/* Phones: a full-width sheet, the composer pinned, every target at least 44px. */
@media (max-width:640px){
  .ax-help-open .t{display:none}
  .ax-help-open{min-width:44px;min-height:44px;justify-content:center;padding:0}
  .ax-help-panel{width:100%;border-left:0}
  .ax-help-msg{max-width:100%}
  .ax-help-clear,.ax-help-close{min-width:44px;min-height:44px}
  .ax-help-chip,.ax-help-acts .btn{min-height:44px}
  .ax-help-composer .btn,.ax-help-composer input{height:44px}
  .ax-help-rate button{min-height:44px;min-width:44px}
  .ax-help-ask{min-height:44px}
  .ax-help-link{min-height:44px;display:inline-flex;align-items:center}
}
@media (prefers-reduced-motion:reduce){
  .ax-help-panel{animation:none}
  .ax-help-thinking i{animation:none;opacity:.7}
}
@media print{.ax-help{display:none}}
