/* ARES Architectural Design */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --ink: #141a26;
  --ink-2: #4a5568;
  --ink-3: #7a8597;
  --line: #d9dee6;
  --wire: #9aa6b8;
  --focus: #2f6fdf;

  --a-claude: #c2603c;
  --a-suite: #2f6fdf;
  --a-ci: #13867a;
  --a-target: #5b6779;
  --a-launcher: #b7791f;
  --a-platform: #7a4fc9;
  --a-human: #c53b5a;

  --k-flow: #5e6c82;
  --k-ci: #13867a;
  --k-deploy: #b7791f;
  --k-cred: #7a4fc9;

  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .08);
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e121a; --surface: #161c27; --surface-2: #1d2532; --ink: #e8ecf3; --ink-2: #b3bdcc; --ink-3: #8691a3;
    --line: #2b3545; --wire: #55627a; --focus: #6ea0ff;
    --a-claude: #e58a66; --a-suite: #6ea0ff; --a-ci: #3cc2b1; --a-target: #9aa6b8; --a-launcher: #e6a845; --a-platform: #a988f0; --a-human: #f07390;
    --k-flow: #8a97ad; --k-ci: #3cc2b1; --k-deploy: #e6a845; --k-cred: #a988f0;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e121a; --surface: #161c27; --surface-2: #1d2532; --ink: #e8ecf3; --ink-2: #b3bdcc; --ink-3: #8691a3;
  --line: #2b3545; --wire: #55627a; --focus: #6ea0ff;
  --a-claude: #e58a66; --a-suite: #6ea0ff; --a-ci: #3cc2b1; --a-target: #9aa6b8; --a-launcher: #e6a845; --a-platform: #a988f0; --a-human: #f07390;
  --k-flow: #8a97ad; --k-ci: #3cc2b1; --k-deploy: #e6a845; --k-cred: #a988f0;
  --shadow: 0 1px 2px rgb(0 0 0 / .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ── header */
.top { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; padding: 18px 24px 12px; }
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.brand h1 { font-size: 20px; letter-spacing: -.01em; }
.tagline { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }
.app-id { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.app-id label { display: flex; flex-direction: column; font-size: 12px; color: var(--ink-3); gap: 3px; }
.app-id input { font: 14px var(--mono); padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); width: 15em; }
.app-id #in-version { width: 7em; }
.app-id input.bad { border-color: var(--a-human); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; width: 34px; height: 34px; cursor: pointer; }

/* ── tour bar */
.tourbar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 6px 12px; cursor: pointer; }
.btn:hover { border-color: var(--ink-3); }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); min-width: 9.5em; }
.progress { width: 140px; height: 4px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--focus); transition: width .3s; }
.count { color: var(--ink-2); font-size: 13px; flex: 1 1 220px; min-width: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--ink-2); }
.lg { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.lg input { accent-color: var(--focus); margin: 0; }
.lg span { width: 22px; height: 0; border-top: 2px solid var(--k-flow); }
.lg-ci span { border-top: 2px dashed var(--k-ci); }
.lg-deploy span { border-top: 2px solid var(--k-deploy); }
.lg-cred span { border-top: 2px dotted var(--k-cred); }

/* ── board */
main { padding: 0 0 40px; transition: padding-right .2s; }
.board-scroll { overflow-x: auto; padding: 8px 0 4px; }
.board {
  position: relative; display: grid; grid-template-columns: repeat(6, minmax(196px, 1fr));
  column-gap: 46px; row-gap: 22px; min-width: 1360px; padding: 12px 24px 24px;
}
.wires { position: absolute; inset: 0; pointer-events: none; z-index: 1; overflow: visible; }
.stage { grid-column: var(--col); grid-row: 2; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.stage-head { display: flex; gap: 10px; align-items: flex-start; padding: 0 2px 4px; border-bottom: 1px solid var(--line); min-height: 64px; }
.stage-head .num { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 600; }
.stage-head h2 { font-size: 15px; }
.stage-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.35; }
.stage[data-stage="promote"] .stage-head .num { background: var(--a-human); }
.stage[data-stage="prod"] .stage-head .num { background: var(--a-suite); }
.nodes { display: flex; flex-direction: column; gap: 24px; flex: 1; justify-content: flex-start; }

.node {
  position: relative; z-index: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  width: 100%; padding: 10px 12px 11px; background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--actor, var(--line)); border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer;
  transition: transform .15s, border-color .15s, opacity .2s, box-shadow .15s;
}
.node:hover { transform: translateY(-1px); border-color: var(--actor); }
.node .actor { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--actor); }
.n-title { font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.n-title em { font-style: normal; font-weight: 400; color: var(--ink-2); font-size: 13px; margin-left: 6px; }
.n-sub { font-size: 12.5px; color: var(--ink-2); font-family: var(--mono); overflow-wrap: anywhere; }
[data-actor="claude"] { --actor: var(--a-claude); }
[data-actor="suite"] { --actor: var(--a-suite); }
[data-actor="ci"] { --actor: var(--a-ci); }
[data-actor="target"] { --actor: var(--a-target); }
[data-actor="launcher"] { --actor: var(--a-launcher); }
[data-actor="platform"] { --actor: var(--a-platform); }
[data-actor="human"] { --actor: var(--a-human); }
.node[data-actor="human"] { border-style: dashed; border-left-style: solid; }

.board.has-focus .node:not(.is-active):not(.is-linked) { opacity: .42; }
.node.is-active { box-shadow: 0 0 0 3px color-mix(in srgb, var(--actor) 35%, transparent), var(--shadow); border-color: var(--actor); opacity: 1; }
.node.is-done::after { content: "✓"; position: absolute; top: 8px; right: 10px; font-size: 12px; color: var(--a-ci); }

/* bands */
.band { border-radius: 14px; }
.band-launcher { grid-column: 4 / 7; grid-row: 1; }
.node-wide { background: color-mix(in srgb, var(--a-launcher) 9%, var(--surface)); }
.mini-steps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mini-steps span { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--a-launcher) 40%, var(--line)); color: var(--ink-2); }
.mini-steps span + span::before { content: "→ "; color: var(--ink-3); }

.band-platform {
  grid-column: 1 / 7; grid-row: 3; padding: 14px 16px 16px; display: grid; grid-template-columns: 230px 1fr; gap: 18px 46px; align-items: center;
  background: color-mix(in srgb, var(--a-platform) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--a-platform) 30%, var(--line));
}
.band-label { display: flex; flex-direction: column; gap: 4px; }
.band-label strong { color: var(--a-platform); font-size: 15px; }
.band-label span { font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }
.band-nodes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 46px; }

.creds {
  position: relative; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 8px; text-align: left; cursor: pointer;
  border: 1px dashed color-mix(in srgb, var(--a-platform) 45%, var(--line)); border-radius: 8px; background: transparent; z-index: 2;
}
.creds::after { content: ""; position: absolute; left: 50%; bottom: -23px; height: 22px; border-left: 2px dotted var(--k-cred); opacity: .6; }
.creds-h { width: 100%; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--a-platform); font-weight: 600; }
.creds.is-linked { border-style: solid; background: color-mix(in srgb, var(--a-platform) 10%, transparent); }
.chip { font: 11.5px/1.4 var(--mono); padding: 2px 7px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); overflow-wrap: anywhere; }
.chip-key { background: color-mix(in srgb, var(--a-platform) 14%, var(--surface)); color: var(--ink); }

/* wires */
.wire { fill: none; stroke-width: 1.6; stroke: var(--k-flow); opacity: .7; transition: opacity .2s, stroke-width .2s; }
.wire.k-ci { stroke: var(--k-ci); stroke-dasharray: 6 5; }
.wire.k-deploy { stroke: var(--k-deploy); stroke-width: 2; }
.wire.k-cred { stroke: var(--k-cred); stroke-dasharray: 2 4; stroke-linecap: round; }
.m-flow { fill: var(--k-flow); } .m-ci { fill: var(--k-ci); } .m-deploy { fill: var(--k-deploy); } .m-cred { fill: var(--k-cred); } .m-lit { fill: var(--focus); }
.wire-label { font: 11px var(--sans); fill: var(--ink-3); opacity: 0; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; transition: opacity .2s; }
.board.has-focus .wire { opacity: .16; }
.board.has-focus .wire.lit { opacity: 1; stroke: var(--focus); stroke-width: 2.4; stroke-dasharray: 8 6; animation: flow 0.9s linear infinite; }
.board.has-focus .wire-label.lit { opacity: 1; fill: var(--ink); }
@keyframes flow { to { stroke-dashoffset: -14; } }
#wires[data-hidden~="flow"] .k-flow, #wires[data-hidden~="ci"] .k-ci,
#wires[data-hidden~="deploy"] .k-deploy, #wires[data-hidden~="cred"] .k-cred { display: none; }
@media (prefers-reduced-motion: reduce) { .board.has-focus .wire.lit { animation: none; } .node, .progress span { transition: none; } }

/* ── topology + rules */
.topology, .rules { max-width: 1180px; margin: 28px auto 0; padding: 0 24px; }
.topology h2, .rules h2 { font-size: 17px; margin-bottom: 6px; }
.topo-row { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.topo-env { display: flex; flex-direction: column; gap: 4px; }
.topo-env code { overflow-wrap: anywhere; }
.topo-path { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 26px; align-items: center; }
.topo-path li { position: relative; padding: 6px 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font: 13px var(--mono); }
.topo-path li + li::before { content: "→"; position: absolute; left: -20px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-family: var(--sans); }
.topo-row[data-env="pre"] .topo-path li:last-child { border-color: var(--a-launcher); }
.topo-row[data-env="prod"] .topo-path li:nth-child(4) { border-color: var(--a-suite); }
.rules ul { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 6px; color: var(--ink-2); }
.rules strong { color: var(--ink); }

/* ── panel */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 100%; z-index: 40; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgb(0 0 0 / .08); padding: 22px 22px 32px;
}
.panel .close { position: absolute; top: 14px; right: 14px; }
.panel h2 { font-size: 20px; margin: 4px 36px 2px 0; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 18px 0 6px; }
.panel ol { margin: 0; padding-left: 20px; display: grid; gap: 5px; }
.p-where { margin: 0; font-size: 12.5px; color: var(--ink-3); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-right: 40px; }
.p-where .actor { font-weight: 600; color: var(--actor); text-transform: uppercase; letter-spacing: .04em; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: color-mix(in srgb, var(--actor) 14%, transparent); }
.p-sub { margin: 0 0 10px; font: 13px var(--mono); color: var(--ink-2); overflow-wrap: anywhere; }
.cmd { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; background: var(--surface-2); border-radius: 7px; padding: 6px 6px 6px 10px; }
.cmd code { background: none; padding: 0; flex: 1; overflow-wrap: anywhere; }
.copy { border: 1px solid var(--line); background: var(--surface); border-radius: 5px; font-size: 12px; padding: 2px 8px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.guard { margin-top: 16px; padding: 10px 12px; border-left: 3px solid var(--a-human); background: color-mix(in srgb, var(--a-human) 8%, transparent); border-radius: 0 8px 8px 0; font-size: 14px; }
.p-links { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--ink-3); }
.p-links > span { width: 100%; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.link-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 3px 10px; cursor: pointer; font-size: 13px; }
.link-chip:hover { border-color: var(--focus); }
@media (min-width: 1180px) { body.panel-open main, body.panel-open .tourbar { padding-right: 420px; } }

.foot { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 20px 24px 28px; font-size: 13px; color: var(--ink-3); border-top: 1px solid var(--line); margin-top: 32px; }

/* ── narrow screens: stages become a vertical list, wires give way to arrows */
@media (max-width: 760px) {
  .top, .tourbar { padding-left: 16px; padding-right: 16px; }
  .app-id input { width: 12em; }
  .legend { display: none; }
  .board { grid-template-columns: 1fr; min-width: 0; padding: 8px 16px 16px; row-gap: 30px; }
  .wires { display: none; }
  .stage, .band-launcher, .band-platform { grid-column: 1; grid-row: auto; }
  .stage { order: calc(var(--col) * 10); }
  .band-launcher { order: 35; }
  .band-platform { order: 100; grid-template-columns: 1fr; }
  .band-nodes { grid-template-columns: 1fr; gap: 10px; }
  .nodes { gap: 10px; }
  .stage::after { content: "↓"; text-align: center; color: var(--ink-3); font-size: 18px; margin-top: -6px; }
  .creds::after { display: none; }
  .topology, .rules { padding: 0 16px; }
  .topo-row { grid-template-columns: 1fr; }
  .panel { top: auto; height: 72vh; width: 100%; border-left: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; }
}
