  :root {
    --bg: #080d16;
    --surface: #0e1726;
    --surface-2: #121d2f;
    --surface-3: #17243a;
    --line: #1d2b41;
    --line-soft: #152136;
    --line-strong: #2a3e5c;
    --text: #e7eef9;
    --muted: #8b9bb3;
    --dim: #74869f;
    --accent: #5b8dd6;
    --accent-2: #2fc8f0;
    --green: #42c59a;
    --amber: #e3ab53;
    --red: #e26868;
    --violet: #9d8cf0;
    --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
    --radius: 11px;
    --shadow: 0 18px 50px rgba(0, 0, 0, .35);
  }

  * { box-sizing: border-box; }

  html { scroll-behavior: smooth; }

  body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
  }

  button, input, select, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; }
  a { color: inherit; text-decoration: none; }
  ::selection { background: rgba(47, 200, 240, .24); }

  button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: 2px;
  }

  .ic { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
  .ic.sm { width: 14px; height: 14px; }
  .sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

  .app { display: flex; min-height: 100vh; position: relative; z-index: 1; }
  .app[hidden] { display: none; }

  /* Rail */
  .rail {
    width: 232px;
    flex: 0 0 232px;
    border-right: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(14, 23, 38, .96), rgba(8, 13, 22, .98));
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px 14px 14px;
    display: flex;
    flex-direction: column;
    z-index: 20;
  }

  .brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
  .brand-mark {
    width: 44px; height: 44px; display: grid; place-items: center;
    background: radial-gradient(circle at 50% 46%, rgba(47, 200, 240, .09), transparent 68%);
    border: 0; box-shadow: none; overflow: visible; border-radius: 10px;
  }
  .brand-mark img {
    width: 44px; height: 44px; display: block; object-fit: contain;
    filter: drop-shadow(0 0 12px rgba(47, 200, 240, .28));
  }
  .brand-name { font-size: 16px; font-weight: 750; letter-spacing: .12em; line-height: 1; }
  .brand-sub { margin-top: 4px; font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }

  .nav { display: flex; flex-direction: column; gap: 3px; }
  .nav-label { padding: 16px 10px 6px; font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); font-weight: 650; }
  .nav-sep { height: 1px; background: var(--line-soft); margin: 12px 6px; }
  .nav-item {
    width: 100%; border: 1px solid transparent; background: none; color: var(--muted);
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
    text-align: left; font-size: 13px; font-weight: 550; transition: background .15s, color .15s, border-color .15s;
  }
  .nav-item:hover { background: rgba(23, 36, 58, .65); color: var(--text); }
  .nav-item.active {
    color: #deebff;
    background: linear-gradient(90deg, rgba(74, 123, 200, .2), rgba(74, 123, 200, .035));
    border-color: rgba(91, 141, 214, .26);
    box-shadow: inset 2px 0 0 var(--accent);
  }
  .nav-item .nav-count {
    margin-left: auto; min-width: 21px; text-align: center; font: 10px var(--mono);
    color: var(--muted); background: rgba(23, 36, 58, .9); border: 1px solid var(--line);
    border-radius: 999px; padding: 1px 6px;
  }
  .nav-item.active .nav-count { color: #b9d3f5; border-color: rgba(91, 141, 214, .28); }
  .nav-item .nav-live { margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(66, 197, 154, .8); }
  .nav-item.active .nav-live { margin-left: auto; }

  .rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
  .owner {
    display: flex; align-items: center; gap: 9px; padding: 9px; border: 1px solid var(--line);
    border-radius: 9px; background: rgba(14, 23, 38, .7);
  }
  .owner-name { font-size: 12px; font-weight: 600; }
  .owner-role { font-size: 9.5px; color: var(--dim); font-family: var(--mono); }
  .env {
    display: flex; align-items: center; gap: 7px; padding: 2px 7px;
    font-size: 10px; color: var(--dim); letter-spacing: .04em;
  }
  .env .mono { margin-left: auto; }

  .avatar {
    width: 30px; height: 30px; border-radius: 8px; display: inline-grid; place-items: center;
    font-size: 11px; font-weight: 750; color: #d9e9ff; flex: 0 0 auto;
    background: linear-gradient(145deg, #26456f, #172a47);
    border: 1px solid rgba(91, 141, 214, .45);
  }
  .avatar.tiny { width: 22px; height: 22px; border-radius: 6px; font-size: 8.5px; }
  .avatar.green { background: linear-gradient(145deg, #1d5849, #123c33); border-color: rgba(66, 197, 154, .35); color: #bff3e1; }
  .avatar.violet { background: linear-gradient(145deg, #3a3168, #25204a); border-color: rgba(157, 140, 240, .35); color: #ded7ff; }

  /* Main */
  .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

  .topbar {
    height: 64px; display: flex; align-items: center; gap: 18px;
    padding: 0 28px; border-bottom: 1px solid var(--line);
    background: rgba(8, 13, 22, .78); backdrop-filter: blur(14px);
    position: sticky; top: 0; z-index: 15;
  }
  .crumb { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); white-space: nowrap; }
  .crumb b { color: var(--text); font-weight: 600; }
  .crumb .ic { width: 13px; height: 13px; }
  .crumb-time { margin-left: 5px; font-size: 9.5px; color: var(--dim); letter-spacing: .02em; }

  .search {
    flex: 1; max-width: 520px; margin-left: auto; min-width: 0; height: 34px;
    display: flex; align-items: center; gap: 9px; padding: 0 10px;
    border: 1px solid var(--line); border-radius: 8px; background: rgba(14, 23, 38, .68);
    color: var(--dim); font-size: 12px; text-align: left;
  }
  .search:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--muted); }
  .search span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  kbd {
    margin-left: auto; font: 9.5px var(--mono); color: var(--dim);
    border: 1px solid var(--line); border-bottom-color: var(--line-strong);
    background: var(--surface); border-radius: 4px; padding: 2px 5px; white-space: nowrap;
  }

  .top-actions { display: flex; align-items: center; gap: 8px; }
  .live-toggle {
    display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 10px;
    border: 1px solid rgba(66, 197, 154, .25); border-radius: 999px;
    background: rgba(66, 197, 154, .07); color: var(--green); font: 10px var(--mono); letter-spacing: .1em;
  }
  .live-toggle.paused { color: var(--amber); border-color: rgba(227, 171, 83, .28); background: rgba(227, 171, 83, .07); }
  .live-toggle .live-sub { color: var(--dim); letter-spacing: 0; }
  .live-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 9px currentColor; animation: pulse 1.9s ease-in-out infinite; }
  .live-toggle.paused .live-dot { animation: none; }
  .bell {
    width: 34px; height: 34px; display: grid; place-items: center; position: relative;
    border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted);
  }
  .bell:hover { color: var(--text); border-color: var(--line-strong); }
  .badge {
    position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 4px;
    display: grid; place-items: center; border-radius: 999px; background: var(--red); color: #fff;
    font: 9px var(--mono); border: 2px solid var(--bg);
  }
  .top-avatar { width: 32px; height: 32px; }

  .content { padding: 26px 28px 70px; width: 100%; max-width: 1640px; margin: 0 auto; }

  /* Views */
  .view { display: none; }
  .view.active { display: block; animation: fadeUp .25s ease; }

  .page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
  .page-head h1 { margin: 0; font-size: 27px; line-height: 1.12; letter-spacing: -.025em; font-weight: 680; }
  .page-head .sub { margin: 7px 0 0; color: var(--muted); font-size: 13px; max-width: 760px; }
  .eyebrow { margin: 0 0 8px; font: 10px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
  .head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

  .panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, .016), transparent 38%), var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    min-width: 0;
  }
  .panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 15px 17px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
  .panel-head .actions { max-width: 100%; flex-wrap: wrap; }
  .panel-head .pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .action-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
  .action-bar .hint { margin-left: auto; color: var(--dim); font: 10px var(--mono); }
  .sync-box .action-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
  .sync-box .action-bar .btn { width: 100%; min-width: 0; padding: 0 6px; white-space: nowrap; }
  .panel-head h2 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -.005em; }
  .panel-head p { margin: 4px 0 0; color: var(--dim); font-size: 11.5px; }
  .panel-body { padding: 16px 17px; }
  .panel-link { border: 0; background: none; color: var(--accent); font-size: 11.5px; display: inline-flex; align-items: center; gap: 4px; padding: 2px; white-space: nowrap; }
  .panel-link:hover { color: var(--accent-2); }

  .mono { font-family: var(--mono); }
  .dim { color: var(--dim); }
  .muted { color: var(--muted); }
  .num { font-variant-numeric: tabular-nums; }

  /* Pills and tags */
  .pill {
    display: inline-flex; align-items: center; gap: 5px; border: 1px solid; border-radius: 999px;
    padding: 2px 7px; font-size: 10px; font-weight: 650; white-space: nowrap; line-height: 1.5;
  }
  .pill[hidden] { display: none; }
  .pill .dot { width: 5px; height: 5px; }
  .pill.green { color: var(--green); background: rgba(66, 197, 154, .075); border-color: rgba(66, 197, 154, .22); }
  .pill.amber { color: var(--amber); background: rgba(227, 171, 83, .08); border-color: rgba(227, 171, 83, .24); }
  .pill.red { color: var(--red); background: rgba(226, 104, 104, .08); border-color: rgba(226, 104, 104, .24); }
  .pill.blue { color: #85b4ff; background: rgba(91, 141, 214, .1); border-color: rgba(91, 141, 214, .28); }
  .pill.cyan { color: var(--accent-2); background: rgba(47, 200, 240, .07); border-color: rgba(47, 200, 240, .23); }
  .pill.violet { color: var(--violet); background: rgba(157, 140, 240, .08); border-color: rgba(157, 140, 240, .24); }
  .pill.dim { color: var(--muted); background: rgba(93, 109, 133, .08); border-color: var(--line); }

  .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
  .dot.green { background: var(--green); box-shadow: 0 0 7px rgba(66, 197, 154, .55); }
  .dot.amber { background: var(--amber); box-shadow: 0 0 7px rgba(227, 171, 83, .5); }
  .dot.red { background: var(--red); box-shadow: 0 0 7px rgba(226, 104, 104, .5); }
  .dot.cyan { background: var(--accent-2); box-shadow: 0 0 7px rgba(47, 200, 240, .5); }
  .dot.dim { background: var(--dim); }

  .tag {
    display: inline-flex; align-items: center; gap: 4px; padding: 1px 5px;
    border: 1px solid var(--line); border-radius: 4px; background: rgba(18, 29, 47, .65);
    color: var(--muted); font: 9.5px var(--mono); white-space: nowrap;
  }
  .tag.cyan { color: var(--accent-2); border-color: rgba(47, 200, 240, .2); }
  .tag.amber { color: var(--amber); border-color: rgba(227, 171, 83, .2); }

  /* Buttons */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 550;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
  }
  .btn:hover { background: var(--surface-3); border-color: var(--line-strong); }
  .btn.primary {
    background: linear-gradient(180deg, #4f82cf, #3e6bb2);
    border-color: #5f93e0; color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset;
  }
  .btn.primary:hover { background: linear-gradient(180deg, #5b8fdd, #4674bd); }
  .btn.ghost { background: transparent; }
  .btn.ghost:hover { background: rgba(23, 36, 58, .65); }
  .btn.danger { color: #f0a1a1; background: rgba(226, 104, 104, .07); border-color: rgba(226, 104, 104, .24); }
  .btn.danger:hover { background: rgba(226, 104, 104, .13); }
  .btn.sm { height: 28px; padding: 0 9px; font-size: 11px; }
  .btn.icon { width: 31px; padding: 0; }
  .btn[disabled] { opacity: .45; pointer-events: none; }

  /* KPI */
  .kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 11px; }
  .kpi {
    position: relative; overflow: hidden; text-align: left; padding: 13px 14px 12px;
    border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
    transition: border-color .15s, background .15s, transform .15s; min-width: 0;
  }
  .kpi::after {
    content: ""; position: absolute; inset: 0 0 auto; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(91, 141, 214, .45), transparent);
    opacity: .5;
  }
  button.kpi:hover { border-color: var(--line-strong); background: var(--surface-2); transform: translateY(-1px); }
  .kpi-label { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); font-weight: 650; }
  .kpi-value { margin-top: 4px; font-size: 25px; line-height: 1.05; font-weight: 680; letter-spacing: -.035em; display: flex; align-items: baseline; gap: 3px; }
  .kpi-value .slash { color: var(--dim); font-weight: 400; font-size: 16px; }
  .kpi-foot { margin-top: 4px; font-size: 10.5px; color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: 3px 5px; }
  .kpi-trend { margin-left: auto; font: 9.5px var(--mono); color: var(--dim); white-space: nowrap; }
  .kpi-trend.up { color: var(--green); }
  .kpi-trend.warn { color: var(--amber); }

  /* Overview */
  .overview-top { margin-top: 13px; display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(290px, 1fr); gap: 13px; align-items: stretch; }
  .overview-side { display: flex; flex-direction: column; gap: 13px; min-width: 0; }
  .overview-bottom { margin-top: 13px; display: grid; grid-template-columns: 1.15fr 1.05fr .95fr; gap: 13px; }

  .flow-map { padding: 2px 8px 8px; overflow-x: auto; }
  .flow-map svg { display: block; width: 100%; height: auto; min-width: 700px; }
  .flow-map text { font-family: "Segoe UI", system-ui, sans-serif; }
  .map-col { fill: var(--dim); font-size: 9px; font-weight: 700; letter-spacing: .13em; }
  .map-node rect.box { fill: #101a2b; stroke: #223149; stroke-width: 1; }
  .map-node:hover rect.box { stroke: #3a5a84; }
  .map-node .n-title { fill: #dfe9f7; font-size: 12.2px; font-weight: 600; }
  .map-node .n-sub { fill: #8999b0; font-size: 10.2px; }
  .map-node .n-count { fill: #c7d6ea; font-size: 10px; font-family: var(--mono); }
  .map-node .n-dim { fill: #64748b; font-size: 10px; }
  .map-node.human rect.box { fill: #0f1c2f; stroke: rgba(91, 141, 214, .4); }
  .map-link { fill: none; stroke: #24344c; stroke-width: 1.45; }
  .map-link.active { stroke: var(--accent-2); stroke-width: 1.7; stroke-dasharray: 5 7; animation: dash 1.8s linear infinite; filter: drop-shadow(0 0 3px rgba(47, 200, 240, .35)); }
  .map-link.wait { stroke: var(--amber); stroke-width: 1.7; stroke-dasharray: 2 6; animation: dash 2.2s linear infinite; }
  .map-link.quiet { stroke-dasharray: 3 8; }
  .map-link-label {
    fill: #8fa2bb; font-size: 9px; font-family: var(--mono); text-anchor: middle;
    paint-order: stroke; stroke: #0b1321; stroke-width: 4px; stroke-linejoin: round;
  }
  .map-link-label.cyan { fill: #6fe0fa; }
  .map-link-label.amber { fill: #efc47d; }
  .map-legend { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; padding: 0 17px 11px; font-size: 10.5px; color: var(--dim); }
  .map-legend span { display: inline-flex; align-items: center; gap: 5px; }
  .legend-line { display: inline-block; width: 18px; height: 0; border-top: 1.5px solid var(--line-strong); }
  .legend-line.cyan { border-color: var(--accent-2); }
  .legend-line.amber { border-color: var(--amber); border-top-style: dashed; }

  /* Decisions */
  .decision-list { padding: 8px; display: flex; flex-direction: column; gap: 7px; }
  .decision {
    display: block; width: 100%; text-align: left; border: 1px solid var(--line-soft);
    background: rgba(18, 29, 47, .55); border-radius: 8px; padding: 10px 11px;
    transition: border-color .15s, background .15s;
  }
  .decision:hover { border-color: var(--line-strong); background: var(--surface-2); }
  .decision-top { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
  .decision-top .mono { margin-left: auto; font-size: 9.5px; color: var(--dim); }
  .decision-title { font-size: 12px; font-weight: 620; line-height: 1.3; }
  .decision-sub { margin-top: 3px; font-size: 10.5px; color: var(--dim); }
  .decision.critical { border-left: 2px solid var(--red); }
  .decision.warn { border-left: 2px solid var(--amber); }
  .decision.info { border-left: 2px solid var(--accent); }

  .pulse-body { padding: 10px 15px 14px; }
  .pulse-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 9px; }
  .pulse-stats div { font-size: 10px; color: var(--dim); }
  .pulse-stats b { display: block; margin-top: 2px; font: 13px var(--mono); color: var(--text); font-weight: 500; }
  .spark { width: 100%; height: 58px; display: block; }
  .spark .grid { stroke: #1b2940; stroke-width: 1; }
  .spark .area { fill: rgba(47, 200, 240, .08); }
  .spark .line { fill: none; stroke: var(--accent-2); stroke-width: 1.7; filter: drop-shadow(0 0 4px rgba(47, 200, 240, .3)); }

  /* Rows */
  .queue-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
  .queue-row:last-child { border-bottom: 0; padding-bottom: 2px; }
  .queue-row:first-child { padding-top: 2px; }
  .queue-name { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 550; }
  .queue-sub { margin: 3px 0 0 14px; font-size: 10px; color: var(--dim); }
  .queue-bar { margin: 7px 0 0 14px; display: flex; gap: 2px; height: 3px; border-radius: 999px; overflow: hidden; background: var(--line-soft); }
  .queue-bar i { display: block; height: 100%; }
  .queue-bar .active { background: var(--accent-2); }
  .queue-bar .wait { background: var(--amber); }
  .queue-bar .new { background: #3d5a80; }
  .queue-count { font: 10px var(--mono); color: var(--muted); align-self: start; padding-top: 2px; }
  .queue-count b { color: var(--text); font-weight: 500; }

  .health-row { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
  .health-row:last-child { border-bottom: 0; padding-bottom: 1px; }
  .health-main { min-width: 0; flex: 1; }
  .health-name { font-size: 11.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .health-task { margin-top: 1px; font-size: 9.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .health-ping { font: 9.5px var(--mono); color: var(--dim); text-align: right; }
  .health-ping b { display: block; color: var(--muted); font-weight: 400; }

  .event-mini { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
  .event-mini:last-child { border-bottom: 0; }
  .event-mini .ic { margin-top: 2px; color: var(--dim); }
  .event-mini-time { font: 9px var(--mono); color: var(--dim); white-space: nowrap; padding-top: 2px; }
  .event-mini-text { font-size: 10.5px; color: var(--muted); line-height: 1.4; }
  .event-mini-text b { color: var(--text); font-weight: 550; }

  /* Work board */
  .info-strip {
    display: flex; align-items: flex-start; gap: 9px; margin-bottom: 13px; padding: 9px 12px;
    border: 1px solid rgba(91, 141, 214, .18); border-radius: 8px;
    background: rgba(91, 141, 214, .055); color: var(--muted); font-size: 11px;
  }
  .info-strip .ic { color: var(--accent); margin-top: 1px; }
  .info-strip b { color: #bcd6f7; font-weight: 600; }
  .board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; align-items: start; }
  .lane { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(14, 23, 38, .55); min-height: 480px; display: flex; flex-direction: column; }
  .lane-head { padding: 12px 13px 10px; border-bottom: 1px solid var(--line-soft); }
  .lane-title { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 650; }
  .lane-title .lane-count { margin-left: auto; font: 10px var(--mono); color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px; }
  .lane-sub { margin: 3px 0 0 14px; font-size: 9.5px; color: var(--dim); }
  .lane-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
  .lane-empty { padding: 22px 10px; text-align: center; color: var(--dim); font-size: 10.5px; border: 1px dashed var(--line); border-radius: 7px; }

  .work-card {
    display: block; width: 100%; text-align: left; padding: 10px 11px;
    background: var(--surface); border: 1px solid var(--line); border-left: 2px solid var(--accent);
    border-radius: 7px; transition: border-color .15s, transform .15s, box-shadow .15s;
  }
  .work-card:hover { border-color: var(--line-strong); border-left-color: var(--accent-2); transform: translateY(-1px); box-shadow: 0 8px 18px rgba(0, 0, 0, .18); }
  .work-card[data-status="waiting"] { border-left-color: var(--amber); }
  .work-card[data-status="retry"] { border-left-color: var(--violet); }
  .work-card[data-status="new"] { border-left-color: #4a6d97; }
  .work-card[data-priority="high"] { background: linear-gradient(180deg, rgba(227, 171, 83, .045), transparent 60%), var(--surface); }
  .wc-top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
  .wc-source { font: 9px var(--mono); letter-spacing: .04em; color: var(--dim); text-transform: uppercase; }
  .wc-age { margin-left: auto; font: 9.5px var(--mono); color: var(--dim); }
  .wc-title { font-size: 12px; font-weight: 610; line-height: 1.32; letter-spacing: -.005em; }
  .wc-meta { margin-top: 6px; font-size: 10px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
  .wc-tags { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 4px; }
  .wc-foot { margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--line-soft); display: flex; align-items: center; gap: 6px; font-size: 9.5px; color: var(--dim); }
  .wc-foot .mono { margin-left: auto; font-size: 9px; }
  .wc-cooldown { margin-top: 6px; font: 9.5px var(--mono); color: var(--violet); display: flex; align-items: center; gap: 5px; }

  /* Two-column layouts */
  .scenario-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 13px; align-items: start; }
  .scenario-list { padding: 7px; position: sticky; top: 78px; }
  .scenario-item {
    display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
    padding: 9px 9px; border: 1px solid transparent; border-radius: 7px;
    background: none; color: var(--muted); transition: background .15s, border-color .15s, color .15s;
  }
  .scenario-item:hover { background: var(--surface-2); color: var(--text); }
  .scenario-item.active { background: rgba(74, 123, 200, .1); border-color: rgba(91, 141, 214, .24); color: var(--text); }
  .si-main { min-width: 0; flex: 1; }
  .si-name { display: block; font-size: 11.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .si-sub { display: block; margin-top: 1px; font-size: 9px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .si-stats { font: 9.5px var(--mono); color: var(--dim); white-space: nowrap; }
  .si-stats b { color: var(--muted); font-weight: 500; }
  .scenario-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 17px 13px; border-bottom: 1px solid var(--line-soft); }
  .scenario-head h2 { margin: 0; font-size: 19px; letter-spacing: -.015em; }
  .scenario-head .desc { margin: 5px 0 0; font-size: 11.5px; color: var(--muted); max-width: 680px; }
  .scenario-meta { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 17px; border-bottom: 1px solid var(--line-soft); }
  .meta-item { font-size: 10px; color: var(--dim); }
  .meta-item b { display: block; margin-top: 2px; font: 10.5px var(--mono); color: var(--muted); font-weight: 400; }
  .ctx { min-width: 150px; }
  .ctx-bar { height: 4px; margin-top: 5px; border-radius: 999px; overflow: hidden; background: var(--line-soft); }
  .ctx-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
  .ctx-bar.warn i { background: linear-gradient(90deg, var(--amber), var(--red)); }

  .tabs { display: flex; gap: 2px; padding: 9px 12px 0; border-bottom: 1px solid var(--line-soft); overflow-x: auto; }
  .tab {
    border: 0; border-bottom: 2px solid transparent; background: none; color: var(--dim);
    padding: 8px 10px 9px; font-size: 11.5px; font-weight: 550; white-space: nowrap;
  }
  .tab:hover { color: var(--muted); }
  .tab.active { color: var(--text); border-bottom-color: var(--accent); }
  .tab .count { font: 9px var(--mono); color: var(--dim); margin-left: 4px; }
  .tab-body { padding: 13px 15px 15px; min-height: 420px; }

  .chat { display: flex; flex-direction: column; min-height: 430px; }
  .chat-feed { flex: 1; display: flex; flex-direction: column; gap: 9px; padding: 2px 2px 12px; }
  .msg { max-width: 84%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line-soft); background: var(--surface-2); font-size: 11.5px; line-height: 1.45; }
  .msg .msg-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font: 9px var(--mono); color: var(--dim); }
  .msg .msg-head b { color: var(--muted); font-weight: 550; }
  .msg.human { align-self: flex-end; background: rgba(74, 123, 200, .11); border-color: rgba(91, 141, 214, .25); }
  .msg.orch { align-self: flex-start; background: var(--surface-2); }
  .msg.system { align-self: center; max-width: 94%; padding: 4px 9px; border: 1px dashed var(--line); background: transparent; color: var(--dim); font: 9.5px var(--mono); text-align: center; }
  .chat-form { display: flex; align-items: center; gap: 7px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
  .chat-form input {
    flex: 1; height: 34px; border: 1px solid var(--line); border-radius: 7px;
    background: var(--surface-2); padding: 0 10px; font-size: 11.5px; outline: none;
  }
  .chat-form input:focus { border-color: var(--accent); }
  .chat-form .icon-btn { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; }
  .chat-form .icon-btn:hover { color: var(--text); border-color: var(--line-strong); }

  .scenario-layout.collapsed { grid-template-columns: 1fr; }
  .scenario-layout.collapsed #scenarioList { display: none; }
  .scenario-list-toggle .ic { transform: rotate(180deg); transition: transform .15s ease; }
  .scenario-list-toggle.is-collapsed .ic { transform: none; }
  #view-scenarios { height: calc(100dvh - 56px); }
  #view-scenarios.active { display: flex; flex-direction: column; }
  #view-scenarios .page-head { flex: none; }
  #view-scenarios .scenario-layout { flex: 1; min-height: 0; align-items: stretch; }
  #scenarioDetail { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
  #scenarioDetail .scenario-head, #scenarioDetail .scenario-meta, #scenarioDetail .tabs { flex: none; }
  #scenarioDetail .tab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .chat-v2 { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .chat-v2-head { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; flex: none; }
  .chat-v2-title { flex: 1; min-width: 150px; }
  .chat-v2-title b, .chat-v2-title span { display: block; }
  .chat-v2-title span { color: var(--dim); font-size: 10px; }
  .chat-v2 .chat-feed { flex: 1; min-height: 0; overflow-y: auto; }
  .chat-v2 .chat-form { flex: none; }
  .chat-task-divider { margin: 5px 0 12px; padding: 7px 9px; border-left: 2px solid var(--accent); background: rgba(56,199,232,.06); color: var(--muted); font-size: 10px; }
  .chat-activity { margin: 4px 0 10px 24px; border: 1px solid var(--line-soft); border-radius: 7px; background: var(--surface); }
  .chat-activity summary { display: flex; gap: 7px; align-items: center; padding: 8px 9px; cursor: pointer; color: var(--muted); font-size: 10px; }
  .chat-activity summary b { flex: 1; font-weight: 500; }
  .chat-activity summary time { color: var(--dim); }
  .chat-activity-detail { padding: 0 10px 10px; color: var(--dim); font: 10px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
  .chat-activity.reasoning summary b { color: var(--violet); }
  .chat-activity.live summary span { color: var(--green); }
  .chat-activity:not([open]) .chat-copy-btn { display: none; }
  .chat-copy-btn { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-left: 6px; padding: 0; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--dim); cursor: pointer; flex: 0 0 auto; vertical-align: middle; }
  .chat-copy-btn:hover { color: var(--muted); background: var(--surface-2); border-color: var(--line-soft); }
  .chat-copy-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  .chat-copy-btn.is-copied { color: var(--green); }
  .chat-copy-btn.is-failed { color: var(--red); }
  .chat-copy-btn svg { display: block; }
  .msg .bubble .chat-copy-btn { display: flex; margin: 6px 0 0 auto; }
  .chat-live { animation: pulse 1.4s ease-in-out infinite; }
  .chat-older { align-self: center; margin-bottom: 12px; }
  .chat-drawer { position: fixed; z-index: 120; top: 70px; right: 16px; bottom: 16px; width: 320px; padding: 13px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); overflow: auto; overscroll-behavior: contain; }
  .chat-drawer.left { left: 16px; right: auto; }
  .chat-drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .chat-search { width: 100%; height: 32px; margin-bottom: 10px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); }
  .chat-session { display: flex; flex-direction: column; width: 100%; height: auto; min-width: 0; margin: 0; padding: 9px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--text); text-align: left; overflow: hidden; }
  .chat-session:hover, .chat-session.active { border-color: #28647a; background: #123044; }
  .chat-session-title, .chat-session-meta, .chat-session-preview { display: block; min-width: 0; }
  .chat-session-title { font-weight: 600; font-size: 11px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
  .chat-session-preview { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
  .chat-session-preview-empty { color: var(--dim); }
  .chat-session-meta { margin-top: 4px; color: var(--dim); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat-session-thread .chat-thread-label { max-width: 100%; }
  .chat-context-card span, .chat-context-card b { display: block; }
  .chat-context-card span { margin-top: 12px; color: var(--dim); font-size: 10px; }
  .chat-context-card b { margin-top: 3px; font-weight: 500; overflow-wrap: anywhere; }
  @media (max-width: 720px) { .chat-drawer, .chat-drawer.left { left: 5vw; right: auto; width: 90vw; } }

  .plan-card { border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); overflow: hidden; }
  .phases { padding: 8px 14px 12px; display: flex; flex-direction: column; gap: 0; }
  .phase { display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; padding: 7px 0; position: relative; }
  .phase:not(:last-child)::after { content: ""; position: absolute; left: 7px; top: 25px; bottom: -2px; width: 1px; background: var(--line); }
  .phase-mark { width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; position: relative; z-index: 1; }
  .phase.done .phase-mark { background: rgba(66, 197, 154, .14); border-color: rgba(66, 197, 154, .5); color: var(--green); }
  .phase.current .phase-mark { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(47, 200, 240, .08); }
  .phase.current .phase-mark::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2); }
  .phase.pending .phase-mark { border-style: dashed; }
  .phase-name { font-size: 11px; color: var(--muted); }
  .phase.done .phase-name { color: var(--dim); text-decoration: line-through; text-decoration-color: rgba(93, 109, 133, .5); }
  .phase.current .phase-name { color: var(--text); font-weight: 550; }
  .phase-state { font: 8.5px var(--mono); color: var(--dim); text-transform: uppercase; letter-spacing: .06em; padding-top: 2px; }
  .phase.current .phase-state { color: var(--accent-2); }
  .plan-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; border-top: 1px solid var(--line-soft); padding: 10px 14px; }
  .plan-note-label { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
  .plan-note { margin-top: 3px; font-size: 10.5px; color: var(--muted); }
  .plan-note.blocker { color: #e7b0b0; }

  .plan-filters { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 12px; }
  .plan-chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 9px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: 10.5px; font-weight: 550; }
  .plan-chip:hover { color: var(--text); border-color: var(--line-strong); }
  .plan-chip.active { color: var(--text); border-color: rgba(91, 141, 214, .45); background: rgba(74, 123, 200, .14); }
  .plan-chip .count { font: 9px var(--mono); color: var(--dim); }
  .plan-group { margin-top: 14px; }
  .plan-group:first-of-type { margin-top: 0; }
  .plan-group-head { display: flex; align-items: center; gap: 7px; margin: 0 2px 7px; }
  .plan-group-head h3 { margin: 0; font: 9px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
  .plan-group-count { min-width: 17px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 999px; color: var(--dim); font: 9px var(--mono); text-align: center; }
  .plan-item { margin-top: 7px; }
  .plan-group .plan-item:first-of-type { margin-top: 0; }
  .plan-summary { display: flex; align-items: center; gap: 9px; padding: 11px 13px; cursor: pointer; list-style: none; }
  .plan-summary:hover { background: rgba(255, 255, 255, .02); }
  .plan-summary::-webkit-details-marker { display: none; }
  .plan-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  .plan-item[open] > .plan-summary { border-bottom: 1px solid var(--line-soft); }
  .plan-summary-main { flex: 1; min-width: 0; }
  .plan-title { display: block; overflow: hidden; color: var(--text); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
  .plan-sub { display: block; margin-top: 2px; overflow: hidden; color: var(--dim); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
  .plan-progress-mini { color: var(--muted); font: 9.5px var(--mono); white-space: nowrap; }
  .plan-chevron { display: inline-grid; place-items: center; color: var(--dim); transition: transform .15s ease; }
  .plan-item[open] .plan-chevron { transform: rotate(90deg); }
  .plan-item.closed .plan-title { color: var(--muted); }
  .plan-body { padding: 0 14px 12px; }
  .plan-goal { padding: 11px 0 2px; color: var(--muted); font-size: 11px; line-height: 1.5; }
  .plan-body .phases { padding: 6px 0 8px; }
  .plan-body .plan-foot { padding: 10px 0 0; }
  .plan-meta { margin-top: 9px; color: var(--dim); font: 9.5px var(--mono); }
  .plan-empty { padding: 24px 14px; border: 1px dashed var(--line); border-radius: 9px; color: var(--dim); font-size: 11.5px; text-align: center; }
  .plan-empty .btn { margin-left: 6px; }

  @media (max-width: 520px) {
    .plan-progress-mini { display: none; }
    .plan-summary { gap: 7px; padding: 10px 11px; }
  }

  .todo-table { width: 100%; border-collapse: collapse; }
  .todo-table th { text-align: left; font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); font-weight: 600; padding: 7px 8px; border-bottom: 1px solid var(--line); }
  .todo-table td { padding: 9px 8px; border-bottom: 1px solid var(--line-soft); font-size: 10.5px; color: var(--muted); vertical-align: middle; }
  .todo-table tr:last-child td { border-bottom: 0; }
  .todo-name { color: var(--text); font-size: 11px; }
  .switch { position: relative; display: inline-block; width: 27px; height: 15px; }
  .switch input { opacity: 0; width: 0; height: 0; }
  .switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background .15s; cursor: pointer; }
  .switch span::after { content: ""; position: absolute; width: 11px; height: 11px; top: 2px; left: 2px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
  .switch input:checked + span { background: rgba(66, 197, 154, .3); }
  .switch input:checked + span::after { transform: translateX(12px); background: var(--green); }
  .switch input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 3px; }
  .switch input:disabled + span { opacity: .5; cursor: not-allowed; }

  .memory-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 11px; }
  .memory-block { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); padding: 12px; }
  .memory-block h3 { margin: 0 0 7px; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); }
  .memory-pre { white-space: pre-wrap; font: 10px/1.65 var(--mono); color: var(--muted); max-height: 330px; overflow: auto; }
  .memory-pre b { color: var(--text); font-weight: 500; }
  .context-row { display: flex; align-items: center; gap: 7px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 10px; color: var(--muted); }
  .context-row:last-child { border-bottom: 0; }
  .context-row .mono { margin-left: auto; font-size: 9px; color: var(--dim); }

  /* Agents */
  .filters { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 13px; }
  .filter-chip { height: 29px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 10.5px; font-weight: 550; }
  .filter-chip:hover { border-color: var(--line-strong); color: var(--text); }
  .filter-chip.active { color: #dce9ff; background: rgba(74, 123, 200, .13); border-color: rgba(91, 141, 214, .35); }
  .filter-chip .count { margin-left: 4px; font: 9px var(--mono); color: var(--dim); }
  .filter-search { margin-left: auto; height: 29px; width: 230px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); padding: 0 9px; font-size: 11px; color: var(--text); outline: none; }
  .filter-search:focus { border-color: var(--accent); }

  .group-section { margin-bottom: 16px; }
  .group-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; background: linear-gradient(180deg, rgba(74, 123, 200, .06), transparent), var(--surface); }
  .group-head .g-icon { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; background: rgba(74, 123, 200, .12); color: var(--accent); border: 1px solid rgba(91, 141, 214, .2); }
  .group-head h3 { margin: 0; font-size: 12.5px; }
  .group-head p { margin: 2px 0 0; font-size: 9.5px; color: var(--dim); }
  .group-head .g-meta { margin-left: auto; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
  .group-card-body { border: 1px solid var(--line); border-radius: 0 0 10px 10px; background: var(--surface); padding: 10px; }
  .agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
  .agent-card {
    text-align: left; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--surface-2); transition: border-color .15s, background .15s, transform .15s;
  }
  .agent-card:hover { border-color: var(--line-strong); background: var(--surface-3); transform: translateY(-1px); }
  .agent-top { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
  .agent-top .pill { margin-left: auto; }
  .agent-name { font-size: 12px; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .agent-role { margin-top: 1px; font-size: 9.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .agent-task { margin-top: 7px; display: flex; align-items: center; gap: 5px; font-size: 9.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .agent-task span:last-child { overflow: hidden; text-overflow: ellipsis; }
  .agent-metrics { display: flex; align-items: center; gap: 8px; margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line-soft); font: 9px var(--mono); color: var(--dim); }
  .agent-metrics b { color: var(--muted); font-weight: 400; }
  .agent-metrics .last { margin-left: auto; }

  /* Group detail */
  .group-tabs { display: grid; gap: 12px; margin-bottom: 16px; }
  .host-panel { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 13px 15px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(180deg, rgba(47, 200, 240, .035), transparent), var(--surface); }
  .host-main { display: flex; align-items: center; gap: 10px; min-width: 250px; }
  .host-icon { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; background: rgba(47, 200, 240, .08); border: 1px solid rgba(47, 200, 240, .2); color: var(--accent-2); }
  .host-main h2 { margin: 0; font-size: 15px; }
  .host-main p { margin: 2px 0 0; font-size: 9.5px; color: var(--dim); }
  .host-resources { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-start; flex: 1 1 100%; min-width: 0; padding-top: 2px; }
  .resource { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2); font: 9px var(--mono); color: var(--muted); }
  .resource b { color: var(--text); font-weight: 400; }
  .resource .dot { width: 5px; height: 5px; }

  .role-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-bottom: 12px; }
  .role-card { text-align: left; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); transition: border-color .15s, background .15s; }
  .role-card:hover { border-color: var(--line-strong); background: var(--surface-2); }
  .role-card.active { border-color: rgba(47, 200, 240, .4); background: linear-gradient(180deg, rgba(47, 200, 240, .055), transparent), var(--surface-2); box-shadow: inset 0 0 0 1px rgba(47, 200, 240, .1); }
  .role-top { display: flex; align-items: center; gap: 6px; }
  .role-top .pill { margin-left: auto; }
  .role-name { margin-top: 6px; font-size: 11.5px; font-weight: 620; }
  .role-role { margin-top: 1px; font-size: 9px; color: var(--dim); }
  .role-task { margin-top: 6px; font-size: 9.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .role-foot { display: flex; gap: 8px; margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--line-soft); font: 8.5px var(--mono); color: var(--dim); }
  .role-foot .auto { margin-left: auto; }

  .group-detail { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 12px; align-items: start; }
  .side-stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
  .auto-state { display: flex; align-items: center; gap: 9px; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--line-soft); }
  .auto-state .big-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px rgba(66, 197, 154, .55); }
  .auto-state.paused .big-dot { background: var(--amber); box-shadow: 0 0 10px rgba(227, 171, 83, .5); }
  .auto-state.off .big-dot { background: var(--dim); box-shadow: none; }
  .auto-state b { font-size: 12px; font-weight: 600; }
  .auto-state span { display: block; font-size: 9.5px; color: var(--dim); margin-top: 1px; }
  .auto-next { font: 17px var(--mono); color: var(--accent-2); letter-spacing: -.02em; }
  .auto-next-label { font-size: 9px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); margin-bottom: 2px; }
  .auto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
  .auto-item { font-size: 9px; color: var(--dim); }
  .auto-item b { display: block; margin-top: 2px; font: 10px var(--mono); color: var(--muted); font-weight: 400; }
  .auto-actions { display: flex; gap: 6px; margin-top: 11px; }
  .callout { display: flex; gap: 7px; padding: 8px 9px; margin-top: 10px; border-radius: 6px; font-size: 9.5px; line-height: 1.4; }
  .callout.warn { color: #eccb96; background: rgba(227, 171, 83, .075); border: 1px solid rgba(227, 171, 83, .2); }
  .callout.danger { color: #f0a1a1; background: rgba(226, 104, 104, .075); border: 1px solid rgba(226, 104, 104, .24); }
  .callout.info { color: var(--muted); background: rgba(91, 141, 214, .06); border: 1px solid rgba(91, 141, 214, .2); }
  .callout .ic { margin-top: 1px; }

  .queue-list { display: flex; flex-direction: column; gap: 4px; }
  .queue-item { padding: 7px 8px; border: 1px solid var(--line-soft); border-radius: 6px; background: rgba(18, 29, 47, .5); }
  .queue-item-top { display: flex; align-items: center; gap: 6px; }
  .queue-item-title { font-size: 10.5px; font-weight: 550; }
  .queue-item-top .tag { margin-left: auto; }
  .queue-item-sub { margin-top: 3px; font-size: 9px; color: var(--dim); display: flex; gap: 7px; flex-wrap: wrap; }

  .outbox-item { padding: 8px 9px; border: 1px solid var(--line-soft); border-radius: 6px; background: rgba(18, 29, 47, .5); }
  .outbox-item p { margin: 0; font-size: 10px; color: var(--muted); line-height: 1.45; }
  .outbox-meta { display: flex; gap: 7px; margin-top: 5px; font: 8.5px var(--mono); color: var(--dim); }

  .feed { position: relative; display: flex; flex-direction: column; gap: 0; }
  .feed-item { display: grid; grid-template-columns: 62px 22px 1fr; gap: 8px; padding: 8px 0; position: relative; }
  .feed-item:not(:last-child)::after { content: ""; position: absolute; left: 79px; top: 31px; bottom: -1px; width: 1px; background: var(--line); }
  .feed-time { font: 9px var(--mono); color: var(--dim); padding-top: 2px; text-align: right; }
  .feed-icon { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--muted); position: relative; z-index: 1; }
  .feed-icon.tool { color: var(--accent-2); border-color: rgba(47, 200, 240, .25); }
  .feed-icon.think { color: var(--violet); border-color: rgba(157, 140, 240, .25); }
  .feed-icon.ok { color: var(--green); border-color: rgba(66, 197, 154, .25); }
  .feed-icon.warn { color: var(--amber); border-color: rgba(227, 171, 83, .25); }
  .feed-icon .ic { width: 11px; height: 11px; }
  .feed-body { min-width: 0; }
  .feed-title { font-size: 10.5px; color: var(--muted); line-height: 1.4; }
  .feed-title b { color: var(--text); font-weight: 550; }
  .feed-detail { margin-top: 3px; font: 9px/1.5 var(--mono); color: var(--dim); background: rgba(8, 13, 22, .45); border: 1px solid var(--line-soft); border-radius: 5px; padding: 5px 7px; white-space: pre-wrap; max-height: 100px; overflow: auto; }
  .request-box { padding: 10px 11px; border: 1px solid rgba(91, 141, 214, .2); border-radius: 7px; background: rgba(74, 123, 200, .06); font-size: 10.5px; color: #c2d5ee; line-height: 1.5; margin-bottom: 10px; }
  .request-box .req-label { display: block; margin-bottom: 4px; font: 8.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
  .stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
  .stat-strip div { font-size: 9px; color: var(--dim); }
  .stat-strip b { display: block; margin-top: 2px; font: 11px var(--mono); color: var(--muted); font-weight: 400; }
  .offline-box { padding: 22px; text-align: center; color: var(--dim); font-size: 11px; border: 1px dashed var(--line); border-radius: 8px; }

  /* Journal */
  .journal-filters { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 13px; }
  .journal-select { height: 29px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); padding: 0 8px; color: var(--muted); font-size: 10.5px; outline: none; }
  .journal-search { height: 29px; width: 260px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); padding: 0 9px; color: var(--text); font-size: 11px; outline: none; margin-left: auto; }
  .journal-search:focus { border-color: var(--accent); }
  .journal-list { padding: 2px 0; }
  .journal-row { display: grid; grid-template-columns: 74px 26px minmax(0, 1fr) auto; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); align-items: start; }
  .journal-row:last-child { border-bottom: 0; }
  .journal-row.is-new { animation: rowIn .5s ease; }
  .j-time { font: 9.5px var(--mono); color: var(--dim); padding-top: 2px; text-align: right; }
  .j-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); color: var(--muted); background: var(--surface-2); }
  .j-icon.action { color: var(--accent-2); border-color: rgba(47, 200, 240, .22); }
  .j-icon.decision { color: var(--green); border-color: rgba(66, 197, 154, .22); }
  .j-icon.problem { color: var(--red); border-color: rgba(226, 104, 104, .22); }
  .j-icon.lesson { color: var(--violet); border-color: rgba(157, 140, 240, .22); }
  .j-icon.work { color: var(--accent); border-color: rgba(91, 141, 214, .22); }
  .j-icon.autonomy { color: var(--amber); border-color: rgba(227, 171, 83, .22); }
  .j-icon .ic { width: 11px; height: 11px; }
  .j-body { min-width: 0; }
  .j-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
  .j-actor { font-size: 10.5px; font-weight: 600; }
  .j-scope { font-size: 9.5px; color: var(--dim); }
  .j-text { margin-top: 3px; font-size: 11px; color: var(--muted); line-height: 1.45; }
  .j-link { border: 0; background: none; color: var(--accent); font: 9.5px var(--mono); padding: 2px 0; display: inline-flex; align-items: center; gap: 3px; }
  .j-link:hover { color: var(--accent-2); }
  .j-type { font: 8.5px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); padding-top: 3px; }

  /* Drawer, inbox, scrim */
  .scrim { position: fixed; inset: 0; z-index: 50; background: rgba(3, 7, 12, .62); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .drawer {
    position: fixed; top: 0; right: 0; width: min(520px, 100vw); height: 100vh; z-index: 60;
    display: flex; flex-direction: column; background: #0b1321; border-left: 1px solid var(--line-strong);
    box-shadow: -30px 0 70px rgba(0, 0, 0, .48); transform: translateX(102%); transition: transform .24s ease;
  }
  .drawer.open { transform: none; }
  .drawer.inbox { width: min(460px, 100vw); }
  .drawer-head { padding: 16px 18px 13px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 10px; }
  .drawer-head-main { flex: 1; min-width: 0; }
  .drawer-kicker { font: 9px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
  .drawer-head h2 { margin: 0; font-size: 17px; line-height: 1.25; letter-spacing: -.015em; }
  .drawer-head p { margin: 5px 0 0; font-size: 10.5px; color: var(--dim); }
  .drawer-close { width: 29px; height: 29px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; }
  .drawer-close:hover { color: var(--text); border-color: var(--line-strong); }
  .drawer-body { flex: 1; overflow: auto; padding: 15px 18px 24px; }
  .drawer-body::-webkit-scrollbar, .scroll::-webkit-scrollbar { width: 7px; height: 7px; }
  .drawer-body::-webkit-scrollbar-thumb, .scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
  .drawer-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 7px; background: rgba(14, 23, 38, .65); }
  .drawer-foot .btn { flex: 1; }

  .detail-section { margin-bottom: 17px; }
  .detail-label { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); font-weight: 600; margin-bottom: 7px; }
  .detail-title { font-size: 13px; font-weight: 600; }
  .detail-sub { margin-top: 2px; font-size: 10px; color: var(--dim); }
  .detail-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
  .kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .kv { padding: 8px 9px; border: 1px solid var(--line-soft); border-radius: 6px; background: rgba(18, 29, 47, .55); }
  .kv-label { font-size: 8.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
  .kv-value { margin-top: 3px; font: 10.5px var(--mono); color: var(--muted); word-break: break-word; }
  .cap-list { display: flex; flex-wrap: wrap; gap: 5px; }
  .note-box { padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); font-size: 10.5px; color: var(--muted); line-height: 1.5; }
  .note-box b { color: var(--text); font-weight: 550; }

  .chain { display: flex; flex-direction: column; gap: 0; }
  .chain-node { display: grid; grid-template-columns: 22px 1fr; gap: 8px; position: relative; padding-bottom: 10px; }
  .chain-node:not(:last-child)::after { content: ""; position: absolute; left: 10px; top: 22px; bottom: 0; width: 1px; background: var(--line); }
  .chain-dot { width: 21px; height: 21px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface-2); display: grid; place-items: center; color: var(--muted); position: relative; z-index: 1; }
  .chain-dot .ic { width: 10px; height: 10px; }
  .chain-dot.human { color: var(--accent); border-color: rgba(91, 141, 214, .35); }
  .chain-dot.orch { color: var(--accent-2); border-color: rgba(47, 200, 240, .3); }
  .chain-dot.agent { color: var(--amber); border-color: rgba(227, 171, 83, .3); }
  .chain-name { font-size: 10.5px; color: var(--text); font-weight: 550; }
  .chain-sub { margin-top: 1px; font-size: 9px; color: var(--dim); }

  .timeline { display: flex; flex-direction: column; gap: 0; }
  .tl-item { display: grid; grid-template-columns: 48px 18px 1fr; gap: 7px; padding: 6px 0; position: relative; }
  .tl-item:not(:last-child)::after { content: ""; position: absolute; left: 61px; top: 25px; bottom: -1px; width: 1px; background: var(--line-soft); }
  .tl-time { font: 8.5px var(--mono); color: var(--dim); text-align: right; padding-top: 2px; }
  .tl-dot { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); position: relative; z-index: 1; display: grid; place-items: center; color: var(--dim); }
  .tl-dot .ic { width: 8px; height: 8px; }
  .tl-dot.green { color: var(--green); border-color: rgba(66, 197, 154, .25); }
  .tl-dot.amber { color: var(--amber); border-color: rgba(227, 171, 83, .25); }
  .tl-dot.cyan { color: var(--accent-2); border-color: rgba(47, 200, 240, .25); }
  .tl-text { font-size: 10px; color: var(--muted); line-height: 1.4; }
  .tl-text b { color: var(--text); font-weight: 550; }

  /* Contexts */
  .context-tab-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
  .context-tab-head h3 { margin: 0; font-size: 13px; }
  .context-tab-head p { margin: 4px 0 0; color: var(--dim); font-size: 10.5px; line-height: 1.45; max-width: 620px; }
  .context-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
  .context-card {
    display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px;
    border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2);
    text-align: left; transition: border-color .15s, background .15s, transform .15s;
  }
  .context-card:hover { border-color: var(--line-strong); background: var(--surface-3); transform: translateY(-1px); }
  .ctx-badge {
    width: 29px; height: 29px; border-radius: 6px; flex: 0 0 auto; display: grid; place-items: center;
    background: rgba(91, 141, 214, .1); border: 1px solid rgba(91, 141, 214, .25);
    color: #9bc0f0; font: 8.5px var(--mono); letter-spacing: .04em;
  }
  .ctx-badge.handshake { color: var(--violet); background: rgba(157, 140, 240, .08); border-color: rgba(157, 140, 240, .25); }
  .ctx-main { flex: 1; min-width: 0; }
  .ctx-name { display: block; font: 10.5px var(--mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ctx-meta { display: block; margin-top: 2px; font-size: 9px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .context-card > .ic { color: var(--dim); flex: 0 0 auto; }
  .context-empty { padding: 24px 18px; text-align: center; border: 1px dashed var(--line); border-radius: 8px; color: var(--dim); font-size: 11px; }
  .context-empty .ic { width: 24px; height: 24px; color: var(--accent); margin-bottom: 7px; }
  .context-stack { display: flex; flex-direction: column; gap: 5px; }
  .context-mini-row {
    display: flex; align-items: center; gap: 7px; width: 100%; padding: 7px 8px;
    border: 1px solid var(--line-soft); border-radius: 6px; background: rgba(18, 29, 47, .55);
    text-align: left; color: var(--muted); transition: border-color .15s, background .15s;
  }
  .context-mini-row:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--text); }
  .context-mini-row .mono { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
  .context-mini-row .tag { font-size: 7.5px; padding: 0 4px; }
  .context-policy { display: flex; gap: 7px; margin-top: 9px; padding: 8px 9px; border: 1px solid rgba(91, 141, 214, .18); border-radius: 6px; background: rgba(91, 141, 214, .05); color: var(--muted); font-size: 9.5px; line-height: 1.45; }
  .context-policy .ic { color: var(--accent); margin-top: 1px; }

  /* Context studio */
  .studio {
    position: fixed; inset: 3vh 3vw; margin: auto; z-index: 80;
    width: min(1320px, 94vw); height: 88vh; max-height: 920px;
    display: flex; flex-direction: column; overflow: hidden;
    background: #0b1321; border: 1px solid var(--line-strong); border-radius: 13px;
    box-shadow: 0 35px 100px rgba(0, 0, 0, .62);
    opacity: 0; pointer-events: none; transform: translateY(8px) scale(.995);
    transition: opacity .18s ease, transform .18s ease;
  }
  .studio.open { opacity: 1; pointer-events: auto; transform: none; }
  .studio-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
  .studio-head-main { flex: 1; min-width: 0; }
  .studio-head h2 { margin: 0; font-size: 18px; letter-spacing: -.015em; line-height: 1.2; }
  .studio-head p { margin: 3px 0 0; font-size: 9.5px; color: var(--dim); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .studio-head .pill { margin-top: 3px; }
  .studio-info-toggle { display: none; }
  .studio-body { position: relative; flex: 1; min-height: 0; min-width: 0; width: 100%; display: grid; grid-template-columns: 270px minmax(0, 1fr) 272px; }
  .studio-list { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--line); }
  .studio-list-head { padding: 9px; border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 6px; }
  .studio-search { height: 27px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); padding: 0 8px; font-size: 10px; color: var(--text); outline: none; }
  .studio-search:focus { border-color: var(--accent); }
  .studio-files { flex: 1; min-height: 0; overflow: auto; padding: 6px; }
  .studio-list-foot { flex: 0 0 auto; padding: 8px 10px; border-top: 1px solid var(--line-soft); font: 8.5px var(--mono); color: var(--dim); display: flex; justify-content: space-between; }
  .ctx-file { display: block; width: 100%; text-align: left; padding: 8px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--muted); }
  .ctx-file:hover { background: var(--surface-2); color: var(--text); }
  .ctx-file.active { background: rgba(74, 123, 200, .12); border-color: rgba(91, 141, 214, .26); color: var(--text); }
  .ctx-file-top { display: flex; align-items: center; gap: 6px; }
  .ctx-file-name { flex: 1; min-width: 0; font: 9.5px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ctx-file-dirty { color: var(--amber); font-size: 11px; line-height: 1; }
  .ctx-file-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 8.5px; color: var(--dim); }
  .ctx-file-meta .tag { font-size: 7.5px; padding: 0 4px; }
  .new-ctx-form { margin: 0 6px 6px; padding: 8px; border: 1px solid rgba(91, 141, 214, .25); background: rgba(74, 123, 200, .06); border-radius: 6px; display: flex; flex-direction: column; gap: 6px; }
  .new-ctx-form input { height: 26px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); padding: 0 7px; font: 9.5px var(--mono); color: var(--text); outline: none; }
  .new-ctx-form input:focus { border-color: var(--accent); }
  .new-ctx-form .row { display: flex; gap: 5px; }
  .studio-editor { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
  .editor-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); min-height: 49px; }
  .editor-head-main { min-width: 0; flex: 1; }
  .editor-file { font: 10.5px var(--mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .editor-badges { display: flex; align-items: center; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
  .editor-actions { display: flex; gap: 5px; flex: 0 0 auto; }
  .editor-shell { flex: 1; min-height: 0; min-width: 0; display: flex; background: #080e18; overflow: hidden; }
  .line-gutter { width: 42px; flex: 0 0 42px; overflow: hidden; padding: 12px 8px 12px 0; text-align: right; font: 10.5px/20px var(--mono); color: #42536b; background: #0a111c; border-right: 1px solid var(--line-soft); user-select: none; }
  .line-gutter span { display: block; height: 20px; }
  .ctx-editor { flex: 1; min-width: 0; width: 100%; resize: none; border: 0; outline: none; background: transparent; color: #d8e5f6; font: 11.5px/20px var(--mono); padding: 12px 14px; tab-size: 2; white-space: pre; overflow: auto; }
  .ctx-editor::selection { background: rgba(47, 200, 240, .22); }
  .editor-foot { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line-soft); }
  .dirty-state { font: 9px var(--mono); color: var(--green); display: inline-flex; align-items: center; gap: 5px; }
  .dirty-state::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
  .dirty-state.dirty { color: var(--amber); }
  .editor-count { font: 8.5px var(--mono); color: var(--dim); margin-left: auto; white-space: nowrap; }
  .editor-empty { flex: 1; display: grid; place-items: center; padding: 30px; text-align: center; color: var(--dim); font-size: 11px; }
  .editor-empty .ic { width: 30px; height: 30px; color: var(--accent); margin-bottom: 9px; }
  .studio-info { min-width: 0; border-left: 1px solid var(--line); overflow: auto; padding: 12px; background: #0b1321; }
  .info-block { margin-bottom: 14px; }
  .info-block:last-child { margin-bottom: 0; }
  .info-block h3 { margin: 0 0 7px; font-size: 8.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); font-weight: 650; }
  .info-rule { display: flex; gap: 6px; margin-bottom: 6px; font-size: 9px; line-height: 1.45; color: var(--muted); }
  .info-rule .ic { margin-top: 1px; color: var(--accent); }
  .info-path { padding: 7px 8px; border: 1px solid var(--line-soft); border-radius: 5px; background: var(--surface-2); font: 8.5px/1.5 var(--mono); color: var(--dim); word-break: break-all; }
  .connect-state { display: flex; align-items: center; gap: 6px; padding: 7px 8px; margin-bottom: 6px; border: 1px solid var(--line-soft); border-radius: 5px; background: var(--surface-2); font-size: 9px; color: var(--muted); }
  .connect-state .dot { width: 5px; height: 5px; }
  .version-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 8px; }
  .version-meta div { padding: 7px; border: 1px solid var(--line-soft); border-radius: 5px; background: rgba(18, 29, 47, .55); font-size: 9px; color: var(--dim); }
  .version-meta b { display: block; margin-top: 2px; font: 10px var(--mono); color: var(--muted); font-weight: 400; overflow-wrap: anywhere; }
  .version { padding: 7px 8px; border: 1px solid var(--line-soft); border-radius: 5px; background: rgba(18, 29, 47, .55); margin-top: 5px; }
  .version-top { display: flex; align-items: center; gap: 5px; font: 8px var(--mono); color: var(--dim); }
  .version-top .who { color: var(--muted); }
  .version-top .restore { margin-left: auto; border: 0; background: none; color: var(--accent); font: 8px var(--mono); padding: 0; }
  .version-top .restore:hover { color: var(--accent-2); }
  .version-preview { margin-top: 4px; font: 8px/1.4 var(--mono); color: var(--dim); max-height: 33px; overflow: hidden; }
  .version-empty { font-size: 9px; color: var(--dim); line-height: 1.45; }

  /* Inbox */
  .inbox-list { display: flex; flex-direction: column; gap: 9px; }
  .inbox-card { border: 1px solid var(--line); border-left: 2px solid var(--accent); border-radius: 8px; background: var(--surface-2); padding: 11px 12px; }
  .inbox-card.critical { border-left-color: var(--red); }
  .inbox-card.warn { border-left-color: var(--amber); }
  .inbox-card.info { border-left-color: var(--accent); }
  .inbox-card.resolved { opacity: .65; }
  .inbox-top { display: flex; align-items: center; gap: 7px; }
  .inbox-top .mono { margin-left: auto; font-size: 9px; color: var(--dim); }
  .inbox-title { margin-top: 7px; font-size: 12.5px; font-weight: 620; line-height: 1.32; }
  .inbox-text { margin-top: 4px; font-size: 10.5px; color: var(--muted); line-height: 1.45; }
  .inbox-scope { margin-top: 6px; font: 9px var(--mono); color: var(--dim); }
  .inbox-answer { margin-top: 8px; min-height: 52px; resize: vertical; font-size: 11px; }
  .inbox-actions { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
  .inbox-empty { text-align: center; padding: 42px 16px; color: var(--dim); font-size: 11px; }
  .inbox-empty .ic { width: 28px; height: 28px; margin-bottom: 8px; color: var(--green); }

  /* Palette */
  .palette-scrim { position: fixed; inset: 0; z-index: 89; background: rgba(3, 7, 12, .7); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .15s; }
  .palette-scrim.open { opacity: 1; pointer-events: auto; }
  .palette {
    position: fixed; z-index: 90; top: 10vh; left: 50%; width: min(620px, calc(100vw - 28px));
    transform: translate(-50%, -8px); opacity: 0; pointer-events: none;
    background: #0c1523; border: 1px solid var(--line-strong); border-radius: 11px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .55); transition: opacity .15s, transform .15s;
    overflow: hidden;
  }
  .palette.open { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
  .palette-input { display: flex; align-items: center; gap: 9px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .palette-input input { flex: 1; border: 0; background: none; outline: none; font-size: 13px; color: var(--text); }
  .palette-input input::placeholder { color: var(--dim); }
  .palette-results { max-height: 52vh; overflow: auto; padding: 7px; }
  .palette-group { padding: 7px 8px 3px; font: 8.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
  .palette-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; border: 1px solid transparent; background: none; border-radius: 7px; padding: 8px 9px; color: var(--muted); }
  .palette-item:hover, .palette-item.selected { background: var(--surface-2); border-color: var(--line); color: var(--text); }
  .palette-item .pi-type { font: 8.5px var(--mono); color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
  .palette-item .pi-main { flex: 1; min-width: 0; }
  .palette-item .pi-label { display: block; font-size: 11.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .palette-item .pi-sub { display: block; margin-top: 1px; font-size: 9px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .palette-item .ic { color: var(--dim); }
  .palette-foot { display: flex; gap: 12px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 9px; color: var(--dim); }
  .palette-empty { padding: 26px; text-align: center; color: var(--dim); font-size: 11px; }

  /* Auth (этап 8) */
  .login-view { position: fixed; inset: 0; z-index: 200; display: none; place-items: center; padding: 24px; background: var(--bg); overflow: auto; }
  .login-view.open { display: grid; }
  .login-card { width: min(390px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 26px; border: 1px solid var(--line-strong); border-radius: 13px; background: #0b1321; box-shadow: var(--shadow); }
  .login-card h1 { margin: 0; font-size: 18px; }
  .login-sub { margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.55; }
  .login-field { display: flex; flex-direction: column; gap: 5px; font-size: 10.5px; color: var(--muted); }
  .login-field input { height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 12px; }
  .login-submit { width: 100%; justify-content: center; }
  .login-error { min-height: 15px; color: var(--red); font-size: 11px; line-height: 1.4; }
  .login-secret { padding: 9px; border: 1px solid var(--line-strong); border-radius: 8px; background: rgba(14, 23, 38, .7); color: var(--muted); font-size: 10.5px; word-break: break-all; }
  .login-secret code { color: var(--text); font-family: var(--mono); user-select: all; }
  .login-uri { margin-top: 6px; color: var(--dim); font-family: var(--mono); font-size: 9.5px; }

  /* read-only: write-контролы скрыты, серверный гейт — в шлюзе */
  [data-role=readonly] [data-write] { display: none; }
  #usersBtn { display: none; }
  body[data-role=admin] #usersBtn { display: inline-flex; }
  .password-overlay { position: fixed; inset: 0; z-index: 120; display: none; place-items: center; padding: 24px; background: rgba(3, 7, 12, .62); backdrop-filter: blur(2px); }
  .password-overlay.open { display: grid; }
  .drawer.users { width: min(760px, 100vw); }
  .users-form { display: grid; grid-template-columns: 1fr 110px auto; gap: 6px; align-items: center; margin-bottom: 14px; }
  .users-form input, .users-form select { height: 30px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; font-size: 11px; }
  .users-check { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 10.5px; }
  .users-table-el { width: 100%; border-collapse: collapse; font-size: 11px; }
  .users-table-el th { padding: 5px 6px; border-bottom: 1px solid var(--line); color: var(--dim); font-weight: 600; text-align: left; }
  .users-table-el td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
  .audit-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; margin-top: 6px; overflow: auto; }
  .audit-row { display: grid; grid-template-columns: 118px 92px 82px 1fr; gap: 6px; padding: 3px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10.5px; }
  .audit-row b { color: var(--text); font-weight: 600; }

  /* Toast */
  .toast {
    position: fixed; z-index: 95; bottom: 22px; left: 50%; transform: translate(-50%, 20px);
    max-width: min(480px, calc(100vw - 28px)); padding: 9px 13px;
    border: 1px solid var(--line-strong); border-radius: 8px; background: #111e30;
    color: var(--text); font-size: 11.5px; box-shadow: var(--shadow);
    opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
  }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }
  .toast .dot { margin-right: 6px; }
  .toast.error { border-color: rgba(226, 104, 104, .55); }

  .global-error, .area-error, .stale-banner {
    padding: 12px 14px; border: 1px solid rgba(226, 104, 104, .45); border-radius: 8px;
    background: rgba(226, 104, 104, .08); color: var(--text); font-size: 12px;
  }
  .global-error { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
  .global-error span { flex: 1; color: var(--muted); }
  .global-error[hidden], .stale-banner[hidden] { display: none; }
  .stale-banner { margin: 12px 28px 0; border-color: rgba(227, 171, 83, .45); background: rgba(227, 171, 83, .08); }
  .site-update-banner {
    position: fixed; z-index: 500; top: 12px; left: 50%; transform: translateX(-50%);
    max-width: calc(100vw - 28px); padding: 10px 16px; border: 1px solid rgba(227, 171, 83, .55);
    border-radius: 8px; background: #111e30; color: var(--text); box-shadow: var(--shadow);
    font-size: 12px; text-align: center; pointer-events: none;
  }
  .site-update-banner[hidden] { display: none; }
  .area-error { margin: 10px 0; }
  .area-error .btn { margin-left: 8px; }

  /* Animations */
  @keyframes fadeUp { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
  @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
  @keyframes dash { to { stroke-dashoffset: -24; } }
  @keyframes rowIn { from { background: rgba(47, 200, 240, .08); } to { background: transparent; } }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  }

  /* Responsive */
  @media (max-width: 1280px) {
    .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .overview-bottom { grid-template-columns: 1fr 1fr; }
    .overview-bottom > :last-child { grid-column: 1 / -1; }
    .group-detail { grid-template-columns: 280px minmax(0, 1fr); }
  }

  @media (max-width: 1080px) {
    .rail { width: 74px; flex-basis: 74px; padding: 16px 9px 12px; }
    .brand { padding: 0 0 16px; justify-content: center; }
    .brand > div:not(.brand-mark) { display: none; }
    .nav-item { justify-content: center; padding: 10px 6px; font-size: 0; gap: 0; }
    .nav-item .nav-count, .nav-item .nav-live { display: none; }
    .nav-item .ic { width: 19px; height: 19px; }
    .nav-label, .nav-sep { display: none; }
    .rail-foot .owner { justify-content: center; padding: 7px; }
    .rail-foot .owner > div:not(.avatar) { display: none; }
    .rail-foot .env { justify-content: center; font-size: 0; gap: 0; }
    .rail-foot .env .mono, .rail-foot .env .dot { display: none; }
    .rail-foot .env::after { content: "NMG"; font: 8px var(--mono); color: var(--dim); }
    .topbar { padding: 0 20px; }
    .content { padding: 22px 20px 60px; }
    .overview-top { grid-template-columns: 1fr; }
    .overview-side { display: grid; grid-template-columns: 1fr 1fr; }
    .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .scenario-layout { grid-template-columns: 235px minmax(0, 1fr); }
    .group-detail { grid-template-columns: 1fr; }
  }

  @media (max-width: 820px) {
    .app { display: block; }
    .rail {
      position: fixed; bottom: 0; left: 0; right: 0; top: auto; width: 100%; height: 58px;
      flex-direction: row; border-right: 0; border-top: 1px solid var(--line); padding: 5px 6px;
      background: rgba(8, 13, 22, .97); backdrop-filter: blur(14px); z-index: 45;
    }
    .brand, .rail-foot, .nav-label, .nav-sep { display: none; }
    .nav { flex-direction: row; flex: 1; gap: 2px; margin: 0; justify-content: space-around; }
    .nav-item { flex-direction: column; gap: 2px; font-size: 8.5px; padding: 5px 3px; flex: 1; }
    .nav-item .ic { width: 16px; height: 16px; }
    .nav-item.active { box-shadow: inset 0 -2px 0 var(--accent); background: rgba(74, 123, 200, .09); }
    .main { padding-bottom: 58px; }
    .topbar { height: auto; min-height: 56px; flex-wrap: wrap; padding: 8px 14px; gap: 10px; }
    .top-actions { margin-left: auto; }
    #connectionStatus { display: none; }
    .search { max-width: none; }
    .search span, .search kbd { display: none; }
    .search { width: 34px; flex: 0 0 34px; justify-content: center; padding: 0; }
    .crumb { font-size: 11px; }
    .content { padding: 18px 14px 50px; }
    .page-head { align-items: flex-start; flex-direction: column; gap: 10px; }
    .page-head h1 { font-size: 23px; }
    .head-actions { justify-content: flex-start; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .overview-side { grid-template-columns: 1fr; }
    .overview-bottom { grid-template-columns: 1fr; }
    .overview-bottom > :last-child { grid-column: auto; }
    .board { grid-template-columns: 1fr; }
    .lane { min-height: auto; }
    .scenario-layout { grid-template-columns: 1fr; }
    .scenario-list { position: static; max-height: 235px; overflow: auto; }
    .group-detail { grid-template-columns: 1fr; }
    .group-resources { width: 100%; margin-left: 0; }
    .host-resources { margin-left: 0; }
    .role-strip { grid-template-columns: 1fr 1fr; }
    .filters { align-items: stretch; }
    .filter-search { margin-left: 0; width: 100%; }
    .journal-search { margin-left: 0; width: 100%; }
    .journal-row { grid-template-columns: 26px minmax(0, 1fr); }
    .j-time { display: none; }
    .j-type { display: none; }
    .memory-grid { grid-template-columns: 1fr; }
    .plan-foot { grid-template-columns: 1fr; }
    .drawer { width: 100vw; }
  }

  @media (max-width: 520px) {
    .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
    .kpi-value { font-size: 21px; }
    .topbar { gap: 7px; }
    .crumb-time { display: none; }
    .top-actions { gap: 6px; }
    .top-actions .live-toggle { width: 28px; padding: 0; justify-content: center; }
    .top-actions .live-toggle #liveText, .top-actions .live-toggle .live-sub { display: none; }
    .role-strip { grid-template-columns: 1fr; }
    .host-resources { flex-basis: 100%; justify-content: flex-start; }
    .stat-strip { grid-template-columns: 1fr 1fr; }
    .kv-grid { grid-template-columns: 1fr; }
    .msg { max-width: 94%; }
    .filter-chip { font-size: 9.5px; padding: 0 8px; }
  }
  @media (max-width: 1050px) {
    .studio-body { grid-template-columns: 250px minmax(0, 1fr); }
    .studio-info { display: none; }
    .studio-info-toggle { display: inline-flex; }
    .studio-info.mobile-open { display: block; position: absolute; right: 0; top: 0; bottom: 0; width: min(330px, 88vw); z-index: 8; box-shadow: -20px 0 50px rgba(0, 0, 0, .4); }
  }

  @media (max-width: 820px) {
    .context-grid { grid-template-columns: 1fr; }
    .studio { inset: 0; width: 100vw; height: 100vh; max-height: none; border-radius: 0; border: 0; }
    .studio-head { padding: 11px 14px; }
    .studio-head h2 { font-size: 16px; }
    .studio-body { grid-template-columns: 1fr; grid-template-rows: 176px minmax(0, 1fr); }
    .studio-list { border-right: 0; border-bottom: 1px solid var(--line); }
    .studio-files { display: flex; gap: 5px; overflow-x: auto; overflow-y: hidden; }
    .ctx-file { min-width: 190px; }
    .studio-list-foot { display: none; }
    .new-ctx-form { margin: 0; }
    .editor-head { padding: 7px 10px; }
    .editor-actions .btn span { display: none; }
    .editor-foot { flex-wrap: wrap; }
    .editor-count { margin-left: 0; }
    .studio-info { display: none; }
  }

  @media (max-width: 520px) {
    .context-tab-head { flex-direction: column; }
    .context-tab-head .btn { width: 100%; }
    .studio-body { grid-template-rows: 205px minmax(0, 1fr); }
    .studio-head .pill { display: none; }
    .studio-list-head { flex-direction: row; align-items: center; }
    .studio-list-head .studio-search { flex: 1; min-width: 0; }
    .studio-list-head .btn { flex: 0 0 auto; width: auto; padding: 0 8px; }
    .editor-head { align-items: flex-start; flex-wrap: wrap; }
    .editor-head-main { flex-basis: 100%; }
    .editor-actions { flex-direction: row; width: 100%; }
    .editor-actions .btn { flex: 1; }
    .ctx-editor { font-size: 10.5px; }
  }

  /* AGT Node control */
  .agt-dialog { width: min(560px, calc(100vw - 26px)); max-height: 86vh; padding: 0; border: 1px solid var(--line-strong); border-radius: 12px; background: #0b1422; color: var(--text); box-shadow: var(--shadow); overflow: auto; }
  .agt-dialog::backdrop { background: rgba(3, 7, 12, .68); backdrop-filter: blur(3px); }
  .agt-dialog-head { display: flex; align-items: center; gap: 9px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .agt-dialog-head h2 { margin: 0; font-size: 15px; }
  .agt-dialog-head .btn { margin-left: auto; }
  .agt-dialog-body { padding: 16px; }
  .agt-dialog-body p { margin: 0 0 10px; color: var(--muted); font-size: 11px; line-height: 1.55; }
  .agt-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
  .health-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .health-tile { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
  .health-tile .big { font: 20px var(--mono); margin-bottom: 4px; }
  .health-tile .label { font-size: 11px; color: var(--dim); }
  .agt-head-actions { margin-bottom: 0; }
  .control-grid { display: grid; grid-template-columns: 265px minmax(450px, 1fr) 285px; gap: 12px; align-items: start; }
  .control-grid > * { min-width: 0; }
  .tree { padding: 7px; }
  .tree-row { width: 100%; display: flex; align-items: center; gap: 7px; min-height: 35px; padding: 7px 8px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); text-align: left; font-size: 11px; }
  .tree-row:hover { background: var(--surface-2); color: var(--text); }
  .tree-row.active { background: rgba(47, 200, 240, .07); border-color: rgba(47, 200, 240, .25); color: #d9f6ff; }
  .tree-row .chev { width: 9px; color: var(--dim); font: 10px var(--mono); }
  .tree-row .label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tree-row .meta { margin-left: auto; font: 9px var(--mono); color: var(--dim); }
  .tree-children { margin: 3px 0 4px 14px; padding-left: 8px; border-left: 1px solid var(--line); }
  .tree-caption { padding: 7px 8px 5px; font: 9px var(--mono); letter-spacing: .09em; text-transform: uppercase; color: var(--dim); }
  .object-icon { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid rgba(91, 141, 214, .22); border-radius: 7px; background: rgba(74, 123, 200, .08); color: var(--accent); flex: 0 0 auto; font: 10px var(--mono); }
  .object-icon.green { color: var(--green); border-color: rgba(66, 197, 154, .22); background: rgba(66, 197, 154, .07); }
  .object-icon.cyan { color: var(--accent-2); border-color: rgba(47, 200, 240, .22); background: rgba(47, 200, 240, .07); }
  .object-icon.amber { color: var(--amber); border-color: rgba(227, 171, 83, .22); background: rgba(227, 171, 83, .07); }
  .sync-box { padding: 12px; }
  .sync-line { display: flex; align-items: center; gap: 8px; font-size: 12px; }
  .sync-line b { font-weight: 600; }
  .sync-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 8px; margin-top: 12px; }
  .sync-meta div { font-size: 11px; color: var(--dim); }
  .sync-meta b { display: block; margin-top: 3px; font: 11px/1.45 var(--mono); color: var(--muted); font-weight: 400; overflow-wrap: anywhere; }
  .cluster-hero { padding: 15px 16px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(135deg, rgba(47, 200, 240, .055), transparent 55%), var(--surface); }
  .cluster-title { display: flex; align-items: flex-start; gap: 11px; }
  .cluster-title h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
  .cluster-title p { margin: 3px 0 0; font-size: 10px; color: var(--dim); }
  .cluster-title .head-pills { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
  .metric { padding: 8px 9px; border: 1px solid var(--line-soft); border-radius: 7px; background: rgba(8, 13, 22, .36); font-size: 10px; color: var(--dim); }
  .metric b { display: block; margin-top: 3px; font: 12px var(--mono); color: var(--text); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
  .lifecycle { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
  .lifecycle .sep { width: 1px; height: 22px; background: var(--line); margin: 0 3px; }
  .section-title { display: flex; align-items: center; gap: 8px; margin: 0 0 11px; font-size: 12px; }
  .section-title .actions, .section-title > .pill { margin-left: auto; }
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px 12px; }
  .field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
  .field.full { grid-column: 1 / -1; }
  .field label, .field-label { font-size: 11px; color: var(--muted); font-weight: 550; }
  .field small { font-size: 10px; color: var(--dim); }
  .input, select, textarea { width: 100%; min-height: 36px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #0b1422; color: var(--text); font-size: 12px; outline: none; }
  .input:focus, select:focus, textarea:focus { border-color: var(--accent); }
  select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-color: var(--surface-2); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b9bb3' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; background-size: 12px; color: var(--text); cursor: pointer; }
  select option, select optgroup { background: var(--surface-2); color: var(--text); }
  select:disabled { opacity: .6; cursor: not-allowed; }
  .input[readonly] { color: #c4d1e2; }
  .input.secret { font-family: var(--mono); letter-spacing: .08em; }
  .check { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 12px; color: var(--muted); }
  .check > input { accent-color: var(--accent); width: 15px; height: 15px; }
  .form-section { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
  .agent-table { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
  .agent-row { display: grid; grid-template-columns: minmax(165px, 1.5fr) .6fr .65fr 1fr .8fr 30px; gap: 9px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line-soft); font-size: 11px; }
  .agent-row:last-child { border-bottom: 0; }
  .agent-row.head { padding-top: 8px; padding-bottom: 8px; background: rgba(18, 29, 47, .65); color: var(--dim); font: 9px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
  .agent-name { font-size: 12px; font-weight: 600; }
  .agent-sub { font-size: 10px; color: var(--dim); margin-top: 2px; }
  .agent-row .model { font: 10px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .repo-table { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
  .repo-row { display: grid; grid-template-columns: 1fr 1.6fr 1fr 1.3fr 30px; gap: 9px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); font-size: 11px; }
  .repo-row:last-child { border-bottom: 0; }
  .repo-row.head { padding-top: 8px; padding-bottom: 8px; background: rgba(18, 29, 47, .65); color: var(--dim); font: 9px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
  .repo-status { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; min-width: 0; }
  .repo-meta { font-size: 9px; color: var(--dim); }
  .repo-err { font-size: 9px; color: #f0a1a1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .operation { padding: 10px 11px; border: 1px solid var(--line-soft); border-radius: 8px; background: rgba(18, 29, 47, .45); }
  .operation + .operation { margin-top: 8px; }
  .operation-top { display: flex; align-items: center; gap: 7px; }
  .operation-title { font-size: 10.5px; font-weight: 600; }
  .operation-top .pill { margin-left: auto; }
  .operation-stage { margin-top: 7px; font: 9px var(--mono); color: var(--muted); }
  .operation-time { margin-top: 4px; font: 8.5px var(--mono); color: var(--dim); }
  .progress { height: 4px; margin-top: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
  .progress span { display: block; height: 100%; border-radius: inherit; background: var(--accent-2); }
  .progress.ok span { background: var(--green); }
  .demo-empty { padding: 22px; text-align: center; color: var(--dim); border: 1px dashed var(--line); border-radius: 8px; font-size: 11px; }
  .context-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 12px; }
  .context-file { width: 100%; padding: 8px 9px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); text-align: left; font-size: 10px; }
  .context-file.active { border-color: rgba(47, 200, 240, .25); background: rgba(47, 200, 240, .06); color: var(--text); }
  .context-editor { min-height: 260px; resize: vertical; font: 10px/1.6 var(--mono); white-space: pre-wrap; }
  .review-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .review-item { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 9px; color: var(--dim); }
  .review-item b { display: block; margin-top: 3px; font: 10px var(--mono); color: var(--muted); font-weight: 400; }
  .validation { display: flex; align-items: center; gap: 8px; padding: 10px 11px; margin-bottom: 13px; border: 1px solid rgba(66, 197, 154, .2); border-radius: 8px; background: rgba(66, 197, 154, .055); color: #b7e6d5; font-size: 10px; }
  .validation .pill { margin-left: auto; }
  @media (max-width: 1350px) {
    .control-grid { grid-template-columns: 245px minmax(0, 1fr); }
    .control-grid > .side-stack:last-child { grid-column: 1 / -1; }
    .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }
  @media (max-width: 1050px) {
    .control-grid { grid-template-columns: minmax(0, 1fr); }
    .control-grid > .side-stack:last-child { grid-column: auto; }
  }
  @media (max-width: 820px) {
    .health-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .context-layout { grid-template-columns: minmax(0, 1fr); }
    .agent-row { grid-template-columns: minmax(140px, 1.4fr) .55fr .6fr 1fr 28px; }
    .agent-row > :nth-child(5) { display: none; }
    .review-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (max-width: 520px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cluster-title { flex-wrap: wrap; }
    .cluster-title .head-pills { margin-left: 0; width: 100%; justify-content: flex-start; }
    .agent-row.head { display: none; }
    .agent-row { grid-template-columns: 1fr auto; gap: 5px 9px; padding: 11px; }
    .agent-row > :nth-child(2), .agent-row > :nth-child(3), .agent-row > :nth-child(4) { display: none; }
    .agent-row > :nth-child(5) { display: block; }
    .agent-row > :last-child { grid-column: 2; grid-row: 1; }
    .lifecycle .sep { display: none; }
  }

  /* Chat: тема скроллбаров, соцсетевая лента и fixed viewport */
  .ic { pointer-events: none; }
  :root { color-scheme: dark; }
  * { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
  *::-webkit-scrollbar { width: 10px; height: 10px; }
  *::-webkit-scrollbar-track { background: transparent; }
  *::-webkit-scrollbar-thumb {
    background: var(--line-strong); background-clip: padding-box;
    border: 2px solid transparent; border-radius: 999px;
  }
  *::-webkit-scrollbar-thumb:hover { background: #3b557a; }

  body[data-screen="scenarios"] { height: 100dvh; min-height: 0; overflow: hidden; }
  body[data-screen="scenarios"] .app { height: 100dvh; min-height: 0; overflow: hidden; }
  body[data-screen="scenarios"] .main { height: 100dvh; min-height: 0; overflow: hidden; }
  body[data-screen="scenarios"] .topbar,
  body[data-screen="scenarios"] .stale-banner { flex: none; }
  body[data-screen="scenarios"] .content {
    flex: 1; min-height: 0; overflow: hidden;
    display: flex; flex-direction: column; padding-bottom: 14px;
  }
  body[data-screen="scenarios"] #view-scenarios.active { height: auto; flex: 1; min-height: 0; }
  body[data-screen="scenarios"] .scenario-layout {
    flex: 1; min-height: 0; align-items: stretch;
    grid-template-rows: minmax(0, 1fr);
  }
  body[data-screen="scenarios"] #scenarioList {
    min-height: 0; overflow-y: auto; position: static;
  }
  body[data-screen="scenarios"] #scenarioDetail { min-height: 0; }
  body[data-screen="scenarios"] #scenarioDetail .tab-body { min-height: 0; overflow-y: auto; }
  body[data-screen="scenarios"] #scenarioDetail .tab-body.chat-tab {
    display: flex; flex-direction: column; overflow: hidden;
  }

  .chat-v2 .chat-feed {
    gap: 14px; padding: 14px 16px 18px;
    scrollbar-gutter: stable; overflow-anchor: none; overscroll-behavior: contain;
  }
  @media (min-width: 900px) {
    .chat-v2 .chat-feed {
      padding-left: max(16px, calc((100% - 860px) / 2));
      padding-right: max(16px, calc((100% - 860px) / 2));
    }
  }

  .chat-feed .msg {
    display: flex; gap: 9px; align-items: flex-start;
    max-width: 88%; padding: 0; border: 0; background: none; font-size: 12px;
  }
  .chat-feed .msg.human { flex-direction: row-reverse; align-self: flex-end; margin-left: auto; }
  .chat-feed .msg .avatar {
    width: 27px; height: 27px; flex: none; display: grid; place-items: center;
    border-radius: 7px; background: #183049; color: var(--accent-2); font: 700 10px var(--mono);
  }
  .chat-feed .msg.human .avatar { background: #28506a; color: #d9f5ff; }
  .chat-feed .msg .bubble { min-width: 0; }
  .chat-feed .msg .msg-head { margin: 0 0 4px; color: var(--muted); font: 10px var(--mono); }
  .chat-feed .msg .msg-head b { color: var(--muted); font-weight: 550; }
  .chat-feed .msg .msg-head span { margin-left: 6px; color: var(--dim); }
  .chat-feed .msg.human .msg-head { text-align: right; }
  .chat-feed .msg .text {
    padding: 10px 12px; border: 1px solid var(--line-soft);
    border-radius: 4px 11px 11px 11px; background: var(--surface-2);
    line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
  }
  .chat-feed .msg.human .text {
    border-color: rgba(91, 141, 214, .35); background: rgba(74, 123, 200, .18);
    border-radius: 11px 4px 11px 11px;
  }
  .chat-feed .msg.system { display: flex; align-self: center; max-width: 94%; }
  .chat-feed .msg.system .text {
    padding: 4px 9px; border-style: dashed; background: transparent;
    color: var(--dim); font: 9.5px var(--mono); text-align: center;
  }
  .chat-feed .chat-activity { margin: 0 0 0 36px; }
  .chat-feed .chat-activity + .chat-activity { margin-top: -6px; }
  .chat-feed .chat-task-divider { margin: 2px 0 6px; }

  .chat-v2 .chat-form { align-items: flex-end; gap: 8px; padding: 10px 2px 2px; }
  .chat-form textarea {
    flex: 1; min-height: 40px; max-height: 120px; padding: 9px 11px;
    border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2);
    font-size: 12px; line-height: 1.45; resize: none; outline: none;
  }
  .chat-form textarea:focus { border-color: var(--accent); }
  .chat-v2 .chat-form .icon-btn,
  .chat-v2 .chat-form [type="submit"] { align-self: flex-end; min-height: 40px; }
  .chat-hint { flex: none; margin-top: 5px; color: var(--dim); font: 9.5px var(--mono); }
  .chat-hint.warn { color: var(--amber); }
  .chat-stop { padding-left: 11px; padding-right: 11px; }
  .chat-stop-icon {
    width: 15px; height: 15px; display: inline-grid; place-items: center;
    border-radius: 50%; background: var(--red);
  }
  .chat-stop-icon::before {
    content: ""; width: 5px; height: 5px; border-radius: 1px; background: #fff;
  }

  .chat-drawer {
    top: 80px; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: min(340px, 92vw);
  }
  .chat-drawer.left { left: 248px; }
  .chat-drawer:focus { outline: none; }

  @media (max-width: 1080px) {
    .chat-drawer.left { left: 90px; }
  }

  @media (max-width: 820px) {
    body[data-screen="scenarios"] .content { padding: 8px 10px; }
    body[data-screen="scenarios"] #view-scenarios .page-head { display: none; }
    body[data-screen="scenarios"] #scenarioList {
      display: flex; gap: 6px; padding: 6px;
      max-height: none; overflow-x: auto; overflow-y: hidden;
    }
    body[data-screen="scenarios"] #view-scenarios .scenario-layout {
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: auto minmax(0, 1fr);
    }
    body[data-screen="scenarios"] #view-scenarios .scenario-item { flex: 0 0 190px; }
    .chat-drawer, .chat-drawer.left {
      top: 8px; bottom: calc(66px + env(safe-area-inset-bottom, 0px));
      left: 4vw; right: auto; width: 92vw;
    }
    .chat-v2 .chat-feed { gap: 10px; padding: 10px 10px 14px; }
    .chat-feed .msg { max-width: 94%; }
    .chat-feed .chat-activity { margin-left: 0; }
    .chat-form textarea { font-size: 16px; }
  }
  @media (max-width: 520px) {
    .chat-form .icon-btn { display: none; }
    #view-scenarios .scenario-meta { display: none; }
  }
  @media (max-height: 560px) {
    body[data-screen="scenarios"] .content { padding: 6px 10px; }
    body[data-screen="scenarios"] #view-scenarios .page-head,
    body[data-screen="scenarios"] .scenario-meta { display: none; }
    .chat-v2 .chat-v2-head { margin-bottom: 4px; }
  }
  @media (pointer: coarse) {
    .chat-form textarea, .chat-search { font-size: 16px; }
    .chat-hint { display: none; }
  }

  /* ---------- Агенты: вариант A (реестр + панель прямого чата) ---------- */
  body[data-screen="agents"] { height: 100dvh; min-height: 0; overflow: hidden; }
  body[data-screen="agents"] .app,
  body[data-screen="agents"] .main { height: 100dvh; min-height: 0; overflow: hidden; }
  body[data-screen="agents"] .topbar,
  body[data-screen="agents"] .stale-banner { flex: none; }
  body[data-screen="agents"] .content {
    flex: 1; min-height: 0; overflow: hidden;
    display: flex; flex-direction: column; padding-bottom: 14px;
  }
  body[data-screen="agents"] #view-agents.active { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  #view-agents .page-head, #view-agents .filters { flex: none; }
  #agentGroups { flex: 1; min-height: 0; }

  .agent-workspace { height: 100%; min-height: 0; display: grid; grid-template-columns: 258px minmax(0, 1fr); gap: 13px; }
  .agent-roster { min-height: 0; overflow-y: auto; padding: 7px; }
  .agent-roster-head { padding: 8px 9px 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 5px; }
  .agent-roster-head b { display: block; font-size: 12px; }
  .agent-roster-head span { display: block; margin-top: 3px; color: var(--dim); font-size: 10px; }
  .agent-roster-item { width: 100%; display: flex; gap: 9px; align-items: flex-start; padding: 10px 9px; text-align: left; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); }
  .agent-roster-item:hover { background: var(--surface-2); color: var(--text); }
  .agent-roster-item.active { background: rgba(74,123,200,.11); border-color: rgba(91,141,214,.28); color: var(--text); }
  .agent-roster-main { flex: 1; min-width: 0; }
  .agent-roster-name { display: block; font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .agent-roster-role, .agent-roster-task { display: block; margin-top: 2px; color: var(--dim); font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .agent-roster-task { color: var(--muted); }
  .agent-chat-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
  .agent-scenario-head { align-items: flex-start; }
  .agent-scenario-head .head-actions { max-width: 42%; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .agent-scenario-head .desc { max-width: 720px; }
  .agent-tabs { padding-top: 7px; }
  .agent-alt-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 18px; }
  .agent-alt-body .memory-grid { min-height: 100%; }
  .agent-alt-body .memory-block { padding: 13px; border: 1px solid var(--line-soft); border-radius: 8px; background: rgba(18,29,47,.45); }
  .agent-alt-body .memory-block h3 { margin: 0 0 9px; font-size: 12px; }
  .agent-alt-body .memory-pre { max-height: none; }
  .agent-context-note { margin-bottom: 12px; }
  .agent-chat-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 15px 14px; }
  .agent-chat-body .chat-v2 { flex: 1; min-height: 0; }
  .chat-v2-head .btn { flex: none; }
  .chat-thread-label { display: inline-block; max-width: min(300px,45vw); overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; white-space: nowrap; }
  .chat-feed .msg.orchestrator .avatar { background: #3a3168; color: #ded7ff; }
  .chat-feed .msg.orchestrator .text { border-color: rgba(157,140,240,.25); }
  .chat-message-source { margin-left: 5px; color: var(--violet); }
  .chat-system-warning { color: var(--amber) !important; }
  .chat-empty { margin: auto; max-width: 430px; padding: 28px 18px; text-align: center; color: var(--dim); }
  .chat-empty .ic { width: 28px; height: 28px; margin-bottom: 10px; color: var(--accent); }
  .chat-empty b { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
  .chat-empty p { margin: 0; font-size: 11px; line-height: 1.55; }
  .chat-form .busy-note { flex: 1; padding: 9px 11px; border: 1px dashed rgba(227,171,83,.3); border-radius: 9px; color: var(--amber); font-size: 11px; }
  .session-sidebar { min-height: 0; display: flex; flex-direction: column; padding: 12px; overflow: hidden; }
  .session-sidebar-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
  .session-sidebar-head b { flex: 1; font-size: 12px; }
  .session-sidebar .chat-search { flex: none; }
  .session-sidebar-list { min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); grid-auto-rows: auto; gap: 8px; align-content: start; }
  .session-source { display: inline-block; margin-top: 5px; color: var(--dim); font: 8.5px var(--mono); text-transform: uppercase; letter-spacing: .05em; }
  .session-new-row { margin: 0; }
  .agent-group { margin: 3px 0 9px; }
  .agent-group-head { width: 100%; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--dim); text-align: left; font: 9px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
  .agent-group-head:hover { background: var(--surface-2); color: var(--muted); }
  .agent-group-head .ic { width: 12px; height: 12px; transition: transform .15s; }
  .agent-group-head.expanded .ic { transform: rotate(90deg); }
  .agent-group-head .count { margin-left: auto; padding: 0 5px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 8.5px; }
  .agent-group-items { margin-left: 10px; padding-left: 7px; border-left: 1px solid var(--line-soft); }
  .agent-group-items[hidden] { display: none !important; }
  .agent-chat-drawer { z-index: 70; }
  .agent-chat-drawer .chat-drawer-head { flex: none; }
  .agent-chat-drawer .chat-context-card .renewed { color: var(--amber); }
  .usage-note { margin-top: 14px; padding: 8px; border: 1px dashed var(--line); border-radius: 6px; color: var(--dim); font-size: 9.5px; line-height: 1.45; }
  .wc-scope { margin-top: 5px; color: var(--accent-2); font: 8.5px var(--mono); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  @media (max-width: 1080px) {
    .agent-workspace { grid-template-columns: 225px minmax(0,1fr); }
  }
  @media (max-width: 820px) {
    body[data-screen="agents"] .content { padding: 10px 10px 76px; }
    #view-agents .page-head { display: none; }
    #view-agents .filters { margin-bottom: 8px; }
    .agent-workspace { grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr); gap: 8px; }
    .agent-roster { display: flex; gap: 6px; padding: 6px; overflow-x: auto; overflow-y: hidden; }
    .agent-roster-head { display: none; }
    .agent-roster-item { flex: 0 0 205px; padding: 8px; }
    .agent-roster-task { display: none; }
    .agent-scenario-head { padding: 10px 12px; }
    .agent-scenario-head .desc, .agent-scenario-meta { display: none; }
    .agent-scenario-head .head-actions { max-width: none; }
    .agent-chat-body { padding: 9px 10px 10px; }
    .agent-group { flex: 0 0 auto; margin: 0; }
    .agent-group-head { display: none; }
    .agent-group-items, .agent-group-items[hidden] { display: flex !important; gap: 6px; margin: 0; padding: 0; border: 0; }
    .agent-chat-drawer { top: 8px; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); left: 4vw !important; right: auto; width: 92vw; }
  }
  @media (max-width: 520px) {
    .agent-scenario-head h2, .chat-v2-title b { font-size: 15px; }
    .chat-v2-head { gap: 5px; }
    .chat-v2-head .btn { padding: 0 7px; }
    .chat-thread-label { max-width: 42vw; }
    .agent-scenario-head .head-actions .pill { display: none; }
  }
  @media (max-height: 620px) {
    .agent-scenario-meta { display: none; }
  }
