body.pg { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.pg-bar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pg-title { margin-right: auto; }
.pg-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pg-check { font-size: 13px; display: flex; gap: 6px; align-items: center; cursor: pointer; }
select.btn { padding-right: 8px; }

.pg-main { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--split, 55%) 6px minmax(0, 1fr); }
.pg-editor, .pg-term { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pg-resizer { cursor: col-resize; background: var(--border); }
.pg-resizer:hover, .pg-resizer:focus-visible { background: var(--accent); outline: none; }

.tabs { display: flex; gap: 2px; padding: 6px 8px 0; background: var(--surface-2); border-bottom: 1px solid var(--border); overflow-x: auto; flex: none; }
.tab { display: flex; align-items: center; gap: 6px; padding: 6px 12px; font: 13px var(--mono); border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--code-bg); color: var(--text); border-color: var(--border); position: relative; top: 1px; }
.tab .x { opacity: .5; padding: 0 2px; border-radius: 4px; }
.tab .x:hover { opacity: 1; background: var(--bad-soft); color: var(--bad); }
.tab.add { font-weight: 700; }

/* Editor: a transparent textarea over a syntax-highlighted <pre> with identical metrics. */
.ed { flex: 1; min-height: 0; display: flex; background: var(--code-bg); font: 14px/1.7 var(--mono); font-variant-ligatures: none; }
.gutter { flex: none; width: 48px; overflow: hidden; text-align: right; padding: 12px 10px 12px 0; color: var(--muted); opacity: .7; user-select: none; white-space: pre; border-right: 1px solid var(--border); }
.ed-wrap { position: relative; flex: 1; min-width: 0; }
.ed-wrap pre, .ed-wrap textarea {
  position: absolute; inset: 0; margin: 0; padding: 12px 14px; border: 0; width: 100%; height: 100%;
  font: inherit; font-variant-ligatures: none; letter-spacing: 0; line-height: inherit; tab-size: 4;
  white-space: pre; overflow: auto; word-wrap: normal; text-wrap: nowrap;
}
.ed-wrap pre { pointer-events: none; color: var(--text); overflow: hidden; }
.ed-wrap textarea { background: transparent; color: transparent; caret-color: var(--text); resize: none; outline: none; }
.ed-wrap textarea::selection { background: var(--accent-soft); color: transparent; }
.pg-status { display: flex; justify-content: space-between; gap: 12px; padding: 4px 12px; font-size: 12px; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--muted); flex: none; }

.term-bar { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px 4px 12px; font-size: 13px; background: #161b22; color: #c9d1d9; border-bottom: 1px solid #2b3340; flex: none; }
.term-bar .btn { color: #c9d1d9; border-color: #2b3340; }
.term-bar .btn:hover { background: #222a35; }
.term-bar .muted { color: #7d8590; }
#term { flex: 1; min-height: 0; background: #0d1117; padding: 10px 14px; overflow: auto; }
#term pre { margin: 0; color: #d7e0ee; font: 14px/1.5 var(--mono); font-variant-ligatures: none; white-space: pre-wrap; word-break: break-word; }
.stdin-box { flex: none; padding: 8px 12px 10px; background: #161b22; color: #c9d1d9; border-top: 1px solid #2b3340; font-size: 12.5px; }
.stdin-box label { display: block; margin-bottom: 4px; }
.stdin-box .muted { color: #7d8590; }
.stdin-box code { background: #222a35; padding: 0 4px; border-radius: 4px; }
.stdin-box textarea { width: 100%; resize: vertical; min-height: 44px; max-height: 160px; font: 13.5px/1.4 var(--mono); background: #0d1117; color: #d7e0ee; border: 1px solid #2b3340; border-radius: 6px; padding: 6px 8px; }
.btn.stop { background: var(--bad); border-color: var(--bad); color: #fff; }

.pg-overlay[hidden] { display: none; }
.pg-overlay { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 50; padding: 16px; }
.pg-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 8px 24px 24px; max-width: 520px; }
.pg-card .code { background: var(--code-bg); border-radius: 8px; }

@media (max-width: 860px) {
  .pg-main { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 6px minmax(0, 1fr); }
  .pg-resizer { cursor: row-resize; }
}
