/* Arthion Agent Studio. One stylesheet, no external fonts (CSP: default-src 'self').
   Look: the Arthion brand (arthion.ai), quiet surfaces, one blue accent, 8px spacing grid. */
/* Arthion brand (arthion.ai): Arthion blue #0846AA, navy text, slate greys, blue-tinted shadows, Inter. */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f8fafc; --fg: #0f172a; --fg-2: #1e293b; --muted: #526077;
  --line: #e5e7eb; --line-2: #d1d5db; --accent: #0846aa; --accent-fg: #f8fafc; --accent-soft: #e8f0fd;
  --ok: #15803d; --ok-soft: #e8f6ec; --warn: #a35200; --warn-soft: #fff3e0; --bad: #b91c1c; --bad-soft: #fdecec;
  --shadow: 0 2px 4px hsl(217 91% 35% / .06), 0 1px 2px hsl(217 91% 35% / .06);
  --shadow-lg: 0 10px 20px -4px hsl(217 91% 35% / .12), 0 6px 12px -4px hsl(217 91% 35% / .1);
  --radius: 10px; --radius-sm: 8px;
  --font: Inter, "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, Roboto, Arial, sans-serif;
  --display: Inter, "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, Roboto, Arial, sans-serif;
  --mono: "Cascadia Code", "Cascadia Mono", Consolas, ui-monospace, monospace;
  font: 16px/1.6 var(--font); text-rendering: optimizeLegibility; color: var(--fg); color-scheme: light;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --surface: #0f172a; --surface-2: #141f38; --fg: #f8fafc; --fg-2: #cbd5e1; --muted: #94a3b8;
    --line: #1f2a3d; --line-2: #334155; --accent: #3c83f6; --accent-fg: #0b1120; --accent-soft: #17284a;
    --ok: #4ade80; --ok-soft: #10291a; --warn: #f0a85a; --warn-soft: #2e2213; --bad: #f87171; --bad-soft: #301818;
    --shadow: 0 1px 2px rgb(0 0 0 / .45); --shadow-lg: 0 12px 40px rgb(0 0 0 / .6); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { background: var(--bg); }
body { margin: 0; color: var(--fg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, .h, .section-title, .bt-name, .dlg-head h2, .stat-value { font-family: var(--display); }
h1 { font-size: 30px; font-weight: 700; letter-spacing: -.01em; margin: 4px 0 20px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
h2 { font-size: 18px; font-weight: 600; margin: 24px 0 10px; }
h3 { font-size: 15.5px; font-weight: 600; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.grow { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- top bar ---- */
.top { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center;
       padding: 10px 24px; background: color-mix(in srgb, var(--surface) 92%, transparent);
       backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand-sub { color: var(--muted); font-weight: 500; }
.logo { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 700;
        background: var(--brand-grad, linear-gradient(135deg, #063a8f, #0846aa 55%, #0b58cc)); }
.mainnav { flex: 1; display: flex; gap: 2px; flex-wrap: wrap; }
.mainnav a { padding: 7px 13px; white-space: nowrap; border-radius: 8px; color: var(--fg-2); font-weight: 500; }
.mainnav a:hover { background: var(--surface-2); text-decoration: none; }
.mainnav a.on { background: var(--accent-soft); color: var(--accent); }
.who { display: flex; gap: 10px; align-items: center; margin: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px;
          background: var(--accent-soft); color: var(--accent); }
.who-name { display: grid; line-height: 1.2; font-size: 14px; font-weight: 500; }
.who-role { color: var(--muted); font-size: 12.5px; font-weight: 400; text-transform: capitalize; }
main { max-width: 1320px; margin: 0 auto; padding: 24px 24px 64px; }

/* ---- controls ---- */
button, .button { font: inherit; font-weight: 500; border: 1px solid var(--line-2); background: var(--surface); color: var(--fg);
                  border-radius: var(--radius-sm); padding: 8px 16px; cursor: pointer; display: inline-flex; align-items: center; white-space: nowrap;
                  gap: 6px; line-height: 1.3; transition: background .12s, border-color .12s; }
button:hover, .button:hover { background: var(--surface-2); text-decoration: none; }
button:disabled { opacity: .55; cursor: default; }
.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.primary:hover, button.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.ghost, button.ghost { background: transparent; }
textarea, input, select { font: inherit; width: 100%; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
                          padding: 9px 12px; background: var(--surface); color: var(--fg); transition: border-color .12s, box-shadow .12s; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; line-height: 1.55; }
textarea.code, .dlg textarea { font: 14px/1.6 var(--mono); }
input.check, input[type=checkbox] { width: auto; accent-color: var(--accent); margin: 0 6px 0 0; }
label { font-weight: 500; }
.inline { display: inline; margin: 0; }

/* ---- cards, lists, tables ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px;
        margin-bottom: 14px; box-shadow: var(--shadow); }
.narrow { max-width: 420px; margin: 48px auto; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.notice { border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); background: var(--accent-soft);
          padding: 10px 14px; border-radius: var(--radius-sm); margin: 0 0 16px; }
.alert { border: 1px solid color-mix(in srgb, var(--bad) 35%, var(--line)); background: var(--bad-soft);
         padding: 10px 14px; border-radius: var(--radius-sm); margin: 0 0 16px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; min-width: 640px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
.num { font-variant-numeric: tabular-nums; }
.state, .pill, .badge { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 550; padding: 3px 10px;
                        border-radius: 999px; border: 1px solid var(--line-2); color: var(--fg-2); background: var(--surface); white-space: nowrap; }
.state.succeeded, .pill.ok, .badge.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.state.failed, .state.timed_out { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.state.running, .state.queued, .pill.draft { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.state.skipped { color: var(--muted); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
pre { overflow-x: auto; background: var(--surface-2); border: 1px solid var(--line); padding: 12px; border-radius: var(--radius-sm);
      font: 13.5px/1.6 var(--mono); }
pre.ticket { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 520px; overflow-y: auto; }
.runnow { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 8px; }
details summary { cursor: pointer; padding: 4px 0; font-weight: 500; }
.row { display: flex; justify-content: space-between; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm);
       padding: 9px 13px; font-size: 14.5px; flex-wrap: wrap; background: var(--surface); }
.row .k { color: var(--muted); font-size: 13.5px; }
.row.pick { cursor: pointer; align-items: center; }
.form-grid { display: grid; gap: 8px; max-width: 760px; }
.form-grid label { margin-top: 6px; }
.two, .form-grid .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .two, .form-grid .two { grid-template-columns: 1fr; } .facts { grid-template-columns: 1fr; } }

/* ---- agents list ---- */
.agent-card { display: flex; gap: 14px; color: var(--fg); margin: 0; transition: border-color .12s, box-shadow .12s; }
.agent-card:hover { text-decoration: none; border-color: var(--line-2); box-shadow: 0 4px 16px rgb(16 16 24 / .08); }
.icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 650; flex: none;
        color: #fff; background: var(--brand-grad, linear-gradient(135deg, #063a8f, #0846aa 60%, #0b58cc)); }
.icon.big { width: 64px; height: 64px; border-radius: 16px; font-size: 22px; }

/* ---- builder header ---- */
.builder-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "left right" "tabs tabs"; gap: 12px 16px; align-items: center; margin-bottom: 4px; }
.builder-top > .bt-left { grid-area: left; } .builder-top > .tabs { grid-area: tabs; justify-self: start; max-width: 100%; } .builder-top > .bt-right { grid-area: right; }
.bt-left { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; min-width: 0; }
.bt-right { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 8px; }
.bt-name { font-weight: 700; font-size: 22px; line-height: 1.25; overflow-wrap: anywhere; }
.back { font-size: 18px; color: var(--fg-2); padding: 2px 8px; border-radius: 8px; }
.back:hover { background: var(--surface); text-decoration: none; }
.tabs { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.tab { padding: 7px 15px; white-space: nowrap; border-radius: 8px; color: var(--fg-2); font-weight: 500; }
.tab:hover { background: var(--surface-2); text-decoration: none; }
.tab.on { background: var(--accent-soft); color: var(--accent); }
.tab.off { color: var(--muted); opacity: .5; cursor: default; }
.tab.off:hover { background: none; }
.sub { margin: 8px 0 18px; }
@media (max-width: 900px) { .builder-top { grid-template-columns: 1fr; grid-template-areas: "left" "right" "tabs"; } .bt-right { justify-content: flex-start; } .tabs { overflow-x: auto; width: 100%; } }

/* ---- builder body ---- */
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.col { display: grid; gap: 14px; min-width: 0; }
.col .card { margin: 0; display: grid; gap: 10px; }
.h { font-size: 18px; font-weight: 650; margin: 0; display: flex; gap: 8px; align-items: baseline; }
.agent-head { display: flex; gap: 16px; align-items: flex-start; }
.title-input { font-size: 24px; font-weight: 650; letter-spacing: -.01em; border-color: transparent; background: transparent; padding: 2px 6px; }
textarea.plain { resize: none; font: inherit; color: var(--fg-2); border-color: transparent; background: transparent; padding: 4px 6px; }
.title-input:hover, textarea.plain:hover { border-color: var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px;
        padding: 4px 11px; font-size: 14px; background: var(--surface); color: var(--fg-2); }
.chip.tool { border-radius: var(--radius-sm); background: var(--surface-2); padding: 5px 10px; }
.chip .link { border: 0; background: none; padding: 0; color: var(--fg); font-size: 14px; font-weight: 500; }
.chip .link:hover { color: var(--accent); background: none; text-decoration: underline; }
.try form { display: grid; gap: 8px; }

/* right-hand panel (Copilot style) */
.col .card.panel { gap: 0; padding: 4px 20px; position: sticky; top: 72px; }
.p-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.p-row > input[type=search] { flex: 1; width: auto; }
.panel > .p-row { padding: 14px 0; }
.p-sec { border-top: 1px solid var(--line); padding: 14px 0; display: grid; gap: 10px; }
.p-sec.p-row { display: flex; }
.p-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.p-title { font-size: 16px; font-weight: 650; margin: 0; display: flex; gap: 8px; align-items: center; }
.p-desc { margin: 2px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
select.compact { width: auto; max-width: 230px; padding: 6px 10px; }
.other-model { padding-bottom: 12px; display: grid; gap: 6px; }
.other-model summary { font-size: 14px; font-weight: 400; }
.plus { border: 0; background: transparent; font-size: 20px; font-weight: 400; line-height: 1; width: 30px; height: 30px;
        padding: 0; justify-content: center; border-radius: 8px; color: var(--muted); }
.plus:hover { color: var(--accent); background: var(--accent-soft); }
.x { border: 0; background: none; padding: 0 2px; color: var(--muted); font-size: 15px; line-height: 1; border-radius: 4px; }
.x:hover { color: var(--bad); background: none; }
.x.big { font-size: 22px; width: 32px; height: 32px; justify-content: center; }
.x.big:hover { background: var(--surface-2); }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 34px; z-index: 20; min-width: 230px; display: grid; padding: 6px;
        background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.menu[hidden] { display: none; }
.menu-item { border: 0; background: none; text-align: left; padding: 9px 12px; border-radius: 8px; cursor: pointer;
             font-size: 14px; font-weight: 400; color: var(--fg); }
.menu-item:hover { background: var(--surface-2); }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 999px; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: var(--surface); border-radius: 50%; box-shadow: var(--shadow); }
.switch input:disabled + span { opacity: .6; }
.switch span::before { transition: transform .15s; } .switch span { transition: background .15s; cursor: pointer; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 960px) { .cols { grid-template-columns: 1fr; } .col .card.panel { position: static; } }

/* dialogs (pickers) */
dialog.dlg { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 1px solid var(--line);
             border-radius: 18px; padding: 24px 28px; background: var(--surface); color: var(--fg); box-shadow: var(--shadow-lg); }
dialog.dlg[open] { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; overflow-x: hidden; }
dialog.dlg.wide { width: min(800px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(16 16 24 / .32); backdrop-filter: blur(2px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h2 { margin: 0; font-size: 20px; font-weight: 650; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 10px; }
.tiles[hidden] { display: none; }
.tile { display: grid; gap: 3px; text-align: left; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
        background: var(--surface); color: var(--fg); font: inherit; font-weight: 400; align-content: start;
        grid-template-columns: minmax(0, 1fr); min-width: 0; white-space: normal; overflow-wrap: anywhere; } /* buttons: wrap */
.tile strong { font-weight: 600; }
button.tile { cursor: pointer; } button.tile:hover { border-color: var(--accent); background: var(--surface); box-shadow: var(--shadow); }
.tile.on { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: var(--ok-soft); }
.tile.off { opacity: .5; background: var(--surface-2); }
.tile[hidden] { display: none; }
details.tile summary { display: grid; gap: 3px; list-style: none; cursor: pointer; font-weight: 400; padding: 0; }
details.tile summary::-webkit-details-marker { display: none; }
details.tile[open] { grid-column: 1 / -1; gap: 8px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { border-radius: 999px; padding: 5px 14px; }
.seg button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.list { display: grid; gap: 8px; max-height: 50vh; overflow-y: auto; }
.pick { display: grid; gap: 2px; text-align: left; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px;
        background: var(--surface); color: var(--fg); font: inherit; font-weight: 400; }
button.pick { cursor: pointer; } button.pick:hover { border-color: var(--accent); background: var(--surface); }
.pick.on { background: var(--ok-soft); }
.pick[hidden] { display: none; }
.drop { position: relative; display: grid; justify-items: center; gap: 6px; padding: 30px 16px; border: 1.5px dashed var(--line-2);
        border-radius: var(--radius); cursor: pointer; text-align: center; font-weight: 400; background: var(--surface-2); }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-icon { font-size: 30px; color: var(--accent); line-height: 1; }

/* Evaluate */
.eval h3 { font-size: 14px; }

/* Preview chat */
.chat { display: grid; gap: 12px; grid-template-rows: auto auto minmax(340px, 1fr) auto; min-height: 600px; margin: 0; }
.messages { overflow-y: auto; max-height: 64vh; display: flex; flex-direction: column; gap: 12px; padding: 4px; }
.msg { max-width: 82%; padding: 11px 15px; border-radius: 14px; border: 1px solid var(--line); line-height: 1.55; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-fg); border-color: var(--accent); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg.pending { color: var(--muted); font-style: italic; }
.msg.pending::before { content: ""; display: inline-block; width: 22px; height: 6px; margin-right: 8px; vertical-align: middle;
  background: radial-gradient(circle 3px, var(--accent) 95%, transparent) 0 50%/8px 6px repeat-x; animation: pend 1s steps(3) infinite; }
@keyframes pend { from { width: 6px; } to { width: 24px; } }
.msg.error { align-self: flex-start; border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.msg .meta { margin-top: 6px; }
.starters { display: flex; flex-wrap: wrap; gap: 8px; }
.starters .chip { cursor: pointer; font-weight: 400; padding: 6px 12px; white-space: normal; text-align: left; max-width: 100%; }
.neurion-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: 1px;
               background: var(--spark, var(--brand-grad)); box-shadow: 0 0 0 3px color-mix(in srgb, #1095c1 25%, transparent); }
.helper-fab .neurion-dot { background: #fff; box-shadow: 0 0 0 3px rgb(255 255 255 / .28); }
.starters .chip:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.chat-form { display: grid; gap: 8px; }
.chat-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Architecture diagram: each kind has one hue (--k), used for the left bar, border and a light tint */
.diagram-wrap { overflow-x: auto; }
svg.diagram { width: 100%; min-width: 900px; height: auto; font: 13px var(--font); }
.d-col { fill: var(--muted); font-size: 11.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
.d-node { --k: #71717a; }
.d-node.who { --k: #1095c1; } .d-node.agent { --k: #0846aa; } .d-node.code { --k: #0f9488; }
.d-node.code-write { --k: #dc2626; } .d-node.model { --k: #d97706; } .d-node.guard { --k: #059669; }
.d-node.ext, .d-node.ext-write { --k: #64748b; }
.d-node rect { fill: color-mix(in srgb, var(--k) 9%, var(--surface)); stroke: color-mix(in srgb, var(--k) 70%, transparent); stroke-width: 1.4; }
.d-node.agent rect { stroke-width: 2.4; fill: color-mix(in srgb, var(--k) 14%, var(--surface)); }
.d-node.guard rect { stroke-dasharray: 6 3; }
.d-node.ext-write rect { stroke: #dc2626; }
.d-node rect.d-bar { fill: var(--k); stroke: none; }
.d-title { fill: var(--fg); font-weight: 600; font-size: 13.5px; } .d-sub { fill: var(--fg-2); font-size: 11.5px; opacity: .85; }
.d-edge { fill: none; stroke: #94a3b8; stroke-width: 1.6; }
.d-edge.step { stroke: #d97706; stroke-width: 2; } .d-edge.write { stroke: #dc2626; stroke-width: 2.2; stroke-dasharray: 7 4; }
.d-arrow { fill: #94a3b8; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--fg-2); font-size: 14px; margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.sw { --k: #64748b; display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 2px solid var(--k);
      background: color-mix(in srgb, var(--k) 18%, var(--surface)); }
.sw.who { --k: #1095c1; } .sw.agent { --k: #0846aa; } .sw.code { --k: #0f9488; } .sw.model { --k: #d97706; }
.sw.guard { --k: #059669; border-style: dashed; } .sw.ext { --k: #64748b; }
.ln { display: inline-block; width: 26px; height: 0; border-top: 2px solid #94a3b8; }
.ln.step { border-color: #d97706; } .ln.write { border-top: 2px dashed #dc2626; }
h1 .button, h1 button, h2 .button, h2 a.small { font-size: 14px; font-weight: 500; letter-spacing: 0; }
@media (max-width: 900px) {
  .top { padding: 10px 16px; }
  .mainnav { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; }
  .brand-sub, .who-name { display: none; }
  .who { margin-left: auto; }
  main { padding: 18px 16px 48px; }
}
fieldset.plain-set { border: 0; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
fieldset.plain-set legend { font-weight: 500; padding: 0; margin-bottom: 6px; }
fieldset.plain-set .chip { cursor: pointer; }
input.code, code { font-family: var(--mono); font-size: 13px; }
.newkey { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.danger, button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
button.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.tile label { display: flex; align-items: center; gap: 6px; font-weight: 500; }
/* Agents dashboard */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; }
.page-head p { margin: 0; max-width: 680px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { display: grid; gap: 2px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 14px; font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 13.5px; } .stat-sub.bad { color: var(--bad); font-weight: 500; }
.list-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
input.search { width: 280px; max-width: 100%; }
.seg .count { color: var(--muted); font-weight: 500; margin-left: 2px; }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 16px; }
.agent-grid .agent-card { position: relative; display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 20px; }
.agent-card[hidden] { display: none; }
.ac-top { display: flex; align-items: flex-start; gap: 12px; }
.ac-title { flex: 1; min-width: 0; display: grid; }
.ac-title h2 { margin: 0; font-size: 17px; font-weight: 650; line-height: 1.3; }
.ac-title a { color: var(--fg); }
a.stretch::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.ac-desc { margin: 0; color: var(--fg-2); font-size: 15px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
           overflow: hidden; min-height: 4.6em; }
.ac-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 13px; font-weight: 500; padding: 3px 9px; border-radius: 6px; background: var(--surface-2); color: var(--fg-2); border: 1px solid var(--line); }
.tag.door { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.ac-foot { display: flex; align-items: center; gap: 14px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: auto; font-size: 14px; flex-wrap: wrap; }
.ac-foot a { position: relative; z-index: 1; }
.ac-run { color: var(--fg-2); display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.succeeded { background: var(--ok); } .dot.failed, .dot.timed_out { background: var(--bad); }
.dot.running, .dot.queued { background: var(--warn); }
.new-card { align-items: center; justify-content: center; text-align: center; border-style: dashed; box-shadow: none;
            background: transparent; color: var(--fg); min-height: 220px; }
.new-card:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.plus-big { font-size: 32px; color: var(--accent); line-height: 1; }
.agent-grid .agent-card:hover { border-color: var(--line-2); box-shadow: 0 6px 20px rgb(16 16 24 / .08); }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.section-title { font-size: 20px; font-weight: 650; margin: 32px 0 12px; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 25%, var(--line)); }
.cost-list { list-style: none; margin: 6px 0 4px; padding: 0; }
.cost-list li { display: flex; justify-content: space-between; gap: 12px; }
details.stat-sub summary { cursor: pointer; }
.use-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 12px; margin-bottom: 20px; }
.use-card { display: flex; gap: 12px; align-items: flex-start; text-decoration: none; color: inherit; }
.use-card:hover { border-color: var(--accent, #0846aa); }
.use-card .uc-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.use-card .uc-text .muted { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ac-pills { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
@media (max-width: 640px) {
  :root { font-size: 16px; }
  main { padding: 14px 12px 88px; }
  h1 { font-size: 25px; margin-bottom: 14px; } .section-title { font-size: 18px; margin-top: 24px; }
  .card, .agent-grid .agent-card { padding: 16px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; } .stat { padding: 12px 14px; } .stat-value { font-size: 24px; }
  .page-head > .p-row, .page-head .p-row { width: 100%; } .page-head .button { flex: 1; justify-content: center; }
  input.search, select.compact { width: 100%; max-width: none; } .list-tools > * { flex: 1 1 100%; }
  textarea, input, select { font-size: 16px; } /* no zoom-in on phones */
  .msg { max-width: 94%; } .chat { min-height: 70vh; } .messages { max-height: 58vh; }
  dialog.dlg { padding: 18px; border-radius: 14px; } .bt-name { font-size: 20px; }
  .p-row { flex-wrap: wrap; } .facts { grid-template-columns: 1fr; }
  .agent-head { flex-direction: column; gap: 10px; } .agent-head > :not(.icon) { width: 100%; min-width: 0; }
  .icon.big { width: 44px; height: 44px; font-size: 16px; border-radius: 12px; } .title-input { font-size: 20px; }
}

/* Ticket picker (ticketpick.js): project dropdown, ticket-type tick boxes, label */
.ticketpick { display: grid; gap: 6px; margin: 8px 0; }
.ticketpick .tp-ui { display: grid; gap: 6px; }
.ticketpick .tp-ui label { display: grid; gap: 4px; }
.ticketpick .tp-types { display: flex; flex-wrap: wrap; gap: 6px 16px; border: 1px solid var(--line, #e2e8f0); border-radius: 8px; padding: 8px 12px; margin: 0; }
.ticketpick .tp-types legend { padding: 0 4px; }
.ticketpick .tp-types label.chk { display: inline-flex; align-items: center; gap: 6px; }
.ticketpick .tp-types p { flex-basis: 100%; margin: 0; }
.ticketpick details.tp-adv summary { cursor: pointer; }
.ticketpick details.tp-adv[open] .tp-query { margin-top: 6px; width: 100%; }
