/* NexaClaw Console v4 - an app shell with a sidebar, selection-first editing.
   Ink on a mineral ground, one brass accent, borders not shadows. */
:root {
  --ground: #f1f2f0; --paper: #ffffff; --paper-2: #f6f7f5; --ink: #171c22; --ink-2: #57616b; --ink-3: #8f989f; --rule: #dfe2de;
  --brass: #9a6f1e; --brass-soft: #f4ecd9; --live: #1e8e5a; --live-soft: #e3f3ea; --warn: #b5432a; --warn-soft: #f8e5e0;
  --display: "Fraunces", Georgia, serif; --sans: "Instrument Sans", "Helvetica Neue", Arial, sans-serif; --r: 10px; --side: 232px;
}
@media (prefers-color-scheme: dark) {
  :root { --ground: #121517; --paper: #1b1f23; --paper-2: #22272c; --ink: #eef0ee; --ink-2: #aab2b8; --ink-3: #6f787f; --rule: #2e343a; --brass: #d2a751; --brass-soft: #3a3020; --live-soft: #1d3328; --warn-soft: #3d2420; }
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--sans); line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
h1, h2, h3, h4 { margin: 0; }

/* shell */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--paper); border-right: 1px solid var(--rule); display: flex; flex-direction: column; padding: 18px 14px; gap: 6px; }
.side .brand { font-family: var(--display); font-size: 1.3rem; font-weight: 500; padding: 4px 10px 2px; }
.side .who { color: var(--ink-2); font-size: 0.86rem; padding: 0 10px 14px; }
.side .nav { display: flex; flex-direction: column; gap: 2px; }
.side .nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-size: 0.95rem; }
.side .nav a:hover { background: var(--paper-2); color: var(--ink); }
.side .nav a[aria-current="page"] { background: var(--brass-soft); color: var(--ink); font-weight: 500; }
.side .nav a i { font-style: normal; margin-left: auto; color: var(--ink-3); font-size: 0.8rem; }
.side .nav svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side .conns { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 12px 10px 4px; border-top: 1px solid var(--rule); font-size: 0.84rem; color: var(--ink-2); }
.side .conns span::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); margin-right: 8px; vertical-align: 1px; }
.side .conns span.on::before { background: var(--live); }
.side .signout { color: var(--ink-3); font-size: 0.84rem; text-decoration: none; padding: 6px 10px; }
.side .signout:hover { color: var(--ink); }
main { padding: 26px 32px 80px; min-width: 0; max-width: 1180px; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; flex-direction: row; align-items: center; padding: 6px 8px; border-right: 0; border-top: 1px solid var(--rule); z-index: 10; gap: 0; }
  .side .brand, .side .who, .side .conns, .side .signout, .side .nav a i { display: none; }
  .side .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .side .nav a { flex-direction: column; gap: 3px; font-size: 0.72rem; padding: 6px 8px; }
  main { padding: 16px 14px 90px; }
}

/* page header */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.ph h1 { font-family: var(--display); font-size: 1.9rem; font-weight: 500; letter-spacing: -0.01em; line-height: 1.1; }
.ph p { margin: 6px 0 0; color: var(--ink-2); max-width: 62ch; }
.ph .actions { margin: 0; }

/* stat strip */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); padding: 14px 16px; min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; text-align: left; cursor: pointer; }
.stat:hover { border-color: var(--ink-3); }
.stat .k { color: var(--ink-2); font-size: 0.82rem; }
.stat .v { font-family: var(--display); font-size: 1.7rem; font-weight: 500; line-height: 1; letter-spacing: -0.01em; }
.stat .v small { font-family: var(--sans); font-size: 0.84rem; color: var(--ink-3); font-weight: 400; margin-left: 6px; letter-spacing: 0; }
.stat .bar { height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: var(--brass); }
.stat .bar i.warn { background: var(--warn); }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.card { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); padding: 16px; }
.card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 10px; }
.spec { display: flex; flex-direction: column; gap: 10px; text-align: left; cursor: pointer; min-height: 150px; }
.spec:hover { border-color: var(--ink-3); }
.spec .name { font-family: var(--display); font-size: 1.3rem; font-weight: 500; line-height: 1.15; }
.spec .intro { margin: 0; color: var(--ink-2); font-size: 0.87rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.spec .foot { margin-top: auto; display: flex; gap: 12px; color: var(--ink-3); font-size: 0.8rem; flex-wrap: wrap; }
.spec .foot b { color: var(--ink-2); font-weight: 500; }
.spec.paused { opacity: .6; }
.add { border-style: dashed; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px; color: var(--ink-2); min-height: 150px; cursor: pointer; background: transparent; text-align: left; }
.add:hover { border-color: var(--brass); color: var(--ink); }
.add .plus { font-family: var(--display); font-size: 1.6rem; line-height: 1; color: var(--brass); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 0.76rem; padding: 3px 9px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--rule); color: var(--ink-2); }
.chip.more { border-style: dashed; }
.tag { display: inline-block; font-size: 0.68rem; font-weight: 500; padding: 2px 7px; border-radius: 999px; margin-left: 8px; vertical-align: middle; background: var(--brass-soft); color: var(--brass); }
.tag.muted { background: var(--paper-2); color: var(--ink-3); border: 1px solid var(--rule); }
.tag.read { background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--rule); }
.tag.draft { background: var(--brass-soft); color: var(--brass); }
.tag.act { background: var(--live-soft); color: var(--live); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.libstrip { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--rule); }
.libhead { display: flex; gap: 12px; align-items: baseline; margin-bottom: 10px; flex-wrap: wrap; }
.lib { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px dashed var(--rule); border-radius: var(--r); }
.libname { font-family: var(--display); font-size: 1.1rem; font-weight: 500; }
.hint { color: var(--ink-3); font-size: 0.83rem; }
.empty { color: var(--ink-3); font-size: 0.9rem; margin: 0; padding: 12px; border: 1px dashed var(--rule); border-radius: 8px; }
.empty.small { padding: 8px 10px; font-size: 0.85rem; }

/* buttons, fields */
.btn { padding: 9px 14px; border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer; font-weight: 500; }
.btn:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.quiet { background: var(--paper); color: var(--ink); border-color: var(--rule); font-weight: 400; }
.btn.quiet:hover { border-color: var(--ink-3); background: var(--paper); }
.btn.danger { background: transparent; color: var(--warn); border-color: transparent; }
.btn.danger:hover { background: var(--warn-soft); }
.btn.sm { padding: 6px 10px; font-size: 0.86rem; }
.linkbtn { background: none; border: 0; color: var(--brass); cursor: pointer; font-size: 0.84rem; padding: 0 4px; }
.linkbtn:hover { text-decoration: underline; }
.x { background: none; border: 0; color: var(--ink-3); cursor: pointer; padding: 0 4px; font-size: 1.05rem; line-height: 1; border-radius: 4px; }
.x:hover { color: var(--warn); background: var(--warn-soft); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.field { display: flex; gap: 8px; }
.field input { flex: 1; min-width: 0; }
input[type=text], input:not([type]), textarea { padding: 9px 12px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); width: 100%; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus { outline: 2px solid var(--brass); outline-offset: 1px; border-color: transparent; }
label.lbl { display: block; font-size: 0.85rem; color: var(--ink-2); margin: 10px 0 4px; }
.seg { display: inline-flex; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--ink-2); font-size: 0.9rem; }
.seg button[aria-selected="true"], .seg button[aria-checked="true"] { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule); font-weight: 500; }
.seg.small button { padding: 5px 10px; font-size: 0.84rem; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.86rem; color: var(--ink-2); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch > span:not(.sr) { width: 34px; height: 20px; border-radius: 10px; background: var(--ink-3); position: relative; transition: background .15s; flex: none; }
.switch > span:not(.sr)::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--live); }
.switch.pause input:checked + span { background: var(--warn); }
.switch.pause input:not(:checked) + span { background: var(--live); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--brass); outline-offset: 2px; }

/* pickers: the selection-first editing */
.picks { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { border: 1px solid var(--rule); background: var(--paper); color: var(--ink-2); border-radius: 999px; padding: 5px 11px; font-size: 0.84rem; cursor: pointer; }
.pick:hover { border-color: var(--ink-3); color: var(--ink); }
.pick[aria-pressed="true"] { background: var(--brass-soft); border-color: var(--brass); color: var(--ink); }
.pick.custom[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pick .rm { margin-left: 6px; opacity: .6; }
.pickgroup { margin-top: 10px; }
.pickgroup .g { font-size: 0.78rem; color: var(--ink-3); margin: 0 0 5px; }
.addown { display: flex; gap: 8px; margin-top: 8px; max-width: 460px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
@media (max-width: 720px) { .checks { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--rule); border-radius: 8px; cursor: pointer; font-size: 0.88rem; background: var(--paper); }
.check:hover { border-color: var(--ink-3); }
.check input { margin-top: 3px; accent-color: var(--brass); flex: none; }
.check.on { border-color: var(--brass); background: var(--brass-soft); }
.check.off { opacity: .55; cursor: not-allowed; }
.check .hint { display: block; margin-top: 2px; }

/* specialist page */
.sp { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .sp { grid-template-columns: 1fr; } }
.sp .left { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 1000px) { .sp .left { position: static; } }
.back { color: var(--ink-2); text-decoration: none; font-size: 0.86rem; display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.back:hover { color: var(--ink); }
.sp .idcard .name { font-family: var(--display); font-size: 1.7rem; font-weight: 500; line-height: 1.1; }
.sp .idcard p { margin: 8px 0 0; color: var(--ink-2); font-size: 0.9rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 0.88rem; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.rights { display: flex; flex-direction: column; gap: 10px; }
.rights .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin-bottom: 14px; overflow-x: auto; }
.tab { padding: 10px 13px; border: 0; background: none; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brass); font-weight: 500; }
.tab:hover { color: var(--ink); }
.tab i { font-style: normal; color: var(--ink-3); margin-left: 5px; font-size: 0.8rem; }
.sec { padding: 14px 0; border-top: 1px solid var(--rule); }
.sec:first-child { border-top: 0; padding-top: 0; }
.sech { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.sech h3 { font-size: 0.92rem; font-weight: 600; margin: 0; }
.sech .hint { margin-left: auto; }
.bul { margin: 0; padding-left: 18px; font-size: 0.9rem; color: var(--ink-2); }
.bul li { padding: 2px 0; }
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.list li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-top: 1px solid var(--rule); font-size: 0.9rem; }
.list li:first-child { border-top: 0; }
.list .when { color: var(--ink-3); font-size: 0.8rem; flex: none; width: 64px; padding-top: 2px; }
.list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list .size { color: var(--ink-3); font-size: 0.8rem; white-space: nowrap; }
.extract { color: var(--ink-3); font-size: 0.8rem; margin-top: 4px; line-height: 1.4; }
.pb { border: 1px solid var(--rule); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; }
.pbh { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.steps { margin: 8px 0 0; padding-left: 20px; font-size: 0.88rem; color: var(--ink-2); }
.pbform { border: 1px solid var(--brass); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.pbform label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--ink-2); }
textarea.persona { min-height: 380px; background: var(--paper-2); font-size: 0.9rem; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--rule); font-size: 0.88rem; }
.feed li:first-child { border-top: 0; }
.feed .when { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.feed .who { color: var(--brass); font-weight: 500; }
.feed .ask { color: var(--ink-2); }
.upload { display: inline-block; }

/* wizard */
.wiz { max-width: 760px; }
.wiz .progress { height: 3px; background: var(--rule); border-radius: 2px; overflow: hidden; margin: 6px 0 20px; }
.wiz .progress i { display: block; height: 100%; background: var(--brass); transition: width .2s; }
.wiz h2 { font-family: var(--display); font-size: 1.5rem; font-weight: 500; margin-bottom: 4px; }
.wiz .lede { color: var(--ink-2); margin: 0 0 16px; }
.starters { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.starter { text-align: left; padding: 14px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--paper); cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.starter:hover { border-color: var(--ink-3); }
.starter[aria-pressed="true"] { border-color: var(--brass); background: var(--brass-soft); }
.starter .n { font-family: var(--display); font-size: 1.15rem; font-weight: 500; }
.starter .hint { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wiz .foot { display: flex; gap: 10px; align-items: center; margin-top: 22px; }
.wiz .foot .hint { margin-left: auto; }

/* tools page */
.gh { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); margin: 18px 0 8px; }
.grid.tools { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.tool { display: flex; flex-direction: column; gap: 8px; }
.tool.off { opacity: .6; }
.tool .th { display: flex; align-items: center; gap: 8px; }
.tool .th b { flex: 1; }
.tool .hint { margin: 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--rule); font-size: 0.8rem; color: var(--ink-2); align-self: flex-start; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.pill.on::before { background: var(--live); }

/* credits, activity */
.credits { display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px; }
@media (max-width: 800px) { .credits { grid-template-columns: 1fr; } }
.credits .wide { grid-column: 1 / -1; }
.gauge .spent { font-family: var(--display); font-size: 2.6rem; font-weight: 500; line-height: 1; letter-spacing: -0.02em; }
.gauge .of { color: var(--ink-2); font-size: 0.9rem; margin-top: 4px; }
.gauge .track { position: relative; height: 6px; background: var(--rule); border-radius: 3px; margin-top: 14px; }
.gauge .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--brass); border-radius: 3px; }
.gauge .fill.warn { background: var(--warn); }
.gauge .tick { position: absolute; top: -4px; width: 1px; height: 14px; background: var(--ink-3); }
.gauge .foot { display: flex; justify-content: space-between; margin-top: 8px; color: var(--ink-3); font-size: 0.8rem; }
.days { display: flex; align-items: flex-end; gap: 3px; height: 88px; margin: 6px 0 4px; }
.days .d { flex: 1; background: var(--ink-3); min-height: 2px; border-radius: 2px 2px 0 0; position: relative; opacity: .7; }
.days .d.today { background: var(--brass); opacity: 1; }
.days .d:hover, .days .d:focus { opacity: 1; }
.days .d:hover::after, .days .d:focus::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 4px 8px; border-radius: 4px; font-size: 0.76rem; white-space: nowrap; z-index: 2; }
.axis { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 0.76rem; }
.models { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.models td { padding: 7px 0; border-top: 1px solid var(--rule); vertical-align: top; }
.models tr:first-child td { border-top: 0; }
.models td:nth-child(2), .models td:nth-child(3) { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
.models .share { height: 3px; background: var(--brass); border-radius: 2px; margin-top: 5px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 800px) { .two { grid-template-columns: 1fr; } }
.groups { display: flex; flex-direction: column; gap: 14px; }
.groups h4 { margin: 0 0 6px; font-size: 0.85rem; font-weight: 600; }
.groups h4 span { color: var(--ink-2); font-weight: 400; margin-left: 6px; }
.groups ul { margin: 0; padding: 0; list-style: none; }
.groups li { font-size: 0.86rem; color: var(--ink-2); padding: 5px 0; border-top: 1px dashed var(--rule); }
.groups li:first-child { border-top: 0; }

/* login */
.login { min-height: 80vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.login .card { max-width: 420px; padding: 32px 28px; }
.login h1 { font-family: var(--display); font-weight: 500; font-size: 2.2rem; margin: 0 0 8px; }
.login p { color: var(--ink-2); margin: 0 auto 22px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 8px; font-size: 0.9rem; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 30; }
.toast.show { opacity: 1; }
@media (max-width: 860px) { .toast { bottom: 74px; } }
@media (prefers-reduced-motion: reduce) { .toast, .switch > span, .switch > span::after, .wiz .progress i { transition: none; } }

/* cards are links */
a.card, a.card * { text-decoration: none; }
a.card { color: inherit; display: flex; }
.stat, .spec, .add { color: inherit; }

main { overflow-x: hidden; }
.sp > div { min-width: 0; }
