/*
 * css/studio.css: BrainDev Studio shell. plan3's app/studio.css translated to plain CSS (same structure, spacing,
 * radii, borders, type sizes and states), copper replaced by the green family from css/tokens.css, plus the
 * BrainDev additions (wallet gate, account chip, on-chain panels) and a real phone layout (SPEC 2):
 * bottom tab bar, bottom-sheet panels, automatic List view, one-row toolbar with an overflow menu.
 */

html:has(body.studio-page), body.studio-page { height: 100%; overflow: hidden; }
body.studio-page { background: var(--studio-bg); overscroll-behavior: none; }
.studio-noscript { padding: 24px; color: var(--muted-foreground); }

.studio {
  --studio-readable: var(--muted-foreground);
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--studio-bg);
  color: var(--foreground);
  font-size: 13px;
  overflow: hidden;
}
.studio-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--studio-bg);
  color: var(--muted-foreground);
}
.studio-loading img { border-radius: 7px; opacity: .9; }

/* ------------------------------------------------------------------ base controls (plan3) */

.studio button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.25;
}
.studio button:hover:not(:disabled),
.studio button.active { background: var(--studio-hover); }
.studio button:disabled { opacity: .35; cursor: default; }
.studio :is(button, a, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.studio .studio-panel:focus, .studio .studio-viewport:focus:not(:focus-visible) { outline: none; }
.studio svg { width: 15px; height: 15px; flex-shrink: 0; }
.studio input:not([type="checkbox"]):not([type="radio"]),
.studio select,
.studio textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--studio-field);
  background: var(--studio-bg);
  color: var(--foreground);
  border-radius: 5px;
  padding: 9px 10px;
  font: inherit;
}
.studio select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aaa294' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; background-size: 14px; }
.studio input[type="date"] { color-scheme: dark; }
.studio textarea { resize: vertical; line-height: 1.6; }
.studio input::placeholder, .studio textarea::placeholder { color: #7d7669; }
.studio label { display: flex; flex-direction: column; gap: 7px; color: var(--studio-label); font-size: 12px; }
.studio label small, .studio .studio-field small { color: var(--studio-dim); line-height: 1.5; font-size: 11px; }
.studio input[type="checkbox"] { accent-color: var(--green); width: 15px; height: 15px; margin: 0; flex-shrink: 0; }
.studio .studio-primary { background: var(--green); color: var(--primary-foreground); font-weight: 650; border-color: var(--green); }
.studio .studio-primary:hover:not(:disabled) { background: var(--green-hover); border-color: var(--green-hover); }
.studio .studio-danger-quiet { color: #e8897a; }
.studio code, .studio kbd { font-family: var(--font-mono); font-size: 11px; }
.studio kbd { display: inline-block; padding: 1px 5px; border: 1px solid var(--studio-edge); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-soft); color: var(--sidebar-foreground); }
.studio summary { cursor: pointer; padding: 10px 0; font-size: 14px; }
.studio-viewport, .studio-canvas-tools, .studio-block-content, .studio-panel-scroll, .studio-preset-list {
  scrollbar-color: var(--studio-scroll) var(--studio-scroll-track);
  scrollbar-width: thin;
}

/* ------------------------------------------------------------------ header */

.studio-header {
  position: relative;
  z-index: 20;
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: var(--studio-header);
  border-bottom: 1px solid var(--studio-line);
}
.studio-brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; text-decoration: none; color: var(--foreground); border-radius: 6px; }
.studio-brand img { width: 26px; height: 26px; border-radius: 7px; }
.studio-brand strong { letter-spacing: .13em; font-size: 17px; font-weight: 700; line-height: 1; }
.studio-brand strong em { font-style: normal; color: var(--green); }
.studio-brand > span { font: 9px var(--font-mono); color: var(--studio-dim); letter-spacing: .13em; padding-left: 8px; border-left: 1px solid var(--studio-field); line-height: 14px; }
.studio .studio-board-switch { min-width: 0; flex: 0 1 auto; max-width: 340px; justify-content: flex-start; font-size: 13px; font-weight: 550; }
.studio-board-switch > svg:first-child { color: var(--muted-foreground); }
.studio-board-switch span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio .studio-chev { width: 12px; height: 12px; color: var(--studio-dim); }
.studio-saved { display: flex; gap: 5px; align-items: center; color: var(--studio-dim); font-size: 11px; white-space: nowrap; min-width: 0; }
.studio-saved span { overflow: hidden; text-overflow: ellipsis; }
.studio-saved svg { color: var(--teal); width: 12px; }
.studio-header-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
.studio .studio-account { gap: 7px; border-color: var(--studio-edge); font-size: 12px; padding: 5px 9px; }
.studio .studio-account .mono { letter-spacing: .02em; }
.studio-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 3px rgba(66, 181, 154, .12); flex-shrink: 0; }
.studio-dot.is-wrong, .studio-account.is-wrong .studio-dot { background: var(--ochre); box-shadow: 0 0 0 3px rgba(200, 174, 98, .14); }
.studio .studio-account.is-wrong { border-color: #5a4a2a; }

/* ------------------------------------------------------------------ toolbar */

.studio-toolbar {
  position: relative;
  z-index: 15;
  display: flex;
  gap: 14px;
  align-items: center;
  min-height: 44px;
  flex-shrink: 0;
  padding: 0 18px;
  background: var(--studio-toolbar);
  border-bottom: 1px solid var(--studio-line);
}
.studio-tabs { display: flex; gap: 3px; flex-shrink: 0; }
.studio .studio-tabs button.active { background: var(--green-wash); color: var(--green-bright); }
.studio-divider { width: 1px; height: 20px; background: var(--studio-field); flex-shrink: 0; }
.studio-context { display: flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--studio-label); font-size: 12px; min-width: 0; }
.studio-context > svg { color: var(--green); }
.studio-context .bd-asset-btn { min-width: 96px; }
.studio-subtle { color: var(--muted-foreground); font-size: 11px; line-height: 1.6; }
.studio-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.studio-toolbar-end { margin-left: auto; display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.studio .studio-viewtoggle { white-space: nowrap; }
.studio .studio-data-state { font: 10px var(--font-mono); color: var(--muted-foreground); padding-left: 8px; gap: 7px; white-space: nowrap; max-width: 220px; }
.studio-data-state span { overflow: hidden; text-overflow: ellipsis; }
.studio-data-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--studio-dim); flex-shrink: 0; }
.studio-data-state[data-tone="ok"] i { background: var(--teal); box-shadow: 0 0 0 3px rgba(66, 181, 154, .1); }
.studio-data-state[data-tone="partial"] i { background: var(--ochre); }
.studio-data-state[data-tone="down"] i { background: var(--brick); }
.studio-data-state[data-tone="pending"] i { animation: studio-pulse 1.2s ease-in-out infinite; }
@keyframes studio-pulse { 50% { opacity: .3; } }
.studio .studio-more { display: none; }

/* ------------------------------------------------------------------ body, rail */

.studio-body { position: relative; display: flex; min-height: 0; flex: 1; }
.studio-rail {
  width: 64px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 5px;
  border-right: 1px solid var(--studio-line);
  background: var(--studio-header);
  z-index: 10;
}
.studio .studio-rail button { width: 52px; min-height: 49px; display: flex; flex-direction: column; gap: 6px; padding: 7px 0; color: var(--muted-foreground); }
.studio .studio-rail span { font-size: 12px; }
.studio .studio-rail button.active { color: var(--green-bright); background: var(--studio-hover); }
.studio-rail-bottom { margin-top: auto; }
.studio-workarea { display: flex; flex-direction: column; flex: 1; min-width: 0; position: relative; }

.studio-recovery-banner, .studio-view-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--green);
  font-size: 13px;
}
.studio-recovery-banner { border-bottom-color: var(--ochre); }
.studio-view-banner > span { flex: 1; min-width: 200px; color: var(--sidebar-foreground); }
.studio-view-banner > svg { color: var(--green); }

/* ------------------------------------------------------------------ canvas tools */

.studio-canvas-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 4px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--studio-line);
  overflow-x: auto;
  background: var(--studio-bg);
}
.studio-canvas-count { color: var(--muted-foreground); font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.studio-build-tools { display: flex; align-items: center; gap: 4px; border-left: 1px solid var(--studio-line); padding-left: 8px; }
.studio-canvas-tools button, .studio-build-tools strong { flex-shrink: 0; white-space: nowrap; }
.studio-build-tools strong { font-size: 12px; font-weight: 550; padding: 0 6px; }
.studio .studio-build-tools button[aria-pressed="true"] { color: var(--foreground); background: var(--green-soft); }
.studio .studio-canvas-help { margin-left: auto; color: var(--muted-foreground); }

/* ------------------------------------------------------------------ viewport, stage, blocks */

.studio-viewport {
  position: relative;
  isolation: isolate;
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 0 12px 12px;
  background-color: var(--canvas);
  background-image: radial-gradient(#383229 1px, transparent 1px);
  background-size: 20px 20px;
  overscroll-behavior: contain;
}
.studio-viewport.is-space { cursor: grab; }
.studio-viewport.is-panning { cursor: grabbing; user-select: none; }
.studio-viewport.is-dragging { user-select: none; }
.studio-scaled { position: relative; }
.studio-stage { position: relative; transform-origin: top left; }
.studio-block {
  position: absolute;
  border: 1px solid #3b352c;
  border-radius: 7px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 2px 3px #0002;
  transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
}
.studio-block.is-selected { border-color: var(--green); box-shadow: 0 0 0 1px #3fbf6e40, 0 8px 26px rgba(0, 0, 0, .22); }
.studio-block-header {
  min-height: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 4px 0 1px;
  border-bottom: 1px solid #322d26;
  background: var(--studio-block-head);
  flex-shrink: 0;
}
.studio .studio-grip {
  flex: 1;
  justify-content: flex-start;
  min-width: 0;
  min-height: 36px;
  font-size: 13px;
  font-weight: 550;
  gap: 8px;
  cursor: grab;
  touch-action: none;
  padding: 4px 8px;
}
.studio .studio-grip:active:not(:disabled) { cursor: grabbing; }
.studio-grip svg { color: #7a7061; width: 12px; }
.studio-grip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio .studio-grip:disabled { opacity: 1; cursor: default; }
.studio .studio-block-header > .studio-block-act { min-height: 36px; min-width: 36px; padding: 3px 5px; color: var(--muted-foreground); }
.studio .studio-block-header > .studio-block-act:hover { color: var(--foreground); }
.studio .studio-block-header > .studio-block-act[aria-pressed="true"] { color: var(--green); }
.studio-block-header > .studio-block-act svg { width: 13px; }
.studio-block-lock { display: inline-grid; place-items: center; width: 24px; color: var(--studio-dim); }
.studio-block-lock svg { width: 12px; height: 12px; }
.studio-block-content { position: relative; min-height: 0; flex: 1; overflow: auto; scrollbar-width: thin; }
.studio-widget-host { min-height: 100%; display: flex; flex-direction: column; }
.studio-widget-host > * { flex: 1; }
.studio .studio-resize {
  position: absolute;
  bottom: 0;
  right: 0;
  min-height: 20px;
  height: 20px;
  width: 20px;
  padding: 0;
  cursor: nwse-resize;
  touch-action: none;
  color: #80958a;
  background: #211e1ac9;
  border-radius: 5px 0 0 0;
  z-index: 5;
}
.studio-resize svg { width: 13px; }
.studio-connections { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; z-index: 1; }
.studio-connections path:not([fill]) { fill: none; stroke: var(--green); stroke-width: 1.4; opacity: .7; }
.studio-connections text { font: 9px var(--font-sans); fill: #9ccdb0; paint-order: stroke; stroke: var(--canvas); stroke-width: 4px; }
.studio-empty { position: absolute; top: 0; left: 0; padding: 80px 65px; max-width: 760px; }
.studio-empty h1 { font-size: 50px; line-height: 1.1; letter-spacing: -.055em; margin: 20px 0; font-weight: 450; }
.studio-empty p { line-height: 1.8; color: var(--muted-foreground); margin-bottom: 24px; }
.studio-empty .eyebrow { color: var(--green-muted); }

/* list view (plan3) */
.studio-list-view .studio-scaled { width: 100% !important; height: auto !important; }
.studio-list-view .studio-stage { width: 100% !important; height: auto !important; transform: none !important; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; padding: 16px 4px; }
.studio-list-view .studio-block { position: relative !important; left: auto !important; top: auto !important; width: 100% !important; height: auto !important; min-height: 280px; }
.studio-list-view .studio-block-content { height: auto; max-height: none; overflow: visible; }
.studio-list-view .studio-resize { display: none; }
.studio-list-view .studio-connections { display: none; }
.studio-list-view .studio-empty { position: static; transform: none; padding: 24px; }

/* widget fallbacks (registry missing / widget threw) */
.sw-fallback { display: flex; flex-direction: column; gap: 16px; padding: 17px 18px 12px; color: var(--muted-foreground); font-size: 12px; min-height: 100%; }
.sw-fallback i { display: block; background: var(--muted); height: 24px; border-radius: 4px; animation: studio-pulse 1.6s ease-in-out infinite; }
.sw-fallback i:nth-of-type(2) { height: 56px; width: 70%; }
.sw-fallback small { color: var(--studio-dim); font-size: 11px; }
.sw-error { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 24px 18px; color: var(--sidebar-foreground); font-size: 12px; line-height: 1.6; }
.sw-error p { color: var(--muted-foreground); }
.sw-error button { border-color: var(--studio-edge) !important; }

/* ------------------------------------------------------------------ canvas footer (bottom bar) */

.studio-canvas-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 40px;
  flex-shrink: 0;
  border-top: 1px solid var(--studio-line);
  padding: 0 12px;
  color: var(--studio-dim);
  font-size: 12px;
  background: var(--studio-bg);
}
.studio-foot-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.studio-foot-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.studio .studio-foot-chip { min-height: 26px; padding: 3px 8px; gap: 7px; border-color: var(--studio-line); color: var(--muted-foreground); font-size: 11px; flex-shrink: 0; }
.studio .studio-foot-chip svg { width: 13px; height: 13px; }
.studio-zoom { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.studio-zoom-label { font: 10px var(--font-mono); width: 40px; text-align: center; }
.studio-canvas-footer button { min-height: 26px; }

/* ------------------------------------------------------------------ wallet gate (SPEC 6 login) */

.studio-gate {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow-y: auto;
  background: radial-gradient(circle at 50% 40%, rgba(21, 20, 17, .55), rgba(10, 9, 8, .86));
  backdrop-filter: blur(2px);
}
.studio-gate-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 30px 28px 24px;
  border: 1px solid #3a5444;
  border-radius: 10px;
  background: #1d1b18;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  text-align: left;
}
.studio-gate-mark { width: 44px; height: 44px; border-radius: 10px; }
.studio-gate-card .eyebrow { font-size: 10px; color: var(--green-muted); }
.studio-gate-card h2 { font-size: 27px; line-height: 1.15; letter-spacing: -.04em; font-weight: 550; margin: -4px 0 0; }
.studio-gate-card > p { color: var(--muted-foreground); font-size: 14px; line-height: 1.6; }
.studio .studio-gate-look { align-self: center; color: var(--muted-foreground); font-size: 13px; min-height: 40px; }
.studio .studio-gate-look:hover { color: var(--foreground); }
.studio-gate-card > small { color: var(--studio-dim); font: 10px/1.5 var(--font-mono); text-align: center; letter-spacing: .02em; }
.studio.has-gate .studio-viewport { filter: saturate(.7) brightness(.8); }

/* ------------------------------------------------------------------ panel (right drawer) */

.studio-panel {
  width: 370px;
  max-width: 90vw;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--studio-panel);
  border-left: 1px solid #3b352c;
  min-height: 0;
  z-index: 20;
}
.studio-panel[hidden] { display: none !important; }
.studio-panel-handle { display: none; }
.studio-panel > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 18px 16px; border-bottom: 1px solid var(--studio-line); flex-shrink: 0; }
.studio-panel h2 { font-size: 18px; margin: 7px 0 0; font-weight: 550; letter-spacing: -.03em; }
.studio-panel .eyebrow { font-size: 10px; color: var(--green-muted); letter-spacing: .12em; }
.studio .studio-panel-close { min-width: 36px; }
.studio-panel-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.studio-panel-scroll { padding: 20px 18px; display: flex; flex-direction: column; gap: 20px; min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; }
/* buttons carry an explicit min-height, so without this the column squeezes tall rows instead of scrolling */
.studio-panel-scroll > * { flex-shrink: 0; }
.studio .studio-panel p { font-size: 14px; line-height: 1.65; }
.studio .studio-panel :is(input, textarea, select) { font-size: 14px; }
.studio .studio-panel .studio-subtle { font-size: 12px; line-height: 1.6; }
.studio-panel h3 { font-size: 16px; font-weight: 550; letter-spacing: -.02em; line-height: 1.35; }
.studio-panel-intro { padding: 16px 18px; border-bottom: 1px solid var(--studio-line); }
.studio .studio-panel-intro p { font-size: 12px; line-height: 1.7; color: var(--muted-foreground); margin: 0 0 12px; }
.studio-library-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 12px 16px 0; }
.studio .studio-library-modes button { min-height: 40px; padding: 6px; white-space: normal; line-height: 1.25; border-color: var(--studio-line); }
.studio .studio-library-modes button[aria-pressed="true"] { background: var(--green-soft); color: var(--foreground); border-color: var(--green-soft); }
.studio-panel-scroll .studio-seg { padding: 0; }
.studio-search-scope { margin: 0; color: var(--muted-foreground); font-size: 11px !important; }
.studio .studio-search { flex-direction: row; align-items: center; gap: 8px; padding: 12px 18px; color: var(--muted-foreground); }
.studio .studio-search input { border: 0 !important; background: transparent !important; padding: 0 !important; }
.studio-library { width: 460px; }
.studio-preset-list { overflow-y: auto; padding: 0 14px 18px; display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; overscroll-behavior: contain; }
.studio-preset { border: 1px solid #3b352c; border-radius: 6px; background: var(--card); flex-shrink: 0; }
.studio-preset > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--studio-line); }
.studio-preset strong { font-size: 12px; }
.studio .studio-preset > p { padding: 10px 12px; font-size: 11px; color: var(--muted-foreground); border-top: 1px solid var(--studio-line); line-height: 1.5; margin: 0; }
.studio-preset-preview { height: 230px; position: relative; overflow: hidden; pointer-events: none; }
.studio-library-empty { border: 0; padding: 18px 4px; }
.studio-field-row { display: flex; gap: 10px; }
.studio-field-row > * { flex: 1; min-width: 0; }
.studio-field { display: flex; flex-direction: column; gap: 7px; }
.studio-field-label { color: var(--studio-label); font-size: 12px; }
.studio .studio-field-picker { width: 100%; min-height: 40px; font-size: 13px; }
.studio-panel fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.studio-panel legend { margin-bottom: 10px; padding: 0; font-size: 12px; color: var(--studio-label); }
.studio-symbols { display: flex; gap: 7px; flex-wrap: wrap; max-height: 170px; overflow: auto; }
.studio .studio-symbols label { flex-direction: row; align-items: center; gap: 6px; border: 1px solid #3b352c; padding: 6px 8px; border-radius: 4px; font: 11px var(--font-mono); cursor: pointer; }
.studio-stock-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 3px 3px 6px; border: 1px solid #3b352c; border-radius: 4px; font: 11px var(--font-mono); }
.studio .studio-stock-chip button { min-height: 24px; min-width: 24px; padding: 2px; color: var(--muted-foreground); }
.studio .studio-stock-chip button svg { width: 12px; height: 12px; }
.studio .studio-check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--sidebar-foreground); }
.studio-preview-section { display: flex; flex-direction: column; gap: 12px; }
.studio-editor-preview { height: 280px; overflow: auto; position: relative; border: 1px solid #34453a; background: var(--card); border-radius: 6px; }
.studio-position { display: flex; flex-direction: column; gap: 12px; padding-top: 18px; border-top: 1px solid var(--studio-line); }
.studio .studio-position input { padding: 8px 6px !important; }
.studio-relations { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--studio-line); padding-top: 18px; }
.studio .studio-relations > p { color: var(--muted-foreground); font-size: 12px; line-height: 1.5; }
.studio-relations > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; line-height: 1.6; }
.studio-relations em { font-style: normal; color: var(--green); }
.studio-panel-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid #3b352c; background: var(--studio-block-head); flex-shrink: 0; }
.studio-panel-footer > button[aria-label="Delete widget"] { margin-right: auto; color: #e8897a; }
.studio-form-error { width: 100%; margin: 0; color: var(--destructive); font-size: 13px !important; line-height: 1.5 !important; }

/* boards */
.studio .studio-board-row { border: 1px solid #3b352c !important; justify-content: flex-start !important; padding: 12px !important; text-align: left; align-items: flex-start; font-size: 13px; }
.studio-board-row > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.studio-board-row small { display: block; margin-top: 4px; color: var(--muted-foreground); font-size: 11px; }
.studio-board-row[aria-current="true"] { background: var(--accent) !important; }
.studio-board-row > svg:last-child:not(:first-child) { color: var(--green); }
.studio .studio-template { display: grid !important; grid-template-columns: 74px 1fr; text-align: left; border: 1px solid #3b352c !important; padding: 12px !important; gap: 4px 12px !important; justify-content: stretch; }
.studio-template > strong { font-size: 13px; align-self: end; }
.studio-template > span { color: var(--muted-foreground); font-size: 11px; line-height: 1.4; align-self: start; }
.template-art { grid-row: span 2; height: 50px; display: grid; grid-template-columns: 1fr 2fr; gap: 4px; padding: 5px; border: 1px solid #2f4a38; border-radius: 3px; }
.template-art i { background: #3b5a45; border-radius: 1px; }
.template-art i:first-child { background: #4fa872; }
.template-risk i:nth-child(3) { background: #3f8a5c; }
.template-blank i { background: none !important; border: 1px dashed #2f4a38; }

.studio-onchain-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid #33604a; border-radius: 6px; background: #1b201c; }
.studio-onchain-card .eyebrow { font-size: 10px; }
.studio .studio-onchain-card > p { font-size: 13px; color: var(--muted-foreground); line-height: 1.6; }
.studio-bytes { display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: var(--muted-foreground); }
.studio-bytes i { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--green) var(--fill, 0%), var(--muted) var(--fill, 0%)); }
.studio-bytes i.is-over { background: var(--brick); }
.studio-chain-list { display: flex; flex-direction: column; gap: 10px; }
.studio-chain-row { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid #3b352c; border-radius: 6px; background: var(--card); min-width: 0; }
.studio-chain-row-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.studio-chain-row strong { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.studio-chain-row small { color: var(--muted-foreground); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.studio .studio-chain-row p { font-size: 13px; color: var(--sidebar-foreground); line-height: 1.55; overflow-wrap: anywhere; }
.studio-chain-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.studio .studio-chain-row-actions button { border-color: var(--studio-edge); }
.studio .studio-chain-row-actions button.active, .studio .studio-icon-btn[aria-pressed="true"] { color: var(--ochre); }
.studio-signal-head { display: flex; align-items: center; gap: 9px; min-width: 0; }
.studio-signal-head strong { flex: 1; min-width: 0; font-family: var(--font-mono); font-weight: 500; letter-spacing: -.01em; }
.studio-badge { flex-shrink: 0; padding: 3px 7px; border-radius: 99px; font: 600 9px/1.2 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; background: var(--muted); color: var(--muted-foreground); }
.studio-badge.is-open { background: var(--teal-soft); color: var(--teal); }
.studio-badge.is-triggered, .studio-badge.is-executed { background: var(--green-soft); color: var(--green-bright); }
.studio-badge.is-expired, .studio-badge.is-cancelled { background: #2a2722; color: var(--studio-dim); }
.studio-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -6px; }
.studio .studio-quick button { min-height: 28px; padding: 3px 9px; border-color: var(--studio-edge); font: 11px var(--font-mono); }
.studio-sign-preview { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px dashed #33604a; border-radius: 6px; background: #161a17; margin: 0; }
.studio-sign-preview strong { font-size: 14px; font-weight: 550; line-height: 1.45; }
.studio-sign-preview span:not(.eyebrow) { color: var(--sidebar-foreground); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.studio-sign-preview small { color: var(--muted-foreground); font-size: 12px; line-height: 1.55; }
.studio-sign-preview ol { margin: 0; padding-left: 18px; color: var(--sidebar-foreground); font-size: 12px; line-height: 1.6; }
.studio-tx { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; line-height: 1.5; color: var(--muted-foreground); }
.studio-tx:empty { display: none; }
.studio-tx svg { width: 14px; height: 14px; margin-top: 2px; }
.studio-tx code { color: var(--studio-dim); }
.studio-tx.is-ok { color: var(--teal); }
.studio-tx.is-error { color: #e8897a; }
.studio-tx > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.studio-empty-state { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px; border: 1px dashed #3b352c; border-radius: 6px; }
.studio-empty-state strong { font-size: 13px; font-weight: 600; }
.studio .studio-empty-state p { font-size: 12px; color: var(--muted-foreground); line-height: 1.6; }
.studio .studio-empty-state button { border-color: var(--studio-edge); }
.studio-skeleton { display: flex; flex-direction: column; gap: 8px; }
.studio-skeleton i { display: block; height: 58px; border-radius: 6px; background: var(--muted); animation: studio-pulse 1.6s ease-in-out infinite; }

/* agent (plan3) */
.studio-gemini, .studio-agent-form { display: flex; flex-direction: column; gap: 12px; }
.studio-agent-note { border-bottom: 1px solid #3b352c; padding-bottom: 18px; }
.studio-agent-note > svg { color: var(--green); width: 24px; height: 24px; }
.studio-agent-note h3 { font-size: 20px; letter-spacing: -.03em; font-weight: 500; margin: 12px 0; }
.studio .studio-agent-note p { color: var(--muted-foreground); line-height: 1.7; font-size: 13px; }
.studio-agent-error { color: var(--destructive); font-size: 13px; margin: 0; }
.studio-agent-error:empty { display: none; }
.studio-agent-fallback { margin: 8px 0 0; display: flex; flex-direction: column; gap: 10px; }
.studio-agent-fallback[open] > *:not(summary) { margin-top: 8px; }
.studio-agent-answer { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 0; padding: 16px; border: 1px solid var(--border); border-radius: 6px; }
.studio-agent-answer > p { white-space: pre-wrap; overflow-wrap: anywhere; }
.studio-agent-answer ul { padding-left: 20px; display: grid; gap: 10px; font-size: 13px; line-height: 1.6; margin: 0; }
.studio-agent-answer h4 { margin: 4px 0 0; font-size: 13px; font-weight: 600; }
.studio-proposal { border: 1px solid #33604a; padding: 16px; border-radius: 6px; display: flex; flex-direction: column; gap: 12px; background: #191d1a; }
.studio .studio-proposal > p { font-size: 12px; color: var(--muted-foreground); }
.studio-proposal ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.studio-proposal li { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.studio-proposal small { color: var(--muted-foreground); }
.studio .studio-change { flex-direction: row; align-items: flex-start; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.studio-change-list { display: grid; gap: 8px; }
.studio-change input { margin-top: 3px !important; }
.studio-change > span { display: grid; gap: 6px; min-width: 0; color: var(--foreground); }
.studio-change strong { font-size: 13px; font-weight: 600; }
.studio-change small { line-height: 1.6; overflow-wrap: anywhere; color: var(--muted-foreground); font-size: 11px; }
.studio-change pre { max-height: 220px; overflow: auto; font: 10px/1.5 var(--font-mono); background: #12110f; padding: 10px; border-radius: 5px; color: var(--muted-foreground); }
.studio-manifest { display: flex; flex-direction: column; gap: 12px; }
.studio-manifest pre { white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow: auto; font: 10px/1.6 var(--font-mono); background: #12110f; padding: 14px; border-radius: 5px; color: var(--muted-foreground); margin: 0; }
.studio-api-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.studio-api-list a { display: inline-flex; align-items: center; gap: 8px; color: var(--green-bright); text-decoration: none; }
.studio-api-list a:hover { text-decoration: underline; }
.studio-api-list svg { width: 12px; height: 12px; }

/* guide and research loop (plan3) */
.studio .research-setup { display: grid; gap: 16px; }
.studio .research-setup h3 { font-size: 22px; line-height: 1.3; margin: 0; }
.studio .research-setup > p { margin: 0; font-size: 14px; color: var(--muted-foreground); }
.studio .research-setup label { font-size: 14px; }
.studio .research-setup > small { color: var(--studio-dim); font-size: 12px; line-height: 1.5; }
.research-receipt { display: grid; gap: 8px; padding: 16px; border: 1px solid var(--border); background: var(--surface-raised); border-radius: 6px; font-size: 13px; line-height: 1.5; }
.research-receipt span { color: var(--sidebar-foreground); }
.studio section.research-receipt { gap: 12px; }
.studio section.research-receipt h3 { font-size: 18px; }
.research-actions { display: flex; flex-direction: column; gap: 8px; }
.studio .research-actions button { justify-content: flex-start; border-color: var(--studio-edge); min-height: 40px; font-size: 13px; }
.studio .research-actions .studio-primary { border-color: var(--green); }
.studio-guide > details { margin: 4px 0; }
.studio-guide p { color: var(--muted-foreground); }
.studio .studio-guide p { font-size: 13px; line-height: 1.7; }
.studio-guide ol { padding-left: 20px; display: grid; gap: 24px; margin: 16px 0 0; }
.studio-guide li p { margin: 8px 0; }
.studio-guide li button { border-color: var(--studio-edge); }
.studio-guide details h3 { margin-top: 12px; }
.studio-guide-section { display: flex; flex-direction: column; gap: 10px; }
.studio-keys { margin: 0; padding-left: 18px; display: grid; gap: 10px; color: var(--muted-foreground); font-size: 13px; line-height: 1.7; }
.studio-guide-link { display: inline-flex; align-items: center; gap: 6px; color: var(--green-bright); text-decoration: none; font-size: 13px; }
.studio-guide-link:hover { text-decoration: underline; }
.studio-guide-link svg { width: 13px; height: 13px; }

/* health (plan3) */
.studio-feed { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.studio-feed strong { display: flex; flex-direction: column; gap: 3px; font-weight: 600; }
.studio-feed strong small { color: var(--studio-dim); font-weight: 400; font-size: 11px; }
.studio-feed > span { font-size: 12px; text-align: right; }
.studio-feed > small { grid-column: 1 / -1; color: var(--muted-foreground); overflow-wrap: anywhere; font-size: 11px; }
.studio-health-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--studio-line); border: 1px solid var(--studio-line); border-radius: 6px; overflow: hidden; }
.studio-health-grid > div { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; background: var(--card); min-width: 0; }
.studio-health-grid span { color: var(--studio-dim); font-size: 11px; }
.studio-health-grid strong { font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }

/* share dialog (plan3) */
.studio-share h2 { font-size: 25px; }
.studio-share > p { line-height: 1.6; color: var(--muted-foreground); font-size: 13px; margin: 0; }
.studio-share-field { display: flex; flex-direction: column; gap: 10px; }
.studio-share-field .studio-primary, .studio-share .studio-primary { align-self: flex-start; display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 8px 14px; border: 1px solid var(--green); border-radius: 6px; background: var(--green); color: var(--primary-foreground); font-weight: 650; font-size: 13px; cursor: pointer; }
.studio-share .studio-primary svg { width: 15px; height: 15px; }
.studio-share .studio-subtle { color: var(--muted-foreground); font-size: 12px; margin: 0; }

/* ------------------------------------------------------------------ motion */

@media (prefers-reduced-motion: no-preference) {
  .studio button { transition: background-color 100ms ease-out, border-color 100ms ease-out, color 100ms ease-out; }
  .studio-panel:not([hidden]) { animation: studio-panel-in 160ms ease-out; }
}
@keyframes studio-panel-in { from { opacity: .4; transform: translateX(12px); } to { opacity: 1; transform: none; } }

@media (pointer: coarse) {
  .studio button, .studio .studio-block-header button, .studio .studio-rail button { min-width: 40px; min-height: 40px; }
  .studio .studio-resize { width: 40px; height: 40px; }
}

/* ------------------------------------------------------------------ responsive */

@media (min-width: 1600px) {
  .studio-panel { width: 400px; }
  .studio-library { width: 480px; }
}

@media (max-width: 1100px) {
  .studio-saved, .studio-brand > span, .studio-toolbar > .studio-hint { display: none; }
  .studio-header { gap: 12px; }
  .studio-header-actions > .studio-h-export > span, .studio-header-actions > .studio-h-share > span { display: none; }
  .studio-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 30; box-shadow: -12px 0 30px #0005; }
  .studio-toolbar { gap: 10px; }
}

@media (max-width: 900px) {
  .studio-context-label { display: none; }
  .studio .studio-data-state { max-width: 150px; }
  .studio-foot-text { max-width: 260px; }
}

/* phones: bottom tab bar, bottom sheets, list view, compact toolbar */
@media (max-width: 760px) {
  .studio { --tabbar: calc(58px + var(--safe-bottom)); }
  .studio-header { gap: 8px; padding: 0 10px 0 12px; }
  .studio-brand img { width: 24px; height: 24px; }
  .studio-brand strong { font-size: 13px; letter-spacing: .1em; }
  .studio .studio-board-switch { flex: 1 1 auto; max-width: none; padding: 6px 8px; }
  .studio-header-actions { gap: 4px; }
  .studio-header-actions > .studio-h-export, .studio-header-actions > .studio-h-share, .studio .studio-account { display: none; }
  .studio .studio-h-primary { width: 44px; min-width: 44px; height: 40px; padding: 0; }
  .studio .studio-h-primary span { display: none; }
  .studio .studio-h-primary svg { width: 18px; height: 18px; }

  .studio-toolbar { gap: 8px; padding: 0 10px; min-height: 50px; }
  .studio-toolbar > .studio-divider, .studio-toolbar-end > :not(.studio-more), .studio-context > svg { display: none !important; }
  .studio .studio-tabs button { min-height: 38px; padding: 6px 12px; font-size: 13px; }
  .studio-context { flex: 1; min-width: 0; }
  .studio-context .bd-asset-btn { min-width: 0; width: 100%; max-width: 168px; min-height: 38px; font-size: 14px; }
  .studio .studio-more { display: inline-flex; min-width: 44px; min-height: 40px; border-color: var(--studio-edge); }
  .studio .studio-more svg { width: 18px; height: 18px; }

  .studio-body { padding-bottom: var(--tabbar); }
  .studio-rail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    width: auto;
    height: var(--tabbar);
    flex-direction: row;
    align-items: stretch;
    justify-content: space-around;
    gap: 0;
    padding: 4px 4px var(--safe-bottom);
    border-right: 0;
    border-top: 1px solid var(--studio-line);
    background: rgba(18, 17, 15, .97);
  }
  .studio-rail-bottom { display: contents; }
  .studio .studio-rail button { flex: 1; width: auto; min-width: 44px; min-height: 50px; gap: 4px; padding: 6px 0 4px; }
  .studio .studio-rail button svg { width: 18px; height: 18px; }
  .studio .studio-rail span { font-size: 11px; }
  .studio .studio-rail button.active { background: transparent; color: var(--green-bright); box-shadow: inset 0 2px 0 var(--green); }

  .studio-canvas-tools, .studio-canvas-footer { display: none; }
  .studio-viewport { padding: 0 10px 16px; }
  .studio-list-view .studio-stage { padding: 10px 0 8px; gap: 12px; grid-template-columns: minmax(0, 1fr); }
  .studio-list-view .studio-block { min-height: 240px; }
  .studio .studio-block-header { min-height: 44px; height: 44px; }
  .studio .studio-block-header > .studio-block-act { min-width: 40px; min-height: 40px; }
  .studio-empty { padding: 32px 8px; }
  .studio-empty h1 { font-size: 34px; }
  .studio-view-banner { font-size: 12px; padding: 8px 10px; }
  .studio-view-banner > span { min-width: 0; flex-basis: 100%; }

  .studio-panel, .studio-library {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    z-index: 60;
    width: 100%;
    max-width: none;
    max-height: 88vh;
    max-height: 88dvh;
    border-left: 0;
    border-top: 1px solid #3b352c;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -16px 40px rgba(0, 0, 0, .5);
    padding-bottom: var(--safe-bottom);
  }
  .studio-panel:not([hidden]) { animation: studio-sheet-in 200ms cubic-bezier(.2, .8, .2, 1); }
  .studio-panel-library, .studio-panel-edit, .studio-panel-agent, .studio-panel-signals, .studio-panel-boards, .studio-panel-guide { height: 88vh; height: 88dvh; }
  .studio-panel-handle { display: grid; place-items: center; height: 20px; flex-shrink: 0; cursor: grab; touch-action: none; }
  .studio-panel-handle i { width: 40px; height: 4px; border-radius: 4px; background: #4a443b; }
  .studio-panel > header { padding: 4px 10px 12px 18px; }
  .studio .studio-panel-close { min-width: 44px; min-height: 44px; }
  .studio-sheet-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .55); }
  .studio-sheet-backdrop[hidden] { display: none; }
  /* 16 px on every form control in a phone sheet (no iOS zoom). The base input rule carries two :not() and sets
     `font: inherit`, so this selector has to out-rank it: a plain `:is(input, ...)` loses for every <input>. */
  .studio .studio-panel input:not([type="checkbox"]):not([type="radio"]),
  .studio .studio-panel input,
  .studio .studio-panel :is(textarea, select),
  .studio .studio-panel .bd-asset-btn { font-size: 16px; }
  .studio .studio-panel button { min-height: 40px; }
  .studio-panel-scroll { padding: 16px; }
  .studio-preset-preview { height: 210px; }
  .studio-library-modes { padding: 12px 12px 0; }
  .studio .studio-library-modes button { min-height: 44px; font-size: 13px; }

  .studio-gate { align-items: start; padding: 20px 12px calc(var(--tabbar) + 12px); }
  .studio-gate-card { padding: 24px 20px 20px; }
  .studio-gate-card h2 { font-size: 24px; }
}
@keyframes studio-sheet-in { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }

@media (max-width: 380px) {
  .studio-brand strong { display: none; }
  .studio-toolbar { gap: 6px; padding: 0 8px; }
  .studio .studio-tabs button { padding: 6px 9px; }
  .studio-context .bd-asset-btn { max-width: 120px; }
  .studio-health-grid { grid-template-columns: minmax(0, 1fr); }
  .studio-field-row { flex-wrap: wrap; }
  .studio-field-row > * { flex-basis: 120px; }
  .studio .studio-rail span { font-size: 12px; }
}

/* stock picker inside the studio (beats the generic .studio button reset) */
.studio .bd-asset-btn { border: 1px solid var(--studio-field); background: var(--studio-bg); padding: 4px 8px 4px 6px; justify-content: flex-start; font: 500 13px var(--font-mono); letter-spacing: .02em; }
.studio .bd-asset-btn:hover:not(:disabled) { background: var(--studio-bg); border-color: #5a5247; }
.studio .bd-asset-btn:disabled { opacity: .6; }
.studio .bd-asset-btn .bd-asset-chev { width: 13px; height: 13px; }
.studio .bd-asset-btn .bd-asset-linkic { width: 13px; height: 13px; }
.studio .studio-tabs button.is-locked:not(.active) { color: var(--studio-dim); }
@media (max-width: 760px) { .studio-view-banner > svg { display: none; } }

/* shared components rendered inside the studio (the gate): beat the generic .studio button reset */
.studio .bd-wallet-row { justify-content: flex-start; gap: 12px; min-height: 54px; padding: 10px 12px; border: 1px solid var(--studio-edge); border-radius: 8px; background: var(--card); font-size: 14px; text-align: left; }
.studio .bd-wallet-row:hover:not(:disabled) { border-color: var(--green); background: #1f241f; }
.studio .bd-wallet-row svg.bd-wallet-go { width: 16px; height: 16px; }
.studio .bd-btn { min-height: 38px; padding: 7px 12px; border: 1px solid var(--studio-edge); border-radius: 6px; font-size: 13px; font-weight: 550; }
.studio .bd-btn-primary { background: var(--green); border-color: var(--green); color: var(--primary-foreground); font-weight: 650; }
.studio .bd-btn-primary:hover:not(:disabled) { background: var(--green-hover); border-color: var(--green-hover); }
.studio-quote-line { color: var(--sidebar-foreground) !important; font-size: 11px !important; line-height: 1.55; }
.studio-quote-line:empty { display: none; }
/* on-chain forms: the fields are held (inert) from the click until the wallet and the chain have answered */
.studio-form-fields { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.studio-form-fields[inert] { opacity: .55; }
.studio .studio-panel .studio-off-note { margin: -4px 0 0; }
.studio-off-note[hidden] { display: none; }
.studio-tip-box:empty { display: none; }
.studio .studio-more-rows { align-self: stretch; border-color: var(--studio-edge); color: var(--muted-foreground); }
.studio-form-error:empty { display: none; }
