:root {
  --bg: #f1f1f1;
  --surface: #ffffff;
  --surface-cool: #f6f8fa;
  --surface-mist: #e6ebf1;
  --ink: #111111;
  --muted: #646464;
  --shell: #050505;
  --shell-alt: #262c36;
  --lime: #d4f33c;
  --sky: #d0e5f7;
  --sky-strong: #3b73e0;
  --on-shell: #f6f8fa;
  --radius-shell: 34px;
  --radius-card: 16px;
  --radius-tile: 12px;
  --radius-pill: 999px;
  --gutter: 12px;
  --field-bg: #ffffff;
  --field-stroke: rgba(17, 17, 17, 0.08);
  --field-height: 52px;
  --line: var(--field-stroke);
  --faint: #8a8a8a;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "Inter Tight", sans-serif;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
}

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.45;
}

a { color: inherit; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0 1.05rem;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: var(--radius-pill);
  box-shadow: inset 0 0 0 1px var(--field-stroke);
  font-weight: 500;
  white-space: nowrap;
}

button:hover { background: var(--surface); }
button:active { transform: translateY(1px) scale(0.98); }

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

button.primary {
  background: var(--ink);
  color: var(--on-shell);
  box-shadow: none;
}
button.primary:hover { background: #000; color: var(--on-shell); }

button.film {
  background: var(--sky);
  color: var(--ink);
  box-shadow: none;
  font-weight: 500;
}
button.film:hover { background: #c3dcf0; }

button.ghost {
  color: var(--muted);
  box-shadow: none;
}
button.ghost:hover { color: var(--ink); background: var(--surface); }

button[disabled] { opacity: 0.4; cursor: not-allowed; transform: none; }

.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: var(--gutter);
  align-items: start;
  min-height: 100dvh;
  padding: var(--gutter);
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: var(--gutter);
  height: calc(100dvh - 2 * var(--gutter));
  padding: 28px 22px 22px;
  color: var(--on-shell);
  background: var(--shell);
  border-radius: var(--radius-shell);
}

.brand { text-decoration: none; display: grid; gap: 0.35rem; }
.brand:focus-visible { outline-color: var(--on-shell); }

.brand-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--on-shell) 62%, var(--shell));
}

.brand-name {
  font-size: 42px;
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -2px;
}

.brand-name .lime { color: var(--lime); }

.nav { display: grid; gap: 0.1rem; }

.nav a {
  text-decoration: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  min-height: 40px;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-pill);
  color: color-mix(in srgb, var(--on-shell) 68%, var(--shell));
  font-size: 14px;
  font-weight: 500;
}

.nav a.active,
.nav a:hover {
  background: rgb(246 248 250 / 8%);
  color: var(--on-shell);
}

.nav a:focus-visible { outline-color: var(--on-shell); }

.nav .count {
  font-size: 12px;
  font-weight: 600;
  color: color-mix(in srgb, var(--on-shell) 42%, var(--shell));
}

.nav a.active .count { color: var(--lime); }

.rail-hint, .rail-keys {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: color-mix(in srgb, var(--on-shell) 46%, var(--shell));
}

.rail-keys { margin-top: auto; letter-spacing: 0.02em; }

.scan-sources {
  display: grid;
  gap: 0.35rem;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  color: color-mix(in srgb, var(--on-shell) 62%, var(--shell));
}

.scan-sources .src {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
}

.scan-sources .src b { font-weight: 600; color: var(--on-shell); }
.scan-sources .src.ok b { color: var(--lime); }
.scan-sources .src.warn { color: color-mix(in srgb, var(--on-shell) 52%, var(--shell)); }

.main {
  min-width: 0;
  padding: 8px 12px 88px;
  max-width: 980px;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: end;
  margin-bottom: 1.15rem;
}

h1 {
  margin: 0;
  font-size: clamp(40px, 5vw, 54px);
  font-weight: 500;
  letter-spacing: -1px;
  line-height: 1.05;
  text-align: left;
}

.lede {
  margin: 0.45rem 0 0;
  color: var(--muted);
  max-width: 46ch;
  font-size: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--field-stroke);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface);
}

.chip.ok {
  color: var(--ink);
  background: var(--sky);
  border-color: transparent;
}

.chip.warn {
  color: var(--ink);
  background: var(--surface-mist);
}

.bulk {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  position: fixed;
  z-index: 8;
  left: calc(248px + 2 * var(--gutter));
  right: var(--gutter);
  bottom: var(--gutter);
  max-width: 980px;
  background: var(--ink);
  color: var(--on-shell);
  border-radius: var(--radius-pill);
  padding: 0.65rem 0.75rem 0.65rem 1.05rem;
}

.bulk button {
  background: #fff;
  color: var(--ink);
  box-shadow: none;
}

.bulk button.primary {
  background: var(--lime);
  color: var(--ink);
}

.bulk button.ghost {
  background: transparent;
  color: color-mix(in srgb, var(--on-shell) 72%, var(--shell));
}

.bulk button.ghost:hover { color: var(--on-shell); background: rgb(246 248 250 / 8%); }

.bulk span {
  margin-right: auto;
  font-size: 13px;
  font-weight: 600;
}

.feed { display: grid; gap: 12px; }

.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.card-mist { background: var(--surface-mist); }
.card-cool { background: var(--surface-cool); }

.card-shell {
  background: var(--shell-alt);
  color: var(--on-shell);
}

.card.selected { box-shadow: inset 0 0 0 2px var(--ink); }
.card-shell.selected { box-shadow: inset 0 0 0 2px var(--on-shell); }

.card-chrome {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.15rem 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.card-shell .card-chrome {
  color: color-mix(in srgb, var(--on-shell) 58%, var(--shell-alt));
}

.pick { margin-left: auto; display: flex; align-items: center; }

.pick input {
  width: 18px;
  height: 18px;
  accent-color: var(--ink);
}

.card-shell .pick input { accent-color: var(--lime); }

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

.num {
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.06em;
  color: var(--ink);
}

.card-shell .num { color: var(--on-shell); }

.hot {
  color: var(--ink);
  background: var(--lime);
  border-radius: var(--radius-pill);
  padding: 0.12rem 0.55rem;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status { text-transform: lowercase; font-weight: 600; }

.card-body { padding: 0.55rem 1.15rem 1.15rem; display: grid; gap: 0.85rem; }

.card-title {
  font-size: clamp(1.35rem, 2.4vw, 1.7rem);
  line-height: 1.12;
  letter-spacing: -0.04em;
  margin: 0;
  font-weight: 500;
  text-align: left;
}

.cluster {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  margin: 0.3rem 0 0;
}

.card-shell .cluster {
  color: color-mix(in srgb, var(--on-shell) 68%, var(--shell-alt));
}

.block h3 {
  margin: 0 0 0.2rem;
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card-shell .block h3 {
  color: color-mix(in srgb, var(--on-shell) 46%, var(--shell-alt));
}

.block p { margin: 0; max-width: 68ch; }

.sources { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.sources a,
.sources .chip {
  text-decoration: none;
  background: var(--sky);
  color: var(--ink);
  border: 0;
  border-radius: var(--radius-pill);
  height: auto;
  padding: 0.22rem 0.7rem;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.card-shell .sources a,
.card-shell .sources .chip {
  background: var(--sky);
  color: var(--ink);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.actions .film { margin-left: auto; }

.k {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, currentColor 55%, transparent);
  margin-left: 0.15rem;
}

.card-shell button {
  color: var(--on-shell);
  box-shadow: inset 0 0 0 1px rgb(246 248 250 / 16%);
}

.card-shell button:hover { background: rgb(246 248 250 / 8%); color: var(--on-shell); }
.card-shell button:focus-visible { outline-color: var(--on-shell); }

.card-shell button.primary {
  background: #fff;
  color: var(--ink);
  box-shadow: none;
}
.card-shell button.primary:hover { background: var(--surface-cool); }

.card-shell button.film {
  background: #fff;
  color: var(--ink);
}

.empty {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 2rem 1.35rem;
  color: var(--muted);
}

.empty strong {
  color: var(--ink);
  display: block;
  font-weight: 500;
  font-size: 1.35rem;
  letter-spacing: -0.04em;
  margin-bottom: 0.35rem;
}

.table { display: grid; gap: 0; }

.row {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 0.8rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--field-stroke);
  align-items: start;
}

.row:first-child { padding-top: 0; }

.row small { color: var(--muted); font-size: 13px; font-weight: 500; }

.form { display: grid; gap: 1rem; max-width: 720px; }

label { display: grid; gap: 0.35rem; font-size: 14px; font-weight: 500; }

input, textarea {
  background: var(--field-bg);
  border: 1px solid var(--field-stroke);
  border-radius: var(--radius-card);
  min-height: var(--field-height);
  padding: 0.55rem 0.85rem;
}

textarea { min-height: 4.5rem; resize: vertical; }

.cluster-edit {
  border: 0;
  border-radius: var(--radius-card);
  padding: 1rem;
  display: grid;
  gap: 0.6rem;
  background: var(--surface);
}

.cluster-edit:nth-child(odd) { background: var(--surface-mist); }

.policy {
  background: var(--shell-alt);
  color: color-mix(in srgb, var(--on-shell) 78%, var(--shell-alt));
  border-radius: var(--radius-card);
  padding: 1rem 1.15rem;
}

.policy strong { color: var(--on-shell); }

.toast {
  position: fixed;
  right: var(--gutter);
  bottom: var(--gutter);
  background: var(--ink);
  color: var(--on-shell);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-pill);
  font-weight: 500;
  z-index: 5;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgb(5 5 5 / .52);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 6;
}

.modal[hidden], .toast[hidden], .bulk[hidden] { display: none; }

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-shell);
  padding: 1.5rem 1.4rem 1.3rem;
  max-width: 32rem;
  width: min(32rem, 100%);
}

.modal-card h2 {
  font-size: clamp(1.7rem, 4vw, 2.15rem);
  font-weight: 500;
  margin: 0 0 0.5rem;
  letter-spacing: -0.04em;
  line-height: 1.1;
  text-align: left;
}

.modal-note { color: var(--muted); font-size: 14px; }

.modal-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.modal-actions .film { min-height: 52px; padding-inline: 1.25rem; }

.run-stage {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.card-shell .run-stage {
  color: color-mix(in srgb, var(--on-shell) 72%, var(--shell-alt));
}

.run-head { display: grid; gap: 0.55rem; margin-bottom: 1.1rem; }

.run-back {
  width: fit-content;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.run-back:hover { color: var(--ink); }

.run-meta {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.timeline { display: grid; gap: 10px; }

.step {
  background: var(--surface);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.step:nth-child(3n) { background: var(--surface-mist); }
.step:nth-child(3n+2) { background: var(--surface-cool); }
.step.is-current { background: var(--shell-alt); color: var(--on-shell); }

.step summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.8rem;
  cursor: pointer;
  list-style: none;
  padding: 0.95rem 1.1rem;
  font-weight: 500;
}

.step summary::-webkit-details-marker { display: none; }

.step-index {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.05em;
}

.step-file {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.step.is-current .step-file,
.step.is-current .step-note {
  color: color-mix(in srgb, var(--on-shell) 62%, var(--shell-alt));
}

.step-note {
  width: 100%;
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.step pre {
  margin: 0;
  padding: 0 1.1rem 1.15rem;
  overflow: auto;
  max-height: 28rem;
  white-space: pre-wrap;
  word-break: break-word;
  font: 400 14px/1.5 var(--font);
}

.card-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1.05rem;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--on-shell);
  text-decoration: none;
  font-weight: 500;
}

.card-shell .card-link {
  background: #fff;
  color: var(--ink);
}

@media (max-width: 800px) {
  .app {
    grid-template-columns: 1fr;
    padding: var(--gutter);
  }
  .rail {
    position: static;
    height: auto;
    border-radius: 24px;
    padding: 22px 18px 16px;
  }
  .brand-name { font-size: 36px; }
  .nav {
    display: flex;
    overflow-x: auto;
    gap: 0.2rem;
  }
  .nav a { white-space: nowrap; }
  .rail-keys { display: none; }
  .main { padding: 0.35rem 0 6rem; }
  .top { flex-direction: column; align-items: start; }
  .bulk { left: var(--gutter); border-radius: var(--radius-card); }
  h1 { font-size: 40px; letter-spacing: -2px; }
  .actions { position: static; }
  .actions button { flex: 1 1 calc(50% - 0.45rem); }
  .actions .film { margin-left: 0; flex: 1 1 100%; }
  .row { grid-template-columns: 1fr; }
  .modal-card { border-radius: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  button:active { transform: none; }
}
