:root {
  --bg: #0d1117; --bg2: #161b22; --bg3: #21262d; --border: #30363d;
  --fg: #e6edf3; --muted: #8b949e; --accent: #2f81f7;
  --green: #3fb950; --red: #f85149; --yellow: #d29922; --purple: #a371f7;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 24px; }
code { font-family: var(--mono); background: var(--bg3); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
a { color: var(--accent); text-decoration: none; }

/* buttons & inputs */
.btn { background: var(--bg3); color: var(--fg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap; }
.btn:hover { background: #30363d; border-color: #8b949e; }
.btn.primary { background: #238636; border-color: #2ea043; }
.btn.primary:hover { background: #2ea043; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red); color: white; border-color: var(--red); }
.btn.ghost { background: transparent; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, textarea, select { width: 100%; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; font: inherit; }
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,129,247,.25); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--fg); }
label.check input { width: auto; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px 4px; margin: 0 0 14px; }
legend { color: var(--fg); font-weight: 600; padding: 0 6px; font-size: 13px; }
.error { color: var(--red); min-height: 18px; font-size: 12.5px; margin: 6px 0; }

/* overlays */
.overlay { position: fixed; inset: 0; background: rgba(1,4,9,.75); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 20px; max-height: 95vh; overflow: auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 18px; }
.card-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; }
.login-card { width: 360px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0; font-size: 22px; }
.editor-card { width: 820px; max-width: 100%; }
.picker-card { width: 640px; max-width: 100%; display: flex; flex-direction: column; gap: 10px; }
.roots { display: flex; flex-wrap: wrap; gap: 6px; }
.roots button { font-family: var(--mono); }
.dir-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 8px; max-height: 320px; overflow: auto; }
.dir-list li { padding: 7px 12px; cursor: pointer; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 13px; }
.dir-list li:last-child { border-bottom: none; }
.dir-list li:hover { background: var(--bg3); }
.files { max-height: 60px; overflow: auto; font-family: var(--mono); }
.hints { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 10px; }
.hints button { font-size: 12px; }

/* layout */
.layout { display: grid; grid-template-columns: 260px 1fr; height: 100vh; }
.sidebar { background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.brand .logo { font-size: 18px; }
.dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.dot.on { background: var(--green); }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 6px; font-size: 11px; font-weight: 600; letter-spacing: .5px; }
.project-list { list-style: none; margin: 0; padding: 4px 8px; overflow: auto; flex: 1; }
.project-list li { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.project-list li:hover { background: var(--bg3); }
.project-list li.active { background: var(--bg3); font-weight: 600; }
.project-list .sub { display: block; font-size: 11px; color: var(--muted); font-weight: 400; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-list .txt { min-width: 0; flex: 1; }
.sidebar-foot { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.empty { margin: auto; text-align: center; }
#projectView { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.project-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.project-header h2 { margin: 0 0 2px; font-size: 20px; }
.actions { display: flex; gap: 8px; align-items: center; }
.split { display: grid; grid-template-columns: 300px 1fr; flex: 1; min-height: 0; }
.runs { border-right: 1px solid var(--border); overflow: auto; }
.panel-title { padding: 10px 16px; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .5px; }
.run-list { list-style: none; margin: 0; padding: 0; }
.run-list li { padding: 10px 16px; border-top: 1px solid var(--border); cursor: pointer; display: flex; gap: 10px; align-items: flex-start; }
.run-list li:hover { background: var(--bg2); }
.run-list li.active { background: var(--bg3); }
.run-list .txt { flex: 1; min-width: 0; }
.run-list .t { font-weight: 600; }
.run-list .s { font-size: 11.5px; color: var(--muted); }
.run-detail { display: flex; flex-direction: column; min-height: 0; }
#runView { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.run-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap; }

/* status */
.badge, .st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg3); }
.st { padding: 0; border: none; background: none; width: 16px; height: 16px; justify-content: center; font-size: 13px; flex-shrink: 0; margin-top: 2px; }
.success { color: var(--green); } .failed { color: var(--red); } .cancelled { color: var(--muted); }
.running { color: var(--yellow); } .queued { color: var(--muted); } .skipped { color: var(--muted); }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--yellow); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* steps + log */
.steps { display: flex; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 6px; padding: 3px 10px; font-size: 12px; background: var(--bg2); }
.step .d { color: var(--muted); font-family: var(--mono); }
.log { flex: 1; overflow: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; padding: 8px 0 24px; background: #0a0d12; }
.log .g { margin: 2px 0; }
.log .gh { padding: 3px 14px; cursor: pointer; user-select: none; color: var(--fg); background: var(--bg2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; position: sticky; top: 0; }
.log .gh .arrow { transition: transform .15s; display: inline-block; width: 10px; color: var(--muted); }
.log .g.open .gh .arrow { transform: rotate(90deg); }
.log .gb { display: none; }
.log .g.open .gb { display: block; }
.log .l { padding: 0 14px 0 44px; white-space: pre-wrap; word-break: break-all; color: #c9d1d9; position: relative; }
.log .l::before { content: attr(data-n); position: absolute; left: 0; width: 34px; text-align: right; color: #484f58; font-size: 11px; }
.log .l.cmd { color: #79c0ff; }
.log .l.err { color: #ff7b72; }
.log .l.ok { color: var(--green); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { max-height: 40vh; }
  .split { grid-template-columns: 1fr; grid-template-rows: 200px 1fr; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
