/* TokenField Web Studio v1 — Studio workspace component styles.
   Built on tokens.css (Plan-401 W4). Recreated from the design handoff;
   dark/obsidian + plasma used sparingly. */

.st-root {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  color: var(--text);
  font: var(--text-ui);
  -webkit-font-smoothing: antialiased;
}

/* ---- buttons / primitives ------------------------------------------------ */
.st-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-md);
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font: var(--text-label);
  cursor: pointer;
  transition: opacity var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.st-btn-primary { background: var(--text-strong); color: var(--bg-base); }
.st-btn-primary:disabled { opacity: .35; cursor: default; }
.st-btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.st-btn-secondary:hover { color: var(--text-strong); border-color: var(--text-muted); }
.st-btn-ghost {
  background: transparent; color: var(--text-muted); border: none; height: 26px; padding: 0 var(--space-2);
}
.st-btn-ghost:hover { color: var(--text-strong); }
.st-btn-lg { height: var(--control-lg); }
.st-btn-sm { height: var(--control-sm); }

/* ---- header -------------------------------------------------------------- */
.st-header {
  display: flex; align-items: center; gap: var(--space-4);
  height: var(--header-h); flex: none;
  padding: 0 var(--space-4) 0 var(--space-5);
  background: var(--bg-alt); border-bottom: 1px solid var(--border);
}
.st-brand { display: flex; align-items: center; gap: var(--space-2); }
.st-mark { width: 32px; height: 27px; overflow: hidden; display: block; }
.st-mark img { width: 60px; height: 60px; display: block; transform: translate(-14.4px, -15.3px); }
.st-wordmark {
  font-family: var(--font-wordmark); font-weight: 500; font-size: 15px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-strong);
}
.st-divider-v { width: 1px; height: 20px; background: var(--border); flex: none; }
.st-crumbs { display: flex; align-items: center; gap: var(--space-2); font: var(--text-label); }
.st-crumb-link { color: var(--text-muted); cursor: pointer; }
.st-crumb-link:hover { color: var(--text-strong); }
.st-crumb-sep { color: var(--text-muted); }
.st-crumb-current { color: var(--text-strong); }
.st-chip {
  font: var(--text-readout); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 2px 6px;
}
.st-header-right { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }
.st-avatar {
  width: 32px; height: 32px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font: var(--text-label); color: var(--text); cursor: pointer; flex: none;
}

/* ---- body / three columns ----------------------------------------------- */
.st-body { display: flex; flex: 1; min-height: 0; }
.st-rail-left { width: var(--rail-w); flex: none; background: var(--bg-alt); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.st-rail-right { width: var(--rail-w); flex: none; background: var(--bg-alt); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.st-rail-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-4) var(--space-3); }
.st-rail-title { font-weight: 600; font-size: 14px; color: var(--text-strong); }
.st-rail-title-muted { font-weight: 500; font-size: 12px; color: var(--text-muted); }
.st-rail-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--space-4) var(--space-4); }
.st-rail-foot { border-top: 1px solid var(--border); padding: var(--space-3) var(--space-4); font: var(--text-caption); color: var(--text-muted); }
.st-rail-placeholder { font-size: 13px; line-height: 1.5; color: var(--text-muted); padding-top: var(--space-2); }

/* ---- parameters ---------------------------------------------------------- */
.st-param { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: 22px; }
.st-param-row { display: flex; align-items: center; gap: var(--space-2); }
.st-param-label { font: var(--text-label); color: var(--text); flex: 1; }
.st-param.active .st-param-label { color: var(--text-strong); }
.st-param-field {
  width: 60px; height: 28px; border-radius: var(--radius-sm);
  background: var(--bg-base); border: 1px solid var(--border);
  color: var(--text); font: var(--text-readout); text-align: right; padding: 0 var(--space-2);
}
.st-param-field:focus { outline: none; border-color: var(--plasma-cyan); }
.st-param.active .st-param-field { border-color: var(--plasma-cyan); }
.st-param-unit { font-size: 12px; color: var(--text-muted); width: 20px; }
.st-slider { position: relative; height: 18px; display: flex; align-items: center; cursor: pointer; }
.st-slider-track { position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.st-slider-fill { height: 100%; background-image: var(--plasma); background-repeat: no-repeat; }
.st-slider-thumb {
  position: absolute; width: 14px; height: 14px; border-radius: var(--radius-pill);
  background: var(--text-strong); transform: translateX(-50%);
  box-shadow: 0 0 0 1px rgba(2, 3, 9, .6);
}
.st-param.active .st-slider-thumb { box-shadow: var(--focus-ring); }

/* ---- viewport ------------------------------------------------------------ */
.st-viewport {
  position: relative; flex: 1; min-width: 0; background: var(--bg-base);
  background-image:
    linear-gradient(var(--viewport-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--viewport-grid) 1px, transparent 1px);
  background-size: 40px 40px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.st-viewport-model { max-width: 60%; max-height: 70%; opacity: 1; transition: opacity var(--dur-base) var(--ease); }
.st-viewport.is-generating .st-viewport-model { opacity: .14; }
.st-toolbar { position: absolute; top: var(--space-4); left: var(--space-4); display: flex; gap: var(--space-2); }
.st-seg {
  display: flex; gap: 3px; padding: 3px; border-radius: 9px;
  background: var(--surface-glass); border: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.st-seg-item {
  height: 28px; padding: 0 var(--space-3); border-radius: var(--radius-sm);
  display: flex; align-items: center; font: var(--text-small); font-weight: 500;
  color: var(--text-muted); cursor: pointer; border: none; background: transparent;
}
.st-seg-item.selected { background: var(--border); color: var(--text-strong); }
.st-hint { position: absolute; bottom: var(--space-4); left: var(--space-4); font: var(--text-caption); color: var(--text-muted); }

/* ---- history ------------------------------------------------------------- */
.st-hist { display: flex; flex-direction: column; gap: var(--space-2); }
.st-hist-item { padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid transparent; }
.st-hist-item.current { background: var(--surface); border-color: var(--border); }
.st-hist-prompt { font-size: 13px; line-height: 1.45; color: var(--text-muted); }
.st-hist-item.current .st-hist-prompt { color: var(--text-strong); }
.st-hist-meta { margin-top: var(--space-1); font: var(--text-readout); color: var(--text-muted); display: flex; align-items: center; gap: var(--space-2); }
.st-dot { width: 6px; height: 6px; border-radius: var(--radius-pill); background-image: linear-gradient(90deg, var(--plasma-green), var(--plasma-cyan)); flex: none; }
.st-dot-red { width: 6px; height: 6px; border-radius: var(--radius-pill); background: var(--plasma-red); flex: none; }
.st-hist-item.pending .st-hist-prompt { animation: st-pulse 1.3s var(--ease) infinite; }
.st-hist-branchmark { font: var(--text-caption); color: var(--text-muted); margin: var(--space-2) 0; }
.st-hist-indent { margin-left: 14px; padding-left: 8px; border-left: 1px solid var(--border); }

/* ---- prompt composer ----------------------------------------------------- */
.st-composer-wrap { border-top: 1px solid var(--border); padding: var(--space-3); flex: none; }
.st-composer-ring { border-radius: 11px; padding: 1px; background: var(--border); }
.st-composer-ring.empty { background-image: var(--plasma); }
.st-composer { border-radius: 10px; background: var(--surface); padding: var(--space-3); }
.st-composer textarea {
  width: 100%; resize: none; border: none; background: transparent;
  color: var(--text-strong); font: var(--text-ui); outline: none; min-height: 60px;
}
.st-composer textarea::placeholder { color: var(--text-muted); }
.st-composer-foot { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-2); }
.st-composer-hint { font: var(--text-caption); color: var(--text-muted); }

/* ---- empty state --------------------------------------------------------- */
.st-empty { max-width: 480px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-6); }
.st-empty-mark { width: 83px; height: 70px; overflow: hidden; }
.st-empty-mark img { width: 118px; height: 118px; transform: translate(-17.5px, -24px); }
.st-empty-title { font: var(--text-title); letter-spacing: -.01em; color: var(--text-strong); }
.st-empty-sub { font: var(--text-body); color: var(--text-muted); }
.st-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; }
.st-chip-ex {
  height: 32px; padding: 0 var(--space-4); border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font: var(--text-small); cursor: pointer;
}
.st-chip-ex:hover { border-color: var(--text-muted); }

/* ---- generating / adjusting overlays ------------------------------------- */
.st-sweep { position: absolute; top: 0; left: 0; right: 0; height: 2px; overflow: hidden; }
.st-sweep::after {
  content: ""; position: absolute; top: 0; height: 2px; width: 40%;
  background-image: var(--plasma); animation: st-sweep 1.4s linear infinite;
}
.st-bar { position: absolute; top: 0; left: 0; right: 0; height: 2px; background-image: var(--plasma); }
.st-card-glass {
  background: var(--surface-glass); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-6); width: 320px; backdrop-filter: blur(8px); box-shadow: var(--shadow-dialog);
  position: relative; z-index: 2;
}
.st-card-title { font: var(--text-heading); color: var(--text-strong); }
.st-card-quote { font-size: 13px; color: var(--text-muted); margin-top: var(--space-2); }
.st-steps { display: flex; flex-direction: column; gap: var(--space-3); margin: var(--space-4) 0; }
.st-step { display: flex; align-items: center; gap: var(--space-3); font: var(--text-ui); color: var(--text-muted); }
.st-step-dot { width: 16px; height: 16px; border-radius: var(--radius-pill); border: 1px solid var(--border); flex: none; display: flex; align-items: center; justify-content: center; font-size: 10px; }
.st-step.done { color: var(--text); }
.st-step.done .st-step-dot { background: var(--plasma-green); border-color: var(--plasma-green); color: var(--bg-base); }
.st-step.active { color: var(--text-strong); }
.st-step.active .st-step-dot { border-color: var(--plasma-cyan); box-shadow: var(--focus-ring); animation: st-pulse 1.2s var(--ease) infinite; }
.st-pill {
  position: absolute; top: var(--space-4); left: 50%; transform: translateX(-50%);
  height: 32px; border-radius: 16px; padding: 0 var(--space-4); z-index: 2;
  background: var(--surface-glass); border: 1px solid var(--border); backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: var(--space-2); font: var(--text-label); color: var(--text);
}
.st-pill-dot { width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--plasma-cyan); animation: st-pulse 1.1s var(--ease) infinite; }
.st-pill-val { font: var(--text-readout); color: var(--text-strong); }

/* ---- error --------------------------------------------------------------- */
.st-error-card { width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.st-error-head { display: flex; align-items: center; gap: var(--space-2); font: var(--text-heading); color: var(--text-strong); }
.st-error-reason { font: var(--text-ui); color: var(--text); }
.st-quote-box { background: var(--bg-alt); border-radius: var(--radius-md); padding: var(--space-3); font-size: 13px; color: var(--text-muted); }
.st-error-actions { display: flex; gap: var(--space-2); }

/* ---- export dialog ------------------------------------------------------- */
.st-scrim { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center; justify-content: center; z-index: 10; }
.st-dialog { width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow-dialog); display: flex; flex-direction: column; gap: var(--space-4); }
.st-dialog-title { font: var(--text-heading); color: var(--text-strong); }
.st-dialog-sub { font-size: 13px; color: var(--text-muted); }
.st-field-label { font: var(--text-label); color: var(--text); margin-bottom: var(--space-2); }
.st-segmented { display: flex; gap: 3px; padding: 3px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 9px; }
.st-segmented button { flex: 1; height: 32px; border-radius: var(--radius-sm); border: none; background: transparent; color: var(--text-muted); font: var(--text-small); font-weight: 500; cursor: pointer; }
.st-segmented button.selected { background: var(--border); color: var(--text-strong); }
.st-hint-line { font: var(--text-caption); color: var(--text-muted); margin-top: var(--space-2); }
.st-file-box { background: var(--bg-alt); border-radius: var(--radius-md); padding: var(--space-3); font: var(--text-readout); color: var(--text-strong); }
.st-dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }

/* ---- sign-in / projects inputs (shared primitives) ----------------------- */
.st-input {
  height: var(--control-lg); width: 100%; border-radius: var(--radius-md);
  background: var(--bg-base); border: 1px solid var(--border); color: var(--text-strong);
  font: var(--text-ui); padding: 0 var(--space-3);
}
.st-input:focus { outline: none; border-color: var(--plasma-cyan); }

/* ---- dev-only state switcher (NOT shipped UI) ---------------------------- */
.st-devbar {
  position: fixed; bottom: var(--space-3); left: 50%; transform: translateX(-50%); z-index: 50;
  display: flex; gap: var(--space-2); padding: var(--space-2);
  background: var(--surface-glass); border: 1px solid var(--border); border-radius: var(--radius-pill);
  backdrop-filter: blur(8px); box-shadow: var(--shadow-menu);
}
.st-devbar button { height: 24px; padding: 0 var(--space-3); border-radius: var(--radius-pill); border: 1px solid var(--border); background: transparent; color: var(--text-muted); font: var(--text-caption); cursor: pointer; }
.st-devbar button.on { background: var(--border); color: var(--text-strong); }
.st-devbar .lbl { font: var(--text-caption); color: var(--text-muted); align-self: center; padding: 0 var(--space-1); }

@keyframes st-sweep { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@keyframes st-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* Plan-401 W4 — live WebGPU viewport canvas fills the viewport; toolbar/hint overlay it. */
.st-viewport-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }

/* ========================================================================== */
/* v2 §8 — left tool rail + right-panel switcher + properties                 */
/* ========================================================================== */
.st-toolrail { width: 52px; flex: 0 0 52px; border-right: 1px solid #1E2028; background: #08090F; display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 6px; }
.st-tool-sep { width: 24px; height: 1px; background: #1E2028; margin: 6px 0; }
.st-tool { width: 36px; height: 36px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: #9CA3AF; display: grid; place-items: center; cursor: pointer; position: relative; transition: background .12s, color .12s; }
.st-tool:hover { background: #101118; color: #E0E2E8; }
.st-tool.active { background: #101118; color: #fff; box-shadow: inset 0 0 0 1px #1E2028; }
.st-tool.planned { opacity: .4; cursor: default; }
.st-tool.planned:hover { background: transparent; color: #9CA3AF; }
.st-tool.planned::after { content: ""; position: absolute; top: 5px; right: 5px; width: 4px; height: 4px; border-radius: 50%; background: #FFD700; }
.st-tool svg { width: 18px; height: 18px; }

.st-switcher { display: flex; gap: 2px; padding: 8px; border-bottom: 1px solid #1E2028; }
.st-switch { flex: 1; height: 28px; border: none; background: transparent; color: #9CA3AF; font: 500 12px/1 'Inter', sans-serif; border-radius: 6px; cursor: pointer; }
.st-switch:hover { color: #E0E2E8; }
.st-switch.active { background: #101118; color: #fff; }

.st-props { padding: 14px; }
.st-props-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid #1E2028; font-size: 13px; }
.st-props-row:last-child { border-bottom: none; }
.st-props-row .k { color: #9CA3AF; }
.st-props-row .v { color: #E0E2E8; }
.st-planned-tag { font: 500 10px/1 'Inter', sans-serif; color: #FFD700; border: 1px solid rgba(255,215,0,.35); border-radius: 999px; padding: 3px 7px; }
