/* PXYZ Agent. Tokens come from pxyz.css (synced from pxyz-brand). No borders: depth is the offset shadow. */
:root { --shadow: 4px 4px 0 var(--px-ink); --shadow-s: 3px 3px 0 var(--px-ink); --side: 288px; --r: 14px; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 400 16px/1.55 var(--px-sans); color: var(--px-ink); background: var(--px-paper); }
button, input, select, textarea { font: inherit; color: inherit; border: 0; outline: 0; background: none; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--px-ink); outline-offset: 2px; }
.grow { flex: 1; } .only-m { display: none; }
.btn-lime, .btn-ghost { display: inline-block; text-align: center; text-decoration: none; background: var(--px-lime); color: var(--px-ink); font: 600 1rem var(--px-sans); padding: 12px 22px; border-radius: var(--r); box-shadow: var(--shadow-s); transition: transform .12s, box-shadow .12s; }
.btn-ghost { background: var(--px-panel); }
.btn-lime:hover, .btn-ghost:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--px-ink); }
.btn-lime:active, .btn-ghost:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--px-ink); }
.btn-lime.wide { width: 100%; } .btn-lime.sm { padding: 6px 16px; font-size: .9rem; }
.link { font: 500 .8rem var(--px-mono); text-decoration: underline; text-underline-offset: 3px; color: var(--px-muted); padding: 4px; }
.link:hover { color: var(--px-ink); }

/* Login */
body.login { display: grid; place-items: center; min-height: 100dvh; padding: 20px; position: relative; overflow: hidden; }
#swarm { position: fixed; inset: 0; width: 100%; height: 100%; opacity: .35; z-index: 0; }
.login-card { position: relative; z-index: 1; width: min(400px, 100%); background: var(--px-paper); border-radius: 22px; box-shadow: 8px 8px 0 var(--px-ink); padding: 40px 32px 28px; display: grid; justify-items: center; gap: 4px; animation: rise .5s ease both; }
.login-card h1 { margin: 14px 0 0; font-size: 2.6rem; } .login-card .px-kicker { margin: 0 0 18px; }
.login-card form { width: 100%; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font: 500 .72rem var(--px-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--px-muted); }
.login-card input { background: var(--px-panel); border-radius: 12px; padding: 13px 14px; font: 400 1rem var(--px-sans); letter-spacing: 0; text-transform: none; color: var(--px-ink); }
.login-card input:focus { box-shadow: var(--shadow-s); background: #fff; }
.login-card .btn-lime { margin-top: 6px; } .login-card small { margin-top: 18px; font: 500 .68rem var(--px-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--px-muted); }
.err { margin: 0; padding: 8px 12px; background: #ffd9d9; border-radius: 10px; font-size: .9rem; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* App shell */
.app { display: grid; grid-template-columns: var(--side) 1fr; height: 100dvh; }
.side { background: var(--px-panel); display: flex; flex-direction: column; gap: 16px; padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 4px; } .brand .px-wordmark { font-size: 1.35rem; } .brand .px-kicker { margin-left: auto; }
.convs { grid-template-columns: minmax(0, 1fr); flex: 1; overflow: auto; display: grid; align-content: start; gap: 4px; margin: 0 -4px; padding: 0 4px; }
.conv { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border-radius: 10px; text-align: left; font-size: .94rem; width: 100%; }
.conv span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv:hover { background: #fff; } .conv.on { background: var(--px-ink); color: #fff; }
.conv .x { opacity: 0; font-size: 1rem; padding: 0 4px; color: inherit; } .conv:hover .x, .conv:focus-within .x { opacity: .7; } .conv .x:hover { opacity: 1; }
.empty-list { font: 500 .8rem var(--px-mono); color: var(--px-muted); padding: 8px; }
.who { display: flex; align-items: center; justify-content: space-between; gap: 8px; } .who .px-kicker { overflow: hidden; text-overflow: ellipsis; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100dvh; position: relative; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px var(--px-pad) 0; }
.chip { display: inline-flex; align-items: center; gap: 10px; background: var(--px-panel); border-radius: 999px; padding: 7px 14px; font: 500 .8rem var(--px-mono); letter-spacing: .02em; max-width: 100%; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover, .chip[aria-expanded=true] { background: var(--px-lime); box-shadow: var(--shadow-s); }
.chip kbd { font: inherit; opacity: .5; }
.thread { flex: 1; overflow-y: auto; padding: 24px var(--px-pad) 12px; scroll-behavior: smooth; }
.col { width: min(760px, 100%); margin: 0 auto; display: grid; gap: 26px; }
.msg.user { justify-self: end; max-width: 85%; background: var(--px-lime); border-radius: 18px 18px 4px 18px; padding: 12px 16px; box-shadow: var(--shadow-s); white-space: pre-wrap; overflow-wrap: anywhere; animation: rise .25s ease both; }
.msg.ai { animation: rise .25s ease both; overflow-wrap: anywhere; }
.meta { margin-top: 8px; font: 500 .68rem var(--px-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--px-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.meta .bad { color: #b00020; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol { margin: .7em 0; } .md h1, .md h2, .md h3 { font-family: var(--px-display); font-weight: 400; margin: 1.2em 0 .4em; line-height: 1.15; }
.md h1 { font-size: 1.6rem; } .md h2 { font-size: 1.3rem; } .md h3 { font-size: 1.1rem; }
.md a { color: var(--px-ink); text-decoration-thickness: 2px; text-underline-offset: 3px; } .md a:hover { background: var(--px-ink); color: #fff; text-decoration: none; }
.md code { font: 500 .88em var(--px-mono); background: var(--px-panel); padding: .1em .35em; border-radius: 6px; }
.md pre { position: relative; background: var(--px-ink); color: #f4f4f4; border-radius: 12px; padding: 16px; overflow: auto; box-shadow: var(--shadow-s); margin: 1em 0; }
.md pre code { background: none; padding: 0; color: inherit; font-size: .85rem; }
.md pre .copy { position: absolute; top: 8px; right: 8px; background: var(--px-lime); color: var(--px-ink); font: 500 .68rem var(--px-mono); padding: 3px 9px; border-radius: 999px; opacity: 0; transition: opacity .15s; }
.md pre:hover .copy, .md pre .copy:focus-visible { opacity: 1; }
.md table { border-collapse: collapse; display: block; overflow: auto; } .md th, .md td { padding: 6px 12px; text-align: left; background: var(--px-panel); } .md tr + tr td { box-shadow: 0 2px 0 #fff inset; }
.md blockquote { margin: .8em 0; padding-left: 14px; box-shadow: -4px 0 0 var(--px-lime); color: var(--px-muted); }
.caret::after { content: ""; display: inline-block; width: .55em; height: 1em; margin-left: 2px; vertical-align: -.15em; background: var(--px-ink); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.hero { min-height: 100%; display: grid; place-content: center; justify-items: center; gap: 18px; text-align: center; padding-bottom: 8vh; }
.hero img { opacity: .9; } .hero h2 { margin: 0; font: 400 clamp(2.2rem, 7vw, 4rem)/1 var(--px-display); }
.hero p { margin: 0; max-width: 46ch; color: var(--px-muted); }
.sugg { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
.sugg button { background: var(--px-panel); border-radius: 12px; padding: 10px 14px; font-size: .92rem; text-align: left; transition: background .12s, box-shadow .12s; }
.sugg button:hover { background: var(--px-lime); box-shadow: var(--shadow-s); }

/* Dock: composer + configurator */
.dock { padding: 0 var(--px-pad) calc(10px + env(safe-area-inset-bottom)); position: relative; width: min(calc(760px + 2 * var(--px-pad)), 100%); margin: 0 auto; }
.composer { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 12px 14px 10px; display: grid; gap: 8px; }
.composer:focus-within { box-shadow: 6px 6px 0 var(--px-ink); }
.composer textarea { resize: none; max-height: 40vh; width: 100%; line-height: 1.5; padding: 4px 2px; }
.composer textarea::placeholder { color: #8a8a8a; }
.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bill { display: inline-flex; align-items: center; gap: 6px; font: 500 .68rem var(--px-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--px-muted); }
.bill select { background: var(--px-panel); border-radius: 999px; padding: 6px 10px; font: 500 .78rem var(--px-mono); letter-spacing: 0; text-transform: none; color: var(--px-ink); max-width: 150px; }
.send, .stop { width: 40px; height: 40px; border-radius: 50%; background: var(--px-ink); color: var(--px-lime); font-size: 1.2rem; font-weight: 700; display: grid; place-items: center; transition: transform .12s, background .12s; }
.send:hover { background: var(--px-lime); color: var(--px-ink); transform: scale(1.06); } .send:disabled { opacity: .3; transform: none; background: var(--px-ink); color: var(--px-lime); cursor: default; }
.stop { background: var(--px-lime); color: var(--px-ink); font-size: .85rem; } .stop[hidden] { display: none; }
.fine { margin: 8px 0 0; text-align: center; font: 500 .66rem var(--px-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--px-muted); min-height: 1em; }
.cfg { position: absolute; left: var(--px-pad); right: var(--px-pad); bottom: calc(100% - 4px); background: #fff; border-radius: 20px; box-shadow: 8px 8px 0 var(--px-ink); padding: 18px; display: grid; grid-template-columns: 1fr 1.4fr; gap: 20px; max-height: min(520px, 64dvh); z-index: 5; animation: rise .18s ease both; }
.cfg[hidden] { display: none; }
.cfg-col { min-height: 0; display: flex; flex-direction: column; gap: 10px; } .cfg-col .px-kicker { margin: 0; }
.modes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; overflow: auto; align-content: start; padding: 2px 4px 6px 2px; }
.mode { background: var(--px-panel); border-radius: 12px; padding: 10px 12px; text-align: left; transition: background .12s, box-shadow .12s; }
.mode b { display: block; font-family: var(--px-display); font-weight: 400; } .mode small { color: var(--px-muted); font-size: .76rem; line-height: 1.3; display: block; }
.mode:hover { background: var(--px-lime); } .mode[aria-pressed=true] { background: var(--px-ink); color: #fff; box-shadow: var(--shadow-s); } .mode[aria-pressed=true] small { color: #cfcfcf; }
#msearch { background: var(--px-panel); border-radius: 10px; padding: 8px 12px; font-size: .9rem; }
.models { overflow: auto; display: grid; align-content: start; gap: 2px; padding-right: 4px; }
.prov { margin: 10px 0 4px; font: 500 .68rem var(--px-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--px-muted); display: flex; justify-content: space-between; gap: 8px; }
.prov.off { opacity: .55; }
.model { text-align: left; padding: 7px 10px; border-radius: 9px; font: 500 .82rem var(--px-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model:hover { background: var(--px-lime); } .model[aria-pressed=true] { background: var(--px-ink); color: #fff; }
.cfg-foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding-top: 4px; }
#cfgSummary { flex: 1; font: 500 .78rem var(--px-mono); color: var(--px-muted); }

.scrim { display: none; }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; } .only-m { display: inline-grid; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(310px, 86vw); z-index: 20; transform: translateX(-102%); transition: transform .25s ease, box-shadow .25s; }
  .app.open .side { transform: none; box-shadow: 8px 0 0 var(--px-ink); } .app.open .scrim { display: block; position: fixed; inset: 0; background: rgba(10,10,10,.35); z-index: 10; }
  .icon { width: 40px; height: 40px; border-radius: 12px; background: var(--px-panel); place-content: center; gap: 4px; } .icon span { display: block; width: 18px; height: 2px; background: var(--px-ink); }
  .cfg { grid-template-columns: 1fr; max-height: 70dvh; overflow: auto; left: 8px; right: 8px; } .modes { grid-template-columns: repeat(3, 1fr); } .models { max-height: 30dvh; }
  .dock { padding-inline: 10px; } .bill select { max-width: 110px; } #chipTop { display: none; }
  .top { padding-top: 10px; }
}
@media (max-width: 480px) { .modes { grid-template-columns: repeat(2, 1fr); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* The composer and login fields show focus with their own shadow, so no extra outline. */
.composer textarea:focus-visible, .login-card input:focus-visible, #msearch:focus-visible { outline: 0; }
#msearch:focus-visible { box-shadow: var(--shadow-s); background: #fff; }

/* Master dashboard */
body.dash { min-height: 100dvh; }
.dash-top { display: flex; align-items: center; gap: 12px; padding: 16px var(--px-pad); } .dash-top .brand { text-decoration: none; color: inherit; }
.btn-ghost.sm { padding: 8px 16px; font-size: .88rem; }
.dash-main { width: min(1000px, 100%); margin: 0 auto; padding: 8px var(--px-pad) 64px; }
.dash-main h1 { font-size: clamp(2.4rem, 7vw, 4rem); line-height: 1; margin: 6px 0 10px; } .dash-main h2 { font-size: 1.6rem; margin: 48px 0 12px; }
.lede { max-width: 58ch; color: var(--px-muted); margin: 0 0 28px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.pcard { background: var(--px-panel); border-radius: 18px; padding: 18px; display: grid; gap: 10px; align-content: start; transition: background .15s, box-shadow .15s; }
.pcard.on { background: #fff; box-shadow: var(--shadow); }
.phead { display: flex; align-items: center; justify-content: space-between; gap: 12px; } .phead h3 { margin: 0; font: 400 1.25rem var(--px-display); }
.switch { width: 52px; height: 30px; border-radius: 999px; background: #cfcfcf; position: relative; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 1px 1px 0 var(--px-ink); transition: transform .15s; }
.switch[aria-checked=true] { background: var(--px-lime); box-shadow: var(--shadow-s); } .switch[aria-checked=true]::after { transform: translateX(22px); background: var(--px-ink); }
.switch:disabled { opacity: .45; cursor: not-allowed; }
.pkey, .pnums { margin: 0; font: 500 .78rem var(--px-mono); color: var(--px-muted); display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #bbb; } .dot.ok { background: var(--px-lime); box-shadow: 1px 1px 0 var(--px-ink); } .dot.no { background: #ff8a8a; }
.pstatus { margin: 0; min-height: 1.2em; font: 500 .78rem var(--px-mono); } .pstatus.bad { color: #b00020; }
.pcard .btn-ghost { justify-self: start; background: #fff; }
.tablewrap { overflow: auto; border-radius: 14px; background: var(--px-panel); } table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th { font: 500 .7rem var(--px-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--px-muted); text-align: left; padding: 12px 14px; }
td { padding: 10px 14px; font-family: var(--px-mono); font-size: .8rem; } tbody tr:nth-child(odd) td { background: #fff; }
.fine.left { text-align: left; margin-top: 10px; }
.dashlink { align-self: flex-start; }

/* Billing */
.bar2 { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; } .bar2 input { background: var(--px-panel); border-radius: 10px; padding: 7px 10px; font: 500 .85rem var(--px-mono); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; } .tile { background: var(--px-panel); border-radius: 16px; padding: 14px 16px; display: grid; gap: 4px; }
.tile b { font: 400 1.7rem var(--px-display); } .tile:first-child { background: var(--px-lime); box-shadow: var(--shadow-s); }
.warn { background: #fff3c4; border-radius: 12px; padding: 10px 14px; font-size: .9rem; margin: 14px 0 0; } .warn[hidden] { display: none; }
form.inline { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; align-items: center; }
form.inline input, form.inline select, .mini { background: var(--px-panel); border-radius: 10px; padding: 9px 12px; font: 500 .85rem var(--px-mono); min-width: 0; } .mini { width: 110px; } form.inline input:focus-visible, .mini:focus-visible { outline: 0; box-shadow: var(--shadow-s); background: #fff; }
.row { display: flex; align-items: center; gap: 8px; } .tok { display: block; word-break: break-all; background: var(--px-ink); color: var(--px-lime); border-radius: 10px; padding: 10px; margin: 6px 0; font: 500 .78rem var(--px-mono); }
.tokshow { display: grid; gap: 4px; } .tokshow small { color: var(--px-muted); }
.meter { height: 8px; background: #e3e3e3; border-radius: 999px; overflow: hidden; } .meter i { display: block; height: 100%; background: var(--px-ink); }
.stmt-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
tfoot th { font-size: .8rem; text-align: left; padding: 14px; }

/* Lake */
.dash-main.wide { width: min(1100px, 100%); } body.lake #space { background: var(--px-panel); border-radius: 999px; padding: 7px 14px; font: 500 .8rem var(--px-mono); margin-left: 12px; max-width: 40vw; }
.searchbar { display: flex; gap: 10px; margin: 8px 0 18px; } .searchbar input { flex: 1; background: var(--px-panel); border-radius: 14px; padding: 15px 18px; font-size: 1.1rem; min-width: 0; transition: box-shadow .12s, background .12s; }
.searchbar input:focus { background: #fff; box-shadow: var(--shadow); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 18px; } .tab { padding: 8px 16px; border-radius: 999px; font: 500 .85rem var(--px-mono); background: var(--px-panel); white-space: nowrap; transition: background .12s; } .tab:hover { background: var(--px-lime); } .tab[aria-selected=true] { background: var(--px-ink); color: #fff; }
.view { animation: rise .2s ease both; } .view[hidden] { display: none; }
.hit { padding: 14px 0; } .hit + .hit { box-shadow: 0 -2px 0 var(--px-panel); } .hh { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; } .hit p { margin: 6px 0; }
.why { display: flex; gap: 6px; flex-wrap: wrap; } .tag { font: 500 .66rem var(--px-mono); letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--px-panel); } .tag.film { background: var(--px-lime); }
.drop { display: grid; gap: 6px; justify-items: center; padding: 34px 16px; border-radius: 18px; background: var(--px-panel); cursor: pointer; text-align: center; transition: background .12s, box-shadow .12s; } .drop:hover, .drop.over { background: var(--px-lime); box-shadow: var(--shadow); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 72px; margin: 22px 0; } .bars i { flex: 1; background: var(--px-ink); border-radius: 3px 3px 0 0; transition: height .4s ease; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 24px; } .col2 .pnums { display: block; margin: 5px 0; overflow-wrap: anywhere; } .tile small { color: var(--px-muted); font: 500 .7rem var(--px-mono); }
.tbl { background: var(--px-panel); border-radius: 12px; padding: 10px 14px; margin: 8px 0; } .tbl summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; } td small.bad { color: #b00020; }
.picker { background: var(--px-panel); border-radius: 999px; padding: 6px 10px; font: 500 .78rem var(--px-mono); max-width: 150px; }
@media (max-width: 820px) { body.lake #space { max-width: 36vw; } }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 10px; z-index: 50; max-width: min(360px, 90vw); } .toast { display: block; background: var(--px-ink); color: #fff; border-radius: 14px; padding: 12px 16px; font-size: .9rem; text-decoration: none; box-shadow: var(--shadow-s); animation: rise .25s ease both; } a.toast:hover { background: var(--px-lime); color: var(--px-ink); }
