/* ==========================================================================
   PascalBlocks – estilos
   ========================================================================== */
:root {
  --top-h: 56px;
  --side-w: 270px;
  --right-w: 440px;
  --preview-h: 45%;

  --bg: #eef2f7;
  --panel: #ffffff;
  --line: #d8dee8;
  --line-2: #e7ebf1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --prog: #f97316;

  --mono: ui-monospace, 'JetBrains Mono', 'Cascadia Code', 'Fira Code', Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.06), 0 2px 8px rgb(15 23 42 / 0.06);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  overflow: hidden;
}
button {
  font: inherit;
  color: inherit;
}
[hidden] {
  display: none !important;
}
code,
kbd {
  font-family: var(--mono);
  font-size: 0.92em;
  background: #f1f5f9;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 0 4px;
}

/* ------------------------------------------------------------- Topo */
.top {
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative;
  z-index: 20;
}
.top__logo {
  height: 34px;
}
.tabs {
  display: flex;
  background: #f1f5f9;
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
.ico {
  display: inline-block;
  vertical-align: -0.22em;
  flex: none;
}
.btn .ico,
.tabs__btn .ico,
.ptabs__btn .ico,
.status .ico,
.menu__pop button .ico,
.subpane-hdr__title .ico,
.docs-nav__btn .ico,
.ex-guide__title .ico {
  transform: translateY(1px);
}
.tabs__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}
.tabs__btn--on {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}
.top__run {
  display: flex;
  align-items: center;
  gap: 8px;
}
.top__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
  background: #f1f5f9;
  white-space: nowrap;
  transition: filter 0.15s, transform 0.1s, background 0.15s;
}
.btn:hover {
  filter: brightness(1.06);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn--run {
  background: var(--ok);
  color: #fff;
  box-shadow: 0 2px 6px rgb(22 163 74 / 0.35);
}
.btn--step {
  background: #7c3aed;
  color: #fff;
}
.btn--stop {
  background: var(--err);
  color: #fff;
}
.btn--ghost {
  background: transparent;
  border-color: var(--line);
}
.btn--ghost:hover {
  background: #f8fafc;
}
.btn--danger-hover:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}
.btn--docs {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}
.btn--docs:hover {
  background: #dbeafe;
}
.btn--small {
  padding: 4px 10px;
  font-size: 12.5px;
  border-radius: 6px;
}
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.icon:disabled {
  opacity: 0.35;
  cursor: default;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  background: #f1f5f9;
}
.status--ok {
  background: #dcfce7;
  color: #166534;
}
.status--warn {
  background: #fef3c7;
  color: #92400e;
}
.status--error {
  background: #fee2e2;
  color: #991b1b;
}

.menu {
  position: relative;
}
.menu__pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgb(15 23 42 / 0.18);
  padding: 6px;
  min-width: 250px;
  z-index: 50;
  max-height: 75vh;
  overflow: auto;
}
.menu__pop--wide {
  min-width: 360px;
  max-width: 420px;
}
.menu__ex-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.menu__ex-desc {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.35;
  white-space: normal;
}
.menu__pop button {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.menu__pop button:hover {
  background: #f1f5f9;
}
.menu__pop hr {
  border: 0;
  border-top: 1px solid var(--line-2);
  margin: 4px 0;
}
.menu__group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  padding: 8px 10px 2px;
}

/* ------------------------------------------------------------- Layout */
.main {
  height: calc(100vh - var(--top-h));
  display: grid;
  grid-template-columns: var(--side-w) minmax(300px, 1fr) 6px var(--right-w);
}
.side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  min-height: 0;
}
.side__code {
  display: none;
}
.main[data-mode='code'] .side__blocks {
  display: none;
}
.main[data-mode='code'] .side__code {
  display: block;
}
.center {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.code-wrap {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  padding: 10px;
  gap: 8px;
}
.main[data-mode='code'] .ws {
  display: none;
}
.main[data-mode='code'] .code-wrap {
  display: flex;
}
.main[data-mode='code'] #previewPanel,
.main[data-mode='code'] #splitH {
  display: none;
}
.main[data-mode='code'] .panel--out {
  height: 100%;
}
.split {
  cursor: col-resize;
  background: transparent;
  position: relative;
}
.split::after {
  content: '';
  position: absolute;
  inset: 0 2px;
  background: var(--line);
  border-radius: 2px;
}
.split:hover::after {
  background: var(--primary);
}
.split--h {
  cursor: row-resize;
  height: 6px;
}
.split--h::after {
  inset: 2px 0;
}
body.is-resizing {
  user-select: none;
  cursor: col-resize;
}
.right {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 10px 10px 10px 4px;
  gap: 0;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.panel--preview {
  height: var(--preview-h);
}
.panel--out {
  flex: 1;
}
.panel__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line-2);
  background: #f8fafc;
  min-height: 40px;
  flex-wrap: wrap;
}
.panel__title {
  font-weight: 700;
  font-size: 13px;
  margin-right: auto;
  padding-left: 4px;
}
.preview {
  flex: 1;
  min-height: 0;
}
.ptabs {
  display: flex;
  gap: 2px;
  margin-right: auto;
}
.ptabs__btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: none;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
}
.ptabs__btn--on {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.1);
}
.count {
  display: inline-block;
  min-width: 18px;
  border-radius: 999px;
  font-size: 11px;
  padding: 0 5px;
}
.count:empty {
  display: none;
}
.count--error {
  background: var(--err);
  color: #fff;
}
.count--warn {
  background: var(--warn);
  color: #fff;
}
.dbg {
  display: flex;
  align-items: center;
  gap: 4px;
}
.dbg .btn {
  background: #ede9fe;
  color: #5b21b6;
}
.dbg input[type='range'] {
  width: 80px;
}
.pbody {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}
.pbody__pane {
  display: none;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  flex: 1;
}
.pbody[data-view='split'] .pbody__pane--console {
  display: flex;
  flex: 1.15;
  border-bottom: 2px solid var(--line);
}
.pbody[data-view='split'] .pbody__pane--vars {
  display: flex;
  flex: 0.95;
  background: #fff;
}
.pbody[data-view='console'] .pbody__pane--console,
.pbody[data-view='vars'] .pbody__pane--vars,
.pbody[data-view='problems'] .pbody__pane--problems {
  display: flex;
  flex: 1;
}
.subpane-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  background: #f1f5f9;
  border-bottom: 1px solid var(--line-2);
  font-size: 11.5px;
  font-weight: 700;
  color: #334155;
  flex: none;
}
.subpane-hdr__title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.subpane-hdr__hint {
  font-weight: 500;
  color: var(--muted);
  font-size: 11px;
}
.subpane-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
}

/* Guia didático do exemplo carregado */
.ex-guide {
  margin: 8px 12px 0;
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
  border: 1px solid #bfdbfe;
  border-left: 4px solid #2563eb;
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  flex: none;
  max-height: 44vh;
  overflow-y: auto;
}
.ex-guide--collapsed .ex-guide__body {
  display: none;
}
.ex-guide__head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ex-guide__badge {
  background: #2563eb;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ex-guide__title {
  font-weight: 800;
  font-size: 14.5px;
  color: #1e3a8a;
}
.ex-guide__tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.ex-guide__tag {
  font-family: var(--mono);
  font-size: 11px;
  background: #dbeafe;
  color: #1e40af;
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.ex-guide__actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}
.ex-guide__body {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #dbeafe;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 12px;
  font-size: 13px;
  line-height: 1.45;
}
.ex-guide__summary {
  margin: 0 0 6px;
  color: #1e293b;
  font-weight: 500;
}
.ex-guide__steps {
  margin: 4px 0 0;
  padding-left: 18px;
  color: #334155;
}
.ex-guide__steps li {
  margin-bottom: 3px;
}
.ex-guide__side {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ex-guide__box {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12.5px;
}
.ex-guide__box--tip {
  background: #fef9c3;
  border: 1px solid #fde047;
  color: #713f12;
}
.ex-guide__box--chal {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #14532d;
}

.banner {
  margin: 10px 10px 0;
  padding: 8px 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------- Paleta */
.pal {
  padding: 8px 8px 0;
}
.pal__sec {
  margin-bottom: 4px;
}
.pal__title {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: none;
  font-weight: 700;
  font-size: 12.5px;
  padding: 8px 6px 6px;
  cursor: pointer;
  text-align: left;
}
.pal__dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}
.pal__chev {
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.15s;
}
.pal__sec--closed .pal__chev {
  transform: rotate(-90deg);
}
.pal__sec--closed .pal__list {
  display: none;
}
.pal__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 2px 6px;
}
.pal__item {
  background: var(--c);
  color: #fff;
  border-radius: 7px;
  padding: 6px 10px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  display: flex;
  align-items: baseline;
  gap: 8px;
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.15);
  transition: transform 0.1s, filter 0.1s;
}
.pal__item:hover {
  filter: brightness(1.08);
  transform: translateX(3px);
}
.pal__label {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12.5px;
  white-space: nowrap;
}
.pal__desc {
  font-size: 11px;
  opacity: 0.85;
  margin-left: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pal.trash--over {
  background: #fee2e2;
}

/* Trechos (operadores e funções) */
.snip,
.side__code {
  padding: 8px 10px 16px;
  border-top: 1px solid var(--line-2);
}
.side__code {
  border-top: 0;
}
.snip__title {
  font-weight: 700;
  font-size: 12.5px;
  padding: 8px 0 4px;
}
.snip__sub {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 11px;
}
.snip__gname {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 8px 0 4px;
}
.snip__list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.snip__list--col .snip__item {
  font-family: var(--sans);
}
.snip__item {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 6px;
  padding: 3px 7px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.snip__item:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
}
.snip__item--tpl {
  background: #eff6ff;
}

/* ------------------------------------------------------------- Área de trabalho */
.ws {
  flex: 1;
  overflow: auto;
  padding: 14px 16px 120px;
  min-height: 0;
  background-color: var(--bg);
  background-image: radial-gradient(#cfd8e3 1px, transparent 1px);
  background-size: 18px 18px;
}
.trash {
  display: none;
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 12px 22px;
  border-radius: 999px;
  background: #fff;
  border: 2px dashed #fca5a5;
  color: #b91c1c;
  font-weight: 700;
  box-shadow: var(--shadow);
  z-index: 5;
}
body.is-dragging .trash {
  display: block;
}
.trash.trash--over {
  background: #fee2e2;
  transform: translateX(-50%) scale(1.08);
}
body.is-dragging,
body.is-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

/* ------------------------------------------------------------- Blocos */
.blk {
  --c: #64748b;
  position: relative;
  background: var(--c);
  color: #fff;
  border-radius: 8px;
  margin: 5px 0;
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.18), 0 2px 4px rgb(15 23 42 / 0.08);
  width: fit-content;
  min-width: 180px;
  max-width: 100%;
  user-select: none;
  touch-action: none;
  cursor: grab;
}
.blk--k-stmt,
.blk--k-caseitem {
  min-width: 140px;
}
.blk:has(> .blk__slot) {
  width: auto;
  min-width: 260px;
}
.blk__row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 8px 6px 10px;
  min-height: 34px;
}
.blk__kw {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.01em;
}
.blk__txt {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--mono);
}
.blk__hint {
  font-size: 11px;
  opacity: 0.85;
  font-style: italic;
}
.blk__section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  padding: 2px 10px 0;
  opacity: 0.9;
}
.blk__slot {
  margin-left: 18px;
  margin-right: 0;
  background: rgb(248 250 252 / 0.97);
  border-radius: 0 6px 6px 0;
  padding: 3px 8px 3px 6px;
  min-height: 34px;
  color: var(--text);
  cursor: default;
}
.blk__slot--empty {
  display: flex;
  align-items: center;
}
.blk__empty {
  color: #94a3b8;
  font-size: 12px;
  font-style: italic;
  padding: 4px 6px;
  pointer-events: none;
}
.blk__slot--target {
  background: #eff6ff;
}
.ws--drag-stmt .blk__slot[data-accepts='stmt'],
.ws--drag-decl .blk__slot[data-accepts='decl'],
.ws--drag-caseitem .blk__slot[data-accepts='caseitem'] {
  outline: 1px dashed #93c5fd;
  outline-offset: -1px;
}
.blk__tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 8px;
}
.blk__tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: rgb(255 255 255 / 0.18);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s;
}
.blk:hover > .blk__head .blk__tool,
.blk--sel > .blk__head .blk__tool {
  opacity: 1;
}
.blk__tool:hover {
  background: rgb(255 255 255 / 0.35);
}
.blk__tool--del:hover {
  background: #ef4444;
}
.blk__badge {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  cursor: help;
}
.blk__check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 10px;
  cursor: pointer;
  background: rgb(255 255 255 / 0.15);
  padding: 2px 8px;
  border-radius: 6px;
}

.blk--sel {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0f172a, 0 4px 10px rgb(0 0 0 / 0.15);
  z-index: 1;
}
.blk--error {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--err);
}
.blk--error.blk--sel {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--err), 0 0 0 6px #0f172a;
}
.blk--warn > .blk__head {
  background-image: repeating-linear-gradient(-45deg, transparent 0 8px, rgb(255 255 255 / 0.08) 8px 16px);
}
.blk--running {
  box-shadow: 0 0 0 3px #fde047, 0 0 18px 4px rgb(250 204 21 / 0.7);
  z-index: 2;
}
.blk--dragsrc {
  opacity: 0.3;
}
.blk--new {
  animation: blk-pop 0.6s ease;
}
@keyframes blk-pop {
  0% {
    transform: scale(0.96);
    filter: brightness(1.4);
  }
  100% {
    transform: none;
    filter: none;
  }
}

/* Bloco raiz (programa) */
.blk--program {
  --c: var(--prog);
  background: var(--prog);
  width: auto;
  min-width: 420px;
  cursor: default;
  margin: 0;
}
.blk--program > .blk__slot {
  min-height: 56px;
  background: #fff;
}
.blk--program > .blk__row {
  padding: 8px 12px;
}

/* Campos */
.fld {
  font-family: var(--mono);
  font-size: 13px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: #fff;
  color: #0f172a;
  padding: 3px 7px;
  min-width: 42px;
  max-width: 100%;
  outline: none;
  cursor: text;
  user-select: text;
}
/* Oculta a setinha de datalist do Chrome que roubava ~20px de espaço do texto */
.fld::-webkit-calendar-picker-indicator,
.fld::-webkit-list-button {
  display: none !important;
  -webkit-appearance: none;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.fld:focus {
  border-color: #0f172a;
  box-shadow: 0 0 0 2px rgb(255 255 255 / 0.6);
}
.fld::placeholder {
  color: #94a3b8;
}
.fld--bad {
  background: #fee2e2;
  border-color: #ef4444;
  text-decoration: underline wavy #ef4444;
  text-underline-offset: 3px;
}
.fld--select {
  cursor: pointer;
  font-weight: 700;
  padding: 2px 4px;
  background: rgb(255 255 255 / 0.95);
}
.fld--code {
  display: block;
  width: min(520px, 100%);
  resize: vertical;
  line-height: 1.45;
  white-space: pre;
}
.blk__row:has(.fld--code) {
  padding-top: 0;
}

/* Partes do writeln */
.parts {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.parts__sep {
  font-weight: 700;
  font-family: var(--mono);
}
.part {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border-radius: 6px;
  padding: 2px 3px 2px 2px;
  background: rgb(255 255 255 / 0.2);
}
.part--text {
  background: rgb(255 255 255 / 0.28);
}
.part__kind {
  border: 0;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  background: rgb(0 0 0 / 0.18);
  color: #fff;
  font-family: var(--mono);
}
.part--expr .part__kind {
  font-style: italic;
}
.part__q {
  font-weight: 800;
  font-size: 14px;
  opacity: 0.9;
}
.part__in {
  min-width: 34px;
}
.part--text .part__in {
  color: #166534;
}
.part__fmt {
  width: 5.5ch;
  min-width: 0;
  font-size: 11.5px;
  padding: 2px 4px;
  background: rgb(255 255 255 / 0.55);
}
.part__fmt--on,
.part__fmt:focus {
  background: #fff;
  width: 7ch;
}
.part__rm {
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.55;
}
.part__rm:hover {
  opacity: 1;
}
.parts__add {
  display: inline-flex;
  gap: 3px;
  margin-left: 4px;
}
.parts__btn {
  border: 1px dashed rgb(255 255 255 / 0.7);
  background: transparent;
  color: #fff;
  font-size: 11.5px;
  border-radius: 5px;
  padding: 2px 6px;
  cursor: pointer;
  font-weight: 600;
}
.parts__btn:hover {
  background: rgb(255 255 255 / 0.18);
}

/* Arrastar */
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.92;
  max-width: 520px;
  filter: drop-shadow(0 10px 18px rgb(15 23 42 / 0.3));
}
.drag-ghost .blk {
  margin: 0;
}
.drop-ind {
  height: 4px;
  border-radius: 3px;
  background: var(--primary);
  margin: 3px 0;
  box-shadow: 0 0 0 2px rgb(37 99 235 / 0.2);
}
.blk__slot--empty .drop-ind {
  flex: 1;
}

/* ------------------------------------------------------------- Editor de código */
.code-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.code-bar__title {
  font-weight: 700;
}
.code-bar__hint {
  color: var(--muted);
  font-size: 12px;
  margin-right: auto;
}
.code-editor {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.pb-editor {
  display: flex;
  height: 100%;
  background: #fff;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 21px;
}
.pb-editor__gutter {
  flex: none;
  width: 46px;
  overflow: hidden;
  background: #f8fafc;
  border-right: 1px solid var(--line-2);
  color: #94a3b8;
  text-align: right;
  padding: 10px 0;
  user-select: none;
}
.pb-gutter__n {
  padding-right: 8px;
  height: 21px;
}
.pb-gutter__n--error {
  background: var(--err);
  color: #fff;
  font-weight: 700;
  cursor: help;
}
.pb-gutter__n--warn {
  background: #fbbf24;
  color: #fff;
  font-weight: 700;
  cursor: help;
}
.pb-gutter__n--active {
  background: #facc15;
  color: #000;
}
.pb-editor__scroll {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.pb-editor__hl,
.pb-editor__ta {
  margin: 0;
  padding: 10px 12px;
  font: inherit;
  line-height: inherit;
  white-space: pre;
  tab-size: 2;
  letter-spacing: 0;
}
.pb-editor__hl {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 100%;
  pointer-events: none;
  color: #0f172a;
}
.pb-editor__ta {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: #0f172a;
  overflow: auto;
}
.pb-editor__ta::selection {
  background: rgb(37 99 235 / 0.25);
  color: transparent;
}
.pb-line {
  height: 21px;
  margin: 0 -12px;
  padding: 0 12px;
}
.pb-line--error {
  background: #fee2e2;
  text-decoration: underline wavy #ef4444;
  text-decoration-skip-ink: none;
  text-underline-offset: 4px;
}
.pb-line--warn {
  background: #fffbeb;
}
.pb-line--sel {
  background: #e0e7ff;
}
.pb-line--active {
  background: #fef08a;
  box-shadow: inset 3px 0 0 #ca8a04;
}
.preview .pb-editor {
  font-size: 12.5px;
  line-height: 19px;
}
.preview .pb-line,
.preview .pb-gutter__n {
  height: 19px;
}
.preview .pb-editor__ta {
  caret-color: transparent;
  cursor: default;
}

/* Realce de sintaxe */
.hl-kw {
  color: #7c3aed;
  font-weight: 700;
}
.hl-type {
  color: #0d9488;
  font-weight: 600;
}
.hl-fn {
  color: #2563eb;
}
.hl-str {
  color: #15803d;
}
.hl-num {
  color: #c2410c;
}
.hl-com {
  color: #94a3b8;
  font-style: italic;
}
.hl-op {
  color: #be185d;
}

/* ------------------------------------------------------------- Terminal */
#terminal {
  height: 100%;
}
.pb-term {
  --term-bg: #0b1220;
  height: 100%;
  overflow: auto;
  background: var(--term-bg, #0b1220);
  color: #e5e7eb;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.45;
  padding: 10px 12px;
  outline: none;
  cursor: text;
}
.pb-term__out {
  white-space: pre-wrap;
  word-break: break-word;
}
.pb-term__inwrap {
  display: inline-block;
  min-width: 60%;
}
.pb-term__input {
  background: transparent;
  border: 0;
  outline: none;
  color: #fde68a;
  font: inherit;
  width: 100%;
  caret-color: #fde68a;
  border-bottom: 1px dashed #fde68a88;
}
.pb-term__echo {
  color: #fde68a;
}
.pb-term--waiting::after,
.pb-term--waitkey::after {
  content: 'Aguardando entrada… digite e pressione Enter';
  display: block;
  margin-top: 6px;
  font-family: var(--sans);
  font-size: 11.5px;
  color: #94a3b8;
}
.pb-term--waitkey::after {
  content: 'Pressione uma tecla…';
}
.pb-term__sys {
  font-family: var(--sans);
  font-size: 12.5px;
  margin: 6px 0;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: normal;
}
.pb-term__sys--info {
  color: #93c5fd;
  background: rgb(59 130 246 / 0.12);
}
.pb-term__sys--ok {
  color: #86efac;
  background: rgb(34 197 94 / 0.12);
}
.pb-term__sys--warn {
  color: #fcd34d;
  background: rgb(245 158 11 / 0.12);
}
.pb-term__sys--error,
.pb-term__sys--errline {
  color: #fca5a5;
  background: rgb(239 68 68 / 0.14);
}
.pb-term__sys--errline {
  margin: 2px 0 2px 12px;
}
.pb-term__sys a {
  color: #fecaca;
  font-weight: 700;
}
.pb-term__hint {
  color: #fde68a;
  margin-top: 3px;
}

/* ------------------------------------------------------------- Variáveis / problemas */
.vars,
.problems {
  padding: 10px;
}
.vars__empty,
.problems__ok {
  color: var(--muted);
  padding: 14px;
  text-align: center;
}
.problems__ok {
  color: var(--ok);
}
.vars__note {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.vars__scope {
  font-weight: 700;
  font-size: 12.5px;
  margin: 8px 0 4px;
}
.vars__tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.vars__tbl td {
  border-bottom: 1px solid var(--line-2);
  padding: 5px 6px;
  vertical-align: top;
}
.vars__name {
  font-family: var(--mono);
  font-weight: 700;
  width: 1%;
  white-space: nowrap;
}
.vars__type {
  color: var(--muted);
  font-size: 11.5px;
  width: 1%;
  white-space: nowrap;
}
.vars__val {
  font-family: var(--mono);
  word-break: break-all;
  font-weight: 600;
  color: #0f172a;
}
.vars__val--uninit {
  color: #94a3b8;
  font-weight: 400;
  font-style: italic;
}
.vars__prev {
  color: #92400e;
  font-size: 11.5px;
  font-weight: 500;
  text-decoration: line-through;
  opacity: 0.75;
  margin-right: 4px;
}
.vars__arrow {
  color: #b45309;
  font-weight: 700;
  margin-right: 4px;
}
.vars__chg td {
  background: #fef9c3;
  transition: background 0.4s;
}
.prob {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line-2);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
}
.prob:hover {
  background: #f8fafc;
}
.prob--error {
  border-left: 4px solid var(--err);
}
.prob--warn {
  border-left: 4px solid var(--warn);
}
.prob__line {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 1px;
}
.prob__msg {
  flex: 1;
}
.prob__hint {
  display: block;
  color: #92400e;
  font-size: 12.5px;
  margin-top: 3px;
}

/* ------------------------------------------------------------- Toast / modal */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 30px);
  opacity: 0;
  pointer-events: none;
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgb(0 0 0 / 0.25);
  transition: all 0.2s;
  z-index: 2000;
  max-width: 90vw;
}
.toast--on {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast--ok {
  background: #166534;
}
.toast--error {
  background: #991b1b;
}
.toast--warn {
  background: #92400e;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal__back {
  position: absolute;
  inset: 0;
  background: rgb(15 23 42 / 0.5);
}
.modal__panel {
  position: relative;
  background: #fff;
  border-radius: 14px;
  width: min(900px, 94vw);
  max-height: 88vh;
  overflow: auto;
  padding: 22px 26px;
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.3);
}
.modal__panel h2 {
  margin: 0 0 10px;
}
.modal__x {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: #f1f5f9;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
}
/* ------------------------------------------------------------- Modal de Documentação & Guia Didático */
.docs-dialog {
  position: relative;
  background: #fff;
  border-radius: 14px;
  width: min(1180px, 96vw);
  height: min(860px, 92vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.35);
}
.docs-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 54px 14px 20px;
  background: linear-gradient(90deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff;
  flex-wrap: wrap;
}
.docs-top__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.docs-top__icon {
  font-size: 28px;
}
.docs-top__title {
  margin: 0;
  font-size: 18px;
}
.docs-top__sub {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.88;
}
.docs-top__search {
  position: relative;
  margin-left: auto;
  flex: 1;
  max-width: 440px;
  min-width: 240px;
}
.docs-top__search-ico {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  pointer-events: none;
}
.docs-top__search input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border-radius: 999px;
  border: 0;
  font-size: 13.5px;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.15);
  outline: none;
}
.docs-top .modal__x {
  top: 16px;
  right: 14px;
  background: rgb(255 255 255 / 0.2);
  color: #fff;
  font-weight: 700;
}
.docs-top .modal__x:hover {
  background: rgb(255 255 255 / 0.35);
}
.docs-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 250px 1fr;
}
.docs-nav {
  background: #f8fafc;
  border-right: 1px solid var(--line);
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.docs-nav__btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: #334155;
}
.docs-nav__btn:hover {
  background: #e2e8f0;
}
.docs-nav__btn--on {
  background: #2563eb;
  color: #fff;
}
.docs-content {
  padding: 22px 28px 40px;
  overflow-y: auto;
  line-height: 1.6;
  color: #1e293b;
}
.docs-content h3 {
  margin: 0 0 8px;
  font-size: 20px;
  color: #0f172a;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 6px;
}
.docs-content h4 {
  margin: 18px 0 6px;
  font-size: 15.5px;
  color: #1e3a8a;
}
.docs-lead {
  font-size: 14.5px;
  color: #475569;
  margin: 0 0 16px;
}
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.doc-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}
.doc-card h5 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 6px;
}
.doc-card p {
  margin: 0 0 8px;
  font-size: 13px;
  color: #334155;
}
.doc-pre {
  background: #0f172a;
  color: #f8fafc;
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 6px 0;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.45;
}
.doc-pre--wrong {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.doc-pre--right {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.doc-callout {
  background: #eff6ff;
  border-left: 4px solid #2563eb;
  padding: 10px 14px;
  border-radius: 6px;
  margin: 12px 0;
  font-size: 13.5px;
}
.doc-callout--warn {
  background: #fffbeb;
  border-left-color: #d97706;
  color: #92400e;
}
.doc-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 10px 0 18px;
}
.doc-tbl th,
.doc-tbl td {
  border: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}
.doc-tbl th {
  background: #f1f5f9;
  font-weight: 700;
}
.doc-fn-filter {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.doc-fn-chip {
  border: 1px solid var(--line);
  background: #f8fafc;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.doc-fn-chip--on {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.doc-fn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fff;
}
.doc-fn__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.doc-fn__sig {
  font-family: var(--mono);
  font-weight: 800;
  font-size: 14px;
  color: #1d4ed8;
  background: #eff6ff;
  padding: 2px 8px;
  border-radius: 6px;
}
.doc-fn__ret {
  font-size: 11.5px;
  font-weight: 700;
  color: #0d9488;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  padding: 1px 7px;
  border-radius: 999px;
}
.doc-fn__cat {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}
.doc-blk {
  border: 1px solid var(--line);
  border-left: 6px solid var(--c, #64748b);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fff;
}
.doc-blk__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.crt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 8px;
  margin: 10px 0;
}
.crt-swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12.5px;
}
.crt-swatch__box {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid rgb(0 0 0 / 0.2);
  flex: none;
}

/* ------------------------------------------------------------- Responsivo */
@media (max-width: 1100px) {
  :root {
    --side-w: 230px;
    --right-w: 360px;
  }
  .btn--step {
    padding: 8px 10px;
  }
  .btn--step .btn__label {
    display: none;
  }
}
@media (max-width: 820px) {
  html,
  body {
    overflow: auto;
  }
  .top {
    flex-wrap: wrap;
    height: auto;
    padding: 8px;
  }
  .main {
    display: flex;
    flex-direction: column;
    height: auto;
  }
  .side {
    max-height: 260px;
  }
  .center {
    min-height: 60vh;
  }
  .split {
    display: none;
  }
  .right {
    height: 80vh;
    padding: 10px;
  }
  .help {
    grid-template-columns: 1fr;
  }
}

