/* The "Exp Debug" bar: summary chips in the pinned bar, the tabbed panel above it and its controls.
   Linked by the debug report itself (lib/ezutils/classes/expdebugbarreport.php), so every design gets it,
   admin and public. Everything is scoped to #debug. The bar has its own colour scheme (the tokens below):
   light, and dark under prefers-color-scheme: dark or admin4's own dark mode (html[data-a4-theme="dark"]).
   Every text colour passes 4.5:1 on the backgrounds it is used on; the section "Isolation from the page"
   at the end keeps the design's colours out of the panel. */

#debug {
  --xd-bg: #ffffff;
  --xd-bg-soft: #f4f5f7;
  --xd-bg-bar: #f2f2f2;
  --xd-fg: #1d1f23;
  --xd-fg-soft: #555b66;
  --xd-line: #c9ccd2;
  --xd-line-strong: #8f95a3;
  --xd-accent: #0b5cad;
  --xd-accent-fg: #ffffff;
  --xd-ok: #1d6b35;
  --xd-on-status: #ffffff; /* text on a status filled with --xd-ok/-warn/-high */
  --xd-ok-bg: #e3f3e7;
  --xd-warn: #7a4a00;
  --xd-warn-bg: #fff0c9;
  --xd-high: #a01818;
  --xd-high-bg: #fde3e3;
  --xd-focus: #1a73e8;
  --xd-row: #ffffff;
  --xd-row-alt: #f0f1f4;
  --xd-head: #e6e8ec;
  --xd-transaction: #f8f6d8;
  /* the shadows of the pinned bar and of the open panel over the page */
  --xd-shadow: rgba(0, 0, 0, .15);
  --xd-shadow-strong: rgba(0, 0, 0, .2);
  /* message levels: heading colours on --xd-row-alt (the classic td.debugheader) */
  --xd-lv-notice: #1d6b35;
  --xd-lv-warning: #8a4600;
  --xd-lv-error: #b01717;
  --xd-lv-debug: #8a3b12;
  --xd-lv-timing: #0b4fa8;
  --xd-lv-strict: #6f2a96;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--xd-fg);
}
@media (prefers-color-scheme: dark) {
  #debug {
    --xd-bg: #1c1e22; --xd-bg-soft: #26292e; --xd-bg-bar: #2a2a2a; --xd-fg: #e8eaed; --xd-fg-soft: #a9afb8;
    --xd-line: #454a52; --xd-line-strong: #6b717c; --xd-accent: #6aa9f0; --xd-accent-fg: #0d1117;
    --xd-ok: #8fd6a3; --xd-on-status: #10161c; --xd-ok-bg: #173323; --xd-warn: #ffd27a; --xd-warn-bg: #3a2c0c; --xd-high: #ff9d9d; --xd-high-bg: #4a1a1a;
    --xd-focus: #8ab4f8; --xd-row: #1c1e22; --xd-row-alt: #24272c; --xd-head: #2c3036; --xd-transaction: #34321c;
    --xd-shadow: rgba(0, 0, 0, .5); --xd-shadow-strong: rgba(0, 0, 0, .6);
    --xd-lv-notice: #8fd6a3; --xd-lv-warning: #ffd27a; --xd-lv-error: #ff9d9d; --xd-lv-debug: #e8b07a;
    --xd-lv-timing: #8ab4f8; --xd-lv-strict: #d7aefb;
  }
}
/* admin4's own switch (design/admin4/templates/page_head_style.tpl): the same dark tokens */
html[data-a4-theme="dark"] #debug {
  --xd-bg: #1c1e22; --xd-bg-soft: #26292e; --xd-bg-bar: #2a2a2a; --xd-fg: #e8eaed; --xd-fg-soft: #a9afb8;
  --xd-line: #454a52; --xd-line-strong: #6b717c; --xd-accent: #6aa9f0; --xd-accent-fg: #0d1117;
  --xd-ok: #8fd6a3; --xd-on-status: #10161c; --xd-ok-bg: #173323; --xd-warn: #ffd27a; --xd-warn-bg: #3a2c0c; --xd-high: #ff9d9d; --xd-high-bg: #4a1a1a;
  --xd-focus: #8ab4f8; --xd-row: #1c1e22; --xd-row-alt: #24272c; --xd-head: #2c3036; --xd-transaction: #34321c;
  --xd-shadow: rgba(0, 0, 0, .5); --xd-shadow-strong: rgba(0, 0, 0, .6);
  --xd-lv-notice: #8fd6a3; --xd-lv-warning: #ffd27a; --xd-lv-error: #ff9d9d; --xd-lv-debug: #e8b07a;
  --xd-lv-timing: #8ab4f8; --xd-lv-strict: #d7aefb;
}

/* --- the pinned bar and the panel above it
   Until #450 these rules were a <style> block the report printed after the bar; they are here now, and the report
   links this file before the bar (expdebugbarreport.php, render()), so the bar is drawn styled. The bar stays at the
   bottom of the window wherever the page is scrolled; the details open as a panel above it (its height follows the
   bar, which may wrap at narrow widths). The panel is 60% of the window high, or the height the user dragged it to,
   never more than the room above the bar. The two heights are custom properties the bar's script sets on the root
   element at run time (--exp-debug-bar-h: the measured bar; --exp-debug-panel-h: the saved panel height). */
#debug, #debug[data-exp-debug-bar] { margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none; }
/* #571: the bar's markup is complete at the first paint (expDebugBarReport::barHtml()) and it keeps at least the
   height of one line (the 38px the page's padding and the panel assume until the script has measured it), so it never
   grows after load; its sides are logical (margin-inline-*, inset-inline-*), so the link stays at the end of the line
   in a right-to-left interface as well. */
#debug > h2 {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 2147483000; margin: 0; box-sizing: border-box; min-height: 38px;
  display: flex; flex-wrap: wrap; align-items: center; background: var(--xd-bg-bar); border-top: 1px solid var(--xd-line-strong);
  box-shadow: 0 -2px 6px var(--xd-shadow); font-size: 14px;
}
#debug > h2 > a { flex: 1 1 auto; padding: 8px 12px; color: var(--xd-fg); text-decoration: none; }
#debug > h2 > label.debug-keep-open {
  margin-inline-start: 1em; margin-inline-end: 12px; color: var(--xd-fg); font-size: 12px; font-weight: normal; cursor: pointer; white-space: nowrap;
}
#debug-details { display: none; }
#debug-details.active {
  display: block; position: fixed; left: 0; right: 0; bottom: var(--exp-debug-bar-h, 38px); z-index: 2147482999;
  height: 60vh; height: min(var(--exp-debug-panel-h, 60vh), calc(100vh - var(--exp-debug-bar-h, 38px)));
  overflow: auto; background: var(--xd-bg); color: var(--xd-fg); border-top: 2px solid var(--xd-line-strong);
  box-shadow: 0 -4px 12px var(--xd-shadow-strong); box-sizing: border-box;
}
body.exp-debug-bar { padding-bottom: calc(var(--exp-debug-bar-h, 38px) + 8px); }
/* a page in a frame shows no bar (expdebugbar.js sets hidden) */
#debug[hidden] { display: none; }

/* --- the report's tables: figures right aligned in equal digits; group rows and summaries by class, not <b>/<i> */
/* the message headings at 12px at least (debug.css draws them at 0.9em, under 12px in the admin designs) */
#debug td.debugheader { font-size: max(12px, 0.9em); }
#debug td.num, #debug td.debugtime { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#debug td.debuglabel, #debug tr.group td.groupname, #debug tr.summary td { font-weight: bold; }
#debug tr.group td.num { font-style: italic; }
#debug .exp-debug-report-time { font-weight: 600; }

#debug { box-sizing: border-box; max-width: 100%; }
#debug * { word-break: normal; overflow-wrap: anywhere; }
#debug :focus-visible { outline: 2px solid var(--xd-focus); outline-offset: 1px; }
#debug .exp-debug-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- the pinned bar */
#debug > h2 > a { font-weight: 600; }
#debug > h2 > a::after { margin-inline-start: .5em; }
#debug .exp-debug-summary { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 4px 0; }
#debug .exp-debug-chip {
  font: 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; padding: 3px 7px; border-radius: 10px;
  border: 1px solid var(--xd-line); background: var(--xd-ok-bg); color: var(--xd-ok); cursor: pointer; white-space: nowrap;
  unicode-bidi: plaintext; /* a figure keeps its order in a right-to-left interface */
}
#debug .exp-debug-chip[data-level="warn"] { background: var(--xd-warn-bg); color: var(--xd-warn); border-color: currentColor; }
#debug .exp-debug-chip[data-level="high"] { background: var(--xd-high-bg); color: var(--xd-high); border-color: currentColor; font-weight: 700; }
#debug .exp-debug-chip:hover { filter: brightness(.95); }
/* How the page came about: "Rendered" by the kernel or "Cached" (served from the page cache with the bar of the
   render that stored it), and the link to a full render or back to the cached view */
#debug .exp-debug-served {
  font: 600 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; padding: 3px 7px; border-radius: 10px;
  border: 1px solid currentColor; background: var(--xd-bg-soft); color: var(--xd-fg); white-space: nowrap; margin-inline: 6px 2px;
  text-transform: uppercase; letter-spacing: .03em;
}
#debug .exp-debug-served[data-served="cache"] { background: var(--xd-ok-bg); color: var(--xd-ok); }
#debug .exp-debug-served-action { font-size: 12px; font-weight: 400; margin-inline-end: 6px; color: var(--xd-accent); white-space: nowrap; }
/* not the bar's own "Exp Debug" link: no open/close arrow */
#debug > h2 > a.exp-debug-served-action { flex: 0 0 auto; padding: 0 6px; color: var(--xd-accent); text-decoration: underline; }
#debug > h2 > a.exp-debug-served-action::after { content: none; }
#debug .exp-debug-from-render { margin: 0 0 8px; color: var(--xd-fg-soft); font-size: 12px; }
/* OPcache, APCu, then the PHP and Exponential versions: the last chips, at the right end of the summary */
#debug .exp-debug-chip.exp-debug-end { margin-inline-start: auto; }
/* the request's HTTP status in colour (green, yellow for a redirect, red from 400 on) and the user with a person icon */
#debug:not([data-exp-debug-theme="toolbar"]) .exp-debug-chip[data-key="request"] { font-weight: 700; border-color: transparent; color: var(--xd-on-status); background: var(--xd-ok); }
#debug:not([data-exp-debug-theme="toolbar"]) .exp-debug-chip[data-key="request"][data-level="warn"] { background: var(--xd-warn); }
#debug:not([data-exp-debug-theme="toolbar"]) .exp-debug-chip[data-key="request"][data-level="high"] { background: var(--xd-high); }
#debug:not([data-exp-debug-theme="toolbar"]) .exp-debug-chip:is([data-key="userprofile"], [data-key="userlogin"])::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-inline-end: 4px; vertical-align: -1px; background-color: currentColor;
  -webkit-mask: var(--xd-person) center / contain no-repeat; mask: var(--xd-person) center / contain no-repeat;
}
#debug { --xd-person: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6m2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0m4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4m-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10s-3.516.68-4.168 1.332c-.678.678-.83 1.418-.832 1.664z'/%3E%3C/svg%3E"); }

/* --- the panel */
#debug-details.active { padding: 0 12px 12px; color: var(--xd-fg); background: var(--xd-bg); }
/* The handle on the panel's top edge (expdebugbar.js, "panel height"): it stays at the top while the panel scrolls,
   the toolbar sticks right under it. 10px high with a grip in the middle; the whole strip takes the pointer. */
#debug .exp-debug-resizer {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: center;
  box-sizing: border-box; height: 10px; margin: 0 -12px; background-color: var(--xd-bg-soft);
  border-bottom: 1px solid var(--xd-line); cursor: ns-resize; touch-action: none; user-select: none;
}
#debug .exp-debug-resizer::before { content: ""; display: block; width: 48px; height: 4px; border-radius: 2px; background: var(--xd-line-strong); }
#debug .exp-debug-resizer:hover::before, #debug .exp-debug-resizer.exp-debug-resizing::before { background: var(--xd-accent); }
#debug .exp-debug-resizer:focus-visible { outline: 2px solid var(--xd-focus); outline-offset: -2px; }
#debug .exp-debug-resizer:focus-visible::before { background: var(--xd-focus); }
body.exp-debug-resizing { cursor: ns-resize; user-select: none; }
#debug .exp-debug-resizer ~ .exp-debug-toolbar { top: 10px; }
#debug .exp-debug-toolbar {
  position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
  padding: 8px 0; background: var(--xd-bg); border-bottom: 1px solid var(--xd-line);
}
#debug .exp-debug-tabs { display: flex; flex-wrap: wrap; gap: 2px; flex: 1 1 auto; }
#debug .exp-debug-tab {
  font: inherit; font-size: 13px; padding: 5px 10px; border: 1px solid transparent; border-radius: 4px 4px 0 0;
  background: transparent; color: var(--xd-fg-soft); cursor: pointer;
}
#debug .exp-debug-tab:hover { color: var(--xd-fg); background: var(--xd-bg-soft); }
#debug .exp-debug-tab[aria-selected="true"] { color: var(--xd-fg); border-color: var(--xd-line); border-bottom-color: var(--xd-bg); background: var(--xd-bg); font-weight: 600; box-shadow: inset 0 2px 0 var(--xd-accent); }
#debug .exp-debug-tab[data-matches="0"] { color: var(--xd-fg-soft); font-style: italic; }
#debug .exp-debug-badge { display: inline-block; min-width: 1.4em; padding: 0 4px; margin-left: 2px; border-radius: 8px; background: var(--xd-bg-soft); font-size: 12px; text-align: center; }
#debug .exp-debug-search input { font: inherit; font-size: 13px; padding: 4px 8px; width: 16em; max-width: 100%; border: 1px solid var(--xd-line); border-radius: 4px; background: var(--xd-bg); color: var(--xd-fg); }
#debug .exp-debug-panel { padding-top: 10px; }
#debug.exp-debug-js .exp-debug-panel-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#debug .exp-debug-panel h3 { font-size: 14px; margin: 14px 0 6px; }
#debug .exp-debug-panel table { max-width: 100%; }
#debug .exp-debug-hint { color: var(--xd-fg-soft); font-size: 13px; margin: 6px 0; }
#debug .exp-debug-hint.exp-debug-warn { color: var(--xd-warn); background: var(--xd-warn-bg); padding: 4px 8px; border-radius: 4px; }
#debug .exp-debug-hint.exp-debug-high { color: var(--xd-high); background: var(--xd-high-bg); padding: 4px 8px; border-radius: 4px; }
#debug .exp-debug-hint.exp-debug-ok { color: var(--xd-ok); background: var(--xd-ok-bg); padding: 4px 8px; border-radius: 4px; }
#debug .exp-debug-report-time { font-size: 12px; color: var(--xd-fg-soft); margin-top: 12px; }
#debug table.exp-debug-facts { border-collapse: collapse; font-size: 13px; margin: 4px 0 8px; }
#debug table.exp-debug-facts th, #debug table.exp-debug-facts td { text-align: left; padding: 3px 12px 3px 0; border-bottom: 1px solid var(--xd-line); vertical-align: top; font-weight: normal; }
#debug table.exp-debug-facts th { color: var(--xd-fg-soft); }
#debug .exp-debug-filter-hidden { display: none !important; }
#debug .exp-debug-empty { color: var(--xd-fg-soft); font-style: italic; }

/* --- buttons and inputs */
#debug .exp-debug-button, #debug .exp-debug-panel button.exp-debug-button {
  font: inherit; font-size: 13px; padding: 4px 10px; margin: 2px 4px 2px 0; border: 1px solid var(--xd-line); border-radius: 4px;
  background: var(--xd-bg-soft); color: var(--xd-fg); cursor: pointer;
}
#debug .exp-debug-button.exp-debug-primary { background: var(--xd-accent); color: var(--xd-accent-fg); border-color: var(--xd-accent); }
#debug .exp-debug-button[aria-pressed="true"] { background: var(--xd-accent); color: var(--xd-accent-fg); border-color: var(--xd-accent); }
#debug .exp-debug-button:disabled { opacity: .5; cursor: default; }
#debug .exp-debug-panel input[type="text"], #debug .exp-debug-panel input[type="search"], #debug .exp-debug-panel select, #debug .exp-debug-panel textarea {
  font: inherit; font-size: 13px; padding: 3px 6px; border: 1px solid var(--xd-line); border-radius: 4px; background: var(--xd-bg); color: var(--xd-fg); max-width: 100%; box-sizing: border-box;
}
#debug .exp-debug-panel input[aria-invalid="true"] { border-color: var(--xd-high); box-shadow: 0 0 0 1px var(--xd-high); }
#debug .exp-debug-panel fieldset { border: 1px solid var(--xd-line); border-radius: 6px; padding: 6px 10px 10px; margin: 8px 0; }
#debug .exp-debug-panel legend { font-weight: 600; padding: 0 4px; font-size: 13px; }
#debug .exp-debug-levels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
#debug .exp-debug-message-tools { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; }
#debug .exp-debug-message-tools > .exp-debug-levels { margin-bottom: 0; }
#debug .exp-debug-copy { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
#debug .exp-debug-copy .exp-debug-button { margin: 0; }
#debug .exp-debug-copy .exp-debug-button[hidden] { display: none; }
#debug .exp-debug-copy-status { font-size: 13px; }
/* the off-screen textarea the copy falls back to (expdebugbar.js, copyByTextarea; appended to the body) */
textarea.exp-debug-copy-area { position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; opacity: 0; }
#debug .exp-debug-copy-status:empty { display: none; }
#debug .exp-debug-copy-status.exp-debug-ok { color: var(--xd-ok); }
#debug .exp-debug-copy-status.exp-debug-warn { color: var(--xd-warn); }
#debug .exp-debug-copy-status.exp-debug-high { color: var(--xd-high); }
/* the User tab: the anonymous visitors' cache profile, the same as the user's or not */
#debug .exp-debug-badge[data-level="ok"] { color: var(--xd-ok); }
#debug .exp-debug-badge[data-level="warn"] { color: var(--xd-warn); }
/* the User tab's policies: the search and the role on one line, a policy for every module or function stands out */
#debug .exp-debug-policies-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#debug .exp-debug-policies-search { min-width: 16em; flex: 1 1 16em; }
#debug .exp-debug-policy-all { color: var(--xd-warn); font-weight: bold; }
#debug .exp-debug-user-policies-section > summary { cursor: pointer; font-weight: bold; margin: 12px 0 6px; }
/* the User tab: an overview, then its parts as sub-tabs; "?" shows the explanations */
#debug .exp-debug-overview { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 4px 0 0; }
#debug .exp-debug-overview-item { display: flex; flex-direction: column; min-width: 0; }
#debug .exp-debug-overview-item dt { font-size: 11px; color: var(--xd-fg-soft); text-transform: uppercase; letter-spacing: .03em; margin: 0; }
#debug .exp-debug-overview-item dd { margin: 1px 0 0; white-space: nowrap; }
#debug .exp-debug-subtabs { display: flex; flex-wrap: wrap; gap: 2px; align-items: flex-end; border-bottom: 1px solid var(--xd-line); margin: 10px 0 8px; }
#debug .exp-debug-subtablist { display: flex; flex-wrap: wrap; gap: 2px; align-items: flex-end; }
#debug .exp-debug-subtab { border: 1px solid transparent; border-bottom: 0; background: none; color: var(--xd-fg-soft); padding: 5px 12px; cursor: pointer; font: inherit; border-radius: 4px 4px 0 0; }
#debug .exp-debug-subtab:hover { color: var(--xd-fg); background: var(--xd-bg-soft); }
#debug .exp-debug-subtab[aria-selected="true"] { color: var(--xd-fg); border-color: var(--xd-line); background: var(--xd-bg); font-weight: 600; box-shadow: inset 0 2px 0 var(--xd-accent); margin-bottom: -1px; }
#debug .exp-debug-subtab[data-matches]::after { content: " (" attr(data-matches) ")"; font-weight: normal; }
#debug .exp-debug-subtab[data-matches="0"] { font-style: italic; }
#debug .exp-debug-subtab-help { margin-left: auto; border: 1px solid var(--xd-line); background: none; color: var(--xd-fg-soft); border-radius: 50%; width: 1.8em; height: 1.8em; cursor: pointer; font: inherit; margin-bottom: 4px; }
#debug .exp-debug-subtab-help[aria-pressed="true"] { color: var(--xd-fg); background: var(--xd-bg-soft); }
#debug .exp-debug-explain-folded .exp-debug-render-explain { display: none; }
/* the User tab's session: a table per group, nested keys indented under their parent, opened with the triangle */
#debug .exp-debug-user-session-section > summary { cursor: pointer; font-weight: bold; margin: 12px 0 6px; }
#debug .exp-debug-session-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#debug .exp-debug-session-filter { min-width: 16em; flex: 1 1 16em; }
#debug .exp-debug-session-group { margin: 14px 0 4px; }
#debug .exp-debug-session-table { width: 100%; }
#debug .exp-debug-session-table tr:nth-child(even) > td { background: var(--xd-bg-soft, rgba(127, 127, 127, .06)); }
#debug .exp-debug-session-keycell { padding-left: calc(4px + var(--depth, 0) * 1.4em); white-space: nowrap; }
#debug .exp-debug-session-toggle, #debug .exp-debug-session-toggle-space { display: inline-block; width: 1.4em; text-align: center; }
#debug .exp-debug-session-toggle { border: 0; background: none; padding: 0; cursor: pointer; color: inherit; font: inherit; }
#debug .exp-debug-session-key { font-weight: bold; }
#debug .exp-debug-session-size { text-align: right; white-space: nowrap; }
#debug .exp-debug-session-value { overflow-wrap: anywhere; }
#debug .exp-debug-session-value code { white-space: pre-wrap; }
#debug .exp-debug-session-soft { color: var(--xd-fg-soft); }
#debug .exp-debug-session-hit > td { outline: 1px solid var(--xd-warn); outline-offset: -1px; }

/* --- settings */
#debug .exp-debug-presets { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 6px 0 10px; }
#debug .exp-debug-group > h3 { border-bottom: 1px solid var(--xd-line); padding-bottom: 3px; }
#debug .exp-debug-setting {
  display: grid; grid-template-columns: minmax(12em, 1.3fr) minmax(10em, 1.2fr) minmax(9em, 1fr) auto; gap: 4px 10px;
  align-items: start; padding: 6px 0; border-bottom: 1px dashed var(--xd-line); font-size: 13px;
}
#debug .exp-debug-setting-name { font-weight: 600; }
#debug .exp-debug-setting-key { display: block; font: 12px ui-monospace, Menlo, Consolas, monospace; color: var(--xd-fg-soft); font-weight: normal; }
#debug .exp-debug-setting-help { display: block; color: var(--xd-fg-soft); font-weight: normal; font-size: 12px; }
#debug .exp-debug-origin { display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 8px; background: var(--xd-bg-soft); border: 1px solid var(--xd-line); color: var(--xd-fg-soft); }
#debug .exp-debug-origin[data-origin="default"] { border-style: dashed; }
#debug .exp-debug-setting-status { font-size: 12px; min-height: 1em; grid-column: 1 / -1; }
#debug .exp-debug-setting textarea { width: 100%; min-height: 4em; }
#debug .exp-debug-scope label { display: block; font-size: 12px; color: var(--xd-fg-soft); }
@media (max-width: 760px) {
  #debug .exp-debug-setting { grid-template-columns: 1fr 1fr; }
}

/* --- IP and user lists */
#debug .exp-debug-iplist { grid-column: 1 / -1; }
#debug .exp-debug-iplist table { border-collapse: collapse; width: 100%; font-size: 13px; }
#debug .exp-debug-iplist th, #debug .exp-debug-iplist td { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--xd-line); }
#debug .exp-debug-iplist tr.exp-debug-matched td { background: var(--xd-ok-bg); color: var(--xd-ok); }
#debug .exp-debug-iplist tr.exp-debug-expired td { color: var(--xd-fg-soft); text-decoration: line-through; }
#debug .exp-debug-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
#debug .exp-debug-row label { font-size: 12px; }
#debug .exp-debug-field-error { color: var(--xd-high); font-size: 12px; }
#debug .exp-debug-mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* --- change log */
#debug .exp-debug-log { font-size: 13px; padding-left: 1.2em; }
#debug .exp-debug-log li { margin: 3px 0; }

/* --- messages and SQL */
#debug #main-debug-table, #debug #exp-debug-sql-table { width: 100%; }
#debug #main-debug-table pre, #debug #exp-debug-sql-table pre { white-space: pre-wrap; margin: 2px 0 6px; font-size: 12px; }
#debug .exp-debug-classic { margin-top: 14px; }
#debug .exp-debug-classic > summary { cursor: pointer; font-weight: 600; font-size: 13px; }
#debug .exp-debug-level-hidden { display: none !important; }
#debug > h2 > a { background: transparent; border-bottom: 0; }
#debug, #debug-details { background-color: var(--xd-bg); }
#debug pre { color: var(--xd-fg); background: transparent; }
#debug .exp-debug-search input { width: 20em; }
#debug .exp-debug-setting { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.1fr); }
#debug .exp-debug-scope select, #debug .exp-debug-setting select, #debug .exp-debug-setting input[type="text"] { width: 100%; }
#debug .exp-debug-presets select { width: auto; max-width: 22em; }
#debug .exp-debug-panel button.exp-debug-button.exp-debug-primary { background: var(--xd-accent); color: var(--xd-accent-fg); border-color: var(--xd-accent); }
#debug .exp-debug-iplist .exp-debug-row input[type="text"], #debug .exp-debug-iplist .exp-debug-row select { width: auto; }
#debug .exp-debug-scope select { max-width: 100%; }
@media (max-width: 760px) {
  #debug .exp-debug-setting { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
#debug .exp-debug-cache-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--xd-line); font-size: 13px; }
#debug .exp-debug-cache-row > strong { grid-column: 1; }
#debug .exp-debug-cache-row > .exp-debug-setting-help { grid-column: 1; }
#debug .exp-debug-cache-row > .exp-debug-row { grid-column: 2; grid-row: 1 / span 2; margin: 0; justify-content: flex-end; }
#debug .exp-debug-cache-row:last-child { border-bottom: 0; }

/* ---- Isolation from the page --------------------------------------------------------------------------------
   The panel sits inside every design's page, whose rules for table, th, td, fieldset, pre, label, form controls
   (and the classic report's debug.css: white and #eee rows, green/orange/red/brown/blue/purple level headings)
   reached into it: light text on the designs' white cells in dark mode, orange headings on light grey in light
   mode. Everything inside the bar now takes its colours from the tokens above, in both schemes. The element
   resets are (1,0,1) and lose to the bar's own class rules; the classic rows and levels are set again below at
   the specificity of debug.css. No !important is needed: no design sets one on these elements. */
#debug[data-exp-debug-bar] > #debug-details.active, #debug-details.active { background: var(--xd-bg); color: var(--xd-fg); border-top-color: var(--xd-line-strong); }
#debug :is(div, section, article, p, form, fieldset, legend, label, dl, dt, dd, ul, ol, li, table, caption, thead, tbody,
  tfoot, tr, th, td, details, summary, h1, h2, h3, h4, h5, h6, pre, code, kbd, samp, b, i, strong, em, small, span, font) {
  color: inherit; background-color: transparent; background-image: none; border-color: var(--xd-line); text-shadow: none;
}
#debug > h2, #debug[data-exp-debug-bar] > h2 { background: var(--xd-bg-bar); color: var(--xd-fg); border-top-color: var(--xd-line-strong); }
/* the bar's text, over the old accordion colours of debug.css */
#debug[data-exp-debug-bar] > h2 > a, #debug[data-exp-debug-bar] > h2 > label.debug-keep-open,
#debug > h2 > a, #debug > h2 > label.debug-keep-open { color: var(--xd-fg); background: transparent; }
#debug a, #debug a:visited { color: var(--xd-accent); }
#debug :is(input, select, textarea) { background: var(--xd-bg); color: var(--xd-fg); border-color: var(--xd-line); }
#debug :is(input, select, textarea)::placeholder { color: var(--xd-fg-soft); opacity: 1; }
#debug :is(button, input[type="submit"], input[type="button"], input[type="reset"]) { background: var(--xd-bg-soft); color: var(--xd-fg); border: 1px solid var(--xd-line); text-shadow: none; }
#debug select option { background: var(--xd-bg); color: var(--xd-fg); }
#debug th, #debug table th { color: var(--xd-fg); background-color: var(--xd-head); }
#debug table.exp-debug-facts th, #debug .exp-debug-iplist th { background-color: transparent; }
#debug table.exp-debug-facts th { color: var(--xd-fg-soft); }
#debug table.exp-debug-facts td { color: var(--xd-fg); }

/* the classic report's tables: messages, timing points, accumulators, SQL, templates, includes, memory */
#debug table tr.data td, #debug table tr.data th { background-color: var(--xd-row); color: var(--xd-fg); border-color: var(--xd-line-strong); }
#debug table tr.data:nth-child(odd) td { background-color: var(--xd-row-alt); color: var(--xd-fg); }
#debug table tr.group td { background-color: var(--xd-bg); color: var(--xd-fg); }
#debug td.debugheader, #debug table tr td.debugheader { background-color: var(--xd-row-alt); color: var(--xd-fg); border-color: var(--xd-line-strong); }
#debug #timingpoints, #debug #timeaccumulators, #debug #debug_resources, #debug #debug_includes, #debug table.debug_resource_usage { border-color: var(--xd-line-strong); }
#debug pre, #debug code { color: var(--xd-fg); background: transparent; }
#debug pre.debugtransaction { background-color: var(--xd-transaction); color: var(--xd-fg); }
#debug tr.notice  td.debugheader span, #debug tr.notice  td.debuglabel { color: var(--xd-lv-notice); }
#debug tr.warning td.debugheader span, #debug tr.warning td.debuglabel { color: var(--xd-lv-warning); }
#debug tr.error   td.debugheader span, #debug tr.error   td.debuglabel { color: var(--xd-lv-error); }
#debug tr.debug   td.debugheader span, #debug tr.debug   td.debuglabel { color: var(--xd-lv-debug); }
#debug tr.timing  td.debugheader span, #debug tr.timing  td.debuglabel { color: var(--xd-lv-timing); }
#debug tr.strict  td.debugheader span, #debug tr.strict  td.debuglabel { color: var(--xd-lv-strict); }
#debug span.debuginfo:after { color: var(--xd-accent); border-color: var(--xd-accent); opacity: 1; }
#debug .exp-debug-panel h3, #debug .exp-debug-panel legend, #debug .exp-debug-classic > summary { color: var(--xd-fg); }

/* ---- The symbol and the minimised bar ------------------------------------------------------------------------
   The Exponential symbol (the two squares of the logo) at the left of the bar minimises it; minimised, only a
   small tab with the symbol stays in the bottom right corner, with the error or warning count as a badge. */
#debug .exp-debug-symbol { display: block; width: 20px; height: 20px; color: var(--xd-fg); }
#debug .exp-debug-symbol-front { stroke: #1d1f23; }
#debug > h2 > button.exp-debug-logo {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  margin: 0; margin-inline-start: 6px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--xd-fg); cursor: pointer;
}
#debug > h2 > button.exp-debug-logo:hover { background: var(--xd-bg-soft); border-color: var(--xd-line); }
#debug.exp-debug-min > h2, #debug.exp-debug-min > #debug-details, #debug.exp-debug-min > #debug-details.active { display: none; }
#debug > button.exp-debug-restore {
  position: fixed; inset-inline-end: 8px; bottom: 8px; z-index: 2147483000; box-sizing: border-box; width: 40px; height: 40px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--xd-line-strong); border-radius: 8px;
  background: var(--xd-bg-bar); color: var(--xd-fg); box-shadow: 0 2px 8px rgba(0, 0, 0, .25); cursor: pointer;
}
#debug > button.exp-debug-restore[hidden] { display: none; }
#debug > button.exp-debug-restore:hover { background: var(--xd-bg-soft); }
#debug .exp-debug-restore-badge {
  position: absolute; top: -6px; inset-inline-end: -6px; min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box; border-radius: 8px;
  font: 700 10px/16px system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; text-align: center;
  background: #b01717; color: #ffffff;
}
#debug .exp-debug-restore-badge[data-level="warn"] { background: #ffc94d; color: #1d1f23; }
#debug.exp-debug-min { border: 0; padding: 0; overflow: visible; }
/* --exp-debug-clearance: the room the bar, or its minimised tab, keeps free at the bottom of the window, for the
   page's own fixed controls there (the help contents' Expand all / Collapse all) to stay above it:
   bottom: calc(var(--exp-debug-clearance, 0px) + <gap>). Unset (so 0) without the bar or in a frame. The tab is 8px
   off the bottom, 40px high and its badge reaches 6px above it: 54px. */
body.exp-debug-bar { --exp-debug-clearance: var(--exp-debug-bar-h, 38px); }
body:has(#debug.exp-debug-min:not([hidden])) { --exp-debug-clearance: 54px; }

/* Bar layout: the page summary and "Keep open on reload" on the left, the "Exp Debug" title and the logo at the
   right end of the bar (next to where the minimised tab sits). Order only; the reading and tab order of the markup
   stays as it is for keyboard and screen reader users. */
#debug[data-exp-debug-bar] > h2 > .exp-debug-summary { order: 1; flex: 1 1 auto; justify-content: flex-start; padding-inline-start: 8px; }
#debug[data-exp-debug-bar] > h2 > label.debug-keep-open { order: 2; margin-inline-start: 12px; margin-inline-end: 12px; }
#debug[data-exp-debug-bar] > h2 > a { order: 3; flex: 0 0 auto; margin-inline-start: auto; }
#debug[data-exp-debug-bar] > h2 > button.exp-debug-logo { order: 4; margin-inline-start: 6px; margin-inline-end: 6px; }

/* The SQL query cache in the Cache tab: what is cached by table and the largest entries (expdebugbar.js,
   renderQueryCache), drawn like the facts tables; the figures right aligned in equal digits. */
#debug table.exp-debug-querycache-table { border-collapse: collapse; font-size: 13px; margin: 4px 0 8px; max-width: 100%; }
#debug table.exp-debug-querycache-table th, #debug table.exp-debug-querycache-table td {
  text-align: left; padding: 3px 14px 3px 0; border-bottom: 1px solid var(--xd-line); vertical-align: top; overflow-wrap: anywhere;
}
#debug table.exp-debug-querycache-table th { color: var(--xd-fg-soft); background-color: transparent; font-weight: 600; }
#debug table.exp-debug-querycache-table .exp-debug-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#debug table.exp-debug-querycache-table th:last-child, #debug table.exp-debug-querycache-table td:last-child { padding-right: 0; }
#debug .exp-debug-panel fieldset h4 { font-size: 13px; font-weight: 600; margin: 10px 0 2px; }
/* the Rendering tab: a hint under each heading, and the template tree with one line per template and a guide line per level */
#debug .exp-debug-panel .exp-debug-render-explain { color: var(--xd-fg-soft); font-size: 12px; margin: 0 0 6px; max-width: 72em; }
#debug .exp-debug-render-tree > summary { font-weight: 600; cursor: pointer; margin: 4px 0; }
#debug ul.exp-debug-tree, #debug ul.exp-debug-tree ul { list-style: none; margin: 0; padding: 0; }
#debug ul.exp-debug-tree { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.6;
  background: var(--xd-bg-soft); border: 1px solid var(--xd-line); padding: 6px 10px; overflow-x: auto; }
#debug ul.exp-debug-tree ul { margin-left: 6px; padding-left: 12px; border-left: 1px solid var(--xd-line-strong); }
#debug ul.exp-debug-tree li { white-space: nowrap; overflow-wrap: normal; }
#debug ul.exp-debug-tree code { font-family: inherit; color: var(--xd-fg); background: transparent; }
#debug .exp-debug-render-override { color: var(--xd-accent); font-weight: 600; }
#debug .exp-debug-render-ms { color: var(--xd-fg-soft); }

/* Printing: the bar and its panel are a tool for the screen; a printed page (a help page, an article) leaves them out. */
@media print {
  #debug, #debug > button.exp-debug-restore { display: none !important; }
}
