.editor-toolbar {
  border-bottom: 1px solid var(--line);
  background: var(--ink-2);
}
.editor-toolbar .row {
  padding: 9px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.row2-label {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  color: var(--text-2);
}
.editor-toolbar .spacer, .previewpane-head .spacer, .codepane-head .spacer, .console-tabs .spacer { flex: 1; }
.file-input { display: none; }
#project-select { padding: 6px 8px; font-size: 0.82rem; }
#popular-deps { padding: 6px 8px; font-size: 0.78rem; }
#project-mode { padding: 6px 8px; font-size: 0.82rem; }
.dep-input { width: 100%; min-width: 0; padding: 6px 8px; font-size: 0.78rem; }
.dep-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dep-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink-3); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 10px; font-family: var(--f-mono); font-size: 0.72rem; color: var(--text-1);
}
.dep-chip .dep-remove { border: none; background: none; color: var(--text-2); cursor: pointer; font-size: 0.85rem; line-height: 1; }
.dep-chip .dep-remove:hover { color: var(--bad); }

.editor-layout {
  display: grid;
  grid-template-columns: 240px 1fr 1fr;
  height: calc(100vh - 64px - 56px);
  min-height: 560px;
}
.editor-layout.tools-open {
  grid-template-columns: 240px 1fr 1fr 280px;
}

/* ---------- tools sidebar (project / dependencies / build) ---------- */
.tools-panel {
  display: none;
  border-left: 1px solid var(--line);
  background: var(--ink-1);
  overflow-y: auto;
  padding: 16px 14px;
}
.editor-layout.tools-open .tools-panel { display: block; }
.tools-section { margin-bottom: 24px; }
.tools-section:last-child { margin-bottom: 0; }
.tools-section-head {
  font-family: var(--f-mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: var(--text-2);
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.tools-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.tools-row:last-child { margin-bottom: 0; }
.tools-row select { flex: 1; min-width: 0; }
.tools-row .btn { flex: 1; justify-content: center; }
.tools-hint {
  font-size: 0.74rem;
  color: var(--text-2);
  line-height: 1.55;
  margin: 10px 0 0;
}
.tools-hint code { font-family: var(--f-mono); font-size: 0.72rem; }

/* ---------- sidebar / file manager ---------- */
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--ink-1);
  overflow-y: auto;
  padding: 12px 10px;
}
.search-input {
  width: 100%;
  padding: 7px 10px;
  font-size: 0.82rem;
  margin-bottom: 10px;
}
.sidebar-label, .search-input + .sidebar-label {
  font-family: var(--f-mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: var(--text-2);
  padding: 4px 8px 10px;
}
.folder { margin-bottom: 6px; }
.folder-name {
  font-family: var(--f-mono);
  font-size: 0.78rem;
  color: var(--text-1);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.folder-name .chip { width: 6px; height: 6px; border-radius: 50%; background: var(--wire); flex: none; }
.folder.drop-target .folder-name { background: var(--ink-3); border-radius: var(--radius); outline: 1px dashed var(--amber); }

.file-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 22px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-1);
}
.file-row:hover { background: var(--ink-2); box-shadow: var(--shadow); }
.file-row.active { background: var(--ink-3); color: var(--text-0); font-weight: 500; }
.file-row .ficon { font-family: var(--f-mono); font-size: 0.72rem; color: var(--text-2); width: 16px; text-align: center; flex: none; }
.file-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .size { font-family: var(--f-mono); font-size: 0.66rem; color: var(--text-2); }
.file-row button.rowbtn {
  border: none; background: none; color: var(--text-2);
  cursor: pointer; padding: 2px 4px; line-height: 1; font-size: 0.85rem;
  visibility: hidden;
}
.file-row:hover button.rowbtn { visibility: visible; }
.file-row button.rowbtn:hover { color: var(--wire); }
.file-row button.rowbtn.del:hover { color: var(--bad); }

.empty-hint {
  margin: 14px 8px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 0.82rem;
  text-align: center;
}
.dropzone-active .sidebar { background: var(--ink-2); outline: 2px dashed var(--amber); outline-offset: -4px; }

/* ---------- code pane ---------- */
.codepane { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }

.tabs-bar {
  display: flex;
  overflow-x: auto;
  background: var(--ink-1);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  font-family: var(--f-mono);
  font-size: 0.76rem;
  color: var(--text-1);
  border-right: 1px solid var(--line);
  background: var(--ink-1);
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.tab.active { background: var(--ink-2); color: var(--text-0); box-shadow: inset 0 -2px 0 var(--amber); }
.tab .tab-close { color: var(--text-2); border: none; background: none; cursor: pointer; font-size: 0.9rem; padding: 0 2px; }
.tab .tab-close:hover { color: var(--bad); }
.tab .dirty-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); flex: none; }

.codepane-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-2);
  font-family: var(--f-mono);
  font-size: 0.78rem;
  color: var(--text-1);
  flex: none;
  flex-wrap: wrap;
}
.codepane-head .fname { color: var(--text-0); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 80px; }
.codepane-head select {
  font-family: var(--f-mono);
  font-size: 0.72rem;
  padding: 3px 6px;
}
.live-reload-pill { font-family: var(--f-mono); font-size: 0.7rem; cursor: pointer; gap: 5px; }
.live-reload-pill input { margin: 0; }
.btn-icon-mini {
  border: 1px solid var(--line);
  background: var(--ink-3);
  color: var(--text-1);
  border-radius: var(--radius);
  padding: 3px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}
.btn-icon-mini:hover { color: var(--text-0); }

.code-body { flex: 1; display: flex; overflow: hidden; background: var(--ink-0); min-height: 0; }
.code-body .CodeMirror { flex: 1; height: 100% !important; font-family: var(--f-mono); font-size: 0.84rem; line-height: 1.55; }
.plain-editor {
  flex: 1; width: 100%; height: 100%; border: none; resize: none;
  background: var(--ink-0); color: var(--text-0);
  font-family: var(--f-mono); font-size: 0.84rem; line-height: 1.55;
  padding: 14px 16px; white-space: pre;
}
.plain-editor:focus { outline: none; }
.codepane-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: 0.9rem;
  padding: 20px;
  text-align: center;
}

/* console / problems panel */
.console-panel {
  flex: none;
  height: 160px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: var(--ink-2);
}
.console-panel.collapsed { height: 34px; }
.console-panel.collapsed .console-body { display: none !important; }
.console-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.console-tabs button {
  border: none; background: none; color: var(--text-2);
  font-family: var(--f-mono); font-size: 0.74rem;
  padding: 8px 14px; cursor: pointer;
}
.console-tabs button.active { color: var(--text-0); box-shadow: inset 0 -2px 0 var(--wire); }
.badge {
  display: inline-block;
  margin-left: 6px;
  background: var(--bad);
  color: #fff;
  border-radius: 999px;
  font-size: 0.62rem;
  padding: 1px 6px;
}
.console-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: var(--f-mono);
  font-size: 0.76rem;
}
.console-line { padding: 3px 0; border-bottom: 1px solid var(--line); color: var(--text-1); white-space: pre-wrap; }
.console-line.error { color: var(--bad); }
.console-line.warn { color: var(--amber); }
.console-empty { color: var(--text-2); padding: 10px 0; }

.audit-score-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; }
.audit-score-label { font-family: var(--f-mono); font-size: 0.78rem; width: 84px; flex: none; color: var(--text-1); }
.audit-bar { flex: 1; height: 8px; background: var(--ink-3); border-radius: 999px; overflow: hidden; }
.audit-bar-fill { height: 100%; border-radius: 999px; transition: width 200ms ease; }
.audit-score-num { font-family: var(--f-mono); font-size: 0.78rem; width: 32px; text-align: right; flex: none; }
.audit-list { list-style: none; margin: 0 0 14px; padding: 0; font-size: 0.78rem; }
.audit-list li { padding: 3px 0 3px 4px; color: var(--text-1); }
.audit-list li.pass { color: var(--good); }
.audit-list li.fail { color: var(--bad); }

/* ---------- preview pane ---------- */
.previewpane { display: flex; flex-direction: column; min-width: 0; background: var(--ink-1); }
.previewpane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-2);
  flex-wrap: wrap;
}
.size-toggle { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.size-toggle button {
  border: none; background: var(--ink-3); color: var(--text-1);
  font-family: var(--f-mono); font-size: 0.72rem; padding: 6px 10px;
  cursor: pointer; border-right: 1px solid var(--line);
}
.size-toggle button:last-child { border-right: none; }
.size-toggle button.active { background: var(--amber); color: var(--amber-ink); }
.width-input { width: 62px; padding: 5px 6px; font-size: 0.75rem; font-family: var(--f-mono); }
.width-readout { font-family: var(--f-mono); font-size: 0.72rem; color: var(--text-2); }
.entry-select { font-family: var(--f-mono); font-size: 0.72rem; padding: 5px 8px; }

.preview-stage {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 22px;
  background:
    linear-gradient(45deg, var(--ink-3) 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(-45deg, var(--ink-3) 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(45deg, transparent 75%, var(--ink-3) 75%) 0 0/16px 16px,
    linear-gradient(-45deg, transparent 75%, var(--ink-3) 75%) 0 0/16px 16px,
    var(--ink-1);
}
.device-frame {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 0 0 1px var(--line), var(--shadow);
  transition: width 160ms ease;
  overflow: hidden;
  height: 100%;
}
.device-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.device-frame:fullscreen, .device-frame:-webkit-full-screen { width: 100% !important; height: 100%; }

@media (max-width: 980px) {
  .editor-layout, .editor-layout.tools-open { grid-template-columns: 1fr; height: auto; }
  .sidebar, .codepane { border-right: none; border-bottom: 1px solid var(--line); height: 360px; }
  .previewpane { height: 480px; }
  .tools-panel { border-left: none; border-top: 1px solid var(--line); }
}
