@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: italic; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Pixelify Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/pixelify-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Pixelify Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/pixelify-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Pixelify Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/pixelify-sans-latin-600-normal.woff2") format("woff2"); }

:root {
  --tl: #0f6b5a; --tr: #0a4a52; --bl: #073640; --br: #021418;
  --edge: #d9dcec;
  --edge-dark: #4b5280;
  --text: #f4f5fb;
  --text-dim: #aab0d0;
  --accent: #ffe680;      /* FF-style highlight yellow */
  --life: #7dffb2;        /* lifestream green */
  --danger: #ff8a8a;
  --radius: 7px;
  --ui-font: "Pixelify Sans", "Courier New", monospace;
  --chat-font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --side-w: 260px;
  --status-h: 38px;
  color-scheme: dark;
}
body.font-pixel { --chat-font: "Pixelify Sans", "Courier New", monospace; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #000;
  color: var(--text);
  font: 15px/1.55 var(--chat-font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-variant-ligatures: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

#lifestream { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }

/* ---------------------------------------------------------------- windows */

.win {
  position: relative;
  background: linear-gradient(to right, var(--tl), var(--tr));
  border: 2px solid var(--edge);
  border-radius: var(--radius);
  box-shadow:
    inset 0 0 0 1px var(--edge-dark),
    inset 0 2px 0 1px rgba(255,255,255,.08),
    0 0 0 1px #000,
    0 6px 24px rgba(0,0,0,.7);
  text-shadow: 1px 1px 0 rgba(0,0,0,.85);
  isolation: isolate;
}
.win::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: calc(var(--radius) - 2px);
  background: linear-gradient(to right, var(--bl), var(--br));
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000);
          mask-image: linear-gradient(to bottom, transparent, #000);
  z-index: -1;
  pointer-events: none;
}

.win.opening { animation: winOpen 240ms cubic-bezier(.2,.8,.2,1) both; transform-origin: center; }
@keyframes winOpen {
  0%   { transform: scale(.55, .03); opacity: 0; }
  45%  { transform: scale(1, .03); opacity: 1; }
  100% { transform: scale(1, 1); opacity: 1; }
}

/* ---------------------------------------------------------------- layout */

#app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  gap: 14px;
  height: calc(100% - var(--status-h) - 14px);
  padding: 14px 14px 0;
}

#sidebar {
  display: flex; flex-direction: column;
  padding: 14px 10px 10px;
  min-height: 0;
  font-family: var(--ui-font);
}
.side-head { position: relative; display: flex; align-items: center; justify-content: center; padding: 0 4px 8px; }
.brand-logo {
  display: block; width: 100%; max-width: 230px; height: auto;
  mix-blend-mode: screen;            /* logo's black background melts into the window */
  -webkit-user-drag: none; user-select: none;
}
.side-head #close-side { position: absolute; top: 0; right: 0; }
.brand { font-size: 26px; letter-spacing: 6px; color: var(--text); text-shadow: 2px 2px 0 #000, 0 0 12px rgba(125,255,178,.35); }

.menu-item {
  display: block; width: 100%;
  background: none; border: 0; text-align: left;
  padding: 7px 10px 7px 34px;
  font-size: 17px; border-radius: 4px;
}
.menu-item:hover, .menu-item:focus-visible { background: rgba(255,255,255,.07); outline: none; }
.menu-label { color: var(--text-dim); font-size: 13px; letter-spacing: 2px; text-transform: uppercase; margin: 14px 10px 4px; }

.chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.chat-list li {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 6px 6px 34px; border-radius: 4px;
  font-size: 16px; line-height: 1.3;
  cursor: pointer;
}
.chat-list li:hover { background: rgba(255,255,255,.07); }
.chat-list li.active { color: var(--accent); }
.chat-list .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list .del { visibility: hidden; background: none; border: 0; color: var(--text-dim); padding: 0 4px; font-size: 14px; }
.chat-list li:hover .del, .chat-list li.active .del { visibility: visible; }
.chat-list .del:hover { color: var(--danger); }
.chat-list .empty { color: var(--text-dim); cursor: default; }
.chat-list .empty:hover { background: none; }

#open-settings { margin-top: 8px; border-top: 1px solid rgba(217,220,236,.25); border-radius: 0; padding-top: 10px; }

#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 12px; }

/* top bar */
#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  font-family: var(--ui-font);
}
.chat-title { flex: 1; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; outline: none; }
.chat-title[contenteditable="true"] { background: rgba(0,0,0,.3); padding: 0 6px; border-radius: 3px; }
.pill {
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(217,220,236,.5);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 15px; white-space: nowrap;
}
.pill:hover { border-color: var(--edge); background: rgba(255,255,255,.08); }
#search-btn[aria-pressed="true"] { color: var(--life); border-color: rgba(125,255,178,.6); }
#search-btn[aria-pressed="false"] { color: var(--text-dim); }
#search-btn:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn { background: none; border: 0; font-size: 18px; padding: 2px 8px; line-height: 1; }
.mobile-only { display: none; }

/* model menu */
.popup {
  position: absolute; z-index: 30;
  min-width: 280px; max-height: 60vh; overflow-y: auto;
  padding: 8px 6px;
  font-family: var(--ui-font);
}
.popup .opt { display: flex; align-items: baseline; gap: 10px; width: 100%; background: none; border: 0; text-align: left; padding: 6px 10px 6px 34px; border-radius: 4px; font-size: 16px; }
.popup .opt:hover { background: rgba(255,255,255,.07); }
.popup .opt.current { color: var(--accent); }
.popup .opt .tags { margin-left: auto; color: var(--text-dim); font-size: 12px; letter-spacing: 1px; }

/* ---------------------------------------------------------------- messages */

#messages {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 4px 6px 8px;
  display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth;
}
.msg { max-width: 860px; width: 100%; padding: 12px 16px 12px; }
.msg.user { align-self: flex-end; width: auto; max-width: min(640px, 85%); }
.msg.assistant { align-self: flex-start; }
.msg .speaker {
  font-family: var(--ui-font); font-size: 15px; letter-spacing: 1px;
  color: var(--text-dim); margin-bottom: 4px;
}
.msg.assistant .speaker { color: var(--life); }
.msg .body { overflow-wrap: anywhere; }
.msg .body > :first-child { margin-top: 0; }
.msg .body > :last-child { margin-bottom: 0; }
.msg .body p { margin: .55em 0; }
.msg .body ul, .msg .body ol { padding-left: 1.4em; margin: .5em 0; }
.msg .body li { margin: .2em 0; }
.msg .body h1, .msg .body h2, .msg .body h3 { font-family: var(--ui-font); font-weight: 500; line-height: 1.25; margin: .9em 0 .4em; }
.msg .body h1 { font-size: 1.35em; } .msg .body h2 { font-size: 1.2em; } .msg .body h3 { font-size: 1.08em; }
.msg .body code { font-family: var(--mono); font-size: .9em; background: rgba(0,0,0,.35); padding: .1em .35em; border-radius: 3px; text-shadow: none; }
.msg .body pre {
  background: rgba(0,0,6,.55); border: 1px solid rgba(217,220,236,.25);
  border-radius: 5px; padding: 10px 12px; overflow-x: auto; position: relative;
}
.msg .body pre code { background: none; padding: 0; font-size: 13.5px; line-height: 1.5; }
.msg .body table { border-collapse: collapse; margin: .6em 0; display: block; overflow-x: auto; }
.msg .body th, .msg .body td { border: 1px solid rgba(217,220,236,.3); padding: 4px 10px; text-align: left; }
.msg .body th { background: rgba(0,0,0,.25); font-weight: 600; }
.msg .body blockquote { margin: .6em 0; padding-left: 12px; border-left: 3px solid rgba(217,220,236,.4); color: var(--text-dim); }
.msg .body hr { border: 0; border-top: 1px solid rgba(217,220,236,.3); }
.msg .body img { max-width: 100%; }
.cite { font-size: .72em; vertical-align: super; line-height: 0; }
.cite a { text-decoration: none; padding: 0 1px; }

.copy-btn {
  position: absolute; top: 6px; right: 6px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(217,220,236,.3);
  border-radius: 3px; font: 12px var(--ui-font); padding: 1px 7px; opacity: 0; transition: opacity .15s;
}
pre:hover .copy-btn { opacity: 1; }

.msg .images { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.msg .images img { max-height: 160px; max-width: 220px; border-radius: 4px; border: 1px solid rgba(217,220,236,.4); }

/* thinking box */
.think {
  margin: 4px 0 10px;
  border: 1px solid rgba(217,220,236,.28);
  border-radius: 5px;
  background: rgba(0,0,0,.22);
}
.think summary {
  list-style: none; cursor: pointer;
  font-family: var(--ui-font); font-size: 14px; color: var(--text-dim);
  padding: 4px 10px;
  user-select: none;
}
.think summary::-webkit-details-marker { display: none; }
.think summary::before { content: "▸ "; }
.think[open] summary::before { content: "▾ "; }
.think .think-text {
  padding: 2px 12px 10px; font-size: 13px; line-height: 1.5; color: var(--text-dim);
  white-space: pre-wrap; max-height: 220px; overflow-y: auto;
  text-shadow: none;
}
.think.live summary { color: var(--life); }
.think.live summary::after { content: ""; display: inline-block; width: 1.4em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* activity line (searching / reading) */
.activity { font-family: var(--ui-font); font-size: 14px; color: var(--life); margin: 2px 0 8px; }
.activity div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity div::before { content: "› "; }
.activity div.fail { color: var(--danger); }

/* sources */
.sources { margin-top: 12px; padding-top: 8px; border-top: 1px solid rgba(217,220,236,.25); font-size: 13px; }
.sources .label { font-family: var(--ui-font); color: var(--text-dim); font-size: 13px; letter-spacing: 1px; margin-bottom: 3px; }
.sources ol { margin: 0; padding-left: 0; list-style-position: inside; }
.sources li::marker { color: var(--accent); font-family: var(--ui-font); }
.sources li { margin: 1px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sources a { color: var(--text); text-decoration: none; }
.sources a:hover { color: var(--accent); }
.sources .host { color: var(--text-dim); }

.msg-foot { display: flex; align-items: center; gap: 12px; margin-top: 8px; font: 13px var(--ui-font); color: var(--text-dim); }
.msg-foot button { background: none; border: 0; padding: 0; color: var(--text-dim); font: inherit; }
.msg-foot button:hover { color: var(--text); }
.msg-foot .spacer { flex: 1; }

.cursor-blink::after { content: "▌"; color: var(--life); animation: blink 1s steps(2) infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }

.notice { align-self: center; max-width: 560px; padding: 12px 16px; font-size: 14px; }
.notice .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.error-msg { color: var(--danger); }

/* empty state */
.welcome {
  margin: auto; text-align: center; padding: 28px 40px;
  font-family: var(--ui-font);
}
.welcome .big { font-size: 34px; letter-spacing: 10px; text-shadow: 2px 2px 0 #000, 0 0 18px rgba(125,255,178,.45); }
.welcome .small { color: var(--text-dim); margin-top: 6px; font-size: 16px; }

/* ---------------------------------------------------------------- composer */

#composer { padding: 8px 10px; margin-bottom: 2px; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
#input {
  flex: 1; resize: none; background: transparent; border: 0; outline: none;
  max-height: 220px; padding: 6px 4px; line-height: 1.5;
  text-shadow: 1px 1px 0 rgba(0,0,0,.85);
}
#input::placeholder { color: var(--text-dim); }
.send-btn {
  background: rgba(0,0,0,.3); border: 1px solid rgba(217,220,236,.6);
  border-radius: 5px; width: 40px; height: 34px; font-size: 15px; flex: none;
}
.send-btn:hover { background: rgba(255,255,255,.1); }
.send-btn.stop { color: var(--danger); border-color: var(--danger); }
#attach-btn { height: 34px; font-size: 20px; }

.attachments { display: flex; gap: 8px; padding: 4px 4px 8px; flex-wrap: wrap; }
.attachments .thumb { position: relative; }
.attachments img { height: 56px; border-radius: 4px; border: 1px solid rgba(217,220,236,.5); display: block; }
.attachments button {
  position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%;
  background: #000; border: 1px solid var(--edge); font-size: 11px; line-height: 1; padding: 0;
}
body.dragging #composer { border-color: var(--life); }

/* ---------------------------------------------------------------- status bar */

#statusbar {
  position: fixed; left: 14px; right: 14px; bottom: 10px; z-index: 2;
  height: var(--status-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 14px;
  font-family: var(--ui-font); font-size: 15px;
  white-space: nowrap; overflow: hidden;
}
.sb-name { letter-spacing: 3px; color: var(--life); }
.sb-label { color: var(--accent); margin-right: 2px; }
.sb-cell { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.sb-time { margin-left: auto; }
#sb-links { color: var(--text-dim); gap: 10px; }
#sb-links .bad { color: var(--danger); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; box-shadow: 0 0 6px currentColor; }
.dot.ready { background: var(--life); color: var(--life); }
.dot.busy { background: var(--accent); color: var(--accent); animation: pulse 1s ease-in-out infinite; }
.dot.error { background: var(--danger); color: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------------------------------------------------------------- hand cursor */

#hand {
  position: fixed; z-index: 50; pointer-events: none;
  left: 0; top: 0; opacity: 0;
  transition: transform 90ms ease-out, opacity 120ms;
  filter: drop-shadow(1px 2px 0 rgba(0,0,0,.6));
}
#hand.on { opacity: 1; }
#hand svg { display: block; animation: bob .7s ease-in-out infinite alternate; }
@keyframes bob { from { transform: translateX(-2px); } to { transform: translateX(2px); } }

/* ---------------------------------------------------------------- settings dialog */

.dialog {
  padding: 0; color: var(--text);
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.dialog::backdrop { background: rgba(0,0,0,.55); }
.settings-form { padding: 14px 18px 18px; font-family: var(--ui-font); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dialog-head h2 { margin: 0; font-weight: 500; font-size: 22px; letter-spacing: 2px; }
.cfg-row { display: flex; align-items: center; gap: 14px; padding: 7px 0; border-bottom: 1px solid rgba(217,220,236,.12); }
.cfg-label { width: 140px; color: var(--accent); flex: none; font-size: 16px; }
.seg { display: flex; gap: 4px; }
.seg button {
  background: none; border: 1px solid transparent; border-radius: 4px;
  padding: 3px 12px 3px 30px; font-size: 16px; color: var(--text-dim);
}
.seg button.on { color: var(--text); border-color: rgba(217,220,236,.5); background: rgba(0,0,0,.25); }
.cfg-select {
  background: rgba(0,0,0,.35); border: 1px solid rgba(217,220,236,.5); border-radius: 4px;
  padding: 3px 6px; font-size: 15px; max-width: 100%;
}
.cfg-select option { background: #0a1a5c; }
.cfg-colors { align-items: flex-start; border-bottom: 0; }
.color-box { position: relative; width: 230px; height: 120px; }
.color-preview { position: absolute; inset: 14px; }
.color-preview.win { box-shadow: inset 0 0 0 1px var(--edge-dark), 0 0 0 1px #000; }
.corner {
  position: absolute; width: 30px; height: 30px; padding: 0; border: 2px solid var(--edge);
  border-radius: 4px; background: none; cursor: pointer; z-index: 2;
}
.corner::-webkit-color-swatch-wrapper { padding: 0; }
.corner::-webkit-color-swatch { border: 0; border-radius: 2px; }
.corner.tl { left: 0; top: 0; } .corner.tr { right: 0; top: 0; }
.corner.bl { left: 0; bottom: 0; } .corner.br { right: 0; bottom: 0; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 0 154px; }
.presets button {
  border: 1px solid var(--edge); border-radius: 4px; padding: 3px 10px; font-size: 14px;
  text-shadow: 1px 1px 0 #000;
}

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: calc(var(--status-h) + 26px); transform: translateX(-50%);
  z-index: 60; padding: 8px 16px; font-family: var(--ui-font); font-size: 15px;
}

/* ---------------------------------------------------------------- scrollbars */

* { scrollbar-width: thin; scrollbar-color: rgba(217,220,236,.35) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(217,220,236,.3); border-radius: 4px; }

/* ---------------------------------------------------------------- mobile */

@media (max-width: 760px) {
  :root { --status-h: 32px; }
  #app { grid-template-columns: 1fr; padding: 8px 8px 0; gap: 8px; height: calc(100% - var(--status-h) - 14px); }
  #sidebar {
    position: fixed; z-index: 40; left: 8px; top: 8px; bottom: calc(var(--status-h) + 16px);
    width: min(300px, 82vw);
    transform: translateX(calc(-100% - 20px)); transition: transform .22s ease;
  }
  body.side-open #sidebar { transform: none; }
  .mobile-only { display: inline-block; }
  #topbar { padding: 6px 8px; gap: 6px; }
  .chat-title { font-size: 16px; }
  .pill { font-size: 13px; padding: 2px 7px; }
  #model-name { max-width: 90px; display: inline-block; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
  .msg { padding: 10px 12px; }
  .msg.user { max-width: 92%; }
  #statusbar { left: 8px; right: 8px; bottom: 8px; gap: 12px; font-size: 13px; padding: 0 10px; }
  .sb-wide { display: none; }
  .cfg-label { width: 100px; font-size: 14px; }
  .presets { margin-left: 0; }
  #hand { display: none; }
  .chat-list .del { visibility: visible; }
}

@media (prefers-reduced-motion: reduce) {
  .win.opening, #hand svg, .dot.busy { animation: none; }
}


/* ---------------------------------------------------------------- auth */

#auth {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center; padding: 16px;
  overflow-y: auto;
}
#auth[hidden] { display: none; }
body.locked #app, body.locked #statusbar { display: none; }
.auth-win {
  width: min(380px, 100%);
  padding: 18px 22px 22px;
  display: flex; flex-direction: column; gap: 10px;
  font-family: var(--ui-font);
}
.auth-logo { width: 220px; max-width: 80%; align-self: center; mix-blend-mode: screen; margin-bottom: -4px; }
.auth-title { text-align: center; font-size: 20px; letter-spacing: 2px; color: var(--accent); }
.auth-note { margin: 0; font-size: 14px; color: var(--text-dim); text-align: center; line-height: 1.4; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 14px; color: var(--accent); }
.field[hidden] { display: none; }
.field input, .add-user input, .pw-row input {
  background: rgba(0,0,0,.35); border: 1px solid rgba(217,220,236,.5); border-radius: 4px;
  padding: 7px 9px; font: 15px var(--chat-font); color: var(--text); outline: none; min-width: 0;
}
.field input:focus, .add-user input:focus, .pw-row input:focus { border-color: var(--edge); background: rgba(0,0,0,.5); }
.auth-error { margin: 0; color: var(--danger); font-size: 14px; text-align: center; }
.auth-btn {
  margin-top: 6px; padding: 8px 12px 8px 34px; font-size: 17px; letter-spacing: 1px;
  background: rgba(0,0,0,.3); border: 1px solid rgba(217,220,236,.7); border-radius: 5px;
}
.auth-btn:hover { background: rgba(255,255,255,.1); }
.auth-btn:disabled { opacity: .5; }

/* ---------------------------------------------------------------- config: sections, users, account */

.cfg-section {
  margin: 18px 0 4px; font-weight: 500; font-size: 17px; letter-spacing: 2px;
  color: var(--life); border-bottom: 1px solid rgba(217,220,236,.25); padding-bottom: 4px;
}
.cfg-hint { font-size: 12px; color: var(--text-dim); letter-spacing: 1px; margin-left: 8px; }
body:not(.is-admin) .admin-only { display: none; }
.user-list { list-style: none; margin: 4px 0 8px; padding: 0; }
.user-list li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid rgba(217,220,236,.1); font-size: 15px; flex-wrap: wrap; }
.user-list .un { flex: 1; min-width: 120px; }
.user-list .un small { color: var(--text-dim); margin-left: 6px; }
.user-list .role { color: var(--accent); font-size: 12px; letter-spacing: 1px; }
.user-list button { font-size: 13px; padding: 1px 8px; }
.add-user, .pw-row { display: flex; gap: 6px; flex-wrap: wrap; }
.add-user input { flex: 1 1 110px; }
.pw-row input { flex: 1 1 150px; }
.pill.danger { color: var(--danger); border-color: rgba(255,138,138,.6); }


/* ---------------------------------------------------------------- v1.3: sidebar search, groups, chat menu */

.chat-search {
  margin: 6px 6px 8px; padding: 5px 9px;
  background: rgba(0,0,0,.3); border: 1px solid rgba(217,220,236,.35); border-radius: 4px;
  font: 14px var(--ui-font); color: var(--text); outline: none;
}
.chat-search:focus { border-color: var(--edge); background: rgba(0,0,0,.45); }
.chat-search::placeholder { color: var(--text-dim); }
.chat-list li.group {
  color: var(--text-dim); font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  padding: 10px 6px 3px 10px; cursor: default;
}
.chat-list li.group:hover { background: none; }
.chat-list li { flex-wrap: wrap; }
.chat-list .pin-mark { color: var(--accent); font-size: 9px; margin-right: 2px; }
.chat-list .more {
  visibility: hidden; background: none; border: 0; color: var(--text-dim);
  padding: 0 5px; font-size: 16px; line-height: 1; border-radius: 3px;
}
.chat-list li:hover .more, .chat-list li.active .more { visibility: visible; }
.chat-list .more:hover { color: var(--text); background: rgba(255,255,255,.1); }
.chat-list li.result .snip {
  flex-basis: 100%; font: 12px/1.35 var(--chat-font); color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px;
}
.rename-input {
  flex: 1; min-width: 0; background: rgba(0,0,0,.45); border: 1px solid var(--edge); border-radius: 3px;
  font: 15px var(--ui-font); color: var(--text); padding: 1px 5px; outline: none;
}
.chat-menu { position: fixed; z-index: 45; min-width: 190px; padding: 6px 4px; }
.chat-menu .opt { font-size: 16px; }
.danger-text { color: var(--danger) !important; }

/* ---------------------------------------------------------------- files */

.file-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.file-chip {
  font: 13px var(--ui-font); padding: 2px 8px; border-radius: 4px;
  background: rgba(0,0,0,.3); border: 1px solid rgba(217,220,236,.35);
}
.attachments .thumb.doc {
  display: flex; flex-direction: column; justify-content: center;
  height: 56px; min-width: 120px; max-width: 220px; padding: 4px 22px 4px 10px;
  background: rgba(0,0,0,.3); border: 1px solid rgba(217,220,236,.5); border-radius: 4px;
}
.thumb.doc .doc-name { font: 14px var(--ui-font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb.doc .doc-meta { font: 12px var(--ui-font); color: var(--text-dim); }
.thumb.doc.uploading .doc-meta { color: var(--life); }

/* ---------------------------------------------------------------- edit & memory */

.edit-box textarea {
  width: 100%; min-width: 260px; resize: vertical;
  background: rgba(0,0,0,.35); border: 1px solid rgba(217,220,236,.5); border-radius: 4px;
  padding: 6px 8px; font: 15px/1.5 var(--chat-font); color: var(--text); outline: none;
}
.edit-actions { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.edit-hint { flex: 1; font: 12px var(--ui-font); color: var(--text-dim); }
.msg.user .msg-foot { justify-content: flex-end; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.msg.user:hover .msg-foot, .msg.user:focus-within .msg-foot { opacity: 1; }
.activity div.mem { color: var(--accent); }
.activity div.mem::before { content: "◆ "; }
.mem-list { list-style: none; margin: 6px 0 8px; padding: 0; max-height: 240px; overflow-y: auto; }
.mem-list li { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid rgba(217,220,236,.1); font: 14px/1.4 var(--chat-font); }
.mem-list li.empty { color: var(--text-dim); border: 0; }
.mem-list .mt { flex: 1; }
.mem-list input { flex: 1; background: rgba(0,0,0,.45); border: 1px solid var(--edge); border-radius: 3px; padding: 3px 6px; color: var(--text); font: inherit; outline: none; }
.mem-list button { font-size: 12px; padding: 1px 7px; }

@media (max-width: 760px) {
  .chat-list .more { visibility: visible; }
  .msg.user .msg-foot { opacity: 1; }
}


/* ---------------------------------------------------------------- separate message colors */
:root {
  --u-tl: #1b3fa8; --u-tr: #0d2470; --u-bl: #0a1a5c; --u-br: #040b2e;
  --g-tl: #0f6b5a; --g-tr: #0a4a52; --g-bl: #073640; --g-br: #021418;
}
.msg.user { --tl: var(--u-tl); --tr: var(--u-tr); --bl: var(--u-bl); --br: var(--u-br); }
.msg.assistant { --tl: var(--g-tl); --tr: var(--g-tr); --bl: var(--g-bl); --br: var(--g-br); }
#color-target button { padding-left: 26px; font-size: 15px; }
.presets button.current { outline: 2px solid var(--accent); outline-offset: 1px; }

/* fixes: hidden cells, and config dialog scrolls inside so its gradient covers everything */
[hidden] { display: none !important; }
.dialog { overflow: hidden; }
.dialog[open] { display: flex; flex-direction: column; }
.dialog .settings-form { overflow-y: auto; max-height: calc(100vh - 44px); }


/* ---------------------------------------------------------------- Lifestream inside the thinking box */
.think { position: relative; overflow: hidden; }
.think.streaming { background: rgba(0, 4, 3, .78); border-color: rgba(125,255,178,.35); box-shadow: inset 0 0 18px rgba(125,255,178,.12); }
.think.streaming[open] .think-text { min-height: 120px; }
.think .box-stream {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; opacity: 1; transition: opacity .7s ease;
}
.think .box-stream.fading { opacity: 0; }
.think summary, .think .think-text { position: relative; z-index: 1; }
.think.streaming .think-text { color: #cfe9dc; text-shadow: 0 0 4px #000, 1px 1px 0 #000; }
.msg-foot .stats { cursor: help; }
