:root {
  --bg-sidebar: #0d0d0d;
  --bg-main: #171717;
  --bg-bubble: #212121;
  --bg-hover: #1c1c1c;
  --bg-active: #262626;
  --border: #2a2a2a;
  --text: #ececec;
  --text-dim: #9a9a9a;
  --text-faint: #6b6b6b;
  --blue: #2f72e4;
  --blue-dot: #4b8df8;
  --green: #4cc06a;
  --red: #e5484d;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-main);
  color: var(--text);
  font: 14.5px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
  width: 280px; flex-shrink: 0;
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  padding: 12px 10px 12px;
}
.sidebar-top { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: #1c1c1c; display: grid; place-items: center; color: #d6d6d6;
  transition: background .15s;
}
.icon-btn:hover { background: #2a2a2a; }
/* Sits on the same line as the buttons and takes the space to their left. */
.search {
  flex: 1; min-width: 0; height: 36px; padding: 0 14px;
  border-radius: 999px; background: #1c1c1c; border: 1px solid var(--border);
  color: var(--text); font: inherit; font-size: 13.5px; outline: none;
}
.search[hidden] { display: none; }
.search:focus { border-color: #3d3d3d; }
.search::placeholder { color: var(--text-faint); }

.sidebar-brand {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  margin: 10px auto 16px; font-size: 13.5px; color: #dcdcdc;
}
.sidebar-brand img { width: 56px; height: 56px; display: block; }
/* logo.svg animates itself. With reduced motion, show the same file with its still-view fragment instead: that choice is made by the page, so it holds even where an image ignores the setting. */
.logo-still { display: none !important; }
@media (prefers-reduced-motion: reduce) { .logo-live { display: none !important; } .logo-still { display: block !important; } }

.bot-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.bot-row {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 7px 8px; border-radius: 12px; position: relative;
}
.bot-row:hover { background: var(--bg-hover); }
.bot-row.active { background: var(--bg-active); }
.bot-row .meta { min-width: 0; flex: 1; }
.bot-row .name { font-size: 14.5px; color: #f0f0f0; }
.bot-row .preview {
  font-size: 13px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 18px;
}
.bot-row .unread {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 9px; height: 9px; border-radius: 50%; background: var(--blue-dot);
}

.hidden-bots {
  display: flex; justify-content: space-between;
  margin-top: 14px; padding: 8px 10px; font-size: 13.5px; color: var(--text-dim);
}
.hidden-bots:hover { color: var(--text); }

.sidebar-bottom { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: 0 2px; }
.me { display: flex; align-items: center; gap: 10px; font-size: 14.5px; }
.me-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #3a3a3a, #1e1e1e); border: 2px solid #444;
  display: grid; place-items: center; font-weight: 600; color: #ddd;
}

/* Bot avatar: each icon turns to the left, blinks and turns back, blinks now
   and then, and later does the same to the right, one 16 to 22 second timeline
   (0 to 8% left, 56 to 64% right, the rest idle blinks). app.js sets --life and
   --delay inline per icon, so no two icons are in step and no timer runs in JS.
   It reads as a rounded 3D head turning, not a flat shape squashing: the body
   narrows only a little, the eyes slide a long way and the eye on the turn side
   narrows (it is further round the curve) while the near one stays wide, and the
   two shading layers inside the body (.avatar-lit: a rim shade and a gloss, see
   shine() in app.js) slide the other way, so the turn side darkens. One blink
   sequence only, so blinks never fight. A Bot also bounces gently while it is
   working. logo.svg carries the same timeline. Only transforms animate. */
.avatar { display: block; flex-shrink: 0; }
.agent-face { flex-shrink: 0; display: inline-block; }
.avatar-turn { transform-box: view-box; transform-origin: 50% 50%; animation: avatar-turn var(--life, 19s) ease-in-out var(--delay, 0s) infinite; }
.avatar-eyes { transform-box: fill-box; transform-origin: center; animation: avatar-eyes var(--life, 19s) ease-in-out var(--delay, 0s) infinite; }
/* --tl-* is the pose when the head looks left, --tr-* when it looks right: how far the eye slides (times --eye) and how wide it stays. */
.avatar-eye-l { --tl-x: -.93; --tl-s: .8; --tr-x: 1.07; --tr-s: 1.04; }
.avatar-eye-r { --tl-x: -1.07; --tl-s: 1.04; --tr-x: .93; --tr-s: .8; }
.avatar-lit { animation: avatar-lit var(--life, 19s) ease-in-out var(--delay, 0s) infinite; }
.avatar-working { animation: avatar-bounce 1.25s ease-in-out infinite; will-change: transform; }
@keyframes avatar-bounce { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-5px) rotate(2deg); } }
@keyframes avatar-turn {
  0%, 8%, 56%, 64%, 100% { transform: scaleX(1); }
  2.6%, 5.6%, 58.6%, 61.6% { transform: scaleX(.94); }
}
@keyframes avatar-lit {
  0%, 8%, 56%, 64%, 100% { transform: translateX(0); }
  2.6%, 5.6% { transform: translateX(var(--lit, 4px)); }
  58.6%, 61.6% { transform: translateX(calc(var(--lit, 4px) * -1)); }
}
@keyframes avatar-eyes {
  0%, 8%, 21.2%, 22.8%, 37.2%, 38.8%, 56%, 64%, 73.2%, 74.8%, 89.2%, 90.8%, 100% { transform: translateX(0) scaleX(1) scaleY(1); }
  22%, 38%, 74%, 90% { transform: translateX(0) scaleX(1) scaleY(.1); }
  2.2%, 3.3%, 4.7%, 5.8% { transform: translateX(calc(var(--eye, 5.6px) * var(--tl-x))) scaleX(var(--tl-s)) scaleY(calc(.5 + var(--tl-s) * .5)); }
  4% { transform: translateX(calc(var(--eye, 5.6px) * var(--tl-x))) scaleX(var(--tl-s)) scaleY(.1); }
  58.2%, 59.3%, 60.7%, 61.8% { transform: translateX(calc(var(--eye, 5.6px) * var(--tr-x))) scaleX(var(--tr-s)) scaleY(calc(.5 + var(--tr-s) * .5)); }
  60% { transform: translateX(calc(var(--eye, 5.6px) * var(--tr-x))) scaleX(var(--tr-s)) scaleY(.1); }
}
@media (prefers-reduced-motion: reduce) { .avatar-turn, .avatar-eyes, .avatar-lit, .avatar-working { animation: none; } }

/* Chat */
.chat { flex: 1; display: flex; flex-direction: column; position: relative; min-width: 0; }
.chat-header {
  height: 60px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.bot-pill {
  display: flex; align-items: center; gap: 10px;
  height: 36px; background: #1f1f1f; padding: 0 14px 0 6px; border-radius: 999px; font-size: 15.5px;
}
.share-btn {
  position: absolute; right: 16px;
  height: 36px; background: #1f1f1f; padding: 0 15px; border-radius: 999px; font-size: 14.5px;
}
.share-btn:hover, .bot-pill:hover { background: #292929; }

/* A Bot's live screen, beside the chat */
.share-btn.screen-btn { right: 92px; }
.screen { width: 46%; min-width: 420px; flex-shrink: 0; display: flex; flex-direction: column; border-left: 1px solid var(--border); background: #111; }
.screen[hidden] { display: none; }
.screen-bar { height: 60px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.screen-bar span { flex: 1; font-size: 14.5px; color: #dcdcdc; }
.screen-take { height: 36px; background: #1f1f1f; padding: 0 15px; border-radius: 999px; font-size: 13.5px; }
.screen-take:hover { background: #292929; }
.screen-take.on { background: var(--blue); color: #fff; }
.screen-view { flex: 1; position: relative; margin: 0 16px 16px; border-radius: 12px; overflow: hidden; background: #000; }
.screen-view iframe { width: 100%; height: 100%; border: 0; display: block; }
.screen-shield { position: absolute; inset: 0; cursor: default; }
.screen-shield[hidden] { display: none; }
.screen-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--text-dim); }
.question .open-screen { margin: 4px 0 6px; background: var(--blue); color: #fff; padding: 7px 14px; border-radius: 999px; font-size: 13.5px; }

.messages {
  flex: 1; overflow-y: auto;
  padding: 18px 80px 140px 80px;
  display: flex; flex-direction: column; gap: 14px;
}
.no-bots { margin: auto; text-align: center; color: var(--text-dim); }
.no-bots h1 { margin: 0 0 8px; color: var(--text); font-size: 22px; font-weight: 600; }
.no-bots p { margin: 0 0 20px; font-size: 14px; }
.no-bots button { padding: 10px 20px; border-radius: 999px; background: var(--blue); color: #fff; font: inherit; }
.composer[hidden], .share-btn[hidden] { display: none; }
.timestamp { align-self: center; max-width: 760px; width: 100%; text-align: center; color: var(--text-dim); font-size: 13px; margin: 6px 0 2px; }
.msg-row { display: flex; align-items: center; gap: 12px; max-width: 1240px; width: 100%; margin: 0 auto; }
.msg-row.user { justify-content: flex-end; }
.bubble {
  background: var(--bg-bubble); border: 1px solid #262626;
  padding: 10px 16px; border-radius: 18px;
  /* min-width:0 matters: without it a wide code block refuses to shrink and
     pushes the whole chat past the edge of the window. */
  max-width: min(760px, 100%); min-width: 0;
  font-size: 15px; line-height: 1.6;
}
.bubble p { margin: 0 0 6px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 4px 0 2px; padding-left: 22px; }
.bubble li { margin: 3px 0; }
.bubble strong { font-weight: 600; }
.msg-row.user .bubble { background: var(--blue); border-color: var(--blue); color: #fff; border-radius: 22px; }

.actions { display: flex; gap: 6px; color: #aaa; opacity: 0; transition: opacity .15s; }
.msg-row:hover .actions { opacity: 1; }
.actions button { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; }
.actions button:hover { background: #262626; color: #fff; }
.actions button.copied { color: var(--green); background: rgba(76, 192, 106, .16); }
.actions svg { width: 18px; height: 18px; }

.question { width: 760px; max-width: 100%; padding: 16px 20px 10px; }
.question h4 { margin: 0 0 12px; font-size: 15px; font-weight: 500; color: #cfcfcf; }
.option {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 10px 0; color: var(--text-dim); font-size: 15px;
}
.option .key {
  width: 30px; height: 30px; border-radius: 8px; background: #2a2a2a;
  display: grid; place-items: center; font-size: 11.5px; color: #8d8d8d;
}
.option:hover { color: var(--text); }
.option:hover .key { background: #343434; color: #ddd; }
.option.picked { color: #fff; }
.option.picked .key { background: var(--blue); color: #fff; }
.question.answered .option:not(.picked) { opacity: .45; pointer-events: none; }
.question .expired { margin: -6px 0 6px; font-size: 13.5px; color: var(--text-dim); }

.typing { display: flex; gap: 4px; padding: 14px 16px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #888; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.scroll-down {
  position: absolute; left: 50%; bottom: 116px; transform: translateX(-50%);
  width: 36px; height: 36px; border-radius: 50%; background: #1f1f1f; border: 1px solid var(--border);
  display: none; place-items: center; color: #ddd;
}
.scroll-down.show { display: grid; }

.composer {
  position: absolute; left: 80px; right: 80px; bottom: 38px;
  max-width: 1240px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  background: #1c1c1c; border: 1px solid var(--border);
  border-radius: 24px; padding: 6px 7px 6px 8px;
  box-shadow: 0 -16px 32px rgba(23,23,23,.9); z-index: 20;
}
.composer textarea {
  flex: 1; min-width: 0; align-self: center; background: none; border: 0; outline: none; color: var(--text);
  font: inherit; font-size: 14.5px; line-height: 21px; padding: 0; margin: 0;
  resize: none; display: block;
  /* Grows with what you type up to three lines (sized by app.js), then scrolls. */
  height: 21px; max-height: 63px; overflow-y: hidden;
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer-plus { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #aaa; background: #262626; }
.composer-mic { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #aaa; background: #262626; }
.composer-voice { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--blue); color: #fff; }
.composer-plus:hover, .composer-mic:hover { color: #fff; }

/* Attach: the menu above the + button, and the chips above the text box */
.plus-menu {
  position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 40;
  background: #1f1f1f; border: 1px solid #2f2f2f; border-radius: 14px; padding: 6px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, .55); display: flex; flex-direction: column; min-width: 164px;
}
.plus-menu[hidden] { display: none; }
.plus-menu button {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 9px 12px; border-radius: 9px; font-size: 13.5px;
}
.plus-menu button:hover { background: #2a2a2a; }
.plus-menu span { font-size: 14.5px; }
/* Picked files: above the box and the model picker, in front of everything. */
.chips {
  position: absolute; left: 6px; right: 6px; bottom: calc(100% + 34px); z-index: 40;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.chips:empty { display: none; }
.composer-error { position: absolute; right: 8px; bottom: calc(100% + 8px); max-width: 60%; color: #f08a8a; font-size: 13px; background: #1c1c1c; border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; }
.composer-error:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; max-width: 260px;
  background: #262626; border: 1px solid #333; box-shadow: 0 6px 18px rgba(0, 0, 0, .45); border-radius: 999px; padding: 3px 5px 3px 7px; font-size: 12px;
}
.chip img { width: 24px; height: 24px; border-radius: 6px; object-fit: cover; }
.chip-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; color: var(--text-dim); font-size: 12.5px; line-height: 1; }
.chip button:hover { background: var(--red); color: #fff; }

/* Attachments shown in the chat history */
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.atts:last-child { margin-bottom: 0; }
.att-img img { max-width: 220px; max-height: 180px; border-radius: 10px; display: block; }
.att-chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px;
  background: rgba(0, 0, 0, .25); border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px; padding: 4px 11px; color: inherit; text-decoration: none;
}
.att-chip:hover { background: rgba(0, 0, 0, .4); }

/* Branding: one faint line under the composer */
.footnote { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; font-size: 11px; color: #5c5c5c; }
.footnote b { font-weight: 600; color: #8a8a8a; }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: #2c2c2c; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* Live backend */
.bot-row .preview em, .typing .status { font-style: normal; color: var(--text-dim); }
.empty { color: var(--text-faint); padding: 12px; font-size: 13.5px; }
.bot-pill { cursor: pointer; }
.bot-pill .harness { font-size: 11.5px; color: var(--text-faint); }
.bubble.error { border-color: #5a2a2a; color: #f1b5b5; }
.bubble code { background: #2b2b2b; padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.bubble pre { background: #141414; border: 1px solid #2a2a2a; border-radius: 10px; padding: 10px 12px; overflow-x: auto; margin: 6px 0; }
.bubble pre code { background: none; padding: 0; }
.bubble a { color: var(--blue-dot); }
.bubble ol { margin: 4px 0 2px; padding-left: 22px; }
.timestamp.routine { font-size: 12px; color: var(--text-faint); white-space: pre-line; max-height: 6em; overflow: hidden; overflow-wrap: anywhere; flex-shrink: 0; }
.typing { align-items: center; }
.typing .status { margin-left: 8px; font-size: 13px; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typing .stop { margin-left: 10px; font-size: 12px; color: var(--text-dim); border: 1px solid #333; border-radius: 999px; padding: 1px 10px; }
.typing .stop:hover { color: #fff; border-color: #555; }
.msg-row.peer { justify-content: flex-end; }
.msg-row.peer .bubble { background: #1b2230; border-color: #263247; }
.bubble .from { font-size: 11.5px; color: var(--text-dim); margin-bottom: 2px; }

/* New Bot window */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; }
.modal-backdrop[hidden] { display: none; }
.modal { width: 620px; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); overflow-y: auto; background: #1f1f1f; border: 1px solid #2c2c2c; border-radius: 26px; box-shadow: 0 24px 80px rgba(0,0,0,.55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 18px 26px; border-bottom: 1px solid #2c2c2c; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 600; }
.modal-close { width: 32px; height: 32px; display: grid; place-items: center; color: #bbb; border-radius: 8px; }
.modal-close:hover { color: #fff; background: #2a2a2a; }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { padding: 22px 32px 34px; display: flex; flex-direction: column; align-items: center; }
.nb-preview { height: 150px; margin: 6px 0 26px; }
.nb-input { width: 100%; height: 50px; background: transparent; border: 1px solid #2f2f2f; border-radius: 14px; padding: 0 16px; font: inherit; font-size: 15.5px; text-align: center; color: var(--text); outline: none; margin-bottom: 34px; }
.nb-input:focus { border-color: #444; }
.nb-input::placeholder { color: #8a8a8a; }
.nb-shapes { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px 26px; width: 470px; max-width: 100%; margin-bottom: 40px; }
.nb-shape { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 14px; transition: transform .12s; }
.nb-shape:hover { transform: scale(1.08); }
.nb-colors { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; width: 400px; max-width: 100%; }
.nb-color { width: 34px; height: 34px; border-radius: 50%; outline: 2px solid transparent; outline-offset: 5px; }
.nb-color.on { outline-color: #4a4a4a; }
.nb-hex-label { margin-top: 18px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-dim); }
.nb-hex-label input, .d-color { width: 105px; border: 1px solid #3b3b3b; border-radius: 8px; padding: 7px 9px; background: #171717; color: var(--text); font: inherit; text-transform: uppercase; }
.nb-hex-label input:focus, .d-color:focus { outline: 1px solid var(--blue); }
.nb-hex-error { margin-top: 6px; color: #f1b5b5; font-size: 12px; }
.d-color-swatch { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 1px solid #555; }
.nb-error { color: #f1b5b5; font-size: 13px; margin-top: 22px; }

/* Skill picker, used by the New Bot window and a Bot's settings */
.sk-head { display: flex; align-items: baseline; justify-content: space-between; width: 100%; margin: 30px 0 10px; font-size: 13.5px; color: var(--text-dim); }
.sk-head b { color: var(--text); font-weight: 500; margin-left: 4px; }
.sk-actions { display: flex; gap: 14px; }
.sk-link { font-size: 12px; color: var(--blue-dot); }
.sk-link:hover { text-decoration: underline; }
.sk-search {
  width: 100%; background: #141414; border: 1px solid #2f2f2f; border-radius: 10px;
  padding: 9px 13px; font: inherit; font-size: 13px; color: var(--text); outline: none; margin-bottom: 8px;
}
.sk-search:focus { border-color: #444; }
.sk-search::placeholder { color: var(--text-faint); }
.sk-list { width: 100%; max-height: 260px; overflow-y: auto; border: 1px solid #242424; border-radius: 12px; background: #161616; }
.sk-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; cursor: pointer; }
.sk-row:hover { background: #1d1d1d; }
.sk-row input { margin-top: 3px; accent-color: var(--blue); flex-shrink: 0; }
.sk-row.off { opacity: .45; }
.sk-meta { min-width: 0; flex: 1; }
.sk-name { font-size: 13px; }
.sk-tag { font-size: 10px; color: var(--text-faint); border: 1px solid #333; border-radius: 999px; padding: 1px 7px; margin-left: 7px; }
.sk-desc { font-size: 11px; color: var(--text-dim); line-height: 1.45; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sk-empty { padding: 16px 12px; color: var(--text-faint); font-size: 12.5px; }
.sk-group { padding: 7px 12px 3px; font-size: 11px; color: var(--text-faint); background: #131313; position: sticky; top: 0; }
.sk-warn { font-size: 11.5px; color: #e3cfa4; margin-top: 8px; }
.no-skill {
  margin-left: 8px; font-size: 10px; vertical-align: middle; white-space: nowrap;
  color: #e3cfa4; background: #23201a; border: 1px solid #3a3326; border-radius: 999px; padding: 1px 7px;
}

/* ---- Narrower windows ---------------------------------------------------
   Three steps: trim the roomy padding, then let the right-hand panels cover
   the chat instead of squeezing it, then turn the sidebar into a slide-over. */
.menu-btn { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 45; }
.backdrop[hidden] { display: none; }

@media (max-width: 1200px) {
  .sidebar { width: 260px; }
  .messages { padding: 18px 40px 140px; }
  .composer { left: 40px; right: 40px; }
  .details { width: 360px; }
}

@media (max-width: 980px) {
  .sidebar { width: 240px; padding: 12px 8px 12px; }
  .messages { padding: 14px 18px 136px; }
  .composer { left: 18px; right: 18px; }
  /* Centring the name makes it collide with the buttons once space is tight. */
  .chat-header { justify-content: space-between; gap: 10px; padding: 0 14px; }
  .bot-pill { min-width: 0; }
  .bot-pill > span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .share-btn, .share-btn.screen-btn { position: static; right: auto; }
  .details, .screen {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%);
    z-index: 40; box-shadow: -24px 0 70px rgba(0, 0, 0, .55);
  }
  .screen { min-width: 0; }
  .modal, .apps-modal { width: calc(100vw - 24px); }
  .app-grid { grid-template-columns: 1fr; }
  .nb-shapes, .nb-colors { width: 100%; }
}

@media (max-width: 720px) {
  .menu-btn { display: grid; flex-shrink: 0; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 86vw); z-index: 50;
    transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: 24px 0 70px rgba(0, 0, 0, .55);
  }
  .sidebar.open { transform: none; }
  .messages { padding: 10px 12px 128px; }
  .composer { left: 12px; right: 12px; }
  .composer { bottom: 28px; padding: 6px 7px 6px 9px; }
  .footnote { bottom: 7px; font-size: 10px; }
  .bubble { font-size: 14px; padding: 9px 13px; }
  .chat-header { height: 60px; padding: 0 10px; }
  .share-btn { padding: 8px 13px; font-size: 12.5px; }
  .details, .screen { width: 100%; }
  .modal-body { padding: 18px 18px 26px; }
  .modal-head, .apps-head { padding: 18px 16px 14px 20px; flex-wrap: wrap; }
  .apps-search { width: 100%; }
  .nb-preview { height: 110px; margin-bottom: 18px; }
  .nb-shape { width: 54px; height: 54px; }
}

@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 16px 18px 16px 32px; border-top: 1px solid #2c2c2c; }
.nb-runs { margin-right: auto; flex-shrink: 0; font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 8px; }
.nb-hint { font-size: 12.5px; color: #e3cfa4; }
.nb-runs select { background: #262626; color: var(--text); border: 1px solid #333; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; outline: none; }
.nb-btn { padding: 10px 24px; border-radius: 999px; font-size: 15.5px; border: 1px solid #3a3a3a; }
.nb-btn:hover { background: #2a2a2a; }
.nb-btn.primary { background: #f2f2f2; color: #111; border-color: #f2f2f2; }
.nb-btn.primary:hover { background: #fff; }
.nb-btn.primary:disabled { background: #333; color: #777; border-color: #333; cursor: default; }

/* Model and effort picker: faint, above the input */
.model-bar {
  position: absolute; left: 10px; bottom: calc(100% + 6px);
  display: flex; gap: 2px;
}
.model-bar[hidden], .model-bar select[hidden] { display: none; }
.model-bar select {
  appearance: none; field-sizing: content; max-width: 320px;
  font: inherit; font-size: 11.5px; color: var(--text-faint);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b6b6b' stroke-width='1.3'/%3E%3C/svg%3E") no-repeat right 7px center / 8px;
  border: 0; border-radius: 7px; padding: 3px 20px 3px 8px; cursor: pointer; outline: none;
}
.model-bar select:hover, .model-bar select:focus-visible { color: var(--text-dim); background-color: #1f1f1f; }
.model-bar option { background: #1c1c1c; color: var(--text); }

/* Bot details panel (click the name at the top) */
.details { width: 400px; flex-shrink: 0; background: #111; border-left: 1px solid #222; overflow-y: auto; padding: 18px 22px 30px; position: relative; }
.details[hidden] { display: none; }
.d-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid #2c2c2c; background: #161616; display: grid; place-items: center; color: #ccc; }
.d-close:hover { color: #fff; background: #222; }
.d-hero { display: flex; flex-direction: column; align-items: center; padding-top: 34px; }
.d-name { margin-top: 14px; width: 100%; background: none; border: 1px solid transparent; border-radius: 10px; text-align: center; font: inherit; font-size: 20.5px; font-weight: 500; color: var(--text); padding: 4px 8px; outline: none; }
.d-name:hover { border-color: #2a2a2a; }
.d-name:focus { border-color: #3a3a3a; background: #181818; }
.d-tabs { display: flex; justify-content: center; gap: 6px; margin: 14px 0 6px; }
.d-tabs button { padding: 7px 16px; border-radius: 999px; font-size: 14.5px; color: var(--text-dim); }
.d-tabs button.on { background: #1e1e1e; color: var(--text); }
.d-section { display: flex; justify-content: space-between; color: var(--text-dim); font-size: 14px; margin: 22px 8px 10px; }
.d-card { background: #1a1a1a; border: 1px solid #242424; border-radius: 16px; padding: 6px 0; margin-bottom: 4px; }
.d-card + .d-card { margin-top: 12px; }
.d-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 16px; font-size: 14.5px; text-align: left; }
.d-item svg { width: 20px; height: 20px; color: #bbb; flex-shrink: 0; }
.d-link span { flex: 1; }
.d-link:hover { background: #202020; }
.d-link:disabled { opacity: .55; cursor: default; }
.d-link svg:last-child { width: 16px; height: 16px; color: #777; }
.d-action-form { margin: 12px 0 4px; padding: 16px; border: 1px solid #2b2b2b; border-radius: 16px; background: #1a1a1a; display: grid; gap: 12px; }
.d-action-form strong { font-size: 15px; font-weight: 600; }
.d-action-form label { display: grid; gap: 5px; color: var(--text-dim); font-size: 13px; min-width: 0; }
.d-action-form input, .d-action-form textarea, .d-action-form select { width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid #373737; border-radius: 9px; background: #101010; color: var(--text); font: inherit; font-size: 14px; outline: none; }
.d-action-form textarea { min-height: 88px; resize: vertical; }
.d-action-form input:focus, .d-action-form textarea:focus, .d-action-form select:focus { border-color: var(--blue); }
.d-action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.d-action-form small { color: var(--text-faint); font-size: 12px; }
.d-action-error { color: #f08a8a; font-size: 13px; }
.d-action-error:empty { display: none; }
.d-confirm { margin-top: 12px; border-radius: 16px; }
.d-delete-error { margin: 8px 8px 0; }
.d-action-buttons { display: flex; justify-content: flex-end; gap: 8px; }
.d-action-buttons button { padding: 8px 12px; border: 1px solid #363636; border-radius: 9px; }
.d-action-buttons button[type="submit"] { background: var(--blue); border-color: var(--blue); color: white; }
.d-action-buttons button:disabled { opacity: .55; cursor: default; }
.d-text { flex: 1; min-width: 0; }
.d-sub { color: var(--text-dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-empty { color: var(--text-faint); font-size: 13.5px; }
.d-danger, .d-danger svg { color: #f08a8a !important; }

/* Routines card: one row per routine */
.rs-row { padding: 12px 16px; display: grid; gap: 7px; min-width: 0; }
.rs-row + .rs-row { border-top: 1px solid #242424; }
.rs-top { display: flex; align-items: center; gap: 12px; }
.rs-name { font-size: 14.5px; overflow-wrap: anywhere; }
.rs-dim { color: var(--text-dim); font-size: 13px; }
.rs-sched { overflow-wrap: anywhere; }
.rs-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; font-size: 13px; min-width: 0; }
.rs-mark { display: inline-grid; place-items: center; flex-shrink: 0; }
.rs-mark svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rs-word { font-weight: 500; }
[data-status="ok"] > .rs-line .rs-mark, [data-status="ok"] > .rs-line .rs-word { color: var(--green); }
[data-status="failed"] > .rs-line .rs-mark, [data-status="failed"] > .rs-line .rs-word,
[data-status="interrupted"] > .rs-line .rs-mark, [data-status="interrupted"] > .rs-line .rs-word { color: #f08a8a; }
[data-status="timeout"] > .rs-line .rs-mark, [data-status="timeout"] > .rs-line .rs-word,
[data-status="skipped"] > .rs-line .rs-mark, [data-status="skipped"] > .rs-line .rs-word { color: #e9a23b; }
[data-status="queued"] > .rs-line .rs-mark, [data-status="queued"] > .rs-line .rs-word,
[data-status="running"] > .rs-line .rs-mark, [data-status="running"] > .rs-line .rs-word { color: var(--blue-dot); }
[data-trigger="catch-up"][data-status="ok"] > .rs-line .rs-mark, [data-trigger="catch-up"][data-status="ok"] > .rs-line .rs-word { color: #e9a23b; }
.rs-spin { animation: rs-spin 0.9s linear infinite; }
@keyframes rs-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .rs-spin { animation: none; } }
.rs-detail { color: var(--text-dim); font-size: 12.5px; line-height: 1.4; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rs-paused { color: #e9a23b; font-size: 12.5px; line-height: 1.4; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rs-row .d-action-error { overflow-wrap: anywhere; }
.rs-notice { color: var(--green); font-size: 13px; overflow-wrap: anywhere; }
.rs-notice.warn { color: #e9a23b; }
.rs-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.app-btn.rs-btn { padding: 4px 9px; font-size: 12.5px; }
.mod-confirm.rs-confirm { margin-top: 0; padding: 10px 12px; }
.mod-confirm.rs-confirm span { min-width: 160px; }
.rs-edit { margin: 4px 0 0; background: #151515; }
.rs-hook { display: grid; gap: 6px; min-width: 0; }
.rs-hook label { display: grid; gap: 4px; }
.rs-hook-url { width: 100%; min-width: 0; font: 12px ui-monospace, Menlo, monospace; padding: 6px 8px; background: #111; color: var(--text); border: 1px solid #2c2c2c; border-radius: 6px; }
.rs-curl { margin: 0; padding: 8px; background: #111; border: 1px solid #242424; border-radius: 6px; font: 11.5px ui-monospace, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-dim); }
.rs-history { display: grid; gap: 0; border-top: 1px solid #242424; padding-top: 4px; max-height: 280px; overflow-y: auto; }
.rs-run { display: grid; gap: 3px; padding: 8px 0; }
.rs-run + .rs-run { border-top: 1px solid #202020; }
.d-action-row.single { grid-template-columns: 1fr; }
.d-computer { padding: 12px 12px 12px 16px; }
.d-screen { width: 104px; height: 64px; border-radius: 10px; background: linear-gradient(135deg, #2c2c2c, #1d1d1d); display: grid; place-items: center; position: relative; }
.d-screen:not(.awake) .avatar { opacity: .45; filter: grayscale(1); }
.d-screen i { position: absolute; top: 4px; right: 10px; font-size: 10px; color: #888; font-style: normal; }
.d-screen.awake { background: linear-gradient(135deg, #24324a, #1a2232); }
.details select { background: #232323; color: var(--text); border: 1px solid #333; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13.5px; outline: none; }
.details .d-action-form select { background: #101010; border-color: #373737; border-radius: 9px; padding: 9px 10px; font-size: 14px; }
.switch { width: 40px; height: 24px; border-radius: 999px; background: #3a3a3a; position: relative; flex-shrink: 0; transition: background .15s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--blue); }
.switch.on span { transform: translateX(16px); }

/* Voice input: red when idle, green on a green wash while listening */
.composer-mic { color: var(--red); transition: color .15s, background .15s; }
.composer-mic:hover { color: #ff7a7f; background: #2f2626; }
.composer-mic.on, .composer-mic.on:hover { color: var(--green); background: rgba(76, 192, 106, .18); }
.composer-mic.on svg { animation: mic-pulse 1.3s ease-in-out infinite; }
@keyframes mic-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
.composer-mic.busy, .composer-mic.busy:hover { color: #e9a23b; background: rgba(233, 162, 59, .18); }
.composer-mic.busy svg { animation: mic-pulse .8s ease-in-out infinite; }
.composer-mic[disabled]:not(.busy) { color: var(--text-faint); cursor: default; }

/* Your own picture, bottom-left */
.me-avatar-wrap { position: relative; display: block; }
.me-avatar { overflow: hidden; padding: 0; cursor: pointer; }
.me-avatar:hover { border-color: #666; }
.me-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.me-rm {
  position: absolute; top: -3px; right: -3px;
  width: 19px; height: 19px; border-radius: 50%;
  background: #333; border: 2px solid var(--bg-sidebar);
  display: none; place-items: center; color: #ddd;
}
.me-rm svg { width: 9px; height: 9px; stroke-width: 3; }
.me-avatar-wrap:hover .me-rm:not([hidden]) { display: grid; }
.me-rm:hover { background: var(--red); color: #fff; }

/* Apps: the marketplace window */
.apps-modal { width: min(1240px, calc(100vw - 48px)); overflow-x: hidden; }
.apps-head { align-items: flex-start; gap: 14px; padding: 18px 18px 14px 24px; }
.apps-title { flex: 1; min-width: 0; }
.apps-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
.apps-search {
  width: 200px; height: 36px; flex-shrink: 0; margin-top: 0;
  background: #141414; border: 1px solid #2f2f2f; border-radius: 999px;
  padding: 0 13px; font: inherit; font-size: 13px; color: var(--text); outline: none;
}
.apps-search:focus { border-color: #444; }
.apps-search::placeholder { color: var(--text-faint); }
.apps-body { display: block; padding: 2px 18px 22px; }
.apps-for { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-dim); margin: 6px 0 10px 6px; }
.apps-for b { color: var(--text); font-weight: 500; }
.apps-note {
  background: #23201a; border: 1px solid #3a3326; color: #e3cfa4;
  border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-bottom: 8px;
}
.apps-note[hidden] { display: none; }

.apps-filters { display: flex; flex-wrap: wrap; gap: 7px; margin: 4px 0 2px 4px; }
.apps-filters button {
  padding: 6px 13px; border-radius: 999px; font-size: 12px;
  color: var(--text-dim); border: 1px solid #2c2c2c; background: #171717;
}
.apps-filters button:hover { color: var(--text); border-color: #3a3a3a; }
.apps-filters button.on { background: #ececec; border-color: #ececec; color: #111; }
.app-cat { font-size: 13.5px; color: var(--text-dim); margin: 16px 0 4px 6px; }
.app-why { font-size: 11px; color: var(--text-faint); line-height: 1.5; margin-top: 3px; }
/* Fills the extra width with more columns instead of a sideways scrollbar. */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 2px 16px; }
.app-row { border-radius: 10px; padding: 7px 8px; min-width: 0; }
.app-row:hover { background: #1a1a1a; }
.app-row.on { background: #161b17; }
.app-row.open { grid-column: 1 / -1; background: #1a1a1a; }
.app-top { display: flex; align-items: center; gap: 10px; }
.app-top[data-reader-setup] { cursor: pointer; }
.app-top[data-reader-setup]:hover .app-name { text-decoration: underline; }
.app-icon { width: 30px; height: 30px; border-radius: 8px; background: #242424; display: grid; place-items: center; flex-shrink: 0; }
.app-icon img { width: 24px; height: 24px; object-fit: contain; }
.app-icon-mavipay { width: 36px; height: 36px; }
.app-icon-mavipay img { width: 33px; height: 33px; }
.app-setup-link { display: inline-block; color: #a5c6ff; text-decoration: underline; text-underline-offset: 2px; }
.app-setup-link:hover { color: #c9ddff; }
.app-letter { font-size: 14.5px; font-weight: 600; line-height: 1; }
.app-meta { flex: 1; min-width: 0; }
.app-name { font-size: 14px; }
.app-blurb { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-add { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--text-dim); flex-shrink: 0; }
.app-add:hover { background: #2c2c2c; color: #fff; }
.app-add.on { color: var(--green); }
.app-add.on:hover { color: var(--red); background: #2a1f1f; }
.app-add:disabled { opacity: .4; cursor: default; }
.app-add svg { width: 16px; height: 16px; }
.app-add.app-connect { width: auto; padding: 0 12px; font-size: 13px; font-weight: 600; color: var(--text); border: 1px solid #3a3a3a; }
.app-soon {
  flex-shrink: 0; font-size: 10.5px; color: var(--text-faint);
  border: 1px solid #2f2f2f; border-radius: 999px; padding: 3px 9px;
}
.app-row:has(.app-soon) .app-icon { opacity: .65; }
.app-btn { padding: 6px 16px; border-radius: 999px; font-size: 13.5px; border: 1px solid #3a3a3a; flex-shrink: 0; }
.app-btn:hover { background: #2a2a2a; }
.app-btn:disabled { opacity: .5; cursor: default; }
.app-form { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.app-form label { font-size: 12.5px; color: var(--text-dim); display: block; margin-bottom: 4px; }
.app-form input {
  width: 100%; background: #121212; border: 1px solid #2f2f2f; border-radius: 10px;
  padding: 9px 12px; font: inherit; font-size: 13.5px; color: var(--text); outline: none;
}
.app-form input:focus { border-color: #444; }
.app-form textarea {
  width: 100%; background: #121212; border: 1px solid #2f2f2f; border-radius: 10px; resize: vertical;
  padding: 9px 12px; font: inherit; font-size: 13px; color: var(--text); outline: none;
}
.app-form textarea:focus { border-color: #444; }
.app-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }
/* Honest card status: a small label, the plain reason, and a greyed card when
   the app cannot be connected at all. */
.app-status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin-top: 4px; }
.app-status-line .app-hint { margin-top: 0; }
.app-status { font-size: 10.5px; line-height: 1; padding: 3px 8px; border-radius: 999px; border: 1px solid #333; color: var(--text-dim); white-space: nowrap; }
.app-status-ready { color: #9fd8a8; border-color: #2d4a33; }
.app-status-setup { color: #e6c98a; border-color: #5a4a26; }
.app-status-dev { color: #a9c4f2; border-color: #2c3f63; }
.app-status-off { color: var(--text-faint); border-color: #333; }
.app-row.off .app-icon, .app-row.off .app-name, .app-row.off .app-blurb, .app-row.off .app-why { opacity: .5; }
.app-link { font-size: 11.5px; color: #a5c6ff; text-decoration: underline; text-underline-offset: 2px; padding: 0; }
.app-link:hover { color: #c9ddff; }
.app-link:disabled { opacity: .5; cursor: default; }
.app-test-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin-top: 4px; }
.app-test-result { font-size: 11.5px; color: var(--text-faint); }
.app-test-result.ok { color: #9fd8a8; }
.app-test-result.bad { color: #f1b5b5; }
.app-actions { display: flex; justify-content: flex-end; gap: 10px; }
.apps-error { color: #f1b5b5; font-size: 13px; margin-top: 12px; }

/* Signing in. Covers the whole window, because nothing behind it is usable
   until the server has let this browser through. */
.gate { position: fixed; inset: 0; z-index: 200; background: var(--bg-main); display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.gate[hidden] { display: none; }
.gate-card {
  width: 420px; max-width: 100%;
  background: #1f1f1f; border: 1px solid #2c2c2c; border-radius: 26px;
  box-shadow: 0 24px 80px rgba(0,0,0,.55);
  padding: 38px 34px 30px;
  display: flex; flex-direction: column; align-items: stretch;
}
.gate-card h1 { margin: 0; font-size: 20.5px; font-weight: 600; text-align: center; }
.gate-sub { margin: 10px 0 26px; font-size: 13.5px; line-height: 1.5; color: var(--text-dim); text-align: center; }
.gate-field { display: block; margin-bottom: 16px; }
.gate-field[hidden] { display: none; }
.gate-field span { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 7px; }
.gate-field input {
  width: 100%; height: 48px;
  background: transparent; border: 1px solid #2f2f2f; border-radius: 14px;
  padding: 0 15px; font: inherit; font-size: 15px; color: var(--text); outline: none;
}
.gate-field input:focus { border-color: #555; }

/* The show/hide eye. It sits inside the box, so the box keeps its full width
   and the eye never looks like a separate control floating beside it. */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 48px; }
.pw-eye {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 10px; color: var(--text-faint);
}
.pw-eye:hover { color: var(--text); background: #2a2a2a; }
.pw-eye:focus-visible { outline: 2px solid #555; outline-offset: -2px; }
.pw-eye svg { width: 19px; height: 19px; }
#gate-code { font-size: 20px; letter-spacing: 6px; text-align: center; }
#gate-code::placeholder { color: #5a5a5a; }

/* The two sign-in modes must not look alike: an envelope for email, a person
   for username, a lock for choosing a password. */
.gate-icon {
  width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 50%;
  display: grid; place-items: center; background: #2a2a2a; color: var(--text);
}
.gate-icon svg { width: 26px; height: 26px; }
#gate[data-step="details"] .gate-card { width: 560px; }
.gate-field.invalid input { border-color: var(--red); }
.field-error, .field-hint { display: block; margin-top: 6px; font-size: 12px; line-height: 1.4; }
.field-error { color: #f1b5b5; }
.field-hint { color: var(--text-faint); }
.field-error[hidden], .field-hint[hidden] { display: none; }
.kyc-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.kyc-grid[hidden] { display: none; }
.kyc-grid .gate-field { grid-column: 1 / -1; }
.kyc-grid .gate-field.half { grid-column: auto; }
@media (max-width: 520px) { .kyc-grid .gate-field.half { grid-column: 1 / -1; } }
.gate-link {
  margin-top: 10px; padding: 6px; font-size: 13.5px; color: var(--text-dim);
  text-decoration: underline; text-underline-offset: 3px; border-radius: 8px;
}
.gate-link[hidden] { display: none; }
.gate-link:hover:not(:disabled) { color: var(--text); }
.gate-link:disabled { text-decoration: none; color: var(--text-faint); cursor: default; }
/* Live password strength. The bar and the wording move together as you type,
   and each rule ticks off on its own so it is obvious which one is missing. */
.pw-strength { margin: -6px 0 16px; }
.pw-strength[hidden] { display: none; }
.pw-bar { height: 5px; border-radius: 999px; background: #2f2f2f; overflow: hidden; }
.pw-bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--red); transition: width .18s ease, background .18s ease; }
.pw-strength[data-level="2"] .pw-bar i { background: #e8a33d; }
.pw-strength[data-level="3"] .pw-bar i { background: #e8d13d; }
.pw-strength[data-level="4"] .pw-bar i { background: var(--green); }
.pw-score { margin-top: 7px; font-size: 11.5px; color: var(--text-dim); min-height: 18px; }
.pw-strength[data-level="4"] .pw-score { color: var(--green); }
.pw-rules { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 5px; }
.pw-rules li { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--text-faint); }
.pw-rules li i {
  flex: none; width: 15px; height: 15px; border-radius: 50%;
  border: 1.5px solid #3f3f3f; position: relative;
}
.pw-rules li.ok { color: var(--text-dim); }
.pw-rules li.ok i { background: var(--green); border-color: var(--green); }
/* The tick is drawn with two borders rotated, so it needs no extra image. */
.pw-rules li.ok i::after {
  content: ""; position: absolute; left: 4.5px; top: 1.5px; width: 4px; height: 7.5px;
  border: solid #10240f; border-width: 0 1.8px 1.8px 0; transform: rotate(45deg);
}

.gate-error { margin: 2px 0 14px; font-size: 13px; line-height: 1.45; color: #f1b5b5; }
.gate-error[hidden] { display: none; }
.gate-go {
  height: 48px; margin-top: 8px; border-radius: 999px;
  background: #f2f2f2; color: #111; font-size: 15.5px; font-weight: 500;
}
.gate-go:hover { background: #fff; }
.gate-go:disabled { background: #333; color: #777; cursor: default; }
.gate-hint { margin: 20px 0 0; font-size: 12px; line-height: 1.5; color: var(--text-faint); text-align: center; }
.gate-hint[hidden] { display: none; }

/* Your own account, on your name in the sidebar. The row is the anchor the
   menu hangs from, so it has to be positioned. */
.me { position: relative; }
.me-name { text-align: left; cursor: pointer; border-radius: 8px; padding: 2px 6px; margin-left: -6px; }
.me-name:hover { background: var(--bg-hover); }
.me-menu {
  position: absolute; bottom: 44px; left: 0; z-index: 60;
  background: #262626; border: 1px solid #333; border-radius: 14px; padding: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); min-width: 180px;
}
.me-menu[hidden] { display: none; }
.me-menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 9px; font-size: 14px; }
.me-menu button:hover { background: #2f2f2f; }

/* "Your account": the same boxes as the sign-in card, in a window. */
.account-modal { width: 600px; }
.account-body { padding: 22px 26px 8px; }
.account-section { margin-top: 10px; padding-top: 18px; border-top: 1px solid #2c2c2c; }
.account-section h4 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.account-section .nb-btn { margin-bottom: 18px; }
.account-note { margin-right: auto; font-size: 13px; color: var(--green); }
.account-note.bad { color: #f1b5b5; }
#account-email { color: var(--text-dim); }

/* "+ Choose skill": the whole library, over whichever window opened it */
.skb-backdrop { z-index: 70; }
.skb-modal { width: 640px; display: flex; flex-direction: column; overflow: hidden; }
.skb-modal .modal-head h3 { display: flex; align-items: baseline; gap: 10px; }
.skb-count { font-size: 13px; font-weight: 400; color: var(--text-dim); }
.skb-body { padding: 16px 22px 8px; display: flex; flex-direction: column; min-height: 0; flex: 1; }
.skb-total { font-size: 12px; color: var(--text-faint); margin: 0 2px 8px; min-height: 16px; }
.skb-list { max-height: none; height: min(52vh, 520px); }
.skb-write { margin-right: auto; }

/* ---- Twitch Moderator ---------------------------------------------------- */
.app-row.native { cursor: pointer; }
.app-open { color: var(--text-dim); }
.mod-modal { width: min(820px, calc(100vw - 48px)); }
.mod-body { padding: 4px 26px 30px; }
.mod-pad { padding: 28px 6px; }
.mod-card { padding: 4px 0 26px; border-bottom: 1px solid #2c2c2c; margin-bottom: 8px; }
.mod-card:last-of-type { border-bottom: 0; }
.mod-sect { margin-top: 24px; }
.mod-sect h4 { margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--text); }
.mod-hint { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; margin-top: 6px; }
.mod-more { padding-top: 6px; display: flex; gap: 18px; flex-wrap: wrap; }
.mod-setup { margin-top: 14px; padding: 12px 16px; border-radius: 14px; background: #181818; border: 1px solid #2c2c2c; }
.mod-setup summary { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.mod-setup-state { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: #222; color: var(--text-dim); }
.mod-setup-state.ok { color: var(--green); }
.mod-setup-state.warn { color: #f0a243; }
.mod-steps-list { margin: 12px 0 4px; padding-left: 22px; font-size: 13.5px; line-height: 1.6; color: var(--text); }
.mod-setup-link { display: inline-block; }
.mod-url { margin-top: 12px; font-size: 13px; }
.mod-url label { display: block; font-weight: 500; margin-bottom: 4px; }
.mod-url-r { display: flex; gap: 8px; align-items: center; }
.mod-url-r input, .mod-creds input { flex: 1; min-width: 0; background: #1c1c1c; border: 1px solid #333; border-radius: 10px; padding: 7px 10px; font: inherit; font-size: 13px; color: var(--text); outline: none; }
.mod-creds { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 8px; }
.mod-creds label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 220px; font-size: 13px; }
.mod-empty { padding: 26px 4px 8px; max-width: 560px; }
.mod-empty h4 { margin: 0 0 10px; font-size: 17px; font-weight: 600; }
.mod-empty p { margin: 0 0 12px; font-size: 14px; line-height: 1.55; color: var(--text-dim); }
.mod-empty .nb-btn { margin-top: 8px; }

.mod-paused { margin: 14px 0 0; padding: 12px 16px; border-radius: 12px; background: #3a1517; border: 1px solid #7a2a2e; color: #ffd0d2; font-weight: 600; font-size: 14px; }
.mod-err { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; background: #2a1819; border: 1px solid #4a2527; color: #f1b5b5; font-size: 13px; line-height: 1.5; }
.mod-warn { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; background: #23201a; border: 1px solid #3a3326; color: #e3cfa4; font-size: 13px; line-height: 1.5; }
.mod-ok { margin-top: 10px; color: var(--green); font-size: 13.5px; }

.mod-status { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 16px; }
.mod-chan { color: var(--text-dim); font-size: 14px; margin-right: auto; }
.mod-dot { width: 11px; height: 11px; border-radius: 50%; background: #777; flex-shrink: 0; }
.mod-dot.ok { background: var(--green); box-shadow: 0 0 0 4px rgba(76, 192, 106, .18); }
.mod-dot.wait, .mod-dot.warn { background: #f0a243; }
.mod-dot.bad { background: var(--red); }
.mod-detail { font-size: 13.5px; color: var(--text-dim); margin: 6px 0 0 21px; line-height: 1.5; }
.mod-round { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #1f1f1f; border: 1px solid var(--border); color: var(--text-dim); flex-shrink: 0; }
.mod-round:hover { color: var(--text); background: #2a2a2a; }
.mod-round:disabled { opacity: .5; cursor: default; }
.mod-round svg { width: 17px; height: 17px; }

.mod-acct { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-top: 1px solid #262626; }
.mod-acct-t { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mod-acct-t b { font-weight: 500; font-size: 14px; }
.mod-acct-t span { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; max-width: 470px; }
.mod-acct-r { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.mod-who { font-size: 14px; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; }
.mod-who i { font-style: normal; font-size: 12px; color: var(--text-faint); }
.mod-twitch { background: #9146ff; border-color: #9146ff; color: #fff; }
.mod-twitch:hover { background: #a460ff; }
.mod-kick { background: #53fc19; border-color: #53fc19; color: #10200b; }
.mod-kick:hover { background: #78ff47; }
.app-btn.danger { border-color: #7a2a2e; color: #ffb4b7; }
.app-btn.danger:hover { background: #3a1517; }
.mod-modrow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0 0; font-size: 13px; color: var(--text-dim); border-top: 1px solid #262626; }
.mod-modrow em { font-style: normal; color: var(--text-faint); }

.mod-line { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 14px; margin-top: 8px; }
.mod-sect select, .mod-row select { background: #262626; color: var(--text); border: 1px solid #333; border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 13.5px; outline: none; max-width: 100%; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: #171717; border: 1px solid #2c2c2c; }
.seg button { padding: 7px 22px; border-radius: 999px; font-size: 14px; color: var(--text-dim); }
.seg button.on { background: #ececec; color: #111; }
.seg button:disabled { opacity: .6; cursor: default; }

.mod-pause { display: block; width: 100%; margin-top: 26px; padding: 16px 20px; border-radius: 16px; text-align: left; background: #231516; border: 2px solid #8a2d32; color: #ffb4b7; }
.mod-pause b { display: block; font-size: 16px; }
.mod-pause span { display: block; margin-top: 3px; font-size: 12.5px; opacity: .85; }
.mod-pause:hover { background: #331a1c; }
.mod-pause.on { background: var(--red); border-color: var(--red); color: #fff; }
.mod-pause.on:hover { background: #ee5a5f; }
.mod-pause:disabled { opacity: .6; cursor: default; }

.mod-row { display: grid; grid-template-columns: 190px 1fr; gap: 14px; padding: 12px 0; border-top: 1px solid #262626; font-size: 14px; line-height: 1.9; }
.mod-row-t { font-weight: 500; color: var(--text); }
.mod-row-b { color: var(--text-dim); min-width: 0; }
.mod-row-b .mod-line { margin-top: 0; color: var(--text); }
.mod-num { width: 74px; background: #1c1c1c; border: 1px solid #333; border-radius: 10px; padding: 5px 9px; font: inherit; font-size: 14px; color: var(--text); outline: none; text-align: center; }
.mod-num:focus, .mod-row textarea:focus { border-color: #555; }
.mod-row textarea { width: 100%; margin-top: 6px; background: #1c1c1c; border: 1px solid #333; border-radius: 10px; padding: 9px 12px; font: inherit; font-size: 13.5px; line-height: 1.5; color: var(--text); outline: none; resize: vertical; }
.mod-steps { margin-top: 8px; }
.mod-step { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; }
.mod-step > span { width: 92px; color: var(--text-dim); }
.mod-step em { font-style: normal; color: var(--text-dim); font-size: 13px; }
.mod-x { width: 26px; height: 26px; border-radius: 50%; color: var(--text-faint); font-size: 17px; line-height: 1; display: grid; place-items: center; margin-left: auto; }
.mod-x:hover { background: var(--red); color: #fff; }
.mod-savebar { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.mod-savebar [hidden] { display: none; }
.mod-saved { font-size: 13px; color: var(--text-dim); }

.mod-acts { display: flex; flex-direction: column; }
.mod-act { padding: 12px 0; border-top: 1px solid #262626; font-size: 13.5px; }
.mod-act.proposed { background: linear-gradient(90deg, rgba(240, 162, 67, .08), transparent); }
.mod-act-h { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.mod-act-h b { font-weight: 500; }
.mod-user { color: var(--text-dim); }
.mod-when { margin-left: auto; font-size: 12px; color: var(--text-faint); }
.mod-src { font-size: 10.5px; font-weight: 600; letter-spacing: .02em; padding: 2px 9px; border-radius: 999px; border: 1px solid transparent; }
.mod-src.rule { background: #1d2a3d; color: #8fb8f5; border-color: #2a3d59; }
.mod-src.agent { background: #2b2140; color: #c6a8f5; border-color: #40305f; }
.mod-src.owner { background: #1d3325; color: #8fd9a4; border-color: #2a4a36; }
.mod-act-msg { margin-top: 5px; color: var(--text); overflow-wrap: anywhere; }
.mod-act-why { margin-top: 3px; font-size: 12.5px; color: var(--text-dim); }
.mod-act-f { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.mod-act-f .mod-act-why { margin: 0; }
.mod-res { font-size: 11.5px; padding: 1px 9px; border-radius: 999px; border: 1px solid #333; color: var(--text-dim); }
.mod-res.done { color: var(--green); border-color: #2a4a36; }
.mod-res.failed, .mod-res.blocked { color: #f1b5b5; border-color: #4a2527; }
.mod-res.proposed { color: #f0a243; border-color: #5a4220; }
.mod-act-btns { margin-left: auto; display: flex; gap: 8px; }
.mod-act-btns .app-btn { padding: 4px 14px; font-size: 13px; }

.mod-foot { margin-top: 22px; }
.mod-remove { font-size: 12.5px; color: var(--text-faint); }
.mod-remove:hover { color: #f1b5b5; }
.mod-confirm { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 14px; border-radius: 12px; background: #231516; border: 1px solid #4a2527; font-size: 13.5px; }
.mod-confirm span { flex: 1; min-width: 220px; color: #f1b5b5; }

@media (max-width: 720px) {
  .mod-modal { width: calc(100vw - 24px); }
  .mod-body { padding: 4px 16px 24px; }
  .mod-acct { flex-direction: column; align-items: flex-start; }
  .mod-acct-r { flex-wrap: wrap; }
  .mod-who { align-items: flex-start; }
  .mod-row { grid-template-columns: 1fr; gap: 2px; }
  .mod-step { flex-wrap: wrap; }
  .mod-step > span { width: auto; }
}
.mod-rules { width: 100%; margin-top: 10px; background: #1c1c1c; border: 1px solid #333; border-radius: 12px; padding: 11px 14px; font: inherit; font-size: 14px; line-height: 1.55; color: var(--text); outline: none; resize: vertical; }
.mod-rules:focus, .mod-ex input:focus { border-color: #555; }
.mod-sub { margin-top: 20px; font-size: 13.5px; font-weight: 500; }
.mod-ex { padding: 10px 0; border-top: 1px solid #262626; display: flex; flex-direction: column; gap: 8px; }
.mod-ex:first-child { margin-top: 8px; }
.mod-ex input[type="text"], .mod-ex-text, .mod-ex-note { background: #1c1c1c; border: 1px solid #333; border-radius: 10px; padding: 7px 11px; font: inherit; font-size: 13.5px; color: var(--text); outline: none; min-width: 0; }
.mod-ex-text { width: 100%; }
.mod-ex-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mod-ex-row select { background: #262626; color: var(--text); border: 1px solid #333; border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 13.5px; outline: none; }
.mod-ex-row em { font-style: normal; color: var(--text-dim); font-size: 13px; }
.mod-ex-note { flex: 1; min-width: 160px; }
.notice { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 80; max-width: min(520px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 12px; background: #231516; border: 1px solid #4a2527; color: #f1b5b5; font-size: 13.5px; box-shadow: 0 12px 32px rgba(0,0,0,.5); cursor: pointer; }

/* Home page: the Linus Bot logo opens it. Top half empty, bottom half the main chat. */
.sidebar-brand { cursor: pointer; border-radius: 14px; padding: 6px 10px; }
.sidebar-brand, .sidebar-brand:hover, .sidebar-brand.active { background: transparent; }
.sidebar-brand:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.home-top { flex: 0 0 calc(50% - 60px); }
.home-top[hidden] { display: none; }
.chat.home .messages { flex: 1 1 0; min-height: 0; padding-top: 8px; border-top: 1px solid var(--border); }
.home-pill { padding-left: 8px; }
.main-action { align-self: center; max-width: 760px; width: 100%; text-align: center; font-size: 12.5px; color: var(--text-faint); }
.main-action::before { content: "↳ "; }
.main-empty { margin: auto; max-width: 420px; text-align: center; font-size: 13.5px; color: var(--text-dim); }
.msg-row.user.main-from .bubble { background: #1b2230; border-color: #263247; color: var(--text); }
.composer-plus[hidden] { display: none; }
.mod-judges { position:relative; max-width:100%; }
.mod-judges summary { cursor:pointer; padding:10px 14px; border:1px solid var(--border,#444); border-radius:12px; max-width:100%; overflow-wrap:anywhere; }
.mod-judge-list { display:grid; gap:8px; padding:14px; margin-top:8px; border:1px solid var(--border,#444); border-radius:12px; background:var(--panel,#242424); }
.mod-judge-list > b { font-size:12px; margin-top:8px; }
.mod-judge-option { display:flex; align-items:center; gap:10px; padding:5px 0; cursor:pointer; }
.mod-judge-option input { width:18px; height:18px; flex:0 0 auto; accent-color:#a979ef; }
.mod-judge-option small { display:block; opacity:.65; font-size:11px; }

/* Mac Access */
.macx-steps { margin: 0 0 14px; padding-left: 20px; font-size: 14px; line-height: 1.7; color: var(--text-dim); }
.macx-steps code, .macx-code em b { color: var(--text); }
.macx-code { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; padding: 14px 18px; border-radius: 14px; background: #171717; border: 1px solid #2c2c2c; }
.macx-code span { font: 600 28px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.macx-code em { font-style: normal; font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.macx-dev { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 0; border-top: 1px solid #262626; }
.macx-dev-t { display: flex; flex-direction: column; gap: 3px; margin-right: auto; min-width: 0; }
.macx-dev-t b { font-weight: 500; font-size: 14.5px; }
.macx-dev-t span { font-size: 12.5px; color: var(--text-dim); }
.macx-more { display: inline-block; margin-top: 8px; }
.macx-ask { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 14px; margin-bottom: 8px; border-radius: 12px; background: #23201a; border: 1px solid #3a3326; }
.macx-ask-t { flex: 1; min-width: 220px; font-size: 14px; line-height: 1.45; }
.macx-ask-t .mod-hint { display: block; margin-top: 2px; }
.macx-summary { margin: 12px 0; padding: 12px 14px; border-radius: 12px; background: #171f2b; border: 1px solid #23344d; color: #cfe0f7; font-size: 13.5px; line-height: 1.5; }
.macx-add { padding: 8px 20px; font-size: 14px; }
.macx-grant { padding: 12px 0; border-top: 1px solid #262626; }
.macx-g-t { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.macx-g-t b { font-weight: 500; font-size: 14.5px; }
.macx-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); border: 1px solid #333; border-radius: 999px; padding: 1px 8px; }
.macx-target { font-size: 12.5px; color: var(--text-dim); word-break: break-all; }
.macx-g-a, .macx-acts { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 13.5px; }
.macx-tick { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.macx-tick.dim { opacity: .45; }
.macx-sw { display: inline-flex; align-items: center; gap: 8px; color: var(--text-dim); }
.macx-recent { font-size: 13px; color: var(--text-dim); padding: 4px 0; line-height: 1.45; }
.macx-recent.bad { color: #e3b0b0; }
.macx-banner { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px); padding: 10px 12px 10px 18px; border-radius: 999px; background: #23201a; border: 1px solid #5a4a2a; box-shadow: 0 12px 40px rgba(0,0,0,.5); font-size: 13.5px; color: #f0dfb8; }
.macx-banner[hidden] { display: none; }
.macx-pick-back { z-index: 55; }
.macx-tabs { margin: 18px 0 12px; flex-wrap: wrap; }
.macx-tabs button { padding: 7px 16px; }
.macx-pane { min-height: 220px; max-height: 42vh; overflow-y: auto; padding-right: 4px; }
.macx-item { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid #242424; font-size: 14px; cursor: pointer; }
.macx-item em { font-style: normal; font-size: 12px; color: var(--text-faint); margin-left: auto; }
.macx-item-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.macx-item-t em { margin-left: 0; word-break: break-all; }
.macx-here { background: #1b1b1b; border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; }
.macx-open { color: var(--text); text-align: left; }
.macx-open:hover { text-decoration: underline; }
.macx-file { color: var(--text-dim); }
.macx-crumbs { font-size: 13px; color: var(--text-faint); margin-bottom: 8px; word-break: break-all; }
.macx-roots { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.macx-search { flex: 1; min-width: 200px; background: #262626; color: var(--text); border: 1px solid #333; border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 13.5px; outline: none; margin-bottom: 8px; }
.macx-chosen { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; padding-top: 14px; border-top: 1px solid #2c2c2c; }
.macx-pick-btns { margin-top: 14px; }
.macx-chosen { flex-direction: column; flex-wrap: nowrap; gap: 0; }
.macx-chosen-row { padding: 8px 0; border-bottom: 1px solid #242424; }
.macx-chosen-row .macx-g-a { margin-top: 6px; }
.macx-unpick { margin-left: auto; }

.message-entry { display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 1240px; margin: 0 auto; min-width: 0; }
.message-content { display: flex; flex-direction: column; gap: 10px; width: 100%; min-width: 0; }
.message-content > .msg-row { margin: 0; max-width: 100%; }
.message-content .bubble { overflow-wrap: anywhere; }
.message-entry.incoming .msg-row { justify-content: flex-start; }
.message-timestamp { color: var(--text-dim); font-size: 11px; line-height: 1.4; font-variant-numeric: tabular-nums; white-space: nowrap; }
.message-entry.incoming .message-timestamp { align-self: flex-start; }
.message-entry.outgoing .message-timestamp { align-self: flex-end; }
.message-content > .routine, .message-content > .main-action { align-self: flex-start; width: auto; text-align: left; margin: 0; }
@media (max-width: 520px) {
  .message-timestamp { font-size: 10.5px; }
  .message-content .bubble { padding: 9px 11px; }
  .message-content .msg-row { gap: 4px; }
  .message-content .actions { gap: 1px; }
  .message-content .actions button { width: 25px; height: 28px; }
  .model-bar { max-width: calc(100% - 12px); }
  .model-bar select { min-width: 0; max-width: 170px; }
}

.bot-order-help { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.bot-row[draggable="true"] { cursor: grab; position: relative; }
.bot-row[draggable="true"]:active { cursor: grabbing; }
.bot-row.dragging { opacity: .45; }
.bot-row.drop-before::before, .bot-row.drop-after::after { content: ""; position: absolute; left: 10px; right: 10px; height: 2px; border-radius: 2px; background: var(--blue, #3073e8); pointer-events: none; }
.bot-row.drop-before::before { top: 0; }
.bot-row.drop-after::after { bottom: 0; }
.bot-grip { flex: 0 0 12px; color: var(--text-dim); font-size: 17px; line-height: 1; opacity: 0; }
.bot-row:hover .bot-grip, .bot-row:focus-visible .bot-grip { opacity: .7; }
.bot-order-status { color: var(--text-dim); font-size: 11px; padding: 6px 14px; overflow-wrap: anywhere; }
.bot-order-status:empty { display: none; }
.bot-order-status.error { color: #f1b5b5; }

.workspace-create { display: flex; align-items: center; gap: 9px; margin: 2px 4px 16px; padding: 9px 10px; text-align: left; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; color: #c9c9c9; flex-shrink: 0; }
.workspace-create > span { font-size: 20px; line-height: 16px; color: var(--blue-dot); }
.workspace-create:hover { background: var(--bg-hover); color: var(--text); border-color: #414141; }
.workspace-create:focus-visible, .workspace-card:focus-visible, .workspace-button:focus-visible, .workspace-breadcrumbs button:focus-visible, .workspace-team-editor button:focus-visible { outline: 2px solid var(--blue-dot); outline-offset: 3px; }
.home-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 0; overflow: hidden; }
.workspace-home { min-width: 0; min-height: 0; overflow: auto; padding: 18px 16px 20px 24px; }
.workspace-home-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.workspace-home-head h2 { font-size: 14px; font-weight: 500; margin: 0; color: var(--text-dim); }
.workspace-home-head > span { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-faint); }
.workspace-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.workspace-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 13px 12px; border: 1px solid #303030; border-radius: 13px; text-align: left; background: #1c1c1c; transition: border-color .15s, background .15s; }
.workspace-card:hover { border-color: #4b4b4b; background: #222; }
.workspace-card-symbol { display: flex; align-items: center; justify-content: space-between; gap: 4px; color: var(--text-dim); }
.workspace-card-symbol > svg { color: #9badca; width: 21px; height: 21px; flex-shrink: 0; }
.workspace-card-symbol > span { font-size: 10.5px; white-space: nowrap; }
.workspace-card-name { font-size: 13px; font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.workspace-card-team { display: flex; align-items: center; gap: 3px; min-height: 21px; }
.workspace-card-team small { font-size: 10px; color: var(--text-dim); padding-left: 3px; }
.workspace-card-empty { justify-content: center; min-height: 120px; border-style: dashed; color: var(--text-dim); font-size: 12px; }
.workspace-card-empty > span:first-child { font-size: 24px; color: var(--blue-dot); line-height: 1; }
.workspace-home-note { font-size: 12px; color: var(--text-dim); overflow-wrap: anywhere; }
.workspace-home-note:not(:empty) { margin-bottom: 12px; }
.workspace-home-note button { color: var(--blue-dot); text-decoration: underline; }
.workspace-reserved { min-width: 0; }
.workspace-top { flex: 0 1 auto; max-height: 48vh; min-height: 0; overflow-y: auto; border-bottom: 1px solid var(--border); padding: 14px 28px 18px; }
.workspace-top[hidden] { display: none; }
.workspace-breadcrumbs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px; font-size: 11.5px; margin-bottom: 12px; color: var(--text-faint); }
.workspace-breadcrumbs button { color: var(--text-dim); text-align: left; overflow-wrap: anywhere; }
.workspace-breadcrumbs button:hover { color: #fff; }
.workspace-breadcrumbs [aria-current] { color: #c6c6c6; overflow-wrap: anywhere; }
.workspace-title-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.workspace-title-row > div { min-width: 0; }
.workspace-title-row h1 { font-size: 20px; font-weight: 600; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
.workspace-title-row p { color: var(--text-dim); font-size: 12px; margin: 5px 0 0; }
.workspace-header-actions { display: flex; gap: 7px; flex-wrap: wrap; flex-shrink: 1; max-width: 100%; }
.workspace-button { padding: 7px 11px; border: 1px solid #3a3a3a; border-radius: 9px; font-size: 12px; line-height: 1.5; color: #d7d7d7; background: #222; }
.workspace-button:hover { background: #2b2b2b; border-color: #505050; }
.workspace-button:disabled, .workspace-team-editor button:disabled { opacity: .35; cursor: default; }
.workspace-pill { display: inline-flex; align-items: center; gap: 9px; padding-left: 6px; min-width: 0; }
.workspace-pill > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-pill svg { color: #9badca; flex-shrink: 0; }
.workspace-team-strip { display: flex; flex-wrap: wrap; gap: 9px 14px; margin-top: 17px; }
.workspace-member { display: inline-flex; align-items: center; gap: 7px; min-width: 0; font-size: 12px; }
.workspace-member > span { overflow-wrap: anywhere; }
.workspace-member small { display: block; color: var(--text-faint); font-size: 10px; line-height: 1.2; }
.workspace-member i { font-size: 19px; color: #555; margin-left: 7px; font-style: normal; }
.workspace-children { margin-top: 18px; }
.workspace-children h2 { color: var(--text-dim); font-size: 12px; font-weight: 500; margin: 0 0 9px; }
.workspace-child-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.workspace-child-grid .workspace-card { gap: 6px; padding: 10px 12px; }
.workspace-runs { margin-top: 17px; display: grid; gap: 7px; }
.workspace-run { border: 1px solid #303030; border-radius: 10px; padding: 9px 11px; font-size: 12px; }
.workspace-run summary { display: flex; align-items: center; gap: 9px; cursor: pointer; list-style: none; }
.workspace-run summary::-webkit-details-marker { display: none; }
.workspace-run summary::before { content: "›"; color: var(--text-faint); font-size: 15px; }
.workspace-run[open] summary::before { transform: rotate(90deg); }
.workspace-run-title { min-width: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-dim); }
.workspace-run summary .message-timestamp { font-size: 10px; color: var(--text-faint); }
.workspace-run-state { font-size: 10px; padding: 1px 7px; border-radius: 20px; background: #2e2e2e; white-space: nowrap; }
.workspace-run-state.completed { color: #8dd2a0; background: #203126; }
.workspace-run-state.running, .workspace-run-state.queued { color: #a6c3f2; background: #202d40; }
.workspace-run-state.failed, .workspace-run-state.interrupted { color: #e8abab; background: #362222; }
.workspace-steps { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 8px; }
.workspace-steps li { display: flex; gap: 9px; align-items: center; }
.workspace-steps li > span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.workspace-steps li > span:last-child { color: var(--text-faint); font-size: 11px; }
.workspace-steps b { font-size: 12px; font-weight: 400; }
.workspace-steps small { display: block; color: var(--text-faint); font-size: 10px; }
.workspace-step-mark { display: grid; place-items: center; width: 21px; height: 21px; border-radius: 50%; border: 1px solid #414141; color: var(--text-dim); font-size: 10px; flex-shrink: 0; }
.workspace-steps .completed .workspace-step-mark { color: #8dd2a0; border-color: #355540; }
.workspace-steps .running .workspace-step-mark { border-color: #6089c2; color: #a6c3f2; }
.workspace-run-error { color: #f1b5b5; font-size: 12px; margin: 10px 0 0; overflow-wrap: anywhere; }
.workspace-resume-review, .workspace-resume-history { margin-top: 12px; padding-top: 12px; border-top: 1px solid #353535; }
.workspace-resume-review h3, .workspace-resume-history h3 { color: var(--text); font-size: 12px; font-weight: 500; margin: 0 0 10px; }
.workspace-resume-review > p { color: var(--text-dim); font-size: 12px; line-height: 1.6; }
.workspace-resume-outputs { display: grid; gap: 6px; margin: 10px 0; }
.workspace-resume-output, .workspace-resume-attempt { padding: 8px 10px; border: 1px solid #353535; border-radius: 8px; margin: 6px 0; min-width: 0; }
.workspace-resume-output > summary, .workspace-resume-attempt > summary { color: var(--text-dim); font-size: 11px; line-height: 1.6; flex-wrap: wrap; }
.workspace-resume-output pre { margin: 10px 0 0; max-height: 260px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: 12px; line-height: 1.6; color: var(--text); }
.workspace-resume-files { margin: 12px 0; min-width: 0; }
.workspace-resume-files > b { font-size: 11px; font-weight: 500; color: var(--text-dim); }
.workspace-resume-files ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.workspace-resume-files li { display: grid; gap: 4px; min-width: 0; }
.workspace-resume-files strong { font-size: 11px; font-weight: 500; color: var(--text); }
.workspace-resume-files code, .workspace-resume-files small { color: var(--text-faint); font-size: 10px; overflow-wrap: anywhere; white-space: pre-wrap; }
.workspace-resume-note { color: var(--text-faint); font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.workspace-resume-time { color: var(--text-faint); font-size: 11px; margin: 8px 0; }
.workspace-resume-warning { padding: 9px 11px; border-left: 2px solid #b68d4e; background: #29251e; border-radius: 0 6px 6px 0; }
.workspace-resume-ack { display: flex; align-items: flex-start; gap: 9px; color: var(--text); font-size: 12px; line-height: 1.6; margin: 12px 0; cursor: pointer; }
.workspace-resume-ack input { flex-shrink: 0; margin-top: 3px; accent-color: var(--blue-dot); }
.workspace-resume-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.workspace-empty { margin: auto; max-width: 410px; text-align: center; padding: 22px; color: var(--text-dim); font-size: 13px; }
.workspace-empty h2 { color: #d4d4d4; font-size: 17px; font-weight: 500; margin: 0 0 9px; }
.workspace-empty p { margin: 0 0 12px; }
.workspace-active { display: flex; justify-content: center; align-items: center; gap: 8px; color: var(--text-dim); font-size: 12px; margin: 10px auto; max-width: 100%; overflow-wrap: anywhere; }
.workspace-busy-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue-dot); animation: workspace-pulse 1.3s ease-in-out infinite; flex-shrink: 0; }
@keyframes workspace-pulse { 50% { opacity: .3; } }
.workspace-message-from { color: #9badca !important; margin-bottom: 6px !important; }
.workspace-view .messages { min-height: 90px; padding-top: 20px; }
.workspace-editor { width: 560px; }
.workspace-editor-body { padding: 22px 26px; }
.workspace-label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 7px; }
.workspace-input { width: 100%; min-width: 0; border: 1px solid #393939; border-radius: 9px; background: #171717; color: var(--text); padding: 10px 12px; font: inherit; font-size: 13px; }
.workspace-input:focus { outline: 1px solid var(--blue-dot); border-color: var(--blue-dot); }
.workspace-form-parent { color: var(--text-faint); font-size: 12px; margin: 7px 0 18px; }
.workspace-form-parent:empty { display: none; }
.workspace-team-mode { display: flex; flex-wrap: wrap; gap: 10px 20px; margin: 22px 0 16px; padding: 12px; border: 1px solid #383838; border-radius: 10px; }
.workspace-team-mode[hidden], #workspace-own-team[hidden], #workspace-inherited-team[hidden] { display: none; }
.workspace-team-mode legend { font-size: 12px; color: var(--text-dim); padding: 0 5px; }
.workspace-team-mode label { display: flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }
.workspace-team-mode input { accent-color: var(--blue-dot); }
.workspace-help { color: var(--text-dim); font-size: 12px; line-height: 1.5; margin: 13px 0; }
.workspace-team-editor { display: grid; gap: 7px; padding: 0; margin: 14px 0 18px; list-style: none; }
.workspace-team-editor li { display: flex; align-items: center; gap: 8px; padding: 9px; border: 1px solid #373737; border-radius: 10px; background: #242424; cursor: grab; position: relative; }
.workspace-team-editor li.dragging { opacity: .4; }
.workspace-team-editor li:focus-visible { outline: 2px solid var(--blue-dot); outline-offset: 1px; }
.workspace-team-editor .drop-before::before, .workspace-team-editor .drop-after::after { position: absolute; content: ""; left: 0; right: 0; height: 2px; background: var(--blue-dot); }
.workspace-team-editor .drop-before::before { top: -4px; }
.workspace-team-editor .drop-after::after { bottom: -4px; }
.workspace-grip { color: #777; }
.workspace-editor-member-name { min-width: 0; flex: 1; font-size: 13px; overflow-wrap: anywhere; }
.workspace-editor-member-name small { display: block; color: var(--text-dim); font-size: 10px; }
.workspace-team-editor button { border-radius: 6px; border: 1px solid #424242; height: 27px; width: 27px; flex-shrink: 0; font-size: 13px; color: #bbb; }
.workspace-team-editor button:hover:not(:disabled) { background: #353535; color: #fff; }
.workspace-add-row { display: flex; gap: 8px; }
.workspace-add-row select { flex: 1; }
.workspace-inherited-members { list-style: none; padding: 0; display: grid; gap: 10px; }
.workspace-inherited-members li { display: flex; gap: 9px; align-items: center; font-size: 13px; }
.workspace-inherited-members small { display: block; color: var(--text-dim); font-size: 10px; }
.workspace-form-error { color: #f1b5b5; font-size: 12px; margin-top: 14px; overflow-wrap: anywhere; }
.workspace-form-error:empty { display: none; }
.workspace-editor .modal-foot { gap: 10px; }
.workspace-editor .modal-foot .workspace-help { margin: 0 auto 0 0; max-width: 240px; font-size: 11px; }
@media (max-width: 1100px) and (min-width: 761px) {
  .workspace-home { padding: 16px 10px 16px 16px; }
  .workspace-grid { gap: 7px; }
  .workspace-card { padding: 11px 9px; }
  .workspace-card-symbol > span { font-size: 9px; }
}
@media (max-width: 760px) {
  .home-top { grid-template-columns: minmax(0, 1fr); }
  .workspace-home { padding: 15px 16px; }
  .workspace-reserved { display: none; }
  .workspace-grid { gap: 8px; }
  .workspace-top { padding: 12px 16px 14px; max-height: 45vh; }
  .workspace-title-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .workspace-title-row h1 { font-size: 19px; }
  .workspace-child-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-run summary .message-timestamp { display: none; }
  .workspace-editor-body { padding: 18px 20px; }
  .workspace-editor .modal-foot { flex-wrap: wrap; }
  .workspace-editor .modal-foot .workspace-help { flex-basis: 100%; max-width: none; }
}
@media (max-height: 600px) {
  .home-top { flex-basis: 38%; }
  .workspace-top { max-height: 36vh; }
  .workspace-editor { max-height: calc(100dvh - 16px); }
}
@media (prefers-reduced-motion: reduce) { .workspace-busy-dot { animation: none; } .workspace-card { transition: none; } }

.custom-mcp { border:1px solid var(--border,#303030); border-radius:14px; padding:16px; margin:0 0 22px; }
.custom-mcp-heading,.custom-mcp-row,.custom-mcp-actions { display:flex; align-items:center; gap:10px; }
.custom-mcp-heading h4 { flex:1; margin:0; font-size:15px; }
.custom-mcp-hint { color:var(--muted,#999); font-size:12px; line-height:1.55; margin:8px 0 12px; }
.custom-mcp-row { border-top:1px solid var(--border,#303030); padding:12px 0; }
.custom-mcp-row > div { flex:1; min-width:0; overflow-wrap:anywhere; }
.custom-mcp-row span { display:block; color:var(--muted,#999); font-size:12px; margin-top:3px; }
.custom-mcp-editor { display:grid; gap:14px; border-top:1px solid var(--border,#303030); padding:16px 0; }
.custom-mcp-editor h4 { margin:0; }
.custom-mcp-editor > label { display:grid; gap:6px; font-size:13px; }
.custom-mcp-editor input:not([type=checkbox]),.custom-mcp-editor textarea,.custom-mcp-editor select { width:100%; box-sizing:border-box; background:var(--bg,#171717); color:inherit; border:1px solid var(--border,#444); border-radius:8px; padding:10px; font:inherit; }
.custom-mcp-editor small { color:var(--muted,#999); }
.custom-mcp-credential { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.4fr) auto; align-items:center; gap:8px; margin:8px 0; }
.custom-mcp-remove-key { font-size:12px; white-space:nowrap; }
@media(max-width:600px) { .custom-mcp { padding:12px; } .custom-mcp-credential { grid-template-columns:minmax(0,1fr); } .custom-mcp-row { flex-wrap:wrap; } .custom-mcp-row > div { flex-basis:100%; } }

.workspace-memory-modal { width: min(720px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
.workspace-memory-body { padding: 18px 26px 24px; overflow-y: auto; min-height: 0; }
.workspace-memory-body textarea { resize: vertical; min-height: 115px; }
.workspace-memory-save-row { display: flex; align-items: center; gap: 12px; }
#workspace-memory-note-status { font-size: 12px; color: var(--text-dim); overflow-wrap: anywhere; }
.workspace-memory-search { margin-top: 25px; }
.workspace-memory-results { display: grid; gap: 8px; }
.workspace-memory-result { display: block; width: 100%; text-align: left; border: 1px solid #363636; border-radius: 10px; padding: 11px 13px; background: #222; overflow-wrap: anywhere; }
.workspace-memory-result:hover { background: #2a2a2a; }
.workspace-memory-result .message-timestamp { margin: 0 0 5px; }
.workspace-memory-result small { display: block; color: var(--text-dim); margin-bottom: 5px; }
.workspace-memory-pages { display: flex; justify-content: space-between; gap: 10px; margin-top: 15px; }
.workspace-memory-source { padding: 15px; border: 1px solid #414141; border-radius: 11px; margin-top: 18px; }
.workspace-memory-source pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 13px; line-height: 1.6; margin-bottom: 0; }
.workspace-history-window { color: var(--text-dim); font-size: 12px; line-height: 1.5; margin: 0 auto 18px; max-width: 680px; }
.workspace-history-window button { color: var(--blue-dot); text-decoration: underline; }
@media (max-width: 600px) { .workspace-memory-body { padding: 16px 18px 20px; } .workspace-memory-save-row { align-items: flex-start; flex-direction: column; } }

.workspace-identity-fields { margin-top: 16px; }
.workspace-identity-fields .workspace-help { margin: 7px 0 15px; font-size: 11px; }
.workspace-identifiers { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 13px; margin-top: 8px; color: var(--text-dim); font-size: 11px; }
.workspace-identifiers button { text-align: left; color: inherit; overflow-wrap: anywhere; }
.workspace-identifiers button:hover { color: var(--text); }
.workspace-identifiers code { font-size: 11px; }
.workspace-identity-copy-status { font-size: 10px; color: var(--text-faint); }
.workspace-card-handle { font-size: 10px; color: var(--text-faint); overflow-wrap: anywhere; margin-top: -5px; }


.nb-workspace-context { margin: 0 0 18px; padding: 12px 14px; border: 1px solid #35445b; border-radius: 10px; background: #1b2533; color: #c4d3e8; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.nb-workspace-context[hidden] { display: none; }
.workspace-button.workspace-danger, .nb-btn.workspace-danger { color: #efb0b0; border-color: #754343; background: #342323; }
.workspace-button.workspace-danger:hover:not(:disabled), .nb-btn.workspace-danger:hover:not(:disabled) { color: #fff; background: #603333; border-color: #a85858; }
.workspace-delete-modal { width: min(490px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
.workspace-delete-body { padding: 22px 26px; overflow-y: auto; min-height: 0; font-size: 13px; line-height: 1.6; }
.workspace-delete-body h4 { font-size: 17px; line-height: 1.4; margin: 0 0 12px; overflow-wrap: anywhere; }
.workspace-delete-body p { margin: 0 0 14px; }
.workspace-delete-kept { color: var(--text-dim); padding: 11px 13px; border-radius: 9px; border: 1px solid #3b3b3b; background: #252525; }
.workspace-delete-body .workspace-form-error { margin: 12px 0; }
@media (max-width: 600px) { .workspace-delete-body { padding: 18px 20px; } .workspace-header-actions { gap: 6px; } }

/* ==== Stage 3: header row, phone layout, chat tools ============================
   Appended after the rules above on purpose: the details panel overlay below has to
   come after `.details { width: 400px; position: relative }` to win. */
@supports (height: 100dvh) {
  .app { height: 100dvh; }
  .modal { max-height: calc(100dvh - 32px); }
}
.chat-header { display: flex; align-items: center; gap: 10px; padding: env(safe-area-inset-top, 0px) 16px 0; height: calc(60px + env(safe-area-inset-top, 0px)); justify-content: flex-start; }
.chat-header .bot-pill { min-width: 0; margin: 0 auto 0 0; }
.bot-pill > span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header .header-actions { position: static; margin-left: auto; flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.chat-header .header-actions .share-btn { position: static; right: auto; white-space: nowrap; flex-shrink: 0; }
.header-actions .hdr-icon { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: #1f1f1f; display: grid; place-items: center; color: #d6d6d6; }
.header-actions .hdr-icon:hover { background: #292929; }
.header-actions .hdr-icon[hidden] { display: none; }
.header-actions .hdr-narrow { display: none; }
@media (min-width: 1181px) {
  .chat-header { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(max-content, 1fr); }
  .chat-header .bot-pill { grid-column: 2; margin: 0; max-width: 100%; }
  .chat-header .header-actions { grid-column: 3; justify-self: end; }
}
@media (max-width: 720px) {
  .chat-header { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .bot-pill .harness { display: none; }
  .header-actions .hdr-wide { display: none !important; }
  .header-actions .hdr-narrow:not([hidden]) { display: grid; }
  .header-actions .hdr-narrow { order: -1; } /* the menu holds Search, Screen and Share, so it comes before Calendar */
}
@media (max-width: 430px) {
  .header-actions .calendar-header-button { font-size: 0; width: 36px; padding: 0; justify-content: center; gap: 0; }
  .header-actions .calendar-header-button::before { content: ""; width: 18px; height: 18px; background: currentColor; -webkit-mask: var(--cal-icon) center / contain no-repeat; mask: var(--cal-icon) center / contain no-repeat;
    --cal-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='5' width='16' height='15' rx='2'/%3E%3Cpath d='M4 10h16M9 3v4M15 3v4'/%3E%3C/svg%3E"); }
}

/* Small menus that hang under a header button: Share, and the "more" menu on phones. */
.pop { position: fixed; z-index: 70; min-width: 200px; max-width: calc(100vw - 16px); background: #262626; border: 1px solid #333; border-radius: 14px; padding: 6px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); }
.pop[hidden] { display: none; }
.pop button { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; width: 100%; min-height: 40px; text-align: left; padding: 9px 12px; border-radius: 9px; font-size: 14px; }
.pop button:hover, .pop button:focus-visible { background: #2f2f2f; outline: none; }
.pop small { display: block; color: var(--text-dim); font-size: 12px; }
.pop { max-height: min(70vh, 460px); overflow-y: auto; }
.pop-head { padding: 8px 12px 4px; font-size: 12px; color: var(--text-dim); }

/* Search inside a chat */
.chat-search { position: absolute; z-index: 35; top: calc(60px + env(safe-area-inset-top, 0px)); left: 16px; right: 16px; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; max-height: min(70%, 520px); background: #1f1f1f; border: 1px solid #333; border-radius: 16px; box-shadow: 0 16px 50px rgba(0, 0, 0, .55); overflow: hidden; }
.chat-search[hidden] { display: none; }
.cs-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; }
.cs-head input { flex: 1; min-width: 0; height: 36px; background: none; border: 0; outline: none; color: var(--text); font: inherit; font-size: 15px; }
.cs-head input::placeholder { color: var(--text-faint); }
.cs-close { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #bbb; flex-shrink: 0; }
.cs-close:hover { background: #2a2a2a; color: #fff; }
.cs-status { padding: 0 16px 8px; font-size: 12.5px; color: var(--text-dim); }
.cs-status:empty { display: none; }
.cs-list { overflow-y: auto; border-top: 1px solid #2a2a2a; }
.cs-list:empty { display: none; }
.cs-item { display: block; width: 100%; text-align: left; padding: 10px 16px; border-bottom: 1px solid #272727; }
.cs-item:last-child { border-bottom: 0; }
.cs-item:hover, .cs-item:focus-visible { background: #262626; outline: none; }
.cs-meta { display: block; font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.cs-snip { display: block; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.cs-snip mark, .pv-body mark { background: #3d5a99; color: #fff; border-radius: 3px; padding: 0 1px; }
.message-entry.jump-hit .bubble { animation: jump-hit 2.6s ease-out; }
@keyframes jump-hit { 0%, 55% { box-shadow: 0 0 0 3px #f0c75e; } 100% { box-shadow: 0 0 0 3px transparent; } }
@media (prefers-reduced-motion: reduce) { .message-entry.jump-hit .bubble { animation: none; box-shadow: 0 0 0 3px #f0c75e; } }

/* Older messages, queued label */
.older-note { align-self: center; color: var(--text-dim); font-size: 12.5px; padding: 4px 10px; text-align: center; }
button.older-note { text-decoration: underline; text-underline-offset: 3px; }
.queued-tag { margin-top: 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; color: #fff; opacity: .9; }
.queued-tag::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #fff; opacity: .8; }

/* Drag and drop */
.drop-hint { position: absolute; inset: 8px; z-index: 60; display: grid; place-items: center; text-align: center; padding: 20px; font-size: 17px; border: 2px dashed var(--blue-dot); border-radius: 22px; background: rgba(23, 23, 23, .88); pointer-events: none; }
.drop-hint[hidden] { display: none; }

/* What hangs above the composer, stacked so nothing covers anything else */
.composer-above { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 0 6px; pointer-events: none; z-index: 40; }
.composer-above > * { position: static; pointer-events: auto; max-width: 100%; }
.composer-above .chips { order: 1; left: auto; right: auto; bottom: auto; }
.composer-above .composer-error { order: 2; max-width: 100%; overflow-wrap: anywhere; }
.composer-above .model-bar { order: 3; flex-wrap: wrap; padding-left: 4px; }

/* Messages: tables, quotes, nested lists, code with a copy button */
.bubble blockquote { margin: 6px 0; padding: 2px 0 2px 12px; border-left: 3px solid #444; color: #cfcfcf; }
.bubble blockquote p { margin: 0 0 4px; }
.bubble li > ul, .bubble li > ol { margin: 2px 0; }
.table-wrap { overflow-x: auto; margin: 6px 0; max-width: 100%; border: 1px solid #2a2a2a; border-radius: 10px; }
.bubble table { border-collapse: collapse; font-size: .93em; min-width: 100%; }
.bubble th, .bubble td { padding: 6px 12px; border-bottom: 1px solid #2c2c2c; text-align: left; vertical-align: top; }
.bubble th { background: #1a1a1a; font-weight: 600; white-space: nowrap; }
.bubble tr:last-child td { border-bottom: 0; }
.code-wrap { position: relative; }
.code-wrap pre { margin: 6px 0; padding-top: 30px; }
.code-copy { position: absolute; top: 12px; right: 8px; font-size: 12px; line-height: 1; padding: 5px 9px; border-radius: 7px; background: #262626; color: #bbb; border: 1px solid #333; }
.code-copy:hover { color: #fff; background: #303030; }
.code-copy.copied { color: var(--green); }

/* Contrast: links on blue and on dark, setup link, status chips */
.msg-row.user .bubble a { color: #fff; text-decoration: underline; }
.app-setup-link { color: #b9d2ff; }
.sk-link, .workspace-home-note button, .workspace-history-window button { color: #7fadff; }
.mod-src.rule, .workspace-run-state.running, .workspace-run-state.queued { color: #b6d0ff; }

/* Print view for "Share as PDF" */
.print-view { display: none; }
.print-view.open { display: block; position: fixed; inset: 0; z-index: 300; overflow: auto; background: #fff; color: #111; }
.pv-bar { position: sticky; top: 0; display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 10px 16px; background: #f3f3f3; border-bottom: 1px solid #ddd; }
.pv-bar span { margin-right: auto; font: 14px -apple-system, sans-serif; color: #444; }
.pv-bar button { padding: 8px 16px; border-radius: 999px; border: 1px solid #bbb; background: #fff; color: #111; font: 14px -apple-system, sans-serif; }
.pv-bar button.primary { background: #111; color: #fff; border-color: #111; }
.pv-doc { max-width: 760px; margin: 0 auto; padding: 32px 24px 60px; font: 11.5pt/1.55 Georgia, "Times New Roman", serif; }
.pv-doc h1 { font-size: 22pt; margin: 0 0 4px; }
.pv-sub { color: #666; font-size: 10pt; margin: 0 0 24px; font-family: -apple-system, "Helvetica Neue", sans-serif; }
.pv-msg { margin: 0 0 16px; break-inside: avoid-page; }
.pv-who { font: 600 9.5pt -apple-system, "Helvetica Neue", sans-serif; color: #333; margin-bottom: 2px; }
.pv-who time { font-weight: 400; color: #777; margin-left: 8px; }
.pv-body { overflow-wrap: anywhere; }
.pv-body p { margin: 0 0 6px; }
.pv-body pre { background: #f4f4f4; border: 1px solid #ddd; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 9.5pt; break-inside: avoid; }
.pv-body code { background: #f1f1f1; padding: 0 3px; font-size: .92em; }
.pv-body pre code { background: none; padding: 0; }
.pv-body .code-copy { display: none; }
.pv-body .table-wrap { border: 0; overflow: visible; }
.pv-body table { border-collapse: collapse; width: 100%; font-size: 10pt; }
.pv-body th, .pv-body td { border: 1px solid #ccc; padding: 4px 8px; text-align: left; vertical-align: top; }
.pv-body blockquote { border-left: 3px solid #ccc; margin: 6px 0; padding-left: 12px; color: #444; }
.pv-atts { font: 9.5pt -apple-system, sans-serif; color: #555; margin-bottom: 3px; }
.pv-msg.you .pv-who { color: #1d4ea3; }
@media print {
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; }
  body > *:not(#print-view) { display: none !important; }
  .print-view.open { position: static; display: block; overflow: visible; }
  .pv-bar { display: none; }
  .pv-doc { max-width: none; padding: 0; }
}

/* Phones and iPads */
.details { z-index: 40; }
@media (max-width: 980px) {
  .details, .screen { position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100%); z-index: 40; box-shadow: -24px 0 70px rgba(0, 0, 0, .55); }
  .details { padding-top: max(18px, env(safe-area-inset-top, 0px)); padding-bottom: max(30px, env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 720px) {
  .details, .screen { width: 100%; }
  .modal-foot { flex-wrap: wrap; padding: 14px 16px; gap: 10px; }
  .nb-runs { flex: 1 1 100%; margin-right: 0; justify-content: space-between; }
  .nb-hint { flex: 1 1 100%; order: -1; }
  #nb-form .modal-foot .nb-btn { flex: 1 1 0; padding: 10px 14px; }
  .apps-head .apps-title { flex: 1 1 calc(100% - 52px); }
  .apps-head .apps-search { order: 3; flex: 1 1 100%; width: 100%; }
  .apps-head .modal-close { order: 2; }
  .home-top { flex: 0 0 auto; max-height: 32dvh; }
  .chat-search { left: 8px; right: 8px; }
}
.composer { bottom: max(38px, calc(env(safe-area-inset-bottom, 0px) + 28px)); }
@media (max-width: 720px) { .composer { bottom: max(28px, calc(env(safe-area-inset-bottom, 0px) + 22px)); } .footnote { bottom: max(7px, env(safe-area-inset-bottom, 0px)); } }

/* Touch screens: bigger targets, and no hover-only buttons */
@media (hover: none) { .actions { opacity: 1; } }
@media (pointer: coarse) {
  .composer textarea, .chat-search input, .search, .nb-input, .apps-search, .sk-search { font-size: 16px; }
  .chip button { width: 36px; height: 36px; margin: -8px -4px -8px 0; font-size: 16px; }
  .message-content .actions button, .actions button { width: 36px; height: 36px; }
  .model-bar select { min-height: 36px; font-size: 14px; padding-top: 8px; padding-bottom: 8px; }
  .modal-close, .code-copy, .me-name, .sk-link, .stop, .typing .stop { min-height: 36px; min-width: 36px; }
  .code-copy { top: 8px; padding: 9px 12px; }
  .nb-color { width: 36px; height: 36px; }
  .apps-filters button, .app-btn, .workspace-button, .d-tabs button, .option, .app-add, .mod-x { min-height: 36px; }
  .app-add { min-width: 36px; }
  .plus-menu button { min-height: 40px; }
  button.older-note { min-height: 36px; }
}
.cs-head input::-webkit-search-cancel-button { display: none; }

/* The Screen panel and the Bot details panel never cover the header row, so Search, Screen, Share and Calendar stay clickable.
   Wide windows put them beside the chat. Anything narrower puts them under the header. */
@media (max-width: 1399px) {
  .details, .screen { position: fixed; top: calc(60px + env(safe-area-inset-top, 0px)); right: 0; bottom: 0; z-index: 40; box-shadow: -24px 0 70px rgba(0, 0, 0, .55); }
  .details { padding-top: 18px; }
}
