:root {
  --bg:        #0a0a0e;
  --bg-2:      #121118;
  --bg-3:      #1d1a28;
  --sub:       #5b556e;
  --sub-alt:   #37324a;
  --text:      #e6e2f2;
  --accent:    #b478ff;
  --accent-dim:#7a4fd0;
  --err:       #ff5c8a;
  --err-bg:    #4a1730;
  --ok:        #e6e2f2;
  --radius:    10px;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Lexend", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--bg-2);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.brand:hover .name { filter: brightness(1.15); }
.brand:hover .logo { filter: brightness(1.15); }
.logo { flex: 0 0 auto; display: block; }
.logo-caret { animation: blink 1s steps(1) infinite; }
.name { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.accent { color: var(--accent); }
.tag { color: var(--sub); font-size: 13px; margin-left: 6px; }
.topbar-actions { display: flex; gap: 8px; }

button {
  font-family: var(--sans);
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  padding: 8px 14px;
  transition: background .12s, color .12s, transform .05s;
}
button:active { transform: translateY(1px); }
.ghost { background: var(--bg-3); color: var(--text); }
.ghost:hover { background: var(--sub-alt); }
.ghost.small { padding: 6px 10px; font-size: 12px; }
.primary { background: var(--accent); color: #1c1c1c; font-weight: 600; }
.primary:hover { filter: brightness(1.08); }

/* ---------- layout ---------- */
.layout { flex: 1 1 auto; display: flex; min-height: 0; }

.sidebar {
  flex: 0 0 240px;
  border-right: 1px solid var(--bg-2);
  display: flex; flex-direction: column;
  min-height: 0;
}
.sidebar.collapsed { display: none; }
#btn-sidebar.active { background: var(--accent-dim); color: #fff; }
.sidebar-head {
  display: flex; justify-content: space-between;
  padding: 14px 16px 8px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--sub);
}
.muted { color: var(--sub); }
.filelist { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1 1 auto; }
.filelist li {
  padding: 7px 10px; border-radius: 7px; font-family: var(--mono);
  font-size: 12.5px; color: var(--sub); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 7px;
}
.filelist li:hover { background: var(--bg-2); color: var(--text); }
.filelist li.active { background: var(--bg-3); color: var(--accent); }
.filelist li .fi-ext { color: var(--sub-alt); font-size: 11px; }
.filelist li.active .fi-ext { color: var(--accent); opacity: .7; }

/* the file list, stats HUD and sidebar toggle only exist while typing a file */
body:not(.typing) .hud,
body:not(.typing) .sidebar,
body:not(.typing) .progbar,
body:not(.typing) #btn-sidebar { display: none; }

/* ---------- progress bar (under the HUD) ---------- */
.progbar { flex: 0 0 auto; height: 2px; background: var(--bg-2); }
.progbar-fill {
  height: 100%; width: 0; background: var(--accent);
  box-shadow: 0 0 8px var(--accent-dim);
  transition: width .18s ease;
}

/* ---------- stage ---------- */
.stage { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; position: relative; }

.hud {
  display: flex; align-items: center; gap: 26px;
  padding: 14px 26px; color: var(--sub);
  border-bottom: 1px solid var(--bg-2);
}
.hud-item { display: flex; align-items: baseline; gap: 6px; }
.hud-val { font-family: var(--mono); font-size: 20px; color: var(--accent); font-weight: 500; min-width: 1ch; }
.hud-lbl { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.hud-file { font-family: var(--mono); font-size: 13px; color: var(--sub); margin-left: auto; }
.hud button { margin-left: 12px; }

.typer-wrap {
  flex: 1 1 auto; overflow-y: auto; padding: 48px 8vw 40vh;
  outline: none; position: relative; scroll-behavior: smooth;
}
.typer {
  margin: 0;
  font-family: var(--mono);
  font-size: 22px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 4;
  /* kill programming ligatures — you must type "<=" not see a fused "≤" */
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0, "calt" 0, "dlig" 0;
}

/* per-character states */
.c { position: relative; transition: color .05s, opacity .05s; }
.c.pending { opacity: .38; }          /* not yet typed: dim syntax color */
.c.ok      { opacity: 1; }            /* typed correctly: full syntax color */
.c.auto    { opacity: .30; }          /* auto-filled indentation / blank lines */
.c.cmt     { opacity: .62 !important; font-style: italic; } /* comment: read it, don't type it */
.c.err {
  opacity: 1; color: var(--err) !important;
  background: var(--err-bg); border-radius: 3px;
}
/* error on whitespace/newline: show a marker */
.c.err.ws::before { content: "·"; position: absolute; left: 0; color: var(--err); opacity: .8; }

/* caret — a single element that slides between characters (see moveCaret) */
.caret {
  position: absolute; left: 0; top: 0; width: 2px;
  background: var(--accent); border-radius: 2px;
  opacity: 0; pointer-events: none; will-change: transform, height;
  transition: transform .08s ease, height .08s ease;
}
.caret.blink { animation: blink 1s steps(1) infinite; }
.caret.no-anim { transition: none; }
@keyframes blink { 50% { opacity: 0; } }
/* newline hint when it's the current slot */
.c.cur.nl::after {
  content: " ↵"; color: var(--accent); opacity: .6; font-size: .8em;
}

/* Prism token colors — purple/black palette (synthwave-ish) */
.tok-comment, .tok-prolog, .tok-doctype, .tok-cdata { color: #6b6488; font-style: italic; }
.tok-punctuation { color: #b0a8cc; }
.tok-keyword, .tok-boolean, .tok-atrule, .tok-important { color: #c99bff; }
.tok-string, .tok-char, .tok-attr-value, .tok-regex { color: #ff9ecb; }
.tok-number { color: #7ee0c8; }
.tok-function, .tok-method { color: #e4d16b; }
.tok-class-name, .tok-maybe-class-name { color: #8be9fd; }
.tok-builtin, .tok-tag { color: #d08bff; }
.tok-operator { color: #d7cbef; }
.tok-property, .tok-constant, .tok-symbol { color: #b8a6ff; }
.tok-variable, .tok-parameter { color: #cfc2f5; }
.tok-attr-name, .tok-selector { color: #b8a6ff; }
.tok-deleted { color: var(--err); }
.tok-decorator, .tok-annotation { color: #e4d16b; }

/* placeholder */
.placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; text-align: center;
  padding: 20px;
}
.placeholder[hidden] { display: none; }
.ph-big { font-size: 22px; color: var(--text); }
.ph-sub { font-size: 14px; color: var(--sub); max-width: 460px; line-height: 1.5; }

/* landing */
.landing { max-width: 760px; width: 100%; text-align: center; }
.landing-title { font-size: 30px; font-weight: 600; margin: 0 0 12px; letter-spacing: -0.5px; }
.landing-sub { font-size: 15px; color: var(--sub); line-height: 1.55; margin: 0 auto 34px; max-width: 540px; }
.options {
  display: flex; flex-direction: column; gap: 14px;
  text-align: left; max-width: 460px; margin: 0 auto;
}
.option-card {
  background: var(--bg-2); border: 1px solid var(--bg-3);
  border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s;
}
.option-card:hover { border-color: var(--accent-dim); }
.opt-h { font-size: 16px; font-weight: 600; color: var(--text); }
.opt-d { font-size: 13px; color: var(--sub); line-height: 1.5; flex: 1 1 auto; }
button.block { width: 100%; }
.repo-row { display: flex; gap: 8px; }
.repo-row input {
  flex: 1 1 auto; min-width: 0; background: var(--bg); color: var(--text);
  border: 1px solid var(--bg-3); border-radius: 8px; padding: 8px 11px;
  font-family: var(--mono); font-size: 13px;
}
.repo-row input:focus { outline: none; border-color: var(--accent-dim); }
.repo-status { font-size: 12.5px; color: var(--sub); min-height: 16px; font-family: var(--mono); }
.repo-status.error { color: var(--err); }

/* results */
.results {
  position: absolute; inset: 0; background: rgba(10,10,14,.86);
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px);
}
.results[hidden] { display: none; }
.results-card {
  background: var(--bg-2); border: 1px solid var(--bg-3); border-radius: var(--radius);
  padding: 30px 40px; min-width: 460px; text-align: center;
}
.results-card h2 { margin: 0 0 22px; font-weight: 500; }
.results-card h2 span { color: var(--accent); font-family: var(--mono); font-size: .7em; }
.results-grid { display: flex; gap: 26px; justify-content: center; margin-bottom: 26px; }
.results-grid > div { display: flex; flex-direction: column; }
.r-val { font-family: var(--mono); font-size: 30px; color: var(--accent); }
.r-lbl { font-size: 12px; color: var(--sub); text-transform: uppercase; letter-spacing: 1px; }
.results-actions { display: flex; gap: 10px; justify-content: center; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }
