

:root {
  --ide-top: 52px;
  --ide-status: 28px;

  
  --tree-w: 252px;
  --ai-w: 340px;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  
  --code-size: 13.5px;
  --code-line: 21px;
  --code-pad-y: 14px;
  --code-pad-x: 16px;
  --gutter-w: 56px;

  
  --code-bg: #fbfbf9;
  --code-line-bg: rgba(47, 111, 237, .055);
  --sel-bg: rgba(47, 111, 237, .20);

  
  --tok-kw: #8250df;
  --tok-str: #0a7a52;
  --tok-num: #b45309;
  --tok-com: #8b9098;
  --tok-fn: #1f6feb;
  --tok-type: #0f766e;
  --tok-op: #6b7280;

  --diff-add-bg: rgba(47, 158, 95, .12);
  --diff-add-word: rgba(47, 158, 95, .26);
  --diff-add-mark: #2f9e5f;
  --diff-del-bg: rgba(214, 69, 69, .10);
  --diff-del-word: rgba(214, 69, 69, .24);
  --diff-del-mark: #d64545;

  --warn: #c9860f;
  --warn-soft: rgba(217, 162, 39, .14);
  --danger-soft: rgba(214, 69, 69, .12);
  --ok-soft: rgba(47, 158, 95, .14);
}

html[data-theme="dark"] {
  --code-bg: #0f1319;
  --code-line-bg: rgba(120, 160, 255, .06);
  --sel-bg: rgba(59, 130, 246, .30);

  --tok-kw: #b48ce6;
  --tok-str: #86cfa2;
  --tok-num: #e0a06a;
  --tok-com: #6e7681;
  --tok-fn: #79b8ff;
  --tok-type: #5cc6bb;
  --tok-op: #98a1ad;

  --diff-add-bg: rgba(78, 194, 127, .15);
  --diff-add-word: rgba(78, 194, 127, .30);
  --diff-add-mark: #4ec27f;
  --diff-del-bg: rgba(240, 113, 113, .15);
  --diff-del-word: rgba(240, 113, 113, .30);
  --diff-del-mark: #f07171;

  --warn: #d9a227;
  --warn-soft: rgba(217, 162, 39, .16);
  --danger-soft: rgba(240, 113, 113, .15);
  --ok-soft: rgba(78, 194, 127, .15);
}


html[data-incognito="true"] {
  --code-bg: #212125;
  --code-line-bg: rgba(255, 255, 255, .05);
  --sel-bg: rgba(255, 255, 255, .17);
}



.code-body {
  height: 100vh;
  overflow: hidden;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

.ide {
  display: grid;
  grid-template-rows: var(--ide-top) minmax(0, 1fr) var(--ide-status);
  height: 100vh;
}

.ide-main {
  display: grid;
  grid-template-columns: var(--tree-w) minmax(0, 1fr) var(--ai-w);
  min-height: 0;
}


.ide-tree   { grid-column: 1; }
.ide-editor { grid-column: 2; }
.ide-ai     { grid-column: 3; }


.ide[data-tree="off"] .ide-main { --tree-w: 0px; }
.ide[data-ai="off"]   .ide-main { --ai-w: 0px; }
.ide[data-tree="off"] .ide-tree,
.ide[data-ai="off"] .ide-ai { display: none; }

.ide-spacer { flex: 1 1 auto; min-width: 0; }


.ide[data-busy="1"] { cursor: progress; }



.ide-top {
  display: flex;
  gap: 7px;
  align-items: center;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 6;
}

.ide-logo {
  margin-right: 2px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.3px;
  color: var(--text);
  text-decoration: none;
  flex: none;
}

.ide-logo:hover { color: var(--accent); }

.tree-toggle { width: 30px; height: 30px; border-radius: 9px; }
.ide[data-tree="off"] .tree-toggle { color: var(--text); background: var(--accent-soft); }


.file-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 300px;
  height: 30px;
  padding: 0 11px;
  margin-right: 4px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text-dim);
  flex: 0 1 auto;
}

.file-chip .fc-ico { flex: none; opacity: .7; }

.fc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
}

.file-chip.empty .fc-name { font-family: var(--font); color: var(--text-dim); }

.dirty-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-in .2s ease;
}



.ide-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 11px;
  flex: none;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .16s, border-color .16s, color .16s, filter .16s, opacity .16s;
}

.ide-btn:hover:not(:disabled) { filter: brightness(1.07); }
.ide-btn:active:not(:disabled) { transform: translateY(.5px); }
.ide-btn:disabled { opacity: .42; cursor: default; }

.ide-btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  font-weight: 500;
}

.ide-btn.ghost:hover:not(:disabled) { background: var(--accent-soft); filter: none; }
.ide-btn.ghost.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.ide-btn.primary { background: var(--accent); color: #fff; border-color: transparent; }

.ide-btn.danger { background: var(--danger); color: #fff; border-color: transparent; }

.ide-btn svg { flex: none; }

.ide-btn kbd,
.welcome kbd,
.kbar kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
}

.ide-btn:not(.ghost) kbd {
  border-color: rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .16);
  color: #fff;
}


.topbar-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
  pointer-events: none;
}

.topbar-progress i {
  display: block;
  height: 100%;
  width: 34%;
  border-radius: 2px;
  background: var(--accent);
  animation: bar-slide 1.15s ease-in-out infinite;
}

#themeBtn { width: 30px; height: 30px; border-radius: 9px; }
#themeBtn:hover { background: var(--accent-soft); color: var(--text); }
#themeBtn .icon-moon { display: none; }
html[data-theme="dark"] #themeBtn .icon-sun { display: none; }
html[data-theme="dark"] #themeBtn .icon-moon { display: block; }



.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  flex: none;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background .16s, color .16s;
}

.mini-btn:hover { background: var(--accent-soft); color: var(--text); }
.mini-btn:disabled { opacity: .4; cursor: default; background: transparent; }
.mini-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.mini-btn.stop {
  padding: 0 9px;
  border: 1px solid var(--border);
  color: var(--danger);
}

.mini-btn.stop:hover { background: var(--danger-soft); color: var(--danger); }



.ide-tree {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.tree-head {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 9px 8px 7px 14px;
  flex: none;
}

.tree-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .7px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.tree-filter {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 10px 8px;
  padding: 0 9px;
  height: 28px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-dim);
  transition: border-color .16s, box-shadow .16s;
}

.tree-filter:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tree-filter svg { flex: none; }

.tree-filter-in {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.tree-filter-in::-webkit-search-cancel-button { -webkit-appearance: none; }

.tree-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 6px 10px;
}

.tree-empty {
  padding: 22px 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
  text-align: center;
}


.tree-children.hide { display: none; }


.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 27px;
  padding-right: 4px;
  padding-left: calc(6px + var(--d, var(--depth, 0)) * 13px);
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  user-select: none;
  transition: background .13s, color .13s;
}

.tree-row:hover { background: var(--accent-soft); }
.tree-row.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.tree-row.dragover { box-shadow: inset 0 0 0 1.5px var(--accent); }


.tree-row .tw {
  width: 12px;
  flex: none;
  color: var(--text-dim);
  font-size: 9px;
  line-height: 1;
  text-align: center;
  transition: transform .16s ease;
}

.tree-row.open > .tw { transform: rotate(90deg); }
.tree-row:not(.dir) > .tw { visibility: hidden; }

.tree-row .ic,
.tree-row .tree-ico { flex: none; opacity: .75; display: flex; }

.tree-row.dir .ic,
.tree-row.dir .tree-ico { color: var(--accent); opacity: .85; }

.tree-row .nm,
.tree-row .tree-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-row.dir .nm,
.tree-row.dir .tree-name { font-weight: 550; }


.tree-row .hit { background: var(--warn-soft); border-radius: 3px; }

.tree-row .tree-size {
  flex: none;
  font-size: 11px;
  color: var(--text-dim);
  opacity: .7;
  font-variant-numeric: tabular-nums;
}


.tree-row .del,
.tree-row .tree-del {
  flex: none;
  width: 20px;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.tree-row:hover .del,
.tree-row:hover .tree-del,
.tree-row.active .del,
.tree-row.active .tree-del { display: flex; }

.tree-row .del:hover,
.tree-row .tree-del:hover { background: var(--danger-soft); color: var(--danger); }

.tree-row:hover .tree-size { display: none; }

.tree-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  flex: none;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-dim);
}

.tree-root {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 11px;
}



.resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  right: -3px;
  width: 6px;
  z-index: 4;
  cursor: col-resize;
  background: transparent;
}

.resizer.left { right: auto; left: -3px; }

.resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--accent);
  opacity: 0;
  transition: opacity .16s;
}

.resizer:hover::after,
.resizer.dragging::after { opacity: .75; }


body.resizing { cursor: col-resize; user-select: none; }
body.resizing * { cursor: col-resize !important; }



.ide-editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--code-bg);
}

.tabs {
  display: flex;
  align-items: stretch;
  gap: 1px;
  height: 36px;
  flex: none;
  padding: 0 6px;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { height: 0; }
.tabs:empty { display: none; }


.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 220px;
  padding: 0 8px 0 11px;
  flex: none;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12.5px;
  cursor: pointer;
  transition: background .14s, color .14s, border-color .14s;
}

.tab:hover { background: var(--bg); color: var(--text); }

.tab.active {
  background: var(--code-bg);
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab .tab-ico { flex: none; opacity: .65; display: flex; }

.tab .nm,
.tab .tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.tab.dirty::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
}


.tab .tab-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
}

.tab .x,
.tab .tab-x {
  width: 18px;
  height: 18px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .14s, background .14s;
}

.tab:hover .x,
.tab:hover .tab-x,
.tab.active .x,
.tab.active .tab-x { opacity: 1; }

.tab .x:hover,
.tab .tab-x:hover { background: var(--danger-soft); color: var(--danger); }



.editor-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.editor-area {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--code-bg);
  overflow: hidden;
}


.code-input,
.code-hl,
.code-hl code,
.gutter-inner .ln {
  font-family: var(--mono);
  font-size: var(--code-size);
  line-height: var(--code-line);
  letter-spacing: 0;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  tab-size: 4;
  -moz-tab-size: 4;
}



.code-gutter {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--gutter-w);
  z-index: 2;
  overflow: hidden;
  background: var(--code-bg);
  border-right: 1px solid var(--border);
  user-select: none;
  pointer-events: none;
}


.gutter-inner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: var(--code-pad-y) 10px var(--code-pad-y) 0;
  will-change: transform;
}

.gutter-inner .ln {
  height: var(--code-line);
  text-align: right;
  color: var(--text-dim);
  opacity: .5;
  font-variant-numeric: tabular-nums;
}

.gutter-inner .ln.cur { opacity: 1; color: var(--text); }
.gutter-inner .ln.changed { color: var(--accent); opacity: .9; }



.code-layer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--gutter-w);
  right: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}


.code-shift {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 100%;
  width: max-content;
  will-change: transform;
}

.code-hl {
  margin: 0;
  padding: var(--code-pad-y) var(--code-pad-x);
  white-space: pre;
  color: var(--text);
  background: transparent;
  border: none;
}

.code-hl code {
  display: block;
  white-space: pre;
  font: inherit;
  color: inherit;
  background: none;
  padding: 0;
  border: none;
}


.active-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: var(--code-line);
  background: var(--code-line-bg);
  pointer-events: none;
}



.code-input {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--gutter-w);
  right: 0;
  z-index: 3;
  display: block;
  width: auto;
  padding: var(--code-pad-y) var(--code-pad-x);
  margin: 0;
  border: none;
  outline: none;
  resize: none;
  overflow: auto;
  white-space: pre;
  overflow-wrap: normal;
  background: transparent;
  
  color: transparent;
  caret-color: var(--text);
}

.code-input::selection { background: var(--sel-bg); color: transparent; }
.code-input::-moz-selection { background: var(--sel-bg); color: transparent; }

.code-input::placeholder { color: var(--text-dim); }


.editor-area.readonly .code-input { caret-color: transparent; }
.editor-area.readonly .code-hl { opacity: .6; }



.tok-kw   { color: var(--tok-kw); font-weight: 550; }
.tok-str  { color: var(--tok-str); }
.tok-num  { color: var(--tok-num); }
.tok-com  { color: var(--tok-com); font-style: italic; }
.tok-fn   { color: var(--tok-fn); }
.tok-type { color: var(--tok-type); }
.tok-op   { color: var(--tok-op); }


.tok-tag  { color: var(--tok-kw); }
.tok-attr { color: var(--tok-fn); }
.tok-key  { color: var(--tok-fn); }
.tok-esc  { color: var(--tok-num); font-weight: 550; }


.tok-find { background: var(--warn-soft); border-radius: 2px; box-shadow: 0 0 0 1px var(--warn); }
.tok-find.cur { background: var(--warn); color: #fff; }




.kbar {
  position: absolute;
  z-index: 8;
  width: min(560px, calc(100% - 32px));
  padding: 10px 11px 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: kbar-in .16s ease;
}

.kbar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.kbar-badge {
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
}

.kbar-lines {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
}

.kbar-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.kbar-in {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}

.kbar-in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kbar-in::placeholder { color: var(--text-dim); }

.kbar-go {
  height: 34px;
  padding: 0 15px;
  flex: none;
  border: none;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .16s, opacity .16s;
}

.kbar-go:hover:not(:disabled) { filter: brightness(1.07); }
.kbar-go:disabled { opacity: .45; cursor: default; }

.kbar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.kbar-status { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); }



.problems {
  flex: none;
  max-height: 38%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  animation: panel-up .18s ease;
}

.problems-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 14px;
  flex: none;
  border-bottom: 1px solid var(--border);
}

.problems-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .7px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.problems-count {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.problems-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px 0 8px;
}


.problem-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
  width: 100%;
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: background .13s;
}

.problem-row:hover { background: var(--accent-soft); }

.problem-row .problem-ico { flex: none; font-size: 12px; line-height: 1.35; }
.problem-row.is-err  .problem-ico { color: var(--danger); }
.problem-row.is-warn .problem-ico { color: var(--warn); }
.problem-row.is-ok   .problem-ico { color: var(--ok); }

.problem-row .problem-pos {
  flex: none;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.problem-row .problem-text { flex: 1; min-width: 0; }

.problems-empty {
  padding: 18px 14px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}



.welcome {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 30px;
  overflow: auto;
  text-align: center;
  background: var(--code-bg);
}

.welcome-art { color: var(--accent); opacity: .55; }

.welcome h2 { font-size: 22px; font-weight: 650; letter-spacing: -.3px; }

.welcome-lead { font-size: 14.5px; color: var(--text-dim); }

.welcome-steps {
  max-width: 480px;
  margin: 2px 0 6px;
  padding-left: 20px;
  text-align: left;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

.welcome-steps li { margin: 5px 0; }
.welcome-steps li::marker { color: var(--text-dim); }
.welcome-steps b { font-weight: 600; }

.welcome-cta {
  height: 36px;
  padding: 0 18px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .16s;
}

.welcome-cta:hover { filter: brightness(1.07); }

.welcome-keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-dim);
}

.welcome-keys span { display: inline-flex; align-items: center; gap: 6px; }



.ide-ai {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.ai-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  flex: none;
  border-bottom: 1px solid var(--border);
}

.ai-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .7px;
  text-transform: uppercase;
  color: var(--text-dim);
}


.ai-modes {
  flex: none;
  padding: 8px 12px 0;
  min-width: 0;
}

.seg {
  display: flex;
  width: 100%;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }

.seg-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 24px;
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background .16s, color .16s;
}

.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }


.ai-ctx {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  flex: none;
  border-bottom: 1px solid var(--border);
}

.ai-ctx:empty { display: none; }

.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  font-size: 11.5px;
  color: var(--text-dim);
}

.ai-chip .nm {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  color: var(--text);
}

.ai-chip.sel { background: var(--accent-soft); border-color: transparent; }
.ai-chip.sel .nm { color: var(--accent); }

.chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex: none;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: .6;
}

.chip-x:hover { opacity: 1; background: var(--danger-soft); color: var(--danger); }



.ai-msgs {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-empty {
  margin: auto 0;
  text-align: center;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
}

.ai-samples {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.ai-sample {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background .16s, border-color .16s;
}

.ai-sample:hover { background: var(--accent-soft); border-color: var(--accent); }


.ai-msg {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 100%;
  animation: msg-in .18s ease;
}

.ai-msg .ai-msg-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.ai-msg .ai-body {
  font-size: 13.5px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.ai-msg.me .ai-body {
  padding: 9px 12px;
  border-radius: 12px 12px 4px 12px;
  background: var(--accent-soft);
  color: var(--text);
  align-self: flex-end;
  max-width: 92%;
}

.ai-msg.me .ai-msg-head { justify-content: flex-end; }

.ai-msg.ai .ai-body { color: var(--text); }


.ai-msg .ai-quote {
  padding: 6px 9px;
  border-left: 2px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-dim);
  white-space: pre;
  overflow-x: auto;
  max-height: 96px;
}

.ai-msg .ai-err {
  padding: 8px 11px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
}


.ai-msgs .code-wrap { margin: 8px 0; border-radius: 10px; }
.ai-msgs .code-wrap pre { max-height: 320px; overflow: auto; }
.ai-msgs .code-wrap code { font-family: var(--mono); font-size: 12px; line-height: 1.55; }
.ai-msgs .md table { font-size: 12.5px; }
.ai-msgs .md h2 { font-size: 17px; }
.ai-msgs .md h3 { font-size: 15px; }
.ai-msgs .md h4 { font-size: 14px; }


.ai-code-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.ai-apply,
.ai-copy {
  height: 26px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
  transition: background .16s, border-color .16s, color .16s;
}

.ai-apply { background: var(--accent); border-color: transparent; color: #fff; }
.ai-apply:hover { filter: brightness(1.07); }
.ai-copy:hover { background: var(--accent-soft); border-color: var(--accent); }


.ai-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.ai-typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: typing 1.05s ease-in-out infinite;
}

.ai-typing i:nth-child(2) { animation-delay: .16s; }
.ai-typing i:nth-child(3) { animation-delay: .32s; }



.ai-compose {
  flex: none;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.ai-in {
  width: 100%;
  max-height: 168px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  resize: none;
  outline: none;
  overflow-y: auto;
  transition: border-color .16s, box-shadow .16s;
}

.ai-in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ai-in::placeholder { color: var(--text-dim); }

.ai-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
}

.ai-note {
  font-size: 11.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-send {
  width: 30px;
  height: 30px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: filter .16s, opacity .16s;
}

.ai-send:hover:not(:disabled) { filter: brightness(1.07); }
.ai-send:disabled { opacity: .4; cursor: default; }



.ide-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-dim);
  user-select: none;
}

.st { white-space: nowrap; font-variant-numeric: tabular-nums; }

.st-path {
  font-family: var(--mono);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}

.st-sep {
  width: 1px;
  height: 12px;
  flex: none;
  background: var(--border);
}

.st-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.st-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  transition: background .2s;
}

.st-save.is-dirty  .st-dot { background: var(--warn); }
.st-save.is-saving .st-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.st-save.is-error  .st-dot { background: var(--danger); }
.st-save.is-error  { color: var(--danger); }



.diff-card {
  max-width: min(1280px, 96vw);
  height: min(84vh, 900px);
}

.diff-head-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.diff-stat {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.diff-stat .plus { color: var(--diff-add-mark); }
.diff-stat .minus { color: var(--diff-del-mark); }

.diff-cols {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}

.diff-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--code-bg);
}

.diff-col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  flex: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.diff-col-head .tag {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 650;
}

.diff-col-head .tag.del { background: var(--diff-del-bg); color: var(--diff-del-mark); }
.diff-col-head .tag.add { background: var(--diff-add-bg); color: var(--diff-add-mark); }

.diff-file {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diff-pane {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 0 16px;
}


.diff-line {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: start;
  min-height: var(--code-line);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: var(--code-line);
}

.diff-ln {
  padding-right: 10px;
  text-align: right;
  color: var(--text-dim);
  opacity: .55;
  user-select: none;
  font-variant-numeric: tabular-nums;
}

.diff-txt {
  padding: 0 14px 0 8px;
  white-space: pre;
  overflow-x: hidden;
  color: var(--text);
}

.diff-ctx { background: transparent; }

.diff-add {
  background: var(--diff-add-bg);
  box-shadow: inset 3px 0 0 var(--diff-add-mark);
}

.diff-del {
  background: var(--diff-del-bg);
  box-shadow: inset 3px 0 0 var(--diff-del-mark);
}

.diff-pad {
  background: repeating-linear-gradient(
    135deg,
    transparent 0 6px,
    var(--border) 6px 7px
  );
  opacity: .35;
}

.diff-pad .diff-ln,
.diff-pad .diff-txt { visibility: hidden; }


.diff-add .diff-word { background: var(--diff-add-word); border-radius: 3px; }
.diff-del .diff-word { background: var(--diff-del-word); border-radius: 3px; }


.diff-skip {
  padding: 4px 14px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

.diff-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.diff-hint { font-size: 12.5px; color: var(--text-dim); }

.diff-empty {
  padding: 40px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}



.small-card { max-width: 440px; }

.small-body {
  padding: 18px 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.small-body .field.mono { font-family: var(--mono); font-size: 13.5px; }

.small-hint { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }

.small-hint code {
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.small-err {
  font-size: 12.5px;
  color: var(--danger);
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--danger-soft);
}

.small-text { font-size: 14px; line-height: 1.55; }

.small-text b { font-family: var(--mono); font-weight: 600; }

.small-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 22px 18px;
}

.small-foot .ide-btn { height: 34px; padding: 0 15px; font-size: 13.5px; }



.ctx-menu {
  position: fixed;
  z-index: 90;
  min-width: 196px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  box-shadow: var(--shadow-lg);
  animation: ctx-in .12s ease;
}

.ctx-item {
  display: block;
  width: 100%;
  padding: 7px 11px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background .13s, color .13s;
}

.ctx-item:hover { background: var(--accent-soft); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: var(--danger-soft); }
.ctx-item:disabled { opacity: .4; cursor: default; background: transparent; }

.ctx-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}




.spin {
  width: 11px;
  height: 11px;
  flex: none;
  border: 1.6px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: spin .7s linear infinite;
}

.toast.err { border-color: var(--danger); color: var(--danger); }
.toast.ok { border-color: var(--ok); }


.tree-body,
.problems-body,
.ai-msgs,
.diff-pane,
.code-input,
.tabs { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

.tree-body::-webkit-scrollbar,
.problems-body::-webkit-scrollbar,
.ai-msgs::-webkit-scrollbar,
.diff-pane::-webkit-scrollbar,
.code-input::-webkit-scrollbar { width: 10px; height: 10px; }

.tree-body::-webkit-scrollbar-thumb,
.problems-body::-webkit-scrollbar-thumb,
.ai-msgs::-webkit-scrollbar-thumb,
.diff-pane::-webkit-scrollbar-thumb,
.code-input::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 6px;
}

.tree-body::-webkit-scrollbar-thumb:hover,
.ai-msgs::-webkit-scrollbar-thumb:hover,
.diff-pane::-webkit-scrollbar-thumb:hover,
.code-input::-webkit-scrollbar-thumb:hover { background: var(--text-dim); background-clip: content-box; }


.code-body :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 7px;
}

.code-input:focus-visible { outline: none; }



@keyframes spin { to { transform: rotate(360deg); } }

@keyframes pulse { 50% { opacity: .35; } }

@keyframes dot-in { from { transform: scale(0); } }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-3px); opacity: 1; }
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(5px); }
}

@keyframes kbar-in {
  from { opacity: 0; transform: translateY(-5px); }
}

@keyframes panel-up {
  from { opacity: 0; transform: translateY(8px); }
}

@keyframes ctx-in {
  from { opacity: 0; transform: scale(.97); }
}

@keyframes bar-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(390%); }
}

@keyframes slide-right { from { transform: translateX(14px); opacity: 0; } }

@keyframes slide-left { from { transform: translateX(-14px); opacity: 0; } }




@media (max-width: 1180px) {
  .ide-main { --ai-w: 0px; }

  .ide-ai {
    position: fixed;
    top: var(--ide-top);
    right: 0;
    bottom: var(--ide-status);
    z-index: 20;
    width: min(400px, 92vw);
    box-shadow: var(--shadow-lg);
    animation: slide-right .18s ease;
  }

  .ide[data-ai="auto"] .ide-ai,
  .ide[data-ai="off"] .ide-ai { display: none; }
  #aiResizer { display: none; }
}

@media (max-width: 900px) {
  .ide-main { --tree-w: 0px; }

  .ide-tree {
    position: fixed;
    top: var(--ide-top);
    left: 0;
    bottom: var(--ide-status);
    z-index: 21;
    width: min(300px, 88vw);
    box-shadow: var(--shadow-lg);
    animation: slide-left .18s ease;
  }

  .ide[data-tree="auto"] .ide-tree,
  .ide[data-tree="off"] .ide-tree { display: none; }

  #treeResizer { display: none; }

  
  .ide-btn .btn-label,
  .ide-btn kbd { display: none; }
  .ide-btn { padding: 0 9px; }
  .ide-btn.primary { padding: 0 11px; }
  .file-chip { max-width: 160px; }

  .diff-cols { grid-template-columns: 1fr; grid-auto-rows: minmax(0, 1fr); }
}



@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}




.m-only { display: none; }
.ide-scrim { display: none; }
.diff-uni { display: none; }


.ide { grid-template-columns: minmax(0, 1fr); }
.ide > * { min-width: 0; }
.fc-name { min-width: 0; }



@media (min-width: 769px) and (max-width: 1100px) and (pointer: coarse) {
  .tree-row { height: 36px; font-size: 13.5px; }
  .tab { min-height: 40px; }
  .tabs { height: 40px; }
  .tab .x,
  .tab .tab-x { opacity: 1; width: 26px; height: 26px; }
  .tree-row .del,
  .tree-row .tree-del { display: flex; }
  .tree-row .tree-size { display: none; }
  .mini-btn { min-width: 34px; height: 34px; }
  .ide-btn { height: 38px; }
  .tree-toggle, #themeBtn { width: 38px; height: 38px; }
  .resizer { display: none; }   
}



@media (max-width: 768px) {

  
  :root {
    --code-size: 16px;
    --code-line: 24px;
    --code-pad-y: 10px;
    --code-pad-x: 10px;
    --gutter-w: 36px;
    --ide-top: 54px;      
  }

  
  .gutter-inner .ln { font-size: 11px; }
  .gutter-inner { padding: var(--code-pad-y) 6px var(--code-pad-y) 0; }

  
  .code-body {
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .ide {
    --top-h: calc(var(--ide-top) + env(safe-area-inset-top, 0px));
    --ide-status: 0px;
    height: var(--vvh, 100dvh);
    grid-template-rows: var(--top-h) minmax(0, 1fr) auto;
  }

  
  .ide-status { display: none; }

  

  .ide-top {
    gap: 3px;
    padding: 0 6px;
    padding-top: env(safe-area-inset-top, 0px);
    height: var(--top-h);
  }

  
  .ide-logo,
  #saveBtn,
  #docsLink,
  #chatLink { display: none; }

  .tree-toggle,
  #themeBtn,
  .ide-top .ide-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
    justify-content: center;
  }

  .ide-top .ide-btn svg { width: 19px; height: 19px; }
  .tree-toggle svg,
  #themeBtn svg { width: 21px; height: 21px; }

  .file-chip {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    height: 40px;
    margin-right: 0;
    padding: 0 10px;
  }

  .fc-name { font-size: 13.5px; }

  

  .tabs { height: 44px; padding: 0 4px; }

  .tab {
    min-height: 44px;
    max-width: 190px;
    padding: 0 4px 0 10px;
    font-size: 13px;
  }

  
  .tab .x,
  .tab .tab-x {
    opacity: 1;
    width: 32px;
    height: 32px;
    position: relative;
    font-size: 13px;
  }

  
  .tab .x::after,
  .tab .tab-x::after { content: ""; position: absolute; inset: -6px; }

  

  
  .code-input {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .editor-stage { overflow: hidden; }

  .welcome { padding: 22px 18px 30px; gap: 12px; }
  .welcome h2 { font-size: 20px; }
  .welcome-lead { font-size: 14px; }
  .welcome-steps { font-size: 14px; }
  .welcome-keys { display: none; }        
  .welcome-cta { min-height: 48px; font-size: 15px; }

  .welcome-touch {
    display: block;
    max-width: 34ch;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-dim);
  }

  .welcome-touch b { color: var(--text); font-weight: 650; }

  

  
  .ide-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, .45);
    -webkit-tap-highlight-color: transparent;
    animation: scrim-in .18s ease;
  }

  
  .ide-scrim[hidden] { display: none; }

  

  
  .ide-tree {
    top: var(--top-h);
    bottom: 0;
    
    z-index: 31;
    width: min(320px, 86vw);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    touch-action: pan-y;
    will-change: transform;
  }

  .tree-head { padding: 6px 6px 6px 14px; gap: 1px; }
  .tree-title { font-size: 11.5px; }

  .tree-filter { height: 44px; margin: 0 10px 8px; border-radius: 11px; }

  
  .tree-filter-in { font-size: 16px; }

  .tree-body { padding: 0 8px 12px; overscroll-behavior: contain; }

  .tree-row {
    height: 48px;
    font-size: 15px;
    gap: 9px;
    border-radius: 10px;
    padding-left: calc(8px + var(--d, var(--depth, 0)) * 15px);
  }

  .tree-row .tw { width: 20px; }

  
  .tree-row .tree-size { display: none; }

  
  .tree-row .del,
  .tree-row .tree-del {
    width: 36px;
    height: 36px;
    position: relative;
    font-size: 15px;
  }

  .tree-row .del::after,
  .tree-row .tree-del::after { content: ""; position: absolute; inset: -6px; }

  
  .tree-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: none;
    padding: 8px 8px 4px;
    border-top: 1px solid var(--border);
  }

  .drawer-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 12px;
    border-radius: 10px;
    color: var(--text);
    font-size: 14.5px;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }

  .drawer-link svg { flex: none; color: var(--text-dim); }
  .drawer-link:active { background: var(--accent-soft); color: var(--accent); }
  .drawer-link:active svg { color: var(--accent); }

  .tree-foot { padding-bottom: 10px; }

  
  .ide-ai {
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    width: auto;
    height: var(--vvh, 100dvh);
    z-index: 60;
    border-left: none;
    box-shadow: none;
    padding-top: env(safe-area-inset-top, 0px);
    touch-action: pan-y;
    will-change: transform;
    animation: sheet-up .2s ease;
  }

  
  .ai-head { padding: 8px 6px 8px 12px; gap: 3px; min-height: 52px; }

  .ai-title {
    min-width: 0;
    font-size: 14px;   
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  
  .seg { flex: none; padding: 3px; border-radius: 11px; }
  .seg-btn { min-height: 38px; padding: 0 8px; font-size: 12.5px; }

  .ai-msgs { padding: 12px 14px; overscroll-behavior: contain; }
  .ai-msg .ai-body { font-size: 15px; line-height: 1.6; }
  .ai-msgs .code-wrap code { font-size: 13px; }
  .ai-msgs .code-wrap pre { max-height: none; }

  .ai-sample { min-height: 44px; padding: 10px 14px; font-size: 14px; }

  .ai-apply,
  .ai-copy { min-height: 44px; padding: 0 16px; font-size: 14px; }

  
  .ai-compose {
    padding: 10px 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }

  .ai-in { font-size: 16px; padding: 11px 13px; border-radius: 13px; }
  .ai-actions { gap: 9px; margin-top: 9px; }
  .ai-send { width: 44px; height: 44px; border-radius: 13px; }
  .ai-send svg { width: 19px; height: 19px; }

  .ai-ctx { padding: 8px 14px; }
  .ai-chip { height: 32px; font-size: 12.5px; }

  
  .chip-x { width: 22px; height: 22px; position: relative; }
  .chip-x::after { content: ""; position: absolute; inset: -11px; }

  

  .m-dock {
    display: flex;
    grid-row: 3;
    align-items: stretch;
    gap: 3px;
    padding: 5px 5px;
    padding-bottom: calc(5px + env(safe-area-inset-bottom, 0px));
    flex: none;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 22;
  }

  .dock-btn {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 2px;
    position: relative;
    border: none;
    border-radius: 11px;
    background: transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .1px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .14s, color .14s, opacity .14s;
  }

  .dock-btn .dk-ico { display: flex; }

  .dock-btn .dk-lbl {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dock-btn:active { background: var(--accent-soft); color: var(--accent); }
  .dock-btn:disabled { opacity: .35; }
  .dock-btn.accent { color: var(--accent); }

  
  .dock-btn.dirty::after {
    content: "";
    position: absolute;
    top: 6px;
    right: calc(50% - 17px);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
  }

  
  .kbar {
    width: auto;
    right: 8px;
    padding: 9px 10px;
    border-radius: 14px;
  }

  .kbar-row { gap: 6px; }
  .kbar-in { min-height: 44px; font-size: 16px; border-radius: 11px; }
  .kbar-go { min-height: 44px; padding: 0 15px; font-size: 14px; border-radius: 11px; }
  .kbar-head { margin-bottom: 7px; }
  .kbar-foot { font-size: 11px; }

  
  .kbar-hint { display: none; }

  

  .problems { max-height: 42dvh; }
  .problem-row { min-height: 44px; align-items: center; font-size: 13.5px; }
  .problems-head { min-height: 44px; }

  

  
  .mini-btn {
    min-width: 44px;
    height: 44px;
    border-radius: 11px;
  }

  .mini-btn.stop { padding: 0 14px; font-size: 13.5px; }

  
  .drawer-x {
    display: inline-flex;
    color: var(--text);
  }

  

  
  .modal { padding: 0; align-items: flex-end; }

  .modal-card {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    animation: sheet-up .2s ease;
  }

  .modal-head { padding: 14px 10px 12px 18px; }
  .modal-head h2 { font-size: 16px; }

  .small-body { padding: 16px 16px 12px; }
  .small-body .field { font-size: 16px; }         
  .small-body .field.mono { font-size: 16px; }
  .small-text { font-size: 15px; }

  .small-foot {
    gap: 8px;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .small-foot .ide-btn {
    flex: 1 1 0;
    height: 48px;
    justify-content: center;
    font-size: 15px;
    border-radius: 13px;
  }

  

  
  .diff-card {
    height: var(--vvh, 100dvh);
    max-height: none;
    max-width: none;
    border-radius: 0;
  }

  .diff-head-right { gap: 6px; }
  .diff-file { display: none; }

  
  .diff-cols { display: none; }

  .diff-uni {
    display: block;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: var(--code-bg);
    padding: 6px 0 14px;
  }

  
  .diff-row {
    display: grid;
    grid-template-columns: 18px 34px minmax(0, 1fr);
    align-items: start;
    min-height: 22px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 22px;
  }

  .diff-row .du-sign {
    text-align: center;
    font-weight: 700;
    user-select: none;
    opacity: .85;
  }

  .diff-row .du-ln {
    padding-right: 7px;
    text-align: right;
    font-size: 10.5px;
    color: var(--text-dim);
    opacity: .6;
    user-select: none;
    font-variant-numeric: tabular-nums;
  }

  .diff-row .du-txt {
    padding-right: 10px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--text);
  }

  .diff-row.diff-add .du-sign { color: var(--diff-add-mark); }
  .diff-row.diff-del .du-sign { color: var(--diff-del-mark); }

  .diff-row.diff-skip-row {
    background: var(--bg);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 11px;
    margin: 4px 0;
  }

  .diff-row.diff-skip-row .du-txt { color: var(--text-dim); white-space: normal; }

  
  .diff-foot {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .diff-hint {
    flex: 1 1 100%;
    order: -1;
    font-size: 12px;
    line-height: 1.4;
  }

  
  .diff-foot .ide-spacer { display: none; }

  .diff-foot .ide-btn {
    flex: 1 1 0;
    height: 52px;
    justify-content: center;
    font-size: 15.5px;
    font-weight: 600;
    border-radius: 13px;
  }

  
  .ctx-menu {
    position: fixed !important;
    top: auto !important;
    left: 10px !important;
    right: 10px !important;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
    width: auto;
    min-width: 0;
    border-radius: 16px;
    padding: 6px;
  }

  .ctx-item {
    min-height: 48px;
    padding: 0 16px;
    border-radius: 11px;
    font-size: 15px;
  }

  

  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    max-width: none;
    transform: none;
    text-align: center;
  }

  
  .resizer { display: none; }

  
  .tree-body::-webkit-scrollbar,
  .ai-msgs::-webkit-scrollbar,
  .diff-uni::-webkit-scrollbar { width: 0; height: 0; }

  .code-input::-webkit-scrollbar { width: 0; height: 8px; }
}


@keyframes sheet-up {
  from { opacity: 0; transform: translateY(16px); }
}

@keyframes scrim-in {
  from { opacity: 0; }
}



.term[hidden] { display: none; }

.term-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  height: 26px;
  padding: 0 10px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
}
.term-bar[hidden] { display: none; }
.term-bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 20px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-dim);
  font: 11.5px/1 inherit;
  cursor: pointer;
}
.term-bar-btn:hover { background: var(--hover, rgba(127,127,127,.14)); color: var(--text); }
.term-bar-hint { font-size: 11px; color: var(--text-dim); opacity: .55; }
.term-bar:hover .term-bar-hint { opacity: .9; }

.term {
  position: relative;
  display: flex;
  flex-direction: column;
  height: var(--term-h, 42%);
  max-height: 88%;
  min-height: 120px;
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.term-grip {
  position: absolute;
  top: -4px;
  left: 0;
  right: 0;
  height: 9px;
  cursor: ns-resize;
  z-index: 4;
  touch-action: none;
}

.term-grip::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 50%;
  width: 46px;
  height: 3px;
  margin-left: -23px;
  border-radius: 2px;
  background: var(--border);
  transition: background .15s;
}

.term-grip:hover::after,
.term-grip:focus-visible::after,
.term-grip.dragging::after { background: var(--accent); }
.term-grip:focus-visible { outline: none; }
body.term-resizing { cursor: ns-resize; user-select: none; }
body.term-resizing iframe { pointer-events: none; }

.term-head {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.term-title { font-size: 12.5px; font-weight: 600; color: var(--text); }
.term-meta { font-size: 12px; color: var(--text-dim); }

.term-body {
  flex: 1;
  min-height: 0;
  padding: 8px 12px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.6px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.term-line { min-height: 1.2em; }
.term-cmd  { color: var(--accent); }
.term-err  { color: var(--danger); }
.term-ok   { color: var(--ok); }
.term-warn { color: var(--warn); }
.term-dim  { color: var(--text-dim); }

.term-foot {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.term-stdin {
  flex: 1;
  padding: 5px 9px;
  font: inherit;
  font-size: 12.6px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.term-stdin:focus { border-color: var(--accent); outline: none; }
.term-stdin::placeholder { color: var(--text-dim); }



.build-plan { margin: 0 0 10px; }
.build-files { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.build-file { font-size: 13px; border: 1px solid var(--line, #e6e6ef); border-radius: 8px;
  background: var(--card, #fff); overflow: hidden; }
.build-file-head { display: flex; align-items: center; gap: 8px; padding: 5px 8px; cursor: pointer; }
.build-file-head:hover { background: rgba(0, 0, 0, .03); }
.build-file-code { display: none; margin: 0; max-height: 260px; overflow: auto;
  background: #0f1117; color: #e6e6ef; padding: 8px 10px;
  border-top: 1px solid var(--line, #e6e6ef);
  font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre; }
.build-file.open .build-file-code { display: block; }
.build-run.fail { border-left: 3px solid #d64550; }
.build-run.ok { border-left: 3px solid #17a06a; }
.build-file-ic { width: 14px; height: 14px; flex: 0 0 14px; border-radius: 50%;
  border: 2px solid #c7c7d4; box-sizing: border-box; }
.build-file.creating .build-file-ic { border-color: #4a6cf7; border-top-color: transparent;
  animation: build-spin .7s linear infinite; }
.build-file.done .build-file-ic { border-color: #17a06a; background: #17a06a; }
.build-file.error .build-file-ic { border-color: #d64550; background: #d64550; }
.build-file-name { font-family: ui-monospace, Menlo, monospace; }
.build-file-meta { margin-left: auto; color: var(--muted, #8a8a9a); font-size: 12px; }
@keyframes build-spin { to { transform: rotate(360deg); } }
.build-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.build-btn { border: 1px solid var(--line, #d8d8e2); background: var(--card, #fff); color: var(--fg, #222);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.build-btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.build-btn:hover { filter: brightness(.97); }
.build-run { margin: 8px 0 0; padding: 10px; background: #0f1117; color: #e6e6ef; border-radius: 8px;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; white-space: pre-wrap; overflow-x: auto; }


.preview-overlay { position: fixed; inset: 0; background: rgba(15,17,23,.55);
  display: flex; align-items: center; justify-content: center; z-index: 90; padding: 24px; }
.preview-overlay[hidden] { display: none; }
.preview-box { width: min(1100px, 96vw); height: min(760px, 92vh); background: #fff;
  border-radius: 12px; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.preview-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid #ececf3; background: #f7f7fb; }
.preview-title { font-size: 13px; font-weight: 600; color: #333; }
.preview-close { margin-left: auto; border: none; background: none; font-size: 16px; line-height: 1;
  cursor: pointer; color: #666; padding: 4px 8px; border-radius: 6px; }
.preview-close:hover { background: #ececf3; }
.preview-frame { border: 0; width: 100%; flex: 1; background: #fff; }

.build-note { margin: 6px 0 0; font-size: 12.5px; color: var(--muted, #8a8a9a); }


.term-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.term-tabs::-webkit-scrollbar { display: none; }

.term-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font: 500 12px/1.4 var(--mono);
  cursor: pointer;
  white-space: nowrap;
}
.term-tab:hover { background: var(--hover); color: var(--text); }
.term-tab.on {
  background: var(--code-bg);
  border-color: var(--border);
  color: var(--text);
}
.term-tab.dead { opacity: .55; text-decoration: line-through; }
.term-tab.add { padding: 3px 9px; font-size: 15px; line-height: 1; color: var(--text-dim); }

.term-tab-x {
  font-style: normal;
  font-size: 10px;
  opacity: 0;
  padding: 0 1px;
  border-radius: 3px;
}
.term-tab:hover .term-tab-x, .term-tab.on .term-tab-x { opacity: .55; }
.term-tab-x:hover { opacity: 1; background: var(--danger-soft); }

.term-status { font-size: 11.5px; color: var(--text-dim); padding-left: 6px; }
.term-status.dead { color: var(--danger); }

.term-wrap {
  flex: 1;
  min-height: 0;
  outline: none;
  display: flex;
}
.term-wrap:focus-visible { box-shadow: inset 0 0 0 1px var(--accent); }

.term-view {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 6px 8px;
  background: var(--code-bg);
  font: var(--code-size)/1.35 var(--mono);
  white-space: pre;
  tab-size: 8;
}
.term-buf .tl { min-height: 1.35em; }
.term-view ::selection { background: var(--sel-bg); }


.agent-head { font-size: 11.5px; color: var(--text-dim); margin-bottom: 6px; min-height: 14px; }
.agent-steps { display: flex; flex-direction: column; gap: 6px; }

.agent-step { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.agent-act {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--hover);
  color: var(--text-dim);
}
.agent-what {
  font: 12px/1.4 var(--mono);
  color: var(--accent);
  background: transparent;
  padding: 0;
}
.agent-note { font-size: 11.5px; color: var(--text-dim); flex: 1 1 100%; }

.agent-out {
  margin: 0 0 2px 0;
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  font: 11.5px/1.45 var(--mono);
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 220px;
  color: var(--text-dim);
}
.agent-out.bad { border-color: var(--diff-del-mark); background: var(--danger-soft); color: var(--text); }

.agent-finish {
  margin-top: 4px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--ok-soft);
  font-size: 12.5px;
}
.agent-changed { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.agent-changed-t { font-size: 11.5px; color: var(--text-dim); }


.dev-bar { display: flex; gap: 2px; margin-left: 12px; }
.dev-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font: 500 11.5px/1.4 inherit;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
}
.dev-btn:hover { background: var(--hover); color: var(--text); }
.dev-btn.on { background: var(--hover); border-color: var(--border); color: var(--text); }
.dev-size { font: 11px var(--mono); color: var(--text-dim); margin-left: 8px; }

.preview-frame.framed {
  margin: 14px auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .18);
  background: #fff;
  display: block;
  flex: none;
}

.agent-modes {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 12px 0;
  flex-wrap: wrap;
}
.agent-modes-t { font-size: 11.5px; color: var(--text-dim); margin-right: 3px; }
.am-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font: 500 11.5px/1.4 inherit;
  padding: 2px 8px;
  border-radius: 20px;
  cursor: pointer;
}
.am-btn:hover { background: var(--hover); color: var(--text); }
.am-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.agent-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0;
  padding: 8px 10px;
  border: 1px solid var(--warn);
  background: var(--warn-soft);
  border-radius: 8px;
  font-size: 12.5px;
}
.agent-confirm code { font: 11.5px var(--mono); }


.pal {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 18, 24, .35);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
}
.pal-box {
  width: min(680px, 92vw);
  background: var(--panel, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
  overflow: hidden;
}
.pal-inp {
  width: 100%;
  border: 0;
  outline: none;
  padding: 14px 16px;
  font: 15px/1.4 inherit;
  background: transparent;
  color: var(--text);
}
.pal-hint {
  padding: 0 16px 8px;
  font-size: 11.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.pal-list { max-height: 46vh; overflow: auto; padding: 6px; }
.pal-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.pal-row.on { background: var(--hover); }
.pal-label { flex: 1; font: 13px/1.4 var(--mono); color: var(--text); }
.pal-note { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }
.pal-empty { padding: 14px 12px; font-size: 12.5px; color: var(--text-dim); }


.ai-head { flex-wrap: nowrap; min-width: 0; }
.ai-title { flex: none; white-space: nowrap; }

.agent-modes { flex-wrap: wrap; row-gap: 4px; }
.am-btn { flex: none; white-space: nowrap; }

.term-head { min-width: 0; }
.ide-head, .doc-head { min-width: 0; }

@media (max-width: 1180px) {
  .seg-btn { font-size: 11px; padding: 0 4px; }
}


.pv-src { display: flex; align-items: center; gap: 3px; margin-left: 10px; }
.pv-port {
  width: 62px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: 11.5px var(--mono);
}
.pv-port:focus { outline: none; border-color: var(--accent); }
.preview-head { flex-wrap: wrap; row-gap: 6px; }
.pv-note {
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.pv-note.bad { color: var(--danger); }


.agent-ask {
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.agent-ask-q { font-size: 13px; line-height: 1.5; color: var(--text); white-space: pre-wrap; }
.agent-ask-in {
  width: 100%;
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 inherit;
  resize: vertical;
}
.agent-ask-in:focus { outline: none; border-color: var(--accent); }
.agent-ask-row { display: flex; gap: 6px; margin-top: 8px; }
.agent-ask-a {
  margin-top: 8px;
  padding-left: 10px;
  border-left: 2px solid var(--accent);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
  white-space: pre-wrap;
}


.cmp-box {
  position: absolute;
  z-index: 30;
  min-width: 190px;
  max-width: 340px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface, var(--bg));
  box-shadow: 0 10px 28px rgba(0, 0, 0, .38);
  overflow: hidden;
}
.cmp-box[hidden] { display: none; }
.cmp-item {
  padding: 5px 9px;
  border-radius: 6px;
  font: 12.5px/1.35 var(--mono, ui-monospace, monospace);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.cmp-item:hover { background: var(--hover, rgba(127, 127, 127, .14)); }
.cmp-item.on { background: var(--accent); color: #fff; }


.agent-ask-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.agent-ask-opt {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font: 12.5px/1.2 inherit;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-ask-opt:hover { border-color: var(--accent); color: var(--accent); }
.agent-ask-opt:active { transform: translateY(1px); }


.live-code {
  margin: 8px 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--code-bg, var(--bg));
}
.live-code-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface, var(--bg));
}
.live-code-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: live-pulse 1.1s ease-in-out infinite;
}
.live-code.done .live-code-dot { background: var(--ok, #3aa76d); animation: none; }
@keyframes live-pulse {
  0%, 100% { opacity: .35; transform: scale(.8); }
  50%      { opacity: 1;   transform: scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
  .live-code-dot { animation: none; }
}
.live-code-name {
  font: 12px/1 var(--mono, ui-monospace, monospace);
  color: var(--text);
  font-weight: 600;
}
.live-code-count { margin-left: auto; font-size: 11px; color: var(--text-dim); }
.live-code-body {
  margin: 0;
  padding: 9px 11px;
  max-height: 230px;
  overflow: auto;
  font: 11.5px/1.5 var(--mono, ui-monospace, monospace);
  color: var(--text-dim);
  white-space: pre;
  tab-size: 4;
}
.live-code.done .live-code-body { max-height: 150px; color: var(--text-dim); opacity: .8; }


.agent-queue { display: flex; flex-direction: column; gap: 4px; padding: 6px 10px 0; }
.agent-queue[hidden] { display: none; }
.agent-queue-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.agent-queue-n {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text);
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}
.agent-queue-t { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-queue-x {
  flex: 0 0 auto;
  border: 0;
  background: none;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.agent-queue-x:hover { color: var(--danger); }


.resume-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface, var(--bg));
}
.resume-t { flex: 1 1 220px; font-size: 12.5px; line-height: 1.45; color: var(--text-dim); }


:root { --hover: rgba(127, 127, 127, .13); }

.preview-box {
  background: var(--bg) !important;
  border: 1px solid var(--border);
}
.preview-head {
  background: var(--surface, var(--bg)) !important;
  border-bottom: 1px solid var(--border) !important;
  gap: 14px !important;
  padding: 9px 12px !important;
}
.preview-title { color: var(--text) !important; }
.preview-frame { background: var(--bg); }
.preview-close {
  color: var(--text-dim) !important;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px !important;
}
.preview-close:hover { background: var(--hover) !important; color: var(--text) !important; }

.pv-group { display: flex; align-items: center; gap: 8px; }
.pv-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
.pv-seg {
  display: flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.pv-seg .dev-btn { border-radius: 6px; border-color: transparent; }
.pv-seg .dev-btn.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.pv-port-wrap { display: flex; align-items: center; gap: 5px; }
.pv-icon { display: inline-flex; align-items: center; justify-content: center; padding: 4px 6px; }
.dev-bar { display: flex; align-items: center; gap: 8px; }

@media (max-width: 900px) {
  .pv-label { display: none; }
  .preview-head { gap: 8px !important; }
}


.brigade {
  margin: 8px 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface, var(--bg));
}
.brigade-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--border);
}
.brigade-t { font-size: 12.5px; font-weight: 650; color: var(--text); }
.brigade-n { margin-left: auto; font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.brigade-row { display: flex; align-items: center; gap: 9px; padding: 6px 11px; }
.brigade-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  animation: live-pulse 1.1s ease-in-out infinite;
}
.brigade-row.ok  .brigade-dot { background: var(--ok, #3aa76d); animation: none; }
.brigade-row.bad .brigade-dot { background: var(--danger); animation: none; }
.brigade-file { font: 12px var(--mono, ui-monospace, monospace); color: var(--text-dim); }
.brigade-row.ok .brigade-file { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .brigade-dot { animation: none; } }




.preview-frame { flex: 1; }
.preview-box > .preview-body,
.preview-box { overflow: hidden; }
.dev-size { font: 11px var(--mono, ui-monospace, monospace); color: var(--text-dim); white-space: nowrap; }


.agent-ask-q {
  font: 13.5px/1.55 inherit;
  color: var(--text);
  white-space: pre-wrap;
}
.agent-ask-opt.own {
  border-style: dashed;
  color: var(--text-dim);
}
.agent-ask-opt.own:hover { border-style: solid; }
.agent-ask-in[hidden], .agent-ask-row[hidden] { display: none; }


.proj-bar { position: relative; padding: 8px 10px 0; }
.proj-cur {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: 600 12.5px/1 inherit;
  cursor: pointer;
  text-align: left;
}
.proj-cur:hover { border-color: var(--accent); }
.proj-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-chev { flex: 0 0 auto; color: var(--text-dim); }

.proj-menu {
  position: absolute;
  top: 44px;
  left: 10px;
  right: 10px;
  z-index: 40;
  max-height: 340px;
  overflow: auto;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface, var(--bg));
  box-shadow: 0 12px 34px rgba(0, 0, 0, .34);
}
.proj-menu[hidden] { display: none; }

.proj-row { display: flex; align-items: center; gap: 3px; border-radius: 7px; }
.proj-row:hover { background: var(--hover, rgba(127,127,127,.13)); }
.proj-row.on .proj-row-name { color: var(--accent); }
.proj-pick {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 9px;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
}
.proj-row-name {
  font: 600 12.5px/1.3 inherit;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proj-row-meta { font-size: 11px; color: var(--text-dim); }
.proj-act {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
}
.proj-act:hover { background: var(--bg); color: var(--text); }
.proj-act.danger:hover { color: var(--danger); }
.proj-new {
  width: 100%;
  margin-top: 4px;
  padding: 8px 9px;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0 0 7px 7px;
  background: none;
  color: var(--accent);
  font: 600 12.5px/1 inherit;
  cursor: pointer;
  text-align: left;
}
.proj-new:hover { background: var(--hover, rgba(127,127,127,.13)); }


.preview-frame { flex: 1 1 auto; min-height: 0; width: 100%; border: 0; background: #fff; }

.preview-frame.framed {
  transform-origin: top center;
  border: 12px solid #22262e;
  border-radius: 30px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .42);
  background: #fff;
}
.preview-frame.framed.tablet { border-width: 14px; border-radius: 20px; }
.preview-frame.framed.rot { border-radius: 24px; }
.preview-body, .preview-box > .preview-body {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
}


.arch-box {
  margin: 10px 0;
  border: 1px solid var(--accent);
  border-radius: 11px;
  overflow: hidden;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.arch-head { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.arch-t { font: 650 12.5px/1 inherit; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; }
.arch-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; }
.arch-row { display: flex; gap: 9px; align-items: baseline; font-size: 12.5px; line-height: 1.5; }
.arch-key {
  flex: 0 0 96px;
  font-weight: 650;
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: .4px;
}
.arch-val { flex: 1 1 auto; min-width: 0; color: var(--text); }

/* шапка предпросмотра всегда над рамкой: кнопки должны нажиматься */
.preview-head { position: relative; z-index: 2; }
.preview-frame { position: relative; z-index: 1; }
