/* fast·md — design system
   Ink-dark tool chrome around a paper-white output well; the one accent is
   the PDF badge's own red. Signature element: the page reel. */

:root {
  --ink-950: #0d1013;
  --ink-900: #13171b;
  --ink-800: #1b2126;
  --ink-700: #27313a;
  --ink-600: #35434f;
  --fog-500: #8c9ba5;
  --fog-300: #b7c2c9;
  --fog-100: #e9edef;
  --paper: #f6f2e9;
  --paper-ink: #1a1c1e;
  --paper-dim: #5c6167;
  --red: #f04e36;
  --red-soft: rgba(240, 78, 54, 0.14);
  --red-line: rgba(240, 78, 54, 0.45);
  --ok: #45c48a;
  --warn: #e8a33d;
  --font-ui: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --font-display: "Archivo", "Instrument Sans", sans-serif;
  --font-mono: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace;
  --radius: 12px;
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    repeating-linear-gradient(115deg,
      transparent 0 22px,
      rgba(255, 255, 255, 0.012) 22px 23px),
    var(--ink-950);
  color: var(--fog-100);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); }

.display {
  font-family: var(--font-display);
  font-stretch: 118%;
  font-weight: 780;
  letter-spacing: -0.015em;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  border-radius: 4px;
}

.is-hidden { display: none !important; }

/* ------------------------------------------------------------- top bar -- */

.top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 clamp(16px, 3vw, 32px);
  height: 58px;
  border-bottom: 1px solid var(--ink-700);
  background: rgba(13, 16, 19, 0.86);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.brand {
  font-size: 21px;
  color: var(--fog-100);
  text-decoration: none;
  line-height: 1;
}
.brand-dot { color: var(--red); }

.top-status {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fog-500);
  border: 1px solid var(--ink-700);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}
.chip--device.is-off { color: var(--warn); border-color: rgba(232, 163, 61, 0.4); }

.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-600);
  display: inline-block; flex: none;
}
.dot--done { background: var(--ok); }
.dot--error { background: var(--red); }

/* -------------------------------------------------------------- layout -- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 26px;
  padding: 24px clamp(16px, 3vw, 32px) 40px;
  max-width: 1460px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 82px;
  max-height: calc(100dvh - 106px);
  overflow-y: auto;
  scrollbar-width: thin;
  padding-right: 2px;
}

.stage { min-height: 520px; }

/* ------------------------------------------------------------ dropzone -- */

.drop {
  border: 1.5px dashed var(--ink-600);
  border-radius: var(--radius);
  padding: 26px 18px 22px;
  text-align: center;
  color: var(--fog-500);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
  cursor: pointer;
  background: var(--ink-900);
}
.drop:hover, .drop:focus-visible { border-color: var(--fog-500); color: var(--fog-300); }
.drop.is-drag {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--fog-100);
  transform: scale(1.012);
}
.drop-icon { opacity: 0.9; }
.drop.is-drag .drop-icon { animation: bob 0.9s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }

.drop-title { font-size: 21px; color: var(--fog-100); margin: 10px 0 2px; }
.drop-sub { font-size: 13px; }
.link { color: var(--fog-100); text-decoration: underline; text-underline-offset: 3px; }

.hint {
  margin: -4px 0 0;
  padding: 8px 12px;
  font-size: 11.5px;
  color: var(--fog-300);
  background: var(--ink-900);
  border: 1px solid var(--ink-700);
  border-left: 3px solid var(--red);
  border-radius: 8px;
}

/* --------------------------------------------------------------- queue -- */

.queue { margin: -2px 0; }
.file-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  background: var(--ink-900);
  border: 1px solid var(--ink-700);
  border-radius: 9px;
  font-size: 13px;
}
.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-meta { color: var(--fog-500); font-size: 10.5px; flex: none; }
.file-remove {
  flex: none;
  background: none;
  border: 0;
  color: var(--fog-500);
  font-size: 16px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 6px;
}
.file-remove:hover { color: var(--red); background: var(--red-soft); }

/* --------------------------------------------------------------- panel -- */

.panel {
  background: var(--ink-900);
  border: 1px solid var(--ink-700);
  border-radius: var(--radius);
  padding: 14px;
}

.eyebrow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fog-500);
}
.eyebrow-keys { font-weight: 400; letter-spacing: 0.05em; color: var(--ink-600); }

/* --------------------------------------------------------- engine rail -- */

.engine-rail { display: flex; flex-direction: column; gap: 8px; }

.engine {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-radius: 10px;
  padding: 11px 12px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
  animation: card-in 0.4s backwards cubic-bezier(0.2, 0.7, 0.2, 1);
}
.engine:nth-child(1) { animation-delay: 0.03s; }
.engine:nth-child(2) { animation-delay: 0.09s; }
.engine:nth-child(3) { animation-delay: 0.15s; }
.engine:nth-child(4) { animation-delay: 0.21s; }
@keyframes card-in { from { opacity: 0; transform: translateY(8px); } }

.engine:hover { border-color: var(--ink-600); transform: translateY(-1px); }
.engine.is-selected {
  border-color: var(--red-line);
  background: linear-gradient(180deg, var(--red-soft), transparent 130%), var(--ink-800);
  box-shadow: inset 3px 0 0 var(--red);
}

.engine-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.engine-key {
  font-size: 10px;
  color: var(--fog-500);
  border: 1px solid var(--ink-700);
  border-radius: 5px;
  padding: 0 5px;
  line-height: 17px;
}
.engine.is-selected .engine-key { color: var(--fog-100); border-color: var(--ink-600); }
.engine-name { font-weight: 650; font-size: 15px; }
.engine-size { margin-left: auto; font-size: 10.5px; color: var(--fog-500); }

.engine-blurb {
  margin: 5px 0 8px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--fog-500);
}
.engine.is-selected .engine-blurb { color: var(--fog-300); }

.engine-foot { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 2.5px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.badge--inspector { color: var(--red); border-color: var(--red-line); background: var(--red-soft); }
.badge--instant { color: var(--fog-300); border-color: var(--ink-600); }
.badge--tesseract { color: var(--fog-300); border-color: var(--ink-600); }
.badge--smolvlm { color: #7ec8f5; border-color: rgba(126, 200, 245, 0.35); }
.badge--qwen { color: var(--warn); border-color: rgba(232, 163, 61, 0.4); }
.badge--cached { color: var(--ok); border-color: rgba(69, 196, 138, 0.4); }
.badge--warn { color: var(--warn); border-color: rgba(232, 163, 61, 0.4); }

/* -------------------------------------------------------------- options -- */

.opt-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 2px;
  border-top: 1px solid var(--ink-800);
}
.opt-row:first-of-type { border-top: 0; }
.opt-label {
  font-size: 12.5px;
  font-weight: 550;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.opt-note { color: var(--fog-500); font-weight: 400; font-size: 11px; }

.seg {
  display: inline-flex;
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
  width: max-content;
}
.seg-btn {
  border: 0;
  background: none;
  border-radius: 6px;
  padding: 4.5px 12px;
  font-size: 12.5px;
  color: var(--fog-500);
  transition: background 0.12s ease, color 0.12s ease;
}
.seg-btn:hover { color: var(--fog-100); }
.seg-btn.is-active { background: var(--ink-600); color: var(--fog-100); }

.lang-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip-btn {
  font-size: 11.5px;
  padding: 3.5px 10px;
  border-radius: 999px;
  border: 1px solid var(--ink-700);
  background: var(--ink-800);
  color: var(--fog-500);
  transition: all 0.12s ease;
}
.chip-btn:hover { color: var(--fog-100); border-color: var(--ink-600); }
.chip-btn.is-active {
  color: var(--fog-100);
  border-color: var(--red-line);
  background: var(--red-soft);
}

.input {
  width: 100%;
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-radius: 9px;
  padding: 8px 11px;
  color: var(--fog-100);
  font-size: 13px;
}
select.input { appearance: none; }
select.input option { background: var(--ink-900); color: var(--fog-100); }
.input:focus { border-color: var(--ink-600); outline: none; }

input[type="range"] {
  width: 100%;
  accent-color: var(--red);
}

/* --------------------------------------------------------------- runbar -- */

.runbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  border: 1px solid var(--ink-700);
  background: var(--ink-800);
  color: var(--fog-100);
  padding: 9px 16px;
  font-weight: 600;
  font-size: 14px;
  transition: filter 0.12s ease, border-color 0.12s ease;
}
.btn:hover { border-color: var(--ink-600); }
kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fog-500);
  border: 1px solid var(--ink-600);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
}
.btn--primary {
  background: var(--red);
  border-color: var(--red);
  color: #16100e;
  padding: 11px 20px;
  font-size: 15px;
}
.btn--primary kbd { color: #7a2417; border-color: rgba(0, 0, 0, 0.3); }
.btn--primary:hover { filter: brightness(1.08); border-color: var(--red); }
.btn--danger { color: var(--red); border-color: var(--red-line); background: var(--red-soft); }
.btn--ghost { background: transparent; }

.runbar-count { font-size: 11px; color: var(--fog-500); }

/* ---------------------------------------------------------- stage empty -- */

.stage {
  display: flex;
  flex-direction: column;
}

.stage-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  min-height: 60vh;
  padding: 20px 8px;
}

.hero {
  margin: 0;
  font-size: clamp(44px, 5.6vw, 78px);
  line-height: 1.02;
  color: var(--fog-100);
}
.hero-dim { color: var(--fog-500); }

.hero-sub {
  max-width: 52ch;
  color: var(--fog-500);
  font-size: 16px;
  margin: 14px 0 26px;
}

.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fog-500);
}
.legend b {
  color: var(--fog-100);
  border: 1px solid var(--ink-600);
  border-radius: 5px;
  padding: 0 5px;
  margin-right: 6px;
  font-weight: 500;
}

/* ------------------------------------------------------------ stage run -- */

.run-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.run-title {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 46ch;
}
.run-stats { display: flex; gap: 26px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; }
.stat-label {
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fog-500);
}
.stat-value {
  font-size: 22px;
  font-weight: 500;
  color: var(--fog-100);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

/* the signature: a film strip of page chips, filling as pages complete */
.reel {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 16px;
  background: var(--ink-900);
  border: 1px solid var(--ink-700);
  border-radius: var(--radius);
  max-height: 42vh;
  overflow-y: auto;
}
.pg-chip {
  --fill: 0;
  position: relative;
  width: 34px;
  height: 42px;
  border-radius: 7px;
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fog-500);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: none;
}
.pg-chip::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--red-soft), rgba(240, 78, 54, 0.32));
  clip-path: inset(calc((1 - var(--fill)) * 100%) 0 0 0);
  transition: clip-path 0.3s ease;
}
.pg-chip > * { position: relative; }
.pg-chip { justify-content: center; }
.pg-chip.is-done {
  border-color: var(--red-line);
  color: var(--fog-100);
}
.pg-chip.is-done::after {
  content: "";
  position: absolute;
  left: 6px; right: 6px; top: 5px;
  height: 2px;
  background: var(--red);
  border-radius: 2px;
}

.model-status {
  display: grid;
  grid-template-columns: 1fr 3px auto;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}
.model-label { font-size: 11px; color: var(--fog-300); }
.model-track { height: 3px; border-radius: 3px; background: var(--ink-700); overflow: hidden; width: 180px; }
.model-bar { height: 100%; width: 0; background: var(--red); transition: width 0.2s ease; }
.model-bytes { font-size: 10px; color: var(--fog-500); }

/* --------------------------------------------------------- stage result -- */

.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.result-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.rtab {
  border: 1px solid var(--ink-700);
  background: var(--ink-900);
  color: var(--fog-500);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12.5px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rtab:hover { color: var(--fog-100); }
.rtab.is-active { color: var(--fog-100); border-color: var(--red-line); background: var(--red-soft); }

.result-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.result-stats {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fog-500);
}

/* the paper well — the output is the light moment on the dark page */
.well {
  border-radius: 14px;
  min-height: 320px;
  max-height: 64vh;
  overflow-y: auto;
  padding: clamp(22px, 3.5vw, 44px);
}
.well.is-paper {
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow: var(--shadow-pop);
}
.well.is-raw {
  background: var(--ink-900);
  border: 1px solid var(--ink-700);
}
.well.is-raw pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--fog-300);
}

.well.is-paper :is(h1, h2, h3, h4) {
  font-family: var(--font-display);
  font-stretch: 112%;
  line-height: 1.18;
  margin: 1.4em 0 0.5em;
  letter-spacing: -0.01em;
}
.well.is-paper h1 { font-size: 1.9em; margin-top: 0.3em; }
.well.is-paper h2 { font-size: 1.5em; }
.well.is-paper h3 { font-size: 1.22em; }
.well.is-paper p { margin: 0.75em 0; line-height: 1.75; }
.well.is-paper ul, .well.is-paper ol { padding-inline-start: 1.5em; line-height: 1.75; }
.well.is-paper li { margin: 0.25em 0; }
.well.is-paper code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: rgba(0, 0, 0, 0.07);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.well.is-paper pre code { display: block; padding: 0.9em; overflow-x: auto; }
.well.is-paper blockquote {
  margin: 1em 0;
  padding-inline-start: 1em;
  border-inline-start: 3px solid rgba(0, 0, 0, 0.18);
  color: var(--paper-dim);
}
.well.is-paper hr { border: 0; border-top: 1px solid rgba(0, 0, 0, 0.14); margin: 1.6em 0; }
.well.is-paper a { color: #b23a26; }

/* --------------------------------------------------------------- footer -- */

.foot {
  padding: 18px clamp(16px, 3vw, 32px) 26px;
  border-top: 1px solid var(--ink-800);
  color: var(--fog-500);
  font-size: 10.5px;
  letter-spacing: 0.05em;
}

/* --------------------------------------------------------------- dialog -- */

.dlg {
  background: var(--ink-900);
  color: var(--fog-100);
  border: 1px solid var(--ink-700);
  border-radius: 16px;
  padding: 22px;
  width: min(560px, calc(100vw - 40px));
  box-shadow: var(--shadow-pop);
}
.dlg::backdrop { background: rgba(5, 7, 9, 0.66); backdrop-filter: blur(3px); }
.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.dlg-head h2 { margin: 0; font-size: 22px; }
.dlg-note { color: var(--fog-500); font-size: 13px; margin: 0 0 14px; }

.model-list { list-style: none; margin: 0; padding: 0; }
.model-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 2px;
  border-top: 1px solid var(--ink-800);
}
.model-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.model-name { font-weight: 600; font-size: 14px; }
.model-meta { font-size: 11px; color: var(--fog-500); }
.model-actions { display: flex; gap: 8px; flex: none; }

.storage-meter { margin-top: 16px; display: flex; flex-direction: column; gap: 7px; }
.storage-track { height: 4px; border-radius: 4px; background: var(--ink-700); overflow: hidden; }
.storage-bar { height: 100%; background: var(--red); border-radius: 4px; transition: width 0.3s ease; }
.storage-meter span { font-size: 10.5px; color: var(--fog-500); }

/* --------------------------------------------------------------- toasts -- */

.toasts {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--ink-800);
  border: 1px solid var(--ink-600);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13.5px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.toast--error .toast-dot { background: var(--red); }
.toast--info .toast-dot { background: var(--ok); }

/* ---------------------------------------------------------- scrollbars -- */

::-webkit-scrollbar, .side::-webkit-scrollbar, .well::-webkit-scrollbar,
.reel::-webkit-scrollbar, .file-list::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--ink-700); border-radius: 8px; border: 2px solid var(--ink-950); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------- responsive -- */

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; overflow: visible; }
  .stage { min-height: 380px; }
  .hero { font-size: clamp(38px, 9vw, 60px); }
  .top-status .chip:first-child { display: none; }
  .run-stats { gap: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
