/* Assistent: docked panel (desktop), bottom sheet (tablet), full screen (phone); anchors. */
:root { --as-w: 400px; }
.as { position: fixed; top: var(--head-h); right: 0; bottom: 0; width: var(--as-w); display: flex; flex-direction: column; background: var(--sheet); border-left: 1px solid var(--line); z-index: 25; }
.as[hidden] { display: none; }
.as-resize { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; }
.as-resize:hover, .as-resize.on { background: var(--accent-soft); }
.as-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--paper-2); }
.as-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.as-title b { font-size: var(--fs-14); }
.as-sub { font-size: var(--fs-12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-body { flex: 1; min-height: 0; overflow: auto; padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.as-empty { margin: auto 0; }
.as-hello { text-align: center; padding: 24px 12px; color: var(--ink-2); }
.as-hello svg { width: 32px; height: 32px; color: var(--accent); margin-bottom: 10px; }
.as-hello h3 { margin-bottom: 6px; color: var(--ink); }
.as-msgs { display: flex; flex-direction: column; gap: 10px; }
.as-msg { display: flex; }
.as-msg.user { justify-content: flex-end; }
.as-bubble { max-width: 92%; padding: 9px 12px; border-radius: var(--r-3); font-size: var(--fs-14); line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; }
.as-msg.user .as-bubble { background: var(--accent-soft); color: var(--accent-ink); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.as-msg.assistant .as-bubble { background: var(--paper-2); border-bottom-left-radius: 4px; max-width: 100%; }
.as-md > * + * { margin-top: 8px; }
.as-md ul, .as-md ol { padding-left: 20px; }
.as-md li + li { margin-top: 2px; }
.as-md h3, .as-md h4, .as-md h5 { font-size: var(--fs-14); font-weight: 600; }
.as-md code { font-family: var(--font-mono); font-size: 0.92em; background: var(--paper-3); padding: 1px 4px; border-radius: 3px; }
.as-md pre { background: var(--paper-3); padding: 8px 10px; border-radius: var(--r-2); overflow: auto; font-size: var(--fs-13); }
.as-md blockquote { border-left: 3px solid var(--line-strong); padding-left: 10px; color: var(--ink-2); }
.as-table { overflow: auto; margin: 0 -4px; }
.as-table .table { width: 100%; font-size: var(--fs-13); }
.as-table th, .as-table td { padding: 4px 6px; white-space: nowrap; }
.as-tool { border: 1px solid var(--line); border-radius: var(--r-2); background: var(--sheet); font-size: var(--fs-13); }
.as-tool-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; background: none; cursor: pointer; text-align: left; color: var(--ink-2); font: inherit; }
.as-tool-head svg { width: 14px; height: 14px; margin-left: auto; transition: transform var(--t-fast) var(--ease); }
.as-tool-head[aria-expanded=true] svg { transform: rotate(180deg); }
.as-tool-name { color: var(--ink); font-weight: 500; }
.as-tool.ok .as-tool-state { color: var(--ok); }
.as-tool.err .as-tool-state { color: var(--danger); }
.as-tool.err { border-color: var(--danger-soft); }
.as-tool-detail { border-top: 1px solid var(--line); padding: 6px 8px; display: grid; gap: 6px; }
.as-tool-args, .as-tool-result { white-space: pre-wrap; word-break: break-word; font-size: var(--fs-12); color: var(--ink-2); max-height: 220px; overflow: auto; }
.as-tool-result:empty, .as-tool-args:empty { display: none; }
.as-spin { width: 12px; height: 12px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: as-spin .8s linear infinite; flex: none; }
@keyframes as-spin { to { transform: rotate(360deg); } }
.as-note { font-size: var(--fs-13); color: var(--ink-2); text-align: center; padding: 4px 8px; }
.as-note.err { color: var(--danger); background: var(--danger-soft); border-radius: var(--r-2); text-align: left; }
.as-approval { padding: 10px 12px; border: 1px solid var(--warn); background: var(--warn-soft); }
.as-approval-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--warn); }
.as-approval-head svg { width: 16px; height: 16px; }
.as-approval-what pre { margin: 4px 0 0; white-space: pre-wrap; font-size: var(--fs-12); color: var(--ink-2); }
.as-approval-actions { justify-content: flex-end; gap: 8px; margin-top: 8px; }
.as-approval.approved { border-color: var(--ok); background: var(--ok-soft); }
.as-approval.denied { opacity: .7; }
.as-foot { border-top: 1px solid var(--line); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--sheet); display: flex; flex-direction: column; gap: 6px; }
.as-chips { display: flex; flex-wrap: wrap; gap: 4px; min-height: 0; }
.as-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: var(--fs-12); color: var(--ink-2); background: var(--paper); max-width: 100%; }
.as-chip.fixed { padding-right: 8px; color: var(--accent-ink); background: var(--accent-soft); border-color: transparent; }
.as-chip button { border: 0; background: none; padding: 0; width: 16px; height: 16px; display: grid; place-items: center; color: var(--ink-3); cursor: pointer; border-radius: 50%; }
.as-chip button:hover { color: var(--ink); background: var(--paper-3); }
.as-chip button svg { width: 11px; height: 11px; }
.as-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.as-suggest:empty { display: none; }
.as-sug { border: 1px solid var(--line-strong); background: var(--sheet); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: var(--fs-13); color: var(--ink-2); cursor: pointer; text-align: left; }
.as-sug:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.as-compose { display: flex; gap: 6px; align-items: flex-end; }
.as-compose textarea { flex: 1; resize: none; min-height: 60px; max-height: 220px; line-height: 1.4; padding: 9px 10px; }
.as-compose .btn.icon { width: 36px; min-height: 36px; flex: none; }
.as-row { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; font-size: var(--fs-12); flex-wrap: wrap; }
.as-kbd { flex: 1 1 220px; text-align: right; }
.as-model { display: inline-flex; align-items: center; gap: 6px; }
.as-model select { min-height: 26px; padding: 2px 26px 2px 8px; font-size: var(--fs-12); min-width: 150px; max-width: 260px; }
.as-threads { border-bottom: 1px solid var(--line); max-height: 45%; overflow: auto; background: var(--paper); }
.as-thread { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.as-thread:hover, .as-thread.on { background: var(--sheet); }
.as-thread .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-13); }
.as-thread .d { font-size: var(--fs-12); white-space: nowrap; }
.as-pad { padding: 10px 12px; }
#assistant-toggle svg { width: 18px; height: 18px; color: var(--accent); }
#assistant-toggle[aria-expanded=true] { background: var(--accent-soft); }

/* the page makes room for the docked panel */
@media (min-width: 1000px) {
  body.as-open #view { margin-right: var(--as-w); }
  body.as-open #toasts { right: calc(var(--as-w) + 16px); }
}
/* tablet: bottom sheet */
@media (max-width: 999px) {
  .as { top: auto; left: 0; right: 0; width: auto; height: min(72dvh, 640px); border-left: 0; border-top: 1px solid var(--line); border-radius: var(--r-3) var(--r-3) 0 0; box-shadow: var(--shadow-2); }
  .as-resize { display: none; }
  .as-kbd { display: none; }
}
/* phone: full screen under the top bar */
@media (max-width: 600px) {
  .as { top: var(--head-h); height: auto; border-radius: 0; box-shadow: none; }
  .as-body { padding: 10px 10px 6px; }
  .as-bubble { max-width: 96%; }
  .as-row { flex-wrap: wrap; }
  .as-table th, .as-table td { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) { .as-body { scroll-behavior: auto; } .as-spin { animation: none; } }

/* point_at anchors */
.as-pulse { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: var(--r-2); animation: as-pulse 1.1s ease-in-out 3; }
@keyframes as-pulse { 0%, 100% { outline-color: var(--accent); } 50% { outline-color: transparent; } }
.as-tip { position: absolute; z-index: 60; padding: 6px 10px; font-size: var(--fs-13); max-width: 260px; pointer-events: none; border: 1px solid var(--accent); }


/* Explain buttons on Statistiek tiles */
.ov-kpi { position: relative; }
.ov-explain { position: absolute; top: 4px; right: 4px; opacity: .4; }
.ov-explain svg { color: var(--accent); }
.ov-kpi:hover .ov-explain, .ov-explain:focus-visible { opacity: 1; }
@media (hover: none) { .ov-explain { opacity: .7; } }
/* admin / platform sections */
.as-admin { padding: 14px 16px; }
.as-admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; margin-top: 12px; }
.as-admin-grid .field > .row { margin: 4px 0; flex-wrap: wrap; }
.as-admin-grid .input { max-width: 420px; }
.as-usage-total { font-size: var(--fs-16); }
@media (max-width: 720px) { .as-admin-grid { grid-template-columns: 1fr; } }

/* shared conversation page: one centred reading column, header and transcript aligned */
.page.as-shared { max-width: 1100px; margin: 0 auto; }
.as-shared-body { padding: 18px 20px; gap: 12px; }
.as-shared .as-msg.assistant .as-bubble { max-width: 100%; }
.as-shared .as-msg.user .as-bubble { max-width: 70%; }
.as-shared .as-table th, .as-shared .as-table td { white-space: normal; }
@media (max-width: 720px) { .as-shared-body { padding: 12px; } .as-shared .as-msg.user .as-bubble { max-width: 92%; } }
.as-thread .t svg { width: 12px; height: 12px; vertical-align: -1px; margin-right: 4px; color: var(--accent); }
[data-share].on svg { color: var(--accent); }

/* charts in answers */
.as-chart { position: relative; margin: 10px 0 6px; }
.as-chart figcaption { font-weight: 600; font-size: var(--fs-13); margin-bottom: 4px; }
.as-chart-legend { display: flex; flex-wrap: wrap; gap: 2px 12px; list-style: none; padding: 0; margin: 0 0 4px; font-size: var(--fs-12); color: var(--ink-2); }
.as-chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.as-chart-svg { width: 100%; }
.as-chart svg { width: 100%; height: auto; display: block; touch-action: none; overflow: visible; font-family: var(--font); }
.as-chart .grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.as-chart .grid.zero { stroke: var(--line-strong); }
.as-chart .axis-text { fill: var(--ink-3); font-size: 11px; }
.as-chart .end-label { fill: var(--ink-2); font-size: 11px; }
.as-chart .as-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.as-chart .area { opacity: .14; }
.as-chart .dot { stroke: var(--sheet); stroke-width: 2; }
.as-chart .dot.hover { r: 5.5; }
.as-chart .bar.hover { filter: brightness(.88); }
.as-chart .crosshair { stroke: var(--ink-3); stroke-width: 1; display: none; pointer-events: none; }
.as-chart-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--sheet); border: 1px solid var(--line-strong); border-radius: var(--r-2); padding: 6px 9px; font-size: var(--fs-12); box-shadow: var(--shadow-1); min-width: 120px; }
.as-chart-tip[hidden] { display: none; }
.as-chart-tip-x { color: var(--ink-2); margin-bottom: 3px; }
.as-chart-tip-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.as-chart-tip-row i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.as-chart-tip-row b { font-family: var(--font-mono); font-weight: 600; }
.as-chart-tip-row span { color: var(--ink-2); }
.as-chart-note { font-size: var(--fs-12); margin-top: 2px; }
.as-chart-table summary { font-size: var(--fs-12); color: var(--ink-2); cursor: pointer; margin-top: 4px; }
.as-chart-table .as-table { max-height: 240px; overflow: auto; margin-top: 4px; }
.as-chart-pending, .as-chart-error { font-size: var(--fs-13); color: var(--ink-2); padding: 8px 10px; border: 1px dashed var(--line-strong); border-radius: var(--r-2); }

/* thinking indicator */
.as-thinking { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: var(--fs-12); padding: 2px 6px; }
.as-dots { display: inline-flex; gap: 3px; }
.as-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); opacity: .35; animation: as-dot 1.2s ease-in-out infinite; }
.as-dots i:nth-child(2) { animation-delay: .18s; }
.as-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes as-dot { 0%, 70%, 100% { opacity: .3; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }
#assistant-toggle.busy svg { animation: as-glow 1.4s ease-in-out infinite; }
@keyframes as-glow { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .as-dots i { animation: none; opacity: .7; } #assistant-toggle.busy svg { animation: none; } }
