


:root {
  --ide-top: 52px;
  --ide-status: 28px;
  --tree-w: 268px;
  --insp-w: 320px;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;

  
  --sheet-w: 800px;
  --sheet-pad-y: 54px;
  --sheet-pad-x: 66px;
  --sheet-gap: 26px;
  
  --sheet-radius: 5px;

  
  --font-doc: "PT Serif", Cambria, Georgia, "Times New Roman", "Liberation Serif", "DejaVu Serif", serif;
  --doc-size: 16.4px;
  --doc-lead: 1.58; 

  
  --paper: #ffffff;
  --paper-edge: #e8e6e0;
  --paper-line: #ebe9e4;
  --desk: #eceae7;
  --paper-shadow: 0 1px 2px rgba(20, 20, 18, .07), 0 14px 30px -12px rgba(20, 20, 18, .18);

  --warn: #d9a227;
  --warn-soft: rgba(217, 162, 39, .14);
  --danger-soft: rgba(214, 69, 69, .12);
}

html[data-theme="dark"] {
  
  --paper: #171b23;
  --paper-edge: #262c35;
  --paper-line: #242a33;
  --desk: #07090c;
  --paper-shadow: 0 1px 2px rgba(0, 0, 0, .55), 0 20px 44px -16px rgba(0, 0, 0, .8);
  --warn-soft: rgba(217, 162, 39, .18);
  --danger-soft: rgba(240, 113, 113, .16);
}

html[data-incognito="true"] {
  --paper: #26262b;
  --paper-edge: #37373d;
  --paper-line: #33333a;
  --desk: #151517;
  --paper-shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 18px 40px -16px rgba(0, 0, 0, .7);
}

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

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


.ide-top {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.ide-logo {
  margin-right: 6px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.3px;
  color: var(--text);
  text-decoration: none;
}
.ide-spacer { flex: 1; }

.ide-btn {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: background .16s ease, border-color .16s ease, transform .1s ease;
}
.ide-btn:hover { border-color: var(--accent); }
.ide-btn:active { transform: translateY(1px); }
.ide-btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.ide-btn.ghost:hover { color: var(--text); background: var(--bg); border-color: var(--border); }
.ide-btn.primary { color: #fff; background: var(--accent); border-color: transparent; }
.ide-btn.primary:hover { filter: brightness(1.08); }
.ide-btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.ide-btn:disabled:hover { border-color: var(--border); }
.ide-btn .dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ide-btn .caret { color: var(--text-dim); font-size: 10px; }

kbd {
  padding: 2px 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
}


.ide-main {
  display: grid;
  grid-template-columns: var(--tree-w) 1fr var(--insp-w);
  min-height: 0;
}
.ide-main.no-inspect { grid-template-columns: var(--tree-w) 1fr 0; }


.ide-tree {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.tree-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.tree-body { flex: 1; overflow-y: auto; padding: 0 8px 10px; }
.tree-empty, .insp-empty {
  padding: 14px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
}
.tree-foot { padding: 10px; border-top: 1px solid var(--border); }

.tree-proj { margin-bottom: 2px; }
.tree-row {
  display: flex;
  gap: 7px;
  align-items: center;
  width: 100%;
  padding: 7px 8px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  background: none;
  border: none;
  border-radius: 8px;
  transition: background .13s ease;
}
.tree-row:hover { background: var(--bg); }
.tree-row.active { color: var(--accent); background: var(--accent-soft); font-weight: 550; }
.tree-row .tw {
  flex: none;
  width: 12px;
  font-size: 9px;
  color: var(--text-dim);
  transition: transform .18s ease;
}
.tree-proj.open .tree-row .tw { transform: rotate(90deg); }
.tree-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .cnt { margin-left: auto; font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.tree-docs { overflow: hidden; max-height: 0; transition: max-height .26s cubic-bezier(.4,0,.2,1); }
.tree-proj.open .tree-docs { max-height: 2400px; }

.tree-doc {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 6px 8px 6px 26px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  background: none;
  border: none;
  border-radius: 8px;
  animation: treeIn .2s ease both;
}
.tree-doc:hover { background: var(--bg); }
.tree-doc.open { background: var(--accent-soft); color: var(--accent); }
.tree-doc .ic { flex: none; font-size: 13px; opacity: .85; }
.tree-doc .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-doc .warn { margin-left: auto; font-size: 10px; color: var(--warn); }
@keyframes treeIn {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: none; }
}


.tree-doc.hintme {
  outline: 1px dashed var(--accent);
  outline-offset: -2px;
  color: var(--accent);
}

.upload-wide {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 9px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  transition: border-color .16s ease, color .16s ease, background .16s ease;
}
.upload-wide:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.upload-wide:disabled { opacity: .5; cursor: not-allowed; }

.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  font: inherit;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  transition: color .14s ease, background .14s ease, border-color .14s ease;
}
.mini-btn:hover:not(:disabled) { color: var(--text); background: var(--bg); border-color: var(--border); }
.mini-btn:disabled { opacity: .45; cursor: not-allowed; }
.mini-btn.wide { padding: 0 10px; font-size: 12px; }


.resizer {
  position: absolute;
  top: 0;
  right: -3px;
  z-index: 5;
  width: 6px;
  height: 100%;
  cursor: col-resize;
}
.resizer.left { right: auto; left: -3px; }
.resizer:hover { background: linear-gradient(90deg, transparent, var(--accent-soft), transparent); }


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

.tabs {
  display: flex;
  gap: 2px;
  min-height: 38px;
  padding: 5px 8px 0;
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex: none;
  max-width: 230px;
  padding: 7px 10px;
  font-size: 12.8px;
  color: var(--text-dim);
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 9px 9px 0 0;
  animation: tabIn .18s ease both;
}
.tab:hover { color: var(--text); background: var(--bg); }
.tab.active {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border);
  font-weight: 550;
}
.tab .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tab.dirty .nm::after {
  content: "•";
  margin-left: 5px;
  font-size: 16px;
  line-height: 0;
  vertical-align: middle;
  color: var(--warn);
}
.tab .x {
  flex: none;
  width: 16px; height: 16px;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  border-radius: 5px;
  opacity: .55;
}
.tab .x:hover { opacity: 1; background: var(--border); }
@keyframes tabIn {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: none; }
}


.panes { display: flex; flex: 1; min-height: 0; }
.pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border);
}
.pane:last-child { border-right: none; }


.pane-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  row-gap: 6px;
  align-items: center;
  padding: 7px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: background .18s ease, box-shadow .18s ease;
}
.pane-spacer { flex: 1; }


.pane-bar.editing {
  background: var(--accent-soft);
  box-shadow: inset 0 2px 0 var(--accent);
}

.find {
  display: flex;
  gap: 5px;
  align-items: center;
  min-width: 0;
  padding: 0 8px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color .16s ease;
}
.find:focus-within { border-color: var(--accent); }
.find-in {
  width: 200px;
  min-width: 90px;
  padding: 6px 2px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
}
.find-n {
  min-width: 44px;
  font-size: 11.5px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}




.doc-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--desk);
  scroll-padding-top: 30px;
}


.doc-page { display: block; }


.doc-text,
.doc-sheet,
.doc-editor {
  position: relative;
  width: min(var(--sheet-w), calc(100% - 40px));
  
  min-height: calc(var(--sheet-w) * 1.414);
  padding: var(--sheet-pad-y) var(--sheet-pad-x) calc(var(--sheet-pad-y) + 10px);
  margin: var(--sheet-gap) auto 64px;
  font-family: var(--font-doc);
  font-size: var(--doc-size);
  line-height: var(--doc-lead);
  color: var(--text);
  text-rendering: optimizeLegibility;
  
  font-variant-numeric: lining-nums tabular-nums;
  overflow-wrap: break-word;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: var(--sheet-radius);
  box-shadow: var(--paper-shadow);
  animation: paperIn .24s ease both;
}
.doc-sheet + .doc-sheet { margin-top: var(--sheet-gap); }

@keyframes paperIn {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}


.sheet-num {
  position: absolute;
  right: var(--sheet-pad-x);
  bottom: 20px;
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}


.panes:has(.pane[data-pane="b"]:not([hidden])) .pane {
  --sheet-w: 620px;
  --sheet-pad-x: 46px;
  --sheet-pad-y: 40px;
}




.doc-text .ln,
.doc-line {
  display: block;
  min-height: calc(var(--doc-size) * var(--doc-lead));
  white-space: pre-wrap;
}


.doc-text p,
.doc-p {
  margin: 0 0 .85em;
  text-align: justify;
  text-indent: 1.25em;
  hyphens: auto;
}
.doc-text p:last-child, .doc-p:last-child { margin-bottom: 0; }
.doc-text p.flush, .doc-p.flush { text-indent: 0; }


.doc-title,
.doc-text h1 {
  display: block;
  margin: 4px 0 6px;
  font-size: 1.3em;
  font-weight: 700;
  line-height: 1.28;
  text-align: center;
  text-indent: 0;
  letter-spacing: .045em;
}

.doc-lead-line {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin: 0 0 26px;
  font-size: .95em;
  color: var(--text-dim);
}


.doc-sect,
.doc-text h2 {
  display: block;
  margin: 1.75em 0 .6em;
  font-size: 1.02em;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  text-indent: 0;
  letter-spacing: .025em;
  scroll-margin-top: 26px; 
}
.doc-sect:first-child, .doc-text h2:first-child { margin-top: 0; }


.doc-sub,
.doc-text h3 {
  display: block;
  margin: 1.1em 0 .35em;
  font-size: 1em;
  font-weight: 650;
  text-indent: 0;
  scroll-margin-top: 26px;
}


.doc-num {
  display: inline-block;
  min-width: 2.6em;
  font-weight: 650;
  font-variant-numeric: lining-nums tabular-nums;
}

.doc-center { display: block; text-align: center; text-indent: 0; }
.doc-right  { display: block; text-align: right;  text-indent: 0; }
.doc-b { font-weight: 700; }
.doc-i { font-style: italic; }
.doc-sp { display: block; height: .9em; }

.doc-text blockquote,
.doc-quote {
  margin: .9em 0;
  padding: .3em 0 .3em 1.1em;
  font-size: .96em;
  color: var(--text-dim);
  text-indent: 0;
  background: none;
  border-left: 2px solid var(--paper-line);
  border-radius: 0;
}


.doc-text ul, .doc-text ol { margin: .5em 0 .85em; padding-left: 1.9em; }
.doc-text li { margin: .25em 0; text-align: justify; }


.doc-text table {
  width: 100%;
  margin: 1em 0;
  font-size: .94em;
  background: none;
  border: 1px solid var(--paper-line);
  border-collapse: collapse;
}
.doc-text th, .doc-text td {
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--paper-line);
}
.doc-text th { font-weight: 650; background: none; }
.doc-text thead th { border-bottom-width: 2px; }


.doc-sign {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 46px;
  margin-top: 2.2em;
  font-size: .96em;
  text-indent: 0;
}
.doc-sign-col { line-height: 1.45; }
.doc-sign-col .who { margin-bottom: .8em; font-weight: 650; }

.doc-fill {
  display: inline-block;
  min-width: 150px;
  border-bottom: 1px solid var(--text-dim);
}


.doc-req { font-size: .92em; line-height: 1.42; text-indent: 0; }


.doc-text .insp-note {
  margin-top: 1.6em;
  padding-top: .8em;
  font-family: var(--font);
  font-size: 12px;
  text-align: center;
  text-indent: 0;
  border-top: 1px dashed var(--paper-line);
}


.doc-text .welcome { min-height: 0; height: auto; padding: 10px 0; }


.doc-text .low {
  text-decoration: underline wavy var(--warn);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: help;
}


.doc-text mark.hit {
  padding: 1px 2px;
  color: inherit;
  background: rgba(250, 204, 21, .4);
  border-radius: 3px;
}
.doc-text mark.hit.cur {
  color: #fff;
  background: var(--accent);
  animation: hitPop .28s ease;
}
@keyframes hitPop { 45% { transform: scale(1.13); } }


.doc-tip {
  display: flex;
  gap: 12px;
  align-items: center;
  width: min(var(--sheet-w), calc(100% - 40px));
  margin: 18px auto -8px;
  padding: 10px 12px 10px 14px;
  font-family: var(--font);
  font-size: 12.6px;
  line-height: 1.45;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 11px;
  animation: paperIn .24s ease both;
}
.doc-tip b { font-weight: 650; }
.doc-tip .mini-btn { flex: none; color: var(--accent); }
.doc-tip .mini-btn:hover { background: var(--surface); border-color: transparent; }



.doc-editor {
  padding: 0;              
  border-color: var(--accent);
  box-shadow: var(--paper-shadow), 0 0 0 4px var(--accent-soft);
  cursor: text;
  transition: box-shadow .18s ease;
}
.doc-editor:focus-within { box-shadow: var(--paper-shadow), 0 0 0 5px var(--accent-soft); }


.doc-editor > .doc-text {
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: var(--sheet-pad-y) var(--sheet-pad-x) calc(var(--sheet-pad-y) + 10px);
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  animation: none;
  white-space: pre-wrap;
  text-align: left;   
  text-indent: 0;
  hyphens: none;
}


.doc-editor > .doc-hl {
  position: relative;
  z-index: 0;
  pointer-events: none;
}
.doc-editor > .doc-hl p { margin: 0; text-align: left; text-indent: 0; }

.doc-editor > .doc-hl mark { padding: 0; background: none; }


.doc-editor > .doc-input {
  position: absolute;
  inset: 0;
  z-index: 1;
  height: 100%;
  font: inherit;
  font-family: var(--font-doc);
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--accent);
  resize: none;
  overflow: hidden;
  outline: none;
}
.doc-editor > .doc-input::selection { background: var(--accent-soft); }


.doc-editor::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: calc(var(--sheet-pad-x) - 16px);
  z-index: 2;
  border-left: 1px dashed var(--paper-line);
  pointer-events: none;
}


.doc-editor .ln.on,
.doc-line.on {
  background: var(--accent-soft);
  border-radius: 3px;
  box-shadow: -10px 0 0 var(--accent-soft), 10px 0 0 var(--accent-soft);
}

.doc-editor .ln.edited { box-shadow: inset 3px 0 0 var(--ok); }


.edit-start { color: var(--accent); }
.edit-start:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); border-color: transparent; }


.edit-save { color: var(--text-dim); }
.edit-save.dirty,
.pane-bar.dirty .edit-save {
  color: #fff;
  background: var(--accent);
  border-color: transparent;
}
.edit-save.dirty:hover:not(:disabled),
.pane-bar.dirty .edit-save:hover:not(:disabled) {
  color: #fff;
  background: var(--accent);
  border-color: transparent;
  filter: brightness(1.08);
}
.edit-stop { color: var(--text-dim); }


.edit-state {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 3px 10px 3px 8px;
  font-size: 11.5px;
  color: var(--ok);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  white-space: nowrap;
}
.edit-state::before {
  content: "";
  width: 7px; height: 7px;
  background: currentColor;
  border-radius: 50%;
}
.edit-state.dirty {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: transparent;
}
.edit-state.dirty::before { animation: dirtyPulse 1.6s ease-in-out infinite; }
.edit-state.saving { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.edit-state.failed { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
@keyframes dirtyPulse { 50% { opacity: .3; } }




.ai-menu {
  position: fixed;
  z-index: 65;
  display: flex;
  gap: 2px;
  align-items: center;
  padding: 5px;
  font-family: var(--font);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: aiPop .16s cubic-bezier(.2,.9,.3,1) both;
}
@keyframes aiPop {
  from { opacity: 0; transform: translateY(5px) scale(.97); }
  to   { opacity: 1; transform: none; }
}


.ai-menu::after {
  content: "";
  position: absolute;
  left: var(--tip, 50%);
  bottom: -5px;
  width: 9px; height: 9px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: translateX(-50%) rotate(45deg);
}

.ai-menu.below::after {
  top: -5px;
  bottom: auto;
  border: none;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.ai-menu-t {
  padding: 0 4px 0 8px;
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
}
.ai-menu-sep { width: 1px; height: 18px; margin: 0 4px; background: var(--border); }

.ai-act {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  height: 30px;
  padding: 0 11px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  background: transparent;
  border: none;
  border-radius: 8px;
  transition: background .14s ease, color .14s ease;
}
.ai-act:hover { color: var(--accent); background: var(--accent-soft); }
.ai-act.on { color: #fff; background: var(--accent); }
.ai-act.ghost { color: var(--text-dim); }
.ai-act.ghost:hover { color: var(--text); background: var(--bg); }

.ai-act[data-act="risks"]:hover { color: var(--danger); background: var(--danger-soft); }
.ai-act[data-act="risks"].on { color: #fff; background: var(--danger); }


.ai-result { display: flex; flex-direction: column; }

.ai-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.ai-act-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent);
}
.ai-head .mini-btn { margin-left: auto; }

.ai-result[data-act="risks"] .ai-act-name { color: var(--danger); }
.ai-result[data-act="risks"] .ai-frag { border-left-color: var(--danger); }


.ai-frag {
  position: relative;
  max-height: 5.4em;
  margin-bottom: 12px;
  padding: 8px 12px;
  overflow: hidden;
  font-family: var(--font-doc);
  font-size: 13.2px;
  line-height: 1.5;
  color: var(--text-dim);
  background: var(--bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  cursor: pointer;
}
.ai-frag::after {
  content: "";
  position: absolute;
  right: 0; bottom: 0; left: 0;
  height: 1.7em;
  background: linear-gradient(transparent, var(--bg));
}
.ai-frag.full { max-height: none; cursor: default; }
.ai-frag.full::after { display: none; }

.ai-body { font-size: 13.6px; line-height: 1.62; color: var(--text); }
.ai-body:empty::before { content: "Думаю…"; color: var(--text-dim); }

.ai-body.streaming::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1.02em;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--accent);
  border-radius: 1px;
  animation: caretBlink 1s steps(2, start) infinite;
}
@keyframes caretBlink { 50% { opacity: 0; } }


.ai-hint-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 14px;
}
.ai-hint {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  font: inherit;
  font-size: 12.8px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
  transition: border-color .16s ease;
}
.ai-hint:focus { border-color: var(--accent); }
.ai-hint::placeholder { color: var(--text-dim); }

.ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.ai-apply { color: #fff; background: var(--accent); border-color: transparent; }
.ai-apply:hover:not(:disabled) {
  color: #fff;
  background: var(--accent);
  border-color: transparent;
  filter: brightness(1.08);
}


.welcome {
  display: flex;
  flex-direction: column;
  gap: 13px;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 44px 30px 60px;
  text-align: center;
  color: var(--text-dim);
  animation: docIn .3s ease both;
}
.welcome-art { color: var(--border); }
.welcome h2 { font-size: 20px; font-weight: 650; color: var(--text); }
.welcome p { max-width: 470px; font-size: 13.5px; line-height: 1.6; }
.welcome.small { min-height: 0; padding: 30px 24px; }
.welcome.small p { max-width: 320px; font-size: 12.5px; }
@keyframes docIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}


.welcome-steps,
.coach-steps {
  max-width: 480px;
  margin: 2px 0;
  padding: 0;
  text-align: left;
  list-style: none;
  counter-reset: step;
}
.welcome-steps li,
.coach-steps li {
  position: relative;
  margin-bottom: 11px;
  padding-left: 34px;
  font-size: 13.2px;
  line-height: 1.5;
  color: var(--text-dim);
}
.welcome-steps li:last-child,
.coach-steps li:last-child { margin-bottom: 0; }
.welcome-steps li::before,
.coach-steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  top: 0; left: 0;
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 50%;
}
.welcome-steps b,
.coach-steps b { color: var(--text); font-weight: 650; }


.welcome-cta {
  height: 38px;
  margin-top: 4px;
  padding: 0 20px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background: var(--accent);
  border: none;
  border-radius: 11px;
  transition: filter .16s ease, transform .1s ease;
}
.welcome-cta:hover { filter: brightness(1.08); }
.welcome-cta:active { transform: translateY(1px); }



.welcome .welcome-alt,
.welcome-drop {
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: center;
  justify-content: center;
  width: min(470px, 100%);
  max-width: 100%;
  margin-top: 6px;
  padding: 24px 26px;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 16px;
  transition: color .16s ease, border-color .16s ease, background .16s ease, transform .16s ease;
}
.welcome .welcome-alt::before,
.welcome-drop::before {
  content: "↓";
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  font-size: 17px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 50%;
}
.welcome .welcome-alt:hover, .welcome .welcome-alt.over,
.welcome-drop:hover, .welcome-drop.over {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}
.welcome .welcome-alt.over, .welcome-drop.over { transform: scale(1.012); }
.welcome-drop .big { font-size: 15.5px; font-weight: 650; color: var(--text); }
.welcome-drop:hover .big, .welcome-drop.over .big { color: var(--accent); }


.welcome-tip {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 550;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 99px;
}
.welcome-tip .arrow { font-size: 15px; animation: tipNudge 1.5s ease-in-out infinite; }
@keyframes tipNudge { 50% { transform: translateX(-5px); } }

.welcome-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: center;
  margin-top: 6px;
  font-size: 12px;
}


.coach {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  
  background: rgba(0, 0, 0, .62);
  animation: veilIn .16s ease both;
}
.coach-card {
  width: min(540px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px 28px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: palIn .2s cubic-bezier(.2,.9,.3,1) both;
}
.coach-card h3 { margin-bottom: 16px; font-size: 18px; font-weight: 650; color: var(--text); }
.coach-note { margin: 16px 0 18px; font-size: 12.5px; line-height: 1.5; color: var(--text-dim); }
.coach-card .ide-btn { height: 38px; padding: 0 18px; font-size: 14px; }


.sk { display: flex; flex-direction: column; gap: 14px; padding: 4px 0; }
.sk i {
  display: block; height: 13px;
  background: linear-gradient(90deg, var(--border) 25%, var(--surface) 50%, var(--border) 75%);
  background-size: 400% 100%;
  border-radius: 6px;
  animation: shimmer 1.3s linear infinite;
}
.sk i:nth-child(3n) { width: 70%; }
.sk i:nth-child(5n) { width: 86%; }


.ide-inspect {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
  border-left: 1px solid var(--border);
}
.insp-tabs { display: flex; padding: 8px 6px 0; gap: 1px; }
.insp-tab {
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  font: inherit;
  font-size: 11.5px;
  color: var(--text-dim);
  cursor: pointer;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.insp-tab:hover { color: var(--text); }
.insp-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.badge-n {
  display: inline-block;
  min-width: 16px;
  margin-left: 5px;
  padding: 1px 4px;
  font-size: 10px;
  color: #fff;
  background: var(--warn);
  border-radius: 20px;
}

.insp-tab[data-tab="ai"] .badge-n {
  min-width: 0;
  padding: 0;
  font-size: 12px;
  color: var(--accent);
  background: none;
}

.insp-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 24px; }
.insp-pane { display: none; animation: docIn .2s ease both; }
.insp-pane.active { display: block; }

.insp-group { margin-bottom: 20px; }
.insp-h {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.insp-note { margin-top: 7px; font-size: 12px; line-height: 1.5; color: var(--text-dim); }

.gauge { height: 7px; overflow: hidden; background: var(--border); border-radius: 99px; }
.gauge-fill {
  width: 0; height: 100%;
  border-radius: 99px;
  transition: width .6s cubic-bezier(.4,0,.2,1), background .3s ease;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-w {
  padding: 4px 9px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text);
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  transition: border-color .14s ease, color .14s ease;
}
.chip-w:hover { color: var(--accent); border-color: var(--accent); }

.outline { font-size: 13px; line-height: 1.65; }
.outline li, .outline p { cursor: pointer; transition: color .14s ease; }
.outline li:hover, .outline p:hover { color: var(--accent); }

.meta { display: grid; grid-template-columns: auto 1fr; gap: 9px 14px; font-size: 12.5px; }
.meta dt { color: var(--text-dim); }
.meta dd { color: var(--text); font-variant-numeric: tabular-nums; word-break: break-word; }


.ide-status {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 0 14px;
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.st-item { display: inline-flex; gap: 5px; align-items: center; font-variant-numeric: tabular-nums; }
.st-item.dim { opacity: .7; }
.st-item.warn { color: var(--warn); }
.st-sep { width: 1px; height: 13px; background: var(--border); }


.palette-wrap {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  justify-content: center;
  padding-top: 12vh;
  background: rgba(0, 0, 0, .68);
  animation: veilIn .14s ease both;
}
@keyframes veilIn { from { opacity: 0; } to { opacity: 1; } }

.palette {
  width: min(620px, 92vw);
  height: fit-content;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  animation: palIn .18s cubic-bezier(.2,.9,.3,1) both;
}
@keyframes palIn {
  from { opacity: 0; transform: translateY(-10px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

.palette-in {
  width: 100%;
  padding: 16px 18px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
}
.palette-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.pal-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  font-size: 13.5px;
  cursor: pointer;
  border-radius: 9px;
}
.pal-item .ic { opacity: .8; }
.pal-item .sub { margin-left: auto; font-size: 11.5px; color: var(--text-dim); }
.pal-item.sel { background: var(--accent-soft); color: var(--accent); }
.palette-foot {
  display: flex;
  gap: 12px;
  padding: 9px 14px;
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}


.menu {
  position: fixed;
  z-index: 70;
  min-width: 240px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: palIn .15s ease both;
}
.menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  background: none;
  border: none;
  border-radius: 8px;
}
.menu button:hover { background: var(--bg); }
.menu button.on { color: var(--accent); background: var(--accent-soft); }


.drop-veil {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(47, 111, 237, .1);
  animation: veilIn .12s ease both;
}
.drop-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  padding: 40px 54px;
  font-size: 14px;
  font-weight: 550;
  color: var(--accent);
  background: var(--surface);
  border: 2px dashed var(--accent);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
}
.drop-card svg { animation: dropBounce .8s ease-in-out infinite; }


.proc {
  position: fixed;
  right: 20px;
  bottom: 44px;
  z-index: 75;
  width: 290px;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: var(--shadow-lg);
  animation: palIn .2s ease both;
}
.proc-name {
  margin-bottom: 9px;
  font-size: 12.5px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proc-track { height: 5px; overflow: hidden; background: var(--border); border-radius: 99px; }
.proc-bar {
  width: 0; height: 100%;
  background: linear-gradient(90deg, var(--accent), #7aa5ff);
  border-radius: 99px;
  transition: width .45s cubic-bezier(.4,0,.2,1);
}
.proc-bar.pulse { animation: barPulse 1.1s ease-in-out infinite; }
.proc-steps { display: flex; gap: 13px; margin-top: 9px; font-size: 11px; color: var(--text-dim); }
.proc-step { position: relative; padding-left: 13px; }
.proc-step::before {
  content: "";
  position: absolute; top: 50%; left: 0;
  width: 6px; height: 6px;
  background: var(--border);
  border-radius: 50%;
  transform: translateY(-50%);
  transition: background .2s ease, box-shadow .2s ease;
}
.proc-step.active { color: var(--accent); }
.proc-step.active::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.proc-step.done { color: var(--ok); }
.proc-step.done::before { background: var(--ok); }


@media (max-width: 1300px) {
  :root { --sheet-w: 720px; }
}
@media (max-width: 1100px) {
  .ide-main { grid-template-columns: 220px 1fr 0; }
  .ide-inspect { display: none; }
}
@media (max-width: 900px) {
  
  :root { --sheet-pad-x: 30px; --sheet-pad-y: 34px; --sheet-gap: 14px; --doc-size: 15.8px; }
  .doc-text, .doc-sheet, .doc-editor, .doc-tip { width: min(var(--sheet-w), calc(100% - 16px)); }
  .doc-text, .doc-sheet, .doc-editor { min-height: 0; }
}
@media (max-width: 760px) {
  .ide-main { grid-template-columns: 0 1fr 0; }
  .ide-tree { display: none; }
}




.ide-drawer-btn {
  display: none;
  flex: none;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 44px;          
  padding: 0;
  font: inherit;
  color: var(--text-dim);
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  transition: color .16s ease, background .16s ease;
}
.ide-drawer-btn .lbl-m {
  font-size: 9px;
  line-height: 1;
  letter-spacing: .01em;
  white-space: nowrap;
}

.ide-drawer-btn[aria-expanded="true"] { color: var(--accent); background: var(--accent-soft); }


.ide-veil { display: none; }


.only-m { display: none; }


@media (max-width: 1100px) {
  
  .ide-inspect {
    display: flex;
    position: fixed;
    top: var(--ide-top);
    right: 0;
    bottom: 0;
    z-index: 60;
    width: min(88vw, 380px);
    visibility: hidden;          
    transform: translateX(101%);
    box-shadow: var(--shadow-lg);
    transition: transform .26s cubic-bezier(.4,0,.2,1), visibility 0s .26s;
  }
  .ide.insp-on .ide-inspect {
    visibility: visible;
    transform: none;
    transition: transform .26s cubic-bezier(.4,0,.2,1), visibility 0s;
  }
  .ide-inspect .resizer { display: none; }   

  .ide.tree-on .ide-veil,
  .ide.insp-on .ide-veil {
    display: block;
    position: fixed;
    inset: var(--ide-top) 0 0;
    z-index: 55;
    background: rgba(0, 0, 0, .42);
    animation: veilIn .16s ease both;
  }

  #mInspBtn { display: inline-flex; }

  
  .insp-body { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  .tree-body, .insp-body { overscroll-behavior: contain; }

  
  .ide-status { white-space: nowrap; overflow: hidden; }
  #stDoc { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

  
  .ide-top, .ide-status {
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    padding-left: max(14px, env(safe-area-inset-left, 0px));
  }
}


@media (max-width: 768px) {
  :root {
    
    --ide-top: calc(56px + env(safe-area-inset-top, 0px));
    --ide-status: calc(28px + env(safe-area-inset-bottom, 0px));
    
    --sheet-pad-x: 20px;
    --sheet-pad-y: 26px;
    --sheet-gap: 10px;
    --doc-size: 16px;
  }

  
  .ide-body, .ide { height: 100vh; height: 100dvh; }
  .ide-body {
    max-width: 100%;
    overflow-x: hidden;          
    -webkit-text-size-adjust: 100%;   
  }

  
  .ide-main { display: flex; grid-template-columns: none; min-width: 0; }
  .ide-editor { flex: 1; min-width: 0; }

  
  .ide-top {
    gap: 5px;
    padding: 0 6px;
    padding-top: env(safe-area-inset-top, 0px);
    overflow: hidden;            
  }
  .ide-logo { display: none; }   
  #splitToggle, #helpBtn { display: none; }   
  .ide-top .lbl, .ide-top kbd { display: none; }   

  
  .ide-top .ide-btn {
    height: 44px;
    padding: 0 10px;
    font-size: 13.5px;
    border-radius: 11px;
  }
  
  .ide-top .ide-btn.ghost, .ide-top .ide-btn.primary {
    flex: none;
    width: 44px;
    padding: 0;
    justify-content: center;
  }
  #pickProject { flex: 1 1 auto; min-width: 0; }
  #projName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  #mTreeBtn { display: inline-flex; }

  
  .ide-tree {
    display: flex;
    position: fixed;
    top: var(--ide-top);
    left: 0;
    bottom: 0;
    z-index: 60;
    width: min(86vw, 330px);
    visibility: hidden;
    transform: translateX(-101%);
    box-shadow: var(--shadow-lg);
    transition: transform .26s cubic-bezier(.4,0,.2,1), visibility 0s .26s;
  }
  .ide.tree-on .ide-tree {
    visibility: visible;
    transform: none;
    transition: transform .26s cubic-bezier(.4,0,.2,1), visibility 0s;
  }
  .ide-tree .resizer { display: none; }
  .ide-inspect { width: min(86vw, 330px); }

  
  .tree-head { padding: 12px 12px 6px; }
  .tree-body { padding: 0 8px 10px; }
  .tree-row, .tree-doc {
    min-height: 44px;
    font-size: 15px;
    border-radius: 10px;
  }
  .tree-doc { padding-left: 22px; }
  .tree-foot { padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .upload-wide { min-height: 48px; font-size: 14.5px; }
  .tree-empty, .insp-empty { font-size: 13.5px; }

  
  .mini-btn { min-width: 44px; height: 44px; font-size: 15px; }
  .mini-btn.wide { padding: 0 12px; font-size: 13.5px; }

  
  .tabs {
    min-height: 50px;
    gap: 5px;
    padding: 6px 10px 0;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
  .tab {
    min-height: 44px;
    max-width: 68vw;             
    padding: 6px 6px 6px 12px;
    font-size: 14px;
    border-radius: 11px 11px 0 0;
  }
  
  .tab .x {
    width: 32px; height: 32px;
    font-size: 15px;
    line-height: 32px;
    border-radius: 9px;
    opacity: .8;
  }

  
  .pane-bar { gap: 6px; padding: 6px 8px; }
  .pane-spacer { display: none; }    
  .find { flex: 1 1 190px; min-width: 0; padding: 0 4px 0 8px; }
  
  
  .find-in { flex: 1; width: auto; min-width: 40px; min-height: 44px; padding: 0 2px; font-size: 16px; }
  .find-n { min-width: 34px; font-size: 12px; }
  .pane-bar .mini-btn.wide { flex: 1 1 auto; }

  
  .ide.is-editing .find { display: none; }   
  .ide.is-editing #outlineA { display: none; }   
  .ide.is-editing .pane-bar {
    background: var(--accent-soft);
    box-shadow: inset 0 2px 0 var(--accent);
  }
  .ide.is-editing .edit-save { flex: 1 1 auto; }
  .doc-editor::before { display: none; }     

  
  .doc-scroll {
    padding-bottom: var(--kb, 0px);
    scroll-padding-bottom: calc(var(--kb, 0px) + 40px);
  }

  
  .doc-text, .doc-sheet, .doc-editor, .doc-tip { width: calc(100% - 12px); }
  .doc-text, .doc-sheet, .doc-editor { min-height: 0; margin-bottom: 30px; }
  .doc-tip { margin: 10px auto -4px; font-size: 13px; }
  .doc-sign { grid-template-columns: 1fr; gap: 18px; }   
  .doc-text table { font-size: .9em; }

  
  .pane[data-pane="b"] { display: none; }

  
  .welcome { padding: 24px 14px 40px; }
  .welcome h2 { font-size: 18px; }
  .welcome p { font-size: 14px; }
  .welcome-steps li, .coach-steps li { font-size: 14px; }
  .welcome-keys { display: none; }        
  .welcome-drop { padding: 20px 16px; }
  .welcome-cta { width: 100%; max-width: 320px; height: 48px; }
  .welcome-tip { font-size: 13.5px; }
  .welcome-tip .arrow.up { animation: tipNudgeUp 1.5s ease-in-out infinite; }
  @keyframes tipNudgeUp { 50% { transform: translateY(-5px); } }

  
  .insp-tabs { padding: 6px 4px 0; }
  .insp-tab { min-height: 44px; padding: 8px 2px; font-size: 12px; }
  .insp-body { padding: 12px 12px calc(24px + env(safe-area-inset-bottom, 0px)); }
  .insp-note { font-size: 13px; }
  .outline { font-size: 14.5px; }
  .outline li, .outline p { padding: 3px 0; }
  .ai-body { font-size: 15px; }
  .ai-frag { font-size: 14px; }
  .meta { font-size: 13.5px; }
  .chip-w {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    font-size: 13px;
  }

  
  .ai-menu {
    top: auto !important;        
    right: 0;
    bottom: 0;
    left: 0 !important;
    z-index: 88;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 30px -12px rgba(0, 0, 0, .45);
    animation: sheetUp .2s cubic-bezier(.2,.9,.3,1) both;
  }
  .ai-menu[hidden] { display: none; }
  .ai-menu::after, .ai-menu-sep { display: none; }   
  .ai-menu-t { flex: 1 0 100%; padding: 0 2px 2px; font-size: 12px; }
  .ai-act {
    flex: 1 1 28%;
    justify-content: center;
    min-height: 48px;
    font-size: 14.5px;
    background: var(--bg);
    border: 1px solid var(--border);
  }
  .ai-act.ghost { flex: 1 0 100%; }
  @keyframes sheetUp {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: none; }
  }

  
  
  .ide-status {
    gap: 10px;
    padding: 0 12px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
  }
  #stKind, #stProject, #stHint, .st-sep { display: none; }
  #stDoc {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #stChars { flex: none; margin-left: auto; }

  
  .palette-wrap { padding: calc(env(safe-area-inset-top, 0px) + 10px) 8px 0; }
  .palette { width: 100%; }
  .palette-in { padding: 14px; }
  .palette-list { max-height: 52dvh; }
  .pal-item { min-height: 48px; font-size: 14.5px; }
  .palette-foot { display: none; }

  
  .menu { left: 8px !important; right: 8px; min-width: 0; max-height: 60dvh; }
  .menu button { min-height: 46px; font-size: 14.5px; }

  .proc { left: 10px; right: 10px; bottom: calc(var(--ide-status) + 10px); width: auto; }
  .toast { bottom: calc(var(--ide-status) + 14px); font-size: 14px; }
  .coach-card { max-height: 84dvh; padding: 20px 18px 18px; }
  .drop-card { padding: 26px 22px; text-align: center; }

  
  input, textarea, select { font-size: 16px; }

  
  .only-d { display: none; }
  span.only-m { display: inline; }
  li.only-m { display: list-item; }
  p.only-m, div.only-m { display: block; }
  .welcome-tip.only-m { display: inline-flex; }
}


@media (max-width: 420px) {
  #openPalette { display: none; }
  .tab { max-width: 60vw; }
  
  .ide-top { gap: 4px; padding-right: 4px; padding-left: 4px; }
  .ide-drawer-btn { width: 46px; }
}


.print-only { display: none; }

@media print {
  @page {
    size: A4;
    
    margin: 20mm 15mm 20mm 30mm;
  }

  
  html, body, .ide-body {
    height: auto;
    overflow: visible;
    background: #fff;
  }
  .ide { display: block; height: auto; }
  .ide-main, .ide-editor, .panes, .doc-page { display: block; }
  .pane, .doc-scroll {
    display: block;
    height: auto;
    min-height: 0;
    overflow: visible;
    background: #fff;
    border: none;
  }

  
  .ide-top, .ide-tree, .ide-inspect, .ide-status,
  .tabs, .pane-bar, .resizer, .doc-tip,
  .ai-menu, .ask-sel, .coach,
  .palette-wrap, .menu, .drop-veil, .proc, .toast,
  .welcome, .sk, .sheet-num, .no-print {
    display: none !important;
  }
  .print-only { display: revert !important; }

  
  .doc-text, .doc-sheet, .doc-editor {
    width: auto;
    max-width: none;
    min-height: 0;
    padding: 0;
    margin: 0;
    color: #000;
    background: #fff;
    border: none;
    border-radius: 0;
    box-shadow: none;
    animation: none;
    
    font-family: "Times New Roman", Times, "Liberation Serif", serif;
    font-size: 12.5pt;
    line-height: 1.5;
  }
  
  .doc-editor > .doc-input { display: none; }
  .doc-editor > .doc-hl { position: static; padding: 0; }
  .doc-editor::before { display: none; }
  .doc-sheet + .doc-sheet { break-before: page; }

  
  .doc-title, .doc-sect, .doc-sub,
  .doc-text h1, .doc-text h2, .doc-text h3 { break-after: avoid; }
  .doc-text p, .doc-p, .doc-text li { orphans: 3; widows: 3; }
  .doc-sign, .doc-text table, .doc-text tr { break-inside: avoid; }

  
  .doc-text mark.hit, .doc-text mark.hit.cur {
    color: #000;
    background: none;
    animation: none;
  }
  .doc-text .low { text-decoration: none; }
  .doc-editor .ln.on, .doc-line.on, .doc-editor .ln.edited {
    background: none;
    box-shadow: none;
  }
  .doc-text .insp-note { border-color: #999; }
}

@media (prefers-reduced-motion: reduce) {
  .ide *, .palette, .drop-card svg, .sk i,
  .ai-menu, .ai-body.streaming::after, .coach, .coach-card,
  .welcome-tip .arrow, .edit-state::before {
    animation: none !important;
    transition: none !important;
  }
}



@media (max-width: 768px) {
  .coach { padding: 0; background: rgba(0, 0, 0, .72); }
  .coach-card {
    
    width: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: calc(env(safe-area-inset-top, 0px) + 24px) 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
    overflow-y: auto;
    border: none;
    border-radius: 0;
  }
}




.insp-pane[data-pane="chat"].active {
  display: flex;
  flex-direction: column;
  min-height: 0;          
  height: 100%;
  padding: 0;
}

.dchat {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.dchat-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dmsg {
  max-width: 100%;
  padding: 8px 10px;
  font-size: 13.4px;
  line-height: 1.6;
  border-radius: 10px;
  overflow-wrap: anywhere;
}

.dmsg.you {
  align-self: flex-end;
  max-width: 92%;
  color: var(--text);
  white-space: pre-wrap;
  background: var(--accent-soft);
  border: 1px solid var(--border);
}

.dmsg.ai {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
}

.dmsg.ai > :first-child { margin-top: 0; }
.dmsg.ai > :last-child { margin-bottom: 0; }


.dmsg.ai.streaming::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1.02em;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--accent);
  animation: dchat-caret 1s steps(2, start) infinite;
}

.dmsg.ai.streaming:empty::before {
  content: "думаю…";
  color: var(--text-dim);
}

@keyframes dchat-caret {
  to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .dmsg.ai.streaming::after { animation: none; }
}

.dchat-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.dchat-in {
  width: 100%;
  min-height: 46px;
  max-height: 160px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13.4px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  resize: none;
}

.dchat-in:focus {
  border-color: var(--accent);
  outline: none;
}

.dchat-in::placeholder { color: var(--text-dim); }

.dchat-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.dchat-row .grow { flex: 1; }



.d-doc {
  font-family: "Times New Roman", "Liberation Serif", Georgia, serif;
  font-size: 16.5px;
  line-height: 1.5;
  color: var(--text);
  text-align: left;
}


.d-head {
  margin: 0 0 2px 0;
  text-align: left;
  line-height: 1.35;
}
.d-head-gap { margin-top: .7em; }

.d-doc .d-head + .d-title { margin-top: 26px; }

.d-title {
  margin: 20px 0 16px;
  font-weight: 700;
  text-align: center;
  text-transform: none;
  letter-spacing: .02em;
}


.d-par {
  margin: 0 0 6px;
  text-indent: 1.25cm;
  text-align: left;
}
.d-subtitle {
  margin: 12px 0 16px;
  text-align: center;
  font-weight: 700;
}


.d-item {
  margin: 0 0 6px;
  padding-left: 1.25cm;
  text-indent: -1.25cm;
  text-align: left;
}

.d-sign {
  margin: 14px 0 0;
  text-align: left;
}

.d-doc .low {
  background: rgba(217, 162, 39, .18);
  border-bottom: 1px dashed rgba(217, 162, 39, .8);
}


@media print {
  @page {
    size: A4 portrait;
    margin: 20mm 15mm 20mm 30mm;
  }

  .ide-top, .ide-tree, .ide-inspect, .ide-status, .tabs, .pane-bar,
  .resizer, .ide-veil, .palette-wrap, .menu, .drop-veil, .toast,
  #welcomeA, #welcomeB, #docTip, .pane[data-pane="b"] {
    display: none !important;
  }

  html, body, .ide, .ide-main, .ide-editor, .panes, .pane,
  .doc-scroll, .doc-page {
    display: block !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .doc-text {
    width: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }

  .d-doc {
    font-family: "Times New Roman", serif;
    font-size: 14pt;
    line-height: 1.5;
    color: #000;
  }

  .d-title { font-size: 14pt; }

  
  .d-title { break-after: avoid; }
  .d-par, .d-item { orphans: 2; widows: 2; }

  .d-doc .low { background: none; border-bottom: 0; }
}



.d-doc .d-head   { text-align: left;   text-indent: 0; }
.d-doc .d-title  { text-align: center; text-indent: 0; }
.d-doc .d-subtitle { text-align: center; text-indent: 0; font-weight: 700; }
.d-doc .d-par    { text-align: left;   text-indent: 1.25cm; }
.d-doc .d-item   { text-align: left;   text-indent: -1.25cm; }
.d-doc .d-sign   { text-align: left;   text-indent: 0; }
