/* The assistant panel (W6, specs screens/assistant-panel.md): a floating panel at 1280 and up, a full-height sheet below.
   Tokens only (ADR-0013); no inline styles (CSP, ADR-0011): JS sets classes, and el.style only for the drag and keyboard offset.
   Mounted once by app.js; one file for the whole panel. */

.ap-launcher, .ap-panel, .ap-scrim { font-family: var(--font-sans); }
.ap-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ap-launcher[hidden], .ap-panel[hidden], .ap-scrim[hidden] { display: none; }

/* ---- launcher ---- */
.ap-launcher {
  position: fixed; z-index: 40; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  right: calc(24px + env(safe-area-inset-right)); bottom: calc(24px + env(safe-area-inset-bottom));
  height: 48px; padding: 0 18px 0 14px; border: 0; border-radius: 24px; cursor: pointer;
  background: var(--accent-text); color: #fff; font: 600 15px/1 var(--font-sans);
}
.ap-launcher:hover, .ap-launcher:active { background: var(--accent-deep); }
.ap-launcher:focus-visible, .ap-icon:focus-visible, .ap-mic:focus-visible, .ap-send:focus-visible, .ap-act:focus-visible, .ap-chip:focus-visible,
.ap-link:focus-visible, .ap-compose textarea:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.ap-launcher svg { width: 20px; height: 20px; flex: none; }
.ap-count { display: none; }
.ap-launcher.has-count .ap-count { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border: 1px solid #fff; border-radius: 11px; background: var(--accent-deep); font-size: 13px; }
.ap-launcher.is-open { display: none; }

/* ---- panel (1280 and up) ---- */
.ap-panel {
  position: fixed; z-index: 45; display: flex; flex-direction: column; overflow: hidden;
  right: calc(24px + env(safe-area-inset-right)); bottom: calc(24px + env(safe-area-inset-bottom));
  width: 400px; height: min(640px, calc(100dvh - 96px));
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgb(28 28 28 / .12);
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity 140ms ease, transform 140ms ease;
}
.ap-panel.is-open { opacity: 1; transform: none; pointer-events: auto; transition: opacity 180ms cubic-bezier(.2, .8, .2, 1), transform 180ms cubic-bezier(.2, .8, .2, 1); }
body.as-open .toast-host { right: 448px; }
.ap-scrim { position: fixed; inset: 0; z-index: 44; background: rgb(28 28 28 / .32); opacity: 0; transition: opacity 200ms ease; }
.ap-scrim.is-open { opacity: 1; }
.ap-grab { display: none; }

/* ---- sheet (below 1280) ---- */
@media (max-width: 1279.98px) {
  .ap-launcher { width: 56px; height: 56px; padding: 0; border-radius: 50%; right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); }
  .ap-launcher svg { width: 24px; height: 24px; }
  .ap-launcher .ap-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .ap-launcher.has-count .ap-count { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; min-height: 0; padding: 0 5px; justify-content: center; border: 0; border-radius: 10px; background: var(--danger); font-size: 12px; font-weight: 600; }
  .ap-panel {
    left: 0; right: 0; bottom: 0; width: auto; height: calc(100dvh - 24px - env(safe-area-inset-top));
    border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; box-shadow: none;
    opacity: 1; transform: translateY(100%); transition: transform 260ms cubic-bezier(.2, .8, .2, 1);
  }
  .ap-panel.is-open { transform: none; transition: transform 260ms cubic-bezier(.2, .8, .2, 1); }
  .ap-panel.is-dragging { transition: none; }
  .ap-grab { display: block; flex: none; width: 36px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--line-strong); touch-action: none; }
  body.ap-modal { overflow: hidden; }
  .ap-scrim:not([hidden]) { display: block; }
}
@media (min-width: 1280px) { .ap-scrim { display: none; } }
@media (min-width: 1025px) and (max-width: 1279.98px) { .ap-panel { left: var(--sidebar); } .ap-scrim { left: var(--sidebar); } }

/* ---- header ---- */
.ap-head { flex: none; display: flex; align-items: center; gap: 4px; min-height: 56px; padding: 6px 8px 6px 16px; border-bottom: 1px solid var(--line); }
.ap-head-text { flex: 1; min-width: 0; }
.ap-head h2 { margin: 0; font: 600 18px/1.2 var(--font-display); color: var(--ink); }
.ap-sub { margin: 0; font-size: 13px; color: var(--muted); }
.ap-sub .ap-link { font-size: 13px; }
.ap-icon, .ap-mic { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--accent-text); cursor: pointer; }
.ap-icon:hover, .ap-mic:hover { background: var(--paper); }
.ap-icon svg, .ap-mic svg { width: 20px; height: 20px; }
.ap-link { display: inline; padding: 0; border: 0; background: none; font: inherit; color: var(--accent-text); text-decoration: underline; cursor: pointer; }
.ap-top { display: none; width: 44px; height: 44px; align-items: center; justify-content: center; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--accent-text); cursor: pointer; }
.ap-top svg { width: 22px; height: 22px; }
.ap-top.is-on { display: inline-flex; }
.ap-top:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* ---- log ---- */
.ap-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ap-welcome h3 { margin: 4px 0 6px; font: 600 20px/1.2 var(--font-display); color: var(--ink); }
.ap-welcome p { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
.ap-chips { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.ap-chip { min-height: 44px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--card); color: var(--accent-text); font: 500 14px/1.3 var(--font-sans); text-align: left; cursor: pointer; }
.ap-chip:hover { background: var(--navy-soft); }
.ap-earlier { display: flex; flex-direction: column; gap: 12px; }
.ap-label-line { margin: 0; font-size: 12px; color: var(--muted); }
.ap-msg { max-width: 85%; padding: 10px 14px; border-radius: var(--radius); font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.ap-msg.user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.ap-msg.assistant { align-self: flex-start; max-width: 92%; background: var(--ink-soft); color: var(--ink); }
.ap-msg.error { align-self: flex-start; max-width: 92%; background: var(--danger-soft); color: var(--danger); }
.ap-spoken { align-self: flex-end; margin: -8px 0 0; display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.ap-spoken svg { width: 14px; height: 14px; }
.ap-looked { align-self: flex-start; margin: -8px 0 0; font-size: 12px; color: var(--muted); }
.ap-typing { align-self: flex-start; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.ap-dots { display: inline-flex; gap: 4px; padding: 10px 12px; border-radius: var(--radius); background: var(--ink-soft); }
.ap-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: ap-bob 1s infinite ease-in-out; }
.ap-dots i:nth-child(2) { animation-delay: .15s; } .ap-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ap-bob { 0%, 80%, 100% { opacity: .35; } 40% { opacity: 1; } }

/* ---- proposal card ---- */
.ap-card { align-self: stretch; padding: 14px; border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); background: var(--card); }
.ap-card .ap-kind { margin: 0 0 4px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--mauve-text); }
.ap-card .ap-text { margin: 0 0 6px; font-size: 15px; color: var(--ink); overflow-wrap: anywhere; }
.ap-card .ap-rec { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.ap-card .ap-rec a { color: var(--accent-text); }
.ap-card .ap-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ap-act { min-height: 44px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--radius-sm); font: 600 15px/1 var(--font-sans); cursor: pointer; }
.ap-act.confirm { min-width: 112px; background: var(--accent-text); color: #fff; }
.ap-act.confirm:hover:not(:disabled) { background: var(--accent-deep); }
.ap-act.discard { background: transparent; color: var(--accent-text); }
.ap-act:disabled { opacity: .6; cursor: default; }
.ap-card .ap-err { margin: 8px 0 0; font-size: 13px; color: var(--danger); }
.ap-card.is-done { border-left-color: var(--success); border-color: var(--line); border-left-width: 3px; padding: 10px 14px; }
.ap-card.is-done .ap-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; font-size: 15px; color: var(--ink); }
.ap-card.is-done .ap-line svg { width: 18px; height: 18px; color: var(--success); flex: none; }
.ap-card.is-done .ap-line a { margin-left: auto; color: var(--accent-text); font-weight: 600; }
.ap-card.is-off { border-color: var(--line); border-left-color: var(--line-strong); background: var(--paper); }
.ap-card.is-off .ap-line { margin: 0; font-size: 14px; color: var(--muted); }

/* ---- voice, composer ---- */
.ap-consent { align-self: stretch; padding: 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.ap-consent p { margin: 0 0 10px; font-size: 14px; color: var(--ink); }
.ap-consent .row { display: flex; gap: 8px; flex-wrap: wrap; }
.ap-listen { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 16px; font-size: 13px; color: var(--ink); background: var(--danger-soft); border-top: 1px solid var(--line); }
.ap-listen[hidden], .ap-hint[hidden], .ap-verr[hidden], .ap-perr[hidden] { display: none; }
.ap-listen i { width: 6px; height: 6px; border-radius: 50%; background: var(--danger); animation: ap-pulse 1.2s infinite ease-in-out; }
@keyframes ap-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.ap-hint { flex: none; margin: 0; padding: 8px 16px 0; font-size: 13px; color: var(--muted); }
.ap-verr, .ap-perr { flex: none; margin: 0; padding: 8px 16px 0; font-size: 13px; color: var(--danger); }
.ap-compose { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 12px 12px 4px; border-top: 1px solid var(--line); }
.ap-compose textarea { flex: 1; min-width: 0; min-height: 44px; max-height: 120px; resize: none; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); font: 400 16px/1.4 var(--font-sans); }
.ap-compose textarea.is-interim { color: var(--muted); }
.ap-compose textarea:disabled { background: var(--paper); }
.ap-mic.is-listening { background: var(--danger); color: #fff; }
.ap-mic.is-listening:hover { background: var(--danger); }
.ap-send { min-height: 44px; padding: 0 18px; border: 0; border-radius: var(--radius-sm); background: var(--accent-text); color: #fff; font: 600 15px/1 var(--font-sans); cursor: pointer; }
.ap-send:hover:not(:disabled) { background: var(--accent-deep); }
.ap-send:disabled { opacity: .5; cursor: default; }
.ap-note { flex: none; margin: 0; padding: 4px 16px calc(12px + env(safe-area-inset-bottom)); font-size: 13px; color: var(--muted); }
.ap-pop { flex: none; margin: 0 12px 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); font-size: 13px; color: var(--ink); }
.ap-pop[hidden] { display: none; }
.ap-pop ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }

/* the driver's button on My runs (56 px) lives in my-runs.css; this is the shared look */
.ap-speak { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 56px; border: 1.5px solid var(--accent-text); border-radius: var(--radius-sm); background: var(--card); color: var(--accent-text); font: 600 16px/1 var(--font-sans); cursor: pointer; }
.ap-speak svg { width: 20px; height: 20px; }
.ap-speak-row { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--accent-text); cursor: pointer; }
.ap-speak:focus-visible, .ap-speak-row:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .ap-panel, .ap-panel.is-open { transform: none; transition: opacity 1ms; }
  .ap-scrim { transition: opacity 1ms; }
  .ap-dots i, .ap-listen i { animation: none; }
}
@media (prefers-reduced-motion: reduce) and (max-width: 1279.98px) {
  .ap-panel { transform: none; opacity: 0; pointer-events: none; }
  .ap-panel.is-open { opacity: 1; pointer-events: auto; }
}

/* inline links keep a 44 px hit area without growing the header or the note line */
.ap-sub .ap-link, .ap-note .ap-link { display: inline-flex; align-items: center; min-height: 44px; margin: -14px 0; }

/* the privacy note floats over the composer instead of pushing the sheet up, and closes on its own (W6-2) */
.ap-pop { position: absolute; left: 12px; right: 12px; bottom: 72px; z-index: 2; max-height: 45%; overflow-y: auto; margin: 0; box-shadow: 0 8px 24px rgb(28 28 28 / .14); background: var(--card); }
.ap-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ap-pop-head .ap-link { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; margin: 0; padding: 0 8px; }
.ap-pop ul { margin-top: 0; }
/* record link and Open are 44 px targets; the record line is a row of its own (W6-6) */
.ap-card .ap-rec { display: flex; align-items: center; flex-wrap: wrap; column-gap: 6px; min-height: 44px; margin: 0 0 4px; }
.ap-card .ap-rec a { display: inline-flex; align-items: center; min-height: 44px; }
.ap-card.is-done .ap-line a { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; margin-left: auto; }

/* The round launcher sits over the page's last line at full scroll; keep room for it (W11-6). 56 + 32 clears its 48px and the 24px offset. */
@media (max-width: 1279px) {
  body.ap-launcher-on #view { padding-bottom: calc(56px + 32px + env(safe-area-inset-bottom)); }
}
