*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--ground); color: var(--ink);
  font: 400 0.9375rem/1.55 var(--sans); -webkit-font-smoothing: antialiased; overflow-x: clip;
}
/* Faint dot grid, as on the KNK site. */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(color-mix(in srgb, var(--primary) 22%, transparent) 1px, transparent 1.5px);
  background-size: 28px 28px; mask-image: linear-gradient(to bottom, #000, transparent 80%);
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1 { font: 400 clamp(1.7rem, 3.2vw, 2.4rem)/1.1 var(--display); letter-spacing: -0.02em; text-wrap: balance; }
h2 { font: 500 1.05rem/1.3 var(--display); letter-spacing: -0.005em; }
h3 { font: 500 1.12rem/1.25 var(--display); letter-spacing: -0.005em; }
.lead { color: var(--muted); max-width: 62ch; }
.mono { font-family: var(--mono); }
.label { font: 500 0.6875rem/1 var(--mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1.75rem;
  padding: 1.25rem 1rem; border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--ground) 82%, transparent); backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 0.7rem; padding: 0 0.35rem; }
.brand .logo { width: 64px; height: auto; flex: none; }
.brand-name { font: 500 1.2rem/1 var(--display); letter-spacing: -0.01em; }
.brand-badge { margin-left: 0.35rem; padding: 0.18rem 0.4rem; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); font: 500 0.625rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); vertical-align: middle; }
.nav { display: grid; gap: 0.25rem; }
.nav a { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.75rem; border-radius: var(--r-sm); color: var(--muted); font-weight: 600; transition: background-color 0.2s, color 0.2s; }
.nav a:hover { color: var(--ink); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.nav a[aria-current='page'] { color: var(--ink); background: color-mix(in srgb, var(--primary) 16%, transparent); }
.nav a[aria-current='page'] svg { color: var(--accent); }
.nav svg, .ico { width: 18px; height: 18px; flex: none; }
.rail-foot { margin-top: auto; display: grid; gap: 0.85rem; padding: 0 0.35rem; font-size: 0.8125rem; color: var(--muted); }
.rail-foot strong { display: block; color: var(--ink); font-weight: 600; }
.engine { display: flex; align-items: center; gap: 0.5rem; font: 500 0.6875rem/1.2 var(--mono); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--secondary); }
.dot.running { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.dot.failed { background: var(--danger); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 25%, transparent); } }
.byline { font-size: 0.75rem; line-height: 1.4; }

.main { min-width: 0; padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 4rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; flex-wrap: wrap; }
.notice { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.75rem; border: 1px solid var(--line); border-radius: 999px; font: 500 0.6875rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.notice::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.who { display: flex; align-items: center; gap: 0.6rem; font-size: 0.875rem; color: var(--muted); }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: color-mix(in srgb, var(--primary) 22%, transparent); color: var(--primary); font: 600 0.75rem/1 var(--mono); }
.page-head { display: grid; gap: 0.6rem; margin-bottom: 1.5rem; }
.back { display: inline-flex; align-items: center; gap: 0.4rem; width: fit-content; margin-bottom: 1rem; color: var(--muted); font-weight: 600; font-size: 0.875rem; }
.back:hover { color: var(--ink); }

/* ---------- Controls ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; margin-bottom: 1.25rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tab { padding: 0.5rem 0.85rem; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 600; font-size: 0.875rem; transition: border-color 0.2s, color 0.2s, background-color 0.2s; }
.tab:hover { color: var(--ink); border-color: var(--primary); }
.tab[aria-pressed='true'] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.tab .count { margin-left: 0.35rem; font: 500 0.6875rem/1 var(--mono); opacity: 0.75; }
.search { position: relative; margin-left: auto; flex: 1 1 220px; max-width: 320px; }
.search svg { position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input[type='search'] { padding-left: 2.4rem; }
input[type='text'], input[type='search'], input[type='number'], input[type='date'], select {
  width: 100%; min-height: 42px; padding: 0.55rem 0.8rem; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: color-mix(in srgb, var(--ground) 60%, var(--surface)); color-scheme: dark;
}
input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input:focus-visible, select:focus-visible { outline-offset: 0; border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.55rem; min-height: 46px; padding: 0 1.4rem; border-radius: 999px; border: 1px solid transparent; font-weight: 700; transition: transform 0.2s var(--ease), box-shadow 0.25s; }
.btn:active { transform: scale(0.97); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-accent:hover { box-shadow: 0 8px 28px -8px var(--accent); }
.btn-ghost { border-color: var(--line); background: transparent; }
.btn-ghost:hover { border-color: var(--primary); }

/* ---------- Cards ---------- */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); }
.card, .panel, .tile {
  border: 1px solid var(--line); border-radius: var(--r);
  background: color-mix(in srgb, var(--surface) 72%, transparent); backdrop-filter: blur(6px);
}
.card { position: relative; display: flex; flex-direction: column; gap: 0.7rem; padding: 1.15rem 1.15rem 1rem; min-height: 214px; transition: border-color 0.25s, transform 0.25s var(--ease); }
.card:hover { border-color: var(--primary); transform: translateY(-2px); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.cat { display: inline-flex; align-items: center; gap: 0.45rem; font: 500 0.6875rem/1 var(--mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--primary); }
.cat svg { width: 15px; height: 15px; }
.star { position: relative; z-index: 2; display: grid; place-items: center; width: 32px; height: 32px; margin: -0.35rem -0.35rem 0 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
.star:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.star[aria-pressed='true'] { color: var(--accent); }
.star[aria-pressed='true'] svg { fill: currentColor; }
.card h3 a::after { content: ''; position: absolute; inset: 0; border-radius: var(--r); }
.card p { color: var(--muted); font-size: 0.875rem; }
.card-foot { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; padding-top: 0.8rem; border-top: 1px solid var(--line); font-size: 0.78rem; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; }
.chip svg { width: 14px; height: 14px; }
.saved b { font: 500 0.9rem/1 var(--mono); color: var(--accent); }
.empty { padding: 3rem 1rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); }

/* ---------- Flow form ---------- */
.split { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
.panel { padding: 1.4rem; display: grid; gap: 1.1rem; }
.panel > h2 { padding-bottom: 0.85rem; border-bottom: 1px solid var(--line); }
.field { display: grid; gap: 0.4rem; }
.field > span { font-weight: 600; font-size: 0.875rem; }
.field em { margin-left: 0.4rem; font: 500 0.625rem/1 var(--mono); font-style: normal; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.check { display: flex; align-items: center; gap: 0.7rem; font-weight: 600; font-size: 0.875rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1rem; }
.meta dt { margin-bottom: 0.4rem; }
.meta dd { font-weight: 600; }

/* ---------- Route (steps): a node line that turns amber as it advances, echoing the logo ---------- */
.route { display: grid; }
.step { position: relative; display: grid; grid-template-columns: 22px 1fr auto; gap: 0 0.9rem; padding-bottom: 1.15rem; }
.step:last-child { padding-bottom: 0; }
.step::before { content: ''; position: absolute; left: 10px; top: 22px; bottom: 0; width: 2px; background: var(--line); }
.step:last-child::before { display: none; }
.node { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); background: var(--ground); display: grid; place-items: center; color: var(--on-accent); z-index: 1; }
.node svg { width: 12px; height: 12px; opacity: 0; }
.step-body strong { display: block; font-weight: 600; line-height: 1.4; }
.step-body small { font-size: 0.8125rem; color: var(--muted); }
.step time { font: 500 0.6875rem/1.9 var(--mono); color: var(--muted); }
.step.done .node { background: var(--accent); border-color: var(--accent); }
.step.done .node svg { opacity: 1; }
.step.done::before { background: var(--accent); }
.step.running .node { border-color: var(--accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent); animation: pulse 1.2s ease-in-out infinite; }
.step.running .step-body small { color: var(--accent); }
.step.failed .node { background: var(--danger); border-color: var(--danger); }
.step.failed .step-body small { color: var(--danger); }
.step.pending .step-body strong { color: var(--muted); font-weight: 500; }
.route.plain .step { grid-template-columns: 22px 1fr; }
.route.plain .node { border-color: var(--primary); }
.route.plain .node span { font: 500 0.625rem/1 var(--mono); color: var(--primary); }

/* ---------- Run ---------- */
.run-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.status { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.75rem; border-radius: 999px; border: 1px solid var(--line); font: 500 0.6875rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; }
.status.ok { color: var(--secondary); border-color: color-mix(in srgb, var(--secondary) 45%, transparent); }
.status.running { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.status.failed { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.bar { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; margin-bottom: 1.5rem; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.5s var(--ease); }
.result { padding: 1rem 1.1rem; border-radius: var(--r-sm); border: 1px solid color-mix(in srgb, var(--secondary) 45%, transparent); background: color-mix(in srgb, var(--secondary) 9%, transparent); }
.result.failed { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 9%, transparent); }
.result .label { display: block; margin-bottom: 0.5rem; }
.kv { display: grid; gap: 0.75rem; }
.kv div { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--line); font-size: 0.875rem; }
.kv div:last-child { border: 0; padding: 0; }
.kv + .kv { padding-top: 0.75rem; border-top: 1px solid var(--line); margin-top: -0.35rem; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* ---------- History ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: color-mix(in srgb, var(--surface) 72%, transparent); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { text-align: left; padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font: 500 0.6875rem/1 var(--mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
tbody tr { cursor: pointer; transition: background-color 0.2s; }
tbody tr:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 600; white-space: normal; min-width: 240px; }
td.num { font: 500 0.8125rem/1 var(--mono); color: var(--muted); }
td small { display: block; font: 500 0.6875rem/1.6 var(--mono); color: var(--muted); }

/* ---------- Dashboard ---------- */
.tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1.25rem; }
.tile { padding: 1.2rem; display: grid; gap: 0.7rem; }
.tile b { font: 300 2.5rem/1 var(--display); letter-spacing: -0.02em; }
.tile b span { font-size: 1.1rem; color: var(--muted); margin-left: 0.2rem; }
.tile.hi b { color: var(--accent); }
.charts { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: start; }
.cols { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; align-items: end; height: 190px; }
.col { display: grid; grid-template-rows: 1fr auto; gap: 0.45rem; height: 100%; justify-items: center; }
.col .stack { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; width: 100%; height: 100%; }
.col i { display: block; width: 100%; max-width: 26px; border-radius: 5px 5px 2px 2px; background: var(--primary); min-height: 2px; }
.col.today i { background: var(--accent); }
.col.off i { background: var(--line); }
.col b { font: 500 0.625rem/1 var(--mono); color: var(--muted); }
.col span { font: 500 0.625rem/1 var(--mono); color: var(--muted); }
.hbars { display: grid; gap: 0.85rem; }
.hbar { display: grid; gap: 0.35rem; }
.hbar div { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.8125rem; }
.hbar div b { font: 500 0.8125rem/1.5 var(--mono); color: var(--muted); white-space: nowrap; }
.hbar i { display: block; height: 8px; border-radius: 4px; background: var(--primary); min-width: 4px; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; gap: 0.75rem; padding: 0.6rem 1rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand .logo { width: 48px; }
  .brand-name { font-size: 1rem; }
  .nav { display: flex; margin-left: auto; gap: 0.1rem; }
  .nav a { padding: 0.55rem; }
  .nav a span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .rail-foot { display: none; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .search { max-width: none; margin-left: 0; flex-basis: 100%; }
  .who span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
