/* Cinta chat — LibreChat-style. Dark default, light via prefers-color-scheme. */
[hidden] { display: none !important; }  /* author display rules beat the UA [hidden] otherwise */
:root {
  color-scheme: dark light;
  --bg: #212830; --sidebar: #1e1f22; --card: #2b3138; --card-hover: #343d46;
  --fg: #e6e1e5; --fg-dim: #9aa3ad; --line: #31373d;
  --accent: #A32CC4; --accent-contrast: #FAF5FC;  /* the only brand change: pink accent -> purple */ --user-bubble: #2e3742;
  --error: #e5534b; --code-bg: #161b1f;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff; --sidebar: #f7f0f2; --card: #ffffff; --card-hover: #efe4e8;
    --fg: #1c1b1f; --fg-dim: #6b7280; --line: #e5e7eb;
    --accent: #A32CC4; --accent-contrast: #ffffff; --user-bubble: #f3e8ec;
    --code-bg: #f6f8fa;
  }
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--fg); overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
img, svg { display: block; }

/* --- signed-out and offline cards --- */
#signedout, #offline { height: 100dvh; display: grid; place-items: center; padding: 24px; }
.so-card { background: var(--card); border-radius: 20px; padding: 40px 36px; max-width: 420px;
  width: 100%; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,.25); }
.so-card h1 { font-size: 28px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.so-card h1 img { width: 34px; height: 34px; border-radius: 8px; }
.so-card .sub { opacity: .7; margin-top: 6px; font-size: 14px; }
.btn { display: inline-block; margin-top: 20px; padding: 12px 28px; border-radius: 999px;
  background: var(--accent); color: var(--accent-contrast); text-decoration: none; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }

/* --- shell --- */
#app { display: flex; height: 100dvh; }
#sidebar {
  width: 260px; flex: none; background: var(--sidebar); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 12px; gap: 10px;
}
.sb-brand {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-weight: 700;
}
.sb-brand img { width: 22px; height: 22px; border-radius: 6px; }
.sb-search input {
  width: 100%; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); outline: none;
}
.sb-search input:focus { border-color: var(--accent); }
#convlist { flex: 1; overflow-y: auto; min-height: 0; }
.bucket { font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--fg-dim); margin: 14px 8px 4px; }
.convrow { position: relative; display: flex; align-items: center; }
.conv {
  display: block; flex: 1; min-width: 0; text-align: left; padding: 8px 10px; border-radius: 8px;
  color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv:hover { background: var(--card); }
.conv.active { background: var(--card-hover); }
.cmenu { flex: none; padding: 2px 7px; border-radius: 6px; color: var(--fg-dim); font-size: 15px;
  opacity: 0; transition: opacity .12s; }
.convrow:hover .cmenu, .cmenu.open { opacity: 1; }
.cmenu:hover { background: var(--card); color: var(--fg); }
.cmenu-pop { position: absolute; right: 6px; top: 30px; z-index: 40; min-width: 170px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); display: flex; flex-direction: column; }
.cmenu-pop button { text-align: left; padding: 8px 12px; border-radius: 6px; font-size: 13.5px;
  color: var(--fg); white-space: nowrap; }
.cmenu-pop button:hover { background: var(--card-hover); }
.cmenu-pop button.danger { color: var(--error); }
.pinnedhead { color: var(--accent); }
.rename { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--accent);
  border-radius: 6px; color: var(--fg); font: inherit; font-size: 14px; padding: 6px 8px; outline: none; }
.archlink { font-size: 12.5px; color: var(--fg-dim); padding: 8px 10px; border-top: 1px solid var(--line);
  text-decoration: none; }
.archlink:hover { color: var(--accent); }
/* --- sidebar message search (issue #11) --- */
.searchhead { color: var(--accent); }
.msghit { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; }
.msghit:hover { background: var(--card); }
.msghit-snip { font-size: 13px; line-height: 1.45; color: var(--fg-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.msghit-snip mark { background: var(--accent); color: var(--accent-contrast);
  border-radius: 3px; padding: 0 2px; }
.msghit-conv { font-size: 12px; color: var(--fg-dim); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.flash { animation: flashhit 1.6s ease-out; border-radius: 12px; }
@keyframes flashhit {
  0%, 35% { background: color-mix(in srgb, var(--accent) 28%, transparent); }
  100% { background: transparent; }
}
/* --- push notifications (issue #14): the per-device switch above the user row --- */
.sb-push { flex: none; display: flex; flex-direction: column; gap: 6px;
  border-top: 1px solid var(--line); padding-top: 10px; }
.pushrow { display: flex; flex-wrap: wrap; gap: 6px; }
.pushrow button { flex: 1 0 auto; padding: 6px 10px; border-radius: 10px;
  border: 1px solid var(--line); font-size: 12.5px; color: var(--fg-dim); }
.pushrow button:hover { background: var(--card); color: var(--fg); }
.pushrow button:disabled { opacity: .45; cursor: default; }
#pushstatus { padding: 0 2px; font-size: 12px; line-height: 1.45; color: var(--fg-dim); }
.sb-user { border-top: 1px solid var(--line); padding-top: 10px; display: flex; gap: 10px; align-items: center; }
.avatar { width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--accent);
  color: var(--accent-contrast); display: grid; place-items: center; font-weight: 700; overflow: hidden; }
.avatar img { width: 20px; height: 20px; }
.uname { font-weight: 600; font-size: 14px; }
.ulink { font-size: 12px; color: var(--fg-dim); }
.ulink:hover { color: var(--accent); }

/* --- main --- */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  height: 52px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
#sbtoggle { padding: 6px; border-radius: 8px; color: var(--fg-dim); }
#sbtoggle:hover { background: var(--card); color: var(--fg); }
.conv-title { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modelchip { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--fg-dim); }
#scroller { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
#messages { max-width: 768px; margin: 0 auto; padding: 24px 16px 16px; display: flex;
  flex-direction: column; gap: 22px; }
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg .avatar { width: 30px; height: 30px; border-radius: 8px; }
.msg .avatar img { width: 18px; height: 18px; }
.msg .body { min-width: 0; flex: 1; }
.msg .who { font-size: 12px; font-weight: 700; margin-bottom: 2px; color: var(--fg-dim); }
.msg.user .content { background: var(--user-bubble); border-radius: 12px; padding: 10px 14px;
  white-space: pre-wrap; overflow-wrap: break-word; }
.msg.assistant .content { overflow-wrap: break-word; }
.msg .content > *:first-child { margin-top: 0; }
.msg .content > *:last-child { margin-bottom: 0; }
.content p { margin: .5em 0; }
.content ul, .content ol { margin: .5em 0; padding-left: 1.4em; }
.content h1, .content h2, .content h3 { margin: .8em 0 .4em; line-height: 1.3; }
.content a { color: var(--accent); }
.content code { background: var(--code-bg); padding: .15em .4em; border-radius: 5px;
  font-size: .92em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.content pre { margin: .6em 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.codehead { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--sidebar); border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--fg-dim); }
.codehead .copy { font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.codehead .copy:hover { background: var(--card); color: var(--fg); }
.content pre code { display: block; padding: 12px; background: var(--code-bg); border-radius: 0;
  font-size: 13px; line-height: 1.5; overflow-x: auto; }
.actions { display: flex; gap: 6px; margin-top: 6px; }
.actions button { padding: 4px 6px; border-radius: 6px; color: var(--fg-dim); font-size: 12px; }
.actions button:hover { background: var(--card); color: var(--fg); }
.errorbubble { background: rgba(229,83,75,.12); color: var(--error); border: 1px solid var(--error);
  border-radius: 12px; padding: 10px 14px; font-size: 14px; }

/* --- composer --- */
#composer { flex: none; padding: 12px 16px 8px; }
#composerbox { max-width: 768px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px 10px; }
#composerbox:focus-within { border-color: var(--accent); }
#input { width: 100%; background: none; border: none; outline: none; resize: none; color: var(--fg);
  font: inherit; line-height: 1.5; max-height: 180px; min-height: 48px;
  padding: 4px 2px; margin: 0; }  /* two-line rest height like the reference composer */

#composerrow { display: flex; align-items: center; gap: 8px; }
#composerrow .cright { margin-left: auto; display: flex; align-items: center; gap: 10px; }
#mic { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  color: var(--fg-dim); background: none; border: none; }
#underrow { max-width: 768px; margin: 6px auto 0; display: flex; justify-content: space-between;
  font-size: 13px; color: var(--fg-dim); }
#send, #stop { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid;
  place-items: center; background: var(--accent); color: var(--accent-contrast); }
#send:disabled { opacity: .4; cursor: default; }
#looptoggle { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid;
  place-items: center; color: var(--fg-dim); border: 1px solid var(--line); }
#looptoggle:hover { background: var(--card-hover); color: var(--fg); }
#looptoggle.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.bgthinking { color: var(--fg-dim); font-size: 14px; animation: bgpulse 1.6s ease-in-out infinite; }
.bgnote { color: var(--fg-dim); font-size: 14px; }
.bgnote.fail { color: var(--error); }
@keyframes bgpulse { 50% { opacity: .35; } }
.footnote { max-width: 768px; margin: 8px auto 0; text-align: center; font-size: 12px;
  color: var(--fg-dim); }

/* --- responsive --- */
#backdrop { display: none; }
@media (max-width: 767px) {
  #sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  #sidebar.open { transform: none; }
  #backdrop.show { display: block; position: fixed; inset: 0; z-index: 10;
    background: rgba(0,0,0,.5); }
}
@media (min-width: 768px) {
  #sidebar.collapsed { display: none; }
}

/* --- message actions (issue #9) --- */
.msg .actions { opacity: 0; transition: opacity .15s ease; }
.msg:hover .actions, .msg .actions:focus-within { opacity: 1; }
.msg .actions button.primary { color: var(--accent); font-weight: 600; }
.editbox { width: 100%; }
.editbox textarea { width: 100%; background: var(--card); color: var(--fg);
  border: 1px solid var(--accent); border-radius: 12px; padding: 10px 14px;
  font: inherit; resize: vertical; min-height: 64px; outline: none; }
.editrow { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.editrow button { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line);
  color: var(--fg-dim); font-size: 13px; }
.editrow button.primary { background: var(--accent); color: var(--accent-contrast);
  border-color: var(--accent); font-weight: 600; }
.editrow button:hover { filter: brightness(1.1); }

/* --- parameters modal (issue #9) --- */
#paramsbtn { position: relative; padding: 6px; border-radius: 8px; color: var(--fg-dim); }
#paramsbtn:hover { background: var(--card); color: var(--fg); }
.pdot { position: absolute; top: 4px; right: 4px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent); }
#paramsmodal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.55);
  display: grid; place-items: center; padding: 20px; }
.modalcard { background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  width: min(460px, 100%); padding: 22px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 12px 48px rgba(0,0,0,.4); }
.modalcard h2 { font-size: 16px; }
.mfield { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.mfield .hint { font-style: normal; font-weight: 400; color: var(--fg-dim); }
.mfield textarea, .mfield input { background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  font: inherit; font-weight: 400; outline: none; }
.mfield textarea { resize: vertical; min-height: 72px; }
.mfield :focus { border-color: var(--accent); }
.modalrow { display: flex; gap: 10px; justify-content: flex-end; }
.modalrow button { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  color: var(--fg-dim); font-size: 13px; }
.modalrow button.primary { background: var(--accent); color: var(--accent-contrast);
  border-color: var(--accent); font-weight: 600; }
.modalrow button:hover { filter: brightness(1.1); }

/* --- attachments: composer chips, drop target, inline renders (issue #10) --- */
#composerbox { flex-wrap: wrap; }  /* chips wrap onto their own line above the input */
#chips { flex: 1 1 100%; order: -1; display: flex; flex-wrap: wrap; gap: 8px; }
#attach { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid;
  place-items: center; color: var(--fg-dim); }
#attach:hover { background: var(--card-hover); color: var(--fg); }
#composerbox.dragover { border-color: var(--accent); background: rgba(163, 44, 196, .08); }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg);
  font-size: 12.5px; max-width: 100%; }
.chip .ico { flex: none; width: 14px; height: 14px; color: var(--fg-dim); }
.chip img.thumb { width: 22px; height: 22px; border-radius: 999px; object-fit: cover; flex: none; }
.chip .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.chip .size { color: var(--fg-dim); font-size: 11px; flex: none; }
.chip .rm { flex: none; padding: 0 2px; color: var(--fg-dim); font-size: 15px; line-height: 1; }
.chip .rm:hover { color: var(--error); }
.msg .attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.msg.user .attachments { justify-content: flex-end; }
.msg .attachments .msg-img { max-width: 320px; max-height: 260px; border-radius: 10px;
  border: 1px solid var(--line); display: block; }
.filechip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  font-size: 12.5px; color: var(--fg); text-decoration: none; max-width: 100%; }
.filechip .ico { flex: none; width: 14px; height: 14px; color: var(--fg-dim); }
.filechip span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filechip:hover { border-color: var(--accent); }
#promptmodal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.55);
  display: grid; place-items: center; padding: 20px; }

/* --- prompts library (issue #12) --- */
#promptspane { flex: none; display: flex; flex-direction: column; min-height: 0;
  max-height: 34%; border-top: 1px solid var(--line); padding-top: 8px; }
.psec-head { display: flex; align-items: center; justify-content: space-between; margin: 0 8px 4px; }
.psec-head .bucket { margin: 0; }
#addprompt { padding: 0 8px; border-radius: 6px; color: var(--fg-dim); font-size: 17px;
  line-height: 1.3; }
#addprompt:hover { background: var(--card); color: var(--fg); }
#promptlist { overflow-y: auto; min-height: 0; }
.prow { position: relative; display: flex; align-items: center; }
.ptitle { display: block; flex: 1; min-width: 0; text-align: left; padding: 6px 10px;
  border-radius: 8px; color: var(--fg); font-size: 14px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.ptitle:hover { background: var(--card); }
.prow:hover .cmenu { opacity: 1; }

/* slash picker: floats above the composer while the text starts with "/" */
#composerbox { position: relative; }
#slashpop { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 25;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px;
  max-height: 240px; overflow-y: auto; display: flex; flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.slashitem { text-align: left; padding: 7px 10px; border-radius: 8px; min-width: 0; }
.slashitem.active { background: var(--card-hover); }
.slashitem .stitle { font-weight: 600; font-size: 13.5px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.slashitem .sbody { color: var(--fg-dim); font-size: 12px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.slashhint { padding: 8px 10px; color: var(--fg-dim); font-size: 12.5px; }

/* --- response closure line: model · duration · tokens · tok/s (issue #14-era polish) --- */
.meta { margin-top: 6px; font-size: 12px; color: var(--fg-dim);
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.meta + .actions { margin-top: 4px; }

/* --- tool approvals (issue #15): proposal cards for Cinta's gated tools --- */
#approvals { max-width: 768px; margin: 0 auto; padding: 0 16px 16px;
  display: flex; flex-direction: column; gap: 14px; }
.propcard { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px;
  background: var(--card); border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-left: 3px solid var(--accent); }
.prophead { display: flex; align-items: center; gap: 9px; min-width: 0; }
.proptool { flex: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 10px; border-radius: 999px; background: var(--accent);
  color: var(--accent-contrast); }
.propdesc { font-size: 13px; color: var(--fg-dim); }
.propcmd { margin: 0; max-height: 220px; overflow-y: auto; padding: 10px 12px;
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
  line-height: 1.5; white-space: pre-wrap; overflow-wrap: break-word; }
.propacts { display: flex; gap: 8px; justify-content: flex-end; }
.propacts button { padding: 7px 16px; border-radius: 10px; font-size: 13.5px;
  font-weight: 600; border: 1px solid var(--line); color: var(--fg-dim); }
.propacts button:hover { filter: brightness(1.1); color: var(--fg); }
.propacts button:disabled { opacity: .45; cursor: default; filter: none; }
.propacts button.prop-ok { background: var(--accent); color: var(--accent-contrast);
  border-color: var(--accent); }
.propacts button.prop-no:hover { color: var(--error); border-color: var(--error); filter: none; }

/* --- update banner: a deploy happened while the PWA was open --- */
#updatebar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; }
#updatebar .updatebtn { width: 100%; padding: 10px; border: none; background: var(--accent);
  color: var(--accent-contrast); font: inherit; font-weight: 600; }

/* --- update banner: a deploy happened while the PWA was open --- */
#updatebar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; }
#updatebar .updatebtn { width: 100%; padding: 10px; border: none; background: var(--accent);
  color: var(--accent-contrast); font: inherit; font-weight: 600; }
