.work.script-wide, .work.script-wide.left-shut, .work.script-wide.right-shut, .work.script-wide.left-shut.right-shut { grid-template-columns: minmax(0, 1fr); }
.work.script-wide > .dock, .work.script-wide > .splitter.v { display: none; }

.topbar .btn.space:disabled { color: var(--disabled-text); }

.script { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--panel); }
.script-modes { flex: none; display: flex; gap: 4px; padding: 0 8px 5px; }
.script-modes .btn.on { background: var(--accent); }
.script-body { position: relative; flex: 1 1 auto; min-height: 0; }
.script-mode { position: absolute; inset: 0; }

.blocks {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 164px 244px minmax(0, 1fr);
  grid-template-rows: 44px minmax(0, 1fr) 26px;
  grid-template-areas: "rail palette head" "rail palette canvas" "rail palette line";
  column-gap: 4px;
  padding: 0 4px 4px;
  --block-text: var(--text);
  --chip-text: var(--ground);
}

.script-rail { grid-area: rail; min-height: 0; display: flex; flex-direction: column; gap: 4px; padding: 5px 0 0 4px; overflow: auto; scrollbar-width: none; }
.script-rail::-webkit-scrollbar { display: none; }
.script-rail > .btn { justify-content: flex-start; color: var(--value); }
.script-cats { display: flex; flex-direction: column; gap: 4px; padding-top: 6px; }
.script-cats .btn { justify-content: flex-start; padding: 0 8px; gap: 7px; }
.script-cats .btn.on { background: var(--accent); }
.script-cats .dot { width: 12px; height: 12px; flex: none; display: block; }

.script-palette { grid-area: palette; position: relative; min-height: 0; overflow: auto; overscroll-behavior: contain; background: var(--tile); touch-action: pan-y; }
.script-palette-sizer { position: relative; }
.script-palette::-webkit-scrollbar, .script-canvas::-webkit-scrollbar { width: 10px; height: 10px; }
.script-palette::-webkit-scrollbar-track, .script-canvas::-webkit-scrollbar-track { background: var(--tile); }
.script-palette::-webkit-scrollbar-thumb, .script-canvas::-webkit-scrollbar-thumb { background: var(--button); }
.script-palette::-webkit-scrollbar-corner, .script-canvas::-webkit-scrollbar-corner { background: var(--tile); }

.script-head { grid-area: head; display: flex; align-items: center; gap: 4px; min-width: 0; }
.script-head .btn { height: 34px; }
.script-head .spring { flex: 1 1 auto; min-width: 0; }
.script-head .btn.has-problems .label { color: var(--problem); }
.script-head .btn.checking .label, .script-head .btn.unchecked .label { color: var(--subtle-text); }
.script-head .spring + .btn { min-width: 172px; justify-content: flex-start; }
.script-head .spring + .btn:not(.has-icon) { padding-left: 14px; }

.script-canvas { grid-area: canvas; position: relative; min-height: 0; overflow: auto; overscroll-behavior: contain; background: var(--tile); outline: 0; }
.script-canvas:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }
.script-sizer { position: relative; margin: 8px 10px 40px; min-height: 64px; }
.script-rows { position: absolute; left: 0; top: 0; right: 0; }

.script-line { grid-area: line; padding: 0 6px; line-height: 26px; color: var(--subtle-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.script-line.notice { color: var(--notice); }
.script-line.problem { color: var(--problem); }

.srow { position: absolute; left: 0; right: 0; }
.sblk, .sbar, .sfoot, .swell { position: absolute; z-index: 1; }
.sblk { cursor: grab; }
.sblk.lifted, .sval.lifted { opacity: 0.4; }

.shp { position: absolute; left: 0; top: 0; display: block; pointer-events: none; }
.shp > i { position: absolute; inset: 0; display: block; }

.sarm { position: absolute; z-index: 2; display: block; pointer-events: none; }
.sarm > i { position: absolute; left: 1.4px; right: 1.4px; top: 0; bottom: 0; display: block; }

.sw { position: absolute; white-space: pre; font-weight: bold; color: var(--block-text); pointer-events: none; }
.sw.dim { opacity: 0.55; }

.schip { position: absolute; display: block; padding: 0; color: var(--chip-text); font-style: normal; cursor: pointer; }
.schip .t { position: absolute; inset: 0; display: grid; place-items: center; white-space: pre; overflow: hidden; }
.schip.arrow .t { right: 10px; }
.schip .a { position: absolute; right: 2px; top: 0; bottom: 0; width: 14px; display: grid; place-items: center; font-size: 0.72em; }
.schip:focus-visible, .sgrip:focus-visible, .pblk:focus-visible { outline-offset: 1px; }
i.schip { cursor: inherit; }

.sgrip { position: absolute; display: grid; place-items: center; padding: 0; background: rgba(255, 255, 255, 0.10); color: rgba(255, 255, 255, 0.55); font-size: 14px; line-height: 1; cursor: grab; touch-action: none; }
.sgrip:hover { background: rgba(255, 255, 255, 0.2); color: var(--text); }

.sval { position: absolute; display: block; cursor: grab; }

.sbadge { position: absolute; display: block; pointer-events: none; }
.sbadge > span { position: absolute; inset: 0; display: grid; place-items: center; font: bold 14px/1 "Liberation Sans", Arial, Helvetica, sans-serif; color: var(--chip-text); }

.pblk { position: absolute; display: block; padding: 0; text-align: left; cursor: grab; touch-action: pan-x pan-y; }

.script-marker { position: absolute; z-index: 5; background: var(--create); pointer-events: none; }
.script-marker.box { background: none; outline: 2px solid var(--create); outline-offset: 0; }
.script-ghost { position: fixed; left: 0; top: 0; z-index: 60; height: 30px; pointer-events: none; }
.script-ghost > span { position: absolute; left: 12px; right: 12px; top: 0; height: 26px; line-height: 26px; color: var(--ground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.script-ghost.deleting > .shp > i { background: var(--danger) !important; }
.script-ghost.deleting > span { color: var(--text); }

.script-field { position: absolute; z-index: 6; padding: 0 6px; background: var(--chip-fill, var(--text)); color: var(--chip-text); outline: 2px solid var(--accent); user-select: text; -webkit-user-select: text; font-size: 13px; }
.script-field.bad { outline-color: var(--problem); }

.menu.script-pop { max-height: min(340px, calc(100vh - 16px)); max-width: calc(100vw - 16px); overflow: auto; z-index: 35; }
.menu.script-pop.two { display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); }
.menu.script-pop .btn { padding-left: 14px; padding-right: 14px; height: 34px; }
.menu.script-pop .btn.on { background: var(--accent); }
.menu.script-pop .btn.danger { background: var(--danger); }
.menu.script-pop .btn.create { background: var(--create); }
.menu.script-pop .none { color: var(--subtle-text); padding: 8px 10px; }
.script-swatches { display: grid; grid-template-columns: repeat(16, 20px); gap: 2px; padding: 2px; }
.script-swatches button { width: 20px; height: 20px; padding: 0; }
.script-swatches button.on { outline: 2px solid var(--text); outline-offset: 0; position: relative; z-index: 1; }
.script-pop .hex { width: 112px; margin: 4px 2px 2px; }
.script-pop .color-head { padding-right: 2px; }
.script-pop .color-wheel { padding: 4px 2px; max-width: 352px; }

.script-templates { display: grid; gap: 4px; }
.script-templates .btn { justify-content: flex-start; }
.script-templates + .words { min-height: 58px; padding-top: 12px; }
.script-variables .item .pick { grid-template-columns: auto minmax(0, 1fr); }
.script-variables .item .field { margin: 0; }
.script-variables .item .does { gap: 4px; }
.script-variables .item .does .btn:first-child { min-width: 96px; color: var(--value); }
.script-variable-new { justify-content: flex-start; flex-wrap: wrap; position: sticky; top: 0; z-index: 1; background: var(--panel); padding: 0 0 4px; }
.script-variable-new + .note { min-height: 26px; }

@media (max-width: 760px) {
  .blocks {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 40px 76px 44px minmax(0, 1fr) 26px;
    grid-template-areas: "rail" "palette" "head" "canvas" "line";
  }
  .script-head .spring + .btn { min-width: 140px; }
  .script-rail { flex-direction: row; align-items: center; padding: 5px 0; overflow-x: auto; overflow-y: hidden; }
  .script-rail > .btn { flex: none; }
  .script-cats { flex-direction: row; padding: 0; }
  .script-palette { touch-action: pan-x; overflow-y: hidden; }
  .script-variables .item { flex-wrap: wrap; }
  .script-variables .item .does { padding-bottom: 5px; }
}

.problems { padding: 2px 8px 10px; display: grid; gap: 2px; }
.problems .cap { color: var(--subtle-text); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; padding: 8px 4px 3px; display: flex; gap: 8px; align-items: baseline; }
.problems .cap .count { color: var(--value); letter-spacing: 0; }
.problems .cap .state { margin-left: auto; color: var(--notice); letter-spacing: 0; text-transform: none; font-size: 14px; }
.problems .line { display: grid; grid-template-columns: 22px minmax(0, 1fr); align-items: center; column-gap: 6px; min-height: 28px; padding: 4px 8px; background: var(--tile); text-align: left; line-height: 1.3; user-select: text; -webkit-user-select: text; }
.problems .line:hover { background: var(--button); }
.problems .line .words { grid-column: 2; overflow-wrap: anywhere; }
.problems .line.stops .words { color: var(--problem); }
.problems .line .mark { grid-column: 1; width: 18px; height: 18px; display: grid; place-items: center; background: var(--problem); color: var(--ground); font-weight: bold; clip-path: polygon(25% 0, 75% 0, 100% 25%, 100% 75%, 75% 100%, 25% 100%, 0 75%, 0 25%); }
.problems .line .more { grid-column: 2; color: var(--subtle-text); }
.problems .none { color: var(--subtle-text); padding: 8px 4px; }
