/* == assistant == */
/* The floating assistant (0.2.37 C3, assistant.py): served to OpunX's pages and, with assistant_in_ui, to a client's
   UI folder (ui.py), so every rule is namespaced under #ox-assistant and cannot restyle the page it floats over. Its
   colours follow OpunX's tokens where the page has them and its own otherwise. No inline style: the script only
   toggles classes and the popover (the top layer), and sets a moved element's place through the CSSOM.
   0.2.41 a42: the popped-out panel: a content column (~70%: tabs 1 2 3 like folder tabs, their window, the typing
   bar along the bottom) and a side column (~30%: the "Assistant" handle and the X, the item type, the search, the
   item card, the company / powered by / model corner, the drop zone); at 480 px and under the side column stacks
   under the content.
   Day / night: the host marks a picked mode as data-theme on <html> (OpunX's pages and the demo's looks: the
   opunx-theme cookie; a client UI: its own toggle) and follows the device until then, so the panel
   matches the same selectors (kept under #ox-assistant with :is) and switches live with the page. Each token takes
   the host's OpunX name, then the common client name (--surface, --border, --danger), then the panel's own value
   for that mode; --accent-text has no client fallback, since a client's "on accent" colour can be for one mode. */
#ox-assistant {
  color-scheme: light;
  --ox-bg: var(--panel, var(--surface, #ffffff)); --ox-text: var(--text, #1d1d1b); --ox-muted: var(--muted, #6b6b66);
  --ox-line: var(--line, var(--border, #deded8)); --ox-accent: var(--accent, #2457c5);
  --ox-accent-text: var(--accent-text, #ffffff); --ox-alert: var(--alert, var(--danger, #a32020));
  --ox-sunken: color-mix(in srgb, var(--ox-line) 35%, var(--ox-bg));
  --ox-accent-soft: color-mix(in srgb, var(--ox-accent) 14%, var(--ox-bg));
  /* 0.8 the look (Sean 2026-11-13): sizes, faces, corners and lifts from the host's design tokens */
  --ox-font: var(--font-sans, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  --ox-fs: var(--fs-3, 14px); --ox-space: var(--space-3, 12px); --ox-radius: var(--radius-md, var(--radius, 10px));
  --ox-frame: 3px;  /* a box's square outside to its rounded inside */
  --ox-ink: color-mix(in srgb, var(--ox-text) 22%, transparent);
  --ox-lift: var(--shadow, 0 1px 0 var(--ox-ink), 0 3px 8px -2px var(--ox-ink));
  --ox-float: var(--shadow-lg, 0 2px 0 var(--ox-ink), 0 18px 44px -8px var(--ox-ink));
  position: fixed; right: 16px; bottom: 16px; z-index: 2147483647;
  font: var(--ox-fs)/1.5 var(--ox-font); color: var(--ox-text);
}
@media (prefers-color-scheme: dark) {
  #ox-assistant:is(:root:not([data-theme="light"]) *) {
    color-scheme: dark;
    --ox-bg: var(--panel, var(--surface, #1f201e)); --ox-text: var(--text, #ecece8); --ox-muted: var(--muted, #a2a29b);
    --ox-line: var(--line, var(--border, #34352f)); --ox-accent: var(--accent, #7aa2ff);
    --ox-accent-text: var(--accent-text, #0d1020); --ox-alert: var(--alert, var(--danger, #ff8a8a));
  }
}
#ox-assistant:is(:root[data-theme="dark"] *) {
  color-scheme: dark;
  --ox-bg: var(--panel, var(--surface, #1f201e)); --ox-text: var(--text, #ecece8); --ox-muted: var(--muted, #a2a29b);
  --ox-line: var(--line, var(--border, #34352f)); --ox-accent: var(--accent, #7aa2ff);
  --ox-accent-text: var(--accent-text, #0d1020); --ox-alert: var(--alert, var(--danger, #ff8a8a));
}
#ox-assistant [hidden] { display: none !important; }
#ox-assistant .ox-hidden { display: none; }
#ox-assistant .ox-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
#ox-assistant .ox-open {
  display: inline-flex; align-items: center; padding: 10px 16px; border-radius: 999px; border: 0;
  background: var(--ox-accent); color: var(--ox-accent-text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); touch-action: none;
}
#ox-assistant .ox-panel {
  display: none; position: fixed; inset: auto 16px 72px auto; margin: 0; z-index: 2147483647;
  width: min(780px, calc(100vw - 32px)); height: min(580px, calc(100dvh - 96px));
  flex-direction: row; overflow: hidden; padding: 0; border: 1px solid var(--ox-line); border-radius: 0;
  background: var(--ox-bg); color: var(--ox-text); box-shadow: var(--ox-lift);
}
/* floating: a shadowed window, moved by its header (boxy, docked, has no grab) */
#ox-assistant .ox-panel.ox-floating { border-radius: var(--ox-radius); box-shadow: var(--ox-float); }
#ox-assistant .ox-floating .ox-tabs, #ox-assistant .ox-floating .ox-label { cursor: grab; }
#ox-assistant .ox-panel:popover-open { display: flex; }
#ox-assistant .ox-panel.ox-shown { display: flex; }
#ox-assistant .ox-moving { opacity: .92; cursor: grabbing; }

/* the content column */
#ox-assistant .ox-main {
  flex: 7 1 0; min-width: 0; min-height: 0; display: flex; flex-direction: column;
  border-right: 1px solid var(--ox-line);
}
#ox-assistant .ox-tabs {
  display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px 0; border-bottom: 1px solid var(--ox-line);
  background: var(--ox-sunken); touch-action: none; user-select: none;
}
/* a tab is a box: a thick frame, square outside, its inside edge rounded (the ::before is the rounded inside) */
#ox-assistant .ox-tab {
  position: relative; isolation: isolate; display: inline-flex; align-items: center; gap: 6px; margin: 0 0 6px;
  padding: calc(var(--ox-space) * .5 + var(--ox-frame)) var(--ox-space); border: 0; border-radius: 0;
  background: var(--ox-line); color: var(--ox-text); cursor: pointer; transition: background-color .12s ease;
}
#ox-assistant .ox-tab::before {
  content: ""; position: absolute; inset: var(--ox-frame); z-index: -1; border-radius: var(--ox-radius);
  background: var(--ox-bg);
}
#ox-assistant .ox-tab:hover { background: color-mix(in srgb, var(--ox-accent) 45%, var(--ox-line)); }
#ox-assistant .ox-tab[aria-selected="true"] { background: var(--ox-accent); font-weight: 600; }
#ox-assistant .ox-tab[aria-selected="true"]::before { background: var(--ox-accent-soft); }
@media (prefers-reduced-motion: reduce) { #ox-assistant .ox-tab { transition: none; } }
#ox-assistant .ox-num {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ox-accent); color: var(--ox-accent-text); font-size: 11px; font-weight: 700;
}
#ox-assistant .ox-tabs .ox-small { margin: 0 0 4px auto; padding: 2px 8px; font-size: 12px; }
#ox-assistant .ox-views { flex: 1; min-height: 0; display: flex; }
#ox-assistant .ox-view { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
#ox-assistant .ox-turns { flex: 1; overflow-y: auto; padding: 10px 12px; }
#ox-assistant .ox-turn { margin: 0 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
#ox-assistant .ox-person { text-align: right; color: var(--ox-accent); }
#ox-assistant .ox-note { color: var(--ox-muted); font-size: 13px; margin: 0 0 6px; }
#ox-assistant .ox-card { margin: 0 0 8px; padding: 8px 10px; border: 1px solid var(--ox-line); border-radius: 8px; }
#ox-assistant .ox-card ol { margin: 4px 0; padding-left: 18px; }
#ox-assistant dl { margin: 2px 0 6px; display: grid; grid-template-columns: auto 1fr; gap: 0 8px; }
#ox-assistant dt { color: var(--ox-muted); }
#ox-assistant dd { margin: 0; overflow-wrap: anywhere; }
#ox-assistant .ox-state { color: var(--ox-muted); font-size: 12px; }
#ox-assistant .ox-warn { margin: 4px 0; font-size: 13px; font-weight: 600; }
#ox-assistant .ox-notepad {
  flex: 1; min-height: 120px; margin: 10px 12px 6px; padding: 8px; resize: none; border: 1px solid var(--ox-line);
  border-radius: 8px; background: transparent; color: inherit; font: inherit;
}
#ox-assistant .ox-row { display: flex; align-items: center; gap: 6px; padding: 0 12px 10px; }
#ox-assistant .ox-said { color: var(--ox-muted); font-size: 12px; }
#ox-assistant .ox-empty { margin: auto; padding: 16px; color: var(--ox-muted); text-align: center; }
#ox-assistant .ox-pdf-name { margin: 6px 12px 0; font-size: 12px; color: var(--ox-muted); overflow-wrap: anywhere; }
#ox-assistant .ox-pdf { flex: 1; width: 100%; min-height: 200px; border: 0; background: var(--ox-sunken); }
#ox-assistant .ox-form {
  display: flex; align-items: flex-end; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--ox-line);
}
#ox-assistant .ox-bar { position: relative; flex: 1; min-width: 0; display: flex; }
#ox-assistant .ox-bar textarea {
  flex: 1; min-width: 0; resize: none; padding: 6px 38px 6px 8px; border: 1px solid var(--ox-line); border-radius: 8px;
  background: transparent; color: inherit; font: inherit; line-height: 1.5;
}
#ox-assistant .ox-bar .ox-mic {
  position: absolute; right: 5px; bottom: 5px; display: grid; place-items: center; width: 28px; height: 28px;
  padding: 0; border: 0; border-radius: 50%; color: var(--ox-muted);
}
#ox-assistant .ox-mic svg { width: 16px; height: 16px; fill: currentColor; }
#ox-assistant .ox-bar .ox-mic.ox-listening { background: var(--ox-alert); color: var(--ox-accent-text); }
#ox-assistant .ox-foot { padding: 0 12px 8px; color: var(--ox-muted); font-size: 12px; }

/* the side column */
#ox-assistant .ox-side {
  flex: 3 1 0; min-width: 210px; min-height: 0; display: flex; flex-direction: column; gap: 6px;
  padding: 0 10px 10px; background: var(--ox-sunken);
}
#ox-assistant .ox-side-head { display: flex; align-items: flex-start; justify-content: space-between; }
#ox-assistant .ox-label {
  padding: 3px 12px 4px; border: 1px solid var(--ox-line); border-top: 0; border-radius: 0 0 8px 8px;
  background: var(--ox-bg); font-size: 12px; font-weight: 700; cursor: grab; touch-action: none; user-select: none;
}
#ox-assistant .ox-x { margin-top: 4px; padding: 0 8px; border: 0; font-size: 20px; line-height: 1.4; box-shadow: none; }
#ox-assistant .ox-side-head .ox-mode { margin: 6px 4px 0 auto; padding: 2px 10px; font-size: 12px; }
#ox-assistant .ox-field-label { margin-top: 4px; color: var(--ox-muted); font-size: 12px; }
#ox-assistant .ox-side select,
#ox-assistant .ox-find input {
  width: 100%; min-width: 0; padding: 6px 8px; border: 1px solid var(--ox-line); border-radius: 8px;
  background: var(--ox-bg); color: inherit; font: inherit;
}
#ox-assistant .ox-find { display: flex; gap: 6px; }
#ox-assistant .ox-item {
  flex: 1; min-height: 72px; overflow-y: auto; padding: 8px; border: 1px solid var(--ox-line); border-radius: 8px;
  background: var(--ox-bg);
}
#ox-assistant .ox-item-card select { margin: 4px 0; }
#ox-assistant .ox-item-card button { margin: 4px 4px 0 0; }
#ox-assistant .ox-none { margin: 0; font-weight: 600; color: var(--ox-muted); }
#ox-assistant .ox-docs { margin: 4px 0; padding: 0; list-style: none; }
#ox-assistant .ox-docs li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 4px; }
#ox-assistant .ox-doc-name { flex: 1 1 100%; overflow-wrap: anywhere; font-size: 13px; }
#ox-assistant .ox-link { color: var(--ox-accent); font-size: 13px; margin-right: 8px; }
#ox-assistant .ox-brand {
  position: relative; display: flex; flex-direction: column; align-items: flex-end; margin-top: auto;
  padding: 8px 10px; border: 2px dashed transparent; border-radius: 10px; text-align: right;
}
#ox-assistant .ox-brand.ox-dropping { border-color: var(--ox-accent); background: var(--ox-accent-soft); }
#ox-assistant .ox-brand:focus-within { outline: 2px solid var(--ox-accent); outline-offset: 1px; }
#ox-assistant .ox-logo { font-size: 16px; font-weight: 800; letter-spacing: .02em; overflow-wrap: anywhere; }
#ox-assistant .ox-powered { color: var(--ox-muted); font-size: 10px; }
#ox-assistant .ox-model { font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }

/* an action button is lifted: shadowed, rising under the pointer, pressed down when held */
#ox-assistant button {
  padding: calc(var(--ox-space) * .5) var(--ox-space); border: 1px solid var(--ox-line); border-radius: var(--ox-radius);
  background: var(--ox-bg); color: inherit; font: inherit; cursor: pointer; box-shadow: var(--ox-lift);
  transition: transform .12s ease, box-shadow .12s ease;
}
#ox-assistant button:hover { transform: translateY(-1px); }
#ox-assistant button:active { transform: translateY(1px); box-shadow: none; }
#ox-assistant button.ox-tab, #ox-assistant .ox-bar button.ox-mic { box-shadow: none; transform: none; }
@media (prefers-reduced-motion: reduce) { #ox-assistant button { transition: none; } }
#ox-assistant button.ox-primary { background: var(--ox-accent); border-color: var(--ox-accent); color: var(--ox-accent-text); }
#ox-assistant button.ox-listening { border-color: var(--ox-alert); color: var(--ox-alert); }
#ox-assistant button:focus-visible,
#ox-assistant .ox-label:focus-visible,
#ox-assistant .ox-open:focus-visible { outline: 2px solid var(--ox-accent); outline-offset: 2px; }
/* 0.8 X1a: the unread badge on the button, and the notices under the handle (the look's tokens); kept apart from
   every other rule's selector list (QA 315 M1) */
#ox-assistant .ox-open { position: relative; }
#ox-assistant .ox-badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--ox-alert); color: var(--ox-accent-text); font-size: 11px; line-height: 18px; text-align: center;
}
#ox-assistant .ox-badge[hidden] { display: none; }
#ox-assistant .ox-notices { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
#ox-assistant .ox-notices-head { display: flex; align-items: center; justify-content: space-between; }
#ox-assistant .ox-notice-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow: auto; }
#ox-assistant .ox-notice {
  display: flex; flex-direction: column; padding: 6px 8px; border-left: var(--ox-frame) solid var(--ox-line);
  border-bottom: 1px solid var(--ox-line);
}
#ox-assistant .ox-notice.ox-unread { background: var(--ox-accent-soft); }
#ox-assistant .ox-notice.ox-warning { border-left-color: var(--ox-accent); }
#ox-assistant .ox-notice.ox-bad { border-left-color: var(--ox-alert); }
#ox-assistant .ox-notice-link { color: var(--ox-text); font-weight: 600; }
#ox-assistant .ox-notice-text { color: var(--ox-muted); }
#ox-assistant .ox-notices [hidden] { display: none; }
#ox-assistant .ox-notices-lost { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px;
  border: 1px solid var(--ox-accent); border-radius: var(--ox-radius); background: var(--ox-accent-soft); }
@media (max-width: 480px) {
  #ox-assistant { right: 8px; bottom: 8px; }
  #ox-assistant .ox-panel {
    inset: auto 8px 64px 8px; width: auto; max-width: none; height: calc(100dvh - 80px);
    flex-direction: column; overflow-y: auto;
  }
  #ox-assistant .ox-main { flex: none; min-height: 62%; border-right: 0; border-bottom: 1px solid var(--ox-line); }
  #ox-assistant .ox-side { display: contents; }  /* its handle and X on top, the rest under the content */
  #ox-assistant .ox-side-head { order: -1; padding: 0 10px; background: var(--ox-sunken); }
  #ox-assistant .ox-side > :not(.ox-side-head) { order: 1; flex: none; width: auto; margin: 6px 10px 0; }
  #ox-assistant .ox-side > .ox-brand { margin-bottom: 10px; }
}
