:root {
  --bg: #1c1c1c;
  --bg-2: #141414;
  --line: #2c2c2c;
  --text: #e6e6e6;
  --dim: #8a8a8a;
  --faint: #5e5e5e;
  --orange: #e08a45;
  --select: #2a2a2a;
  color: var(--text);
  background: var(--bg);
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 1px solid var(--orange);
  outline-offset: 2px;
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.term {
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}

.bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.dots { display: flex; gap: 0.35rem; }
.dots i {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  display: block;
}
.dots i:nth-child(1) { background: #e06a5e; }
.dots i:nth-child(2) { background: #d6b15a; }
.dots i:nth-child(3) { background: #6aaa64; }

.title { color: var(--dim); }
.title b { color: var(--text); font-weight: 500; }

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.35rem 0.6rem 0;
  overflow-x: auto;
}

.domain {
  display: inline-flex;
  gap: 0.45rem;
  align-items: baseline;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  color: var(--dim);
}

.domain em {
  font-style: normal;
  color: var(--faint);
  font-size: 12px;
}

.domain.is-active {
  background: #333;
  color: var(--text);
}

.hint {
  margin: 0;
  padding: 0.15rem 0.85rem 0.35rem;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
}

body.has-files:not(.has-editor) .workspace {
  grid-template-columns: minmax(0, 1fr) 5px minmax(160px, var(--pane-tree, 240px));
}

body.has-editor .workspace {
  grid-template-columns: minmax(160px, var(--pane-chat, 1fr)) 5px minmax(180px, var(--pane-editor, 1.35fr)) 5px minmax(150px, var(--pane-tree, 230px));
}

.split {
  display: none;
  cursor: col-resize;
  background: transparent;
  touch-action: none;
  position: relative;
}

.split::before {
  content: "";
  position: absolute;
  inset: 0 -3px;
}

body.has-files #split-tree,
body.has-editor #split-editor,
body.has-editor #split-tree { display: block; }

.split[hidden] { display: none !important; }

.split:hover,
.split.is-dragging,
.split:focus-visible { background: var(--orange); }

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

.log {
  overflow: auto;
  min-height: 0;
  padding: 0.2rem 0 0.6rem;
}

.tree,
.editor {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: #181818;
}

.tree[hidden],
.editor[hidden] { display: none; }

.editor { background: #1e1e1e; }

.tree-head {
  display: block;
  padding: 0.35rem 0.55rem;
  border-bottom: 1px solid var(--line);
}

.tree-head input {
  width: 100%;
  background: #252526;
  border: 1px solid #3c3c3c;
  border-radius: 4px;
  padding: 0.22rem 0.4rem;
  color: var(--text);
}

.tree-head input:focus { outline: none; border-color: #555; }

.tree-body,
.editor-body {
  overflow: auto;
  min-height: 0;
  flex: 1;
}

.tree-body details > summary { list-style: none; }
.tree-body details > summary::-webkit-details-marker { display: none; }
.tree-body summary::before { content: "▸  "; color: var(--faint); }
.tree-body details[open] > summary::before { content: "▾  "; }

.tree-item {
  display: block;
  width: 100%;
  text-align: left;
  padding-top: 0.08rem;
  padding-bottom: 0.08rem;
  padding-right: 0.45rem;
  color: #cccccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-item:hover { background: #2a2d2e; }
.tree-item.is-active { background: #37373d; color: #fff; }

.editor-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.28rem 0.6rem;
  background: #252526;
  border-bottom: 1px solid var(--line);
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
}

.editor-tab > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-meta { color: var(--dim); flex: none; }

.editor-tab button { color: var(--dim); padding: 0 0.2rem; }
.editor-tab button:hover { color: var(--text); }

.grid-wrap { min-width: min-content; }

.grid {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  line-height: 1.35;
}

.grid th,
.grid td {
  padding: 0.16rem 0.55rem;
  border-bottom: 1px solid #2a2a2a;
  border-right: 1px solid #242424;
  white-space: nowrap;
  vertical-align: top;
}

.grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #252526;
  color: #d0d0d0;
  font-weight: 500;
  text-align: left;
}

.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }

.grid .rownum {
  position: sticky;
  left: 0;
  z-index: 1;
  color: #5a5a5a;
  background: #1a1a1a;
  text-align: right;
  user-select: none;
}

.grid th.rownum { z-index: 2; background: #1a1a1a; }

.grid tbody tr:hover td { background: #2a2d2e; }
.grid tbody tr:hover td.rownum { background: #222; }

.pdf {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #141414;
}

.pdf-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.28rem 0.6rem;
  border-bottom: 1px solid var(--line);
  background: #252526;
  color: var(--dim);
}

.pdf-bar button { color: var(--text); padding: 0 0.25rem; }
.pdf-bar button:disabled { opacity: 0.35; cursor: default; }

.pdf-stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 0.8rem;
}

.pdf-stage canvas {
  box-shadow: 0 0 0 1px #333;
  background: #fff;
}

.doc {
  height: 100%;
  min-height: 0;
  background: #fff;
}

.doc-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.deck {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.8rem;
  background: #141414;
}

.slide-wrap { display: flex; flex-direction: column; gap: 0.25rem; }

.slide-index { color: var(--faint); font-size: 11px; }

.slide {
  position: relative;
  width: 100%;
  container-type: inline-size;
  background: #fff;
  box-shadow: 0 0 0 1px #333;
  overflow: hidden;
}

.slide-shape {
  position: absolute;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  line-height: 1.15;
  padding: 0.2em 0.35em;
}

.slide-shape p { margin: 0; white-space: pre-wrap; }

.slide-shape img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.slide-table {
  width: 100%;
  height: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.slide-table td {
  border: 1px solid rgba(128, 128, 128, 0.35);
  vertical-align: top;
  padding: 0.12em 0.28em;
}

.book-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  flex-wrap: wrap;
}

.book-bar button.is-active { color: var(--orange); }

.sheet {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 100%;
}

.gutter {
  margin: 0;
  padding: 0.55rem 0.55rem 0.55rem 0.4rem;
  text-align: right;
  color: #5a5a5a;
  background: #1a1a1a;
  border-right: 1px solid #2a2a2a;
  user-select: none;
  white-space: pre;
  line-height: 1.5;
  font-size: 12px;
}

.editor-body .code {
  margin: 0;
  max-height: none;
  min-height: 100%;
  background: transparent;
  padding: 0.55rem 0.75rem;
}

.entry {
  display: grid;
  grid-template-columns: 1rem minmax(0, 1fr);
  gap: 0.35rem;
  width: 100%;
  text-align: left;
  padding: 0.22rem 0.75rem;
  border-radius: 0;
}

.entry:hover { background: var(--select); }

.mark {
  color: var(--dim);
  user-select: none;
}

.entry:hover .mark,
.entry:focus-visible .mark { color: var(--text); }

.cmd { display: block; color: var(--text); }
.sub { display: block; color: var(--dim); }

.who {
  color: var(--orange);
  margin-bottom: 0.15rem;
}

.prose p {
  margin: 0.35rem 0;
  max-width: 88ch;
  white-space: pre-wrap;
}

.prose code,
.fn code {
  color: #f0c38a;
}

.code {
  margin: 0.35rem 0;
  padding: 0.45rem 0.65rem;
  background: var(--bg-2);
  overflow: auto;
  max-height: 24rem;
  font-size: 12px;
  line-height: 1.5;
}

.code code {
  display: block;
  white-space: pre;
  font-family: inherit;
}

.kv {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 0.05rem 0.75rem;
  color: var(--dim);
}

.kv b {
  font-weight: 400;
  color: var(--text);
  overflow-wrap: anywhere;
}

.nest { color: var(--dim); padding: 0.05rem 0 0.05rem 0.2rem; }
.nest .name { color: var(--text); }

.check { padding: 0.28rem 0; }
.check p { margin: 0.1rem 0 0; max-width: 88ch; color: var(--dim); }
.check summary,
.env-fold summary { cursor: pointer; color: var(--orange); }

.env-fold { margin: 0.2rem 0.75rem 0.8rem 2.1rem; }

.file {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  text-align: left;
  padding: 0.12rem 0;
  color: var(--dim);
}

.file:hover { color: var(--text); }
.file small { color: var(--faint); }
.file:disabled { color: var(--faint); cursor: default; }

.block {
  padding: 0.15rem 0.75rem 0.45rem 2.1rem;
}

.note { color: var(--dim); padding: 0.4rem 0.75rem; }

.status {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  border-top: 1px solid var(--line);
  padding: 0.4rem 0.75rem;
  color: var(--dim);
}

.find {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 8rem;
}

.prompt { color: var(--orange); }

.search { flex: 1; }

.search input {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 0;
}

.search input:focus { outline: none; }
.search input::placeholder { color: var(--faint); }

#range { white-space: nowrap; }

.keys { display: flex; gap: 0.7rem; }
.keys button { color: var(--dim); }
.keys button:hover { color: var(--text); }
.keys button:disabled { color: var(--faint); cursor: default; }

.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in { color: #ff7b72; }

.hljs-string,
.hljs-addition,
.hljs-doctag { color: #a5d6a7; }

.hljs-number,
.hljs-literal,
.hljs-type { color: #d2a8ff; }

.hljs-comment,
.hljs-quote { color: #6e7681; }

.hljs-title,
.hljs-function,
.hljs-section { color: #d2a8ff; }

.hljs-attr,
.hljs-attribute,
.hljs-variable,
.hljs-name { color: #79c0ff; }

.hljs-deletion { color: #ffa198; background: transparent; }

.hljs-meta,
.hljs-meta .hljs-keyword { color: #8b949e; }

.hljs-params,
.hljs-symbol { color: #e6edf3; }

@media (max-width: 800px) {
  .kv { grid-template-columns: 1fr; }
  .keys { gap: 0.45rem; }
  #range { display: none; }
  .split { display: none !important; }
  body.has-files .workspace,
  body.has-editor .workspace {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(0, 1fr) minmax(160px, 34vh) minmax(140px, 28vh);
  }
  .editor { order: 2; }
  .tree { order: 3; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
