:root{
  --ink:#14201f; --muted:#465855; --line:#dfe7e5;
  --bg:#f2f5f4; --card:#ffffff;
  --accent:#0b3b39; --accent-ink:#ffffff;
  --bubble-me:#0b3b39; --bubble-me-ink:#fff;
  --bubble-them:#ffffff;
  --danger:#b3261e; --ok:#1e7e34; --warn:#9a6700;
  --radius:14px; --safe-b:env(safe-area-inset-bottom,0px);
}
.learning-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
#learningBody{max-width:960px;margin:0 auto}
.learning-heading h2{font-size:22px;margin:0}
.learning-stats{display:flex;gap:20px;flex-wrap:wrap;margin:18px 0;font-size:13px;color:var(--muted)}
.learning-stats strong{display:block;font-size:24px;color:var(--ink)}
.learning-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:16px}
.learning-actions button{min-height:44px;flex:1}
.memory-card h3{margin-top:12px;line-height:1.45;overflow-wrap:anywhere}
.memory-card p,.learning-summary p{font-size:14px;line-height:1.55}
.memory-card blockquote{border-left:3px solid var(--line);padding:8px 12px;margin:12px 0;white-space:pre-wrap;overflow-wrap:anywhere;font-size:14px}
.memory-card summary,.memory-used summary,#learningContent summary{cursor:pointer;padding:12px 0;color:var(--muted);font-size:13px}
.memory-source{font-size:13px;max-width:100%;overflow-wrap:anywhere}
.learning-report{white-space:pre-wrap;overflow-wrap:anywhere;font:inherit;font-size:13px;line-height:1.55}
.learning-check{display:flex;align-items:flex-start;gap:10px;margin:16px 0;line-height:1.5}
#learningBudget{background:var(--card);color:var(--ink);border:1px solid var(--line);border-radius:10px;padding:12px;width:100%;font:inherit}
.learning-event{font-size:14px;border-bottom:1px solid var(--line);padding-bottom:12px;overflow-wrap:anywhere}
.learning-event:last-child{border-bottom:0}
.answer-feedback{display:flex;align-items:center;flex-wrap:wrap;gap:4px;margin-top:12px;border-top:1px solid var(--line);padding-top:4px}
.answer-feedback button{background:transparent;color:var(--muted);border:1px solid transparent;border-radius:9px;min-height:40px;min-width:40px;padding:7px;cursor:pointer;font-size:13px}
.answer-feedback button.selected{background:var(--bg);border-color:var(--accent);color:var(--ink)}
.memory-used{font-size:12px}.memory-used ul{padding-left:18px;white-space:normal}
@media(max-width:380px){#tabbar .tab{font-size:12px;padding-left:6px;padding-right:6px}.learning-actions button{padding:10px}}
@media (prefers-color-scheme:dark){
  :root{
    --ink:#e8efed; --muted:#9db3b0; --line:#27403d;
    --bg:#0e1514; --card:#16211f;
    --accent:#7fd1c7; --accent-ink:#062825;
    --bubble-me:#7fd1c7; --bubble-me-ink:#062825;
    --bubble-them:#16211f;
  }
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
[hidden]{display:none!important}
html{
  height:100%;
  height:100svh;
  overflow:hidden;
}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  font-size:16px; line-height:1.45;
  display:flex; flex-direction:column;
  position:fixed; left:0; right:0; width:100%;
  top:var(--vv-top, 0px);
  height:var(--app-h, 100svh);
  max-height:var(--app-h, 100svh);
  overflow:hidden;
}
#topbar{
  display:flex; align-items:center; gap:8px;
  padding:10px 12px; background:var(--card);
  border-bottom:1px solid var(--line);
  padding-top:calc(10px + env(safe-area-inset-top,0px));
  min-height:60px;
  flex:none;
}
#titleWrap{flex:1; min-width:0}
#viewTitle{margin:0; font-size:19px; font-weight:700; white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis}
#viewSub{margin:0; font-size:12.5px; color:var(--muted); white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis}
.iconbtn{
  min-width:44px; min-height:44px; border:0; background:transparent;
  color:var(--ink); font-size:26px; line-height:1; border-radius:12px;
  display:flex; align-items:center; justify-content:center; cursor:pointer;
}
#views{flex:1 1 auto; min-height:0; overflow:hidden; position:relative; display:flex}
.view{flex:1; min-height:0; overflow-y:auto; padding:14px 14px 24px; width:100%;
  -webkit-overflow-scrolling:touch}
.view[hidden]{display:none}
#view-projects,#view-chats,#view-bots,#view-loops,#view-learning{
  padding-bottom:calc(88px + var(--safe-b));
}
.stack{display:flex; flex-direction:column; gap:12px}
.card{
  background:var(--card); border:1px solid var(--line); border-radius:var(--radius);
  padding:14px; width:100%; text-align:left; font:inherit; color:inherit;
  cursor:pointer;
}
.card:active{transform:scale(.995)}
.card h3{margin:0 0 4px; font-size:17px}
.card .row{display:flex; align-items:center; gap:8px; margin-top:8px;
  font-size:13px; color:var(--muted)}
.card .grow{flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis;
  white-space:nowrap}
.center{max-width:420px; margin:8vh auto 0; text-align:center}
.muted{color:var(--muted)}
.error{color:var(--danger)}
.empty{text-align:center; color:var(--muted); margin-top:12vh}
input[type=password],input[type=text],textarea,select{
  font:inherit; color:var(--ink); background:var(--card);
  border:1px solid var(--line); border-radius:12px; padding:13px 14px; width:100%;
}
button{font:inherit}
.primary{background:var(--accent); color:var(--accent-ink); border:0;
  border-radius:12px; padding:12px 18px; font-weight:700; cursor:pointer}
.primary:disabled{opacity:.5}
.big{width:100%; margin-top:12px; min-height:50px}
.ghost{background:transparent; border:1px solid var(--line); color:var(--ink);
  border-radius:12px; padding:12px 18px; cursor:pointer}
.fab{
  position:fixed; right:18px; bottom:calc(104px + var(--safe-b));
  width:60px; height:60px; border-radius:50%; border:0;
  background:var(--accent); color:var(--accent-ink);
  font-size:32px; line-height:1; cursor:pointer;
  box-shadow:0 4px 16px rgba(0,0,0,.25);
}
.dot{width:12px; height:12px; border-radius:50%; display:inline-block;
  flex:none}
.dot.green{background:var(--ok)} .dot.yellow{background:var(--warn)}
.dot.red{background:var(--danger)} .dot.gray{background:#9aa5a3}
.statusdot{width:10px; height:10px; border-radius:50%; flex:none}
.statusdot.running{background:var(--accent); animation:blink 1s infinite alternate}
.statusdot.idle{background:#9aa5a3}
@keyframes blink{to{opacity:.35}}
@media (prefers-reduced-motion:reduce){
  .statusdot.running{animation:none} .pulse{animation:none}
}
.chips{display:flex; gap:8px; flex-wrap:wrap; margin-bottom:10px}
.chip{font-size:12.5px; padding:5px 11px; border-radius:999px;
  border:1px solid var(--line); background:var(--card); color:var(--muted);
  cursor:pointer; min-height:44px}
button:active,.card:active,.optcard:active{filter:brightness(.93)}
.primary:active,.fab:active,.round:active{filter:brightness(1.12)}
input:focus-visible,textarea:focus-visible,select:focus-visible,button:focus-visible{
  outline:3px solid var(--accent); outline-offset:1px}
textarea:disabled,input:disabled{opacity:.6}
.primary:disabled{opacity:.45}
.chip.on{background:var(--accent); color:var(--accent-ink); border-color:transparent}
.msgs{display:flex; flex-direction:column; gap:10px; padding-bottom:8px}
.msg{max-width:88%; padding:10px 13px; border-radius:16px; font-size:15.5px;
  overflow-wrap:anywhere; white-space:pre-wrap}
.msg.user{align-self:flex-end; background:var(--bubble-me); color:var(--bubble-me-ink);
  border-bottom-right-radius:6px}
.msg.bot{align-self:flex-start; background:var(--bubble-them);
  border:1px solid var(--line); border-bottom-left-radius:6px}
.msg code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  font-size:.88em; background:rgba(127,127,127,.16); border-radius:6px;
  padding:1px 5px}
.msg pre{margin:8px 0 2px; padding:10px 12px; border-radius:10px;
  background:rgba(127,127,127,.14); overflow-x:auto}
.msg pre code{background:transparent; padding:0; white-space:pre-wrap;
  overflow-wrap:anywhere}
.msg .tools{font-size:12.5px; color:var(--muted); margin-top:6px}
.msg .meta{font-size:11.5px; color:var(--muted); margin-top:6px}
.typing{display:flex; align-items:center; gap:8px; padding:6px 2px 10px;
  color:var(--muted); font-size:14px}
.pulse{width:10px; height:10px; border-radius:50%; background:var(--accent);
  animation:blink .8s infinite alternate}
.stop{margin-left:auto; border:1px solid var(--danger); color:var(--danger);
  background:transparent; border-radius:999px; padding:8px 16px; font-weight:700}
.chatview{display:flex; flex-direction:column; overflow:hidden; padding-bottom:0}
.chatview .msgs{flex:1 1 auto; min-height:0; overflow-y:auto; padding-bottom:8px}
.chatview .chips,.chatview .typing,.chatview .attachrow{flex:none}
#view-tasks{display:flex; flex-direction:column; overflow:hidden; padding-bottom:0}
#view-tasks > .seg{
  flex:none; flex-shrink:0; position:relative; z-index:2;
  background:var(--bg); min-height:52px; align-items:center;
}
#taskList{flex:1 1 auto; min-height:0; overflow-y:auto}
#view-tasks .composer,#view-tasks #noTasks{flex:none}
.composer{
  display:flex; gap:8px; align-items:flex-end; padding:10px 0 10px;
  position:relative; background:var(--bg); flex:none;
}
.composer textarea{flex:1; resize:none; max-height:140px; min-height:48px}
.tobottom{
  position:fixed; bottom:calc(96px + var(--safe-b)); left:50%;
  transform:translateX(-50%);
  width:56px; height:56px; border-radius:50%; border:0; margin:0;
  background:var(--accent); color:var(--accent-ink);
  font-size:24px; line-height:1; cursor:pointer; z-index:5;
  box-shadow:0 4px 16px rgba(0,0,0,.25);
  display:flex; align-items:center; justify-content:center;
}
.tobottom[hidden]{display:none}
.round{width:48px; height:48px; border-radius:50%; padding:0; font-size:22px; flex:none}
.composer .ghost.round{display:flex; align-items:center; justify-content:center; color:var(--muted)}
.composer .ghost.round:disabled{opacity:.45}
.attachrow{display:flex; gap:8px; overflow-x:auto; padding:10px 2px 0}
.attachrow[hidden]{display:none}
.thumb{position:relative; flex:none; width:72px; height:72px}
.thumb img{width:72px; height:72px; object-fit:cover; border-radius:10px;
  border:1px solid var(--line); display:block}
.thumb.uploading img{opacity:.45}
.thumbx{position:absolute; top:-7px; right:-7px; width:22px; height:22px;
  border-radius:50%; background:var(--card); border:1px solid var(--line);
  font-size:11px; line-height:1; padding:0}
.msg .shots{display:flex; flex-wrap:wrap; gap:6px; margin-top:8px}
.msg .shots img{max-width:min(220px, 60vw); max-height:220px; border-radius:10px;
  border:1px solid var(--line); display:block}
#sheetWrap{position:fixed; inset:0; z-index:20}
#sheetWrap[hidden]{display:none}
#sheetBackdrop{position:absolute; inset:0; background:rgba(0,0,0,.45)}
#sheet{
  position:absolute; left:0; right:0; bottom:0; background:var(--card);
  border-radius:20px 20px 0 0; padding:8px 18px calc(18px + var(--safe-b));
  max-height:88dvh; overflow-y:auto;
}
.grab{width:44px; height:5px; border-radius:3px; background:var(--line); margin:6px auto 10px}
.sheethead{display:flex; align-items:center; gap:8px}
.sheethead h2{flex:1}
#sheetX{font-size:18px}
#sheet:has(#asstHist){display:flex; flex-direction:column; height:88dvh; overflow:hidden}
#sheet:has(#asstHist) #sheetBody{display:flex; flex-direction:column; flex:1; min-height:0}
#sheet:has(#asstHist) #sheetBody > :not(#asstHist){flex-shrink:0}
#asstHist{flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain}
#asstHist .msg{flex-shrink:0}
#asstForm{position:static}
#sheet h2{margin:4px 0 12px; font-size:19px}
#sheet label{display:block; font-size:13.5px; font-weight:700; margin:14px 0 6px}
#sheet select{margin-bottom:2px}
.seg{display:flex; gap:8px; overflow-x:auto; padding:4px 0 8px;
  -webkit-overflow-scrolling:touch}
.seg button{flex:none; min-height:44px; padding:8px 14px; border-radius:999px;
  border:1px solid var(--line); background:transparent; color:var(--ink)}
.seg button.on{background:var(--accent); color:var(--accent-ink); border-color:transparent}
.optcard{border:1px solid var(--line); border-radius:12px; padding:12px; margin:6px 0;
  display:flex; gap:10px; align-items:center; cursor:pointer; min-height:56px}
.optcard.on{border:2px solid var(--accent); padding:11px}
.optcard small{display:block; color:var(--muted)}
.optcard.disabled{opacity:.5}
.sheetrow{display:flex; gap:10px; margin-top:16px}
.sheetrow .big{margin-top:0}
.healthrow{display:flex; align-items:center; gap:10px; padding:11px 2px;
  border-bottom:1px solid var(--line); font-size:14.5px}
.healthrow .grow{flex:1; min-width:0}
.healthrow small{display:block; color:var(--muted); font-size:12.5px}
.updatebtn{flex:none; min-height:44px; border:0; border-radius:999px;
  background:var(--accent); color:var(--accent-ink); font-weight:700;
  padding:8px 16px; font-size:14px; cursor:pointer}
.updatebtn:disabled{opacity:.6}
#toast{
  position:fixed; left:50%; transform:translateX(-50%);
  bottom:calc(90px + var(--safe-b)); background:var(--ink); color:var(--bg);
  padding:10px 18px; border-radius:999px; font-size:14px; z-index:30;
  max-width:90vw; text-align:center;
}
#toast[hidden]{display:none}
.delrow{display:flex; gap:8px; align-items:center}
.delrow .card{flex:1}
.swipewrap{position:relative; overflow:hidden; border-radius:var(--radius)}
.swipebg{position:absolute; inset:0; display:flex; align-items:center;
  padding:0 16px; background:var(--accent); color:var(--accent-ink);
  font-weight:700; font-size:15px}
.swipefg{position:relative; background:var(--bg); transition:transform .18s ease;
  touch-action:pan-y}
@media (prefers-reduced-motion:reduce){
  .swipefg{transition:none}
}
.delbtn{flex:none; min-width:48px; min-height:48px; border-radius:12px;
  border:1px solid var(--line); background:transparent; color:var(--danger);
  font-size:18px}
#tabbar{display:flex; gap:4px; padding:8px 12px calc(8px + var(--safe-b));
  background:var(--card); border-top:1px solid var(--line); flex:none}
#tabbar[hidden]{display:none}
body.kb-open #tabbar{display:none}
body.kb-open .fab,body.kb-open .traychip{visibility:hidden; pointer-events:none}
body.kb-open .composer{padding-bottom:10px}
.tab{flex:1; min-height:48px; border:0; border-radius:12px; background:transparent;
  color:var(--muted); font-weight:700; font-size:15px}
.tab.on{background:var(--accent); color:var(--accent-ink)}
.taskrow{display:flex; align-items:center; gap:8px; min-width:0}
.taskrow .card{flex:1; min-width:0; width:auto; display:flex; gap:10px; align-items:center}
.delrow{min-width:0}
.delrow .card{width:auto; min-width:0}
.donebtn{flex:none; width:44px; height:44px; border-radius:50%;
  border:2px solid var(--accent); background:transparent; color:transparent;
  font-size:20px; line-height:1}
.donebtn.done{background:var(--accent); color:var(--accent-ink)}
.taskrow .tt{flex:1; min-width:0; overflow-wrap:anywhere}
.taskrow .tt strong{overflow-wrap:anywhere}
.taskrow .tt small{display:block; color:var(--muted)}
.taskrow .card .ghost{flex:none; white-space:nowrap; min-height:44px;
  display:flex; align-items:center}
.grip{flex:none; min-width:44px; min-height:44px; border:0; background:transparent;
  color:var(--muted); border-radius:9px; font-size:20px; cursor:grab; touch-action:none}
.grip:active{cursor:grabbing}
.taskrow.dragging{opacity:.6}
.taskrow.dragging .card{box-shadow:0 8px 24px rgba(0,0,0,.25)}
@media(max-width:480px){
  .view{padding-left:10px; padding-right:10px}
  .taskrow{gap:6px}
  .taskrow .card{gap:8px; padding:12px; flex-wrap:wrap}
  .taskrow .tt{flex:1 1 100%; order:3}
  .taskrow .card .ghost{margin-left:auto}
  .grip{min-width:32px; width:32px; font-size:16px}
  .donebtn{width:40px; height:40px}
  .delbtn{min-width:44px}
  body[data-view="tasks"] .fab{bottom:calc(172px + var(--safe-b))}
}
.loopcard .grow{white-space:normal}
.srvtag{flex:none; font-size:12px; font-weight:700; padding:3px 10px;
  border-radius:999px; background:var(--accent); color:var(--accent-ink)}
.traychip{position:fixed; left:50%; transform:translateX(-50%);
  bottom:calc(90px + var(--safe-b)); z-index:15;
  background:var(--accent); color:var(--accent-ink);
  border:0; border-radius:999px; padding:12px 20px;
  font:inherit; font-weight:700; font-size:14px;
  box-shadow:0 4px 16px rgba(0,0,0,.25); cursor:pointer}
.traychip[hidden]{display:none}
#annotateWrap{position:fixed; inset:0; z-index:40; background:var(--bg);
  display:flex; flex-direction:column}
#annotateWrap[hidden]{display:none}
.annbar{display:flex; align-items:center; gap:8px; padding:10px 12px;
  padding-top:calc(10px + env(safe-area-inset-top,0px));
  background:var(--card); border-bottom:1px solid var(--line)}
#annTitle{flex:1; text-align:center; font-weight:700; font-size:15px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.annstage{flex:1; overflow:auto; display:flex; align-items:center;
  justify-content:center; padding:12px; touch-action:none}
#annCanvas{max-width:100%; max-height:100%; border-radius:10px;
  background:#000; touch-action:none}
.anntools{display:flex; align-items:center; gap:10px; padding:10px 12px;
  padding-bottom:calc(10px + var(--safe-b));
  background:var(--card); border-top:1px solid var(--line); flex-wrap:wrap}
.anngroup{display:flex; gap:6px}
.annswatch{width:40px; height:40px; border-radius:50%; border:3px solid transparent;
  cursor:pointer; padding:0}
.annswatch.on{border-color:var(--ink)}
.annwidth{min-width:44px; min-height:44px; border-radius:10px;
  border:1px solid var(--line); background:transparent; color:var(--ink);
  font:inherit; font-weight:700; cursor:pointer}
.annwidth.on{background:var(--accent); color:var(--accent-ink); border-color:transparent}
/* Spend panels stay readable on narrow screens. */
.spend-total { font-size: 1.5rem; font-weight: 700; margin-top: 12px; }
.spend-grid { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.spend-grid dd { margin: 0; font-variant-numeric: tabular-nums; }
.spend-notice { border-left: 3px solid #df9d39; padding: 8px 12px; }
.spend-table { width: 100%; text-align: left; font-size: .9rem; }
.spend-table td, .spend-table th { padding: 8px 2px; }
.spend-request { padding: 10px 0; border-bottom: 1px solid #8884; overflow-wrap: anywhere; }
#botUsdBudget, #botRunBudget, #defaultUsdBudget { display: block; width: 100%; box-sizing: border-box; min-height: 48px; padding: 10px 12px; border: 1px solid #7895; border-radius: 12px; background: transparent; color: inherit; font: inherit; margin: 8px 0 16px; }
