:root {
  --rose-pink: rgb(240, 97, 158);
  --orchid: rgb(191, 99, 224);
  --magenta: rgb(214, 66, 158);
  --deep-plum: rgb(69, 23, 94);
  --blush-pearl: rgb(250, 199, 230);
  --silver-chrome: rgb(230, 237, 250);
  --glass-card: rgba(36, 13, 51, 0.42);
  --glass-bar: rgba(28, 10, 43, 0.48);
  --bg-void: #0d0513;
  --text-primary: #f5eef8;
  --text-secondary: rgba(235, 222, 244, 0.68);
  --border-pearl: rgba(250, 199, 230, 0.16);
  --green-ok: #34d399;
  --amber-warn: #fbbf24;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", sans-serif;
  --font-rounded: "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
}

.hidden-file-input,
[hidden] {
  display: none !important;
}

.studio-shell {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.morph-rail {
  position: relative;
  width: 268px;
  flex: 0 0 268px;
  height: 100%;
  overflow: hidden;
  background: rgba(19, 8, 28, 0.92);
}

.main-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background: rgba(13, 5, 19, 0.88);
}

.shell-divider {
  width: 1px;
  flex: 0 0 1px;
  background: rgba(250, 199, 230, 0.18);
}

.swirl-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.rail-glass,
.stage-glass {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(22px) saturate(135%);
  -webkit-backdrop-filter: blur(22px) saturate(135%);
}

.rail-glass {
  background: rgba(18, 8, 28, 0.45);
}

.stage-glass {
  padding: 6px;
}

.stage-rim {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid rgba(250, 199, 230, 0.22);
  background: rgba(14, 6, 22, 0.34);
  overflow: hidden;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.stage-rim.is-drop-targeted {
  border: 2.5px solid var(--rose-pink);
  box-shadow: inset 0 0 36px rgba(240, 97, 158, 0.26), 0 0 24px rgba(191, 99, 224, 0.28);
}

/* Left Rail Contents */
.rail-header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 14px 10px;
}

.rail-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.rail-brand {
  min-width: 0;
  flex: 1;
}

.rail-title {
  font-family: var(--font-rounded);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
}

.rail-sub {
  font-size: 10.5px;
  font-weight: 500;
  color: rgba(250, 199, 230, 0.85);
}

.wasm-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber-warn);
  flex-shrink: 0;
}

.wasm-dot.is-ready {
  background: var(--green-ok);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.7);
}

.wasm-dot.is-err {
  background: #f87171;
}

.drop-nav-btn {
  margin: 0 12px 10px;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: rgba(250, 199, 230, 0.06);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.drop-nav-btn.is-selected {
  background: rgba(240, 97, 158, 0.24);
  border-color: rgba(250, 199, 230, 0.45);
}

.drop-nav-plus {
  color: var(--rose-pink);
  font-size: 13px;
}

.rail-section-label {
  padding: 4px 14px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

.slot-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slot-empty {
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 11px;
  color: var(--text-secondary);
  white-space: pre-line;
}

.slot-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px;
  border-radius: 10px;
  background: rgba(36, 13, 51, 0.30);
  border: 1px solid rgba(250, 199, 230, 0.12);
}

.slot-card.is-selected {
  background: rgba(214, 66, 158, 0.28);
  border-color: rgba(240, 97, 158, 0.72);
}

.slot-select-btn {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.slot-title {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-lang {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(240, 97, 158, 0.24);
  color: var(--blush-pearl);
  flex-shrink: 0;
}

.slot-meta {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.slot-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.slot-icon-btn {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.slot-icon-btn:hover {
  background: rgba(250, 199, 230, 0.14);
  color: var(--text-primary);
}

.rail-bottom {
  padding: 12px;
}

.rail-morph-btn {
  width: 100%;
  justify-content: center;
}

/* Top Bar */
.stage-topbar {
  min-height: 48px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.topbar-drop-view,
.topbar-active-view {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.topbar-drop-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.active-title-block {
  min-width: 0;
  flex: 1 1 auto;
}

.active-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.active-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(240, 97, 158, 0.24);
  color: var(--blush-pearl);
  flex-shrink: 0;
}

.active-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.tel-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 3px 7px;
  border-radius: 7px;
  background: var(--glass-card);
  border: 1px solid rgba(250, 199, 230, 0.14);
}

.tel-k {
  font-size: 9px;
  color: var(--text-secondary);
}

.tel-v {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.col-orchid { color: var(--orchid); }
.col-pearl { color: var(--blush-pearl); }
.col-silver { color: var(--silver-chrome); }
.col-rose { color: var(--rose-pink); }

.topbar-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-glass,
.btn-morph-prominent {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-glass {
  background: rgba(250, 199, 230, 0.10);
  border: 1px solid rgba(250, 199, 230, 0.22);
  color: var(--text-primary);
}

.btn-glass:hover {
  background: rgba(250, 199, 230, 0.18);
}

.btn-morph-prominent {
  background: var(--magenta);
  border: 1px solid rgba(250, 199, 230, 0.35);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(214, 66, 158, 0.35);
}

.btn-morph-prominent:hover {
  filter: brightness(1.1);
}

.btn-lg {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
}

.stage-divider {
  height: 1px;
  background: rgba(250, 199, 230, 0.16);
  flex-shrink: 0;
}

/* See-Through Drop Stage */
.drop-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 14px;
}

.drop-orb-wrap {
  position: relative;
  width: 128px;
  height: 128px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-orb {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 97, 158, 0.38) 8%, rgba(191, 99, 224, 0.24) 48%, transparent 72%);
}

.drop-doc-glyph {
  position: relative;
  font-size: 46px;
  font-weight: 300;
  color: var(--blush-pearl);
  text-shadow: 0 3px 12px rgba(69, 23, 94, 0.7);
}

.drop-headline {
  margin: 0;
  font-family: var(--font-rounded);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.22;
}

.drop-subcopy {
  margin: 0;
  max-width: 510px;
  font-size: 12px;
  color: var(--text-secondary);
}

.drop-cta-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preset-strip {
  margin-top: 10px;
  max-width: 720px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--glass-card);
  border: 1px solid var(--border-pearl);
}

.preset-strip-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.preset-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.preset-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(250, 199, 230, 0.22);
  background: rgba(250, 199, 230, 0.08);
  color: var(--blush-pearl);
  cursor: pointer;
}

.preset-pill:hover {
  background: rgba(240, 97, 158, 0.25);
  border-color: var(--rose-pink);
}

/* Active Stage + IR Drawer */
.active-stage-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.active-scroll {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
}

.active-inner {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.verify-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.28);
  color: var(--green-ok);
}

.verify-banner.is-warn {
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.28);
  color: var(--amber-warn);
}

.verify-text {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hdl-frame {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(240, 97, 158, 0.42);
  background: #0b0f17;
}

.hdl-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 520;
  cursor: crosshair;
}

.hdl-canvas:focus {
  outline: none;
}

/* CartridgeStageControls */
.controls-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.outputs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.output-card,
.arrays-card,
.inputs-card,
.cst-map-card {
  padding: 12px;
  border-radius: 11px;
  background: var(--glass-card);
  border: 1px solid rgba(250, 199, 230, 0.14);
}

.output-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.output-lbl {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.output-val {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--rose-pink);
}

.output-val.is-meter {
  color: var(--blush-pearl);
}

.meter-progress {
  width: 100%;
  height: 7px;
  margin-top: 6px;
  accent-color: var(--rose-pink);
}

.section-cap {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.array-strip-item {
  padding: 10px;
  border-radius: 9px;
  background: rgba(31, 10, 46, 0.45);
  margin-top: 6px;
}

.array-strip-lbl {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;
}

.array-canvas {
  display: block;
  width: 100%;
  height: 68px;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.slider-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.slider-lbl {
  font-size: 12px;
  font-weight: 600;
}

.slider-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.micro-btn {
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  border: 1px solid rgba(250, 199, 230, 0.25);
  background: rgba(250, 199, 230, 0.1);
  color: var(--text-primary);
  cursor: pointer;
}

.slider-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--blush-pearl);
  font-variant-numeric: tabular-nums;
}

.morph-slider {
  width: 100%;
  accent-color: var(--rose-pink);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
}

.toggle-row input {
  accent-color: var(--rose-pink);
}

/* CST Map Card */
.cst-map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cst-map-title {
  font-size: 12px;
  font-weight: 700;
}

.arb-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
}

.arb-toggle input {
  accent-color: var(--rose-pink);
}

.cst-layers {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-secondary);
}

.cst-boundary {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--rose-pink);
}

.cst-hash {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--green-ok);
  font-variant-numeric: tabular-nums;
}

/* IR Drawer */
.ir-drawer {
  width: 360px;
  flex: 0 0 360px;
  border-left: 1px solid rgba(250, 199, 230, 0.16);
  background: rgba(0, 0, 0, 0.34);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ir-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.seg-control {
  display: inline-flex;
  border-radius: 7px;
  padding: 2px;
  background: rgba(255, 255, 255, 0.08);
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
}

.seg-btn.is-active {
  background: rgba(240, 97, 158, 0.34);
  color: var(--text-primary);
}

.drawer-editor {
  flex: 1 1 auto;
  width: 100%;
  resize: none;
  border-radius: 8px;
  border: 1px solid rgba(250, 199, 230, 0.14);
  background: rgba(0, 0, 0, 0.5);
  color: var(--text-primary);
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.45;
}

.drawer-editor:focus {
  outline: none;
  border-color: var(--rose-pink);
}

/* Footer Banner */
.stage-footer {
  padding: 7px 16px;
  background: var(--glass-bar);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  flex-shrink: 0;
}

.footer-sparkle {
  color: var(--blush-pearl);
}

.footer-status {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Standalone Floating Glass Window */
.standalone-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 3, 14, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.standalone-win {
  position: relative;
  width: min(640px, 100%);
  max-height: 88vh;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(15, 6, 22, 0.94);
  border: 1px solid rgba(250, 199, 230, 0.28);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
}

.standalone-glass {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.sa-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}

.sa-close-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 0;
  background: #ff5f57;
  cursor: pointer;
  flex-shrink: 0;
}

.sa-title-wrap {
  flex: 1;
  min-width: 0;
}

.sa-verified-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.2);
  color: var(--green-ok);
  flex-shrink: 0;
}

.sa-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
}

.sa-inner {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sa-footer {
  padding: 7px 16px;
  background: var(--glass-bar);
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-secondary);
}

.sa-drift {
  font-weight: 700;
  color: var(--green-ok);
}

@media (max-width: 1120px) {
  .badge-row {
    display: none;
  }

  .ir-drawer {
    width: 280px;
    flex-basis: 280px;
  }
}

@media (max-width: 820px) {
  html,
  body,
  .studio-shell {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
  }

  .studio-shell {
    flex-direction: column;
  }

  .morph-rail {
    width: 100%;
    flex: 0 0 auto;
    height: auto;
    max-height: 240px;
  }

  .shell-divider {
    width: 100%;
    height: 1px;
  }

  .main-stage {
    min-height: 620px;
  }

  .active-stage-wrap {
    flex-direction: column;
  }

  .ir-drawer {
    width: 100%;
    flex: 0 0 260px;
    border-left: 0;
    border-top: 1px solid rgba(250, 199, 230, 0.16);
  }
}
