/* The studio sits inside the Alerts view (.app-view max 1120px, .alert-feed max 760px for the Inbox list).
   Widen only those two wrappers, and only while they contain the studio; Inbox and other routes keep their widths. */
body.page-app .app-view:has(.rule-studio),body.page-app[data-route] .app-view:has(.rule-studio){max-width:1560px}
.alert-feed:has(.rule-studio){max-width:none}
.rule-studio{font-size:15px;line-height:1.5;min-width:0;padding-bottom:16px}
.rule-studio h2{font-size:18px;margin:0 0 12px}.rule-studio h3{font-size:15px;margin:0}
.rule-studio .btn,.rule-studio summary,.studio-move-menu .btn{min-height:44px}
.studio-notice{padding:12px 16px;background:var(--surface-2);border-radius:10px;color:var(--muted);margin:0 0 16px}
.studio-panel,.studio-criteria,.studio-runbar,.studio-results{padding:16px;min-width:0;background:var(--surface);border:1px solid var(--border);border-radius:14px}
.rule-studio .studio-handle.btn{width:44px;min-width:44px;height:44px;flex:none;padding:0;font-size:24px;cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;border:0}
.studio-help{margin-top:16px;color:var(--text-muted)}
.studio-cohort-search{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:8px}.studio-cohort-search>input{flex:1;min-width:120px;width:0}
.studio-cohort-list{max-height:22rem;overflow-y:auto;overscroll-behavior:contain}.studio-cohort-list>label{display:flex;align-items:center;gap:8px;min-height:44px}
.studio-scope select,.studio-study-controls select{box-sizing:border-box;width:100%;max-width:100%;min-width:0;min-height:44px;font-size:16px}.studio-scope>p{font-size:13px}
.studio-toolbar,.studio-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.studio-toolbar{justify-content:space-between;margin-bottom:12px}.studio-toolbar h2{margin:0}
.studio-group{padding:8px;border:1px solid var(--border);border-left:3px solid var(--focus-ring,var(--accent));border-radius:12px;background:var(--bg-2);min-width:0}
.studio-root{border-left-color:var(--accent)}.studio-group-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.studio-group-head>.btn{white-space:normal}.studio-slot{height:12px;position:relative}
.studio-slot.studio-drop-target:after{content:'';position:absolute;top:4px;left:0;right:0;border-top:3px solid var(--accent)}
.studio-group.studio-drop-target{outline:2px solid var(--accent)}.studio-dragging{opacity:.5}.studio-arming{outline:2px solid var(--accent)}
.studio-node{padding:12px;border:1px solid var(--border);background:var(--surface);border-radius:10px;min-width:0}
.studio-node-head{display:flex;gap:8px;align-items:center}.studio-node-head h3{flex:1;min-width:0}.studio-node-head>.btn:last-child{min-width:44px}
.studio-group-footer{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}.studio-basis{font-size:13px;color:var(--muted)}.studio-basis p{margin:0 0 8px}
.studio-scalar{margin-top:12px;min-width:0}.studio-scalar-top{display:flex;align-items:center;justify-content:space-between;gap:8px}
.studio-scalar-top>label{font-size:14px;min-width:0}.studio-exact-box{display:flex;gap:6px;align-items:center;flex:none}.studio-exact-box>span{font-size:13px;color:var(--muted)}
.studio-exact{width:82px;min-height:44px;font:inherit;font-size:16px;text-align:right;padding:8px;border:1px solid var(--border);border-radius:8px;color:var(--text);background:var(--bg)}
.studio-exact[aria-invalid=true]{border-color:var(--red,#be352d)}
.studio-range-lane{display:flex;align-items:center;min-height:44px;width:100%}
.studio-range{width:100%;height:44px;margin:0;accent-color:var(--accent);background:transparent;touch-action:pan-y pinch-zoom;direction:ltr;cursor:ew-resize;appearance:none;-webkit-appearance:none}
.studio-range::-webkit-slider-runnable-track{height:6px;background:var(--border);border-radius:8px}
.studio-range::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;width:26px;height:26px;margin-top:-10px;border:3px solid var(--surface);border-radius:50%;background:var(--accent);box-shadow:0 0 0 1px var(--accent)}
.studio-range::-moz-range-track{height:6px;background:var(--border);border-radius:8px}.studio-range::-moz-range-thumb{width:24px;height:24px;border:2px solid var(--surface);border-radius:50%;background:var(--accent)}
.studio-range-hints{display:flex;justify-content:space-between;color:var(--muted);font-size:12px}.studio-field-error{color:var(--red,#be352d);font-size:13px;margin:0}.studio-field-error:not(:empty){margin-top:8px}
.studio-presets{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}.studio-explain,.studio-study{border-top:1px solid var(--border);padding-top:16px;margin-top:20px}
.studio-explanation{overflow-wrap:anywhere;margin:8px 0}.studio-technical{white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px;max-height:320px;overflow:auto}
.studio-result-body{font-size:14px;overflow-wrap:anywhere}.studio-result-state{padding:10px;background:var(--surface-2);border-radius:8px}.studio-stale{border:1px solid var(--accent)}
.studio-drag-ghost{position:fixed;pointer-events:none;z-index:1000;width:min(290px,80vw);padding:12px;background:var(--surface);color:var(--text);border:2px solid var(--accent);border-radius:12px;box-shadow:0 8px 30px #0004}.studio-drag-ghost>*{display:block}.studio-drag-ghost small{margin-top:8px;color:var(--muted)}.studio-drag-ghost.invalid{border-color:var(--muted)}
.studio-announcement{position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden;white-space:nowrap}
.studio-move-menu{display:grid;gap:8px}.studio-move-menu>.btn{text-align:left;white-space:normal}
@media(prefers-reduced-motion:reduce){.rule-studio *{scroll-behavior:auto!important;transition:none!important}}
.rule-studio .studio-inspect{display:flex;gap:8px;margin:12px 0;flex-wrap:wrap}
.rule-studio .studio-inspect .input{min-width:0;flex:1 1 150px;font-size:16px}
.rule-studio .studio-listing-choices{display:grid;gap:8px;margin:12px 0}
.rule-studio .studio-listing-choices .btn{white-space:normal;text-align:left;justify-content:flex-start;min-height:44px;max-width:100%;overflow-wrap:anywhere}
.rule-studio .studio-match{border-top:1px solid var(--border);padding:16px 0;overflow-wrap:anywhere}
.rule-studio .studio-proof{margin-top:8px}
.rule-studio .studio-proof p{margin:8px 0}
.rule-studio .studio-result-body>select{width:100%;margin:8px 0;font-size:16px;min-height:44px}
.studio-cohort{min-width:0;margin:12px 0;border:1px solid var(--border);border-radius:8px;padding:10px}
.studio-cohort label{display:flex;gap:8px;align-items:center;min-height:44px}.studio-cohort input{width:20px;height:20px;flex:none}
.studio-chart{margin:12px 0}.studio-chart svg{display:block;width:100%;height:auto;color:var(--accent-text,var(--text))}.studio-chart svg text{font-size:10px;fill:var(--text)}.studio-chart figcaption{font-size:13px}
.studio-result-body>.btn{white-space:normal;max-width:100%;margin:4px 0}

.studio-draft-save{display:flex;align-items:center;justify-content:space-between;gap:.75rem;flex-wrap:wrap;margin-block:.75rem}.studio-save-state{font-size:.875rem;color:var(--muted)}

/* Monitor confirmation shares the app dialog's single scroll owner. */
.monitor-confirm{min-width:0;display:flex;flex-direction:column;gap:12px}
.monitor-confirm .screen-field{display:grid;gap:6px;min-width:0}
.monitor-confirm input[type=text]{box-sizing:border-box;width:100%;min-height:44px;padding:10px 12px;font:inherit;font-size:16px;color:var(--text);background:var(--bg);border:1px solid var(--border);border-radius:8px}
.monitor-confirm fieldset{min-width:0;display:grid;gap:8px;padding:12px;border:1px solid var(--border);border-radius:8px}
.monitor-confirm .screen-check{box-sizing:border-box;width:100%;min-height:44px}
.monitor-confirm>.btn{max-width:100%;min-height:44px;white-space:normal}
.monitor-confirm input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.modal-box:has(.monitor-confirm) .modal-close,.modal-box:has(.monitor-confirm) .modal-actions .btn{min-width:44px;min-height:44px}

/* Results-first workspace (PRD §R.2): compact criteria, one run bar, full-width result canvas. */
.rule-studio{display:flex;flex-direction:column;gap:12px}
.studio-head{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}.studio-head h2{font-size:24px;margin:0}
.studio-criteria-bar{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.studio-scope{display:flex;align-items:center;gap:8px;flex-wrap:wrap;min-width:0}
.studio-scope select{width:auto;max-width:100%;min-height:44px;font-size:16px}
.studio-criteria-bar .studio-actions{margin-left:auto}
.studio-criteria-bar [aria-pressed=true],.studio-result-tabs [aria-pressed=true],.studio-subviews [aria-pressed=true]{border-color:var(--accent);color:var(--accent-text,var(--text));font-weight:600}
.studio-explanation{font-size:16px;font-weight:500;margin:12px 0}
.studio-tree .studio-group{border:0;border-left:3px solid var(--border);background:transparent;padding:4px 0 4px 10px;border-radius:0}
.studio-tree>.studio-group.studio-root{border-left:0;padding-left:0}
.studio-tree-advanced .studio-group{border:1px solid var(--border);border-left:3px solid var(--accent);border-radius:12px;padding:8px;background:var(--bg-2)}
.studio-group>.studio-node,.studio-group>.studio-group{margin:6px 0}
.studio-node{padding:8px 12px;display:grid;gap:4px}
.studio-node-head{min-height:44px}.studio-node-head h3{font-size:15px}
.studio-node-values{display:flex;gap:8px;flex-wrap:wrap;align-items:flex-start;min-width:0}
.studio-field-chip.btn{white-space:normal;text-align:left;font-variant-numeric:tabular-nums;border:1px solid var(--border);border-radius:999px;padding:6px 14px;font-size:15px}
.studio-field-open{flex:1 1 100%;min-width:0;padding:8px 12px;border:1px solid var(--accent);border-radius:10px;background:var(--bg)}
.studio-field-open>[data-studio-field-done]{margin-top:8px}
.studio-scope .studio-field-open{flex:1 1 320px}
.studio-badge{display:inline-block;font-size:12px;color:var(--muted);border:1px solid var(--border);border-radius:999px;padding:1px 8px;margin-left:8px;white-space:nowrap}
.studio-runbar{display:grid;gap:12px}
/* The saved-run reader (study-history.js) keeps its flexible tab row; only the run bar uses the three-mode grid. */
.studio-result-tabs{display:flex;gap:8px;flex-wrap:wrap}.studio-result-tabs>.btn{flex:1;white-space:normal}
.studio-runbar .studio-result-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr))}
.studio-study-controls{display:flex;gap:8px;flex-wrap:wrap;align-items:flex-start}
.studio-study[hidden]{display:none}
.studio-study-method{flex:1 1 100%}.studio-study-method>label{display:grid;gap:6px;margin:8px 0;max-width:360px}
.studio-study-method select{min-height:44px;font-size:16px}
.studio-portfolio-controls{display:flex;gap:8px;flex-wrap:wrap;flex:1 1 100%}.studio-portfolio-controls>p{flex:1 1 100%;margin:0;font-size:13px;color:var(--muted)}
.studio-footer{display:flex;gap:8px;flex-wrap:wrap}.studio-footer>[data-studio-run]{background:var(--accent);color:var(--accent-contrast,#fff);border-color:var(--accent)}
.studio-footer>[data-studio-run]:disabled{opacity:.5}
.studio-results{min-height:280px}.studio-results>h2{font-size:18px}
.studio-subviews{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:8px}.studio-subviews[hidden]{display:none}
.studio-mode-mismatch{padding:12px;border:1px solid var(--accent);border-radius:8px}
.studio-method-body>label{display:grid;gap:6px;max-width:420px}.studio-method-body select{min-height:44px;font-size:16px}
.studio-help>summary{cursor:pointer;min-height:44px;display:flex;align-items:center}
.studio-chooser{display:grid;gap:8px;min-width:min(420px,80vw)}.studio-chooser input{min-height:44px;font-size:16px}
.studio-chooser-list{display:grid;gap:6px;max-height:60vh;overflow-y:auto;overscroll-behavior:contain}
.studio-chooser-list>.btn{justify-content:flex-start;text-align:left;white-space:normal;min-height:44px}
.studio-chooser-list>.btn>span{display:flex;flex-wrap:wrap;align-items:center;gap:4px}
@media(max-width:700px){
  .studio-panel,.studio-criteria,.studio-runbar,.studio-results{padding:12px}
  .studio-head h2{font-size:20px}.studio-criteria-bar .studio-actions{margin-left:0}
  .studio-runbar .studio-result-tabs{grid-template-columns:minmax(0,1fr)}
  .studio-footer>.btn{flex:1 1 140px;white-space:normal}
  .studio-scalar-top{flex-wrap:wrap}.studio-exact{width:96px}
  .studio-tree .studio-group{padding-left:6px}
  .studio-sheet-details{align-items:flex-start;flex-wrap:wrap}
  .studio-sheet-details>.studio-sheet-head{flex-basis:100%}
}
.rule-studio .btn:disabled{pointer-events:none}

/* ---- Sentence-first default (owner decision 2026-10-06; reference docs/rule-studio/mock-sentence-first-2026-10-06.html).
   Desktop: sentence editor left, instant results right (sticky). Phone: editor sticks at the top, the list scrolls
   underneath it in the page's one scroll owner, the action bar sticks at the bottom. Parameters open in a sheet. ---- */
.studio-sentence-first{font-size:14px}
.studio-sentence-first .studio-head h2{font-size:20px}
.studio-sentence-layout{display:grid;grid-template-columns:minmax(0,5fr) minmax(0,6fr);gap:16px;align-items:start}
.studio-mobile-nav{display:none}
.studio-sentence-editor{grid-column:1;min-width:0;background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:12px}
.studio-sentence-first .studio-instant{grid-column:2;grid-row:1/span 2;min-width:0;background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:12px;position:sticky;top:12px;max-height:calc(100vh - 24px);overflow:auto;overscroll-behavior:contain;display:flex;flex-direction:column}
.studio-sentence-first .studio-advanced{grid-column:1;min-width:0;color:var(--muted);font-size:13px}
.studio-advanced>summary{cursor:pointer;min-height:44px;display:flex;align-items:center;padding:0 4px}
.studio-advanced[open]>summary{margin-bottom:8px}
.studio-advanced[open]{color:var(--text);font-size:15px}
.studio-advanced .studio-criteria,.studio-advanced .studio-runbar,.studio-advanced .studio-results{margin-top:12px}
.studio-fine{color:var(--muted);font-size:11px}
/* the sentence */
.studio-sentence{font-size:15px;line-height:1.9;min-height:34px;overflow-wrap:anywhere}
.studio-sentence.studio-drop{outline:2px dashed var(--accent);outline-offset:2px;border-radius:8px}
.rule-studio .studio-tok.btn{display:inline-flex;align-items:center;gap:5px;min-height:30px;border:1px solid var(--border);background:var(--bg-2);border-radius:9px;padding:1px 9px;margin:1px 2px;font-size:13px;line-height:1.7;vertical-align:middle;white-space:normal;text-align:left}
.rule-studio .studio-tok-scope.btn{font-weight:600}
.rule-studio .studio-tok-add.btn{border-style:dashed;color:var(--accent)}
.studio-tok-unknown{display:inline-block;border:1px solid var(--yellow,#b58a12);color:var(--yellow,#b58a12);border-radius:9px;padding:1px 9px;margin:1px 2px;font-size:13px;line-height:1.7;vertical-align:middle}
.studio-conds{display:inline}
.studio-chip{display:inline-flex;align-items:stretch;border:1px solid color-mix(in srgb,var(--accent) 55%,transparent);background:color-mix(in srgb,var(--accent) 16%,transparent);border-radius:9px;margin:1px 0;vertical-align:middle;font-size:13px;line-height:1.7;max-width:100%}
.studio-chip-text,.studio-chip-x{border:0;background:transparent;color:inherit;font:inherit;cursor:pointer;min-height:30px}
.studio-chip-text{padding:1px 4px 1px 9px;text-align:left}
.studio-chip-x{padding:0 8px 0 4px;color:var(--muted);font-size:14px;border-radius:0 9px 9px 0}
.studio-chip-x:hover{color:var(--red)}
.studio-chip-hot{animation:studio-pulse .9s ease-out}
.studio-chip-ghost{opacity:.6;border-style:dashed}
@keyframes studio-pulse{0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--accent) 55%,transparent)}100%{box-shadow:0 0 0 10px transparent}}
.studio-glue{display:inline-block;color:var(--muted);font-size:12px;margin:0 3px;vertical-align:middle}
.studio-glue.any{color:var(--accent);font-weight:700}
/* read-only sentence (management rows): the same tokens and chips, no buttons */
.studio-sentence-static{display:block;font-size:13px;line-height:1.9}
.studio-sentence-static .studio-tok-static{display:inline-flex;align-items:center;min-height:26px;border:1px solid var(--border);background:var(--bg-2);border-radius:9px;padding:0 8px;margin:1px 2px;font-size:12px;line-height:1.7;vertical-align:middle;white-space:normal}
.studio-sentence-static .studio-tok-scope{font-weight:600}
.studio-sentence-static .studio-chip{font-size:12px}
.studio-sentence-static .studio-chip-text{display:inline-block;min-height:26px;padding:0 8px;cursor:default}
/* one outcome-labelled choice instead of AND/OR tokens */
.studio-op{display:flex;gap:6px;margin-top:8px}
.studio-op[hidden]{display:none}
.studio-op-choice{flex:1;min-width:0;border:1px solid var(--border);background:var(--bg-2);color:var(--text);border-radius:10px;padding:6px 8px;font:inherit;font-size:12px;cursor:pointer;text-align:left;line-height:1.3;min-height:44px}
.studio-op-choice b{display:block;font-size:13px}
.studio-op-choice small{color:var(--muted)}
.studio-op-choice[aria-pressed=true]{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 16%,transparent)}
/* sentence input */
.studio-ask{display:flex;gap:6px;margin-top:8px}
.studio-ask-input{flex:1;min-width:0;box-sizing:border-box;background:var(--bg-2);border:1px solid var(--border);color:var(--text);border-radius:10px;padding:8px 10px;font:inherit;font-size:16px;min-height:44px}
.studio-ask-input:focus{outline:2px solid var(--accent);outline-offset:0;border-color:transparent}
.studio-mic{border:1px solid var(--border);background:var(--bg-2);color:var(--text);border-radius:10px;min-width:44px;min-height:44px;padding:0 10px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center}
.studio-mic[hidden]{display:none}
.studio-mic.live{background:var(--accent);color:var(--accent-ink,#1a1400);border-color:var(--accent)}
.studio-mic-icon{width:20px;height:20px}
.studio-ask-hint{font-size:12px;color:var(--muted);margin:6px 0 0;min-height:16px}
.studio-examples,.studio-pills{display:flex;gap:6px;margin-top:8px;overflow-x:auto;padding-bottom:2px;scrollbar-width:none;align-items:center}
.studio-examples::-webkit-scrollbar,.studio-pills::-webkit-scrollbar{display:none}
.studio-examples>.studio-fine{flex:none}
.studio-example{flex:none;border:1px dashed var(--border);background:transparent;color:var(--text);border-radius:999px;padding:6px 10px;font:inherit;font-size:12px;cursor:pointer;white-space:nowrap;min-height:32px}
/* signal pills */
.studio-pill{flex:none;border:1px solid var(--border);background:var(--bg-2);color:var(--text);border-radius:999px;padding:6px 11px;font:inherit;font-size:13px;cursor:grab;display:inline-flex;align-items:center;gap:6px;min-height:36px;white-space:nowrap}
.studio-pill:active{cursor:grabbing}
.studio-pill-count{color:var(--muted);font-size:11px;font-variant-numeric:tabular-nums}
.studio-pill[aria-pressed=true]{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 16%,transparent)}
.studio-pill[aria-pressed=true] .studio-pill-count{color:var(--accent)}
/* A ✓ pill is a toggle: the mark is the selected state; a pointer or keyboard focus on desktop previews the removal
   (× in the danger colour, the title says "Tap to remove"). Touch screens keep the ✓ and tap once to remove. */
.studio-pill-mark{color:var(--accent);font-weight:600;line-height:1}
.studio-pill-mark::before{content:'✓'}
.studio-pill[aria-pressed=true]:focus-visible{border-color:var(--red)}
.studio-pill[aria-pressed=true]:focus-visible .studio-pill-mark{color:var(--red)}
.studio-pill[aria-pressed=true]:focus-visible .studio-pill-mark::before{content:'×'}
@media (hover:hover){
.studio-pill[aria-pressed=true]:hover{border-color:var(--red)}
.studio-pill[aria-pressed=true]:hover .studio-pill-mark{color:var(--red)}
.studio-pill[aria-pressed=true]:hover .studio-pill-mark::before{content:'×'}
}
.studio-pill-soon{opacity:.5;cursor:not-allowed}
.studio-mini-hist{width:34px;height:14px;color:var(--muted)}
/* sheet: parameters, scope, cap */
.studio-sheet{background:var(--surface);border:1px solid var(--border);border-radius:12px;margin-top:10px;padding:12px}
.studio-sheet:focus{outline:none}
.studio-sheet-stack{display:grid;gap:0;margin-top:10px;border:1px solid var(--border);border-radius:12px;background:var(--surface);overflow:clip}
.studio-sheet-stack>.studio-sheet-inline{margin:0;border:0;border-radius:0;background:transparent;padding:11px 12px 13px}
.studio-sheet-stack>.studio-sheet-inline+.studio-sheet-inline{border-top:1px solid var(--border)}
.studio-sheet-stack>.studio-sheet-inline.is-active{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 72%,transparent);background:color-mix(in srgb,var(--accent) 4%,transparent)}
.studio-sheet-details{display:flex;align-items:center;gap:8px;min-width:0}
.studio-sheet-details>.studio-sheet-head{flex:1 1 180px;margin:0}
.studio-sheet-details>.studio-rsi-period{flex:none}
.studio-sheet-details>.studio-sheet-actions{flex:none;margin:0}
.studio-sheet-fields{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(220px,100%),1fr));gap:10px 16px;min-width:0}
.studio-sheet-inline>.studio-method-line{margin:3px 0 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.studio-sheet-head{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:14px;font-weight:600;margin-bottom:6px}
.studio-sheet-title-wrap{min-width:0;overflow-wrap:anywhere}
.studio-sheet-count{font-weight:400;margin-left:4px}
.studio-sheet-row{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-top:8px}
.studio-sheet-row>.studio-scope-input{flex:1 1 160px;min-width:0;min-height:44px;font-size:16px}
.rule-studio .studio-choice.btn{border-radius:999px;white-space:normal;text-align:left}
.rule-studio .studio-choice.btn[aria-pressed=true],.rule-studio .studio-preset.btn[aria-pressed=true]{border-color:var(--accent);color:var(--accent-text,var(--text));background:color-mix(in srgb,var(--accent) 16%,transparent)}
.rule-studio .studio-rsi-period{display:flex;align-items:center;gap:6px;margin:0}
.rule-studio .studio-rsi-period>.studio-fine{position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden;white-space:nowrap}
.rule-studio .studio-rsi-period .studio-sheet-row{gap:0}
.rule-studio .studio-rsi-period .studio-choice.btn{min-height:38px;border-radius:0;margin-left:-1px;padding:7px 14px}
.rule-studio .studio-rsi-period .studio-choice.btn:first-child{margin-left:0;border-radius:9px 0 0 9px}
.rule-studio .studio-rsi-period .studio-choice.btn:last-child{border-radius:0 9px 9px 0}
.studio-sheet .studio-scalar{margin-top:8px}
.studio-sheet-presets{align-items:center}
.studio-sheet-presets>.studio-fine{margin-right:2px}
.studio-method-line{margin:10px 0 0}
.studio-method-line code{font-family:ui-monospace,"SF Mono",Menlo,Consolas,monospace;font-size:11px}
.studio-sheet-actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.studio-sheet-details .studio-sheet-actions>.btn{min-height:36px;padding:6px 9px;font-size:12px}
.rule-studio .studio-danger.btn{color:var(--red)}
.studio-scrim{display:none}
/* results list */
.studio-instant-body{min-width:0;flex:1 1 auto}
.rule-simulation{min-width:0}
.rule-simulation-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.rule-simulation-head h2{margin:0;font-size:20px}
.rule-simulation-name{font-weight:600;margin:8px 0}
.rule-simulation-context{margin:12px 0;padding:12px;border:1px solid var(--border);border-radius:12px;background:var(--surface)}
.rule-simulation-context h3{font-size:14px;margin:0 0 8px;color:var(--muted)}
.rule-simulation-sentence{display:flex;align-items:center;gap:6px;flex-wrap:wrap;line-height:1.7}
.rule-simulation .perf-controls{margin-bottom:12px}
.monitor-simulate{margin:4px 0;min-height:44px}
.instant-head{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;margin-bottom:6px}
.instant-summary{font-size:13px;color:var(--muted);margin:0;min-width:0}
.instant-summary b{color:var(--text);font-size:16px;font-variant-numeric:tabular-nums}
.instant-summary b.instant-big.hot{color:var(--accent)}
.studio-seg{display:inline-flex;border:1px solid var(--border);border-radius:999px;overflow:hidden;flex:none}
.studio-seg>button{border:0;background:transparent;color:var(--muted);padding:5px 10px;font:inherit;font-size:12px;cursor:pointer;min-height:32px;white-space:nowrap}
.studio-seg>button[aria-pressed=true]{background:var(--bg-2);color:var(--text);font-weight:600}
.instant-ctl{display:flex;gap:8px;align-items:center;justify-content:space-between;margin:4px 0 6px;flex-wrap:wrap}
.instant-state{margin:8px 0}
.instant-stale .instant-list{opacity:.55;transition:opacity .15s}
.instant-list{list-style:none;margin:6px 0;padding:0;display:flex;flex-direction:column;gap:4px}
.instant-row{display:grid;grid-template-columns:64px minmax(0,1fr) auto;gap:8px;align-items:center;padding:6px 8px;border-radius:9px;background:var(--bg-2);border:1px solid var(--border);min-width:0;font-variant-numeric:tabular-nums}
.instant-row.instant-changed{animation:instant-flash 1.4s ease-out}
@keyframes instant-flash{0%{background:color-mix(in srgb,var(--green) 16%,var(--bg-2));border-color:var(--green)}100%{background:var(--bg-2);border-color:var(--border)}}
.instant-row.instant-dim{opacity:.55}
.instant-tk{min-width:0}
.instant-tk .ticker-chip{display:inline-block;min-height:0;padding:0;border:0;background:transparent;font-family:ui-monospace,"SF Mono",Menlo,Consolas,monospace;font-weight:700;font-size:13px;line-height:1.2}
.instant-name{display:block;color:var(--muted);font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.instant-st{font-size:12px;color:var(--muted);min-width:0;line-height:1.3}
.instant-when{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.instant-dots{display:inline-flex;gap:3px;margin-right:6px;vertical-align:middle}
.instant-dot{width:7px;height:7px;border-radius:50%;border:1px solid var(--muted);display:inline-block}
.instant-dot.on{background:var(--green);border-color:var(--green)}
.instant-dot.unk{border-style:dashed}
.instant-now{display:inline-block;border-radius:999px;padding:0 6px;font-size:10px;border:1px solid var(--border);margin-right:4px;white-space:nowrap}
.instant-now.now-matched{color:var(--green);border-color:var(--green)}
.instant-now.now-non_match{color:var(--muted);border-color:transparent;padding:0;margin-right:6px}
.instant-side{display:flex;align-items:center;gap:8px;justify-content:flex-end}
.instant-change{display:flex;flex-direction:column;align-items:flex-end;gap:0;text-align:right;white-space:nowrap;line-height:1.2}
.instant-bench{display:block;max-width:14ch;white-space:normal;line-height:1.25}.instant-spy{font-size:10px;color:var(--muted);white-space:nowrap}
.return-badge{font-weight:700;font-size:13px;white-space:nowrap}
/* Returns follow the change-colour setting (T-12: --pos / --neg swap under 红涨绿跌); stance colours are --bull / --bear. */
.return-up{color:var(--pos,var(--green))}.return-down{color:var(--neg,var(--red))}.return-flat{color:var(--muted)}
.instant-spark{width:56px;height:18px;color:var(--muted);flex:none}.instant-spark .spark-marker{fill:var(--accent)}
.instant-method{font-size:11px;color:var(--muted);margin:10px 0 0}
.instant-note{padding:12px;border:1px solid var(--border);border-radius:10px;margin:8px 0}
/* action bar */
.studio-bar{position:sticky;bottom:0;margin-top:10px;padding:8px 0 calc(4px + var(--safe-bottom,0px));background:var(--surface);display:flex;gap:10px;align-items:center;justify-content:space-between;z-index:4}
.studio-bar-n{font-size:12px;color:var(--muted);min-width:0}
.studio-bar-n b{color:var(--text);font-size:14px}
.rule-studio .studio-start.btn{min-height:44px;font-weight:700;white-space:nowrap}
.studio-toast{pointer-events:auto;display:flex;gap:12px;align-items:center}
.studio-toast-undo{border:0;background:transparent;color:var(--accent);font:inherit;font-weight:600;cursor:pointer;min-height:32px;padding:0 4px}
/* advanced editor keeps its block palette */
.studio-blocks{display:flex;flex-wrap:wrap;gap:6px;margin:10px 0}
.studio-block{display:inline-flex;align-items:center;gap:0;border:1px dashed var(--border);border-radius:10px;background:var(--bg-2)}
.studio-block .studio-handle.btn{width:36px;min-width:36px;font-size:18px}
.studio-block-add.btn{border:0;white-space:nowrap}
@media(max-width:560px){.studio-block .studio-handle.btn{width:44px;min-width:44px}}
@media(max-width:560px){
  .studio-blocks{flex-wrap:nowrap;overflow-x:auto;scroll-snap-type:x proximity;padding-bottom:4px;-webkit-overflow-scrolling:touch}
  .studio-block{flex:none;scroll-snap-align:start}
  .studio-explanation{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;cursor:pointer}
  .studio-explanation[aria-expanded=true]{display:block}
}
/* Phone: conditions and filtered stocks are two explicit side-by-side choices. Only the selected pane is in
   the reading flow, so a tall condition stack can never cover or push the stock results several screens away. */
@media(max-width:900px){
  .studio-sentence-first{font-size:13px}
  .studio-sentence-first .studio-head h2{font-size:17px}
  .studio-sentence-layout{display:flex;flex-direction:column;align-items:stretch;gap:8px}
  .studio-mobile-nav{position:sticky;top:0;z-index:7;display:grid;grid-template-columns:1fr 1fr;padding:4px;background:var(--surface);border:1px solid var(--border);border-radius:12px;scroll-margin-top:0}
  .studio-mobile-pane{min-width:0;min-height:44px;padding:8px 10px;border:0;border-radius:8px;background:transparent;color:var(--muted);font:inherit;font-size:14px;font-weight:600;cursor:pointer}
  .studio-mobile-pane[aria-pressed=true]{background:var(--bg-2);color:var(--text);box-shadow:inset 0 0 0 1px var(--border)}
  .studio-mobile-pane:focus-visible{outline:3px solid var(--focus,var(--accent));outline-offset:1px}
  .studio-sentence-first[data-mobile-pane=conditions] .studio-instant{display:none}
  .studio-sentence-first[data-mobile-pane=results] .studio-sentence-editor{display:none}
  .app-main:has(.studio-sentence-first){padding-bottom:0}
  .studio-sentence-first{padding-bottom:0}
  .studio-sentence-editor{position:static;padding:10px}
  .app-main:has(.studio-sentence-first){overflow-x:hidden}
  .studio-ask-hint:empty{display:none}
  .studio-examples[data-idle]{display:none}
  .instant-summary{font-size:12px}
  .studio-sentence{font-size:14px;line-height:1.8}
  .studio-sentence-first .studio-instant{position:static;max-height:none;overflow:visible;padding:10px}
  .studio-sheet-host .studio-sheet-modal{position:fixed;left:0;right:0;bottom:0;z-index:40;border-radius:16px 16px 0 0;margin:0;padding:12px 16px calc(14px + var(--safe-bottom,0px));box-shadow:0 -12px 40px rgba(0,0,0,.4);max-height:72vh;overflow-y:auto;overscroll-behavior:contain}
  .studio-sheet-stack{margin-top:8px}
  .studio-sheet-stack>.studio-sheet-inline{padding:10px 10px 12px}
  .studio-scrim{display:block;position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:39}
  .instant-row{grid-template-columns:60px minmax(0,1fr) auto;gap:6px;padding:6px}
  .studio-bar{margin-top:6px;padding:6px 0 calc(8px + var(--safe-bottom,0px))}
}
@media(max-width:380px){.instant-spark{display:none}}
@media(prefers-reduced-motion:reduce){.rule-studio *{animation:none!important;transition:none!important}}
