/* TeamBots web UI. Dark by default, light when the system or the person asks for it.
   Colours and shapes follow the TeamBots reference UI. */
:root {
  --bg:#0c0c0d; --side:#111112; --s1:#19191b; --s2:#222225; --s3:#2e2e32; --line:#27272a;
  --ink:#ededee; --ink2:#b9b9be; --muted:#85858b; --btn:#f2f2f2; --btn-ink:#0c0c0d;
  --tok:#8ab8ff; --tok-bg:rgba(110,168,255,.15); --ok:#4cc38a; --bad:#ff6369; --warn:#f5b84b;
  --shadow:0 12px 40px rgba(0,0,0,.55); --sans:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace; color-scheme:dark;
}
@media (prefers-color-scheme: light) { :root:not([data-theme=dark]) {
  --bg:#fff; --side:#f8f8f7; --s1:#f3f3f2; --s2:#eaeae8; --s3:#dcdcd9; --line:#e6e6e3;
  --ink:#141414; --ink2:#3f3f42; --muted:#74747a; --btn:#141414; --btn-ink:#fff;
  --tok:#1557c0; --tok-bg:rgba(21,87,192,.10); --ok:#18794e; --bad:#cd2b31; --warn:#8a6100;
  --shadow:0 12px 40px rgba(0,0,0,.14); color-scheme:light; } }
:root[data-theme=light] {
  --bg:#fff; --side:#f8f8f7; --s1:#f3f3f2; --s2:#eaeae8; --s3:#dcdcd9; --line:#e6e6e3;
  --ink:#141414; --ink2:#3f3f42; --muted:#74747a; --btn:#141414; --btn-ink:#fff;
  --tok:#1557c0; --tok-bg:rgba(21,87,192,.10); --ok:#18794e; --bad:#cd2b31; --warn:#8a6100;
  --shadow:0 12px 40px rgba(0,0,0,.14); color-scheme:light; }

* { box-sizing:border-box; }
[hidden] { display:none !important; }
html, body, #root { height:100%; }
body { margin:0; font:15px/1.55 var(--sans); background:var(--bg); color:var(--ink); -webkit-font-smoothing:antialiased; overflow:hidden; }
button, input, select, textarea { font:inherit; color:inherit; }
button { cursor:pointer; background:none; border:0; padding:0; }
button:disabled { cursor:default; opacity:.45; }
a { color:var(--tok); text-decoration:none; } a:hover { text-decoration:underline; }
:focus-visible { outline:2px solid var(--tok); outline-offset:2px; }
.muted { color:var(--muted); } .mono { font-family:var(--mono); font-size:.9em; }
.grow { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
* { scrollbar-width:thin; scrollbar-color:var(--s3) transparent; }

.btn { display:inline-flex; align-items:center; gap:7px; height:36px; padding:0 14px; border-radius:999px; border:1px solid var(--line); background:transparent; font-size:14px; font-weight:500; white-space:nowrap; }
.btn:hover:not(:disabled) { background:var(--s2); }
.btn.primary { background:var(--btn); color:var(--btn-ink); border-color:var(--btn); }
.btn.primary:hover:not(:disabled) { opacity:.88; background:var(--btn); }
.btn.danger { color:var(--bad); }
.btn.sm { height:30px; padding:0 11px; font-size:13px; }
.ib { width:32px; height:32px; border-radius:9px; display:inline-grid; place-items:center; color:var(--ink2); flex:none; }
.ib:hover { background:var(--s2); color:var(--ink); }
input:not([type=checkbox]), select, textarea { width:100%; background:var(--s1); border:1px solid var(--line); border-radius:11px; padding:9px 12px; outline:0; }
input:not([type=checkbox]):focus, select:focus, textarea:focus { border-color:var(--s3); box-shadow:0 0 0 3px var(--s2); }
textarea { resize:vertical; min-height:42px; }
input[type=checkbox] { width:16px; height:16px; accent-color:var(--btn); flex:none; }
.field { display:block; margin:0 0 14px; }
.field > span { display:block; font-size:13px; color:var(--ink2); margin-bottom:6px; }
.field small, .check small { display:block; color:var(--muted); font-size:12.5px; margin-top:5px; line-height:1.4; }
.check { display:flex; gap:10px; align-items:flex-start; margin:0 0 14px; cursor:pointer; }
.check input { margin-top:3px; }
.check.off { cursor:default; opacity:.6; }
.tag { font-size:11.5px; color:var(--muted); border:1px solid var(--line); border-radius:99px; padding:1px 8px; white-space:nowrap; }
.tag.ok { color:var(--ok); } .tag.warn { color:var(--warn); }
.field small.warnnote, small.warnnote { display:block; color:var(--warn); font-size:12.5px; margin-top:5px; }
.av { width:26px; height:26px; border-radius:50%; background:var(--s2); display:inline-grid; place-items:center; font-size:12px; font-weight:600; flex:none; color:var(--ink2); text-transform:uppercase; }
.av.bot { border-radius:8px; background:var(--btn); color:var(--btn-ink); }
.logo { width:30px; height:30px; border-radius:9px; flex:none; }

/* sign in */
#auth { height:100%; display:grid; place-items:center; padding:20px; overflow:auto; }
.authbox { width:100%; max-width:360px; }
.authbox h1 { font-size:26px; font-weight:600; letter-spacing:-.02em; margin:18px 0 4px; }
.authbox p { color:var(--muted); margin:0 0 22px; }
.authbox .btn { width:100%; justify-content:center; height:42px; margin-top:4px; }
.authsep { display:flex; align-items:center; gap:10px; margin:16px 0 10px; color:var(--muted); font-size:12.5px; }
.authsep::before, .authsep::after { content:""; flex:1; height:1px; background:var(--line); }

/* shell */
#app { height:100%; display:flex; }
#side { width:264px; flex:none; background:var(--side); border-right:1px solid var(--line); display:flex; flex-direction:column; padding:10px 8px 8px; min-height:0; }
.brand { display:flex; align-items:center; gap:10px; padding:2px 4px 10px 6px; }
.brand strong { flex:1; font-size:15.5px; letter-spacing:-.01em; }
.nav, .item, .project, .me { display:flex; align-items:center; gap:10px; width:100%; text-align:left; border-radius:10px; padding:7px 9px; color:var(--ink2); font-size:14px; min-height:36px; }
.nav:hover, .item:hover, .project:hover, .me:hover { background:var(--s1); color:var(--ink); }
.nav.on, .item.on { background:var(--s2); color:var(--ink); }
.project { margin:8px 0 2px; border:1px solid var(--line); padding:8px 10px; }
.project .pname { flex:1; min-width:0; display:flex; flex-direction:column; line-height:1.25; }
.project small { color:var(--muted); font-size:11.5px; } .project b { font-weight:550; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.project.on { border-color:var(--s3); background:var(--s1); }
#side .scroll { flex:1; overflow-y:auto; min-height:0; margin:0 -4px; padding:0 4px; }
.sec { display:flex; align-items:center; justify-content:space-between; font-size:12px; color:var(--muted); padding:14px 9px 4px; }
.sec .ib { width:24px; height:24px; border-radius:7px; }
.item { cursor:pointer; padding:5px 9px; }
.item .lead { width:22px; display:grid; place-items:center; color:var(--muted); flex:none; }
.item .more { width:22px; height:22px; font-size:14px; opacity:0; }
.item:hover .more, .item.on .more, .item .more:focus { opacity:1; }
@media (hover:none) { .item .more { opacity:1; } }
.item.archived .grow { color:var(--muted); }
.archtoggle { font-size:12.5px; color:var(--muted); }
.archnote { display:flex; align-items:center; gap:12px; background:var(--s1); border:1px solid var(--line); border-radius:16px; padding:10px 10px 10px 16px; font-size:13.5px; color:var(--ink2); }
.emptyhint { font-size:12.5px; color:var(--muted); padding:2px 9px 4px; }
.me { margin-top:6px; }

#main { flex:1; min-width:0; display:flex; flex-direction:column; position:relative; }
#top { height:54px; flex:none; display:flex; align-items:center; gap:10px; padding:0 14px; border-bottom:1px solid var(--line); }
#top .title { font-weight:600; font-size:15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#top .sub { color:var(--muted); font-size:13px; }
#menuBtn { display:none; }
#view { flex:1; overflow-y:auto; overflow-x:hidden; min-height:0; }
#col { max-width:780px; margin:0 auto; padding:8px 20px 28px; }
#dock { flex:none; padding:0 20px 18px; position:relative; }
#dock > * { max-width:780px; margin-left:auto; margin-right:auto; }

/* composer */
.composer { position:relative; background:var(--s1); border:1px solid var(--line); border-radius:22px; padding:8px; }
.composer:focus-within { border-color:var(--s3); }
.composer textarea { border:0; background:transparent; box-shadow:none !important; resize:none; min-height:24px; max-height:220px; padding:4px 10px; }
.crow { display:flex; align-items:center; gap:6px; padding:2px 2px 0 4px; }
.crow .hint { font-size:12.5px; color:var(--muted); flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cbtn { height:34px; min-width:34px; padding:0 9px; border-radius:99px; border:1px solid var(--line); display:inline-flex; align-items:center; justify-content:center; gap:6px; color:var(--ink2); font-size:13px; }
.cbtn:hover { background:var(--s2); color:var(--ink); }
.cbtn.stop { color:var(--bad); }
.send { width:36px; height:36px; border-radius:50%; background:var(--btn); color:var(--btn-ink); display:grid; place-items:center; flex:none; font-size:18px; }
.send:disabled { background:var(--s3); color:var(--muted); opacity:1; }
.composer.drop { border-color:var(--tok); }
.mmenu { position:absolute; left:0; bottom:calc(100% + 8px); width:min(420px, 100%); max-height:300px; overflow-y:auto; background:var(--s1); border:1px solid var(--line); border-radius:14px; box-shadow:var(--shadow); z-index:30; padding:6px; }
.mrow { display:flex; align-items:center; gap:10px; width:100%; text-align:left; padding:7px 10px; border-radius:10px; font-size:14px; }
.mrow.sel, .mrow:hover { background:var(--s2); }
.mrow .md { flex:1; min-width:0; color:var(--muted); font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.running { font-size:13px; color:var(--muted); margin:0 auto 8px; }
.running.live { cursor:pointer; }
.running .rline { display:flex; align-items:center; gap:8px; }
.running .grow { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.running b { color:var(--ink2); font-weight:550; }
.running .act { font-family:var(--mono); font-size:12.5px; }
.running .rnote { margin:3px 0 0 22px; font-style:italic; overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
.running .rtodos { margin:4px 0 0 22px; display:flex; flex-wrap:wrap; gap:4px 12px; }
.running .todo.completed { color:var(--ink2); }
.running .todo.in_progress { color:var(--ink); font-weight:550; }
.stepnote { font-size:13.5px; color:var(--ink2); padding:2px 4px; }
.stepnote p { margin:4px 0; }

/* messages */
.msg { margin:16px 0; display:flex; flex-direction:column; align-items:flex-start; }
.msg .who { display:flex; align-items:center; gap:8px; font-size:13px; font-weight:600; margin-bottom:5px; }
.msg .who time { font-weight:400; color:var(--muted); font-size:12px; }
.msg .who .av { width:22px; height:22px; font-size:11px; border-radius:7px; }
.msg.user .body { background:var(--s2); border-radius:18px; padding:8px 15px; max-width:min(88%, 640px); white-space:pre-wrap; overflow-wrap:anywhere; }
.msg.user.mine { align-items:flex-end; }
.msg.bot .body { max-width:100%; overflow-wrap:anywhere; min-width:0; width:100%; }
.msg.bot.error .body { border:1px solid var(--bad); border-radius:14px; padding:10px 14px; color:var(--bad); }
.mention { color:var(--tok); background:var(--tok-bg); border-radius:5px; padding:0 2px; }
.body p { margin:0 0 .8em; white-space:pre-wrap; } .body > :last-child { margin-bottom:0; }
.body code { font:.88em var(--mono); background:var(--s2); border-radius:6px; padding:1.5px 5px; }
.body pre { margin:0 0 .9em; padding:12px 14px; overflow-x:auto; font:13px/1.55 var(--mono); border:1px solid var(--line); border-radius:14px; background:var(--s1); }
.body pre code { background:none; padding:0; }
.body h3, .body h4, .body h5, .body h6 { margin:1.1em 0 .5em; line-height:1.3; font-weight:650; } .body > h3:first-child, .body > h4:first-child { margin-top:0; }
.body h3 { font-size:1.2em; } .body h4 { font-size:1.08em; } .body h5, .body h6 { font-size:1em; }
.body ul, .body ol { margin:0 0 .8em; padding-left:1.5em; } .body li { margin:.2em 0; white-space:pre-wrap; } .body li > ul, .body li > ol { margin:.2em 0 0; }
.body blockquote { margin:0 0 .8em; padding:2px 0 2px 12px; border-left:3px solid var(--s3); color:var(--ink2); }
.body hr { border:0; border-top:1px solid var(--line); margin:1em 0; }
.body .tablewrap { overflow-x:auto; margin:0 0 .9em; border:1px solid var(--line); border-radius:12px; width:fit-content; max-width:100%; }
.body table { border-collapse:collapse; font-size:.94em; line-height:1.45; }
.body th, .body td { padding:7px 12px; text-align:left; vertical-align:top; border-bottom:1px solid var(--line); border-right:1px solid var(--line); min-width:90px; }
.body th:last-child, .body td:last-child { border-right:0; } .body tbody tr:last-child td { border-bottom:0; }
.body th { background:var(--s1); font-weight:600; white-space:nowrap; }
.msg.user .body { white-space:normal; } .msg.user .body p { white-space:pre-wrap; } .msg.user .body .tablewrap { background:var(--bg); }
.work { margin:6px 0; max-width:100%; width:100%; }
.work > summary { list-style:none; display:flex; align-items:center; gap:8px; padding:4px 10px 4px 8px; margin-left:-8px; border-radius:99px; cursor:pointer; font-size:13.5px; color:var(--muted); }
.work > summary::-webkit-details-marker { display:none; }
.work > summary:hover { background:var(--s1); color:var(--ink); }
.steps { margin:6px 0; display:flex; flex-direction:column; gap:4px; }
.step { border:1px solid var(--line); border-radius:13px; background:var(--side); overflow:hidden; }
.step summary { list-style:none; display:flex; align-items:center; gap:9px; padding:7px 11px; cursor:pointer; font-size:13.5px; color:var(--ink2); }
.step summary::-webkit-details-marker { display:none; }
.step .tn { font-weight:550; white-space:nowrap; }
.step .targ { flex:1; min-width:0; font:12.5px var(--mono); color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.step .in { border-top:1px solid var(--line); padding:10px 12px 12px; }
.step .lbl { font-size:11.5px; color:var(--muted); margin:8px 0 4px; } .step .lbl:first-child { margin-top:0; }
.step pre { margin:0; font:12.5px/1.5 var(--mono); white-space:pre-wrap; overflow-wrap:anywhere; max-height:300px; overflow:auto; background:var(--s1); border-radius:9px; padding:8px 10px; }
.askbox { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin:8px 0; padding:10px 12px; border:1px solid var(--warn); border-radius:11px; font-size:13.5px; width:100%; }
.askbox.done { border-color:var(--line); color:var(--muted); }
.askbox .t { flex:1; min-width:180px; }
.askbox pre { width:100%; margin:4px 0 0; font:12.5px var(--mono); white-space:pre-wrap; overflow-wrap:anywhere; background:var(--s1); border-radius:9px; padding:8px 10px; max-height:200px; overflow:auto; }
.spin { width:14px; height:14px; border-radius:50%; border:2px solid var(--s3); border-top-color:var(--ink2); animation:spin .8s linear infinite; flex:none; }
@keyframes spin { to { transform:rotate(360deg); } }
.empty { text-align:center; padding:12vh 20px; color:var(--muted); }
.empty h1 { color:var(--ink); font-size:26px; font-weight:600; letter-spacing:-.02em; margin:16px 0 6px; }

/* pages */
.page h2 { font-size:13px; font-weight:500; color:var(--muted); margin:28px 0 10px; }
.page h1 { font-size:24px; font-weight:600; letter-spacing:-.02em; margin:20px 0 4px; }
.li { display:flex; align-items:center; gap:8px; padding:9px 0; border-bottom:1px solid var(--line); min-width:0; flex-wrap:wrap; }
.li .tx { flex:1 1 12em; min-width:min(12em, 100%); overflow-wrap:break-word; font-size:14px; }
.li .tx small { display:block; color:var(--muted); font-size:12.5px; }
.none { color:var(--muted); font-size:13px; padding:6px 0; }
.rowbtns { display:flex; gap:8px; flex-wrap:wrap; margin-top:6px; }
.copyrow { display:flex; gap:8px; align-items:center; } .copyrow code { flex:1; font:12.5px var(--mono); background:var(--s1); border:1px solid var(--line); border-radius:10px; padding:7px 10px; overflow-wrap:anywhere; }

/* dialogs, menus, toasts */
dialog.dlg { border:1px solid var(--line); background:var(--bg); color:var(--ink); border-radius:20px; padding:0; width:min(520px, calc(100vw - 28px)); max-height:calc(100vh - 40px); box-shadow:var(--shadow); }
dialog.dlg::backdrop { background:rgba(0,0,0,.55); }
dialog.dlg .pad { padding:22px 22px 18px; overflow-y:auto; max-height:calc(100vh - 42px); }
dialog.dlg h2 { font-size:18px; margin:0 0 14px; letter-spacing:-.01em; }
.dfoot { display:flex; justify-content:flex-end; gap:8px; margin-top:6px; }
.pop { position:fixed; z-index:60; min-width:200px; background:var(--s1); border:1px solid var(--line); border-radius:14px; box-shadow:var(--shadow); padding:6px; }
.popitem { display:flex; align-items:center; gap:10px; width:100%; text-align:left; padding:7px 10px; border-radius:9px; font-size:14px; }
.popitem:hover { background:var(--s2); }
#toasts { position:fixed; bottom:20px; left:50%; transform:translateX(-50%); display:flex; flex-direction:column; gap:8px; z-index:100; align-items:center; pointer-events:none; max-width:calc(100vw - 28px); }
.toast { background:var(--btn); color:var(--btn-ink); border-radius:12px; padding:9px 16px; font-size:14px; box-shadow:var(--shadow); max-width:520px; white-space:pre-wrap; animation:rise .18s ease-out; }
.toast.bad { background:var(--bad); color:#fff; }
@keyframes rise { from { opacity:0; transform:translateY(8px); } }

@media (max-width: 860px) {
  #side { position:fixed; inset:0 auto 0 0; z-index:50; transform:translateX(-100%); transition:transform .18s; box-shadow:var(--shadow); }
  #app.sideopen #side { transform:none; }
  #menuBtn { display:inline-grid; }
  #col, #dock { padding-left:16px; padding-right:16px; }
}

.msg .body a.chatimg { display: block; margin: 6px 0; width: fit-content; max-width: 100%; }
.msg .body a.chatimg img { display: block; max-width: min(100%, 560px); max-height: 420px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--s1); }
.authbox .autherr { color: var(--bad); font-size: 13px; overflow-wrap: anywhere; }
.mention.mention-me { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); font-weight: 600; }
.msg.tome .body { box-shadow: inset 3px 0 0 var(--warn); }
.msg.bot.tome .body { padding-left: 10px; }
.pswitch { position: relative; }
.pswitch .chev { color: var(--muted); flex: none; transition: transform .15s; }
.pswitch.open .chev { transform: rotate(180deg); }
.pswitch.open > .project { border-color: var(--s3); }
.pswitch .plist { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); max-height: 60vh; overflow: auto;
  background: var(--s1); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 5px; }
.pswitch .plist[hidden] { display: none; }
.pswitch .popt { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border-radius: 8px; padding: 7px 9px; color: var(--ink2); }
.pswitch .popt:hover { background: var(--s2); color: var(--ink); }
.pswitch .popt .pname { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pswitch .popt b { font-weight: 550; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pswitch .popt small { color: var(--muted); font-size: 11.5px; }
.pswitch .popt .check { color: var(--ink); font-size: 13px; }
.pswitch .popt.add { font-size: 13.5px; }
.pswitch .popt .plus { width: 18px; text-align: center; color: var(--muted); }
.pswitch .psep { height: 1px; background: var(--line); margin: 4px 2px; }

/* unread mentions: a red count like a chat app */
.badge { flex: none; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff;
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.item.on .badge { opacity: .85; }
.busy { flex: none; width: 8px; height: 8px; margin: 0 4px; border-radius: 50%; background: var(--ok);
  animation: bubble 2.4s ease-in-out infinite; }
@keyframes bubble { 0%, 100% { opacity: .35; transform: scale(.75); box-shadow: 0 0 0 0 transparent; }
  50% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 25%, transparent); } }
@media (prefers-reduced-motion: reduce) { .busy { animation: none; } }
#menuBtn { position: relative; }
#menuBtn.dot::after { content: ''; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
dialog.dlg.down { width:min(440px, calc(100vw - 28px)); }
dialog.dlg.down::backdrop { background:rgba(0,0,0,.7); backdrop-filter:blur(2px); }
dialog.dlg.down .downhead { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
dialog.dlg.down h2 { margin:0; }
dialog.dlg.down p { margin:0 0 8px; line-height:1.45; }
