:root {
  --bg: #111318; --surface: #191c23; --card: #1d212a;
  --accent: #e8b84b; --text: #eeeeee; --muted: #8a90a0;
  --ok: #4caf7d; --warn: #e07a5f; --radius: 12px;
  --stage-done: #3d7a5c; --stage-next: #2a2f3a;
}
[hidden] { display: none !important; }
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  min-height: 100vh; padding-bottom: 40px;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--surface);
  border-bottom: 1px solid #2a2f3a; position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 800; font-size: 18px; }
.brand-sub { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 6px; }
.topbar-right { display: flex; gap: 6px; align-items: center; }
.model-select { max-width: 240px; font-size: 12px; padding: 6px 8px; }
main { padding: 14px; display: flex; flex-direction: column; gap: 14px; max-width: 980px; margin: 0 auto; }
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px 16px; border: 1px solid #262b36;
}
.card.slim { padding: 12px 14px; }
.sec-title { font-size: 14px; margin-bottom: 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.row { display: flex; gap: 8px; }
input, select {
  flex: 1; background: var(--surface); border: 1px solid #2a2f3a; color: var(--text);
  padding: 10px 12px; border-radius: 8px; font-size: 14px; min-width: 0;
}
.btn {
  background: var(--accent); color: #111; border: none; border-radius: 8px;
  padding: 10px 14px; font-weight: 700; font-size: 14px; cursor: pointer;
  text-decoration: none; display: inline-block;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost, .btn-sm.ghost { background: transparent; color: var(--text); border: 1px solid #2a2f3a; }
.btn.sm { padding: 6px 10px; font-size: 12px; }

/* Темы — горизонтальная лента-чипов */
.topics-strip { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 4px;
  mask-image: linear-gradient(90deg, #000 90%, transparent); }
.topics-strip:empty { display: none; }
.chip {
  flex: 0 0 auto; max-width: 320px; padding: 8px 12px;
  border: 1px solid #2a2f3a; border-radius: 999px; font-size: 12px;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--muted);
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip b { color: var(--accent); font-weight: 600; }

/* Конвейер-лента: труба стадий */
.lane {
  display: flex; align-items: center; gap: 0;
  mask-image: linear-gradient(90deg, #000 92%, transparent);
  background: #161920; border: 1px solid #262b36; border-radius: 10px;
  padding: 14px 16px 14px 12px; overflow-x: auto;
}
.stage-node {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 74px;
}
.stage-dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--stage-next); border: 2px solid #3a4150;
  display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #565f70;
}
.stage-node.done .stage-dot { background: var(--stage-done); border-color: var(--stage-done); color: #dff5ea; }
.stage-node.cur .stage-dot {
  background: var(--accent); border-color: var(--accent); color: #111;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(232,184,75,.18); } }
.stage-node.fin .stage-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.stage-name { font-size: 10px; color: var(--muted); text-transform: lowercase; text-align: center; }
.stage-node.cur .stage-name { color: var(--accent); font-weight: 700; }
.stage-link { width: 26px; height: 3px; background: var(--stage-next); flex: 0 0 auto; }
.stage-link.done { background: var(--stage-done); }

/* Пружинки проектов под лентой */
.projects-rail { display: flex; gap: 8px; overflow-x: auto; padding-top: 10px; }
.projects-rail:empty { display: none; }
.rail-chip {
  flex: 0 0 auto; padding: 7px 12px; border-radius: 8px; font-size: 12px;
  background: var(--surface); border: 1px solid #2a2f3a; cursor: pointer;
  max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-chip:hover { border-color: var(--accent); }
.rail-chip .n { color: var(--accent); font-weight: 700; margin-right: 6px; }

/* Плитки проектов с прогрессом */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.tile {
  background: var(--surface); border: 1px solid #2a2f3a; border-radius: 10px;
  padding: 12px 14px; cursor: pointer; transition: border-color .15s;
}
.tile:hover { border-color: var(--accent); }
.tile.sel { border-color: var(--accent); background: #20242e; }
.tile-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.tile-title { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { color: var(--muted); font-size: 11px; margin-top: 4px; }
.tile-bar { display: flex; gap: 3px; margin-top: 10px; }
.tile-bar .seg { flex: 1; height: 7px; border-radius: 4px; background: var(--stage-next); }
.tile-bar .seg.done { background: var(--stage-done); }
.tile-bar .seg.cur { background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.tile-bar .seg.fin { background: var(--ok); }
.tile-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.badge {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: #262b36; color: var(--muted); white-space: nowrap;
}
.badge.ok { background: rgba(76,175,125,.15); color: var(--ok); }
.badge.run { background: rgba(232,184,75,.15); color: var(--accent); }

/* Деталь */
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-head .sec-title { margin-bottom: 0; }
.proj-actions { display: flex; gap: 6px; }
.log {
  background: #0d0f14; border-radius: 8px; padding: 10px; margin-top: 10px;
  font-family: monospace; font-size: 11px; line-height: 1.5;
  max-height: 300px; overflow: auto; white-space: pre-wrap; word-break: break-all;
  color: #c5cad6;
}
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--accent); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; z-index: 50;
  max-width: 90vw;
}
.toast:empty { display: none; }

/* Скроллбары в тему */
::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2f3a; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a4150; }
