:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-alt: #eef2f0;
  --line: #ccd6d1;
  --line-strong: #9aa8a2;
  --text: #18211d;
  --muted: #5d6b65;
  --accent: #176b6a;
  --accent-strong: #0e5453;
  --warn: #9a5a13;
  --error: #a13434;
  --ok: #277242;
  --code-bg: #101614;
  --code-text: #e9f0ec;
  --code-muted: #7c8b84;
  --tool-bg: #111715;
  --tool-surface: #17201d;
  --tool-surface-alt: #202b27;
  --tool-line: #314039;
  --tool-text: #dce6e1;
  --tool-muted: #9aaaa2;
  --focus: #2c7fda;
  --source-font-size: 14px;
  --outputs-font-size: 13px;
  --diagnostics-font-size: 14px;
  --line-number-width: 58px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--tool-bg);
  color: var(--text);
}

button,
textarea,
select,
input {
  font: inherit;
}

.app-shell {
  height: 100vh;
  min-height: 100%;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 14px;
  background: var(--tool-surface-alt);
  border-bottom: 1px solid var(--tool-line);
  color: var(--tool-text);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: #101614;
  color: var(--tool-text);
  border: 1px solid var(--tool-line);
  border-radius: 6px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--tool-text);
  font-size: 16px;
  line-height: 1.1;
}

.brand p {
  margin-top: 1px;
  color: var(--tool-muted);
  font-size: 11px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.layout-control {
  height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--tool-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.layout-select {
  height: 28px;
  min-width: 170px;
  padding: 0 24px 0 8px;
  border: 1px solid #4a5d54;
  border-radius: 6px;
  background: #1f2b26;
  color: var(--tool-text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.topbar .tool-button {
  min-height: 28px;
  height: 28px;
  padding: 0 8px;
  gap: 4px;
  background: #1f2b26;
  color: var(--tool-text);
  border-color: #4a5d54;
  font-size: 11px;
  font-weight: 700;
}

.topbar .tool-button:hover {
  border-color: #76aaa0;
}

.switch-control {
  height: 28px;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid #4a5d54;
  border-radius: 6px;
  background: #1f2b26;
  color: var(--tool-text);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.switch-control:hover {
  border-color: #76aaa0;
}

.switch-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-label {
  color: var(--tool-muted);
}

.switch-track {
  width: 30px;
  height: 16px;
  position: relative;
  flex: 0 0 auto;
  border: 1px solid #4a5d54;
  border-radius: 999px;
  background: #121a17;
}

.switch-thumb {
  width: 12px;
  height: 12px;
  position: absolute;
  top: 1px;
  left: 1px;
  border-radius: 999px;
  background: #7c8b84;
  transition: transform 120ms ease, background 120ms ease;
}

.switch-control input:checked ~ .switch-track {
  background: #244b37;
  border-color: #4f8d62;
}

.switch-control input:checked ~ .switch-track .switch-thumb {
  transform: translateX(14px);
  background: #b8f2c8;
}

.switch-control input:focus-visible ~ .switch-track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.topbar-button {
  white-space: nowrap;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.toggle-control {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.toggle-control input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.tool-button,
.primary-button,
.icon-button,
.download-button,
.remove-file-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  min-height: 34px;
}

.tool-button,
.primary-button,
.download-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.tool-button.compact {
  min-width: 48px;
  justify-content: center;
  min-height: 28px;
  height: 28px;
  padding: 0 7px;
  font-size: 11px;
}

.tool-button.mini {
  min-width: 40px;
  min-height: 28px;
  height: 28px;
  justify-content: center;
  padding: 0 7px;
  font-size: 11px;
}

.primary-button.compact {
  min-width: 78px;
  justify-content: center;
  min-height: 28px;
  height: 28px;
  padding: 0 9px;
  font-size: 11px;
}

.toggle-control.compact {
  height: 28px;
  gap: 5px;
  padding: 0 7px;
  font-size: 11px;
}

.primary-button {
  border-color: var(--accent-strong);
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.icon-button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
}

.remove-file-button {
  min-width: 50px;
  min-height: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  font-size: 11px;
}

button:hover {
  border-color: var(--accent);
}

button:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.workspace {
  display: grid;
  grid-template-columns:
    var(--workspace-col-1, minmax(420px, 1.28fr))
    var(--workspace-col-2, minmax(280px, 0.68fr))
    var(--workspace-col-3, minmax(380px, 1fr));
  min-height: 0;
  background: var(--tool-bg);
}

.editor-pane,
.emulator-pane,
.side-pane {
  min-height: 0;
  border-right: 1px solid var(--tool-line);
}

.workspace > .workspace-pane.is-last-column {
  border-right: 0;
}

.editor-pane {
  display: grid;
  grid-template-rows: 40px 34px minmax(0, 1fr) var(--project-files-height, 156px);
  background: var(--tool-bg);
}

.editor-pane.project-files-collapsed {
  --project-files-height: 40px;
}

.emulator-pane {
  display: grid;
  grid-template-rows: 40px minmax(0, 1fr);
  min-width: 0;
  background: var(--tool-surface);
}

.emulator-pane.is-collapsed {
  grid-template-rows: 40px 0;
  overflow: hidden;
}

.emulator-pane.is-collapsed .emulator-head {
  justify-content: center;
  padding: 0;
}

.emulator-pane.is-collapsed .emulator-head h2,
.emulator-pane.is-collapsed .scale-control,
.emulator-pane.is-collapsed #emulatorStatus,
.emulator-pane.is-collapsed #resetEmulatorButton {
  display: none;
}

.emulator-pane.is-collapsed .emulator-actions {
  width: 100%;
  justify-content: center;
  overflow: visible;
}

.emulator-pane.is-collapsed .emulator-stage {
  display: none;
}

.side-pane {
  display: grid;
  grid-template-rows: minmax(220px, 0.9fr) minmax(240px, 1.1fr);
  min-width: 0;
  background: var(--tool-bg);
}

.side-pane.is-collapsed {
  grid-template-rows: 40px 40px;
  overflow: hidden;
}

.panel {
  min-height: 0;
  display: grid;
  grid-template-rows: 46px 1fr;
  border-bottom: 1px solid var(--tool-line);
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  background: var(--tool-surface-alt);
  border-bottom: 1px solid var(--tool-line);
}

.side-pane .panel {
  grid-template-rows: 40px 1fr;
}

.side-pane.is-collapsed .panel {
  grid-template-rows: 40px 0;
  overflow: hidden;
}

.side-pane.is-collapsed .pane-head {
  justify-content: center;
  padding: 0;
}

.side-pane.is-collapsed .pane-head h2,
.side-pane.is-collapsed .pane-actions > :not(.build-toggle-button) {
  display: none;
}

.side-pane.is-collapsed .pane-actions {
  width: 100%;
  justify-content: center;
  overflow: visible;
}

.side-pane.is-collapsed .outputs,
.side-pane.is-collapsed .diagnostics {
  display: none;
}

.editor-pane .pane-head,
.side-pane .pane-head {
  background: var(--tool-surface-alt);
  border-bottom-color: var(--tool-line);
}

.pane-head h2 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--tool-muted);
  letter-spacing: 0.04em;
}

.pane-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 4px;
  min-width: 0;
}

.pane-actions > span:not(.status-pill) {
  color: var(--tool-muted);
  font-size: 11px;
  font-weight: 700;
}

.editor-pane .pane-head h2,
.editor-pane .pane-head > span,
.side-pane .pane-head h2,
.side-pane .pane-head > span {
  color: var(--tool-muted);
}

.source-head {
  min-width: 0;
  overflow: hidden;
}

.source-title {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}

.source-title h2 {
  flex-shrink: 0;
}

.source-meta {
  flex: 1 1 auto;
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  color: var(--tool-muted);
  font-size: 11px;
}

.source-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#sourceName {
  flex: 1 1 auto;
  max-width: none;
}

#lineCount {
  flex-shrink: 0;
}

.source-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  min-width: 0;
}

.source-actions .tool-button,
.source-actions .toggle-control,
.side-pane .tool-button,
.project-panel .tool-button,
.project-panel .remove-file-button {
  background: #1f2b26;
  color: var(--tool-text);
  border-color: #4a5d54;
}

.source-actions .tool-button:hover,
.source-actions .toggle-control:hover,
.side-pane .tool-button:hover,
.project-panel .tool-button:hover,
.project-panel .remove-file-button:hover {
  border-color: #76aaa0;
}

.source-actions .toggle-control input {
  accent-color: #67c08d;
}

.font-control {
  height: 28px;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid #4a5d54;
  border-radius: 6px;
  background: #1f2b26;
}

.font-button {
  height: 26px;
  min-width: 28px;
  padding: 0 6px;
  border: 0;
  border-right: 1px solid #4a5d54;
  border-radius: 0;
  background: transparent;
  color: var(--tool-text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.font-button:last-child {
  border-right: 0;
  border-left: 1px solid #4a5d54;
}

.font-button:hover {
  background: #244b37;
}

.font-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.font-button:disabled:hover {
  background: transparent;
}

.font-size-value {
  min-width: 35px;
  padding: 0 5px;
  color: var(--tool-text);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.editor-tabs {
  min-width: 0;
  display: flex;
  align-items: end;
  gap: 4px;
  padding: 5px 8px 0;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--tool-surface);
  border-bottom: 1px solid var(--tool-line);
}

.editor-tab {
  max-width: 180px;
  height: 29px;
  min-height: 29px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--tool-line);
  border-bottom-color: transparent;
  border-radius: 6px 6px 0 0;
  background: #141d1a;
  color: var(--tool-muted);
  font-size: 12px;
  font-weight: 700;
}

.editor-tab.active {
  background: var(--tool-surface);
  color: var(--tool-text);
  border-color: #4a5d54;
  border-bottom-color: var(--tool-surface);
}

.editor-tab-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-tab-badge {
  flex-shrink: 0;
  padding: 1px 5px;
  border-radius: 999px;
  background: #244b37;
  color: #b8f2c8;
  font-size: 10px;
  text-transform: uppercase;
}

.emulator-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.scale-control {
  height: 28px;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid #4a5d54;
  border-radius: 6px;
  background: #1f2b26;
}

.scale-button {
  height: 26px;
  min-width: 34px;
  padding: 0 6px;
  border: 0;
  border-right: 1px solid #4a5d54;
  border-radius: 0;
  background: transparent;
  color: var(--tool-text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.fullscreen-scale-button {
  min-width: 38px;
}

.scale-button:last-child {
  border-right: 0;
}

.scale-button.active {
  background: #244b37;
  color: #b8f2c8;
}

.emulator-actions .tool-button {
  background: #1f2b26;
  color: var(--tool-text);
  border-color: #4a5d54;
}

.emulator-actions .tool-button:hover,
.scale-button:hover {
  border-color: #76aaa0;
}

.reset-button {
  min-width: 48px;
  min-height: 28px;
  height: 28px;
  padding: 0 7px;
  font-size: 11px;
}

.emulator-stage {
  min-height: 0;
  display: grid;
  background: var(--tool-surface);
}

.emulator-pane:fullscreen {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: 40px minmax(0, 1fr);
  border: 0;
  background: var(--tool-surface);
}

.emulator-pane:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: 40px minmax(0, 1fr);
  border: 0;
  background: var(--tool-surface);
}

#emulatorFrame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  display: block;
  background: var(--tool-surface);
}

.editor-frame {
  min-height: 0;
  display: grid;
  grid-template-columns: var(--line-number-width) 1fr;
  background: var(--tool-surface);
}

#lineNumbers,
#sourceHighlight,
#sourceEditor,
.diagnostics {
  font-family: "Cascadia Mono", "Consolas", "SFMono-Regular", monospace;
  line-height: 1.5;
  letter-spacing: 0;
}

#lineNumbers {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  padding: 14px 10px 14px 0;
  text-align: right;
  overflow: hidden;
  user-select: none;
  color: var(--tool-muted);
  background: #111916;
  border-right: 1px solid var(--tool-line);
}

#lineNumbers,
#sourceHighlight,
#sourceEditor {
  font-size: var(--source-font-size);
}

#sourceHighlight,
#sourceEditor {
  grid-column: 2;
  grid-row: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  padding: 14px;
  tab-size: 4;
}

#sourceHighlight {
  position: relative;
  z-index: 1;
  margin: 0;
  overflow: hidden;
  white-space: pre;
  background: var(--tool-surface);
  color: var(--tool-text);
  pointer-events: none;
}

#sourceEditor {
  position: relative;
  z-index: 2;
  resize: none;
  overflow: auto;
  background: transparent;
  color: transparent;
  caret-color: #ffffff;
  outline: none;
  -webkit-text-fill-color: transparent;
}

#sourceEditor::selection {
  background: rgba(44, 127, 218, 0.34);
}

.editor-frame.syntax-highlight-pending #sourceEditor {
  color: rgba(220, 230, 225, 0.46);
  -webkit-text-fill-color: rgba(220, 230, 225, 0.46);
}

.editor-frame.syntax-color-disabled #sourceHighlight {
  display: none;
}

.editor-frame.syntax-color-disabled #sourceEditor,
.editor-frame.syntax-color-disabled.syntax-highlight-pending #sourceEditor {
  background: var(--tool-surface);
  color: var(--tool-text);
  -webkit-text-fill-color: var(--tool-text);
}

.asm-comment {
  color: #7f968c;
}

.asm-line {
  display: block;
  min-height: 1.5em;
  white-space: pre;
}

.asm-label {
  color: #8de0aa;
  font-weight: 700;
}

.asm-mnemonic {
  color: #8fd9ff;
  font-weight: 700;
}

.asm-directive {
  color: #b8f2c8;
  font-weight: 700;
}

.asm-register {
  color: #f0c77b;
}

.asm-condition {
  color: #d8bdff;
}

.asm-number {
  color: #91e7d1;
}

.asm-string {
  color: #f3a6a6;
}

.diagnostics {
  margin: 0;
  padding: 12px 14px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--tool-surface);
  color: var(--tool-text);
  font-size: var(--diagnostics-font-size);
}

.status-pill {
  min-width: 54px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--line);
}

.status-pill.idle {
  color: var(--tool-muted);
  background: #121a17;
  border-color: var(--tool-line);
}

.status-pill.running {
  color: #f0c77b;
  background: #322718;
  border-color: #6c5528;
}

.status-pill.ok {
  color: #8de0aa;
  background: #173323;
  border-color: #3f7650;
}

.status-pill.error {
  color: #ffaaa5;
  background: #351c1c;
  border-color: #7b4141;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 8px 10px;
  overflow: auto;
  background: var(--tool-surface);
  color: var(--tool-text);
}

.file-list li {
  min-height: 36px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--tool-line);
}

.project-panel {
  grid-template-rows: 40px 1fr;
  border-top: 1px solid var(--tool-line);
  border-bottom: 0;
  overflow: hidden;
}

.project-panel .pane-head {
  padding: 0 10px;
}

.project-panel.is-collapsed {
  grid-template-rows: 40px 0;
}

.project-panel.is-collapsed .file-list {
  display: none;
}

.project-toggle-button,
.emulator-toggle-button,
.build-toggle-button {
  width: 28px;
  min-width: 28px;
  justify-content: center;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.file-meta {
  min-width: 0;
}

.file-meta.clickable {
  cursor: pointer;
}

.file-meta.clickable:hover .file-name {
  color: #b8f2c8;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.file-size {
  color: var(--tool-muted);
  font-size: 12px;
}

.outputs {
  overflow: auto;
  padding: 10px;
  background: var(--tool-surface);
  color: var(--tool-text);
}

.output-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border-bottom: 1px solid var(--tool-line);
}

.output-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.output-actions .download-button {
  min-height: 28px;
  height: 28px;
  padding: 0 7px;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.side-pane .download-button,
.side-pane .tool-button,
.side-pane .icon-button,
.side-pane .remove-file-button {
  background: #1f2b26;
  color: var(--tool-text);
  border-color: #4a5d54;
}

.side-pane .download-button:hover,
.side-pane .tool-button:hover,
.side-pane .icon-button:hover,
.side-pane .remove-file-button:hover {
  border-color: #76aaa0;
}

.output-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: var(--outputs-font-size);
}

.output-size {
  color: var(--tool-muted);
  font-size: var(--outputs-font-size);
}

.empty-state {
  color: var(--tool-muted);
  font-size: 13px;
  padding: 6px 0;
}

.outputs .empty-state {
  font-size: var(--outputs-font-size);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 13, 12, 0.7);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: min(420px, 100%);
  display: grid;
  gap: 11px;
  padding: 16px;
  border: 1px solid #4a5d54;
  border-radius: 8px;
  background: var(--tool-surface-alt);
  color: var(--tool-text);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.38);
}

.modal-card h2 {
  color: var(--tool-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-field {
  display: grid;
  gap: 6px;
}

.modal-field span {
  color: var(--tool-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.modal-field input {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border: 1px solid #4a5d54;
  border-radius: 6px;
  background: var(--tool-surface);
  color: var(--tool-text);
  outline: none;
}

.modal-field input:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(44, 127, 218, 0.28);
}

.modal-hint,
.modal-error {
  margin: 0;
  font-size: 12px;
}

.modal-hint {
  color: var(--tool-muted);
}

.modal-error {
  color: #ffaaa5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(360px, 1fr) var(--responsive-cpc-column, minmax(430px, 1fr));
    grid-template-rows: minmax(0, 1fr) var(--responsive-build-row, minmax(250px, 34vh));
  }

  .workspace.emulator-pane-collapsed {
    --responsive-cpc-column: 44px;
  }

  .workspace.build-pane-collapsed {
    --responsive-build-row: 40px;
  }

  .editor-pane {
    grid-column: 1;
    grid-row: 1;
    border-bottom: 1px solid var(--tool-line);
  }

  .emulator-pane {
    grid-column: 2;
    grid-row: 1;
    border-bottom: 1px solid var(--tool-line);
  }

  .side-pane {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr);
    grid-template-rows: minmax(0, 1fr);
    border-right: 0;
  }

  .side-pane.is-collapsed {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 40px;
  }

  .panel {
    border-right: 1px solid var(--tool-line);
  }

  .panel:last-child {
    border-right: 0;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-rows: auto 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .layout-control {
    width: 100%;
  }

  .layout-select {
    min-width: 190px;
    max-width: 100%;
  }

  .toolbar {
    overflow-x: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(500px, 52vh) var(--responsive-cpc-row, minmax(320px, 34vh)) var(--responsive-build-row, minmax(320px, 1fr));
  }

  .workspace.emulator-pane-collapsed {
    --responsive-cpc-row: 40px;
  }

  .workspace.build-pane-collapsed {
    --responsive-build-row: 80px;
  }

  .editor-pane {
    grid-column: 1;
    grid-row: 1;
    grid-template-rows: auto 34px minmax(0, 1fr) var(--project-files-height, 148px);
    border-right: 0;
    border-bottom: 1px solid var(--tool-line);
  }

  .emulator-pane {
    grid-column: 1;
    grid-row: 2;
    border-right: 0;
  }

  .side-pane {
    grid-column: 1;
    grid-row: 3;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(150px, 1fr) minmax(170px, 1fr);
  }

  .side-pane.is-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: 40px 40px;
  }

  .panel {
    border-right: 0;
  }

  .source-meta {
    gap: 8px;
    overflow: hidden;
  }

  .source-head {
    align-items: stretch;
    flex-direction: column;
    height: auto;
    padding: 8px 12px;
  }

  .source-actions {
    flex: 0 1 auto;
    margin-left: 0;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .emulator-actions {
    overflow-x: auto;
  }
}
