/* ── WORKSPACE SHELL ─────────────────────────────────────── */
.workspace {
  background: #09080F;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(139,92,246,.2);
  box-shadow: 0 8px 40px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.04);
}
.ws-toolbar {
  background: #130F22;
  padding: .65rem 1.25rem;
  display: flex; align-items: center; gap: .75rem;
  border-bottom: 1px solid rgba(139,92,246,.15);
}
.ws-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ws-dot-r { background: #FF5F57; }
.ws-dot-y { background: #FEBC2E; }
.ws-dot-g { background: #28C840; }
.ws-label {
  margin-left: .25rem;
  font-family: 'Space Mono', monospace;
  font-size: .72rem; color: #6D5FA6; letter-spacing: .04em;
}

/* ── LEGEND ──────────────────────────────────────────────── */
.legend {
  display: flex; flex-wrap: wrap; gap: .4rem;
  padding: .75rem 1.25rem;
  background: #0E0B1C;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.lg-item {
  display: flex; align-items: center; gap: .3rem;
  font-family: 'Nunito', sans-serif; font-size: .7rem;
  color: #8B7DB4; white-space: nowrap;
}
.lg-dot {
  width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0;
}

/* ── SCRIPT GRID ─────────────────────────────────────────── */
.scripts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1px;
  background: rgba(255,255,255,.04);
}
.script-panel {
  background: #09080F;
  padding: 1rem;
  min-width: 0;
}

/* ── ACCORDION ───────────────────────────────────────────── */
.acc-item { border-bottom: 1px solid rgba(255,255,255,.05); }
.acc-item:last-child { border-bottom: none; }
.acc-trigger {
  width: 100%; background: none; border: none;
  display: flex; align-items: center; gap: .6rem;
  padding: .85rem 1.25rem; cursor: pointer;
  text-align: left; transition: background .15s;
}
.acc-trigger:hover { background: rgba(255,255,255,.03); }
.acc-icon {
  flex-shrink: 0; width: 16px; height: 16px;
  color: #6D5FA6; transition: transform .2s;
}
.acc-trigger[aria-expanded="true"] .acc-icon { transform: rotate(90deg); }
.acc-name {
  font-family: 'Fredoka', sans-serif; font-size: .95rem;
  color: #C4B5FD; flex: 1; line-height: 1.2;
}
.acc-meta {
  font-family: 'Space Mono', monospace; font-size: .65rem;
  color: #4A3D72; white-space: nowrap;
}
.acc-body {
  padding: 0 1.25rem .85rem 1.25rem;
  display: none;
}
.acc-body.open { display: block; }

/* ── BLOCK STACK ─────────────────────────────────────────── */
.blk-stack { display: flex; flex-direction: column; gap: 0; }

.blk {
  display: flex; align-items: flex-start; flex-wrap: wrap;
  gap: 3px; min-height: 26px;
  padding: 3px 10px 3px 8px;
  border-radius: 0 5px 5px 0;
  font-family: 'Space Mono', monospace;
  font-size: .71rem; line-height: 1.45;
  margin: 1px 0; position: relative;
  word-break: break-word; max-width: 100%;
}
/* Left connector notch */
.blk::before {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  background: rgba(255,255,255,.22);
  border-radius: 2px 0 0 2px;
}
/* Hat block */
.blk-hat {
  border-radius: 10px 10px 0 0;
  padding-top: 6px; padding-bottom: 6px;
  margin-bottom: 0;
}
.blk-hat::before { border-radius: 2px 0 0 0; }

/* Block category colours */
.blk-event    { background: #92400E; color: #FEF3C7; }
.blk-broadcast{ background: #78350F; color: #FDE68A; }
.blk-motion   { background: #1E40AF; color: #BFDBFE; }
.blk-motor    { background: #0F766E; color: #CCFBF1; }
.blk-control  { background: #9A3412; color: #FFEDD5; }
.blk-variable { background: #991B1B; color: #FEE2E2; }
.blk-myblock  { background: #4C1D95; color: #EDE9FE; }
.blk-sound    { background: #831843; color: #FCE7F3; }
.blk-sensor   { background: #1E3A8A; color: #DBEAFE; }
.blk-other    { background: #1C1A2E; color: #6B7280; font-style: italic; }

/* Nesting indent + faint connector line */
.blk-nested { position: relative; }

/* ── PARAMETER SLOTS ─────────────────────────────────────── */
.slot {
  display: inline-block; border-radius: 4px;
  padding: 0 5px; font-size: .68rem; font-weight: 700;
  line-height: 1.5; white-space: nowrap;
}
.slot-port { background: rgba(0,0,0,.35); color: #FCD34D; }
.slot-msg  { background: rgba(255,255,255,.18); color: #F5F3FF; }
.slot-param{ background: rgba(0,0,0,.3); color: #A5F3FC; font-style: italic; }
.slot-num  { background: rgba(255,255,255,.15); color: #86EFAC; }

/* ── SECTION HEADINGS ─────────────────────────────────────── */
.sec-head {
  display: flex; align-items: center; gap: .65rem;
  padding: 1rem 1.25rem .55rem;
  font-family: 'Fredoka', sans-serif; font-size: .92rem;
  color: #E9D5FF; letter-spacing: .1em; text-transform: uppercase;
  font-weight: 600;
  border-top: 1px solid rgba(255,255,255,.22);
  margin-top: .25rem;
}
.sec-head:first-of-type { border-top: none; margin-top: 0; }
.sec-head-line {
  flex: 1; height: 1px; background: rgba(255,255,255,.18);
}

/* ── CATEGORY BADGES ─────────────────────────────────────── */
.badge-handlers {
  display: flex; flex-wrap: wrap; gap: .3rem;
  padding: .5rem 1.25rem .5rem;
}
.badge {
  font-family: 'Nunito', sans-serif; font-size: .72rem;
  font-weight: 700; padding: .15rem .5rem; border-radius: 6px;
  cursor: pointer; transition: opacity .15s; border: none;
  line-height: 1.4;
}
.badge:hover { opacity: .8; }
.badge.active { outline: 2px solid rgba(255,255,255,.4); }
.badge-mission { background: #F97316; color: #fff; }
.badge-arm     { background: #7C3AED; color: #fff; }
.badge-custom  { background: #0891B2; color: #fff; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-blk {
  font-family: 'Space Mono', monospace; font-size: .7rem;
  color: #4A3D72; padding: .5rem .75rem; font-style: italic;
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 767px) {
  .scripts-grid { grid-template-columns: 1fr; }
}
