/* punk0 site. Two layers: `page` is the white marketing page (--p-* tokens);
   `views` draws the coded product views, which read only the app's own theme
   tokens from themes.css (generated from web/themes). */
@layer page, views;

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

@layer page {
  :root {
    --p-paper: #ffffff;
    --p-ink: #1f2030;
    --p-body: #4a4c5e;
    --p-muted: #6c6f85;
    --p-rule: #e3e5ec;
    --p-band: #f6f7f9;
    --p-brand: #fe640b;
    --p-brand-ink: #b5470a;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --wrap: 1240px;
    --gutter: clamp(20px, 4vw, 40px);
    --sec: clamp(80px, 10vw, 136px);
    --r: 4px;
  }

  *, *::before, *::after { box-sizing: border-box; }
  [hidden] { display: none !important; }
  html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
  @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

  body {
    margin: 0;
    background: var(--p-paper);
    color: var(--p-body);
    font: 17px/1.6 var(--sans);
    -webkit-font-smoothing: antialiased;
  }
  a { color: var(--p-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
  a:hover { color: var(--p-brand-ink); }
  h1, h2, h3, h4 { font-family: var(--mono); color: var(--p-ink); margin: 0; }
  p { margin: 0; }
  code, kbd, pre { font-family: var(--mono); }
  :not(pre) > code {
    font-size: 0.84em;
    padding: 0.08em 0.36em;
    border: 1px solid var(--p-rule);
    border-radius: 3px;
    background: var(--p-band);
    color: var(--p-ink);
    white-space: nowrap;
  }
  kbd {
    display: inline-block;
    margin-right: 0.2em;
    padding: 0 0.42em;
    border: 1px solid #d2d5de;
    border-bottom-width: 2px;
    border-radius: 3px;
    background: #fff;
    font-size: 0.76em;
    line-height: 1.65;
    color: var(--p-ink);
  }
  :focus-visible { outline: 2px solid var(--p-brand); outline-offset: 2px; border-radius: 2px; }
  ::selection { background: rgba(254, 100, 11, 0.18); }

  .wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
  .dim { color: var(--p-muted); }

  .skip {
    position: absolute; left: 8px; top: -60px; z-index: 20;
    padding: 10px 14px; background: var(--p-ink); color: #fff;
    border-radius: var(--r); font-weight: 600; text-decoration: none;
  }
  .skip:focus { top: 8px; }

  .wordmark {
    font: 700 19px/1 var(--mono);
    letter-spacing: -0.02em;
    color: var(--p-ink);
    text-decoration: none;
  }
  .wordmark span { color: var(--p-brand); }

  /* Buttons */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 44px; padding: 0 18px;
    border: 1px solid transparent; border-radius: var(--r);
    font: 600 14.5px/1 var(--mono); letter-spacing: -0.01em;
    text-decoration: none; white-space: nowrap; cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 80ms ease;
  }
  .btn:active { transform: translateY(1px); }
  .btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
  .btn-ink { background: var(--p-ink); color: #fff; }
  .btn-ink:hover { background: #33354a; color: #fff; }
  .btn-line { background: #fff; border-color: #d2d5de; color: var(--p-ink); }
  .btn-line:hover { border-color: var(--p-ink); color: var(--p-ink); }
  .btn-brand { background: var(--p-brand); color: #fff; }
  .btn-brand:hover { background: #e2550a; color: #fff; }

  /* Nav */
  .nav {
    position: sticky; top: 0; z-index: 10;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--p-rule);
    backdrop-filter: saturate(1.4) blur(8px);
  }
  .nav-row { display: flex; align-items: center; gap: 28px; height: 60px; }
  .nav-row > nav { margin-left: auto; }
  .nav-links { display: flex; gap: 26px; margin: 0; padding: 0; list-style: none; }
  .nav-links a { font: 500 13.5px/1 var(--mono); color: var(--p-muted); text-decoration: none; }
  .nav-links a:hover { color: var(--p-ink); }

  /* Hero */
  .hero { padding: clamp(56px, 8vw, 104px) 0 72px; }
  .hero-grid { display: grid; gap: 28px; }
  h1 {
    font-size: clamp(2.2rem, 4.2vw, 3.6rem);
    line-height: 1.04;
    letter-spacing: -0.05em;
    font-weight: 800;
    text-wrap: balance;
  }
  /* One sentence per line; a sentence wraps on its own on narrow screens. */
  h1 > span { display: block; }
  .hero-side { display: flex; flex-direction: column; align-items: flex-start; gap: 28px; }
  .lede { font-size: clamp(1.05rem, 1.5vw, 1.2rem); line-height: 1.6; color: var(--p-body); max-width: 52ch; }
  .get { display: grid; gap: 14px; width: 100%; max-width: 760px; }
  .get-links { font: 500 13.5px/1.4 var(--mono); color: var(--p-muted); }
  .get-links a { color: var(--p-ink); }
  .get-tabs { display: flex; gap: 4px; margin-left: -6px; }
  .get-card .code-head { gap: 12px; }
  .get-tabs button {
    height: 28px; padding: 0 10px; border: 1px solid transparent; border-radius: 3px;
    background: none; font: 600 12px/1 var(--mono); color: var(--p-muted); cursor: pointer;
  }
  .get-tabs button:hover { color: var(--p-ink); }
  .get-tabs button[aria-selected="true"] { background: #fff; border-color: #d2d5de; color: var(--p-ink); }
  .get-card pre { font-size: 13.5px; }

  .stage { margin: clamp(44px, 6vw, 72px) 0 0; }
  .stage .fit { width: 1180px; transform-origin: 0 0; }
  .stage-bar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px;
    min-height: 52px; margin-top: 14px; padding: 8px 0;
    border-top: 1px solid var(--p-rule);
    font-size: 14px; color: var(--p-muted);
  }
  .stage-status { flex: 1 1 260px; min-height: 1.6em; }
  .stage-status.waiting { color: var(--p-brand-ink); }
  .stage-wait { flex: 0 0 auto; min-width: 112px; display: flex; justify-content: flex-end; }
  .stage-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
  .theme-name { font-size: 13px; color: var(--p-muted); white-space: nowrap; }
  .theme-name b { color: var(--p-ink); font-weight: 600; }

  .swatches { display: inline-flex; flex-wrap: wrap; gap: 6px; }
  .swatch {
    position: relative;
    width: 28px; height: 28px; padding: 0;
    border: 1px solid rgba(31, 32, 48, 0.2); border-radius: 50%;
    cursor: pointer;
    transition: transform 120ms ease;
  }
  .swatch::after {
    content: ""; position: absolute; inset: 0; margin: auto;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--sw-accent);
  }
  .swatch:hover { transform: scale(1.12); }
  .swatch[aria-checked="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--p-ink); }

  /* Sections */
  .sec { padding: clamp(64px, 7vw, 104px) 0; border-top: 1px solid var(--p-rule); }
  h2 {
    font-size: clamp(1.8rem, 3.2vw, 2.6rem);
    line-height: 1.08;
    letter-spacing: -0.04em;
    font-weight: 800;
    text-wrap: balance;
  }
  h3 { font-size: 1.125rem; line-height: 1.3; font-weight: 700; letter-spacing: -0.02em; }
  .sec-lede { margin-top: 16px; max-width: 62ch; font-size: 1.08rem; color: var(--p-body); }
  .sec-lede.narrow { max-width: 58ch; }
  .note { margin-top: 18px; max-width: 74ch; font-size: 14.5px; color: var(--p-muted); }
  .sub { margin-top: clamp(64px, 8vw, 96px); font-size: clamp(1.3rem, 2.2vw, 1.7rem); letter-spacing: -0.035em; font-weight: 800; }

  /* The punk0 way */
  .way { margin-top: 44px; }
  .way-head, .way-list > div {
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    gap: clamp(20px, 4vw, 56px);
  }
  .way-head {
    padding-bottom: 10px;
    font: 600 12.5px/1 var(--mono); color: var(--p-muted);
  }
  .way-head span:last-child { color: var(--p-brand-ink); }
  .way-list { margin: 0; }
  .way-list > div { padding: 18px 0; border-top: 1px solid var(--p-rule); }
  .way-list dt { color: var(--p-muted); }
  .way-list dd { margin: 0; color: var(--p-ink); }

  .principles {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 56px;
    border: 1px solid var(--p-rule); border-radius: var(--r);
    background: var(--p-rule); gap: 1px; overflow: hidden;
  }
  .principles > div { background: #fff; padding: 22px 22px 24px; }
  .principles p { margin-top: 8px; font-size: 16px; }

  /* Compare */
  .cmp { margin-top: 44px; display: grid; gap: 28px; }
  .data { width: 100%; border-collapse: collapse; font-size: 14.5px; }
  .data caption { caption-side: bottom; text-align: left; padding-top: 12px; font-size: 13.5px; color: var(--p-muted); line-height: 1.5; }
  .data th, .data td { padding: 12px 14px; border-bottom: 1px solid var(--p-rule); text-align: right; white-space: nowrap; }
  .data thead th { font: 600 12px/1.3 var(--mono); color: var(--p-muted); border-bottom-color: #cfd2db; }
  .data th[scope="row"], .data thead th:first-child { text-align: left; font-family: var(--mono); color: var(--p-ink); font-weight: 600; }
  .data td { font-family: var(--mono); color: var(--p-ink); font-variant-numeric: tabular-nums; }
  .data tr.us th, .data tr.us td { background: rgba(254, 100, 11, 0.05); }
  .data tr.us th[scope="row"] { box-shadow: inset 3px 0 0 var(--p-brand); }
  .data td.txt { font-family: var(--sans); text-align: left; white-space: normal; color: var(--p-body); }
  .data .na { color: var(--p-muted); }
  .data .sub-num { display: block; margin-top: 2px; font: 12px/1.4 var(--sans); color: var(--p-muted); white-space: normal; }
  .data caption { padding: 12px 14px; border-top: 1px solid var(--p-rule); background: var(--p-band); }
  .ships thead th { text-align: left; }
  .ships th[scope="row"] { width: 22%; white-space: normal; font-size: 13.5px; }
  .ships td.txt { width: 26%; font-size: 15px; vertical-align: top; }
  .ships tbody th, .ships tbody td { vertical-align: top; }
  .ships thead th:nth-child(2), .ships tbody td:nth-child(2) { color: var(--p-ink); background: rgba(254, 100, 11, 0.04); }
  .ships thead th:nth-child(2) { color: var(--p-brand-ink); }
  .table-scroll { position: relative; overflow-x: auto; border: 1px solid var(--p-rule); border-radius: var(--r); background: #fff; }
  .table-scroll .data tr:last-child > * { border-bottom: 0; }
  .table-scroll .data th[scope="row"], .table-scroll .data thead th:first-child { position: sticky; left: 0; z-index: 1; background: #fff; }

  /* How it works */
  .how { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: clamp(40px, 6vw, 88px); align-items: start; }
  .steps { list-style: none; counter-reset: s; margin: 40px 0 0; padding: 0; }
  .steps li { counter-increment: s; display: grid; grid-template-columns: 40px 1fr; padding: 20px 0; border-top: 1px solid var(--p-rule); }
  .steps li::before { content: counter(s); grid-row: span 2; font: 700 15px/1.45 var(--mono); color: var(--p-brand-ink); }
  .steps p { margin-top: 6px; font-size: 16.5px; }
  .log { margin: 0; position: sticky; top: 92px; border: 1px solid var(--p-rule); border-radius: var(--r); overflow: hidden; }
  .log-head { padding: 9px 14px; background: var(--p-band); border-bottom: 1px solid var(--p-rule); font: 12px/1.4 var(--mono); color: var(--p-muted); }
  .log pre { margin: 0; padding: 20px 22px; overflow-x: auto; font-size: 13.5px; line-height: 1.75; color: var(--p-ink); background: #fff; }
  .log .ok { color: #2f8a1d; }

  /* Grids of cells: 1px rules, not cards */
  .grid { display: grid; gap: 1px; margin-top: 44px; background: var(--p-rule); border: 1px solid var(--p-rule); border-radius: var(--r); overflow: hidden; }
  .g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cell { background: #fff; padding: clamp(22px, 3vw, 32px); display: flex; flex-direction: column; gap: 10px; }
  .cell > p { font-size: 16px; }
  .cell .app.mini { margin-top: 6px; }
  .cell > h3 + p { margin-top: 2px; }

  .keys { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(20px, 3vw, 40px); margin: 32px 0 0; }
  .keys dt { font: 700 14.5px/1.4 var(--mono); color: var(--p-ink); }
  .keys dd { margin: 8px 0 0; font-size: 16px; }

  /* Built on px0 band */
  .band { background: var(--p-band); }
  .band .cell { background: #fff; }
  .px0-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 32px; align-items: end; }
  .px0-links { display: flex; gap: 10px; flex-wrap: wrap; }
  .tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; padding: 0; list-style: none; }
  .tags li { padding: 3px 8px; border: 1px solid var(--p-rule); border-radius: 3px; font: 12px/1.5 var(--mono); color: var(--p-ink); background: var(--p-band); }
  .px0-speed { margin-top: 56px; }
  .px0-speed h3 { margin-bottom: 16px; font-size: 1.15rem; }

  /* Install */
  .install { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); grid-template-areas: "text codes" "docs codes"; gap: 0 clamp(36px, 6vw, 80px); align-items: start; }
  .install-text { grid-area: text; }
  .install .codes { grid-area: codes; }
  .install-docs { grid-area: docs; }
  .next { margin-top: 40px; font-size: 1rem; }
  .docs { list-style: none; margin: 10px 0 0; padding: 0; }
  .docs li { padding: 12px 0; border-top: 1px solid var(--p-rule); }
  .docs a { font: 600 15px/1.4 var(--mono); text-decoration: none; }
  .docs a:hover { text-decoration: underline; }
  .docs span { display: block; margin-top: 2px; font-size: 14.5px; color: var(--p-muted); }
  .codes { display: grid; gap: 16px; }
  .code-card { border: 1px solid var(--p-rule); border-radius: var(--r); overflow: hidden; }
  .code-head { display: flex; align-items: center; justify-content: space-between; min-height: 40px; padding: 6px 8px 6px 14px; background: var(--p-band); border-bottom: 1px solid var(--p-rule); font: 600 12px/1 var(--mono); color: var(--p-muted); }
  .code-card pre { margin: 0; padding: 18px 20px; overflow-x: auto; font-size: 14px; line-height: 1.75; color: var(--p-ink); background: #fff; }
  .copy { height: 28px; padding: 0 12px; border: 1px solid #d2d5de; border-radius: 3px; background: #fff; font: 600 12px/1 var(--mono); color: var(--p-ink); cursor: pointer; }
  .copy:hover { border-color: var(--p-ink); }
  .copy[data-state="done"] { color: #2f8a1d; border-color: #2f8a1d; }

  /* Footer */
  .foot { border-top: 1px solid var(--p-rule); padding: 36px 0 56px; }
  .foot-row { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; font-size: 14px; color: var(--p-muted); }
  .foot-row > a:last-child { margin-left: auto; }

  @media (max-width: 1080px) {
    .hero-grid, .how, .px0-head { grid-template-columns: minmax(0, 1fr); }
    .install { grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "codes" "docs"; }
    .install .codes { margin-top: 28px; }
    .log { position: static; }
    .principles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (max-width: 760px) {
    body { font-size: 16px; }
    .nav-links { display: none; }
    .nav-gh { margin-left: auto; }
    .g-2, .g-3, .principles, .keys { grid-template-columns: minmax(0, 1fr); }
    .way-head { display: none; }
    .way-list > div { grid-template-columns: minmax(0, 1fr); gap: 6px; }
    .stage-wait { min-width: 0; justify-content: flex-start; }
    .swatches { display: grid; grid-template-columns: repeat(7, 32px); gap: 8px; }
    .swatch { width: 32px; height: 32px; }
    .foot-row > a:last-child { margin-left: 0; }
  }
}

/* ------------------------------------------------------------------ views */
@layer views {
  .app {
    --sh: 0 1px 0 rgba(0,0,0,.02), 0 18px 50px -24px rgba(31, 32, 48, 0.35);
    background: var(--bg);
    color: var(--fg);
    font: 12.5px/1.5 var(--mono);
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background-color 200ms ease, color 200ms ease;
  }
  .app * { box-sizing: border-box; }
  .app .dim { color: var(--faint); }
  .app .wm { font-weight: 700; color: var(--fg); } .app .wm span { color: var(--mark-active); }
  .app .k { color: var(--k); } .app .kt { color: var(--kt); } .app .nf { color: var(--nf); }
  .app .nb { color: var(--nb); } .app .s { color: var(--s); } .app .c { color: var(--c); font-style: italic; }
  .app .o { color: var(--o); } .app .p { color: var(--p); } .app .m { color: var(--m); }

  /* shared bits */
  .app .tabs { display: flex; align-items: center; gap: 2px; height: 34px; padding: 0 6px; background: var(--bg2); border-bottom: 1px solid var(--line); }
  .app .tab { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 3px; color: var(--dim); white-space: nowrap; }
  .app .tab.on { background: var(--bg); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line); }
  .app .tab .kind { color: var(--accent); }
  .app .tab .x { margin-left: 4px; color: var(--faint); }
  .app .tab-add { padding: 0 8px; color: var(--faint); }
  .app .tdot, .app .sdot, .app .cdot, .app .fdot { display: inline-block; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--bg4); }
  .app .tdot.on, .app .sdot.on, .app .cdot.on { background: var(--gi); }
  .app .tdot.work { background: var(--accent-fg); }
  .app .tdot.wait { background: var(--mark-active); }
  .app .tdot.idle { background: var(--gi); }
  .app .fdot { width: 6px; height: 6px; border-radius: 1px; background: var(--accent-fg); }
  .app .seg { display: inline-flex; padding: 2px; border-radius: 3px; background: var(--bg3); gap: 2px; }
  .app .seg > span { padding: 2px 8px; border-radius: 2px; color: var(--dim); }
  .app .seg > span.on { background: var(--bg); color: var(--fg); }
  .app .icons { color: var(--faint); letter-spacing: 0.3em; }
  .app .chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border-radius: 3px; font-weight: 600; }
  .app .chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
  .app .chip.wait { color: var(--mark-active); background: color-mix(in srgb, var(--mark-active) 14%, transparent); }
  .app .chip.work { color: var(--accent-fg); background: color-mix(in srgb, var(--accent-fg) 12%, transparent); }
  .app .term { padding: 12px 14px; white-space: pre; overflow: hidden; color: var(--fg); line-height: 1.55; }
  .app .term .hl { color: var(--accent); font-weight: 700; }
  .app .code { margin: 0; padding: 6px 0; font: inherit; line-height: 1.55; display: flex; flex-direction: column; overflow: hidden; }
  .app .code .row { display: block; padding-right: 10px; white-space: pre; }
  .app .code .ln { display: inline-block; width: 34px; padding-right: 8px; text-align: right; color: var(--faint); user-select: none; }
  .app .code .row.add { background: var(--gi-bg); }
  .app .code .row.del { background: var(--gd-bg); }
  .app .code .row.del, .app .code .row.del span { text-decoration-color: color-mix(in srgb, var(--gd) 50%, transparent); }
  .app .code .mk { background: color-mix(in srgb, var(--fg) 12%, transparent); border-radius: 2px; }
  .app .ag-status, .app .ed-status { display: flex; align-items: center; gap: 12px; height: 26px; padding: 0 10px; background: var(--bg2); border-top: 1px solid var(--line); font-size: 11.5px; color: var(--dim); white-space: nowrap; }
  .app .ag-status .mid { flex: 1; display: flex; justify-content: center; gap: 8px; }
  .app .res b { color: var(--fg); font-weight: 600; }

  /* agents page */
  .agents { box-shadow: var(--sh); }
  .agents .ag-body { display: grid; grid-template-columns: 236px minmax(0, 1fr) minmax(0, 0fr) 232px; height: 560px; }
  .agents[data-state="5"] .ag-body { transition: grid-template-columns 450ms cubic-bezier(.2,.7,.2,1); }
  .agents:not([data-state="5"]) .ag-diff > * { visibility: hidden; }
  .agents[data-state="5"] .ag-body { grid-template-columns: 236px minmax(0, 1fr) minmax(0, 1fr) 232px; }
  .agents .ag-side { background: var(--bg2); border-right: 1px solid var(--line); padding: 8px 8px; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
  .agents .search { display: flex; align-items: center; gap: 8px; margin: 4px 0; padding: 5px 8px; border-radius: 3px; background: var(--bg3); color: var(--faint); }
  .agents .mag { width: 9px; height: 9px; border: 1.5px solid var(--faint); border-radius: 50%; }
  .agents .side-head { display: flex; justify-content: space-between; padding: 6px 4px 2px; }
  .agents .proj { display: flex; align-items: center; gap: 6px; padding: 6px 4px 2px; }
  .agents .proj .chev { color: var(--faint); }
  .agents .proj .br { color: var(--faint); font-size: 11px; }
  .agents .ws { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 3px; border: 1px solid transparent; }
  .agents .ws.sel { background: var(--bg3); border-color: var(--line); }
  .agents .ws-t { display: flex; flex-direction: column; min-width: 0; flex: 1; }
  .agents .ws b { font-weight: 500; }
  .agents .ws small { color: var(--faint); font-size: 10.5px; }
  .agents .badge { font-size: 11px; color: var(--faint); display: inline-flex; align-items: center; gap: 4px; }
  .agents .badge.num { padding: 0 6px; border-radius: 3px; background: var(--bg4); color: var(--fg); }
  .agents .badge[data-badge]::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
  .agents .badge[data-badge]::after { content: attr(data-label); }
  .agents .badge[data-badge=""] { display: none; }
  .agents .badge[data-badge="work"] { color: var(--accent-fg); }
  .agents .badge[data-badge="wait"] { color: var(--mark-active); font-weight: 700; }
  .agents .badge[data-badge="idle"] { color: var(--gi); }
  .agents .ag-center { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); }
  .agents .ag-center .term { flex: 1; }
  .agents .term .ban { color: var(--accent); }
  .agents .term .box { display: block; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 6px 0; padding: 2px 0; }
  .agents .term .ask { display: block; border: 1px solid var(--mark-active); border-radius: 4px; padding: 6px 10px; margin: 6px 0; }
  .agents .term .caret { display: inline-block; width: 7px; height: 14px; vertical-align: -2px; background: var(--fg); animation: blink 1s steps(1) infinite; }
  .agents .tdot[data-tdot] { background: var(--bg4); }
  .agents[data-state="2"] [data-tdot], .agents[data-state="4"] [data-tdot] { background: var(--accent-fg); }
  .agents[data-state="3"] [data-tdot] { background: var(--mark-active); }
  .agents[data-state="5"] [data-tdot] { background: var(--gi); }
  .agents .ag-diff { min-width: 0; overflow: hidden; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--bg); }
  .agents .ag-diff > * { min-width: 460px; }
  .agents .diff-bar, .agents .file-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
  .agents .diff-bar { justify-content: space-between; color: var(--dim); }
  .agents .diff-bar .add { color: var(--gi); } .agents .diff-bar .del { color: var(--gd); }
  .agents .file-head { background: var(--bg2); }
  .agents .file-head .cnt { margin-left: auto; color: var(--gi); }
  .app .st-m { color: var(--accent-fg); font-weight: 700; }
  .agents .hunk { padding: 3px 10px; background: color-mix(in srgb, var(--accent-fg) 10%, var(--bg)); color: var(--dim); border-bottom: 1px solid var(--line); }
  .agents .ag-files { background: var(--bg2); display: flex; flex-direction: column; min-width: 0; }
  .agents .files-top { display: flex; justify-content: space-between; align-items: center; height: 34px; padding: 0 8px; border-bottom: 1px solid var(--line); }
  .agents .files-list { flex: 1; padding: 6px; }
  .agents .empty { padding: 6px 6px; color: var(--faint); }
  .agents .fl { display: none; justify-content: space-between; align-items: center; padding: 3px 6px; border-radius: 3px; }
  .agents .fl > span:first-child { display: inline-flex; align-items: center; gap: 7px; }
  .agents .fl.all { background: var(--bg3); color: var(--accent-fg); }
  .agents .fl .st { display: inline-flex; align-items: center; gap: 8px; }
  .agents .tick { width: 11px; height: 11px; border: 1px solid var(--faint); border-radius: 2px; }
  .agents .branch { padding: 7px 10px; border-top: 1px solid var(--line); color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .agents:is([data-state="2"], [data-state="3"], [data-state="4"], [data-state="5"]) [data-files-empty] { display: none; }
  .agents:is([data-state="2"], [data-state="3"], [data-state="4"], [data-state="5"]) [data-file="all"],
  .agents:is([data-state="2"], [data-state="3"], [data-state="4"], [data-state="5"]) [data-file="ring.go"],
  .agents:is([data-state="4"], [data-state="5"]) [data-file="ring_test.go"] { display: flex; }
  .agents [data-chip] { display: none; }
  .agents:is([data-state="2"], [data-state="4"]) [data-chip="work"],
  .agents[data-state="3"] [data-chip="wait"] { display: inline-flex; }
  .agents .fl.new { animation: rise 320ms ease-out; }

  @keyframes blink { 50% { opacity: 0; } }
  @keyframes rise { from { opacity: 0; transform: translateY(4px); } }

  /* Status words in page copy: only the dot takes the theme's status colour,
     the word keeps the page's text colour for contrast. */
  .app.st-word { display: inline; background: none; border: 0; border-radius: 0; overflow: visible; font: inherit; color: inherit; }
  .st-word i { font-style: normal; font-weight: 600; white-space: nowrap; color: var(--p-ink); }
  .st-word i::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; vertical-align: 0.06em; }
  .st-word .s-work::before { background: var(--accent-fg); }
  .st-word .s-wait::before { background: var(--mark-active); }
  .st-word .s-idle::before { background: var(--gi); }

  /* minis */
  .app.mini { font-size: 12px; box-shadow: none; }
  .status-mini .browser-tab { display: inline-flex; align-items: center; gap: 8px; margin: 8px 8px 0; padding: 5px 12px; border-radius: 6px 6px 0 0; background: var(--bg2); border: 1px solid var(--line); border-bottom: 0; color: var(--fg); font-family: var(--sans); font-size: 12px; }
  .status-mini .fav { width: 10px; height: 10px; border: 2px solid var(--mark-active); border-radius: 2px; }
  .status-mini .term.short { padding: 10px 12px; font-size: 11.5px; }
  .status-mini .tabs, .graph .gr, .app.mini .code .row, .agents .ag-diff .code .row { -webkit-mask-image: linear-gradient(90deg, #000 86%, transparent); mask-image: linear-gradient(90deg, #000 86%, transparent); }
  .chats { padding-bottom: 8px; }
  .chats .chat-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--bg2); }
  .chats .grp { padding: 8px 10px 2px; color: var(--dim); }
  .chats .chat { display: flex; align-items: center; gap: 8px; padding: 4px 10px; }
  .chats .chat .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chats .chat .meta { color: var(--faint); font-size: 11px; white-space: nowrap; }
  .chats .chat-preview { margin: 2px 10px 6px 25px; padding: 8px 10px; border-left: 2px solid var(--accent); background: var(--bg2); border-radius: 0 3px 3px 0; display: grid; gap: 4px; }
  .chats .chat-preview b { color: var(--accent-fg); font-weight: 600; margin-right: 6px; }
  .app .btns { display: flex; gap: 6px; margin-top: 2px; }
  .app .btns .b { padding: 2px 9px; border: 1px solid var(--line); border-radius: 3px; background: var(--bg); }
  .app .btns .b.pri { background: var(--accent); border-color: var(--accent); color: var(--bg); }
  .res .rp-head { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; background: var(--bg2); border-bottom: 1px solid var(--line); }
  .res .rp-head span { color: var(--dim); font-size: 11px; }
  .res .rp { display: grid; grid-template-columns: minmax(0, 1fr) 56px 48px 72px; align-items: center; gap: 8px; padding: 4px 10px; }
  .res .rp > span:nth-child(n+3) { text-align: right; font-variant-numeric: tabular-nums; }
  .res .rp.h { color: var(--faint); font-size: 11px; border-bottom: 1px solid var(--line); }
  .res .rp.g { font-weight: 600; }
  .res .rp.self { border-top: 1px solid var(--line); }
  .res .rp .in { padding-left: 16px; display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
  .res .rp small { color: var(--faint); font-weight: 400; }
  .res svg { width: 56px; height: 14px; fill: none; stroke: var(--accent-fg); stroke-width: 1.2; }
  .picker .pk-in { margin: 8px; padding: 6px 8px; border: 1px solid var(--accent); border-radius: 3px; background: var(--bg); }
  .picker .caret { display: inline-block; width: 1px; height: 13px; margin-left: 1px; vertical-align: -2px; background: var(--fg); }
  .picker .pk { display: flex; justify-content: space-between; padding: 4px 10px; }
  .picker .pk.on { background: var(--bg3); }
  .picker mark { background: none; color: var(--mark-active); font-weight: 700; }
  .pr .pr-bar { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--bg2); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
  .pr .pr-bar .ttl { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .pr .pill { flex: none; }
  .pr .num { padding: 0 6px; border-radius: 3px; background: var(--bg4); }
  .pr .pill { margin-left: auto; color: var(--gi); font-weight: 600; }
  .pr .code { font-size: 11px; }
  .graph { padding: 8px 0; }
  .graph .gr { display: flex; align-items: center; gap: 8px; padding: 4px 12px; white-space: nowrap; overflow: hidden; position: relative; }
  .graph .gr::before { content: ""; position: absolute; left: 16px; top: 0; bottom: 0; width: 2px; background: var(--line); }
  .graph .gr:first-child::before { top: 50%; } .graph .gr:last-child::before { bottom: 50%; }
  .graph .node { position: relative; z-index: 1; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--accent-fg); background: var(--bg); flex: none; }
  .graph .node.head { background: var(--accent-fg); }
  .graph .ref { padding: 0 6px; border-radius: 3px; background: color-mix(in srgb, var(--accent-fg) 15%, transparent); color: var(--accent-fg); }
  .graph .ref.main { background: color-mix(in srgb, var(--gi) 18%, transparent); color: var(--gi); }

  /* editor */
  .editor { display: grid; grid-template-columns: 200px minmax(0, 1fr) 300px; height: 540px; box-shadow: var(--sh); }
  .editor .ed-tree { background: var(--bg2); border-right: 1px solid var(--line); padding: 6px 0; overflow: hidden; }
  .editor .tree-head { padding: 6px 12px 8px; color: var(--dim); }
  .editor .tr { display: flex; align-items: center; gap: 8px; padding: 2px 12px 2px 14px; color: var(--fg); }
  .editor .tr::before { content: ""; width: 6px; height: 6px; border-radius: 1px; background: var(--accent-fg); flex: none; }
  .editor .tr b { margin-left: auto; }
  .editor .tr.on { background: var(--bg3); }
  .editor .tr.mod b { color: var(--accent-fg); }
  .editor .ed-main { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); }
  .editor .ed-actions { margin-left: auto; display: flex; gap: 4px; }
  .editor .ed-actions .b { padding: 2px 9px; border-radius: 3px; color: var(--dim); }
  .editor .ed-actions .b.on { background: var(--bg); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line); }
  .editor .ed-code { flex: 1; padding: 8px 0; }
  .editor .ed-code .ln { width: 44px; }
  .editor .row.del { text-decoration: line-through; text-decoration-thickness: 1px; }
  .editor .qe { display: block; margin: 6px 12px 6px 44px; width: 540px; border: 1px solid var(--accent); border-radius: 5px; background: var(--bg); box-shadow: var(--shadow); white-space: normal; }
  .editor .qe-in { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 10px; }
  .editor .spark { color: var(--accent); }
  .editor .qe-btn { margin-left: auto; padding: 2px 9px; border-radius: 3px; background: var(--accent); color: var(--bg); font-weight: 600; white-space: nowrap; }
  .editor .qe-in .x { color: var(--faint); }
  .editor .qe-hint { display: block; padding: 0 10px 7px 30px; color: var(--faint); font-size: 11px; }
  .editor .qe-act { display: flex; gap: 8px; margin: 6px 0 6px 44px; }
  .editor .qe-act .b { padding: 3px 10px; border-radius: 3px; border: 1px solid var(--line); background: var(--bg2); }
  .editor .qe-act .b.acc { background: var(--gi); border-color: var(--gi); color: var(--bg); font-weight: 600; }
  .editor .qe-act kbd { border: 0; background: color-mix(in srgb, var(--bg) 25%, transparent); color: inherit; font-size: 10px; margin: 0 0 0 4px; padding: 0 4px; }
  .editor .ed-status { gap: 14px; }
  .editor .ed-status .sp { flex: 1; }
  .editor .lang { display: inline-flex; align-items: center; gap: 6px; }
  .editor .ed-right { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
  .editor .ed-right .term { flex: 1; }
  .editor .prompt { color: var(--fg); }
}

@media (max-width: 760px) {
  @layer views {
    .res .rp { grid-template-columns: minmax(0, 1fr) 44px 68px; }
    .res .rp > :nth-child(2) { display: none; }
    .res .rp > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .res .rp .in small { display: none; }
  }
}
