:root {
  /* Baseline: QAICK_Studio_FE/src/index.css (default graphite theme).
     Shell structure: app/layout/StudioLayout.tsx and app/layout/layout.css.
     Component conventions: studio/action-editor-v2, studio/properties and studio/dialogs.
     Keep these native CSS tokens aligned with Studio; no runtime dependency. */
  color-scheme: dark;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  --chrome: #141413;
  --navigation: #161615;
  --inspector: #181817;
  --canvas: #111110;
  --surface: #181817;
  --surface-2: #20201e;
  --surface-3: #272725;
  --ink: #f1f0ec;
  --ink-2: #cbc9c1;
  --muted: #a6a49d;
  --faint: #94928b;
  --line: #30302d;
  --line-strong: #484842;
  --qk-blue: #8e80f6;
  --qk-blue-strong: #a193fa;
  --qk-blue-soft: #272725;
  --qk-blue-line: #635a9d;
  --ok: #6fb98f;
  --ok-soft: #1b2720;
  --warn: #d6a85f;
  --warn-soft: #292319;
  --fail: #e58e86;
  --fail-soft: #302321;
  --radius-sm: 5px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-pop: 0 8px 24px rgb(0 0 0 / 16%);
  --surface-soft: var(--surface-2);
  --text: var(--ink);
  --border: var(--line);
  --primary: var(--qk-blue);
  --primary-hover: var(--qk-blue-strong);
  --primary-soft: var(--qk-blue-soft);
  --danger: var(--fail);
  --danger-soft: var(--fail-soft);
  --success: var(--ok);
  --shadow: none;
  color: var(--text);
  background: var(--canvas);
}
:root[data-theme="light"] {
  /* Studio light tokens, including its shell's blue accent override. */
  color-scheme: light;
  --chrome: #ffffff;
  --navigation: #ffffff;
  --inspector: #f4f5f6;
  --canvas: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #edf0f7;
  --ink: #182234;
  --ink-2: #34435b;
  --muted: #617089;
  --faint: #7c8aa0;
  --line: #e5e7eb;
  --line-strong: #cfd5dd;
  --qk-blue: #0969ff;
  --qk-blue-strong: #0055d4;
  --qk-blue-soft: #e8eeff;
  --qk-blue-line: #c8d5fa;
  --ok: #14804a;
  --ok-soft: #e6f5ec;
  --warn: #92620a;
  --warn-soft: #fdf3e2;
  --fail: #bc3327;
  --fail-soft: #fdecea;
  --shadow-pop: 0 18px 44px -16px rgb(16 24 40 / 30%);
}
* { box-sizing: border-box; }
/* Studio shell: compact toolbar, navigation, editor/inspector, status strip.
   Existing sections stack at narrow widths rather than requiring new controls. */
body { margin: 0; height: 100dvh; display: grid; grid-template-rows: 44px minmax(0, 1fr) 28px; overflow: hidden; }
[hidden] { display: none !important; }
.topbar { min-width: 0; padding: 6px 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--border); background: var(--chrome); }
.brand { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: .02em; }
.brand-mark { color: var(--primary); font-size: 13px; font-weight: 700; }
.brand-caption { font-size: 12px; font-weight: 450; color: var(--muted); letter-spacing: 0; }
.toolbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.workspace-shell { min-height: 0; min-width: 0; overflow: hidden; padding-right: 12px; background: var(--canvas); }
.page-heading { grid-area: heading; padding: 24px 32px; border-bottom: 1px solid var(--border); background: var(--canvas); }
.eyebrow { margin: 0 0 10px; color: var(--primary); font-size: 10px; font-weight: 600; letter-spacing: .09em; }
h1 { margin: 0 0 10px; font-size: 21px; font-weight: 650; letter-spacing: -.04em; line-height: 1.25; }
.page-heading > p:last-child { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.workspace-layout { display: grid; height: 100%; min-height: 0; grid-template-columns: clamp(240px, 20vw, 300px) minmax(0, 1fr); }
#rule-form, .field, .panel { min-width: 0; }
.dashboard { border: 1px solid var(--border); background: var(--navigation); }
#rule-form { min-height: 0; overflow: auto; background: var(--canvas); }
.rule-builder { display: grid; min-height: 100%; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; grid-template-areas: "heading" "identity" "panels" "submission"; background: var(--canvas); }
.request-panel { min-width: 0; }
.response-panel { min-width: 0; background: var(--inspector); }
.builder-heading { grid-area: identity; padding: 20px; margin: 24px 32px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.builder-heading .field { max-width: 560px; }
#mockRuleName { font-size: 14px; font-weight: 500; background: var(--surface); }
.panels { grid-area: panels; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-width: 0; margin: 0 32px 24px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); overflow: hidden; }
.panel { overflow: hidden; }
.panels > .panel { border: 1px solid var(--border); border-radius: var(--radius); }
.panels > .request-panel { background: var(--surface-2); }
.panel-heading { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.panel-heading > div { min-width: 0; }
h2 { margin: 0 0 4px; font-size: 14px; font-weight: 600; letter-spacing: -.015em; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.panel-symbol { display: grid; place-items: center; flex-shrink: 0; width: 32px; height: 32px; border: 1px solid var(--qk-blue-line); border-radius: var(--radius); color: var(--primary); background: var(--primary-soft); }
.panel-symbol svg { display: block; }
.response-symbol { color: var(--success); background: var(--ok-soft); border-color: var(--ok); }
.fields { display: flex; flex-direction: column; gap: 18px; padding: 20px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
label, .field-title { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px; font-size: 12px; font-weight: 600; }
.optional { color: var(--muted); font-size: 10px; font-weight: 400; }
.required { color: var(--danger); font-size: 14px; }
input, select, textarea { display: block; width: 100%; min-width: 0; padding: 5px 8px; min-height: 28px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: 12px; transition: border-color .16s, box-shadow .16s, background .16s; }
select { min-height: 28px; }
textarea { resize: vertical; min-height: 100px; font-family: var(--mono); font-size: 12px; line-height: 1.7; }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--qk-blue-line); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 2px var(--qk-blue-line); }
.key-value-editor { display: flex; flex-direction: column; gap: 9px; }
.key-value-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 9px; }
.hint { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.field-error-disclaimer { color: var(--danger); font-size: 11px; line-height: 1.5; }
.field-invalid, .field-invalid:hover, .field-invalid:focus { border: 1px solid var(--danger); background: var(--fail-soft); color: var(--text); }
.field-invalid:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button { flex-shrink: 0; padding: 5px 10px; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--primary); color: var(--canvas); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; transition: background .16s, color .16s, border-color .16s, box-shadow .16s; }
button:hover { background: var(--primary-hover); box-shadow: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
button:disabled { cursor: default; opacity: .5; box-shadow: none; }
#import-curl { align-self: flex-start; padding: 5px 10px; border-color: var(--qk-blue-line); color: var(--primary); background: var(--primary-soft); }
#import-curl:hover { background: var(--surface-3); }
.theme-toggle { display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 4px; color: var(--ink-2); background: transparent; cursor: pointer; }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle:hover { color: var(--ink); background: var(--surface-3); box-shadow: none; }
.theme-toggle:focus-visible { outline: 2px solid var(--qk-blue); outline-offset: 2px; }
:root[data-theme="light"] :is(#create-group, #register-rule, #proceed-default-name, #confirm-clear-rules) { color: #ffffff; }
.submission { grid-area: submission; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 32px 24px; border-top: 1px solid var(--border); }
.submission p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.8; }
#path-help, #body-help, #headers-help, #response-help, #status-help, .submission p { font-size: 11px; }
#register-rule { padding: 5px 10px; box-shadow: none; }
#register-rule span { margin-left: 9px; }
.rules-sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: auto; border-right: 1px solid var(--border); background: var(--navigation); }
.group-create { display: flex; flex-direction: column; gap: 8px; padding: 16px; background: var(--navigation); }
.group-create button { align-self: flex-start; }
.dashboard { display: flex; flex: 1; flex-direction: column; min-height: 180px; }
.rule-group { min-width: 0; }
.rule-group:has(.group-rules:not([hidden])) { padding-bottom: 12px; }
.group-header { display: flex; align-items: center; gap: 6px; padding: 4px; }
.group-toggle { flex: 1; min-width: 0; padding: 16px 12px; text-align: left; overflow-wrap: anywhere; background: var(--surface-soft); color: var(--text); }
.group-toggle::before { content: '\25B8'; margin-right: 6px; }
.group-toggle[aria-expanded="true"]::before { content: '\25BE'; }
.group-toggle:hover, .group-toggle[aria-pressed="true"] { color: var(--primary); background: var(--primary-soft); box-shadow: none; }
.group-rules { margin: 0 8px 0 18px; padding: 6px 0 6px 10px; border-left: 2px solid var(--border); border-radius: 0 0 6px 0; background: var(--surface-soft); }
.rule-details { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.rule-row[draggable="true"] { cursor: grab; }
#ungrouped-rules { min-width: 0; }
.drop-target { outline: 2px solid var(--primary); outline-offset: -2px; background: var(--primary-soft); }
.dashboard .panel-heading { flex-wrap: wrap; gap: 8px; background: var(--surface-2); padding: 12px 14px; }
.dashboard .panel-heading > div { flex: 1 1 100%; }
#rules-heading { margin-bottom: 7px; font-size: 13px; }
#clear-rules { padding: 6px 10px; font-size: 12px; color: var(--muted); border-color: var(--border); background: var(--surface); }
#clear-rules:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); box-shadow: none; }
.rules-list { display: flex; flex-direction: column; gap: 7px; padding: 8px; overflow-y: auto; min-height: 0; flex: 1; font-size: 12px; color: var(--muted); }
.rule-row { display: flex; align-items: center; gap: 8px; padding: 3px 10px; border: 1px solid transparent; border-radius: var(--radius); transition: border-color .16s, background .16s; }
.rule-row:hover { border-color: var(--border); background: var(--surface-soft); }
.rule-row:has(.rule-name[aria-pressed="true"]) { border-color: var(--qk-blue-line); background: var(--primary-soft); box-shadow: inset 3px 0 var(--primary); }
.rule-name { flex: 1; min-width: 0; padding: 5px 0; border: 0; border-radius: 3px; color: var(--text); background: transparent; box-shadow: none; text-align: left; font-size: 12px; font-weight: 550; line-height: 1.6; overflow-wrap: anywhere; }
.rule-name:hover { color: var(--primary); background: transparent; box-shadow: none; }
.rule-name[aria-pressed="true"] { color: var(--primary); }
.delete-rule, .edit-group { display: grid; place-items: center; width: 32px; height: 32px; padding: 6px; border-radius: var(--radius-sm); color: var(--faint); background: transparent; box-shadow: none; }
.delete-rule:hover { color: var(--danger); background: var(--danger-soft); box-shadow: none; }
.delete-rule svg, .edit-group svg { display: block; }
.edit-group:hover { color: var(--primary); background: var(--primary-soft); box-shadow: none; }
.group-rename-input { flex: 1; min-width: 0; min-height: 51px; }
#toast-container { position: fixed; inset: 20px auto auto 50%; transform: translateX(-50%); margin: 0; width: max-content; max-width: calc(100vw - 32px); padding: 0; border: 0; background: transparent; overflow: visible; pointer-events: none; z-index: 1000; }
.toast { max-height: calc(100dvh - 40px); overflow-y: auto; padding: 12px 18px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); background: var(--surface); box-shadow: var(--shadow-pop); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; opacity: 1; transform: translateY(0); transition: opacity var(--toast-exit-duration), transform var(--toast-exit-duration); }
.toast.toast-hiding { opacity: 0; transform: translateY(-10px); }
#toast-container[data-type="success"] .toast { color: var(--success); background: var(--ok-soft); border-color: var(--ok); }
#toast-container[data-type="error"] .toast, .notice { color: var(--danger); background: var(--danger-soft); border-color: var(--fail); }
footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; padding: 0 16px; border-top: 1px solid var(--border); background: var(--chrome); color: var(--faint); font-size: 9px; letter-spacing: .08em; }
.confirmation-modal { position: fixed; inset: 0; margin: auto; width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 26px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); }
.confirmation-modal::backdrop { background: rgb(0 0 0 / 40%); }
.confirmation-modal h2 { margin: 0 0 16px; font-size: 18px; }
.confirmation-modal p { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.confirmation-modal .modal-warning { color: var(--danger); }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 24px; }
#cancel-clear-rules, #cancel-default-name { border-color: var(--border); background: var(--surface); color: var(--text); }
#cancel-clear-rules:hover, #cancel-default-name:hover { background: var(--surface-soft); box-shadow: none; }
#confirm-clear-rules { background: var(--danger); color: var(--canvas); }
#confirm-clear-rules:hover { filter: brightness(.9); box-shadow: none; }
@media (max-width: 380px) { .confirmation-modal { padding: 20px; } .modal-actions { flex-direction: column-reverse; } }
/* Studio bounds side panes; stack the existing response region when space is limited. */
@media (max-width: 1200px) {
  .workspace-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .rule-builder { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "heading" "identity" "panels" "submission"; }
  .panels { grid-template-columns: minmax(0, 1fr); grid-auto-rows: 1fr; margin: 0 24px 24px; }
  .page-heading { padding: 20px 24px; }
  .builder-heading { margin: 20px 24px; }
  .submission { padding: 16px 24px 24px; }
}
@media (max-width: 760px) {
  body { height: auto; min-height: 100dvh; grid-template-rows: 44px minmax(0, 1fr) auto; overflow: visible; }
  .workspace-shell { overflow: visible; padding-right: 0; }
  .workspace-layout { height: auto; grid-template-columns: minmax(0, 1fr); }
  .rules-sidebar { border-right: 0; border-bottom: 1px solid var(--border); overflow: visible; }
  .dashboard { min-height: 0; }
  .rules-list { flex: auto; max-height: 320px; }
  #rule-form { overflow: visible; padding-right: 0; }
  .page-heading { padding: 20px 16px; }
  .builder-heading { margin: 16px; padding: 16px; }
  .panels { margin: 0 16px 16px; }
  .brand-caption { display: none; }
  .submission { padding: 16px; flex-direction: column; align-items: stretch; }
  footer { padding: 8px 16px; flex-wrap: wrap; }
}
@media (max-width: 380px) {
  .fields, .panel-heading { padding: 16px 12px; }
  .page-heading { padding: 20px 12px; }
  .builder-heading { margin: 12px; padding: 12px; }
  .panels { margin: 0 12px 12px; padding: 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
