/* Agent Control — a bright, friendly chat system in two interchangeable themes.
 *
 * Colour theory, the same roles in both themes:
 *  - Mint green (~160deg) is what YOU do: your bubbles, send, primary actions.
 *  - Violet (~265deg) is one step round a triad from mint. It is reserved for
 *    "this is waiting on you", so it never competes with anything else.
 *  - Deeper green marks what you finished (same family as "you": you did it).
 *    Red is kept for destructive actions only, far from both.
 *  - Each bot owns one of six pastel hues, evenly spaced, at one lightness. Its
 *    face, its name and its bubbles all carry that hue, so you can tell who is
 *    talking by colour alone. Decision cards stay neutral so they stand out.
 *  - Neutrals are barely tinted: a clean off-white by day, a dark grey by night
 *    (never black). 60% ground, 30% tinted bubbles, 10% mint and violet.
 * The app follows the system setting unless a theme is pinned under
 * You > Colours. System fonts, no font fetch. */
:root{
  color-scheme:light;
  /* Light */
  --bg:#fbfaf8; --surface:#ffffff; --raised:#f2f1ed; --control:#e7e5df; --control-hi:#dad7cf; --line:#eceae4;
  --text:#22262b; --muted:#646a72;
  --brand:#36c391; --on-brand:#06281c; --brand-soft:#e0f6ec;
  --me:#c4f0d9; --on-me:#0f2f20; --on-me-muted:#3f6b56; --me-quote:rgba(255,255,255,.62);
  --them:#ffffff;
  --wait:#6a4bd6; --on-wait:#ffffff; --wait-bg:#ebe5ff; --good:#1b7a56; --good-bg:#dbf3e7; --bad:#bd3a2c; --bad-bg:#fde5e1;
  --shade:rgba(34,38,43,.36);
  --t0-bg:#d5e8fb; --t0:#2a66a3; --t0-soft:#eaf3fd;
  --t1-bg:#e5dcfb; --t1:#6245b5; --t1-soft:#f1ecfd;
  --t2-bg:#ffdfc6; --t2:#a2531a; --t2-soft:#fff0e3;
  --t3-bg:#f9ecb8; --t3:#7a5c00; --t3-soft:#fdf6dc;
  --t4-bg:#fbd8e3; --t4:#a83c5d; --t4-soft:#fdecf1;
  --t5-bg:#cdeef1; --t5:#1b727e; --t5-soft:#e5f6f7;
  --r-bubble:20px; --r-box:18px; --r-ctl:14px;
  --list-w:360px; --info-w:380px;
  --font:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",sans-serif;
  --ease:cubic-bezier(.23,1,.32,1); --spring:cubic-bezier(.3,1.18,.5,1); --drawer:cubic-bezier(.32,.72,0,1);
}
:root[data-theme="cocoa"]{
  color-scheme:dark;
  /* Dark: a true dark grey, never black, with very little white in it */
  --bg:#1a1a1d; --surface:#222226; --raised:#2b2b30; --control:#38383e; --control-hi:#45454c; --line:#2f2f34;
  --text:#ecebe8; --muted:#a6a4a2;
  --brand:#86cfae; --on-brand:#0d281c; --brand-soft:#25372e;
  --me:#86cfae; --on-me:#0d281c; --on-me-muted:#2c5741; --me-quote:rgba(13,40,28,.14);
  --them:#2b2b30;
  --wait:#c4b7f5; --on-wait:#21173b; --wait-bg:#322c49; --good:#9ad9bc; --good-bg:#23372d; --bad:#eea09a; --bad-bg:#422827;
  --shade:rgba(8,8,10,.66);
  --t0-bg:#2c3e50; --t0:#a6cbec; --t0-soft:#25313c;
  --t1-bg:#393253; --t1:#c8bcf0; --t1-soft:#2e2a3f;
  --t2-bg:#4d3929; --t2:#eec29c; --t2-soft:#392f27;
  --t3-bg:#484021; --t3:#e6d383; --t3-soft:#353121;
  --t4-bg:#4d313e; --t4:#eeb2c3; --t4-soft:#3a2a31;
  --t5-bg:#294347; --t5:#a1d8de; --t5-soft:#243537;
}
/* Before the script resolves "follow the system", avoid a light flash at night. */
@media(prefers-color-scheme:dark){:root:not([data-theme]){--bg:#1a1a1d;--text:#ecebe8;--muted:#a6a4a2}}
.t0{--tile:var(--t0-bg);--tint:var(--t0);--bubble:var(--t0-soft)}.t1{--tile:var(--t1-bg);--tint:var(--t1);--bubble:var(--t1-soft)}.t2{--tile:var(--t2-bg);--tint:var(--t2);--bubble:var(--t2-soft)}
.t3{--tile:var(--t3-bg);--tint:var(--t3);--bubble:var(--t3-soft)}.t4{--tile:var(--t4-bg);--tint:var(--t4);--bubble:var(--t4-soft)}.t5{--tile:var(--t5-bg);--tint:var(--t5);--bubble:var(--t5-soft)}
*{box-sizing:border-box;scrollbar-width:thin;scrollbar-color:var(--control) transparent}
html,body{height:100%;margin:0}
body{background:var(--bg);color:var(--text);font:15px/1.4 var(--font);-webkit-font-smoothing:antialiased;overflow:hidden}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer;border:0;background:none;padding:0;text-align:inherit}
a{color:inherit}
h1,h2,h3,p{margin:0}
.hidden{display:none!important}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
button:disabled{opacity:.55;cursor:default}
[hidden]{display:none!important}
:focus-visible{outline:2px solid var(--brand);outline-offset:2px;border-radius:8px}
#main:focus,h2:focus{outline:none}

/* ---------- frame: list | thread | info ---------- */
.app{display:grid;grid-template-columns:var(--list-w) minmax(0,1fr);height:100dvh}
body.has-info .app{grid-template-columns:var(--list-w) minmax(0,1fr) var(--info-w)}
.pane{min-width:0;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.pane-list{border-right:1px solid var(--line);position:relative}
.pane-info{border-left:1px solid var(--line);overflow-y:auto;padding-bottom:24px}
.pane-info>*{flex:none}
body:not(.has-info) .pane-info{display:none}
.progress{position:fixed;inset:0 0 auto;height:2px;z-index:60;background:linear-gradient(90deg,transparent,var(--brand),transparent);background-size:40% 100%;background-repeat:no-repeat;animation:slide 1.1s linear infinite}
@keyframes slide{from{background-position:-40% 0}to{background-position:140% 0}}
.splash{margin:auto;color:var(--muted)}
.view-enter{animation:enter .22s var(--ease)}
@keyframes enter{from{opacity:0;transform:translateY(6px)}}

/* ---------- shared atoms ---------- */
.avatar{flex:none;display:inline-flex;align-items:center;justify-content:center;border-radius:50%;font-weight:700;line-height:1;background:var(--tile,var(--raised));color:var(--tint,var(--muted))}
.avatar-plain{background:var(--raised);color:var(--muted)}
.avatar-plain.small{width:38px;height:38px}
.avatar-pair{flex:none;position:relative;display:inline-block}
.avatar-pair .avatar{position:absolute}
.avatar-pair .avatar:first-child{left:0;top:0}
.avatar-pair .avatar:last-child{right:0;bottom:0;box-shadow:0 0 0 2px var(--bg)}
.avatar-gap{flex:none;width:30px}
.icon-btn{flex:none;position:relative;width:44px;height:44px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:var(--text);transition:background .15s,transform .14s var(--ease)}
.icon-btn:hover{background:var(--raised)}
.icon-btn:focus-visible,.avatar:focus-visible,.tint:focus-visible{border-radius:50%}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:0 16px;border-radius:var(--r-ctl);background:var(--control);color:var(--text);font-size:15px;text-decoration:none;white-space:nowrap;transition:filter .15s,transform .1s}
.btn:hover{filter:brightness(1.12)}
.btn:active,.icon-btn:active,.chip:active,.filter:active,.fab:active{transform:scale(.95)}
.btn.primary{background:var(--brand);color:var(--on-brand);font-weight:600}
.btn.good{background:var(--good-bg);color:var(--good);font-weight:600}
.btn.danger{background:var(--bad-bg);color:var(--bad)}
.btn.ghost{background:transparent;color:var(--muted)}
.btn.small{min-height:36px;padding:0 12px;font-size:14px;border-radius:12px}
.btn.wide{width:100%}
.badge{flex:none;min-width:20px;height:20px;padding:0 6px;border-radius:10px;background:var(--wait);color:var(--on-wait);font-size:12px;font-weight:700;line-height:20px;text-align:center}
.badge-dot{position:absolute;top:4px;right:2px;min-width:17px;height:17px;padding:0 4px;border-radius:9px;background:var(--wait);color:var(--on-wait);font-size:11px;font-weight:700;line-height:17px;text-align:center}
.tag{flex:none;padding:3px 9px;border-radius:9px;background:var(--control);color:var(--muted);font-size:12px;white-space:nowrap}
.tag.good{background:var(--good-bg);color:var(--good)} .tag.warn{background:var(--wait-bg);color:var(--wait)} .tag.bad{background:var(--bad-bg);color:var(--bad)}
.note{margin:14px 16px 0;color:var(--muted);font-size:13px;line-height:1.45}
.empty{display:flex;flex-direction:column;gap:4px;padding:28px 20px;text-align:center;color:var(--muted);font-size:14px}
.empty strong{color:var(--text);font-weight:600}
.code{display:block;margin-top:6px;padding:10px 12px;border-radius:12px;background:var(--bg);font:14px ui-monospace,SFMono-Regular,Menlo,monospace;word-break:break-all;user-select:all}
.search{flex:none;display:flex;align-items:center;gap:10px;height:44px;margin:0 14px;padding:0 14px;border-radius:22px;background:var(--surface);color:var(--muted)}
.search input{flex:1;min-width:0;border:0;outline:0;background:transparent;color:var(--text);font-size:15px}
.search:focus-within{box-shadow:0 0 0 2px var(--control)}

/* ---------- chat list ---------- */
.list-head{flex:none;display:flex;align-items:center;justify-content:space-between;padding:18px 10px 10px 20px}
.list-head h1{font-size:28px;font-weight:700;letter-spacing:-.02em}
.list-tools{display:flex;align-items:center}
.filters{flex:none;display:flex;gap:8px;padding:12px 14px 6px;overflow-x:auto;scrollbar-width:none}
.filter{flex:none;display:inline-flex;align-items:center;gap:8px;height:36px;padding:0 14px;border-radius:18px;background:var(--surface);font-size:14px;transition:background .18s,color .18s,transform .14s var(--ease)}
.filter.on{background:var(--brand);color:var(--on-brand);font-weight:600}
.chat-list{flex:1;overflow-y:auto;padding:6px 8px}
.chat-row{display:flex;align-items:center;gap:12px;width:100%;padding:10px;border-radius:16px;transition:background .12s}
.chat-row:hover{background:var(--surface)}
.chat-row.current{background:var(--brand-soft)}
.chat-row:hover:not(.current){background:var(--raised)}
.chat-row-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
.chat-row-top,.chat-row-bottom{display:flex;align-items:center;justify-content:space-between;gap:8px}
.chat-row-name{display:inline-flex;align-items:center;gap:6px;font-size:16px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-row-name svg{color:var(--muted)}
.chat-row time{flex:none;font-size:12px;color:var(--muted)}
.chat-row time.warn{color:var(--wait)}
.chat-row-preview{min-width:0;font-size:14px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-row-preview .who{color:var(--text)}
.typing-text{color:var(--good)}
.list-foot{flex:none;display:flex;flex-direction:column;align-items:center;gap:3px;padding:12px 16px 16px;color:var(--muted);font-size:12px;text-align:center}
.promise{display:inline-flex;align-items:center;gap:7px;font-size:13px}
.fab{display:none}

/* ---------- thread ---------- */
.thread-head{flex:none;display:flex;align-items:center;gap:6px;min-height:64px;padding:8px 14px;border-bottom:1px solid var(--line)}
.thread-head .back{display:none}
.thread-title{flex:1;min-width:0;display:flex;align-items:center;gap:11px;padding:4px 8px 4px 4px;border-radius:14px}
.thread-title:hover{background:var(--surface)}
.thread-title-text{min-width:0;display:flex;flex-direction:column}
.thread-title-text strong{font-size:16px;font-weight:600}
.thread-title-text span{font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.needs-pill{flex:none;height:36px;padding:0 14px;border-radius:18px;background:var(--wait-bg);color:var(--wait);font-size:13px;font-weight:600;white-space:nowrap}
.thread-log{flex:1;overflow-y:auto;display:flex;flex-direction:column;gap:3px;padding:14px max(14px,calc((100% - 760px)/2)) 10px;overscroll-behavior:contain}
.day,.event{align-self:center;margin:10px 0 6px;padding:4px 12px;border-radius:12px;background:var(--surface);color:var(--muted);font-size:12px;text-align:center}
.event{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px;max-width:88%;padding:6px 12px}
.msg{display:flex;align-items:flex-end;gap:8px;max-width:100%}
.msg.lead{margin-top:9px}
.msg.me{justify-content:flex-end}
.bubble{position:relative;max-width:min(78%,560px);padding:8px 13px;border-radius:var(--r-bubble);background:var(--them);overflow-wrap:anywhere}
.msg.them .bubble{border-bottom-left-radius:6px;background:var(--bubble,var(--them))}
.msg.them .bubble.card .post-quote{background:var(--surface)}
.msg.me .bubble{background:var(--me);color:var(--on-me);border-bottom-right-radius:6px}
.bubble .sender{display:block;margin-bottom:1px;font-size:12px;font-weight:600;color:var(--tint,var(--muted))}
.bubble .text{white-space:pre-wrap;line-height:1.38}
.bubble time{float:right;margin:7px 0 -2px 12px;font-size:11px;color:var(--muted)}
.msg.me .bubble time{color:var(--on-me-muted)}
.by-model{font-weight:700;letter-spacing:.04em}
.handoff{display:flex;align-items:center;gap:4px;margin-top:4px;font-size:12px;color:var(--muted)}
.bubble.card{width:min(78%,420px);padding:6px}
.bubble.card .sender{padding:4px 8px 0}
.typing{display:inline-flex;gap:5px;padding:14px 15px}
.typing i{width:7px;height:7px;border-radius:50%;background:var(--muted);animation:blink 1.2s infinite}
.typing i:nth-child(2){animation-delay:.18s}.typing i:nth-child(3){animation-delay:.36s}
@keyframes blink{0%,60%,100%{opacity:.3;transform:none}30%{opacity:1;transform:translateY(-3px)}}
.welcome{margin:auto;display:flex;flex-direction:column;align-items:center;gap:8px;max-width:400px;padding:24px;text-align:center}
.welcome h2{margin-top:8px;font-size:22px}
.welcome p{color:var(--muted)} .welcome .quiet{font-size:13px}

/* a shared post, quoted inside a bubble */
.post{display:flex;flex-direction:column;gap:6px}
.post-quote{display:flex;flex-direction:column;gap:3px;padding:10px 12px;border-radius:14px;background:var(--raised);text-decoration:none;font-size:14px;line-height:1.36}
.post-quote strong{font-size:12px;color:var(--muted);font-weight:600}
.msg.me .post-quote{background:var(--me-quote)}.msg.me .post-quote strong{color:var(--on-me-muted)}
.post-meta{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 6px 2px 8px;font-size:12px;color:var(--muted)}
.msg.me .post-meta{color:var(--on-me-muted)}
.msg.me .post-meta .btn.primary{background:var(--on-me);color:var(--me)}

/* the decision card: a draft you answer in place */
.draft{width:min(86%,460px);border-radius:var(--r-bubble);background:var(--them);overflow:hidden}
.msg.them .draft{border-bottom-left-radius:6px}
.stack .draft{width:100%}
.draft>header{display:flex;align-items:baseline;justify-content:space-between;gap:10px;padding:11px 14px 0;font-size:13px}
.draft-to{font-weight:600}.draft-score{color:var(--muted);font-size:12px;white-space:nowrap}
.draft-text{padding:8px 14px 12px;white-space:pre-wrap;line-height:1.4;overflow-wrap:anywhere}
.card-actions{display:flex;flex-wrap:wrap;gap:8px;padding:0 10px 10px}
.card-actions .btn{flex:1 1 auto}
.card-actions .btn.ghost{flex:0 0 auto}
.draft-state{display:flex;align-items:center;gap:8px;min-height:40px;padding:6px 8px 6px 14px;background:var(--raised);color:var(--muted);font-size:12px;font-weight:600}
.draft-state span{flex:1}
.draft-state .dot{width:7px;height:7px;border-radius:50%;background:currentColor;animation:pulse 1.8s infinite}
@keyframes pulse{50%{opacity:.35}}
.tone-wait .draft-state{background:var(--wait-bg);color:var(--wait)}
.tone-done .draft-state{color:var(--good)}
.tone-off .draft-text,.tone-off .draft-to{color:var(--muted)}
.edit-form{padding:8px 10px 0}.edit-form .card-actions{padding:8px 0 10px}
.evidence-panel{margin:0 10px 10px;border-radius:12px;background:var(--raised);font-size:13px}
.evidence-panel summary{display:flex;align-items:center;min-height:40px;padding:0 12px;color:var(--muted);cursor:pointer;list-style:none}
.evidence-panel summary span{display:inline-flex;align-items:center;gap:7px}
.evidence-panel summary::-webkit-details-marker{display:none}
.evidence-item{display:flex;flex-direction:column;gap:8px;padding:10px 12px;border-top:1px solid var(--line)}
.evidence-form{display:flex;flex-direction:column;gap:8px;padding:10px 12px 12px;border-top:1px solid var(--line)}

/* composer */
.chips{flex:none;display:flex;gap:8px;padding:4px max(14px,calc((100% - 760px)/2)) 8px;overflow-x:auto;scrollbar-width:none}
.chips.center{justify-content:center;flex-wrap:wrap;padding:0}
.chip{flex:none;height:36px;padding:0 14px;border:1px solid var(--control);border-radius:18px;font-size:14px;white-space:nowrap;transition:background .15s}
.chip:hover{background:var(--raised)}
/* A finger needs a taller target than a mouse pointer does. */
@media (pointer:coarse){.chip{height:44px;border-radius:22px}}
.composer{flex:none;display:flex;align-items:flex-end;gap:8px;padding:0 max(12px,calc((100% - 764px)/2)) max(14px,env(safe-area-inset-bottom))}
.composer textarea{flex:1;min-width:0;min-height:46px;max-height:180px;padding:12px 18px;border:0;outline:0;border-radius:23px;background:var(--raised);font-size:16px;line-height:1.35;resize:none}
.composer textarea:focus{box-shadow:0 0 0 2px var(--control)}
.composer .icon-btn{width:46px;height:46px;background:var(--raised)}
.composer .send{background:var(--brand);color:var(--on-brand);overflow:hidden}
.composer .send:hover{background:var(--brand);filter:brightness(1.1)}

/* desktop landing */
.home{margin:auto;width:100%;max-width:620px;display:flex;flex-direction:column;align-items:center;gap:14px;padding:24px;text-align:center}
.home-mark{display:inline-flex;color:var(--brand)}
.home h1{font-size:30px;font-weight:700;letter-spacing:-.02em}
.home p{color:var(--muted);max-width:460px}
.home .composer{width:100%;padding:10px 0 4px}

/* ---------- panes with rows: info panel + You pages ---------- */
.pane-head{flex:none;display:flex;align-items:center;gap:6px;min-height:64px;padding:8px 14px 8px 8px}
.pane-head-text{flex:1;min-width:0}
.pane-head h2{font-size:17px;font-weight:600}
.pane-head p{font-size:13px;color:var(--muted)}
.pane-main>.pane-head{border-bottom:1px solid var(--line)}
.page-body{flex:1;overflow-y:auto;width:100%;max-width:680px;margin:0 auto;padding:6px 0 28px}
.hero{display:flex;flex-direction:column;align-items:center;gap:6px;padding:10px 24px 8px;text-align:center}
.hero h2{margin-top:8px;font-size:22px;font-weight:700}
.hero p{color:var(--muted);font-size:14px}
.box-label{margin:20px 28px 0;font-size:13px;font-weight:400;color:var(--muted)}
.box{margin:8px 14px 0;border-radius:var(--r-box);background:var(--surface);overflow:hidden}
.box>.btn,.box>p>.btn{margin:12px 14px}
.box>form,.box>.prose{padding:14px}
.box>form{display:flex;flex-direction:column;gap:12px;align-items:stretch}
.box>form .check-row{padding:4px 0;min-height:0}
.box>form>.btn{align-self:flex-start}
.prose{white-space:pre-wrap;line-height:1.45}
.row{display:flex;align-items:center;gap:12px;width:100%;min-height:54px;padding:9px 14px;color:var(--text)}
.row+.row{border-top:1px solid var(--line)}
button.row:hover{background:var(--raised)}
button.row>svg:last-child{flex:none;color:var(--muted)}
.row-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.row-title{font-size:15px}.row-sub{font-size:13px;color:var(--muted);overflow-wrap:anywhere}
.row-right{flex:none;font-size:14px;color:var(--muted)}
.row-right.warn{color:var(--wait);font-weight:600}
.row.tone-bad .row-title{color:var(--bad)}
.row-actions{display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-end}
.toolbar{display:flex;gap:8px;padding:10px 14px 0}
.pick{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px;font-size:12px;color:var(--muted)}
.count{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:10px 16px 0;color:var(--muted);font-size:13px}
.stack{display:flex;flex-direction:column;gap:10px;padding:12px 14px 0}
.stack .bubble.card{width:100%;max-width:none}
.run-card{border-radius:var(--r-box);background:var(--surface);overflow:hidden}
.run-card>header{display:flex;align-items:flex-start;gap:10px;padding:12px 14px}
.run-timeline{list-style:none;margin:0;padding:0 14px 12px}
.run-step{position:relative;display:flex;flex-direction:column;gap:2px;padding:6px 0 6px 18px;font-size:13px;color:var(--muted)}
.run-step strong{display:inline-flex;align-items:center;gap:5px;color:var(--text);font-weight:600}
.run-step::before{content:"";position:absolute;left:3px;top:13px;width:7px;height:7px;border-radius:50%;background:var(--control)}
.run-step::after{content:"";position:absolute;left:6px;top:22px;bottom:-11px;width:1px;background:var(--control)}
.run-step:last-child::after{display:none}

/* ---------- forms ---------- */
.form{display:flex;flex-direction:column;gap:14px;padding:14px}
.sheet .form{padding:4px 0 0}
.field{display:flex;flex-direction:column;gap:6px}
.field-label,.contract-fieldset legend{font-size:13px;color:var(--muted)}
.field-help{font-size:12px;color:var(--muted);margin:0}
.input{width:100%;min-height:46px;padding:11px 14px;border:0;outline:0;border-radius:var(--r-ctl);background:var(--raised);font-size:16px}
.box .input,.draft .input,.sheet .input{background:var(--raised)}
.sheet .input{background:var(--surface)}
.input:focus{box-shadow:0 0 0 2px var(--muted)}
textarea.input{resize:vertical;line-height:1.4}
select.input{appearance:none;padding-right:34px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%239a9aa2' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m1 1 5 5 5-5'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 13px center}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.check-row{display:flex;align-items:flex-start;gap:12px;min-height:44px;padding:11px 14px;cursor:pointer}
.check-row input{flex:none;width:20px;height:20px;margin:1px 0 0;accent-color:var(--brand)}
.check-row small{display:block;color:var(--muted);font-size:13px}
.contract-fieldset{margin:0;padding:0;border:0}
.contract-fieldset .check-row{padding:8px 0;min-height:0}
.tints{display:flex;flex-wrap:wrap;gap:10px}
.tint{flex:none;width:44px;height:44px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center}
.tint svg{opacity:0}.tint.on svg{opacity:1}.tint{background:var(--tile);color:var(--tint)}
.tint.on{box-shadow:0 0 0 2px var(--raised),0 0 0 4px var(--tint)}
.tint{transition:transform .16s var(--ease)}.tint.on{transform:scale(1.05)}

/* ---------- layers ---------- */
.modal-layer,.command-layer{position:fixed;inset:0;z-index:40;display:flex;align-items:center;justify-content:center;padding:20px;background:var(--shade);animation:fade .16s}
@keyframes fade{from{opacity:0}}
.sheet{width:100%;max-width:460px;max-height:min(88dvh,760px);overflow-y:auto;padding:18px;border-radius:24px;background:var(--raised);animation:rise .3s var(--drawer)}
@keyframes rise{from{opacity:0;transform:translateY(22px) scale(.98)}}
.sheet-grip{display:none}
.sheet-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;margin-bottom:14px}
.sheet-head h2{font-size:19px;font-weight:700}
.sheet-head p{margin-top:3px;color:var(--muted);font-size:14px}
.sheet-head .icon-btn{margin:-8px -8px 0 0}
.sheet .box{margin:0;background:var(--surface)}
.sheet .box button.row:hover{background:var(--control)}
.sheet .box .row+.row{border-color:var(--line)}
.sheet .avatar-plain{background:var(--raised)}
.sheet{box-shadow:0 20px 60px var(--shade)}
.sheet .note{margin:12px 2px 0}
.sheet-actions{display:flex;flex-direction:column;gap:8px;margin-top:14px}
.command-layer{align-items:flex-start;padding-top:12vh}
.command-card{width:100%;max-width:520px;padding:12px;border-radius:24px;background:var(--raised);animation:rise .2s var(--ease)}
.command-card .search{margin:0;background:var(--surface)}
.command-results{max-height:46vh;overflow-y:auto;margin-top:8px}
.command-item{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;min-height:46px;padding:0 14px;border-radius:12px}
.command-item small{color:var(--muted);font-size:13px}
.command-item.selected,.command-item:hover{background:var(--control)}
.command-foot{padding:8px 8px 0;color:var(--muted);font-size:12px}
.toast{position:fixed;left:50%;bottom:92px;z-index:70;transform:translateX(-50%);max-width:min(92vw,440px);padding:11px 18px;border-radius:22px;background:var(--text);color:var(--bg);font-size:14px;font-weight:500;text-align:center;animation:toast-in .22s var(--ease)}
@keyframes toast-in{from{opacity:0;transform:translate(-50%,8px)}}
.toast.error{background:var(--bad);color:var(--bad-bg)}

/* ---------- motion ----------
 * Entrances are quick and soft, with only a hint of overshoot, and start from
 * the bubble's tail so a message feels spoken, not printed. Only NEW items animate ([data-fresh], set by the thread
 * renderer with a negative delay so a repaint mid-animation carries on instead
 * of restarting). Everyday controls stay under 300ms. Nothing loops except the
 * mascot's blink, and the one celebration is saved for "I posted it". */
.msg[data-fresh] .bubble,.msg[data-fresh] .draft{animation:pop-in .24s var(--spring) both;animation-delay:var(--age,0ms)}
.msg.them[data-fresh] .bubble,.msg.them[data-fresh] .draft{transform-origin:0 100%}
.msg.me[data-fresh] .bubble{transform-origin:100% 100%}
.event[data-fresh]{animation:fade-up .3s var(--ease) both;animation-delay:var(--age,0ms)}
@keyframes pop-in{from{opacity:0;transform:scale(.95) translateY(6px)}}
@keyframes fade-up{from{opacity:0;transform:translateY(6px)}}
/* a draft changing state: the footer slides in and the tick draws itself */
.draft[data-changed] .draft-state{animation:state-in .28s var(--ease) both;animation-delay:var(--age,0ms)}
.draft[data-changed] .draft-state svg path{stroke-dasharray:40;animation:draw .5s .12s var(--ease) both}
@keyframes state-in{from{opacity:0;transform:translateY(100%)}}
@keyframes draw{from{stroke-dashoffset:40}to{stroke-dashoffset:0}}
/* send: the arrow leaves, a new one arrives from below */
.send.sent svg{animation:whoosh .42s var(--ease)}
@keyframes whoosh{0%{transform:none}45%{transform:translateY(-34px) scale(.8);opacity:0}46%{transform:translateY(30px);opacity:0}100%{transform:none;opacity:1}}
/* list, chips and sheets */
.chat-row:active{transform:scale(.985)}
.chat-row{transition:background .12s,transform .14s var(--ease)}
body.booting .chat-row{animation:fade-up .28s var(--ease) both}
body.booting .chat-row:nth-child(2){animation-delay:30ms}body.booting .chat-row:nth-child(3){animation-delay:60ms}body.booting .chat-row:nth-child(n+4){animation-delay:90ms}
.chip{transition:background .15s,transform .14s var(--ease),border-color .15s}
.chip:hover{border-color:var(--brand)}
@keyframes float{50%{transform:translateY(-4px)}}
/* confetti: a dozen dots thrown from the button you pressed */
.confetti{position:fixed;z-index:80;width:6px;height:6px;border-radius:2px;pointer-events:none;animation:throw .6s var(--ease) forwards}
@keyframes throw{to{transform:translate(var(--dx),var(--dy)) rotate(var(--rot));opacity:0}}
/* ---------- the bots are alive ----------
 * This is where the personality lives. Every bot is a small character:
 *   idle      blinks, winks now and then, glances about, on its own beat
 *   pairs     the two bots of a group look at each other, then back at you
 *   watching  big faces follow your pointer (ui-fx.js moves .look)
 *   composing they look down at what you are writing
 *   nod       you sent something
 *   thinking  eyes roll up, head bobs, antenna pulses while a reply is coming
 *   talking   mouth moves and eyes squint as its message lands
 *   cheer     you approved or posted: a jump, blushing cheeks, happy eyes
 *   aww       you skipped a draft: a small sad shake
 *   sleepy    nobody has moved for a while: eyes close, z z z
 *   woke      you came back: a startled hop
 *   poke      tap a big face: boing, spin, wink or go shy, and it says hi
 * States are classes on #root (set in ui-fx.js) so they survive repaints.
 * The chrome around the bots stays calm, and reduced motion stops all of it. */
.avatar.face{overflow:visible;transition:transform .22s var(--spring)}
.avatar.face svg{width:100%;height:100%;overflow:visible}
.face .eye,.face .mouth,.face .top,.face .cheek{transform-box:fill-box;transform-origin:center}
.face .top{transform-origin:50% 100%}
.face .look{transition:transform .18s var(--ease)}
.face .cheek{fill:var(--bad);opacity:0;transition:opacity .25s}
.face .zz{font:700 8px var(--font);fill:currentColor;opacity:0}
/* idle */
.face .eye{animation:blink 5.200s infinite;animation-delay:var(--beat,0s)}
.face .eye:first-child{animation-name:blink-wink}
.face .eyes{animation:glance 9s infinite;animation-delay:var(--beat,0s)}
.face .top{animation:sway 7s ease-in-out infinite;animation-delay:var(--beat,0s)}
@keyframes blink{0%,45%,49%,100%{transform:none}47%{transform:scaleY(.12)}}
@keyframes blink-wink{0%,45%,49%,78%,84%,100%{transform:none}47%,81%{transform:scaleY(.12)}}
@keyframes glance{0%,62%,100%{transform:none}66%,76%{transform:translateX(1.600px)}82%,90%{transform:translateX(-1.600px)}}
@keyframes sway{0%,100%{transform:rotate(-4deg)}50%{transform:rotate(4deg)}}
/* pairs: the front two bots of a group check in with each other */
.avatar-pair .face:first-child .eyes{animation:peek-right 8s infinite}
.avatar-pair .face:last-child .eyes{animation:peek-left 8s infinite}
@keyframes peek-right{0%,40%,70%,100%{transform:none}46%,64%{transform:translate(2px,1.200px)}}
@keyframes peek-left{0%,40%,70%,100%{transform:none}46%,64%{transform:translate(-2px,-1.200px)}}
/* composing: they read along */
.composing .thread-title .face .eyes{animation:read 1.600s ease-in-out infinite}
@keyframes read{0%,100%{transform:translate(-1.400px,2px)}50%{transform:translate(1.400px,2px)}}
/* nod */
.nod .thread-title .avatar.face{animation:nod .6s var(--ease)}
@keyframes nod{0%,100%{transform:none}30%{transform:translateY(3px) rotate(4deg)}60%{transform:translateY(-1px)}}
/* thinking */
.thinking .avatar.face{animation:bob .9s ease-in-out infinite}
.thinking .avatar.face .eyes{animation:look-up .9s ease-in-out infinite}
.thinking .avatar.face .eye{animation:none}
.thinking .avatar.face .top{animation:ping .9s ease-in-out infinite}
@keyframes bob{50%{transform:translateY(-2px) rotate(-3deg)}}
@keyframes look-up{0%,100%{transform:translate(0,-1.600px)}50%{transform:translate(1.200px,-2.400px)}}
@keyframes ping{50%{transform:scale(1.25) rotate(8deg)}}
/* talking: a message lands */
.msg[data-fresh] .avatar.face .eye{animation:squint .7s var(--ease) both;animation-delay:var(--age,0ms)}
.msg[data-fresh] .avatar.face .mouth{animation:talk .8s ease-in-out both;animation-delay:var(--age,0ms)}
.msg[data-fresh] .avatar.face{animation:lean .6s var(--spring) both;animation-delay:var(--age,0ms)}
@keyframes squint{0%,100%{transform:none}35%,65%{transform:scaleY(.3)}}
@keyframes talk{0%,100%{transform:none}20%,60%{transform:scaleY(1.700)}40%,80%{transform:scaleY(.6)}}
@keyframes lean{0%{transform:scale(.7)}60%{transform:scale(1.1) rotate(6deg)}100%{transform:none}}
/* cheer */
.cheer .thread-head .avatar.face,.cheer .thread-log .avatar.face{animation:jump .7s var(--spring) 2}
.cheer .face .cheek{opacity:.7}
.cheer .face .eye{animation:none;transform:scaleY(.28) translateY(-2px)}
.cheer .face .mouth{transform:scale(1.400)}
@keyframes jump{0%,100%{transform:none}40%{transform:translateY(-7px) rotate(-8deg) scale(1.08)}70%{transform:translateY(0) rotate(6deg)}}
/* aww */
.aww .thread-head .avatar.face,.aww .thread-log .avatar.face{animation:shake .5s ease-in-out 2}
.aww .face .eyes{animation:none;transform:translateY(2px)}
.aww .face .mouth{transform:scaleY(-1) translateY(-1px)}
.aww .face .top{animation:none;transform:rotate(-24deg)}
@keyframes shake{0%,100%{transform:none}25%{transform:translateX(-2px) rotate(-4deg)}75%{transform:translateX(2px) rotate(4deg)}}
/* sleepy and woke */
.sleepy .face .eye{animation:none;transform:scaleY(.12)}
.sleepy .face .eyes{animation:none}
.sleepy .face .top{animation:none;transform:rotate(-20deg)}
.sleepy .avatar.face{animation:snooze 3.600s ease-in-out infinite}
.sleepy .face .zz{animation:zz 2.400s ease-out infinite}
.sleepy .face .zz2{animation-delay:1.200s}
@keyframes snooze{50%{transform:translateY(1.500px) rotate(3deg)}}
@keyframes zz{0%{opacity:0;transform:translate(-4px,6px) scale(.6)}30%{opacity:.9}100%{opacity:0;transform:translate(4px,-6px) scale(1.200)}}
.woke .avatar.face{animation:startle .6s var(--spring)}
.woke .face .eye{animation:none;transform:scale(1.350)}
@keyframes startle{0%{transform:none}35%{transform:translateY(-6px) scale(1.1)}100%{transform:none}}
/* hello when a chat opens, and perk up on hover */
.view-enter .thread-title .avatar.face,.poke .avatar.face{animation:hello .9s var(--spring) .1s both}
@keyframes hello{0%{transform:scale(.8) rotate(0)}35%{transform:scale(1.06) rotate(-12deg)}65%{transform:rotate(9deg)}100%{transform:none}}
@media(hover:hover){.chat-row:hover .avatar.face,.row:hover .avatar.face{transform:translateY(-2px) rotate(-6deg)}.chat-row:hover .face .cheek,.poke:hover .face .cheek{opacity:.6}.chat-row:hover .face .eye{animation-duration:1.400s}}
/* poke */
.poke{position:relative;display:inline-flex;border-radius:50%;cursor:pointer}
.poke:active{transform:scale(.94)}
.poke.boing .avatar,.poke.boing .mascot{animation:boing .8s var(--spring)}
.poke.spin .avatar,.poke.spin .mascot{animation:spin .8s var(--ease)}
.poke.shy .avatar,.poke.shy .mascot{animation:shy .9s var(--ease)}
.poke.shy .face .cheek,.poke.boing .face .cheek{opacity:.8}
.poke.shy .face .eyes{animation:none;transform:translate(-2px,2px)}
.poke.wink .face .eye:first-child{animation:none;transform:scaleY(.12)}
.poke.wink .face .mouth{transform:scale(1.300)}
@keyframes boing{0%,100%{transform:none}25%{transform:scale(1.18,.84)}50%{transform:scale(.9,1.14) translateY(-8px)}75%{transform:scale(1.06,.96)}}
@keyframes spin{to{transform:rotate(360deg)}}
@keyframes shy{0%,100%{transform:none}40%,70%{transform:rotate(-10deg) translateX(-3px) scale(.96)}}
.poke-say{position:absolute;left:62%;bottom:78%;padding:3px 9px;border-radius:12px 12px 12px 3px;background:var(--brand);color:var(--on-brand);font-size:13px;font-weight:600;white-space:nowrap;pointer-events:none;animation:say 1.100s var(--ease) forwards}
@keyframes say{0%{opacity:0;transform:translateY(6px) scale(.7)}20%{opacity:1;transform:none}75%{opacity:1}100%{opacity:0;transform:translateY(-10px)}}
/* the home-screen mascot */
.mascot{width:88px;height:88px;color:var(--brand);animation:float 5s ease-in-out infinite}
.mascot .antenna{transform-box:fill-box;transform-origin:50% 100%;animation:wiggle 6s ease-in-out infinite}
.mascot .cheek{fill:var(--bad);opacity:.5}
.mascot rect.face{fill:var(--bg)}
@keyframes wiggle{0%,80%,100%{transform:none}85%{transform:rotate(-10deg)}92%{transform:rotate(10deg)}}
/* theme picker */
.themes{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:10px;padding:14px}
.theme{display:flex;flex-direction:column;gap:3px;padding:12px;border-radius:16px;border:2px solid var(--line);background:var(--raised);font-size:14px;transition:border-color .15s}
.theme strong{font-weight:600;margin-top:6px}.theme small{color:var(--muted);font-size:12px}
.theme.on{border-color:var(--brand)}
.theme-dots{display:flex;gap:6px}
.theme-dots i{width:20px;height:20px;border-radius:50%;box-shadow:0 0 0 1px var(--line)}

/* ---------- narrower desktop: the info panel floats over the thread ---------- */
@media(max-width:1180px){
  body.has-info .app{grid-template-columns:var(--list-w) minmax(0,1fr)}
  .pane-info{position:fixed;inset:0 0 0 auto;z-index:30;width:min(var(--info-w),100%);background:var(--bg);animation:slide-in .24s var(--ease)}
}
@keyframes slide-in{from{transform:translateX(24px);opacity:0}}

/* ---------- phone: one pane at a time, like a messenger ---------- */
@media(max-width:850px){
  .app{display:block}
  .pane{position:fixed;inset:0;width:100%;border:0;background:var(--bg)}
  body[data-pane="list"] .pane-main,body[data-pane="main"] .pane-list,body[data-pane="info"] .pane-list{display:none}
  body[data-pane="main"] .pane-main,body[data-pane="info"] .pane-info{animation:slide-in .22s var(--ease)}
  .pane-info{z-index:30;width:100%}
  .thread-head .back{display:inline-flex;margin-left:-8px}
  .thread-head{padding-left:10px}
  .list-head .new-chat{display:none}
  .fab{position:absolute;right:18px;bottom:calc(64px + env(safe-area-inset-bottom));z-index:5;display:inline-flex;align-items:center;justify-content:center;width:58px;height:58px;border-radius:20px;background:var(--brand);color:var(--on-brand);box-shadow:0 8px 24px var(--shade);transition:transform .14s var(--ease)}
  .bubble{max-width:84%}.bubble.card,.draft{width:min(92%,460px)}
  .modal-layer{align-items:flex-end;padding:0}
  .sheet{max-width:none;border-radius:24px 24px 0 0;padding:10px 16px calc(18px + env(safe-area-inset-bottom))}
  .sheet-grip{display:block;width:38px;height:4px;margin:0 auto 12px;border-radius:2px;background:var(--control)}
  .command-layer{padding:10px}
  /* on a phone the bottom belongs to the composer, so notices drop in under the header */
  .toast{top:calc(74px + env(safe-area-inset-top));bottom:auto}
}
@media(max-width:500px){
  .form-grid{grid-template-columns:1fr}
  .list-head h1{font-size:30px}
}
@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}
}
