:root {
  --ink: #393939;
  --muted: #666;
  --paper: #f4f4f4;
  --panel: #fff;
  --line: #cecece;
  --pine: #c5351f;
  --pine-dark: #9f2818;
  --blue: #363f51;
  --blue-soft: #e9ebef;
  --amber: #8a5900;
  --amber-soft: #fff4d9;
  --red: #b3261e;
  --brand: #f04022;
  --shadow: 0 12px 30px rgba(57, 57, 57, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1040px; }
button, input, select, textarea { font: inherit; }

.topbar {
  min-height: 92px;
  padding: 20px 34px;
  background: var(--brand);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 5px solid #393939;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, serif; font-size: 30px; font-weight: 500; }
h2 { margin-bottom: 0; font-size: 18px; }
h3 { margin-bottom: 4px; font-size: 15px; }
.eyebrow { margin-bottom: 5px; font-size: 10px; letter-spacing: .16em; font-weight: 800; opacity: .7; }
.status { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: white; box-shadow: 0 0 0 4px rgba(255,255,255,.2); }

.workflow-tabs { position: sticky; top: 0; z-index: 10; padding: 0 22px; display: flex; gap: 4px; background: #393939; }
.workflow-tab { min-height: 52px; border: 0; border-bottom: 4px solid transparent; padding: 10px 18px; background: transparent; color: #d8d8d8; font-weight: 750; cursor: pointer; }
.workflow-tab span { display: inline-grid; width: 22px; height: 22px; margin-right: 7px; place-items: center; border: 1px solid #777; border-radius: 50%; font-size: 10px; }
.workflow-tab:hover { color: white; }
.workflow-tab.active { border-bottom-color: var(--brand); color: white; }
.workflow-tab.active span { border-color: var(--brand); background: var(--brand); }
.tab-workspace { min-height: calc(100vh - 149px); }
[hidden] { display: none !important; }
.session-error {
  margin: 0;
  padding: 12px 24px;
  border-top: 1px solid #8f2f2a;
  border-bottom: 1px solid #8f2f2a;
  background: #fff0ed;
  color: #7b211d;
  font-weight: 700;
  text-align: center;
}
.stage-layout { max-width: 1080px; margin: 0 auto; padding: 28px 22px; display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); gap: 20px; }
.stage-actions { display: flex; justify-content: space-between; gap: 10px; }
.audience-summary { margin-bottom: 16px; border: 1px solid var(--line); border-radius: 10px; background: #f7f7f7; padding: 14px; }
.audience-summary strong { display: block; margin-bottom: 4px; font-size: 20px; }
.audience-summary p { margin: 0; color: var(--muted); font-size: 11px; }
.workflow-explainer ol { margin: 18px 0; padding-left: 20px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.preview-panel, .history-panel { max-width: 1240px; margin: 22px auto; }
.preview-empty { padding: 42px 16px; text-align: center; color: var(--muted); }
.preview-summary { margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 9px; }
.preview-stat { min-width: 130px; border-radius: 9px; background: #efefef; padding: 10px 12px; }
.preview-stat strong { display: block; font-size: 20px; }
.preview-stat span { color: var(--muted); font-size: 10px; }
.preview-table-shell { max-height: 480px; }
.diff-table td { max-width: 360px; white-space: normal; vertical-align: top; }
.diff-table .diff-before { color: #8b2e20; text-decoration: line-through; text-decoration-color: rgba(139,46,32,.45); }
.diff-table .diff-after { color: #23633e; font-weight: 800; }
.diff-table .blocked { color: var(--amber); font-weight: 750; }
.diff-table input[type="checkbox"] { accent-color: var(--brand); }
.commit-bar { margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.commit-bar p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.commit-actions { display: flex; gap: 8px; }
.button.disabled-action { background: #ddd; color: #777; }
.button.danger { background: var(--red); color: white; }
.button.danger:disabled { background: #ddd; color: #777; cursor: not-allowed; }
.changeset-history { display: grid; gap: 10px; }
.changeset-card { border: 1px solid var(--line); border-radius: 10px; padding: 13px 14px; display: grid; grid-template-columns: 1fr auto; gap: 8px 18px; align-items: center; }
.changeset-card h3 { margin: 0 0 4px; }
.changeset-card p { margin: 0; color: var(--muted); font-size: 11px; }
.changeset-card .changeset-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 7px; }
.changeset-card .changeset-meta span { border-radius: 999px; background: #efefef; padding: 4px 7px; font-size: 9px; }
.changeset-card.revert-commit { border-left: 4px solid var(--blue); }
.history-actions { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.history-warning { grid-column: 1 / -1; border-left: 4px solid var(--red); background: #f8eded; border-radius: 7px; padding: 8px 10px; }
.execution-results { grid-column: 1 / -1; display: grid; gap: 7px; margin-top: 3px; }
.execution-result { border-left: 4px solid var(--line); background: #f4f4f4; border-radius: 7px; padding: 8px 10px; }
.execution-result.verified { border-left-color: var(--pine); }
.execution-result.applied_unverified { border-left-color: var(--blue); }
.execution-result.conflict, .execution-result.failed, .execution-result.unknown_outcome, .execution-result.reconciliation_failed { border-left-color: var(--red); }
.execution-result.not_applied, .execution-result.not_attempted { border-left-color: var(--gold); }
.execution-result strong, .execution-result span { display: block; }
.execution-result span { color: var(--muted); font-size: 10px; text-transform: capitalize; }
.execution-result p { margin-top: 4px; }

.workspace { padding: 22px; display: grid; grid-template-columns: 360px minmax(660px, 1fr); gap: 20px; }
.left-column, .right-column { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 15px; }
.pill { border-radius: 999px; background: var(--blue-soft); color: var(--blue); padding: 5px 9px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.pill.warning { background: var(--amber-soft); color: var(--amber); }
.help { color: var(--muted); font-size: 12px; line-height: 1.5; }

.chat-panel { min-height: 420px; display: flex; flex-direction: column; }
.chat-heading-actions { display: flex; align-items: center; gap: 7px; }
.chat-heading-actions button { border: 0; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; text-decoration: underline; }
.chat-messages { min-height: 260px; max-height: 430px; overflow-y: auto; padding: 4px 2px 14px; display: flex; flex-direction: column; gap: 10px; }
.message { max-width: 92%; border-radius: 13px; padding: 10px 12px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.message.assistant { align-self: flex-start; background: #ededed; border-bottom-left-radius: 4px; }
.message.user { align-self: flex-end; background: var(--pine); color: white; border-bottom-right-radius: 4px; }
.message.error-message { background: #fff0ee; color: var(--red); }
.message.assistant-progress { min-width: 205px; }
.assistant-progress-line { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.assistant-progress-detail, .assistant-timing { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 500; }
.assistant-dots { display: inline-flex; gap: 3px; }
.assistant-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--blue); animation: assistant-dot 1.1s ease-in-out infinite; }
.assistant-dots i:nth-child(2) { animation-delay: .14s; }
.assistant-dots i:nth-child(3) { animation-delay: .28s; }
@keyframes assistant-dot { 0%, 70%, 100% { opacity: .28; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }
.quick-options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick-options button { border: 1px solid #bcbcbc; background: white; color: var(--pine-dark); padding: 5px 8px; border-radius: 999px; font-size: 11px; cursor: pointer; }
.chat-form { margin-top: auto; display: grid; gap: 9px; }
.chat-mode { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 9px; }
.chat-mode select { min-height: 30px; font-size: 11px; }
.llm-disclosure { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.35; }
textarea { resize: vertical; border: 1px solid #c9c9c9; border-radius: 9px; padding: 10px; background: white; color: var(--ink); }
textarea:focus, input:focus, select:focus { outline: 2px solid rgba(240,64,34,.22); border-color: var(--brand); }

.button { border: 0; border-radius: 8px; padding: 9px 13px; font-weight: 700; font-size: 12px; cursor: pointer; }
.button:disabled { opacity: .5; cursor: wait; }
.button.primary { background: var(--pine); color: white; }
.button.primary:hover { background: var(--pine-dark); }
.button.secondary { background: #e9e9e9; color: var(--pine-dark); }
.button.ghost { background: white; border: 1px dashed #aaa; color: var(--pine-dark); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.action-picker { margin: 0 0 14px; }
.action-picker select { min-height: 40px; font-weight: 750; }
.form-grid .span-two { grid-column: 1 / -1; }
.field-hint { color: var(--muted); font-size: 10px; font-weight: 500; }
.numeric-transform-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 650; }
input, select { min-height: 34px; border: 1px solid #c9c9c9; border-radius: 7px; padding: 6px 8px; background: white; color: var(--ink); }
.action-summary { margin-top: 12px; font-size: 12px; }
.action-summary .ready { color: var(--pine); font-weight: 750; }
.action-summary .blocked { color: var(--amber); font-weight: 750; }
.action-review-shell { margin-top: 9px; max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.action-review-table { min-width: 780px; font-size: 10px; }
.action-review-table th, .action-review-table td { white-space: normal; vertical-align: top; }
.action-review-table small { color: var(--muted); }
.action-review-table details { max-width: 170px; }
.action-review-table code { display: block; margin-top: 4px; overflow-wrap: anywhere; white-space: pre-wrap; }

.builder-panel { position: relative; isolation: isolate; }
.builder-heading { align-items: end; }
.builder-controls { display: flex; gap: 10px; }
.filter-rows { display: flex; flex-direction: column; gap: 8px; }
.filter-row { display: grid; grid-template-columns: 1.45fr 1fr 1fr 34px; gap: 8px; align-items: center; padding: 9px; background: #f7f7f7; border: 1px solid #e3e3e3; border-radius: 9px; }
.filter-row > * { min-width: 0; max-width: 100%; }
.filter-row select, .filter-row input { width: 100%; }
.filter-field-search { padding-right: 25px; }
.filter-row .remove { width: 32px; height: 32px; border-radius: 7px; border: 0; background: #ececec; color: #666; cursor: pointer; font-size: 18px; }
.filter-row .filter-description { grid-column: 1 / -1; font-size: 11px; color: var(--muted); padding: 0 3px; }
.filter-field-error { grid-column: 1 / -1; padding: 0 3px; color: #76501d; font-size: 10px; font-weight: 700; }
.filter-availability { display: inline-block; margin-left: 7px; border-radius: 999px; padding: 2px 7px; background: #e7ece8; color: var(--pine); font-size: 9px; font-weight: 750; }
.filter-availability.empty { background: var(--amber-soft); color: #76501d; }
.filter-availability.unavailable { background: var(--amber-soft); color: #76501d; }
.filter-row.unapplied-filter { grid-template-columns: 1fr; border-color: #dda75f; background: var(--amber-soft); }
.unapplied-filter .unapplied-heading { color: #76501d; font-size: 12px; font-weight: 800; }
.unapplied-filter code { overflow-wrap: anywhere; color: #76501d; font-size: 10px; white-space: pre-wrap; }
.unapplied-filter .filter-description { color: #76501d; }
.unapplied-actions { display: flex; gap: 8px; }
.unapplied-actions button { width: auto; border: 0; border-radius: 7px; padding: 7px 11px; background: var(--pine); color: #fff; cursor: pointer; font: inherit; font-weight: 750; }
.unapplied-actions button.secondary-button { background: transparent; color: #76501d; border: 1px solid #c58c42; }
.unapplied-resolution { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(150px, 1fr) auto; gap: 8px; align-items: center; width: 100%; }
.unapplied-resolution button:disabled { cursor: not-allowed; opacity: .5; }
.resolution-error { grid-column: 1 / -1; color: #8d2f24; font-size: 11px; }
.builder-actions { display: flex; justify-content: space-between; margin-top: 12px; }
.run-query-controls { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.query-run-status { max-width: 240px; color: var(--muted); font-size: 10px; line-height: 1.3; text-align: right; }
.query-run-status.pending { color: var(--blue); }
.query-run-status.success { color: #23633e; font-weight: 750; }
.query-run-status.warning { color: var(--amber); font-weight: 750; }
.query-run-status.error { color: var(--red); font-weight: 750; }
.dsl-details { margin-top: 13px; border-top: 1px solid var(--line); padding-top: 12px; }
.dsl-details summary { cursor: pointer; color: var(--pine-dark); font-size: 12px; font-weight: 750; }
#dslEditor { width: 100%; min-height: 170px; margin-bottom: 8px; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.error { min-height: 17px; color: var(--red); font-size: 12px; margin-top: 8px; }

.query-handoff {
  position: fixed;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  border: 1px solid rgba(240, 64, 34, .28);
  border-radius: 999px;
  padding: 0 10px 0 7px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 8px 22px rgba(57, 57, 57, .16);
  color: var(--pine-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .02em;
  pointer-events: none;
  white-space: nowrap;
}
.query-handoff-mark {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  font-size: 10px;
}
.query-handoff-arrow { color: #9a9a9a; }
.builder-panel.ai-query-arrival { animation: query-builder-arrival .82s ease-out; }
.builder-panel.ai-query-arrival .filter-row:not(.unapplied-filter) {
  animation: query-filter-arrival .38s ease-out both;
  animation-delay: calc(var(--filter-index, 0) * 45ms);
}

@keyframes query-builder-arrival {
  0% { border-color: var(--line); box-shadow: var(--shadow); }
  28% { border-color: rgba(240, 64, 34, .72); box-shadow: 0 0 0 4px rgba(240, 64, 34, .10), var(--shadow); }
  100% { border-color: var(--line); box-shadow: var(--shadow); }
}

@keyframes query-filter-arrival {
  0% { background: rgba(240, 64, 34, .09); transform: translateY(-3px); }
  100% { background: #f7f7f7; transform: translateY(0); }
}

.count-cards { display: flex; gap: 8px; }
.count-card { min-width: 88px; background: #efefef; border-radius: 9px; padding: 8px 10px; }
.count-card strong { display: block; font-size: 20px; }
.count-card span { color: var(--muted); font-size: 10px; }
.filter-stages { display: flex; gap: 7px; overflow-x: auto; padding: 3px 0 14px; }
.stage { min-width: 155px; border: 1px solid var(--line); border-radius: 9px; padding: 10px; position: relative; }
.stage:not(:last-child)::after { content: "→"; position: absolute; right: -14px; top: 28px; z-index: 2; color: #9aa29d; }
.stage strong { display: block; font-size: 12px; margin-bottom: 5px; }
.stage .numbers { color: var(--pine); font-size: 20px; font-weight: 800; }
.stage .numbers small { color: var(--muted); font-size: 10px; font-weight: 500; }
.stage p { color: var(--muted); font-size: 10px; margin: 4px 0 0; }

.map-shell { min-width: 0; max-width: 100%; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; margin-bottom: 16px; }
.map-heading { padding: 12px 14px; background: #f7f7f7; border-bottom: 1px solid var(--line); }
.map-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.cluster-map { min-width: 0; max-width: 100%; padding: 12px; min-height: 120px; overflow: auto; background: white; }
.cluster-map svg { display: block; }
.map-label { font-size: 10px; fill: #4f4f4f; }
.map-count { font-size: 9px; fill: #777; }
.map-cell-pass { fill: var(--blue); }
.map-cell-fail { fill: #ededed; }
.map-final { fill: none; stroke: var(--ink); stroke-width: 2; }

@media (prefers-reduced-motion: reduce) {
  .assistant-dots i { animation: none; opacity: .72; }
}

.table-shell { min-width: 0; max-width: 100%; overflow: auto; max-height: 360px; border: 1px solid var(--line); border-radius: 10px; }
.results-panel { scroll-margin-top: 68px; }
.results-panel.viewport-contained {
  height: var(--result-viewer-height);
  max-height: var(--result-viewer-height);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.results-panel.viewport-contained > .panel-heading,
.results-panel.viewport-contained > .filter-stages { flex: 0 0 auto; }
.results-panel.viewport-contained > #queryWarnings {
  flex: 0 1 auto;
  max-height: 126px;
  overflow-y: auto;
}
.results-panel.viewport-contained > .map-shell {
  min-height: 138px;
  max-height: min(220px, 29vh);
  display: flex;
  flex: 0 1 190px;
  flex-direction: column;
}
.results-panel.viewport-contained .cluster-map {
  min-height: 0;
  flex: 1 1 auto;
}
.results-panel.viewport-contained > .table-shell {
  min-height: 120px;
  max-height: none;
  flex: 1 1 240px;
}
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { position: sticky; top: 0; background: #efefef; color: #595959; text-align: left; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; padding: 9px; }
td { border-top: 1px solid #ececec; padding: 9px; white-space: nowrap; }
.result-contract-note { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 500; }
.empty-state { color: var(--muted); font-size: 12px; padding: 18px 4px; }
.member-link { border: 0; padding: 0; background: none; color: var(--pine); font-weight: 750; cursor: pointer; text-decoration: underline; text-decoration-color: #e5a598; text-underline-offset: 3px; }
.member-link:hover { color: var(--blue); text-decoration-color: var(--blue); }

.drawer-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(35, 35, 35, .34); backdrop-filter: blur(2px); }
.member-drawer { position: fixed; z-index: 21; inset: 0 0 0 auto; width: min(680px, 72vw); background: var(--paper); box-shadow: -18px 0 50px rgba(57, 57, 57, .2); transform: translateX(105%); transition: transform .22s ease; overflow-y: auto; }
.member-drawer.open { transform: translateX(0); }
.drawer-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 22px 24px; color: white; background: var(--brand); border-bottom: 4px solid #393939; }
.drawer-header h2 { font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.drawer-close { width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.3); border-radius: 50%; background: rgba(255,255,255,.08); color: white; font-size: 24px; cursor: pointer; }
.drawer-content { padding: 20px 24px 40px; display: grid; gap: 16px; }
.detail-section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.detail-section > h3 { margin-bottom: 12px; font-size: 16px; }
.profile-line { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.profile-line span { border-radius: 999px; background: #ededed; padding: 5px 9px; color: #464646; font-size: 11px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 0; }
.detail-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-grid div { min-width: 0; }
.detail-grid dt { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.detail-grid dd { margin: 3px 0 0; overflow-wrap: anywhere; font-size: 12px; }
.detail-metrics { display: grid; grid-template-columns: 1fr 1.5fr; gap: 9px; }
.detail-metrics div { border-radius: 9px; background: #efefef; padding: 10px 12px; }
.detail-metrics strong { display: block; color: var(--pine); font-size: 18px; }
.detail-metrics span { color: var(--muted); font-size: 10px; }
.coverage-note { margin: 10px 0; border-left: 3px solid var(--blue); padding: 7px 9px; background: #eef0f3; color: #525252; font-size: 11px; line-height: 1.45; }
.coverage-note.warning-note { border-color: #dda75f; background: var(--amber-soft); color: #76501d; }
.detail-card { margin-top: 9px; border: 1px solid var(--line); border-radius: 9px; padding: 12px; }
.detail-card-heading { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 11px; }
.detail-card-heading span { color: var(--muted); font-size: 11px; }
.detail-subgroup { padding: 10px 0; border-top: 1px solid #e5e5e5; }
.detail-subgroup:first-of-type { border-top: 0; padding-top: 0; }
.detail-subgroup h4 { margin: 0 0 8px; color: #52605a; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.timeline-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.agreement-group { padding-bottom: 0; }
.contract-text { color: var(--muted); font-size: 11px; }
.contract-text summary { cursor: pointer; color: var(--pine); font-weight: 700; }
.contract-text p { margin: 8px 0 0; white-space: pre-wrap; line-height: 1.55; }
.detail-table-shell { max-height: 250px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.detail-table { font-size: 11px; }
.detail-table th { z-index: 1; }
.attendance { display: inline-block; border-radius: 999px; padding: 3px 7px; font-size: 9px; font-weight: 750; }
.attendance.qualified { color: #28303f; background: #e2e5eb; }
.attendance.excluded { color: var(--amber); background: var(--amber-soft); }
.detail-empty, .detail-loading, .detail-error { padding: 16px 4px; color: var(--muted); font-size: 12px; }
.detail-error { color: var(--red); }

@media (max-width: 1100px) {
  body { min-width: 0; }
  .workspace { min-width: 0; grid-template-columns: minmax(0, 1fr); }
  .left-column { display: grid; grid-template-columns: 1fr; }
  .member-drawer { width: min(680px, 90vw); }
  .stage-layout { grid-template-columns: 1fr; }
  .commit-bar { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 720px) {
  .topbar { min-height: 76px; padding: 14px 16px; align-items: flex-start; gap: 12px; }
  .topbar .status { max-width: 48%; justify-content: flex-end; text-align: right; }
  h1 { font-size: 25px; }
  .workflow-tabs { padding: 0 8px; overflow-x: auto; }
  .workflow-tab { min-height: 46px; padding: 8px 10px; white-space: nowrap; }
  .tab-workspace { min-height: calc(100vh - 127px); }
  .workspace, .stage-layout { padding: 12px; gap: 12px; }
  .left-column, .right-column { gap: 12px; }
  .panel { padding: 14px; border-radius: 11px; }
  .chat-panel { min-height: 0; }
  .chat-messages { min-height: 150px; max-height: 230px; }
  .panel-heading { flex-wrap: wrap; margin-bottom: 12px; }
  .builder-heading { align-items: flex-start; }
  .builder-controls, .count-cards { width: 100%; flex-wrap: wrap; }
  .builder-controls label { flex: 1 1 130px; }
  .count-card { min-width: 0; flex: 1 1 130px; }
  .filter-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px; }
  .filter-row > :first-child { grid-column: 1 / -1; }
  .filter-row .filter-description { grid-column: 1 / -1; }
  .unapplied-resolution { grid-template-columns: 1fr; }
  .unapplied-resolution .resolution-error { grid-column: 1; }
  .map-heading { padding: 9px 11px; }
  .map-heading p { line-height: 1.35; }
  .results-panel.viewport-contained > .map-shell { min-height: 126px; }
  .table-shell { max-width: 100%; }
  .member-drawer { width: 100vw; }
}

@media (max-height: 620px) {
  .results-panel.viewport-contained { overflow-x: hidden; overflow-y: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .query-handoff { display: none; }
  .builder-panel.ai-query-arrival,
  .builder-panel.ai-query-arrival .filter-row:not(.unapplied-filter) { animation: none; }
  .builder-panel.ai-query-arrival { border-color: rgba(240, 64, 34, .72); }
}
