/* The portal assistant panel (assistant.js). Tokens from DESIGN.md only: dark, hairlines, no shadows or
   glows; gold only on the primary button (Send, Confirm); controls are pills at least 44px tall. */

/* Docked: the page reflows beside the panel. */
@media (min-width: 768px) {
  body.as-docked { padding-right: var(--as-w, 344px); }
  body.as-docked .viewas { right: var(--as-w, 344px); }
}
html.as-lock, html.as-lock body { overflow: hidden; }

/* Launcher: a pill bottom-right carrying the face. */
.as-launch { position: fixed; z-index: 15; right: max(var(--gutter), env(safe-area-inset-right)); bottom: max(var(--gutter), env(safe-area-inset-bottom)); display: inline-flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 22px 0 7px; border-radius: var(--r-control); border: 1px solid var(--border); background: var(--card); color: var(--foreground); cursor: pointer; font-size: 15px; font-weight: 400; }
.as-launch:hover { border-color: var(--muted); }
.as-face { width: 40px; height: 40px; flex: none; border-radius: 50%; overflow: hidden; display: grid; place-items: center; }
.as-face-live { display: block; width: 40px; height: 40px; }
.as-disc { width: 100%; height: 100%; display: grid; place-items: center; border-radius: 50%; background: var(--background); border: 1px solid var(--border); font: 400 15px/1 var(--serif); color: var(--foreground); }

/* The panel, in its three forms. */
.as-panel { position: fixed; z-index: 15; display: flex; flex-direction: column; min-width: 0; background: var(--background); color: var(--foreground); font-size: 15px; }
.as-panel[data-form="docked"] { top: 0; right: 0; bottom: 0; width: var(--as-w, 344px); border-left: 1px solid var(--border); }
.as-panel[data-form="floating"] { z-index: 16; border: 1px solid var(--border); border-radius: var(--r-tile); overflow: hidden; resize: both; min-width: 376px; min-height: 420px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
.as-panel[data-form="sheet"] { z-index: 31; left: 0; right: 0; top: calc(var(--vvt, 0px) + 24px); height: calc(var(--vvh, 100dvh) - 24px); border-top: 1px solid var(--border); border-radius: var(--r-tile) var(--r-tile) 0 0; overflow: hidden; transition: transform .2s ease-out; }
.as-scrim { position: fixed; inset: 0; z-index: 30; background: color-mix(in srgb, var(--background) 72%, transparent); }

.as-resize { display: none; position: absolute; z-index: 1; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; touch-action: none; }
.as-panel[data-form="docked"] .as-resize { display: block; }
.as-resize:hover, .as-resize:focus-visible { background: var(--border); outline: none; }
.as-grab { display: none; height: 20px; padding-top: 8px; touch-action: none; }
.as-grab i { display: block; width: 40px; height: 4px; margin: 0 auto; border-radius: 2px; background: var(--border); }
.as-panel[data-form="sheet"] .as-grab { display: block; }

.as-head { display: flex; align-items: center; gap: 0; min-height: 64px; padding: 10px 2px 10px 10px; border-bottom: 1px solid var(--border); }
.as-panel[data-form="floating"] .as-head { cursor: move; touch-action: none; }
.as-panel[data-form="sheet"] .as-head { min-height: 56px; padding-top: 4px; touch-action: none; }
.as-move { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; border-radius: var(--r-control); }
.as-title { font: 400 18px/1.1 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-ib { width: 44px; height: 44px; flex: none; padding: 0; border: 0; border-radius: var(--r-control); background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.as-ib:hover, .as-ib[aria-expanded="true"], .as-ib[aria-pressed="true"] { color: var(--foreground); }
.as-ib[aria-pressed="true"] { outline: 1px solid var(--foreground); outline-offset: -1px; }
.as-ib svg { width: 20px; height: 20px; }

/* Conversations list: drops over the log. */
.as-threads { position: relative; z-index: 2; max-height: 60%; overflow-y: auto; padding: 12px 12px 8px; border-bottom: 1px solid var(--border); background: var(--background); display: grid; gap: 8px; }
.as-threads ul { list-style: none; margin: 0; padding: 0; }
.as-thread { width: 100%; min-height: 48px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 4px; border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; cursor: pointer; font-size: 14px; }
.as-thread span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-thread[aria-current="true"] span:first-child { text-decoration: underline; text-underline-offset: 3px; }
.as-thread:hover span:first-child { text-decoration: underline; text-underline-offset: 3px; }

/* The conversation. */
.as-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; gap: 18px; }
.as-log:focus { outline: none; }
.as-me { align-self: flex-end; max-width: 86%; padding: 10px 14px; border-radius: var(--r-tile); border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; }
.as-a { display: grid; gap: 12px; min-width: 0; }
.as-text { display: grid; gap: 10px; overflow-wrap: anywhere; }
.as-text:empty, .as-extras:empty, .as-chips:empty { display: none; }
.as-extras { display: grid; gap: 12px; }
.as-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.as-chip { min-height: 44px; max-width: 100%; padding: 0 16px; border-radius: var(--r-control); border: 1px solid var(--border); background: transparent; color: var(--foreground); display: inline-flex; align-items: center; font-size: 14px; font-weight: 400; text-decoration: none; text-align: left; cursor: pointer; }
.as-chip:hover { border-color: var(--muted); }
.as-note { font-size: 14px; }
.as-err { color: var(--change); font-size: 14px; }
.as-errbox { display: grid; gap: 8px; justify-items: start; }

.as-empty { margin-top: auto; display: grid; gap: 12px; }
.as-empty > p { font-size: 14px; }
.as-sugg { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }

/* A proposed action. */
.as-card { padding: 16px; border-radius: var(--r-tile); background: var(--card); display: grid; gap: 10px; }
.as-card-t { font-size: 17px; line-height: 1.3; letter-spacing: -0.01em; }
.as-card dl { margin: 0; display: grid; gap: 8px; }
.as-card dl div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.as-card dt { flex: none; }
.as-card dd { margin: 0; text-align: right; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.as-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.as-out { font-size: 14px; }
.as-out:empty { display: none; }
.as-card > a.btn { justify-self: start; }

/* Input. 16px text, so a phone never zooms into the box. */
.as-form { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; gap: 8px; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.as-input.field { min-height: 44px; max-height: 160px; padding: 10px 14px; resize: none; font-size: 16px; line-height: 1.4; }
.as-send { padding: 0 18px; }
.as-send:disabled { cursor: progress; }

/* Show me: the thing asked about, outlined for a moment. */
.as-flash { outline: 2px solid var(--foreground); outline-offset: 4px; border-radius: 4px; animation: as-flash 1.2s ease-out forwards; }
@keyframes as-flash { 0%, 55% { outline-color: var(--foreground); } 100% { outline-color: transparent; } }

@media (prefers-reduced-motion: reduce) {
  .as-flash { animation: none; }
  .as-panel[data-form="sheet"] { transition: none; }
}
