@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #1e1f22;
  --side: #232427;
  --panel: #2b2d30;
  --raised: #26282b;
  --editor: #1b1c1f;
  --line: #393b40;
  --line-strong: #4e5157;
  --ink: #dfe1e5;
  --muted: #8f929a;
  --faint: #6b6e76;
  --blue: #3574f0;
  --blue-hover: #4b86f6;
  --blue-soft: #2a3142;
  --green: #6aab73;
  --yellow: #d6b15a;
  --red: #f75464;
  --selection: #214283;
  --top-h: 38px;
  --status-h: 24px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12.5px;
  line-height: 1.5;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.35rem 0.75rem;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

button:hover { background: var(--blue-hover); }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--blue-hover); outline-offset: 1px; }

button.ghost {
  background: #35373b;
  color: var(--ink);
  border-color: var(--line);
}

button.ghost:hover:not(:disabled) { background: #3f4247; }
button.small { padding: 0.2rem 0.5rem; font-size: 12px; }

button.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--blue-hover);
}

button.link:hover { text-decoration: underline; background: none; }

h1, h2, h3 { font-weight: 700; letter-spacing: 0; margin: 0; }
h1 { font-size: 15px; }
h2 { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
h3 { font-size: 12.5px; }

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 0.3em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #2f3135;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
}

.hint { color: var(--muted); margin: 0; }
.error { color: var(--red); min-height: 1.2em; margin: 0; }

label { display: grid; gap: 0.3rem; color: var(--muted); }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--editor);
  color: var(--ink);
  padding: 0.35rem 0.5rem;
}

input:focus, textarea:focus, select:focus {
  outline: 1px solid var(--blue);
  border-color: var(--blue);
}

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

.brand { display: flex; align-items: center; gap: 0.5rem; }
.mark {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--blue) 0 50%, var(--green) 50% 100%);
}

/* вход */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.gate form {
  width: min(24rem, 100%);
  padding: 1.25rem;
  display: grid;
  gap: 0.85rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* каркас */

#app {
  height: 100vh;
  display: grid;
  grid-template-rows: var(--top-h) 1fr var(--status-h);
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0 0.75rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.top-right { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.top-right .hint, .top-right .error { min-height: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36rem; }
.crumb { color: var(--muted); }
.crumb::before { content: "/"; margin-right: 0.5rem; color: var(--faint); }
.crumb:empty { display: none; }

.shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  min-height: 0;
}

.side {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  background: var(--side);
  border-right: 1px solid var(--line);
}

.side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.job-list { overflow: auto; padding: 0.3rem; display: grid; gap: 1px; align-content: start; }
.job-list .hint { padding: 0.75rem; }

.job {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 0.15rem 0.6rem;
  align-items: center;
  text-align: left;
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--ink);
}

.job:hover:not(.active) { background: #2d2f33; }
.job.active { background: var(--blue-soft); border-color: #34446a; }
.job.child {
  margin-left: calc(var(--depth, 1) * 14px);
  width: calc(100% - var(--depth, 1) * 14px);
  position: relative;
}
.job.child::before {
  content: "";
  position: absolute;
  left: -9px;
  top: -2px;
  height: 1.1rem;
  width: 7px;
  border-left: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  border-bottom-left-radius: 4px;
}

.job-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { grid-column: 2 / 4; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-time { color: var(--faint); font-size: 11.5px; }

.tag {
  display: inline-block;
  padding: 0 0.4em;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--muted);
  font-size: 11px;
}

/* статусы */

.dot { width: 12px; height: 12px; border-radius: 50%; position: relative; display: inline-block; flex: none; }
.dot.queued { border: 2px dashed var(--yellow); }
.dot.running { border: 2px solid var(--blue); border-right-color: transparent; animation: spin 0.9s linear infinite; }
.dot.done { background: var(--green); }
.dot.done::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 1.5px;
  width: 3px;
  height: 6px;
  border: solid #1e1f22;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}
.dot.failed { background: var(--red); }
.dot.failed::after { content: "×"; position: absolute; inset: 0; display: grid; place-items: center; color: #1e1f22; font-weight: 700; line-height: 1; font-size: 11px; }
.dot.cancelled { border: 2px solid var(--faint); }
.dot.cancelled::after { content: ""; position: absolute; left: 1.5px; top: 3.5px; width: 5px; height: 1.5px; background: var(--faint); }

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .dot.running { animation: none; }
}

.pill { padding: 0 0.55em; border-radius: 99px; border: 1px solid var(--line-strong); font-size: 11.5px; color: var(--muted); }
.pill.queued { color: var(--yellow); border-color: #5c4f2b; }
.pill.running { color: var(--blue-hover); border-color: #34446a; }
.pill.done { color: var(--green); border-color: #3a5a40; }
.pill.failed { color: var(--red); border-color: #6a2f37; }

/* рабочая область */

.main { overflow: auto; min-width: 0; }
.view { min-width: 0; max-width: 62rem; padding: 1rem 1.25rem 2rem; display: grid; gap: 0.9rem; align-content: start; }
.view-head { display: grid; gap: 0.25rem; }
.toolbar { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }

.projects { display: grid; gap: 0.4rem; }

.project {
  display: grid;
  grid-template-columns: minmax(9rem, 12rem) 1fr minmax(10rem, 1fr);
  gap: 0.5rem 0.75rem;
  align-items: center;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--raised);
}

.project:has(input[type="checkbox"]:checked) { border-color: #34446a; background: #262b36; }
.project .who { display: grid; gap: 0.1rem; }
.project .who label { display: flex; align-items: center; gap: 0.5rem; color: var(--ink); font-weight: 700; }
.project .who small { color: var(--muted); padding-left: 1.6rem; }
.project input[type="checkbox"] { width: auto; accent-color: var(--blue); }

/* карточка прогона */

.detail-head { display: grid; gap: 0.35rem; }
.detail-title { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.detail-title h1 { overflow-wrap: anywhere; }
.meta { color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }

a.button {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  background: #35373b;
  text-decoration: none;
  color: var(--ink);
}

a.button:hover { background: #3f4247; }

.repeat {
  display: grid;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: 4px;
  background: var(--raised);
}

.repeat textarea { min-height: 3.5rem; }
.drift { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { padding: 0.1rem 0.55rem; border-radius: 3px; background: #2f3135; border: 1px solid var(--line); color: var(--muted); }
.chip.fresh { color: var(--green); border-color: #3a5a40; background: #263029; }
.chip.warn { color: var(--yellow); border-color: #5c4f2b; }

.tabs { display: flex; gap: 0.2rem; border-bottom: 1px solid var(--line); }
.tab {
  background: none;
  color: var(--muted);
  border-radius: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 0.4rem 0.8rem;
  margin-bottom: -1px;
}
.tab:hover { background: none; color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--blue); }
.tabs .spacer { flex: 1; }
.tabs .copy { align-self: center; }

.pane { min-height: 8rem; }
.empty { color: var(--muted); padding: 1.5rem 0; }

pre {
  margin: 0;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 38rem;
  padding: 0.7rem 0.85rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--editor);
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.55;
}

/* markdown */

.md { line-height: 1.6; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md h2, .md h3, .md h4, .md h5 { margin: 1.3rem 0 0.4rem; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 13.5px; }
.md h2 { font-size: 15px; padding-bottom: 0.3rem; border-bottom: 1px solid var(--line); }
.md h4, .md h5 { color: var(--muted); }
.md p { margin: 0.5rem 0; }
.md ul, .md ol { margin: 0.4rem 0; padding-left: 1.4rem; }
.md li { margin: 0.15rem 0; }
.md code {
  padding: 0.05em 0.35em;
  border-radius: 3px;
  background: #2f3135;
  color: #e6c07b;
  font-family: inherit;
  font-size: 0.95em;
}
.md pre { margin: 0.6rem 0; max-height: none; }
.md pre code { padding: 0; background: none; color: inherit; font-size: inherit; }
.md blockquote { margin: 0.6rem 0; padding: 0.1rem 0.8rem; border-left: 3px solid var(--line-strong); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.md a { color: var(--blue-hover); }
.md table { border-collapse: collapse; margin: 0.6rem 0; display: block; overflow: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 0.25rem 0.6rem; text-align: left; vertical-align: top; }
.md th { background: var(--raised); }

/* статус-бар */

.statusbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 0.75rem;
  background: var(--panel);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  min-width: 0;
}

.sb-item { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.sb-spacer { flex: 1; }
.sb-item .dot { width: 8px; height: 8px; border-width: 0; }
.sb-item .dot.ok { background: var(--green); }
.sb-item .dot.bad { background: var(--red); }

::selection { background: var(--selection); }

@media (max-width: 860px) {
  #app { height: auto; min-height: 100vh; grid-template-rows: auto auto auto; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .view { padding: 0.8rem; }
  .top-right .hint, .top-right .error { display: none; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .job-list { max-height: 14rem; }
  .project { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; padding: 0.4rem 0.75rem; }
  .sb-keys { display: none; }
}
