/* ===========================
   Editor layout (2026-10) — one compact top bar, tabbed code column,
   preview column with its own toolbar and console. Loaded after editor.css
   and uses the homepage tokens from /assets/agency.css (--ag-*).
   =========================== */

body.editor-page {
  --cf-top: 56px;
  --cf-bg: var(--ag-bg, #080A0F);
  --cf-panel: var(--ag-bg2, #0E1118);
  --cf-card: var(--ag-card, #121722);
  --cf-line: var(--ag-line, rgba(255,255,255,.08));
  --cf-line2: var(--ag-line2, rgba(255,255,255,.14));
  --cf-ink: var(--ag-ink, #F5F7FA);
  --cf-mut: var(--ag-mut, #A7AFBD);
  --cf-mut2: var(--ag-mut2, #7F8899);
  --cf-accent: var(--ag-accent, #5B8CFF);
  --cf-soft: var(--ag-soft, rgba(91,140,255,.12));
  --cf-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--cf-bg);
  color: var(--cf-ink);
  font-family: var(--ag-font);
  margin: 0;
}

/* ---------- Top bar ---------- */
.cf-top {
  position: sticky; top: 0; z-index: 60;
  height: var(--cf-top);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: rgba(8,10,15,.86);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--cf-line);
}
.cf-brand { display: flex; align-items: center; gap: 10px; color: var(--cf-ink); text-decoration: none; font-weight: 800; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.cf-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--ag-grad); display: grid; place-items: center; flex: 0 0 auto; box-shadow: 0 6px 18px -8px rgba(91,140,255,.8); }
.cf-mark svg { width: 17px; height: 17px; }
.cf-sep { width: 1px; height: 24px; background: var(--cf-line2); flex: 0 0 auto; }
.cf-crumbs { display: flex; align-items: center; gap: 6px; }
.cf-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 9px;
  font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
  color: var(--ag-a2, #7DA3FF);
  border: 1px solid rgba(91,140,255,.35);
  background: var(--cf-soft);
  transition: background .15s, border-color .15s, color .15s;
}
.cf-pill span { font-size: 17px; line-height: 1; margin-top: -2px; }
.cf-pill:hover { background: rgba(91,140,255,.2); color: #fff; }
.cf-pill-plain { color: var(--cf-mut); border-color: transparent; background: transparent; }
.cf-pill-plain:hover { color: var(--cf-ink); background: rgba(255,255,255,.06); }

.cf-title {
  min-width: 120px; width: 260px; flex: 0 1 260px;
  height: 34px; padding: 0 10px; border-radius: 9px;
  background: transparent; border: 1px solid transparent;
  color: var(--cf-ink); font: 600 15px var(--ag-font);
  transition: background .15s, border-color .15s;
}
.cf-title::placeholder { color: var(--cf-mut2); }
.cf-title:hover { background: rgba(255,255,255,.04); }
.cf-title:focus { outline: none; background: var(--cf-card); border-color: rgba(91,140,255,.5); }

.cf-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  font: 600 11.5px var(--cf-mono); letter-spacing: .02em; white-space: nowrap;
  color: var(--ag-warn, #F5B544); background: var(--ag-warn-bg, rgba(245,181,68,.12));
  border: 1px solid rgba(245,181,68,.28); cursor: pointer; user-select: none;
}
.cf-chip input { margin: 0; accent-color: var(--ag-warn, #F5B544); width: 13px; height: 13px; }

.cf-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.cf-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: 9px;
  font: 600 13px var(--ag-font); white-space: nowrap; cursor: pointer;
  color: var(--cf-ink); background: var(--cf-card);
  border: 1px solid var(--cf-line2);
  transition: background .15s, border-color .15s, transform .1s;
}
.cf-btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
.cf-btn:hover { background: var(--ag-card2, #161c29); border-color: rgba(255,255,255,.22); }
.cf-btn:active { transform: translateY(1px); }
.cf-btn:focus-visible, .cf-icon:focus-visible, .cf-tab:focus-visible, .cf-seg button:focus-visible { outline: 2px solid var(--cf-accent); outline-offset: 2px; }
.cf-primary {
  background: var(--ag-grad) !important; border-color: transparent !important;
  color: var(--ag-ink-on-accent, #080A0F) !important; font-weight: 700;
  box-shadow: 0 8px 22px -12px rgba(91,140,255,.9);
}
.cf-primary:hover { filter: brightness(1.08); }
.cf-split { display: inline-flex; }
.cf-split > .cf-btn:first-child { border-radius: 9px 0 0 9px; }
.cf-split > .cf-caret { border-radius: 0 9px 9px 0; border-left: 0; padding: 0 8px; }
.cf-icon {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; cursor: pointer;
  color: var(--cf-mut); background: transparent; border: 1px solid var(--cf-line2);
  transition: color .15s, background .15s;
}
.cf-icon svg { width: 17px; height: 17px; }
.cf-icon:hover { color: var(--cf-ink); background: rgba(255,255,255,.06); }

/* Save menu (reuses .btn-menu open/close logic in editor.js) */
.btn-menu { position: relative; }
.btn-menu-list { position: absolute; top: calc(100% + 8px); right: 0; min-width: 196px; border-radius: 12px; padding: 6px; display: none; z-index: 200; }
.btn-menu.open .btn-menu-list { display: block; }
.btn-menu-list button { display: flex; align-items: center; width: 100%; text-align: left; background: none; border: 0; font: 600 13.5px var(--ag-font); padding: 9px 11px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.editor-page .btn-menu-list { background: var(--cf-card); border: 1px solid var(--cf-line2); box-shadow: var(--ag-sh); }
.editor-page .btn-menu-list button { color: var(--ag-ink2, #D7DCE6); }
.editor-page .btn-menu-list button:hover { background: var(--cf-soft); color: #fff; }
.editor-page .btn-menu-list #btnClear { color: var(--ag-err, #FF6B5E); }

/* ---------- Workspace ---------- */
.editor-page > .workspace {
  height: calc(100vh - var(--cf-top));
  height: calc(100dvh - var(--cf-top));
  min-height: 460px;
  background: var(--cf-bg);
}
.workspace .panes { background: var(--cf-panel); display: flex; flex-direction: column !important; }
.workspace.layout-horizontal .panes { border-right: 0; }
.workspace.layout-vertical .panes { border-bottom: 0; }

/* File tabs */
.cf-tabs {
  flex: 0 0 auto; height: 46px; display: flex; align-items: stretch;
  padding: 0 8px 0 4px; background: var(--cf-panel);
  border-bottom: 1px solid var(--cf-line);
}
.cf-tablist { display: flex; align-items: stretch; }
.cf-sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.editor-page .splitter:focus-visible { outline: 2px solid var(--cf-accent); outline-offset: -2px; }
.cf-ctabs button:focus-visible { outline: 2px solid var(--cf-accent); outline-offset: -2px; }
.cf-tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 0 16px; background: none; border: 0; cursor: pointer;
  font: 500 13px var(--cf-mono); color: var(--cf-mut2);
  transition: color .15s;
}
.cf-tab:hover { color: var(--cf-ink); }
.cf-tab.on { color: var(--cf-ink); font-weight: 700; }
.cf-tab.on::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--ag-grad); border-radius: 2px 2px 0 0; }
.cf-tab .dot { width: 7px; height: 7px; border-radius: 50%; opacity: .9; }
.cf-tab .dot.html { background: #FF7A59; }
.cf-tab .dot.css { background: #5B8CFF; }
.cf-tab .dot.js { background: #F5B544; }
.cf-sp { flex: 1; }
.cf-tablink {
  align-self: center; background: none; border: 0; cursor: pointer;
  font: 600 11px var(--cf-mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--cf-mut2); padding: 6px 8px; border-radius: 6px;
}
.cf-tablink:hover { color: var(--cf-ink); background: rgba(255,255,255,.06); }

/* One file visible at a time */
.workspace .panes .pane { display: none; border: 0 !important; background: var(--cf-panel); }
.workspace .panes .pane.on { display: flex; }

/* CodeMirror on the homepage palette */
.editor-page .CodeMirror { background: var(--cf-panel) !important; font-family: var(--cf-mono) !important; font-size: 14px; line-height: 1.75; }
.editor-page .CodeMirror-gutters { background: var(--cf-panel) !important; border-right: 0 !important; }
.editor-page .CodeMirror-linenumber { color: #4A5163 !important; padding: 0 12px 0 8px; }
.editor-page .CodeMirror-activeline-background { background: rgba(91,140,255,.06) !important; }
.editor-page .CodeMirror-activeline-gutter .CodeMirror-linenumber { color: var(--cf-mut) !important; }
.editor-page .CodeMirror-cursor { border-left-color: var(--cf-accent) !important; }
.editor-page .CodeMirror-selected, .editor-page .CodeMirror-focused .CodeMirror-selected { background: rgba(91,140,255,.22) !important; }
.editor-page .CodeMirror-vscrollbar::-webkit-scrollbar, .editor-page .CodeMirror-hscrollbar::-webkit-scrollbar { width: 8px; height: 8px; }
.editor-page .CodeMirror-vscrollbar::-webkit-scrollbar-thumb, .editor-page .CodeMirror-hscrollbar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 8px; }

/* Status line under the code */
.editor-page .status-bar { height: 28px; background: var(--cf-panel); border-top: 1px solid var(--cf-line); color: var(--cf-mut2); font: 500 11px var(--cf-mono); gap: 14px; padding: 0 14px; }
.editor-page .status-dot { background: var(--ag-ok, #22C55E); }
.editor-page .status-dot.error { background: var(--ag-err, #FF6B5E); }
.editor-page .status-dot.warn { background: var(--ag-warn, #F5B544); }

/* Splitter: a thin line with a grip */
.editor-page .splitter { flex: 0 0 6px; background: var(--cf-bg); border-left: 1px solid var(--cf-line); border-right: 1px solid var(--cf-line); }
.editor-page .splitter::after { content: ''; position: absolute; top: 50%; left: 50%; width: 2px; height: 36px; transform: translate(-50%,-50%); border-radius: 2px; background: rgba(255,255,255,.18); }
.editor-page .workspace.layout-vertical .splitter { border: 0; border-top: 1px solid var(--cf-line); border-bottom: 1px solid var(--cf-line); }
.editor-page .workspace.layout-vertical .splitter::after { width: 36px; height: 2px; }
.editor-page .splitter:hover, .editor-page .splitter.dragging { background: var(--cf-soft); }

/* ---------- Preview column ---------- */
.editor-page .preview-wrap { display: flex; flex-direction: column; background: var(--cf-bg); min-width: 0; }
.cf-ptool {
  flex: 0 0 auto; height: 58px; display: flex; align-items: center; gap: 12px;
  padding: 0 14px; background: var(--cf-bg); border-bottom: 1px solid var(--cf-line);
}
.cf-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--cf-panel); border: 1px solid var(--cf-line); }
.cf-seg button {
  width: 34px; height: 30px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--cf-mut2);
  transition: color .15s, background .15s;
}
.cf-seg button svg { width: 17px; height: 17px; }
.cf-seg button:hover { color: var(--cf-ink); }
.cf-seg button.active { color: var(--cf-ink); background: var(--cf-card); border-color: rgba(91,140,255,.45); box-shadow: 0 0 0 1px rgba(91,140,255,.15); }
.cf-size { font: 500 11.5px var(--cf-mono); color: var(--cf-mut2); padding: 5px 9px; border-radius: 7px; background: var(--cf-panel); border: 1px solid var(--cf-line); white-space: nowrap; }

.cf-stage { flex: 1; min-height: 0; position: relative; overflow: auto; display: flex; justify-content: center; background: #fff; }
.cf-stage .preview-frame { width: 100%; height: 100%; border: 0; background: #fff; }
/* Device widths: framed canvas on the dark stage */
.cf-stage.is-device { background: var(--cf-panel); background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px); background-size: 18px 18px; padding: 18px 0; }
.cf-stage.is-device .preview-frame { flex: 0 0 auto; border-radius: 12px; box-shadow: 0 0 0 1px var(--cf-line2), var(--ag-sh); }

/* Console under the preview */
.editor-page .console { background: var(--cf-panel); border-top: 1px solid var(--cf-line); max-height: 38%; }
.editor-page .console.collapsed { max-height: 40px; }
.editor-page .console-header { height: 40px; padding: 0 10px 0 8px; background: var(--cf-panel); border-bottom: 1px solid var(--cf-line); text-transform: none; letter-spacing: 0; }
.cf-ctabs { display: flex; gap: 4px; align-self: stretch; align-items: center; }
.cf-ctabs button {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 7px;
  background: none; border: 0; cursor: pointer; font: 600 13px var(--ag-font); color: var(--cf-mut);
}
.cf-ctabs button:hover { color: var(--cf-ink); }
.cf-ctabs button.on { color: var(--cf-ink); background: var(--cf-card); }
.cf-cright { display: flex; align-items: center; gap: 6px; color: var(--cf-mut2); }
.editor-page .console-count { background: var(--cf-soft); color: var(--ag-a2, #7DA3FF); }
.editor-page .console-body.only-errors .console-line:not(.error) { display: none; }
.editor-page .console-body:empty::before { content: 'Console output from your preview shows up here.'; display: block; padding: 12px 14px; color: var(--cf-mut2); font-family: var(--ag-font); font-size: 12.5px; }

/* Sidebar sits under the 56px bar */
.editor-page .editor-sidebar { top: var(--cf-top); background: var(--cf-panel); border-left: 1px solid var(--cf-line2); box-shadow: var(--ag-sh3); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .cf-crumbs .cf-pill-plain, .cf-chip { display: none; }
}
@media (max-width: 920px) {
  .cf-top { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .cf-sep, .cf-bname { display: none; }
  .cf-title { order: 5; flex: 1 1 100%; width: auto; }
  .cf-actions { gap: 6px; }
  .cf-btn > span { display: none; }
  .cf-btn { padding: 0 10px; }
  body.editor-page { --cf-top: 100px; }
}
/* <=1024px: editor.css already stacks code above preview here; size the stack */
@media (max-width: 1024px) {
  .editor-page > .workspace { height: auto; min-height: 0; flex-direction: column !important; overflow: visible; }
  .editor-page .workspace .panes { width: 100% !important; height: 60vh !important; display: flex !important; }
  .editor-page .workspace .panes .pane.on { flex: 1 1 auto; min-height: 0; }
  .editor-page .workspace .panes .pane .pane-body,
  .editor-page .workspace .panes .pane .CodeMirror { min-height: 0; }
  .editor-page .workspace .preview-wrap { height: 72vh; min-height: 0; flex: 0 0 auto; }
  .cf-tabs { overflow-x: auto; scrollbar-width: none; }
  .cf-tabs::-webkit-scrollbar { display: none; }
  .cf-tab { padding: 0 12px; flex: 0 0 auto; }
}
@media (max-width: 760px) {
  .cf-tablink#btnTidy { display: none; }
  .editor-page .splitter { display: none !important; }
  .cf-seg [data-device="1280"], #layoutV { display: none; }
  .cf-actions #btnReset { display: none; }
  .editor-page .editor-sidebar { width: 100%; }
}
