/* The assistant: right-hand panel (any screen) and the full page (#/assistant). EVERY class is prefixed `as-`
   (tests/js/assistant_render.test.mjs checks the prefix against the other stylesheets). Tokens only, from tokens.css.
   Phone: the panel is full screen. */

/* ---- panel */
.as-panel { position: fixed; z-index: 65; top: calc(var(--top-h) + 10px); right: 10px; bottom: 10px; width: min(420px, calc(100vw - 20px)); display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--sh-3); overflow: hidden; animation: as-in .4s var(--ease-drawer) both; }
@keyframes as-in { from { transform: translateX(24px); opacity: 0; } }
.as-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.as-ht { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.as-ht b { font-size: 15px; font-weight: 600; }
.as-av { flex: none; width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: conic-gradient(from 200deg, var(--brand), var(--coral), var(--brand)); color: var(--on-brand); }
.as-av .ic { width: 13px; height: 13px; stroke-width: 2; }
.as-av-lg { width: 48px; height: 48px; border-radius: 14px; } .as-av-lg .ic { width: 24px; height: 24px; }
.as-tools { display: flex; gap: 2px; flex: none; }
.as-ib { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-3); }
.as-ib:hover { background: var(--sunk); color: var(--ink); }
.as-ib.is-on { background: var(--tint); color: var(--brand-2); }
.as-ib .ic { width: 17px; height: 17px; }

.as-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.as-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 16px 14px; overscroll-behavior: contain; }
.as-scroll:focus { outline: none; }

/* ---- a turn */
.as-turn { display: grid; gap: 12px; margin-bottom: 22px; min-width: 0; }
.as-user { justify-self: end; max-width: 86%; background: var(--ink); color: var(--on-brand); border-radius: 16px 16px 4px 16px; padding: 10px 14px; }
.as-user p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 500; }
.as-bot { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start; }
.as-bot-b { min-width: 0; display: grid; gap: 10px; align-content: start; }
.as-answer { display: grid; gap: 8px; min-width: 0; }
.as-p, .as-ul, .as-h { margin: 0; line-height: 1.6; font-size: 14px; overflow-wrap: anywhere; word-break: break-word; }
.as-h { font-size: 14px; font-weight: 600; }
.as-ul { padding-left: 18px; display: grid; gap: 4px; }
.as-period { font-weight: 700; }
.as-fig { display: inline; margin: 0 1px; padding: 0 6px; border: 1px solid var(--tint-2); border-radius: var(--r-xs); background: var(--tint); color: var(--brand-2); font-weight: 750; font-size: inherit; font-variant-numeric: tabular-nums; cursor: help; overflow-wrap: anywhere; }
.as-fig:hover { border-color: var(--brand); }
.as-fig.is-open { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.as-fig-identifier { font-family: var(--mono); font-size: .92em; }
.as-srcnote { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--subtle); color: var(--ink-2); font-size: 12.5px; line-height: 1.45; }
.as-srcnote .ic { width: 15px; height: 15px; margin-top: 1px; color: var(--brand-2); }
.as-sources { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 12.5px; color: var(--ink-3); overflow-wrap: anywhere; }
.as-assume { margin: 0; font-size: 12.5px; color: var(--ink-3); overflow-wrap: anywhere; }
.as-verified { margin: 0; display: inline-flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 700; color: var(--green); }
.as-verified.is-bad { color: var(--amber); }
.as-verified .ic { width: 14px; height: 14px; }
.as-follow, .as-starters, .as-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.as-sugg, .as-opt { max-width: 100%; display: inline-flex; gap: 7px; align-items: center; padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--paper); color: var(--ink); font-size: 13px; font-weight: 650; text-align: left; overflow-wrap: anywhere; }
.as-sugg:hover, .as-opt:hover { background: var(--tint); border-color: var(--tint-2); color: var(--brand-2); }
.as-sugg .ic { width: 15px; height: 15px; }
.as-opt { border-radius: var(--r-sm); padding: 8px 12px; }
.as-tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-sm); max-width: 100%; }
.as-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.as-table th { text-align: left; padding: 6px 9px; background: var(--subtle); color: var(--ink-2); font-weight: 750; white-space: nowrap; border-bottom: 1px solid var(--line); }
.as-table td { padding: 5px 9px; border-top: 1px solid var(--line); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.as-table tr:first-child td { border-top: 0; }

/* ---- status lines, notices, live */
.as-status { margin: 0; display: flex; gap: 8px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 13px; line-height: 1.45; background: var(--sunk); color: var(--ink-2); overflow-wrap: anywhere; }
.as-status .ic { width: 16px; height: 16px; margin-top: 1px; }
.as-tone-ok { background: var(--green-t); border-color: var(--ok-bd); color: var(--ok-ink); }
.as-tone-warn { background: var(--amber-t); border-color: var(--warn-bd); color: var(--warn-ink); }
.as-tone-bad { background: var(--red-t); border-color: var(--bad-bd); color: var(--bad-ink); }
.as-tone-info { background: var(--tint); border-color: var(--info-bd); color: var(--info-ink); }
.as-notice { margin: 0 14px 8px; padding: 8px 11px; border-radius: var(--r-sm); font-size: 13px; background: var(--red-t); color: var(--bad-ink); border: 1px solid var(--bad-bd); }
.as-live { display: flex; gap: 9px; align-items: center; color: var(--ink-3); font-size: 13px; font-weight: 600; min-height: 30px; }
.as-dots { display: inline-flex; gap: 3px; }
.as-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--brand); animation: as-dot 1.1s infinite ease-in-out; }
.as-dots i:nth-child(2) { animation-delay: .15s; } .as-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes as-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.as-spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--tint-2); border-top-color: var(--brand); animation: as-turn .8s linear infinite; }
@keyframes as-turn { to { transform: rotate(360deg); } }
.as-ask { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--info-bd); border-radius: var(--r-sm); background: var(--tint); }
.as-ask p { margin: 0; overflow-wrap: anywhere; }

/* ---- how I got this, plan */
.as-steps { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--subtle); min-width: 0; }
.as-steps-t { width: 100%; display: flex; gap: 6px; align-items: center; padding: 7px 10px; border: 0; background: none; font-size: 13px; font-weight: 750; color: var(--ink-2); text-align: left; }
.as-steps-t .ic { width: 15px; height: 15px; color: var(--ink-3); }
.as-steps-b { padding: 0 10px 10px; display: grid; gap: 10px; }
.as-steplist, .as-plan { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.as-step { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-2); }
.as-step-l { overflow-wrap: anywhere; }
.as-step .ic, .as-plan-i .ic { width: 15px; height: 15px; }
.as-step.is-ok .ic { color: var(--green); } .as-step.is-error .ic { color: var(--red); } .as-step.is-refused .ic, .as-step.is-proposed .ic { color: var(--amber); }
.as-step-ms { font-size: 12px; font-variant-numeric: tabular-nums; }
.as-plan-i { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.as-plan-i.is-done .ic { color: var(--green); } .as-plan-i.is-doing .ic { color: var(--brand); } .as-plan-i.is-blocked .ic { color: var(--red); }

/* ---- proposed action (confirm card) */
.as-card { border: 1px solid var(--warn-bd); border-radius: var(--r-sm); background: var(--paper); overflow: hidden; }
.as-card-h { flex-wrap: wrap; display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--amber-t); color: var(--warn-ink); font-size: 13px; }
.as-card-h .ic { width: 15px; height: 15px; }
.as-card-b { padding: 10px 12px; display: grid; gap: 4px; overflow-wrap: anywhere; }
.as-card-b p { margin: 0; font-size: 13px; }
.as-card-warn { margin: 0; padding: 8px 12px; background: var(--amber-t); color: var(--warn-ink); font-size: 13px; border-bottom: 1px solid var(--warn-bd); }
.as-card-rows, .as-card-items { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 3px; font-size: 13px; white-space: pre-wrap; }
.as-card-after { font-weight: 600; }
.as-card-head-figs { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 3px; font-size: 13px; }
.as-card-head-figs li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; padding: 4px 8px; border-radius: var(--r-xs); background: var(--sunk); font-variant-numeric: tabular-nums; }
.as-card-sub { margin: 6px 0 0 !important; font-size: 12px !important; font-weight: 750; color: var(--ink-3); }
.as-card-problem { color: var(--bad-ink); }
.as-card-items { list-style: none; padding-left: 0; }
.as-card-items li.is-off { opacity: .6; text-decoration: line-through; }
.as-tick { display: flex; gap: 8px; align-items: flex-start; min-height: 28px; cursor: pointer; white-space: normal; }
.as-tick input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--brand); }
.as-risk { padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; font-size: 11.5px; font-weight: 750; white-space: nowrap; }
.as-risk-decide { background: var(--red-t); color: var(--bad-ink); }
.as-risk-write, .as-risk-transition { background: var(--paper); color: var(--warn-ink); }
.as-risk-draft { background: var(--tint); color: var(--brand-2); }
.as-note { display: grid; gap: 4px; margin-top: 6px; }
.as-note label { font-size: 12.5px; font-weight: 750; }
.as-note-in { width: 100%; min-height: 56px; resize: vertical; font-size: 14px; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--paper); color: var(--ink); }
.as-note-in:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.as-card-err { margin: 0; display: flex; gap: 8px; padding: 8px 12px; background: var(--red-t); color: var(--bad-ink); font-size: 13px; border-top: 1px solid var(--bad-bd); overflow-wrap: anywhere; }
.as-card-err .ic { flex: none; width: 15px; height: 15px; margin-top: 2px; }
.as-card-btns { display: flex; gap: 8px; margin-left: auto; }
.as-card-btns button { min-height: 36px; }
.as-card-exp { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.as-card-res { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; padding: 9px 12px; border-top: 1px solid var(--line); font-size: 13px; overflow-wrap: anywhere; }
.as-ct-ok { border-color: var(--ok-bd); } .as-ct-ok .as-card-h { background: var(--green-t); color: var(--ok-ink); }
.as-card.as-ct-bad { border-color: var(--bad-bd); }
.as-card.as-ct-bad .as-card-h { background: var(--red-t); color: var(--bad-ink); }
.as-card.as-ct-neutral { border-color: var(--line); } .as-card.as-ct-neutral .as-card-h { background: var(--sunk); color: var(--ink-2); }
.as-card.as-ct-neutral .as-card-b, .as-card.is-expired .as-card-b, .as-card.is-superseded .as-card-b { opacity: .75; }
.as-card:focus { outline: none; box-shadow: var(--focus); }
.as-card-f { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 12.5px; flex-wrap: wrap; }

/* ---- empty, history, help */
.as-empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 28px 8px 8px; }
.as-empty h3 { margin: 4px 0 0; font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.as-empty .as-starters { justify-content: center; margin-top: 8px; }
.as-history { display: grid; gap: 4px; align-content: start; padding: 4px 2px; }
.as-new { display: flex; gap: 8px; align-items: center; width: 100%; padding: 9px 11px; border: 1px dashed var(--line-2); border-radius: var(--r-sm); background: none; color: var(--brand-2); font-weight: 750; font-size: 13.5px; }
.as-new:hover { background: var(--tint); }
.as-new .ic { width: 16px; height: 16px; }
.as-hgroup { display: grid; gap: 2px; margin-top: 10px; }
.as-hgroup h4 { margin: 0 0 2px 4px; font-size: 12px; font-weight: 800; color: var(--ink-3); }
.as-hitem { display: grid; gap: 1px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: none; text-align: left; min-width: 0; }
.as-hitem:hover { background: var(--sunk); }
.as-hitem.is-on { background: var(--tint); }
.as-hitem b { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-help { display: grid; gap: 10px; align-content: start; }
.as-help h3 { margin: 0; font-size: 16px; font-weight: 800; }
.as-help p { margin: 0; font-size: 13px; }
.as-cap h4 { margin: 4px 0 6px; font-size: 13px; font-weight: 800; }
.as-cap ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.as-cap li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.as-cap .ic { width: 15px; height: 15px; color: var(--green); margin-top: 2px; }
.as-link { display: inline; padding: 0; border: 0; background: none; color: var(--brand-2); font-weight: 750; font-size: 12.5px; text-align: left; text-decoration: underline; text-underline-offset: 3px; }
.as-legacy a { font-size: 12.5px; }

/* ---- composer */
.as-composer { flex: none; margin: 0 12px 12px; padding: 8px 10px 8px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--paper); box-shadow: var(--sh); display: grid; gap: 6px; }
.as-composer:focus-within { border-color: var(--brand); box-shadow: var(--focus); }
.as-ctx { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.as-ctx:empty { display: none; }
.as-chip { display: inline-flex; gap: 5px; align-items: center; max-width: 100%; padding: 2px 3px 2px 8px; border: 1px solid var(--tint-2); border-radius: 999px; background: var(--tint); color: var(--brand-2); font-size: 12.5px; font-weight: 700; }
.as-chip .ic { width: 13px; height: 13px; }
.as-chip-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.as-chip-x { width: 20px; height: 20px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--brand-2); padding: 0; }
.as-chip-x:hover { background: var(--tint-2); }
.as-chip-x .ic { width: 12px; height: 12px; }
.as-input { width: 100%; min-height: 28px; max-height: 150px; resize: none; border: 0; border-radius: 0; background: transparent; padding: 5px 2px; font-size: 14px; line-height: 1.45; box-shadow: none; overflow-y: auto; }
.as-input:focus, .as-input:focus-visible { outline: none; box-shadow: none; }
.as-input::placeholder { color: var(--ink-3); }
.as-cbar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.as-send { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--brand); color: var(--on-brand); padding: 0; }
.as-send:hover { background: var(--brand-2); }
.as-send[disabled] { opacity: .35; pointer-events: none; }
.as-send .ic { width: 16px; height: 16px; }
.as-stop { display: inline-flex; gap: 7px; align-items: center; height: 32px; padding: 0 13px; border: 0; border-radius: 999px; background: var(--ink); color: var(--paper); font-weight: 750; font-size: 13px; }
.as-stop .ic { width: 13px; height: 13px; }
.as-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.as-muted { color: var(--ink-3); }
.as-pad { padding: 8px 6px; margin: 0; }

/* ---- full page */
.as-page { display: grid; grid-template-columns: 250px minmax(0, 1fr) 290px; gap: 16px; height: calc(100dvh - var(--top-h) - var(--d-page-y) * 2 - 12px); min-height: 440px; }
.as-page-side, .as-page-help, .as-page-main { min-width: 0; min-height: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); }
.as-page-side, .as-page-help { overflow-y: auto; padding: 12px; }
.as-page-main { display: flex; flex-direction: column; overflow: hidden; }
.as-page-main .as-scroll { padding: 18px 22px; }
.as-page-main .as-composer { margin: 0 18px 16px; }
.as-page-main .as-notice { margin: 0 18px 8px; }
@media (max-width: 1240px) { .as-page { grid-template-columns: 240px minmax(0, 1fr); } .as-page-help { display: none; } }
@media (max-width: 900px) { .as-page { grid-template-columns: minmax(0, 1fr); } .as-page-side { display: none; } }

/* ---- phone: the panel is the whole screen */
@media (max-width: 760px) {
  .as-panel { top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100dvh; border: 0; border-radius: 0; z-index: 80; padding-bottom: env(safe-area-inset-bottom); animation: as-up .22s var(--ease); }
  @keyframes as-up { from { transform: translateY(30px); opacity: 0; } }
    .as-composer { margin: 0 10px 10px; }
  .as-page { height: calc(100dvh - 56px - 66px - 30px); min-height: 380px; }
  .as-page-main .as-scroll { padding: 14px; }
  .as-page-main .as-composer { margin: 0 10px 10px; }
  body.as-open { overflow: hidden; }
}

/* ---- confirm card: phone, reduced motion */
@media (max-width: 760px) {
  .as-card-f { flex-direction: column; align-items: stretch; }
  .as-card-btns { margin-left: 0; } .as-card-btns button { flex: 1 1 0; min-height: 44px; }
  .as-tick { min-height: 40px; align-items: center; } .as-tick input { width: 22px; height: 22px; margin: 0; }
  .as-card-res button { min-height: 44px; }
}
.as-card { transition: border-color .15s, background .15s; }
@media (prefers-reduced-motion: reduce) { .as-card, .as-card * { transition: none !important; animation: none !important; } }
