.pg-layout {
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr;
  height: calc(100vh - 64px); margin-top: 64px;
}
.pg-toolbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; background: var(--bg-secondary); border-bottom: 1px solid var(--border);
}
.pg-toolbar select, .pg-toolbar button {
  font-family: var(--font-sans); font-size: 0.85rem;
}
.pg-toolbar button {
  padding: 6px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-primary); cursor: pointer;
}
.pg-toolbar button.run {
  background: var(--accent-t); color: #000; border-color: var(--accent-t); font-weight: 700;
}
.pg-toolbar button:hover { opacity: 0.85; }
.pg-toolbar .spacer { flex: 1; }
.pg-toolbar .status { font-size: 0.8rem; color: var(--text-muted); }

.pg-editor {
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.pg-editor-header, .pg-output-header {
  padding: 8px 16px; font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.pg-editor-header { color: var(--accent-t); }

.hl-container {
  position: relative; flex: 1; overflow: hidden;
}
.hl-backdrop {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  overflow: auto; pointer-events: none;
}
.hl-code {
  margin: 0; padding: 16px; border: none; border-radius: 0; background: transparent;
  font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.7;
  color: var(--text-primary); white-space: pre-wrap; word-wrap: break-word;
  tab-size: 2;
}

#codeEditor {
  position: relative; z-index: 1;
  flex: 1; width: 100%; height: 100%; resize: none; border: none; outline: none;
  background: transparent; color: transparent; caret-color: var(--accent-t);
  font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.7;
  padding: 16px; tab-size: 2;
  -webkit-text-fill-color: transparent;
}
#codeEditor::selection { background: rgba(99,102,241,0.3); -webkit-text-fill-color: transparent; }

.hl-kw      { color: #c084fc; font-weight: 600; }
.hl-bi      { color: var(--accent-t); }
.hl-str     { color: var(--accent-gold); }
.hl-num     { color: var(--accent-blue); }
.hl-cmt     { color: var(--text-muted); font-style: italic; }
.hl-op      { color: var(--accent-a); }
.hl-br      { color: var(--text-secondary); }
/* FPGA 회로방언 — A색 오렌지 (#ff6b35) */
.hl-fpga    { color: #ff6b35; font-weight: 600; }
/* RPN 스택 키워드 — U색 보라 (#8b5cf6) */
.hl-rpn     { color: #8b5cf6; font-weight: 600; }
/* 3진 연산 키워드 — accent-u 밝은 계열 */
.hl-ternary { color: #a78bfa; font-style: italic; }

.pg-output { display: flex; flex-direction: column; }
.pg-output-header { color: var(--accent-o); }

#outputConsole {
  flex: 1; overflow-y: auto; padding: 16px;
  font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.6;
  background: var(--bg-primary); color: var(--text-secondary);
  white-space: pre-wrap;
}
#outputConsole .out-line { color: var(--text-primary); }
#outputConsole .out-error { color: var(--accent-a); }
#outputConsole .out-info { color: var(--accent-u); }

@media (max-width: 768px) {
  .pg-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr 1fr; }
  .pg-editor { border-right: none; border-bottom: 1px solid var(--border); }
}
