/* Query population (frontend/js/population-query.js).

   One workspace in the height the page leaves: the Tables rail, a divider, and a main column
   of query tabs, a toolbar, the editor, a second divider and the results. The type sizes,
   colours, buttons and the results grid (data-table) are the ones Explore population uses,
   so the two tabs read as one page. */

/* Several parts below set display, which would otherwise beat the hidden attribute. */
#lab-query-body [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.pq-icon { width: 14px; height: 14px; flex: none; }
.pq-lock { width: 12px; height: 12px; color: var(--text-muted); }

/* While a divider is dragged the whole page shows its cursor and nothing gets selected. */
body.pq-resizing-x, body.pq-resizing-x * { cursor: col-resize !important; user-select: none !important; }
body.pq-resizing-y, body.pq-resizing-y * { cursor: row-resize !important; user-select: none !important; }

/* ─── Workspace ───────────────────────────────────────────────────── */
/* The height left under the app header, the sub-navigation, the blurb and the page's own
   padding (styles.css: .main-content 24px, .page-subnav-blurb). */
.pq-workspace {
    --pq-rail-w: 288px;
    --pq-editor-h: 300px;
    display: grid;
    grid-template-columns: var(--pq-rail-w) 7px minmax(0, 1fr);
    height: calc(100vh - var(--header-height) - var(--subnav-height) - 80px);
    min-height: 560px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.pq-main {
    display: grid;
    grid-template-rows: 40px auto minmax(120px, min(var(--pq-editor-h), calc(100% - 270px))) 7px minmax(180px, 1fr);
    min-width: 0;
    min-height: 0;
}

/* ─── Dividers ────────────────────────────────────────────────────── */
.pq-split { position: relative; background: var(--bg-card); z-index: 2; }
.pq-split::before { content: ""; position: absolute; background: var(--border-primary); transition: background var(--transition-fast); }
.pq-split::after { content: ""; position: absolute; border-radius: 2px; background: var(--border-secondary); opacity: 0; transition: opacity var(--transition-fast), background var(--transition-fast); }
.pq-split-v { cursor: col-resize; }
.pq-split-v::before { top: 0; bottom: 0; left: 3px; width: 1px; }
.pq-split-v::after { top: 50%; left: 2px; width: 3px; height: 32px; transform: translateY(-50%); }
.pq-split-h { cursor: row-resize; }
.pq-split-h::before { left: 0; right: 0; top: 3px; height: 1px; }
.pq-split-h::after { left: 50%; top: 2px; height: 3px; width: 32px; transform: translateX(-50%); }
.pq-split:hover::after, .pq-split:focus-visible::after { opacity: 1; }
.pq-split:hover::before, .pq-split.is-dragging::before, .pq-split:focus-visible::before { background: var(--accent-primary-300); }
.pq-split.is-dragging::after { opacity: 1; background: var(--accent-primary); }
.pq-split:focus-visible { outline: none; }

/* ─── Tables rail ─────────────────────────────────────────────────── */
.pq-rail { background: var(--surface-sunken); padding: 14px 10px 12px; display: grid; gap: 10px; align-content: start; overflow: auto; min-height: 0; }
.pq-rail > *, .pq-groups, .pq-group, .pq-tables, .pq-t { min-width: 0; }
.pq-rail:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-blue-glow); }
.pq-pane-title { font-size: var(--fs-subheading); font-weight: 650; color: var(--text-primary); letter-spacing: -0.012em; margin: 0; }
.pq-rail-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 6px; }
.pq-rail-note { font-size: var(--fs-small); color: var(--text-muted); padding: 0 6px; margin: 0; }
.pq-search { position: relative; display: flex; align-items: center; }
.pq-search .pq-icon { position: absolute; left: 10px; color: var(--text-muted); pointer-events: none; }
.pq-search input { width: 100%; height: 32px; padding: 0 10px 0 30px; border: 1px solid var(--border-color); border-radius: var(--radius-ctl); background: var(--bg-card); color: var(--text-primary); font-family: inherit; font-size: var(--fs-small); }
.pq-search input:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-blue-glow); }
.pq-groups { display: grid; gap: 2px; }
.pq-group-h { display: flex; align-items: center; gap: 6px; width: 100%; height: 30px; padding: 0 6px 0 8px; border: 0; border-radius: var(--radius-sm); background: none; font-family: inherit; font-size: var(--fs-small); font-weight: 650; color: var(--text-secondary); cursor: pointer; text-align: left; }
.pq-group-h:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.pq-group-h:focus-visible, .pq-caret:focus-visible, .pq-tname:focus-visible, .pq-eye:focus-visible, .pq-col:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent-blue-glow), inset 0 0 0 1px var(--accent-blue); }
.pq-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pq-chevron { width: 12px; height: 12px; color: var(--text-muted); transition: transform var(--transition-fast); }
.pq-group.is-open > .pq-group-h .pq-chevron, .pq-t.is-open > .pq-row .pq-chevron { transform: rotate(90deg); }
.pq-count { font-size: var(--fs-small); font-weight: 500; color: var(--text-muted); font-variant-numeric: tabular-nums; text-align: right; }
.pq-tables { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 1px; }
.pq-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto 52px; align-items: center; gap: 4px; height: 28px; padding: 0 6px; border-radius: var(--radius-sm); }
.pq-row:hover, .pq-t.is-open > .pq-row { background: var(--bg-tertiary); }
.pq-caret, .pq-tname, .pq-eye, .pq-col { border: 0; background: none; padding: 0; font-family: inherit; cursor: pointer; border-radius: var(--radius-xs); }
.pq-caret { display: grid; place-items: center; width: 20px; height: 22px; }
.pq-tname { text-align: left; font-size: var(--fs-body); font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pq-tname:hover, .pq-col:hover { color: var(--accent-primary); }
.pq-group.is-locked .pq-tname { color: var(--text-tertiary); }
/* The count and the preview share the last column: the eye takes the count's place on hover. */
.pq-end { position: relative; display: flex; justify-content: flex-end; align-items: center; height: 100%; }
.pq-end .pq-count { transition: opacity var(--transition-fast); }
.pq-row:hover .pq-end .pq-count, .pq-row:focus-within .pq-end .pq-count { opacity: 0; }
.pq-eye { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 26px; height: 22px; color: var(--text-secondary); opacity: 0; transition: opacity var(--transition-fast), color var(--transition-fast); }
.pq-row:hover .pq-eye, .pq-eye:focus-visible { opacity: 1; }
.pq-eye:hover { color: var(--accent-primary); }
.pq-cols { list-style: none; margin: 2px 0 8px 18px; padding: 2px 0 2px 12px; border-left: 1px solid var(--border-primary); display: grid; }
.pq-cols li { display: flex; align-items: center; gap: 6px; height: 24px; padding-right: 8px; }
.pq-col { font-size: var(--fs-small); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pq-tag { font-size: var(--fs-micro); font-weight: 650; letter-spacing: .03em; text-transform: uppercase; color: var(--accent-primary); background: var(--accent-primary-50); border-radius: 4px; padding: 0 5px; line-height: 16px; }
.pq-type { margin-left: auto; font-size: var(--fs-micro); color: var(--text-muted); text-transform: lowercase; }

/* ─── Query tabs ──────────────────────────────────────────────────── */
.pq-tabs { display: flex; align-items: stretch; min-width: 0; background: var(--surface-sunken); border-bottom: 1px solid var(--border-primary); }
.pq-tabs-list { display: flex; align-items: stretch; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.pq-tabs-list::-webkit-scrollbar { display: none; }
.pq-tab { position: relative; display: flex; align-items: center; flex: none; max-width: 240px; border-right: 1px solid var(--border-primary); }
.pq-tab.is-active { background: var(--bg-card); }
.pq-tab.is-active::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--accent-primary); }
.pq-tab.is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--bg-card); }
.pq-tab-btn { display: flex; align-items: center; gap: 8px; min-width: 0; height: 100%; padding: 0 4px 0 14px; border: 0; background: none; font-family: inherit; font-size: var(--fs-small); font-weight: 600; color: var(--text-tertiary); cursor: pointer; }
.pq-tab-btn:hover, .pq-tab.is-active .pq-tab-btn { color: var(--text-primary); }
.pq-tab-btn:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-blue-glow); }
.pq-tab-icon { display: inline-flex; color: var(--text-muted); }
.pq-tab.is-active .pq-tab-icon { color: var(--accent-primary); }
.pq-tab-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pq-tab-input { width: 150px; height: 24px; padding: 0 6px; border: 1px solid var(--accent-blue); border-radius: var(--radius-xs); font-family: inherit; font-size: var(--fs-small); font-weight: 600; color: var(--text-primary); box-shadow: 0 0 0 3px var(--accent-blue-glow); outline: none; }
.pq-tab-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; margin: 0 3px; }
.pq-tab-dot.is-error { background: var(--accent-red); }
.pq-tab-spin { width: 12px; height: 12px; }
.pq-tab-x { display: grid; place-items: center; width: 22px; height: 22px; margin-right: 6px; padding: 0; border: 0; border-radius: var(--radius-xs); background: none; color: var(--text-muted); cursor: pointer; opacity: 0; transition: opacity var(--transition-fast); }
.pq-tab:hover .pq-tab-x, .pq-tab.is-active .pq-tab-x, .pq-tab-x:focus-visible { opacity: 1; }
.pq-tab-x:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.pq-tab-x:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent-blue-glow); }
.pq-tab-x .pq-icon { width: 12px; height: 12px; }
.pq-tab-add { display: grid; place-items: center; flex: none; width: 40px; border: 0; background: none; color: var(--text-tertiary); cursor: pointer; }
.pq-tab-add:hover { color: var(--accent-primary); background: var(--bg-tertiary); }
.pq-tab-add:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-blue-glow); }

/* ─── Toolbar ─────────────────────────────────────────────────────── */
.pq-bar { position: relative; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 12px; border-bottom: 1px solid var(--border-primary); flex-wrap: wrap; }
.pq-run.btn, .pq-stop.btn { gap: 6px; min-width: 92px; }
.pq-run .pq-icon, .pq-stop .pq-icon { width: 12px; height: 12px; }
.pq-stop.btn { border: 1px solid var(--accent-red); color: var(--accent-red); background: var(--bg-card); }
.pq-stop.btn:hover { background: #fef2f2; }
.pq-kbd { display: inline-block; font-family: inherit; font-size: var(--fs-micro); font-weight: 600; line-height: 1; letter-spacing: .02em; padding: 3px 5px; border-radius: 4px; border: 1px solid var(--border-secondary); background: var(--bg-tertiary); color: var(--text-secondary); }
.pq-kbd.on-dark { margin-left: 4px; border-color: rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .14); color: #fff; }
.pq-bar-divider { width: 1px; height: 20px; background: var(--border-primary); }
/* Over a query Model Studio handed over: which model and version, and that it is a copy. */
.pq-origin { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 8px 12px 4px; padding: 7px 12px; border: 1px solid #c7dfe7; border-radius: var(--radius-ctl); background: #eef6f8; color: var(--text-secondary); font-size: var(--fs-small); line-height: 1.45; }
.pq-origin[hidden] { display: none; }
.pq-origin strong { color: var(--text-primary); font-weight: 650; }
.pq-origin span { flex: 1 1 320px; min-width: 0; }
.pq-link { padding: 0; border: 0; background: none; color: var(--accent-primary); font: 600 var(--fs-small) Inter, sans-serif; white-space: nowrap; cursor: pointer; }
.pq-link:hover { text-decoration: underline; }
.pq-link:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; border-radius: 3px; }
.pq-field { display: flex; }
.pq-select.form-control { height: var(--control-sm); width: 200px; padding-top: 0; padding-bottom: 0; border-radius: var(--radius-ctl); font-size: var(--fs-small); font-weight: 600; color: var(--text-primary); background-position: right 10px center; }
.pq-labels { position: relative; display: flex; align-items: center; gap: 8px; }
.pq-switch { display: inline-flex; align-items: center; gap: 8px; height: var(--control-sm); font-size: var(--fs-small); font-weight: 600; color: var(--text-secondary); cursor: pointer; position: relative; user-select: none; }
.pq-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pq-track { width: 28px; height: 16px; border-radius: 8px; background: var(--border-secondary); position: relative; transition: background var(--transition-fast); flex: none; }
.pq-knob { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25); transition: left var(--transition-fast); }
.pq-switch input:checked + .pq-track { background: var(--accent-primary); }
.pq-switch input:checked + .pq-track .pq-knob { left: 14px; }
.pq-switch input:checked ~ span:not(.pq-track) { color: var(--text-primary); }
.pq-switch input:focus-visible + .pq-track { box-shadow: 0 0 0 3px var(--accent-blue-glow); }
.pq-switch.is-disabled { color: var(--text-muted); cursor: not-allowed; }
.pq-switch.is-disabled .pq-track { opacity: .5; }
.pq-info { display: inline-grid; place-items: center; width: 16px; height: 16px; padding: 0; border-radius: 50%; border: 1px solid var(--border-secondary); background: var(--bg-card); font-family: inherit; font-size: 10px; font-weight: 700; line-height: 1; color: var(--text-tertiary); cursor: pointer; }
.pq-info:hover, .pq-info[aria-expanded="true"] { color: var(--accent-primary); border-color: var(--accent-primary); }
.pq-info:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-blue-glow); }
.pq-withheld { font-size: var(--fs-small); color: var(--text-muted); }
.pq-help { position: absolute; top: calc(100% + 8px); left: 0; z-index: 20; width: 380px; background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 12px 14px; font-size: var(--fs-small); color: var(--text-secondary); line-height: 1.55; }
.pq-gap { flex: 1; }
.pq-ghost { display: inline-flex; align-items: center; gap: 6px; height: var(--control-sm); padding: 0 10px; border: 1px solid transparent; border-radius: var(--radius-ctl); background: none; font-family: inherit; font-size: var(--fs-small); font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.pq-ghost:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.pq-ghost:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-blue-glow); }

/* ─── Editor ──────────────────────────────────────────────────────── */
.pq-editor-pane { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.pq-editor { flex: 1; min-height: 0; overflow: hidden; }
.pq-editor > .pq-cm { height: 100%; }
.pq-textarea { display: block; width: 100%; height: 100%; resize: none; border: 0; outline: 0; padding: 14px 16px; font-family: var(--font-mono); font-size: var(--fs-body); line-height: 1.65; color: var(--text-primary); background: transparent; tab-size: 2; }
.pq-textarea::placeholder { font-family: 'Inter', sans-serif; color: var(--text-muted); }
.pq-params { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 8px 16px; border-top: 1px solid var(--border-primary); background: var(--surface-sunken); flex: none; }
.pq-plabel { font-size: 0.72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-tertiary); font-weight: 700; }
.pq-param { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-small); }
.pq-param code { font-family: var(--font-mono); font-size: var(--fs-small); background: var(--accent-primary-50); color: var(--accent-primary); padding: 2px 6px; border-radius: 5px; }
.pq-input.form-control { height: var(--control-sm); width: 150px; padding-top: 0; padding-bottom: 0; font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.pq-phint { color: var(--text-muted); max-width: 460px; line-height: 1.4; }

/* ─── Results ─────────────────────────────────────────────────────── */
.pq-results { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; }
.pq-results-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; padding: 8px 12px 8px 16px; border-bottom: 1px solid var(--border-primary); }
.pq-head-text { display: flex; align-items: center; gap: 12px; min-width: 0; flex-wrap: wrap; }
.pq-filter { width: 220px; }
.pq-meta { font-size: var(--fs-small); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.pq-meta strong { color: var(--text-primary); font-weight: 650; }
.pq-meta-labels { color: #92400e; font-weight: 600; }
.pq-head-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.pq-results-body { overflow: auto; min-height: 0; }
.pq-results-body:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-blue-glow); }
.pq-results-foot { display: flex; align-items: center; gap: 12px; height: 32px; padding: 0 16px; border-top: 1px solid var(--border-primary); background: var(--surface-sunken); font-size: var(--fs-small); color: var(--text-tertiary); min-width: 0; }
.pq-foot-sql { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: var(--fs-small); color: var(--text-secondary); background: none; padding: 0; }
.pq-foot-facts { flex: none; font-variant-numeric: tabular-nums; }
.pq-foot-hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pq-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-secondary); border-top-color: var(--accent-primary); animation: pq-spin 1s linear infinite; flex: none; }
@keyframes pq-spin { to { transform: rotate(360deg); } }

/* The grid is the app's data-table, on the pane's own scroll. */
.pq-grid { min-width: 100%; width: auto; }
.pq-grid th { position: sticky; top: 0; z-index: 1; padding: 0; }
.pq-grid th button { display: block; width: 100%; padding: 10px 16px; border: 0; background: none; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; text-align: inherit; cursor: pointer; }
.pq-grid th button[aria-disabled="true"] { cursor: default; }
.pq-grid th button:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-blue-glow); }
.pq-grid th.n, .pq-grid td.n { text-align: right; }
.pq-grid tr { cursor: default; }
.pq-grid td { padding-top: 9px; padding-bottom: 9px; color: var(--text-primary); max-width: 420px; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.pq-grid .pq-rn { width: 1%; text-align: right; color: var(--text-muted); padding-left: 16px; padding-right: 8px; }
.pq-grid th.pq-rn { padding: 10px 8px 10px 16px; }
.pq-null { color: var(--text-muted); font-style: italic; }
.pq-cell { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-primary); cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pq-cell:hover { text-decoration: underline; }
.pq-cell:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent-blue-glow); border-radius: 3px; }
.pq-cut { font-size: var(--fs-micro); color: var(--text-muted); }
.pq-more, .pq-empty { padding: 12px 16px; font-size: var(--fs-small); color: var(--text-muted); }
.pq-sortnote { margin: 0; padding: 8px 16px; font-size: var(--fs-small); color: var(--text-secondary); background: var(--accent-primary-50); border-bottom: 1px solid var(--accent-primary-100); }
.pq-banner { padding: 8px 16px; background: #fffbeb; border-bottom: 1px solid #fde68a; color: #92400e; font-size: var(--fs-small); font-weight: 600; }
.pq-notice { margin: 16px; max-width: 680px; border-radius: var(--radius-md); padding: 16px 18px; display: grid; gap: 6px; font-size: var(--fs-body); line-height: 1.55; border: 1px solid; }
.pq-notice strong { font-size: var(--fs-subheading); font-weight: 650; }
.pq-notice code { font-size: var(--fs-small); }
.pq-notice.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.pq-notice.bad { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.pq-notice.info { background: var(--accent-primary-50); border-color: var(--accent-primary-200); color: var(--text-secondary); }
.pq-notice.info strong { color: var(--text-primary); }
.pq-actions { display: flex; gap: 8px; margin-top: 6px; }
.pq-skel { display: grid; gap: 12px; padding: 18px 16px; }
.pq-skel span { height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--bg-tertiary), var(--border-primary), var(--bg-tertiary)); background-size: 200% 100%; animation: pq-shimmer 1.4s ease-in-out infinite; }
.pq-skel span:nth-child(odd) { width: 82%; }
@keyframes pq-shimmer { to { background-position: -200% 0; } }

/* First visit: the starters before anything has run in this tab. */
.pq-gallery { padding: 16px; display: grid; gap: 12px; }
.pq-gcards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pq-gcard { display: grid; grid-template-rows: auto auto 1fr auto; gap: 6px; padding: 16px; border: 1px solid var(--border-primary); border-radius: var(--radius-md); background: var(--bg-card); font-family: inherit; text-align: left; cursor: pointer; transition: border-color var(--transition-fast), box-shadow var(--transition-fast); }
.pq-gcard:hover { border-color: rgba(var(--accent-primary-rgb), .35); box-shadow: var(--shadow-md); }
.pq-gcard:focus-visible { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-blue-glow); }
.pq-eyebrow { font-size: 0.72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-tertiary); font-weight: 700; }
.pq-gcard strong { font-size: var(--fs-subheading); font-weight: 650; color: var(--text-primary); letter-spacing: -0.01em; }
.pq-gcard p { margin: 0; font-size: var(--fs-body); color: var(--text-secondary); line-height: 1.5; }
.pq-gcard-open { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: var(--fs-small); font-weight: 650; color: var(--accent-primary); }
.pq-gallery-f { margin: 0; font-size: var(--fs-small); color: var(--text-muted); }

/* ─── Side panel ──────────────────────────────────────────────────── */
.pq-panel-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .24); z-index: 300; }
.pq-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 301; background: var(--bg-card); border-left: 1px solid var(--border-primary); box-shadow: var(--shadow-lg); overflow: auto; padding: 20px 24px 32px; display: grid; gap: 14px; align-content: start; }
.pq-panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border-primary); }
.pq-panel-h h2 { font-size: var(--fs-heading); font-weight: 650; letter-spacing: -0.012em; margin: 0; }
.pq-panel-note { font-size: var(--fs-body); color: var(--text-secondary); margin: 0; line-height: 1.55; }
.pq-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pq-chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-secondary); background: var(--bg-card); font-family: inherit; font-size: var(--fs-small); font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.pq-chip span { color: var(--text-muted); font-weight: 500; margin-left: 2px; }
.pq-chip:hover { color: var(--text-primary); }
.pq-chip[aria-pressed="true"] { background: var(--accent-primary); border-color: var(--accent-primary); color: #fff; }
.pq-chip[aria-pressed="true"] span { color: rgba(255, 255, 255, .8); }
.pq-chip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-blue-glow); }
.pq-exs { display: grid; gap: 10px; }
.pq-ex { border: 1px solid var(--border-primary); border-radius: var(--radius-md); padding: 14px 16px; display: grid; gap: 6px; }
.pq-ex h3 { font-size: var(--fs-subheading); font-weight: 650; margin: 0; }
.pq-ex p { margin: 0; font-size: var(--fs-body); color: var(--text-primary); line-height: 1.5; }
.pq-ex .pq-ex-t { font-size: var(--fs-small); color: var(--text-secondary); }
.pq-ex-t span, .pq-ex-group { font-size: 0.72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-tertiary); font-weight: 700; }
.pq-ex-group { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pq-badge-labels { font-size: var(--fs-micro); letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.pq-ex-f { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 4px; }
.pq-concepts { display: flex; flex-wrap: wrap; gap: 4px; }
.pq-concepts code { font-size: var(--fs-micro); background: var(--bg-tertiary); color: var(--text-secondary); padding: 2px 6px; border-radius: 4px; }
.pq-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pq-history button { display: grid; gap: 6px; width: 100%; padding: 10px 12px; border: 1px solid var(--border-primary); border-radius: var(--radius-md); background: var(--bg-card); font-family: inherit; text-align: left; cursor: pointer; }
.pq-history button:hover { border-color: rgba(var(--accent-primary-rgb), .35); }
.pq-history button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-blue-glow); }
.pq-history code { font-size: var(--fs-small); white-space: pre-wrap; color: var(--text-primary); }
.pq-history span { font-size: var(--fs-small); color: var(--text-muted); }
.pq-value { margin: 0; background: var(--surface-sunken); border: 1px solid var(--border-primary); border-radius: var(--radius-md); padding: 14px; font-family: var(--font-mono); font-size: var(--fs-small); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 70vh; overflow: auto; }

/* The link into this tab from an alert's detail panel (frontend/js/alerts.js). */
.panel-query-link { border: 0; background: none; padding: 0; font: inherit; color: var(--text-muted); text-decoration: underline; cursor: pointer; }
.panel-query-link:hover { color: var(--accent-primary); }
.panel-query-link:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

/* Narrow windows: the rail sits above the query, and only the editor's divider moves. */
@media (max-width: 900px) {
    .pq-workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: 240px auto; height: auto; }
    .pq-split-v { display: none; }
    .pq-rail { border-bottom: 1px solid var(--border-primary); }
    .pq-main { grid-template-rows: 40px auto var(--pq-editor-h) 7px 460px; }
    .pq-gcards { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    .pq-spin, .pq-skel span { animation: none; }
}
