:root {
  --page: #ffffff;
  --frame: #ffffff;
  --side: #fafafa;
  --line: rgba(17, 17, 20, 0.08);
  --ink: #18181b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --accent: #2f6bff;
  --accent-soft: rgba(47, 107, 255, 0.45);
  --accent-halo: rgba(47, 107, 255, 0.18);
  --code-key: #7c3aed;
  --code-str: #0f8a5f;
  --code-fn: #2f6bff;
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.split {
  position: relative;
  width: min(680px, 92vw);
  height: min(340px, 74vh);
  -webkit-user-select: none;
  user-select: none;
}

.split__frame {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: var(--frame);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(17, 17, 20, 0.04), 0 12px 32px -12px rgba(17, 17, 20, 0.14), 0 32px 64px -32px rgba(17, 17, 20, 0.1);
  overflow: hidden;
  touch-action: pan-y;
}

/* the three panes: absolute, their left and width are written by the script on every frame */
.pane {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  container-type: inline-size;
}

.pane--files, .pane--preview { background: var(--side); }

.pane__in {
  position: absolute;
  inset: 0;
  min-width: 0;
  transition: opacity .25s ease, filter .25s ease;
}

.pane__head {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 560;
  letter-spacing: .01em;
  color: var(--muted);
  white-space: nowrap;
}

.pane__tab {
  color: var(--ink);
  font-weight: 600;
  padding: 4px 9px;
  margin-left: -9px;
  border-radius: 8px;
  background: rgba(17, 17, 20, 0.045);
}

/* Files */
.tree { list-style: none; padding: 8px 6px; }

.tree__row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 480;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}

.tree__row svg {
  flex: none;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linejoin: round;
}

.tree__row--dir { color: var(--ink); font-weight: 560; }
.tree__row:not(.tree__row--dir) { padding-left: 20px; }
.tree__row--on { background: #ffffff; color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(17, 17, 20, 0.05); }
.tree__row--on svg { color: var(--accent); }

@container (max-width: 104px) {
  .tree__row span { display: none; }
  .tree__row, .tree__row:not(.tree__row--dir) { padding: 0; gap: 0; justify-content: center; }
  .pane__head { justify-content: center; padding: 0; }
}

@container (max-width: 44px) {
  .pane__in { opacity: 0; filter: blur(2px); }
}

/* Editor */
.code {
  padding: 12px 0;
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 12px;
  line-height: 22px;
  color: var(--ink);
  white-space: pre;
  overflow: hidden;
}

.ln {
  display: inline-block;
  width: 34px;
  padding-right: 12px;
  text-align: right;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.k { color: var(--code-key); }
.s { color: var(--code-str); }
.f { color: var(--code-fn); }
.n { color: #c2410c; }

/* Preview: the invoice card the code renders */
.mini {
  margin: 14px;
  padding: 14px;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 0 0 1px var(--line), 0 6px 16px -8px rgba(17, 17, 20, 0.16);
  display: grid;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
}

.mini__who { font-size: 11px; font-weight: 560; color: var(--muted); }
.mini__sum { font-size: 20px; font-weight: 640; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.mini__due { font-size: 11px; color: var(--faint); }
.mini__btn {
  margin-top: 10px;
  height: 30px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 11.5px;
  font-weight: 560;
  display: grid;
  place-items: center;
}

@container (max-width: 130px) {
  .mini { margin: 10px 8px; padding: 10px; }
  .mini__sum { font-size: 15px; }
  .mini__btn { font-size: 0; height: 22px; }
}

/* the snap lines at 25, 50 and 75: they appear only while a handle comes close */
.guide {
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 0;
  border-left: 1px dashed var(--accent);
  opacity: 0;
  pointer-events: none;
}

/* the handles: a hit area 18 pixels wide around a hairline */
.handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 18px;
  margin-left: -9px;
  cursor: col-resize;
  touch-action: none;
  outline: none;
  z-index: 2;
}

.handle__line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  margin-left: -.5px;
  background: var(--line);
  transition: background .2s ease, width .2s cubic-bezier(.3, 1.4, .5, 1), margin-left .2s cubic-bezier(.3, 1.4, .5, 1);
}

.handle__grip {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 28px;
  margin: -14px 0 0 -2px;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(17, 17, 20, 0.14), 0 2px 6px rgba(17, 17, 20, 0.12);
  opacity: 0;
  transform: scale(.6);
  transition: opacity .2s ease, transform .3s cubic-bezier(.3, 1.5, .5, 1), background .2s ease, box-shadow .2s ease;
}

.handle.is-hover .handle__line, .handle:focus-visible .handle__line {
  width: 3px;
  margin-left: -1.5px;
  background: var(--accent-soft);
}
.handle.is-hover .handle__grip, .handle:focus-visible .handle__grip { opacity: 1; transform: scale(1); }

.handle.is-active .handle__line { width: 3px; margin-left: -1.5px; background: var(--accent); }
.handle.is-active .handle__grip {
  opacity: 1;
  transform: scale(1.06, var(--squash, 1));
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-halo), 0 2px 8px rgba(47, 107, 255, 0.35);
}

@media (hover: hover) {
  .handle:hover .handle__line { width: 3px; margin-left: -1.5px; background: var(--accent-soft); }
  .handle:hover .handle__grip { opacity: 1; transform: scale(1); }
  .handle.is-active:hover .handle__line { background: var(--accent); }
}

.split.is-dragging, .split.is-dragging * { cursor: col-resize; }

/* the percentage that follows the handle while you drag */
.pill {
  position: absolute;
  top: -38px;
  left: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--ink);
  color: rgba(255, 255, 255, 0.62);
  font-size: 11.5px;
  font-weight: 520;
  line-height: 26px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 18px -6px rgba(17, 17, 20, 0.4);
  opacity: 0;
  z-index: 3;
}

.pill b { color: #fff; font-weight: 620; font-variant-numeric: tabular-nums; }

/* the demo pointer of the autopilot */
.ghost {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  margin: -3px 0 0 -5px;
  pointer-events: none;
  overflow: visible;
  opacity: 0;
  z-index: 4;
  filter: drop-shadow(0 2px 3px rgba(17, 17, 20, 0.25));
}

.ghost [data-ghost-arrow] path { fill: var(--ink); stroke: #fff; stroke-width: 1.4; stroke-linejoin: round; }
.ghost [data-ghost-resize] { opacity: 0; }
.ghost__bars { stroke: #fff; stroke-width: 4.4; stroke-linecap: round; fill: none; }
.ghost__arrows { stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; fill: none; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .handle__line, .handle__grip, .pane__in { transition: opacity .2s ease, background .2s ease; }
}
