/* SuperAI — console for Claude Code sessions */
:root{
  --bg:#0b0d12; --bg-2:#11141b; --bg-3:#171b24; --bg-4:#1e2330;
  --line:#242a38; --line-2:#2f3648;
  --fg:#e8ecf5; --fg-2:#a4adc2; --fg-3:#6f7a92;
  --accent:#6c8cff; --accent-2:#8aa2ff; --accent-soft:rgba(108,140,255,.14);
  --ok:#31c48d; --warn:#f5a524; --err:#f0616d;
  --radius:14px; --radius-lg:20px; --radius-sm:9px;
  --shadow:0 8px 32px rgba(0,0,0,.42);
  --mono:ui-monospace,"SF Mono",SFMono-Regular,"JetBrains Mono",Menlo,Consolas,monospace;
  --sans:"Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,system-ui,sans-serif;
  --sidebar-w:280px;
  color-scheme:dark;
}
:root[data-theme="light"]{
  --bg:#f7f8fc; --bg-2:#ffffff; --bg-3:#f1f3f9; --bg-4:#e8ebf3;
  --line:#e2e6f0; --line-2:#d2d8e6;
  --fg:#111624; --fg-2:#4d566d; --fg-3:#7c869e;
  --accent-soft:rgba(108,140,255,.12);
  --shadow:0 8px 28px rgba(20,30,60,.10);
  color-scheme:light;
}
*,*::before,*::after{box-sizing:border-box}
/* Several components set an explicit display (.launcher is flex, .scope-chip is
   inline-flex, .box-btn is grid), which outranks the UA rule for [hidden] and
   leaves them on screen when toggled off. Make the attribute authoritative. */
[hidden]{display:none!important}
html,body{height:100%}
body{
  margin:0;background:var(--bg);color:var(--fg);font-family:var(--sans);
  font-size:15px;line-height:1.6;-webkit-font-smoothing:antialiased;
  overscroll-behavior:none;
}
button,input,textarea,select{font:inherit;color:inherit}
button{cursor:pointer;background:none;border:none}
a{color:var(--accent-2)}
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-thumb{background:var(--line-2);border-radius:8px;border:3px solid transparent;background-clip:padding-box}
::-webkit-scrollbar-thumb:hover{background:var(--fg-3);background-clip:padding-box;border:3px solid transparent}
::-webkit-scrollbar-track{background:transparent}

/* ---------------------------------------------------------------- login */
.auth-wrap{min-height:100dvh;display:grid;place-items:center;padding:24px;
  background:radial-gradient(1200px 600px at 50% -10%,rgba(108,140,255,.16),transparent 60%)}
.auth-card{width:100%;max-width:400px;background:var(--bg-2);border:1px solid var(--line);
  border-radius:var(--radius-lg);padding:36px 30px;box-shadow:var(--shadow)}
.auth-logo{display:flex;align-items:center;gap:11px;margin-bottom:26px}
.auth-logo .mark{width:42px;height:42px;border-radius:12px;display:grid;place-items:center;
  background:linear-gradient(140deg,var(--accent),#a06cff);font-size:21px;
  box-shadow:0 6px 20px rgba(108,140,255,.4)}
.auth-logo h1{margin:0;font-size:21px;letter-spacing:-.4px;font-weight:650}
.auth-logo p{margin:2px 0 0;font-size:12.5px;color:var(--fg-3)}
.field{margin-bottom:15px}
.field label{display:block;font-size:12.5px;color:var(--fg-2);margin-bottom:7px;font-weight:550}
.field input{width:100%;padding:12px 14px;background:var(--bg-3);border:1px solid var(--line);
  border-radius:var(--radius-sm);outline:none;transition:border-color .15s,box-shadow .15s}
.field input:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
.btn-primary{width:100%;padding:12px;border-radius:var(--radius-sm);font-weight:600;
  background:linear-gradient(140deg,var(--accent),#7f6cff);color:#fff;transition:filter .15s,transform .1s}
.btn-primary:hover{filter:brightness(1.08)} .btn-primary:active{transform:translateY(1px)}
.auth-err{background:rgba(240,97,109,.12);border:1px solid rgba(240,97,109,.3);color:#ff9aa2;
  padding:10px 13px;border-radius:var(--radius-sm);font-size:13px;margin-bottom:15px}

/* ----------------------------------------------------------------- shell */
.app{display:flex;height:100dvh;overflow:hidden}

.sidebar{width:var(--sidebar-w);flex-shrink:0;background:var(--bg-2);border-right:1px solid var(--line);
  display:flex;flex-direction:column;transition:transform .26s cubic-bezier(.4,0,.2,1);z-index:40}
/* The budget here is tight and worth stating: at --sidebar-w 280px the row has
   254px of usable width, and the mark plus five 32px buttons at a 9px gap ate
   237px of it — leaving 17px for a title that needs about 60. It had been
   overflowing quietly for a while; a sixth button pushed the buttons themselves
   past the sidebar edge, onto the title and, with the drawer open on a phone,
   onto the menu icon beneath. Smaller buttons and a tighter gap give the title
   63px, and the ellipsis below guarantees the rest. */
.sb-head{padding:12px 10px 9px;display:flex;align-items:center;gap:5px}
.sb-head .icon-btn{width:28px;height:28px}
.sb-head .icon-btn svg{width:16px;height:16px}
.sb-head .mark{width:32px;height:32px;border-radius:9px;display:grid;place-items:center;
  background:linear-gradient(140deg,var(--accent),#a06cff);font-size:16px;flex-shrink:0}
/* min-width:0 is what stops the title sliding under the icons: a flex item's
   default min-width is auto, so "SuperAI" refused to shrink and overflowed
   instead. The ellipsis is the visible contract — the row can run out of space,
   but it can never overlap. */
.sb-head .name{font-weight:650;letter-spacing:-.3px;font-size:15px;
  min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sb-head .name span{display:block;font-size:11px;color:var(--fg-3);font-weight:400;letter-spacing:0}
.icon-btn{width:32px;height:32px;border-radius:8px;display:grid;place-items:center;color:var(--fg-2);
  transition:background .15s,color .15s;flex-shrink:0}
.icon-btn:hover{background:var(--bg-4);color:var(--fg)}
/* The portal's control panel is a link rather than a button, so it needs the
   two things a <button> already had: no underline, and the pointer. */
a.icon-btn{text-decoration:none;cursor:pointer}
.icon-btn svg{width:17px;height:17px;stroke:currentColor;fill:none;stroke-width:1.9;
  stroke-linecap:round;stroke-linejoin:round}

.new-chat{margin:10px 12px 9px;padding:10px 13px;border-radius:11px;display:flex;align-items:center;
  gap:9px;font-weight:570;font-size:14px;border:1px solid var(--line-2);background:var(--bg-3);
  transition:background .15s,border-color .15s}
.new-chat:hover{background:var(--bg-4);border-color:var(--accent)}
.new-chat svg{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round}

/* One row, two controls: search takes the space, scope takes what it needs.
   Two full-width stacked rows above the chat list was most of what made this
   rail feel crowded. */
.sb-tools{display:flex;gap:7px;padding:0 12px 9px;align-items:stretch}
.sb-tools .sb-search{flex:1;min-width:0;padding:0}
.sb-tools .sb-filter{flex:none;width:92px;padding:0}
.sb-tools .sb-search .sb-search-ico{left:10px;top:9px}
.sb-tools .sb-search-clear{right:5px;top:5px}
.sb-filter{padding:0 12px 8px}
.sb-filter select{width:100%;padding:8px 11px;background:var(--bg-3);border:1px solid var(--line);
  border-radius:9px;font-size:13px;outline:none;appearance:none;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236f7a92' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat:no-repeat;background-position:right 9px center;background-size:15px}

.sb-search{position:relative;padding:0 12px 8px}
.sb-search .sb-search-ico{position:absolute;left:21px;top:9px;width:14px;height:14px;
  fill:none;stroke:var(--fg-3);stroke-width:2;stroke-linecap:round;pointer-events:none}
.sb-search input{width:100%;padding:8px 28px 8px 32px;background:var(--bg-3);
  border:1px solid var(--line);border-radius:9px;font-size:13px;outline:none;
  color:inherit;font-family:inherit}
.sb-search input:focus{border-color:var(--accent)}
.sb-search input::-webkit-search-cancel-button{display:none}
.sb-search-clear{position:absolute;right:18px;top:5px;width:24px;height:24px;padding:0;
  display:grid;place-items:center;background:none;border:0;cursor:pointer;color:var(--fg-3);
  border-radius:6px}
.sb-search-clear:hover{color:var(--fg);background:var(--bg-2)}
.sb-search-clear svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:2;
  stroke-linecap:round}

/* Footer of the resting list: says how much is not loaded, and takes you to
   the search box instead of fetching it. */
.conv-more{margin:10px 8px 0;padding:9px 10px;width:calc(100% - 16px);text-align:left;
  background:none;border:1px dashed var(--line);border-radius:9px;cursor:pointer;
  color:var(--fg-3);font-size:12px;font-family:inherit;line-height:1.5}
.conv-more:hover{color:var(--fg-2);border-color:var(--accent);background:var(--bg-3)}

.conv-list{flex:1;overflow-y:auto;padding:0 8px 12px}
.conv-group{font-size:11px;text-transform:uppercase;letter-spacing:.7px;color:var(--fg-3);
  padding:12px 8px 5px;font-weight:600}
.conv{display:flex;align-items:center;gap:9px;padding:8px 9px;border-radius:9px;cursor:pointer;
  transition:background .13s;position:relative}
.conv:hover{background:var(--bg-3)}
.conv.active{background:var(--accent-soft)}
.conv.active::before{content:"";position:absolute;left:0;top:7px;bottom:7px;width:2.5px;
  border-radius:2px;background:var(--accent)}
.conv .ico{font-size:14px;flex-shrink:0;width:19px;text-align:center}
.conv .t{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13.5px}
/* The row actions float over the end of the row instead of taking part in the
   flex flow — laid out inline they would steal ~80px from every title even
   while hidden, so each chat would read half-truncated at rest.  The leading
   gradient fades the title out underneath them on hover; its layers reproduce
   whatever the row's own background is, so the fade is invisible. */
.conv .acts{position:absolute;right:7px;top:50%;transform:translateY(-50%);
  display:flex;align-items:center;gap:1px;padding-left:26px;border-radius:0 8px 8px 0;
  opacity:0;pointer-events:none;transition:opacity .13s;
  background:linear-gradient(90deg,transparent,var(--bg-3) 26px)}
.conv:hover .acts,.conv:focus-within .acts{opacity:1;pointer-events:auto}
.conv.active .acts{background-image:linear-gradient(90deg,transparent,var(--accent-soft) 26px),
  linear-gradient(90deg,transparent,var(--bg-2) 26px)}
.conv .act{width:24px;height:24px;border-radius:6px;display:grid;place-items:center;
  color:var(--fg-3);flex-shrink:0;transition:color .13s,background .13s}
.conv .act:hover{color:var(--fg);background:var(--bg-4)}
.conv .del:hover{color:var(--err);background:var(--bg-4)}
.conv .act svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;
  stroke-linejoin:round}
/* No always-on pin badge: the "Pinned" group header already explains the row's
   position, and a badge would cost title width on exactly the rows that have
   the longest names. */
.conv .pin.on{color:var(--accent)}
.conv .pin.on svg{fill:var(--accent-soft)}
.rename-input{width:100%;min-width:0;font:inherit;color:var(--fg);background:var(--bg-2);
  border:1px solid var(--accent);border-radius:6px;padding:2px 6px;outline:none}
.empty-note{padding:26px 14px;text-align:center;color:var(--fg-3);font-size:13px;line-height:1.7}

.sb-foot{border-top:1px solid var(--line);padding:10px 12px;display:flex;align-items:center;gap:9px}
.avatar{width:29px;height:29px;border-radius:50%;display:grid;place-items:center;font-size:12px;
  font-weight:650;background:linear-gradient(140deg,var(--accent),#a06cff);color:#fff;flex-shrink:0}
.sb-foot .who{flex:1;min-width:0;font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* ------------------------------------------------------------------ main */
.main{flex:1;display:flex;flex-direction:column;min-width:0;position:relative}
.topbar{height:56px;flex-shrink:0;display:flex;align-items:center;gap:10px;padding:0 14px;
  border-bottom:1px solid var(--line);background:var(--bg);position:relative;z-index:20}
/* Deliberately NOT backdrop-filter. The bar sits over the scrolling transcript,
   so a blur there has to be recomputed against new content every single frame —
   on a 200-message thread that is the difference between smooth and juddering.
   Opaque looks near-identical and costs nothing. */
.topbar .title{flex:1;min-width:0;font-weight:600;font-size:14.5px;overflow:hidden;
  text-overflow:ellipsis;white-space:nowrap}
.topbar .title.editable{cursor:text;border-radius:7px;padding:3px 7px;margin-left:-7px}
.topbar .title.editable:hover{background:var(--bg-3)}
#pin-chat.on{color:var(--accent)} #pin-chat.on svg{fill:var(--accent-soft)}
.scope-chip{display:inline-flex;align-items:center;gap:6px;padding:5px 10px;border-radius:20px;
  background:var(--bg-3);border:1px solid var(--line-2);font-size:12.5px;color:var(--fg-2);
  max-width:190px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex-shrink:0}
.scope-chip b{color:var(--fg);font-weight:600}
.only-mobile{display:none}

/* -------------------------------------------------------------- launcher */
.launcher{flex:1;overflow-y:auto;display:flex;flex-direction:column;align-items:center;
  justify-content:center;padding:36px 20px;text-align:center;
  background:radial-gradient(900px 460px at 50% 0%,rgba(108,140,255,.10),transparent 62%)}
.launcher .hero-mark{width:60px;height:60px;border-radius:18px;display:grid;place-items:center;
  background:linear-gradient(140deg,var(--accent),#a06cff);font-size:29px;margin-bottom:17px;
  box-shadow:0 10px 34px rgba(108,140,255,.36)}
.launcher h2{margin:0 0 7px;font-size:25px;letter-spacing:-.6px;font-weight:660}
.launcher p{margin:0 0 28px;color:var(--fg-2);font-size:14.5px;max-width:440px}
.scope-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(196px,1fr));gap:12px;
  width:100%;max-width:660px}
.scope-card{padding:17px;border-radius:var(--radius);border:1px solid var(--line);background:var(--bg-2);
  text-align:left;transition:transform .16s,border-color .16s,box-shadow .16s;position:relative;overflow:hidden}
.scope-card::after{content:"";position:absolute;inset:0;opacity:0;background:radial-gradient(280px 120px at 20% 0%,var(--accent-soft),transparent 70%);transition:opacity .2s}
.scope-card:hover{transform:translateY(-2px);border-color:var(--accent);box-shadow:var(--shadow)}
.scope-card:hover::after{opacity:1}
.scope-card .ico{font-size:23px;margin-bottom:9px;display:block}
.scope-card .nm{font-weight:620;font-size:14.5px;margin-bottom:3px;position:relative}
.scope-card .ds{font-size:12.5px;color:var(--fg-3);line-height:1.5;position:relative;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.scope-card.missing{opacity:.55}
.scope-card.missing .ds::after{content:" • path missing";color:var(--warn)}
.scope-card.other{border-style:dashed}

/* ------------------------------------------------------------- transcript */
.thread{flex:1;overflow-y:auto;scroll-behavior:smooth;overscroll-behavior:contain;
  padding:22px 0 8px;
  scrollbar-gutter:stable}
.thread-inner{max-width:820px;margin:0 auto;padding:0 20px}
.msg{margin-bottom:24px;animation:rise .26s ease;
  /* The browser lays out and paints every message in the thread, including the
     190 above the fold — each with markdown, code blocks and a tool timeline.
     content-visibility lets it skip all of that for anything off-screen, and
     the remembered intrinsic size keeps the scrollbar from jumping as they
     come in and out of view. This is the single biggest win on a long chat. */
  content-visibility:auto;contain-intrinsic-size:auto 220px}
@keyframes rise{from{opacity:0;transform:translateY(7px)}to{opacity:1;transform:none}}
.msg-head{display:flex;align-items:center;gap:8px;margin-bottom:7px}
.msg-head .who{font-size:12.5px;font-weight:650;letter-spacing:.1px}
.msg-head .badge{font-size:10.5px;padding:2px 7px;border-radius:20px;font-weight:600;
  letter-spacing:.3px;text-transform:uppercase}
.badge.queued{background:rgba(245,165,36,.15);color:var(--warn)}
.badge.running{background:var(--accent-soft);color:var(--accent-2)}
.badge.error{background:rgba(240,97,109,.15);color:var(--err)}
.badge.cancelled{background:var(--bg-4);color:var(--fg-3)}
.msg-head .meta{margin-left:auto;font-size:11.5px;color:var(--fg-3);font-variant-numeric:tabular-nums}

.msg.user .bubble{background:var(--bg-3);border:1px solid var(--line);border-radius:var(--radius);
  padding:12px 15px;white-space:pre-wrap;word-break:break-word}
/* Arabic and English mix freely here — let the browser resolve direction per
   block, and keep RTL paragraphs aligned to their own side. */
.msg .bubble,.md p,.md li,.md h1,.md h2,.md h3,.md h4,.md blockquote,#input{unicode-bidi:plaintext}
[dir="rtl"],.md p:dir(rtl),.md li:dir(rtl){text-align:right}
.md .cb,.md .cb pre,.md code,.step .sm,.step .out{direction:ltr;text-align:left;unicode-bidi:isolate}
.msg.assistant .bubble{padding:0}
.msg.assistant .bubble.thinking-only{color:var(--fg-3);font-style:italic}

.attach-row{display:flex;flex-wrap:wrap;gap:7px;margin-top:9px}
.attach-pill{display:inline-flex;align-items:center;gap:7px;padding:6px 10px;border-radius:9px;
  background:var(--bg-4);border:1px solid var(--line-2);font-size:12.5px;max-width:100%}
.attach-pill svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:1.9;flex-shrink:0}
.attach-pill .nm{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:180px}
.attach-pill img{max-height:130px;border-radius:7px;display:block}
.attach-pill audio{height:32px;max-width:230px}

/* ------------------------------------------------------------- activity */
.activity{margin:0 0 11px;border:1px solid var(--line);border-radius:var(--radius);
  background:var(--bg-2);overflow:hidden}
.activity-head{display:flex;align-items:center;gap:8px;padding:9px 13px;cursor:pointer;
  font-size:12.5px;color:var(--fg-2);user-select:none;transition:background .13s}
.activity-head:hover{background:var(--bg-3)}
.activity-head .chev{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:2.2;
  stroke-linecap:round;transition:transform .2s;flex-shrink:0}
.activity.open .chev{transform:rotate(90deg)}
.activity-head .lbl{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.activity-head .n{font-size:11px;color:var(--fg-3);font-variant-numeric:tabular-nums}
.activity-body{display:none;border-top:1px solid var(--line);padding:5px 0;max-height:420px;
  overflow-y:auto}
.activity.open .activity-body{display:block}
.step{display:flex;gap:9px;padding:7px 13px;font-size:12.5px;align-items:flex-start}
.step + .step{border-top:1px solid color-mix(in srgb,var(--line) 55%,transparent)}
.step .dot{width:7px;height:7px;border-radius:50%;margin-top:7px;flex-shrink:0;background:var(--fg-3)}
.step.running .dot{background:var(--accent);animation:pulse 1.3s ease-in-out infinite}
.step.done .dot{background:var(--ok)} .step.error .dot{background:var(--err)}
@keyframes pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.35;transform:scale(.7)}}
.step .body{flex:1;min-width:0}
.step .nm{font-weight:600;color:var(--fg);font-size:12.5px}
.step .sm{color:var(--fg-2);font-family:var(--mono);font-size:11.5px;word-break:break-all;
  margin-top:2px;line-height:1.5}
.step .out{margin-top:5px;font-family:var(--mono);font-size:11px;color:var(--fg-3);
  background:var(--bg);border:1px solid var(--line);border-radius:7px;padding:6px 8px;
  max-height:150px;overflow:auto;white-space:pre-wrap;word-break:break-word}
.step.error .out{color:#ffa7ad;border-color:rgba(240,97,109,.3)}
.step.thinking .nm{color:var(--fg-2);font-style:italic;font-weight:500}

.live-line{display:flex;align-items:center;gap:9px;color:var(--fg-2);font-size:13px;padding:2px 0 6px}
.spinner{width:14px;height:14px;border-radius:50%;border:2px solid var(--line-2);
  border-top-color:var(--accent);animation:spin .7s linear infinite;flex-shrink:0}
@keyframes spin{to{transform:rotate(360deg)}}
.caret{display:inline-block;width:2px;height:1em;background:var(--accent);
  vertical-align:text-bottom;animation:blink 1s steps(2) infinite;margin-left:1px}
@keyframes blink{50%{opacity:0}}

.err-box{background:rgba(240,97,109,.09);border:1px solid rgba(240,97,109,.28);color:#ffa7ad;
  padding:10px 13px;border-radius:var(--radius-sm);font-size:13px;margin-top:9px;
  white-space:pre-wrap;word-break:break-word}

/* --------------------------------------------------------------- queue */
.queue-bar{max-width:820px;margin:0 auto 10px;padding:0 20px;width:100%}
.queue-inner{display:flex;align-items:center;gap:9px;padding:8px 12px;border-radius:11px;
  background:rgba(245,165,36,.09);border:1px solid rgba(245,165,36,.26);font-size:12.5px;
  color:var(--warn)}
.queue-inner .txt{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.queue-inner button{color:var(--warn);font-size:12px;text-decoration:underline;opacity:.85}
.queue-inner button:hover{opacity:1}

/* ------------------------------------------------------------- composer */
.composer-wrap{flex-shrink:0;padding:0 0 max(14px,env(safe-area-inset-bottom));
  background:linear-gradient(to top,var(--bg) 62%,transparent)}
.composer{max-width:820px;margin:0 auto;padding:0 20px}
.chips{display:flex;flex-wrap:wrap;gap:7px;margin-bottom:8px}
.chip{display:inline-flex;align-items:center;gap:7px;padding:5px 9px;border-radius:9px;
  background:var(--bg-3);border:1px solid var(--line-2);font-size:12px;max-width:230px}
.chip .nm{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chip .x{color:var(--fg-3);font-size:15px;line-height:1;padding:0 1px}
.chip .x:hover{color:var(--err)}
.chip.busy{color:var(--fg-3)}

.box{border:1px solid var(--line-2);border-radius:var(--radius-lg);background:var(--bg-2);
  padding:8px 8px 8px 14px;display:flex;align-items:flex-end;gap:8px;
  transition:border-color .16s,box-shadow .16s;box-shadow:var(--shadow)}
.box:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft),var(--shadow)}
.box.recording{border-color:var(--err);box-shadow:0 0 0 3px rgba(240,97,109,.15)}
#input{flex:1;background:none;border:none;outline:none;resize:none;padding:9px 0;max-height:220px;
  min-height:24px;line-height:1.55;font-size:15px}
#input::placeholder{color:var(--fg-3)}
.box-btn{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;color:var(--fg-2);
  flex-shrink:0;transition:background .14s,color .14s}
.box-btn:hover{background:var(--bg-4);color:var(--fg)}
.box-btn svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:1.9;
  stroke-linecap:round;stroke-linejoin:round}
.box-btn.rec{color:var(--err);background:rgba(240,97,109,.13);animation:recpulse 1.4s ease-in-out infinite}
@keyframes recpulse{50%{background:rgba(240,97,109,.26)}}
#send{background:linear-gradient(140deg,var(--accent),#7f6cff);color:#fff}
#send:hover{filter:brightness(1.1);background:linear-gradient(140deg,var(--accent),#7f6cff)}
#send:disabled{opacity:.4;cursor:not-allowed;filter:none}
#send.stop{background:var(--err)}
.hint{display:flex;align-items:center;gap:9px;margin-top:7px;font-size:11.5px;color:var(--fg-3);
  flex-wrap:wrap;justify-content:center}
.hint .sep{opacity:.4}
.mini-select{background:var(--bg-3);border:1px solid var(--line);border-radius:7px;padding:3px 7px;
  font-size:11.5px;color:var(--fg-2);outline:none;cursor:pointer}
.mini-select:focus{border-color:var(--accent)}
.rec-time{color:var(--err);font-variant-numeric:tabular-nums;font-weight:600}

/* -------------------------------------------------- markdown / rich text */
.md{word-break:break-word;overflow-wrap:anywhere}
.md > *:first-child{margin-top:0} .md > *:last-child{margin-bottom:0}
.md p{margin:0 0 11px}
.md h1,.md h2,.md h3,.md h4{margin:19px 0 9px;line-height:1.32;font-weight:650;letter-spacing:-.2px}
.md h1{font-size:21px} .md h2{font-size:18px} .md h3{font-size:16px} .md h4{font-size:14.5px}
.md ul,.md ol{margin:0 0 11px;padding-left:22px}
.md li{margin:3px 0} .md li > p{margin:0}
.md blockquote{margin:0 0 11px;padding:2px 0 2px 14px;border-left:3px solid var(--line-2);
  color:var(--fg-2)}
.md hr{border:none;border-top:1px solid var(--line);margin:17px 0}
.md strong{font-weight:660;color:var(--fg)}
.md code{font-family:var(--mono);font-size:.875em;background:var(--bg-4);padding:2px 5px;
  border-radius:5px;border:1px solid var(--line)}
.md table{border-collapse:collapse;width:100%;margin:0 0 11px;font-size:13.5px;display:block;
  overflow-x:auto}
.md th,.md td{border:1px solid var(--line);padding:7px 11px;text-align:left}
.md th{background:var(--bg-3);font-weight:620}
.md tr:nth-child(even) td{background:color-mix(in srgb,var(--bg-3) 45%,transparent)}
.md img{max-width:100%;border-radius:9px}

.md .cb{margin:0 0 12px;border:1px solid var(--line);border-radius:11px;overflow:hidden;
  background:var(--bg-2)}
.md .cb-head{display:flex;align-items:center;gap:8px;padding:6px 11px;background:var(--bg-3);
  border-bottom:1px solid var(--line);font-size:11.5px;color:var(--fg-3);font-family:var(--mono)}
.md .cb-head .lang{flex:1;text-transform:lowercase}
.md .cb-head button{font-size:11px;color:var(--fg-2);padding:3px 8px;border-radius:6px;
  border:1px solid var(--line-2);transition:background .13s,color .13s}
.md .cb-head button:hover{background:var(--bg-4);color:var(--fg)}
.md .cb-head button.ok{color:var(--ok);border-color:var(--ok)}
.md .cb pre{margin:0;padding:12px 13px;overflow-x:auto;font-family:var(--mono);font-size:12.8px;
  line-height:1.62}
.md .cb pre code{background:none;border:none;padding:0;font-size:inherit}

/* links — deliberately loud, so a code-server / preview URL is unmissable */
.md a{color:var(--accent-2);text-decoration:none;border-bottom:1px solid rgba(138,162,255,.4);
  transition:background .14s,border-color .14s}
.md a:hover{background:var(--accent-soft);border-bottom-color:var(--accent-2)}
.md a.url-pill{display:inline-flex;align-items:center;gap:6px;padding:3px 9px 3px 10px;
  border-radius:8px;background:var(--accent-soft);border:1px solid rgba(108,140,255,.34);
  font-family:var(--mono);font-size:12.5px;font-weight:520;border-bottom-width:1px;
  max-width:100%;vertical-align:baseline;word-break:break-all;line-height:1.45}
.md a.url-pill:hover{background:rgba(108,140,255,.24);border-color:var(--accent)}
.md a.url-pill::after{content:"";width:11px;height:11px;flex-shrink:0;opacity:.75;
  background:currentColor;-webkit-mask:var(--ext-icon) center/contain no-repeat;
  mask:var(--ext-icon) center/contain no-repeat}
:root{--ext-icon:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/><polyline points='15 3 21 3 21 9'/><line x1='10' y1='14' x2='21' y2='3'/></svg>")}
.md a.path-pill{font-family:var(--mono);font-size:12.5px;background:var(--bg-4);padding:2px 6px;
  border-radius:5px;border:1px solid var(--line);color:var(--fg);border-bottom-color:var(--line)}

/* token colours */
.tk-key{color:#c792ea} .tk-str{color:#c3e88d} .tk-num{color:#f78c6c}
.tk-com{color:var(--fg-3);font-style:italic} .tk-fn{color:#82aaff} .tk-op{color:#89ddff}
:root[data-theme="light"] .tk-key{color:#8e44c9} :root[data-theme="light"] .tk-str{color:#2e7d32}
:root[data-theme="light"] .tk-num{color:#c2410c} :root[data-theme="light"] .tk-fn{color:#1d5fd0}
:root[data-theme="light"] .tk-op{color:#0e7490}

/* ---------------------------------------------------------------- modal */
.overlay{position:fixed;inset:0;background:rgba(4,6,12,.66);backdrop-filter:blur(3px);z-index:60;
  display:none;align-items:center;justify-content:center;padding:20px;animation:fade .18s ease}
.overlay.show{display:flex}
@keyframes fade{from{opacity:0}to{opacity:1}}
.modal{background:var(--bg-2);border:1px solid var(--line-2);border-radius:var(--radius-lg);
  width:100%;max-width:520px;max-height:min(78dvh,660px);display:flex;flex-direction:column;
  box-shadow:var(--shadow);animation:pop .2s cubic-bezier(.2,1.1,.4,1)}
@keyframes pop{from{opacity:0;transform:scale(.96) translateY(8px)}to{opacity:1;transform:none}}
.modal-head{padding:16px 18px 12px;border-bottom:1px solid var(--line)}
.modal-head h3{margin:0;font-size:16px;font-weight:640;letter-spacing:-.2px}
.modal-head p{margin:4px 0 0;font-size:12.5px;color:var(--fg-3)}
.crumbs{display:flex;align-items:center;gap:3px;flex-wrap:wrap;padding:10px 18px;font-size:12px;
  border-bottom:1px solid var(--line);font-family:var(--mono)}
.crumbs button{color:var(--accent-2);padding:2px 5px;border-radius:5px}
.crumbs button:hover{background:var(--bg-3)}
.crumbs .sl{color:var(--fg-3)}
.crumbs .cur{color:var(--fg);padding:2px 5px}
.modal-body{flex:1;overflow-y:auto;padding:7px 10px}
.dir{display:flex;align-items:center;gap:10px;padding:9px 11px;border-radius:9px;cursor:pointer;
  width:100%;text-align:left;transition:background .13s}
.dir:hover{background:var(--bg-3)}
.dir .fi{font-size:15px;flex-shrink:0}
.dir .nm{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13.5px}
.dir .tag{font-size:10px;padding:2px 6px;border-radius:5px;background:var(--accent-soft);
  color:var(--accent-2);font-weight:600;flex-shrink:0}
.dir .go{color:var(--fg-3);flex-shrink:0}
.dir .go svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:2.2;stroke-linecap:round}
.modal-foot{padding:12px 18px;border-top:1px solid var(--line);display:flex;gap:9px;align-items:center}
.modal-foot .pathline{flex:1;min-width:0;font-family:var(--mono);font-size:11.5px;color:var(--fg-3);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.btn-ghost{padding:9px 14px;border-radius:9px;border:1px solid var(--line-2);font-size:13px;
  font-weight:550;transition:background .14s}
.btn-ghost:hover{background:var(--bg-3)}
.btn-solid{padding:9px 16px;border-radius:9px;background:linear-gradient(140deg,var(--accent),#7f6cff);
  color:#fff;font-size:13px;font-weight:600;transition:filter .14s}
.btn-solid:hover{filter:brightness(1.09)}

.toast-host{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);z-index:90;
  display:flex;flex-direction:column;gap:8px;align-items:center;pointer-events:none}
.toast{background:var(--bg-4);border:1px solid var(--line-2);color:var(--fg);padding:9px 15px;
  border-radius:10px;font-size:13px;box-shadow:var(--shadow);animation:rise .22s ease}
.toast.err{border-color:rgba(240,97,109,.4);color:#ffa7ad}

.scrim{display:none;position:fixed;inset:0;background:rgba(4,6,12,.55);z-index:35}
.scrim.show{display:block}

/* --------------------------------------------------------------- mobile */
@media (max-width:860px){
  .only-mobile{display:grid}
  .sidebar{position:fixed;inset:0 auto 0 0;transform:translateX(-100%);box-shadow:var(--shadow)}
  .sidebar.open{transform:none}
  .thread-inner,.composer,.queue-bar{padding-left:14px;padding-right:14px}
  .topbar{padding:0 10px}
  .scope-chip{max-width:120px}
  .launcher h2{font-size:21px} .launcher p{font-size:13.5px}
  .scope-grid{grid-template-columns:1fr}
  #input{font-size:16px} /* stop iOS zoom-on-focus */
  .hint{font-size:11px}
  .modal{max-height:82dvh}
}
@media (prefers-reduced-motion:reduce){
  *{animation-duration:.01ms!important;transition-duration:.01ms!important;scroll-behavior:auto!important}
}


/* ------------------------------------------------------------ usage panel */
.meter{padding:14px 8px}
.meter + .meter{border-top:1px solid var(--line)}
.meter-top{display:flex;align-items:baseline;gap:8px;margin-bottom:9px}
.meter-top .lbl{font-size:13.5px;font-weight:600}
.meter-top .pct{margin-left:auto;font-size:17px;font-weight:660;
  font-variant-numeric:tabular-nums;letter-spacing:-.4px}
.meter-bar{height:9px;border-radius:6px;background:var(--bg-4);overflow:hidden;
  border:1px solid var(--line)}
.meter-fill{height:100%;border-radius:6px;transition:width .5s cubic-bezier(.3,1,.4,1);
  background:linear-gradient(90deg,var(--accent),#7f6cff)}
.meter-fill.warn{background:linear-gradient(90deg,#f5a524,#f07d24)}
.meter-fill.hot{background:linear-gradient(90deg,#f0616d,#d63c4a)}
.meter-sub{margin-top:7px;font-size:12px;color:var(--fg-3)}
.usage-empty{padding:26px 14px;text-align:center;color:var(--fg-3);font-size:13px;line-height:1.7}

/* a booked follow-up reads as pending work, not a warning */
.queue-inner.sched{background:var(--accent-soft);border-color:rgba(108,140,255,.3);
  color:var(--accent-2)}
.queue-inner.sched button{color:var(--accent-2)}
.msg.scheduled .msg-head .who::after{content:" · scheduled";color:var(--fg-3);
  font-weight:400;font-size:11.5px}


/* ------------------------------------------------------------- drop zone */
.dropzone{position:fixed;inset:0;z-index:80;display:none;align-items:center;
  justify-content:center;padding:26px;background:rgba(4,6,12,.72);
  backdrop-filter:blur(4px);animation:fade .14s ease}
.dropzone.show{display:flex}
.dropzone-card{border:2px dashed var(--accent);border-radius:var(--radius-lg);
  background:var(--bg-2);padding:38px 46px;text-align:center;max-width:420px;
  box-shadow:var(--shadow);animation:pop .18s cubic-bezier(.2,1.1,.4,1)}
.dropzone-card svg{width:42px;height:42px;stroke:var(--accent);fill:none;stroke-width:1.7;
  stroke-linecap:round;stroke-linejoin:round;margin-bottom:13px}
.dropzone-card .t{font-size:18px;font-weight:640;letter-spacing:-.3px;margin-bottom:5px}
.dropzone-card .s{font-size:13px;color:var(--fg-3);line-height:1.55}

/* ------------------------------------------------ services & schedules */
.svc-tools{padding:11px 18px;border-bottom:1px solid var(--line);display:flex;gap:10px;
  align-items:center;flex-wrap:wrap}
#svc-search{flex:1;min-width:180px;background:var(--bg-3);border:1px solid var(--line);
  border-radius:9px;padding:8px 11px;font-size:13px;outline:none}
#svc-search:focus{border-color:var(--accent)}
.svc-filters{display:flex;gap:5px;flex-wrap:wrap}
.svc-chip{padding:6px 11px;border-radius:8px;border:1px solid var(--line);font-size:12px;
  color:var(--fg-2);transition:background .13s,border-color .13s,color .13s}
.svc-chip:hover{background:var(--bg-3)}
.svc-chip.on{background:var(--accent-soft);border-color:transparent;color:var(--accent-2);
  font-weight:600}

.svc-sum{display:flex;gap:7px;flex-wrap:wrap;padding:10px 8px 4px}
.svc-stat{display:flex;align-items:baseline;gap:5px;background:var(--bg-3);border-radius:8px;
  padding:6px 10px;font-size:12px;color:var(--fg-3)}
.svc-stat b{font-size:14px;font-weight:660;color:var(--fg);font-variant-numeric:tabular-nums}
.svc-stat.bad b{color:var(--err)}
.svc-stat.good b{color:var(--ok,#4ec9a5)}

.svc-group{margin:12px 0 4px}
.svc-group-head{display:flex;align-items:center;gap:8px;padding:7px 9px;position:sticky;top:0;
  background:var(--bg-2);z-index:1}
.svc-group-head .ic{font-size:14px}
.svc-group-head .nm{font-size:13px;font-weight:650;letter-spacing:-.1px}
.svc-group-head .pt{font-family:var(--mono);font-size:11px;color:var(--fg-3);flex:1;min-width:0;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.svc-group-head .ct{font-size:11px;color:var(--fg-3);flex-shrink:0}

.svc-row{display:flex;align-items:center;gap:10px;padding:9px 11px;border-radius:9px;
  transition:background .13s}
.svc-row:hover{background:var(--bg-3)}
.svc-row .dot{width:8px;height:8px;border-radius:50%;flex-shrink:0;background:var(--fg-3)}
.svc-row .dot.active{background:#4ec9a5;box-shadow:0 0 0 3px rgba(78,201,165,.16)}
.svc-row .dot.failed{background:var(--err);box-shadow:0 0 0 3px rgba(240,97,109,.18)}
.svc-row .dot.waiting{background:var(--accent-2);box-shadow:0 0 0 3px var(--accent-soft)}
.svc-main{flex:1;min-width:0}
.svc-main .nm{font-size:13px;font-family:var(--mono);overflow:hidden;text-overflow:ellipsis;
  white-space:nowrap}
.svc-main .ds{font-size:11.5px;color:var(--fg-3);overflow:hidden;text-overflow:ellipsis;
  white-space:nowrap;margin-top:1px}
.svc-side{flex-shrink:0;text-align:right;font-size:11px;color:var(--fg-3);line-height:1.5}
.svc-side .st{font-weight:600;color:var(--fg-2)}
.svc-side .st.failed{color:var(--err)}
.svc-tag{font-size:9.5px;padding:2px 5px;border-radius:5px;background:var(--bg-4);color:var(--fg-3);
  font-weight:600;letter-spacing:.3px;flex-shrink:0;text-transform:uppercase}
.svc-tag.timer{background:var(--accent-soft);color:var(--accent-2)}
.svc-tag.cron{background:rgba(245,165,36,.15);color:var(--warn)}
.svc-cmd{font-family:var(--mono);font-size:11.5px;color:var(--fg-2);overflow:hidden;
  text-overflow:ellipsis;white-space:nowrap}

/* ------------------------------------------------------------ schedules */
/* The view switch sits above everything the sidebar shows, because it decides
   what "everything the sidebar shows" means. */
.view-switch{display:flex;gap:4px;margin:0 12px 10px;padding:3px;background:var(--bg-3);
  border:1px solid var(--line);border-radius:11px}
.vs-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;padding:7px 6px;
  border-radius:8px;font-size:13px;font-weight:560;color:var(--fg-3);
  transition:background .15s,color .15s}
.vs-btn svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:1.9;
  stroke-linecap:round;stroke-linejoin:round}
.vs-btn:hover{color:var(--fg-2)}
.vs-btn.on{background:var(--bg-2);color:var(--fg);box-shadow:0 1px 3px rgba(0,0,0,.2)}
:root[data-theme="light"] .vs-btn.on{box-shadow:0 1px 3px rgba(20,30,60,.10)}
.vs-count{font-style:normal;font-size:10.5px;font-weight:650;padding:1px 6px;border-radius:20px;
  background:var(--accent-soft);color:var(--accent-2);font-variant-numeric:tabular-nums}

.sched-view{flex:1;overflow-y:auto;display:flex;flex-direction:column;padding:22px 24px 40px}
.sched-head{display:flex;align-items:flex-start;gap:12px;max-width:900px;width:100%;
  margin:0 auto 20px;flex-wrap:wrap}
.sched-head>div:first-child{flex:1;min-width:200px}
.sched-head h2{margin:0;font-size:23px;letter-spacing:-.5px;font-weight:660}
.sched-head p{margin:4px 0 0;color:var(--fg-2);font-size:13.5px}
.sched-body{max-width:900px;width:100%;margin:0 auto;display:flex;flex-direction:column;gap:10px}

.wa-pill{display:inline-flex;align-items:center;gap:7px;padding:8px 13px;border-radius:9px;
  border:1px solid var(--line-2);background:var(--bg-2);font-size:12.5px;color:var(--fg-2);
  transition:border-color .15s,color .15s}
.wa-pill:hover{border-color:var(--ok);color:var(--fg)}
.wa-pill svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:1.9;
  stroke-linecap:round;stroke-linejoin:round}
.wa-pill.ok{border-color:rgba(49,196,141,.45);color:var(--ok)}
.wa-pill.bad{border-color:rgba(240,97,109,.45);color:var(--err)}

/* One automation. The status dot and the "next run" line are the two things
   worth reading at a glance, so they bracket the row. */
.auto-card{border:1px solid var(--line);background:var(--bg-2);border-radius:var(--radius);
  padding:14px 16px;display:flex;gap:13px;align-items:flex-start;transition:border-color .15s}
.auto-card:hover{border-color:var(--line-2)}
.auto-card.off{opacity:.62}
.auto-card .ico{font-size:20px;line-height:1.3;flex-shrink:0}
.auto-main{flex:1;min-width:0}
.auto-name{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.auto-name b{font-size:14.5px;font-weight:630;letter-spacing:-.15px}
.auto-req{font-size:12.5px;color:var(--fg-2);margin-top:3px;overflow:hidden;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;line-clamp:2}
.auto-meta{display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin-top:8px;
  font-size:11.5px;color:var(--fg-3)}
.auto-meta .sep{opacity:.5}
.auto-tag{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:20px;
  background:var(--bg-3);border:1px solid var(--line);font-size:11px;color:var(--fg-2)}
.auto-tag.building{background:var(--accent-soft);border-color:transparent;color:var(--accent-2)}
.auto-tag.failed{background:rgba(240,97,109,.13);border-color:transparent;color:var(--err)}
.auto-tag.ready{background:rgba(49,196,141,.13);border-color:transparent;color:var(--ok)}
.auto-tag.mono{font-family:var(--mono)}
.auto-out{margin-top:9px;padding:8px 11px;border-radius:9px;background:var(--bg-3);
  border:1px solid var(--line);font-family:var(--mono);font-size:11.5px;color:var(--fg-2);
  white-space:pre-wrap;overflow:hidden;max-height:86px}
.auto-out.err{background:rgba(240,97,109,.08);border-color:rgba(240,97,109,.25);color:#ff9aa2}
.auto-side{display:flex;flex-direction:column;align-items:flex-end;gap:7px;flex-shrink:0}
.auto-next{font-size:11.5px;color:var(--fg-3);text-align:right;font-variant-numeric:tabular-nums}
.auto-acts{display:flex;gap:4px}
.auto-acts button{width:28px;height:28px;border-radius:7px;display:grid;place-items:center;
  color:var(--fg-3);transition:background .15s,color .15s}
.auto-acts button:hover{background:var(--bg-4);color:var(--fg)}
.auto-acts button.danger:hover{color:var(--err)}
.auto-acts svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:1.9;
  stroke-linecap:round;stroke-linejoin:round}

/* A toggle that reads as a state, not a button: this is the one control that
   decides whether the job runs at all. */
.sw{width:36px;height:20px;border-radius:20px;background:var(--line-2);position:relative;
  transition:background .18s;flex-shrink:0}
.sw::after{content:"";position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;
  background:var(--fg-2);transition:transform .18s,background .18s}
.sw.on{background:rgba(49,196,141,.35)}
.sw.on::after{transform:translateX(16px);background:var(--ok)}

.sched-empty{text-align:center;padding:48px 20px;color:var(--fg-3)}
.sched-empty .big{font-size:38px;margin-bottom:12px}
.sched-empty h3{margin:0 0 6px;font-size:16px;color:var(--fg);font-weight:620}
.sched-empty p{margin:0 auto 18px;font-size:13.5px;max-width:440px;line-height:1.65}
.sched-empty code{font-family:var(--mono);font-size:12px;background:var(--bg-3);
  padding:1px 6px;border-radius:5px;border:1px solid var(--line)}

/* Sidebar rows in the Schedules view. */
.auto-row{display:flex;align-items:center;gap:9px;padding:9px 11px;margin:0 8px 2px;
  border-radius:10px;cursor:pointer;transition:background .15s}
.auto-row:hover{background:var(--bg-3)}
.auto-row .dot{width:7px;height:7px;border-radius:50%;flex-shrink:0;background:var(--fg-3)}
.auto-row .dot.on{background:var(--ok);box-shadow:0 0 0 3px rgba(49,196,141,.16)}
.auto-row .dot.bad{background:var(--err);box-shadow:0 0 0 3px rgba(240,97,109,.18)}
.auto-row .dot.building{background:var(--accent-2);box-shadow:0 0 0 3px var(--accent-soft);
  animation:pulse 1.6s ease-in-out infinite}
@keyframes pulse{50%{opacity:.35}}
.auto-row .nm{flex:1;min-width:0;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;
  white-space:nowrap}
.auto-row .wh{font-size:11px;color:var(--fg-3);flex-shrink:0}

/* --------------------------------------------------- forms in the modals */
.field-row{display:flex;gap:10px}
.field textarea,.field select,.field input[type=number],.field input:not([type]),
.field input[type=text],.field input[type=search]{
  width:100%;padding:10px 12px;background:var(--bg-3);border:1px solid var(--line);
  border-radius:var(--radius-sm);outline:none;font-size:13.5px;
  transition:border-color .15s,box-shadow .15s}
.field textarea{resize:vertical;line-height:1.6;font-family:inherit}
.field textarea:focus,.field select:focus,.field input:focus{
  border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
.field-hint{font-size:11.5px;color:var(--fg-3);margin-top:6px;line-height:1.55}
.field-hint code{font-family:var(--mono);background:var(--bg-3);padding:1px 5px;border-radius:4px}
.modal-body .field{margin:0 8px 14px}
.check{display:flex;align-items:center;gap:8px;margin-top:10px;font-size:12.5px;
  color:var(--fg-2);cursor:pointer;font-weight:400}
.check input{width:15px;height:15px;accent-color:var(--accent)}
.seg{display:inline-flex;gap:3px;padding:3px;background:var(--bg-3);border:1px solid var(--line);
  border-radius:9px}
.seg-btn{padding:6px 14px;border-radius:7px;font-size:12.5px;color:var(--fg-3);
  transition:background .15s,color .15s}
.seg-btn.on{background:var(--bg-2);color:var(--fg);font-weight:560}
.chip-row{display:flex;gap:5px;flex-wrap:wrap;margin-top:8px}
.mini-chip{padding:4px 10px;border-radius:20px;border:1px solid var(--line-2);font-size:11.5px;
  color:var(--fg-2);background:var(--bg-3);transition:border-color .15s,color .15s}
.mini-chip:hover{border-color:var(--accent);color:var(--fg)}
.mini-chip.on{background:var(--accent-soft);border-color:transparent;color:var(--accent-2)}

/* ------------------------------------------------ automation detail panel */
.ad-grid{display:grid;grid-template-columns:auto 1fr;gap:8px 16px;padding:12px 10px;
  font-size:13px;align-items:baseline}
.ad-grid dt{color:var(--fg-3);font-size:12px}
.ad-grid dd{margin:0;min-width:0;overflow-wrap:anywhere}
.ad-block{margin:10px 8px;padding:12px 14px;border-radius:var(--radius);background:var(--bg-3);
  border:1px solid var(--line)}
.ad-block h4{margin:0 0 7px;font-size:12px;color:var(--fg-3);font-weight:600;
  text-transform:uppercase;letter-spacing:.5px}
.ad-block p{margin:0;font-size:13.5px;line-height:1.65}
.ad-code{width:100%;min-height:400px;font-family:var(--mono);font-size:12px;line-height:1.65;
  background:var(--bg-3);border:1px solid var(--line);border-radius:var(--radius-sm);
  padding:12px;outline:none;resize:vertical;white-space:pre;overflow-wrap:normal;
  overflow-x:auto;tab-size:4}
.ad-code:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
.run-row{display:flex;gap:10px;align-items:flex-start;padding:10px 11px;border-radius:9px;
  border:1px solid var(--line);margin:0 8px 6px;background:var(--bg-2)}
.run-row .dot{width:8px;height:8px;border-radius:50%;margin-top:6px;flex-shrink:0}
.run-row .dot.ok{background:var(--ok)} .run-row .dot.quiet{background:var(--fg-3)}
.run-row .dot.bad{background:var(--err)}
.run-main{flex:1;min-width:0}
.run-when{font-size:12px;color:var(--fg-2);display:flex;gap:7px;flex-wrap:wrap;align-items:center}
.run-when .k{font-size:10.5px;padding:1px 7px;border-radius:20px;background:var(--bg-4);
  color:var(--fg-3)}
.run-out{margin-top:6px;font-family:var(--mono);font-size:11.5px;white-space:pre-wrap;
  color:var(--fg-2);max-height:200px;overflow:auto}
.run-out.err{color:#ff9aa2}

/* -------------------------------------------------------- WhatsApp panel */
.wa-state{margin:10px 8px;padding:14px 15px;border-radius:var(--radius);display:flex;gap:12px;
  align-items:flex-start;border:1px solid var(--line);background:var(--bg-3)}
.wa-state.ok{border-color:rgba(49,196,141,.35);background:rgba(49,196,141,.07)}
.wa-state.warn{border-color:rgba(245,165,36,.35);background:rgba(245,165,36,.07)}
.wa-state.bad{border-color:rgba(240,97,109,.35);background:rgba(240,97,109,.07)}
.wa-state .big{font-size:22px;line-height:1.2;flex-shrink:0}
.wa-state .grow{flex:1;min-width:0}
.wa-state h4{margin:0 0 4px;font-size:14px;font-weight:620}
.wa-state p{margin:0;font-size:12.5px;color:var(--fg-2);line-height:1.6}
.wa-state code{font-family:var(--mono);font-size:11.5px;background:var(--bg-4);padding:1px 5px;
  border-radius:4px}
.wa-row{display:flex;align-items:center;gap:10px;padding:9px 11px;margin:0 8px 4px;
  border-radius:9px;border:1px solid var(--line);background:var(--bg-2);font-size:13px}
.wa-row .ph{font-family:var(--mono);font-size:12px;color:var(--fg-2)}
.wa-row .dot{width:7px;height:7px;border-radius:50%;flex-shrink:0;background:var(--fg-3)}
.wa-row .dot.ok{background:var(--ok)} .wa-row .dot.bad{background:var(--err)}
.wa-row .wh{font-size:11px;color:var(--fg-3);flex-shrink:0}
.wa-row .grow{flex:1;min-width:0}
.wa-sub{font-size:11.5px;color:var(--fg-3);margin:14px 8px 6px;font-weight:600;
  text-transform:uppercase;letter-spacing:.5px}
.wa-send{display:flex;gap:8px;margin:0 8px}
.wa-send input{flex:1;padding:10px 12px;background:var(--bg-3);border:1px solid var(--line);
  border-radius:var(--radius-sm);outline:none;font-size:13.5px}
.wa-send input:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}

@media(max-width:760px){
  .sched-view{padding:16px 14px 32px}
  .sched-head h2{font-size:20px}
  .auto-card{flex-wrap:wrap}
  .auto-side{flex-direction:row;align-items:center;width:100%;justify-content:space-between}
  .ad-grid{grid-template-columns:1fr;gap:2px 0}
  .ad-grid dt{margin-top:8px}
}

/* Only the tail of a long thread is loaded up front; this is the way back. */
.load-earlier{display:flex;justify-content:center;padding:6px 0 14px}
.load-earlier button{padding:7px 16px;border-radius:20px;border:1px solid var(--line-2);
  background:var(--bg-2);font-size:12.5px;color:var(--fg-2);
  transition:border-color .15s,color .15s}
.load-earlier button:hover{border-color:var(--accent);color:var(--fg)}
.load-earlier button:disabled{opacity:.6;cursor:default}
/* Placeholder in a timeline whose steps are still on the server. */
.step-load{padding:8px 10px;font-size:12px;color:var(--fg-3);font-style:italic}

/* ─────────────────────────────────── switch to the Super Dashboard ──
 * The one piece of the chat console that knows the dashboard exists: a link,
 * nothing more.  Styled loudly because it is a change of context, not a
 * change of view — the destination is a separate page with its own stylesheet
 * and its own scripts. */
.to-dash{
  display:flex; align-items:center; gap:11px;
  margin:10px 12px 0; padding:9px 11px;
  border:1px solid var(--line); border-radius:var(--radius);
  background:linear-gradient(135deg, rgba(232,163,61,.10), rgba(87,198,232,.07));
  color:inherit; text-decoration:none;
  transition:border-color .16s ease, transform .16s ease;
}
.to-dash:hover{ border-color:#e8a33d; transform:translateY(-1px); }
.to-dash:active{ transform:none; }
.to-dash .td-mark{
  flex:none; width:26px; height:26px; display:grid; place-items:center;
  border-radius:7px; background:rgba(232,163,61,.14); color:#e8a33d;
  font:13px/1 "JetBrains Mono", ui-monospace, monospace; letter-spacing:-2px;
}
.to-dash .td-txt{
  flex:1; min-width:0;
  font:600 12px/1.2 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing:.11em; color:var(--fg-2);
}
.to-dash .td-txt b{ color:#e8a33d; font-weight:600; }
.to-dash .td-go{ flex:none; width:15px; height:15px; color:#e8a33d; opacity:.65; }

/* ──────────────────────────────────── the two task rows ──
 * Todo Tasks and Task Doer sit on one line, by request.  The pair owns the
 * margins so the two children can be pure halves — putting a horizontal margin
 * on a flex child here is what makes "50%" overflow the rail by exactly the
 * gap.  Each keeps its own accent (violet, ice) because they go to different
 * places: one opens a panel over this console, the other is a separate page.
 */
.rail-pair{
  display:flex; gap:8px; margin:8px 12px 0; align-items:stretch;
}
.rail-pair > *{ flex:1 1 0; min-width:0; margin:0; }

.to-doer{
  display:flex; align-items:center; gap:8px;
  padding:9px 10px;
  border:1px solid var(--line); border-radius:var(--radius);
  background:linear-gradient(135deg, rgba(87,198,232,.12), rgba(63,176,138,.06));
  color:inherit; text-decoration:none;
  transition:border-color .16s ease, transform .16s ease;
}
.to-doer:hover{ border-color:#57c6e8; transform:translateY(-1px); }
.to-doer:active{ transform:none; }
.to-doer .tdr-mark{
  flex:none; width:24px; height:24px; display:grid; place-items:center;
  border-radius:7px; background:rgba(87,198,232,.14); color:#57c6e8;
  font:14px/1 "JetBrains Mono", ui-monospace, monospace;
}
.to-doer .tdr-txt{
  flex:1; min-width:0;
  font:600 11px/1.2 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing:.06em; color:var(--fg-2);
  /* The rail narrows on a phone before these labels do; clipping beats
     wrapping "TASKDOER" onto two lines and making the pair taller. */
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.to-doer .tdr-txt b{ color:#57c6e8; font-weight:600; }
/* Ice reads on the dark rail and greys out on white, like the violet beside it. */
:root[data-theme="light"] .to-doer{
  background:linear-gradient(135deg, rgba(14,116,144,.10), rgba(63,176,138,.06));
}
:root[data-theme="light"] .to-doer:hover{ border-color:#0e7490; }
:root[data-theme="light"] .to-doer .tdr-txt b{ color:#0e7490; }
:root[data-theme="light"] .to-doer .tdr-mark{
  color:#0e7490; background:rgba(14,116,144,.13);
}

/* ─────────────────────────────────────────────── Todo Tasks ──
 * Same shape as the dashboard link above, deliberately: the rail's two loud
 * rows read as one pair.  It sits where the Memory link used to, which is why
 * it borrows that block's geometry rather than inventing a third one — but it
 * is a button, not a link: the list opens over this console because a task
 * turns into a chat in it.  Violet rather than amber, so the two are told
 * apart without reading either.
 */
.to-todo{
  display:flex; align-items:center; gap:8px;
  padding:9px 10px;
  border:1px solid var(--line); border-radius:var(--radius);
  background:linear-gradient(135deg, rgba(167,139,250,.12), rgba(108,140,255,.06));
  color:inherit; text-align:left;
  transition:border-color .16s ease, transform .16s ease;
}
.to-todo:hover{ border-color:#a78bfa; transform:translateY(-1px); }
.to-todo:active{ transform:none; }
.to-todo .tt-mark{
  flex:none; width:24px; height:24px; display:grid; place-items:center;
  border-radius:7px; background:rgba(167,139,250,.16); color:#a78bfa;
  font-size:14px; font-weight:700;
}
.to-todo .tt-txt{
  flex:1; min-width:0;
  font:600 11px/1.2 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing:.06em; color:#a78bfa;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
/* How many are waiting — the reason to look at the row at all. */
.to-todo .tt-count{
  flex:none; min-width:18px; height:18px; padding:0 5px; border-radius:99px;
  background:#a78bfa; color:#0b0d12; font:700 10px/18px var(--sans);
  font-style:normal; text-align:center;
}
/* The dark theme's violet is legible on #0b0d12 and washes out on white, so
   light mode gets a darker one of the same family rather than the same hex. */
:root[data-theme="light"] .to-todo{
  background:linear-gradient(135deg, rgba(124,58,237,.10), rgba(108,140,255,.06));
}
:root[data-theme="light"] .to-todo:hover{ border-color:#7c3aed; }
:root[data-theme="light"] .to-todo .tt-txt{ color:#6d28d9; }
:root[data-theme="light"] .to-todo .tt-mark{
  color:#6d28d9; background:rgba(124,58,237,.13);
}
:root[data-theme="light"] .to-todo .tt-count{ background:#6d28d9; color:#fff; }

.to-dash:hover .td-go{ opacity:1; }

/* ------------------------------------------------------- pinned panel */
/* A sheet on the right rather than a centred modal: it is a list you pick
   from and dismiss, so it should feel like a drawer, not an interruption. */
/* .overlay centres its child; this one is pinned to the right edge instead. */
#pins{align-items:stretch;justify-content:flex-end;padding:0}
.side-sheet{position:relative;inset:auto;width:min(420px,100%);display:flex;
  flex-direction:column;background:var(--bg-2);border-left:1px solid var(--line);
  box-shadow:-24px 0 60px -30px rgba(0,0,0,.8);animation:slide-in .26s cubic-bezier(.22,1,.36,1)}
@keyframes slide-in{from{transform:translateX(100%)}}
.ss-head{display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:16px 18px;border-bottom:1px solid var(--line)}
.ss-head h2{margin:0;font-size:15px;font-weight:650;letter-spacing:-.01em}
.ss-body{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:10px}
.ss-body .conv{border-radius:9px}
.ss-empty{padding:40px 18px;text-align:center;color:var(--fg-3);font-size:13px;line-height:1.7}
.pin-count{position:absolute;top:1px;right:1px;min-width:15px;height:15px;padding:0 3px;
  border-radius:9px;background:var(--accent-2);color:#0b0d12;font-size:9.5px;font-weight:700;
  display:grid;place-items:center;line-height:1}
#pins-btn{position:relative}

/* ---------------------------------------------------- Todo Tasks panel */
/* The same right-hand sheet as pinned chats, for the same reason: a list you
   pick from and dismiss. A footer, though — this list is added to, not just
   read from, and "New task" has to be reachable without scrolling to the end
   of it. */
#todos{align-items:stretch;justify-content:flex-end;padding:0}
.ss-foot{display:flex;align-items:center;gap:10px;padding:12px 16px;
  border-top:1px solid var(--line);background:var(--bg-2)}
.td-show{flex:1;display:flex;align-items:center;gap:7px;font-size:12.5px;
  color:var(--fg-3);cursor:pointer;user-select:none}
.td-show input{accent-color:var(--accent);width:14px;height:14px;cursor:pointer}

.td-row{padding:12px 13px;margin-bottom:8px;border:1px solid var(--line);
  border-radius:11px;background:var(--bg-3)}
.td-row:hover{border-color:var(--line-2)}
/* Done tasks stay in the list but stop competing for attention. */
.td-row.done{opacity:.55}
.td-row.done .td-head .t{text-decoration:line-through}
.td-head{display:flex;align-items:baseline;gap:8px}
.td-head .t{flex:1;min-width:0;font-size:14px;font-weight:600;line-height:1.45;
  word-break:break-word}
.td-tag{flex:none;font-style:normal;font-size:10px;font-weight:700;letter-spacing:.08em;
  text-transform:uppercase;color:#a78bfa;background:rgba(167,139,250,.14);
  border-radius:99px;padding:2px 7px}
/* Three lines of the note, which is enough to recognise it; the whole thing is
   in the editor, and a wall of text here would bury the rows underneath. */
.td-desc{margin:7px 0 0;font-size:12.5px;line-height:1.6;color:var(--fg-2);
  white-space:pre-wrap;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;
  overflow:hidden}
.td-meta{display:flex;align-items:center;gap:8px;margin-top:9px;
  font-size:11.5px;color:var(--fg-3)}
.td-when{margin-left:auto}
.td-acts{display:flex;align-items:center;gap:4px;margin-top:10px}
.td-start{flex:1;display:flex;align-items:center;justify-content:center;gap:7px;
  padding:7px 12px;border-radius:8px;border:1px solid var(--line-2);
  background:var(--bg-4);color:var(--fg);font-size:12.5px;font-weight:600;
  transition:border-color .13s,background .13s}
.td-start:hover{border-color:#a78bfa;background:rgba(167,139,250,.12)}
.td-start svg{width:13px;height:13px;fill:currentColor;stroke:none}
/* .act is styled under .conv elsewhere; these rows are not conversations. */
.td-acts .act{width:29px;height:29px;border-radius:8px;display:grid;place-items:center;
  color:var(--fg-3);flex-shrink:0;transition:color .13s,background .13s}
.td-acts .act:hover{color:var(--fg);background:var(--bg-4)}
.td-acts .del:hover{color:var(--err);background:var(--bg-4)}
.td-acts .act svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round}
/* How many files the note carries. Count, not names: the row is for
   recognising the task, and the names are a hover away. */
.td-clip{color:var(--fg-2)}
/* The attach button in the editor. Full width and quiet — it is an option, not
   the thing you came to the form to do. */
.td-attach{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;
  border:1px dashed var(--line-2);border-radius:10px;padding:10px;font-size:12.5px;
  color:var(--fg-2)}
.td-attach:hover{border-color:var(--accent);color:var(--fg)}
.td-attach svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:1.9;
  stroke-linecap:round;stroke-linejoin:round}
#td-chips:empty{display:none}
