:root { color-scheme: light; }
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
  background: #f5f5f5;
  color: #171717;
}
button, input, textarea, select { font: inherit; color: inherit; }
button, a { cursor: pointer; }
button, .ghost, header a {
  border-radius: 10px;
  padding: 8px 14px;
  border: 0;
  text-decoration: none;
}
button { background: #171717; color: #fff; }
button.ghost, a.ghost, header a {
  background: #fff;
  color: #171717;
  border: 1px solid #e6e6e6;
}
button:hover { background: #333; }
button.ghost:hover, a.ghost:hover, header a:hover { background: #f3f3f3; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.card {
  width: min(420px, 100%);
  background: #fff;
  padding: 28px;
  border: 1px solid #ececec;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .04);
}
.card.wide { width: min(560px, 100%); }
.card h1 { margin: 0 0 8px; font-size: 22px; font-weight: 650; }
.card h2 { margin: 18px 0 8px; font-size: 15px; font-weight: 650; }
.card h2:first-of-type { margin-top: 4px; }
.hint { margin: 0 0 16px; color: #737373; }
.err { margin: 0 0 16px; color: #171717; }
label { display: block; margin-bottom: 12px; color: #404040; }
input, textarea, select {
  width: 100%;
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
  padding: 8px 10px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid #e5e5e5; border-color: #d4d4d4; }
.card a { color: #171717; }

.app { height: 100vh; display: flex; flex-direction: column; }
header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #ececec;
}
header strong { font-size: 15px; }
header span { flex: 1; color: #737373; }
main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--col-left, 248px) 12px minmax(0, 1fr) 12px var(--col-right, 380px);
  padding: 12px;
}
button.split {
  width: 100%;
  height: 100%;
  min-width: 0;
  position: relative;
  cursor: col-resize;
  touch-action: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: transparent;
}
button.split:hover { background: transparent; }
.split::before {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 5px;
  width: 2px;
  border-radius: 1px;
  background: #e5e5e5;
}
.split:hover::before, .split.drag::before { background: #a3a3a3; }
body.col-drag, body.col-drag * { cursor: col-resize; user-select: none; }
aside, .editor-pane, .chat {
  min-width: 0;
  min-height: 0;
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 16px;
  overflow: hidden;
}
aside { overflow: auto; }
.ver {
  position: sticky;
  top: 0;
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
}
.ver button { width: 100%; }
#files { padding: 8px; }
#files button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: #262626;
  border: 0;
  border-radius: 8px;
  padding: 7px 8px;
}
#files button:hover { background: #f5f5f5; }
#files button.on { background: #f0f0f0; font-weight: 650; }

.editor-pane, .chat { display: flex; flex-direction: column; }
.bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
}
#path { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #525252; }
#diag {
  display: block;
  width: 100%;
  text-align: left;
  background: #fde8e6;
  color: #7f1d1d;
  border: 0;
  border-radius: 0;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.45;
}
#diag:hover { background: #fbd5d2; }
#diag[hidden] { display: none; }
#save:disabled { opacity: .4; cursor: not-allowed; }
.code { position: relative; flex: 1; min-height: 0; background: #fff; }
#gutter {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  left: 0;
  width: 52px;
  overflow: hidden;
  background: #fafafa;
  border-right: 1px solid #f0f0f0;
  color: #a3a3a3;
  padding: 14px 0 28px;
  font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: right;
  user-select: none;
}
#gutter div { padding-right: 8px; }
#gutter .bad { color: #b42318; background: #fde8e6; font-weight: 650; }
.code pre, .code textarea {
  position: absolute;
  inset: 0;
  margin: 0;
  border: 0;
  padding: 14px 16px 28px 64px;
  font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}
.code pre { pointer-events: none; color: #262626; }
.code textarea {
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: #171717;
  -webkit-text-fill-color: transparent;
  border-radius: 0;
}
.code textarea:focus { outline: none; }
.code textarea::placeholder { color: #a3a3a3; -webkit-text-fill-color: #a3a3a3; }
.tok-kw { color: #7c3aed; font-weight: 650; }
.tok-cm { color: #3f7f4a; }
.tok-str { color: #b42318; }
.tok-num { color: #0369a1; }
.tok-id { color: #1f2328; }
#complete {
  position: absolute;
  z-index: 3;
  margin: 0;
  padding: 4px;
  list-style: none;
  min-width: 180px;
  max-height: 220px;
  overflow: auto;
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .06);
}
#complete[hidden] { display: none; }
#complete li { padding: 6px 8px; border-radius: 8px; color: #262626; }
#complete li.on, #complete li:hover { background: #f3f3f3; }

#log { flex: 1; overflow: auto; padding: 14px; }
.note { margin: 0 0 10px; color: #737373; font-size: 12px; }
.note.err { color: #171717; }
.bubble {
  margin: 0 0 10px;
  padding: 10px 12px;
  background: #f5f5f5;
  border-radius: 14px;
  white-space: pre-wrap;
}
.turn { margin: 0 0 14px; }
.tools:empty, .think[hidden], .answer:empty { display: none; }
.tool {
  margin: 0 0 8px;
  padding: 8px 10px;
  background: #f7f7f7;
  border-radius: 12px;
  font-size: 12px;
  color: #525252;
}
.tool b { color: #171717; font-weight: 650; }
.tool .st { margin-left: 8px; color: #a3a3a3; }
.tool pre { margin: 6px 0 0; white-space: pre-wrap; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.think {
  margin: 0 0 8px;
  padding: 8px 12px;
  border: 1px solid #eee;
  border-radius: 12px;
  background: #fafafa;
  color: #525252;
}
.think summary { cursor: pointer; color: #737373; font-size: 12px; }
.answer { padding-top: 2px; }
.md p { margin: 0 0 8px; }
.md h1, .md h2, .md h3 { margin: 10px 0 6px; font-size: 14px; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 18px; }
.md code { background: #f3f3f3; border-radius: 4px; padding: 1px 4px; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; }
.md pre { margin: 0 0 8px; padding: 10px; background: #f6f6f6; border-radius: 10px; overflow: auto; }
.md pre code { background: transparent; padding: 0; }
.md a { color: #171717; }
.md-table { margin: 0 0 10px; overflow-x: auto; }
.md table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 13px; line-height: 1.5; }
.md th, .md td { border-bottom: 1px solid #eee; padding: 6px 8px; text-align: left; vertical-align: top; }
.md th { color: #737373; font-weight: 650; white-space: nowrap; }
.md td:first-child, .md td:nth-child(2) { white-space: nowrap; }
.md td:last-child { min-width: 16em; max-width: 28em; }
#ask {
  position: relative;
  flex: none;
  margin: 10px 12px 12px;
  padding: 12px 12px 46px;
  border: 1px solid #e4e4e4;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
#ask:focus-within { border-color: #d0d0d0; }
#prompt {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 2px 4px 0;
  border: 0;
  border-radius: 0;
  resize: none;
  background: transparent;
  line-height: 1.5;
}
#prompt:focus { outline: none; }
#ask button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  background: #2f6fed;
  display: grid;
  place-items: center;
}
#ask button:hover { background: #1d5de0; }
#ask button svg { display: block; }
