:root {
  --bg: #16130f;
  --fg: #e8dfd0;
  --dim: #7d7264;
  --accent: #e2884a;
  --line: #221d17;
  --kw: #d9775a;
  --str: #a9b665;
  --fn: #e2b04a;
  --num: #c58fd6;
  --rule: color-mix(in srgb, var(--fg) 14%, transparent);
  --chrome: color-mix(in srgb, var(--fg) 55%, var(--bg));
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --serif: "Instrument Serif", Georgia, serif;
  --cell: 13px;
  --row: 20px;
  --max: 1320px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 var(--cell)/var(--row) var(--mono);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s, color 0.25s;
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
::selection { background: var(--accent); color: var(--bg); }

.stage {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  width: 100%;
  max-width: var(--max);
  height: 100dvh;
  margin: 0 auto;
  padding: 22px 28px 18px;
}

/* header */
.top { display: flex; align-items: baseline; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 600; letter-spacing: 0.02em; }
.brand svg { width: 22px; height: 22px; fill: var(--accent); align-self: center; }
.tagline { margin: 0; flex: 1; font: italic 400 17px/1 var(--serif); color: var(--dim); }
.links { display: flex; gap: 16px; }
.links a { color: var(--chrome); }
.links a:hover { color: var(--accent); }

/* editor: wheel | pane | eye */
.editor {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 300px;
  min-height: 0;
}
.tabline, .tree { display: none; }

/* wheel */
.wheel {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--rule);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.wheel.is-dragging { cursor: grabbing; }
.wheel-ink { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.wheel-list { position: absolute; inset: 0 0 0 70px; margin: 0; padding: 0; list-style: none; }
.wheel-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 196px;
  padding: 0;
  border: 1px solid var(--rule);
  background: var(--line);
  transform-origin: 0 50%;
  will-change: transform;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.wheel-card img, .wheel-card canvas { display: block; width: 100%; aspect-ratio: 8 / 5; object-fit: cover; object-position: top; pointer-events: none; }
.wheel-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2px 8px;
  text-align: left;
  background: linear-gradient(transparent, color-mix(in srgb, var(--bg) 88%, transparent) 40%);
  color: var(--chrome);
}
.wheel-card.is-current { border-color: var(--fg); box-shadow: 0 12px 30px -16px rgb(0 0 0 / 0.7); }
.wheel-card.is-current .wheel-cap { color: var(--fg); }
.wheel-marker {
  position: absolute;
  top: 50%;
  left: 280px;
  transform: translateY(-50%);
  color: var(--fg);
  pointer-events: none;
}
.wheel-hint { position: absolute; left: 78px; bottom: 6px; margin: 0; color: var(--dim); pointer-events: none; }

/* pane */
.pane { display: grid; grid-template-rows: auto 1fr; min-width: 0; min-height: 0; padding-left: 28px; }
.winbar {
  margin: 0;
  padding: 0 0 10px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.buffer {
  overflow-y: auto;
  padding: 4px 4px 48px 0;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

/* eye gutter */
.gutter { display: flex; justify-content: center; padding-top: 30px; min-height: 0; overflow: hidden; pointer-events: none; }
.eye { display: block; }

/* buffer content */
.ln { min-height: var(--row); }
.prompt-user { color: var(--accent); }
.prompt-path { color: var(--fn); }
.prompt-branch { color: var(--dim); }
.cmd-text { color: var(--fg); font-weight: 600; }
.caret { display: inline-block; width: 1ch; background: var(--fg); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.out { color: var(--chrome); }
.k { color: var(--kw); }
.s { color: var(--str); }
.f { color: var(--fn); }
.n { color: var(--num); }
.d { color: var(--dim); }
.h { color: var(--accent); font-weight: 600; }
.err { color: var(--kw); }
.ok { color: var(--str); }
.bar-fill { color: var(--accent); }
.bar-empty { color: var(--rule); }
.buffer a { color: var(--fn); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.buffer a:hover { text-decoration-color: var(--fn); }
.buffer button.ls { color: var(--fn); }
.buffer button.ls:hover { text-decoration: underline; }

/* bottom bar */
.bar {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 40px;
  padding-top: 12px;
  border-top: 1px solid var(--chrome);
}
.bar p { margin: 0; }
.bar-id { min-width: 300px; }
.bar-title { color: var(--fg); letter-spacing: 0.12em; }
.cmdline { display: flex; gap: 0; white-space: nowrap; color: var(--dim); }
.cmdline .cmd { color: var(--fg); }
.cmdline .cmd:empty + .hint { display: inline; }
.cmdline .cmd:not(:empty) + .hint { display: none; }
.cmdline .cmd.err { color: var(--kw); }
.bar.is-command .cmd::after { content: " "; display: inline-block; width: 1ch; background: var(--fg); animation: blink 1s steps(1) infinite; }
.bar-cols { display: flex; gap: 36px; }
.col { display: grid; gap: 2px; }
.label { font-size: 11px; letter-spacing: 0.14em; color: var(--dim); }
.value { font-size: 17px; line-height: 22px; color: var(--fg); }
.stats .value { color: var(--accent); }
.bar-server { margin-left: auto; text-align: right; display: grid; gap: 2px; }
.bar-server .value .dot { color: var(--str); }
.bar-server .value .dot.down { color: var(--kw); }
.cmd-input { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 1180px) {
  .editor { grid-template-columns: 280px minmax(0, 1fr); }
  .gutter { display: none; }
  .bar-id { min-width: 0; }
}

@media (max-width: 860px) {
  .state { display: none; }
}

@media (max-width: 700px) {
  :root { --cell: 12px; --row: 19px; }
  .stage { padding: 16px 16px 10px; gap: 12px; }
  .tagline { display: none; }
  .top { justify-content: space-between; }
  .wheel {
    display: none;
    position: absolute;
    inset: 33px 0 0 0;
    z-index: 2;
    border-right: 0;
    background: var(--bg);
  }
  .editor.drawer-open .wheel { display: block; }
  .wheel-card { width: 210px; }
  .wheel-marker { left: 300px; }
  .editor {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    position: relative;
    border: 1px solid var(--rule);
    border-radius: 6px;
    overflow: hidden;
  }
  .tabline {
    display: flex;
    padding: 6px 14px;
    border-bottom: 1px solid var(--rule);
    text-align: left;
    color: var(--dim);
  }
  .tab-file { color: var(--fg); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab-toggle { color: var(--accent); }
  .tree {
    position: absolute;
    inset: 33px 0 0 0;
    z-index: 2;
    overflow-y: auto;
    padding: 10px 0;
    background: var(--bg);
  }
  .editor.drawer-open .tree { display: none; }
  .tree .root { padding: 0 14px 6px; color: var(--dim); margin: 0; }
  .tree button { display: flex; gap: 8px; width: 100%; padding: 0 14px; text-align: left; line-height: 30px; color: var(--chrome); }
  .tree button .glyph { width: 1.2ch; color: var(--dim); }
  .tree button .warn-pill {
    font-size: 10px;
    line-height: 14px;
    height: 14px;
    min-width: 14px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--kw);
    color: var(--bg);
    font-weight: 600;
    text-align: center;
    align-self: center;
  }
  .tree button .date { margin-left: auto; color: var(--dim); font-size: 11px; }
  .tree button.child { padding-left: calc(14px + 2.4ch); }
  .tree button.is-cursor, .tree button.is-open { background: var(--line); color: var(--fg); }
  .tree .sep { height: 1px; margin: 8px 14px; background: var(--rule); }
  .pane { padding: 0; }
  .winbar { display: none; }
  .buffer { padding: 12px 14px 32px; }
  .bar { gap: 16px; padding-top: 8px; }
  .bar-id .cmdline .hint, .stats { display: none; }
  .value { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .caret, .bar.is-command .cmd::after { animation: none; }
  body { transition: none; }
}
