/* What the app hides (by level, or not open yet) stays hidden, whatever its display. */
[hidden] { display: none !important; }

: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;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-main);
  color: var(--text);
  font: 16px/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: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

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

/* Sidebar */
.sidebar {
  width: 380px; flex-shrink: 0;
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  padding: 16px 14px 14px;
}
.sidebar-top { display: flex; justify-content: flex-end; gap: 10px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: #1c1c1c; display: grid; place-items: center; color: #d6d6d6;
  transition: background .15s;
}
.icon-btn:hover { background: #2a2a2a; }
.icon-btn.on svg { stroke: var(--blue-dot); }
.search {
  margin: 12px 4px 0; padding: 9px 14px; border-radius: 12px;
  background: #1c1c1c; border: 1px solid var(--border); color: var(--text); font: inherit; outline: none;
}

.bot-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; margin-top: 12px; }
/* One group per Instance. */
.group { padding: 14px 12px 4px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-faint); }
.bot-row {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 10px 10px; border-radius: 14px; 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: 16px; color: #f0f0f0; }
.bot-row .preview {
  font-size: 14.5px; 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: 15px; 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: 16px; cursor: pointer; }
.me-avatar {
  width: 40px; height: 40px; 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: a soft "Squish" robot with a visor */
.avatar { display: block; flex-shrink: 0; }

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

/* A Bot's live screen, beside the chat */
.share-btn.screen-btn { right: 108px; }
.app:has(.screen:not([hidden])) .share-btn { display: none; } /* the panel has its own close button */
.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: 72px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.screen-bar span { flex: 1; font-size: 16px; color: #dcdcdc; }
.screen-take { background: #1f1f1f; padding: 8px 16px; border-radius: 999px; font-size: 15px; }
.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: 15px; }

.messages {
  flex: 1; overflow-y: auto;
  padding: 18px 80px 140px 80px;
  display: flex; flex-direction: column; gap: 14px;
}
.timestamp { align-self: center; max-width: 760px; width: 100%; text-align: center; color: var(--text-dim); font-size: 14.5px; 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; max-width: 760px;
  font-size: 16.5px; 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; }
.msg-row.user .bubble .from { color: rgba(255,255,255,.75); }

.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 svg { width: 18px; height: 18px; }

.question { width: 760px; max-width: 100%; padding: 16px 20px 10px; }
.question h4 { margin: 0 0 12px; font-size: 16.5px; 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: 16.5px;
}
.option .key {
  width: 30px; height: 30px; border-radius: 8px; background: #2a2a2a;
  display: grid; place-items: center; font-size: 13px; 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; }

.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: 38px; height: 38px; 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: center; gap: 10px;
  background: #1c1c1c; border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 8px 7px 10px;
  box-shadow: 0 -16px 32px rgba(23,23,23,.9);
}
.composer input {
  flex: 1; background: none; border: 0; outline: none; color: var(--text);
  font: inherit; font-size: 17px;
}
.composer input::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: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--blue); color: #fff; }
.composer-plus:hover, .composer-mic:hover { color: #fff; }

/* Branding: one faint line under the composer */
/* A Membre with "voir": the chat without the composer. */
.read-only {
  position: absolute; left: 80px; right: 80px; bottom: 44px;
  max-width: 1240px; margin: 0 auto; text-align: center;
  font-size: 14px; color: var(--text-dim);
}
.footnote { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; font-size: 12.5px; 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: 15px; }
.bot-pill { cursor: pointer; }
.bot-pill .harness { font-size: 13px; 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: 13.5px; color: var(--text-faint); }
.typing { align-items: center; }
.typing .status { margin-left: 8px; font-size: 14.5px; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typing .stop { margin-left: 10px; font-size: 13.5px; 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: 13px; 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: 26px 26px 24px 32px; border-bottom: 1px solid #2c2c2c; }
.modal-head h3 { margin: 0; font-size: 20px; 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: 22px; height: 22px; }
.modal-body { padding: 22px 32px 34px; display: flex; flex-direction: column; align-items: center; }
.nb-photo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 6px 0 24px; border-radius: 20px; }
.nb-preview { height: 150px; }
.nb-photo-label { font-size: 15px; color: var(--text-dim); border: 1px solid #333; border-radius: 999px; padding: 6px 16px; }
.nb-photo:hover .nb-photo-label { color: var(--text); background: #2a2a2a; }
.avatar.photo { border-radius: 50%; object-fit: cover; background: #262626; }
.nb-input.nb-role { height: auto; min-height: 84px; padding: 12px 16px; resize: vertical; text-align: left; font-size: 16px; line-height: 1.4; margin-bottom: 22px; }
.nb-advanced { width: 100%; border: 1px solid #2c2c2c; border-radius: 14px; padding: 0 16px; display: flex; flex-direction: column; }
.nb-advanced summary { cursor: pointer; padding: 12px 0; color: var(--text-dim); font-size: 15px; }
.nb-advanced[open] summary { margin-bottom: 4px; }
.nb-advanced .nb-runs { margin: 0 0 12px; justify-content: space-between; }
.nb-look { font-size: 14.5px; color: var(--text-dim); margin: 8px 0 16px; }
.nb-advanced .nb-shapes { gap: 16px 20px; margin: 0 auto 24px; }
.nb-advanced .nb-colors { margin: 0 auto 18px; }
.d-role { margin-top: 6px; padding: 0 24px; text-align: center; color: var(--text-dim); font-size: 14.5px; white-space: pre-wrap; }
.nb-input { width: 100%; height: 50px; display: block; background: transparent; border: 1px solid #2f2f2f; border-radius: 14px; padding: 0 16px; font: inherit; font-size: 17px; text-align: center; color: var(--text); outline: none; margin-bottom: 16px; }
.nb-input:focus { border-color: #444; }
.nb-input::placeholder { color: #8a8a8a; }
.nb-shapes { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px 32px; width: 460px; max-width: 100%; margin-bottom: 44px; }
.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: 22px 22px; width: 340px; 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-error { color: #f1b5b5; font-size: 14.5px; margin-top: 22px; }
.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; font-size: 14.5px; color: var(--text-dim); display: flex; align-items: center; gap: 8px; }
.nb-runs select { max-width: 62%; background: #262626; color: var(--text); border: 1px solid #333; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 14.5px; outline: none; }
.nb-btn { padding: 10px 24px; border-radius: 999px; font-size: 17px; 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: 80px; right: 80px; bottom: 98px; z-index: 1;
  max-width: 1240px; margin: 0 auto; padding-left: 14px;
  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: 13px; 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: 16px; right: 16px; width: 40px; height: 40px; 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: 23px; 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: 16px; 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: 15.5px; 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: 16px; 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 svg:last-child { width: 16px; height: 16px; color: #777; }
.d-text { flex: 1; min-width: 0; }
.d-sub { color: var(--text-dim); font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-empty { color: var(--text-faint); font-size: 15px; }
.d-danger, .d-danger svg { color: #f08a8a !important; }
.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: 11px; 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: 15px; outline: none; }
.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); }

/* Sign-in */
.signin .modal-body { gap: 14px; }
.signin-list { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.signin-dev { width: 100%; margin: 6px 0 0; text-align: center; font-size: 13px; opacity: 0.7; }
.icon-btn[hidden] { display: none; }
.devices .modal-body { align-items: stretch; }
.device-list { display: flex; flex-direction: column; gap: 6px; }
.device-member { margin: 12px 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; opacity: .6; }
.device-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #2c2c2c; }
.device-text { flex: 1; min-width: 0; }
.device-name { font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
.device-here { display: inline-block; white-space: nowrap; margin-left: 6px; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #2f4f3a; color: #bfe8cb; }
.device-when { font-size: 13px; opacity: .65; }
.device-row .nb-btn { padding: 6px 16px; font-size: 14px; }
.log-list { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 10px; }
.log-list li { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; background: #262626; font-size: 14px; }
.log-list time, .log-list small { font-size: 12px; opacity: 0.65; }

/* Phone: the Bot list or one chat, full width; panels and the New Bot window
   cover the screen. */
.back-btn { display: none; }
@media (max-width: 700px) {
  .sidebar { width: 100%; }
  body.in-chat .sidebar, body:not(.in-chat) .chat { display: none; }
  .back-btn { display: grid; position: absolute; left: 12px; }
  .bot-pill { max-width: calc(100% - 190px); overflow: hidden; white-space: nowrap; }
  .share-btn:not(.screen-btn) { display: none; }
  .share-btn.screen-btn { right: 12px; padding: 9px 14px; }
  .messages { padding: 12px 14px 150px; }
  .bubble { max-width: 85%; }
  .composer, .read-only { left: 12px; right: 12px; }
  .model-bar { left: 12px; right: 12px; }
  .details, .screen { position: fixed; inset: 0; width: auto; min-width: 0; z-index: 40; border: 0; }
}
@media (max-width: 600px) {
  .modal-backdrop#nb { place-items: stretch; }
  #nb .modal { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; overflow: hidden; border-radius: 0; border: 0; display: flex; flex-direction: column; }
  #nb .modal-head { padding: 16px 16px 14px 20px; }
  #nb .modal-body { padding: 18px 20px 24px; flex: 1; min-height: 0; overflow-y: auto; }
  #nb .modal-body > * { flex-shrink: 0; }
  #nb .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
}

/* Approvals (#27): what Bots wait on, for gérer */
.approvals { position: fixed; top: 72px; left: 50%; transform: translateX(-50%); width: min(600px, calc(100vw - 24px)); z-index: 45; display: flex; flex-direction: column; gap: 8px; }
.approvals[hidden] { display: none; }
.approval { border: 1px solid #5a4a1f; background: #241f12; box-shadow: 0 8px 24px rgba(0,0,0,.5); border-radius: 14px; padding: 10px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.approval p { flex: 1 1 260px; margin: 0; font-size: 15.5px; }
.approval small { display: block; color: var(--text-dim); font-size: 13px; }
.approval .nb-btn { padding: 7px 16px; font-size: 15px; }
.approval .nb-btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
