/* The knowledge assistant's chat (T-3058, T-4138, T-4283): one column, readable at 320 px, the
   accent colour a deployment chooses on --accent. System fonts, no image, no font file. The full
   page (/d/{publicId}) centres the same column; the launcher's panel shows it edge to edge. The
   page itself never scrolls: the conversation is the one scroll area, between a header and a
   composer that stay put. Contrast is AA in both schemes. */
:root {
  --accent: #1f5fae; --on-accent: #ffffff; --link: var(--accent);
  --fg: #1a1d21; --muted: #555e69; --bg: #ffffff; --line: #d9dee4; --soft: #f2f4f7; --bubble: var(--soft);
  --radius: 12px; --radius-s: 8px; --pill: 999px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%);
}
@media (prefers-color-scheme: dark) {
  /* Text in the accent would be too dark on a dark page: links and chips take a light blue (AA). */
  :root { --fg: #eef1f5; --muted: #aab4c0; --bg: #15181c; --line: #343b44; --soft: #1f242a; --bubble: #23292f;
    --link: #9cc3ff; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--fg); background: var(--bg); }
.jc-chat { display: flex; flex-direction: column; height: 100%; height: 100dvh; }
.jc-page .jc-chat { max-width: 760px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.jc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.jc-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* The header: the body's monogram and name, the language toggle, New conversation. */
.jc-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px max(12px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); background: var(--bg); }
.jc-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.jc-avatar { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 14px; letter-spacing: .02em; }
.jc-avatar .jc-icon { width: 18px; height: 18px; }
.jc-title { margin: 0; display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.jc-name { font-size: 16px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jc-role { font-size: 12px; font-weight: 400; color: var(--muted); }
.jc-actions { flex: none; display: flex; align-items: center; gap: 6px; }
.jc-actions [hidden], .jc-form[hidden] { display: none; }
.jc-langs { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--soft); }
.jc-langs button { min-width: 40px; min-height: 32px; padding: 0 10px; border: 0; border-radius: var(--pill);
  background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.jc-langs button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); box-shadow: 0 1px 3px rgb(16 24 40 / 15%); }
.jc-icon-button { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; padding: 0;
  border: 0; border-radius: var(--pill); background: transparent; color: var(--muted); cursor: pointer; }
.jc-icon-button:hover { background: var(--soft); color: var(--fg); }
.jc-icon-button:disabled { opacity: .5; cursor: default; }
.jc-tools { flex: none; margin: 0; padding: 6px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.jc-tools summary { cursor: pointer; color: var(--muted); }
.jc-tools label { display: inline-flex; gap: 6px; align-items: center; margin: 6px 12px 0 0; }

/* The conversation: the only scroll area. */
.jc-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px 4px; margin: 0; list-style: none;
  display: flex; flex-direction: column; }
/* Where the panel is taller than the conversation (a phone's full screen), the conversation sits
   on the composer, as in a messenger; scrolling up still reaches its start. */
.jc-log > :first-child { margin-top: auto; }
/* A fresh chat reads from the top: the greeting under the header, its suggestions under it (T-4592). */
.jc-log > .jc-intro:first-child { margin-top: 0; }
.jc-log > li { margin: 0 0 14px; overflow-wrap: anywhere; }
.jc-you { display: flex; flex-wrap: wrap; justify-content: flex-end; }
.jc-time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.jc-you .jc-time { flex-basis: 100%; text-align: right; margin-top: 2px; }
.jc-you p { margin: 0; max-width: 85%; padding: 9px 13px; border-radius: 18px 18px 4px 18px; background: var(--accent);
  color: var(--on-accent); white-space: pre-wrap; }
.jc-bot { max-width: 100%; }
.jc-bot > .jc-answer { padding: 10px 13px; border-radius: 18px 18px 18px 4px; background: var(--bubble); }
.jc-answer p { margin: 0 0 8px; }
.jc-answer p:last-child, .jc-answer ul:last-child, .jc-answer ol:last-child { margin-bottom: 0; }
.jc-answer ul, .jc-answer ol { margin: 0 0 8px; padding-left: 20px; }
.jc-answer li, .jc-part li { margin: 0 0 4px; padding: 0; }
.jc-answer code { font-size: 13px; background: var(--bg); padding: 0 4px; border-radius: 4px; }
.jc-answer a, .jc-cite a { color: var(--link); }
/* A citation is a small numbered pill, a 22 px target inside the sentence (WCAG 2.5.8 exempts inline targets;
   the 44 px ones are the source rows under the answer). */
.jc-cite { font-size: 11px; margin-left: 2px; vertical-align: 2px; line-height: 1; }
.jc-cite a { display: inline-block; min-width: 18px; padding: 3px 4px; border-radius: var(--pill); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line);
  text-align: center; text-decoration: none; font-weight: 600; }
.jc-answer table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 0 0 8px; font-size: 13px; }
.jc-answer th, .jc-answer td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.jc-answer th { background: var(--bg); font-weight: 600; }
.jc-answer pre { margin: 0 0 8px; padding: 8px 10px; overflow-x: auto; background: var(--bg); border-radius: 8px; }
.jc-answer pre code { padding: 0; background: none; }
.jc-status { margin: 0; padding: 8px 2px; font-size: 13px; color: var(--muted); }

/* The empty chat: greeting, then the deployment's questions as compact chips in a wrapping row. */
.jc-log > li.jc-intro { margin-bottom: 8px; }
.jc-greeting { margin: 2px 0 12px; white-space: pre-wrap; font-size: 16px; }
.jc-suggest { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.jc-log .jc-suggest li { margin: 0; padding: 0; }
.jc-suggest button { min-height: 36px; padding: 7px 12px; text-align: left; border: 1px solid var(--line);
  border-radius: var(--pill); background: var(--bg); color: var(--link); font: inherit; font-size: 13.5px; line-height: 1.3; cursor: pointer; }
.jc-suggest button:hover { border-color: var(--accent); background: var(--soft); }
.jc-followups { margin-top: 10px; }

/* The first open: the language before anything else (T-4283 item 13). */
/* The close button stays, so a phone's full-screen chooser is never a dead end. */
.jc-choosing .jc-langs, .jc-choosing .jc-fresh, .jc-choosing .jc-foot { display: none; }
.jc-choose { padding: 16px 0; text-align: center; }
.jc-log > .jc-choose:first-child { margin-block: auto; }
.jc-choose-title { margin: 0 0 16px; font-size: 17px; font-weight: 600; }
.jc-choose-list { display: flex; flex-direction: column; gap: 10px; max-width: 280px; margin: 0 auto; }
.jc-choose-list button { min-height: 48px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--bg);
  color: var(--link); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
.jc-choose-list button:first-child { background: var(--accent); color: var(--on-accent); }

/* Sources: a compact numbered list under the footer row, closed until its count opens it (T-4364). */
.jc-cards { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
/* One line per source: number, title, host; what the page publishes (its parts) wraps under it. */
.jc-log .jc-cards > li { margin: 0; padding: 5px 10px 5px 34px; position: relative; border: 1px solid var(--line);
  border-radius: var(--radius-s); background: var(--bg); font-size: 13px; display: flex; flex-wrap: wrap; align-items: baseline;
  column-gap: 8px; }
.jc-cards > li > .jc-part { flex-basis: 100%; }
.jc-cards[hidden] { display: none; }
.jc-card-n { position: absolute; left: 9px; top: 7px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-size: 11px; line-height: 18px; text-align: center; }
.jc-cards a { flex: 0 1 auto; min-width: 0; color: var(--link); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jc-domain { flex: none; margin-left: auto; color: var(--muted); font-size: 12px; }
.jc-part { margin-top: 6px; padding: 6px 8px; border-radius: 6px; background: var(--soft); overflow-wrap: anywhere; }
.jc-part p { margin: 2px 0; }
.jc-part ol { margin: 4px 0 0; padding-left: 20px; }
.jc-part a { font-weight: 400; white-space: normal; }

/* One quiet row under the answer (T-4364): who and when, copy, the verdict, then the sources'
   badges and count; icon actions keep a visible outline, so they read as buttons. */
.jc-answer-tools { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.jc-by { color: var(--muted); font-size: 12px; white-space: nowrap; }
.jc-by .jc-time { font-size: 12px; }
.jc-sources { margin-left: auto; min-height: 32px; padding: 0 8px; display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: var(--pill); background: none; color: var(--muted); font: inherit; font-size: 12px;
  white-space: nowrap; cursor: pointer; }
.jc-sources:hover { background: var(--soft); }
.jc-badges { display: inline-flex; }
.jc-badge { width: 18px; height: 18px; margin-left: -5px; border: 2px solid var(--bg); border-radius: 50%;
  background: var(--badge, var(--accent)); color: #fff; font-size: 10px; font-weight: 700; line-height: 18px; text-align: center;
  box-sizing: content-box; }
.jc-badge:first-child { margin-left: 0; }
.jc-chevron { width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg); }
.jc-sources[aria-expanded="true"] .jc-chevron { transform: translateY(2px) rotate(-135deg); }
.jc-answer-tools .jc-icon-button { min-width: 32px; min-height: 32px; border: 1px solid var(--line); background: var(--bg); }
.jc-answer-tools .jc-icon { width: 17px; height: 17px; }
.jc-note { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.jc-note textarea { flex: 1 1 100%; min-height: 48px; font: inherit; color: inherit; background: var(--bg);
  padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-s); }
.jc-note button { min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--pill);
  background: var(--bg); color: var(--fg); font: inherit; font-size: 13px; cursor: pointer; }
.jc-thanks { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

/* A data answer's table, chart and links (T-4140, T-4198). */
.jc-data { margin: 0 0 10px; }
.jc-data-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--bg); }
.jc-data table { border-collapse: collapse; width: 100%; font-size: 13px; }
.jc-data caption { text-align: left; padding: 6px 8px; color: var(--muted); }
.jc-data th, .jc-data td { padding: 4px 8px; border-top: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: top; }
/* T-4650: the name wraps within 40 % of the table, so a value column shows at 400 px; a long text
   keeps two lines, numbers line up on the right. */
.jc-data th:first-child, .jc-data td:first-child { white-space: normal; max-width: 40%; min-width: 7em; }
.jc-data td:first-child .jc-cell, .jc-data td .jc-cell { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.jc-data td:first-child .jc-cell { overflow-wrap: anywhere; }
.jc-data .jc-num { text-align: right; font-variant-numeric: tabular-nums; }
.jc-data-chart { display: block; width: 100%; height: auto; margin: 6px 0 0; }
.jc-chart-axis { stroke: var(--line); }
.jc-chart-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.jc-chart-bar { fill: var(--accent); }
.jc-chart-text { fill: var(--muted); font-size: 10px; }
.jc-data-links { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0 0; font-size: 13px; }
.jc-data-links a { color: var(--link); }
.jc-steps { margin-top: 6px; font-size: 13px; color: var(--muted); }
.jc-steps summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.jc-steps ol { margin: 0 0 4px; padding-left: 20px; }
.jc-script summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.jc-script pre { font-size: 12px; overflow-x: auto; background: var(--soft); padding: 8px; border-radius: 6px; }

/* A failed answer is one quiet line and its Retry, not an alarm (T-4253). */
.jc-log li.jc-error { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 13px;
  border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.jc-error > p { flex: 1 1 12em; margin: 0; }
.jc-retry { min-height: 36px; padding: 0 12px; border: 1px solid var(--accent); border-radius: var(--pill); background: var(--bg);
  color: var(--link); font: inherit; font-size: 13px; cursor: pointer; }

/* The composer: one bar, the labelled send button inside its border; the notice under it, whole. */
.jc-foot { flex: none; padding: 8px max(12px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: var(--bg); }
.jc-form { display: flex; align-items: flex-end; gap: 6px; min-height: 50px; box-sizing: border-box; padding: 5px 5px 5px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg); box-shadow: var(--shadow); }
.jc-form:focus-within { border-color: var(--accent); }
.jc-form textarea::placeholder { color: var(--muted); opacity: 1; }
.jc-form textarea { flex: 1; min-height: 36px; max-height: 160px; padding: 7px 0; resize: none; border: 0; outline: none;
  font: inherit; color: inherit; background: transparent; }
.jc-send { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border: 0;
  border-radius: 10px; background: var(--accent); color: var(--on-accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.jc-send:hover { filter: brightness(1.1); }
.jc-send:disabled { opacity: .5; cursor: default; }
.jc-send svg { width: 18px; height: 18px; }
.jc-form .jc-stop { background: var(--fg); color: var(--bg); }
.jc-form button[hidden] { display: none; }
.jc-more { padding: 0; border: 0; background: none; color: var(--link); font: inherit; text-decoration: underline; cursor: pointer; }
.jc-privacy-line { margin: 6px 4px 0; font-size: 11.5px; line-height: 1.4; color: var(--muted); }
/* The privacy dialog (T-4670): over the chat, inside the panel's own page. */
.jc-about { max-width: min(360px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; box-sizing: border-box;
  padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--fg);
  box-shadow: var(--shadow); font-size: 14px; line-height: 1.45; }
.jc-about::backdrop { background: rgba(0, 0, 0, .35); }
.jc-about h2 { margin: 0 0 10px; font-size: 16px; }
.jc-about h3 { margin: 14px 0 4px; font-size: 14px; }
.jc-about p { margin: 0 0 10px; }
.jc-about a { color: var(--link); }
.jc-remember { display: flex; align-items: flex-start; gap: 8px; margin: 4px 0 6px; font-weight: 600; cursor: pointer; }
.jc-remember input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); }
.jc-hint { font-size: 12.5px; color: var(--muted); }
.jc-about-close { min-height: 38px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--accent);
  color: var(--on-accent); font: inherit; font-weight: 600; cursor: pointer; }

/* A phone's full screen: the header keeps one line for the name and its subtitle, with a smaller
   monogram and tighter gaps beside the 44 px controls; a name longer than that ends in an ellipsis
   and is whole in its tooltip. */
@media (max-width: 390px) {
  .jc-brand { gap: 6px; }
  .jc-avatar { width: 28px; height: 28px; font-size: 12px; }
  .jc-actions { gap: 2px; }
  .jc-name { font-size: 15px; }
  .jc-role { font-size: 11px; }
}
@media (max-width: 480px) {
  .jc-icon-button, .jc-answer-tools .jc-icon-button, .jc-langs button { min-height: 44px; min-width: 44px; }
  .jc-log .jc-cards > li { min-height: 44px; align-items: center; }
  .jc-card-n { top: 12px; }
  .jc-sources { min-height: 44px; }
  .jc-send { height: 44px; }
  .jc-suggest button { min-height: 44px; }
  /* A button is an inline block: the padding grows the tap target, the negative margin keeps the line. */
  .jc-more { padding: 14px 12px; margin: -14px -8px; }
  .jc-privacy-line { margin-bottom: 8px; }
}
/* With the expand button (T-4658, never on a phone) four controls share a 420 px header: 34 px
   targets and a slimmer toggle keep the name whole. */
.jc-actions:has(.jc-size) { gap: 2px; }
.jc-actions:has(.jc-size) .jc-icon-button { min-width: 34px; min-height: 36px; }
.jc-actions:has(.jc-size) .jc-langs button { min-width: 34px; min-height: 32px; padding: 0 8px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* T-4657: "Table | Map" over a data card, and the frame of the chart renderer on viz.{domain}. */
.jc-tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.jc-tab { font: inherit; padding: 4px 12px; border: 1px solid currentColor; border-radius: 999px; background: transparent; color: inherit; cursor: pointer; opacity: 0.7; }
.jc-tab[aria-selected="true"] { opacity: 1; font-weight: 600; }
.jc-viz { display: block; width: 100%; height: 360px; border: 0; }
