/* Kraken — replica styles. See DESIGN.md for the design spec. */
@import url("https://fonts.googleapis.com/css?family=Lato:300");

:root {
  --bg-main: #f8f7f5;
  --bg-side: #f0efed;
  --card: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #3d3d3d;
  --ink-3: #5c5c5c;
  --muted: #8f8f8f;
  --faint: #a3a1a0;
  --line: #e4e2df;
  --bubble: #e9e8e6;
  --chip-bg: #dbe7fd;
  --chip-ink: #2b5fd9;
  --black: #141414;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-main);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; color: inherit; }

/* ---------- icons ---------- */
.ic {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}
.ic-xs { width: 13px; height: 13px; }
.ic-sm { width: 15px; height: 15px; }
.logo { width: 20px; height: 20px; color: var(--ink); flex: none; }
img.logo { display: block; border-radius: 6px; }
/* Fallback "M" badge: swapped in by JS if the logo image files fail to load,
   so AI messages never show a broken-image icon. */
.logo-fallback {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  background: #16a34a; color: #fff; font-weight: 800; font-size: 12px;
  border-radius: 5px; line-height: 1; user-select: none;
}
.provider-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 12px; margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; }
.provider-btn:hover { background: var(--bg-main); }
.provider-btn .ic { width: 18px; height: 18px; }
#loginErr { min-height: 18px; color: #c0392b; font-size: 12px; margin: 10px 0 0; }
.or-div { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; color: var(--muted); font-size: 12px; }
.or-div::before, .or-div::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.logo-lg { width: 24px; height: 24px; }
.avatar-ic { width: 18px; height: 18px; color: #8b9096; }

.icon-btn {
  background: none; border: none; cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-grid; place-items: center; color: #6f6f6f;
}
.icon-btn:hover { background: #e7e5e2; }
.icon-btn .ic { width: 17px; height: 17px; }

.btn-dark {
  background: var(--black); color: #fff; border: none; cursor: pointer;
  border-radius: 999px; padding: 7px 14px;
  font-size: 12.5px; font-weight: 550; letter-spacing: .1px;
  white-space: nowrap;
}
.btn-dark:hover { background: #2b2b2b; }
.btn-ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--line);
  cursor: pointer; border-radius: 999px; padding: 7px 14px;
  font-size: 12.5px; font-weight: 550; letter-spacing: .1px;
  white-space: nowrap;
}
.btn-ghost:hover { background: var(--hover); }

/* ---------- app frame ---------- */
.app { display: flex; height: 100dvh; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 240px; min-width: 240px;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 12px 10px 10px;
  overflow: hidden;
  position: relative;
  z-index: 60;
}
/* only the chat list scrolls — header, nav and user bar stay fixed */
#chatSections {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
#chatSections::-webkit-scrollbar { width: 5px; }
#chatSections::-webkit-scrollbar-track { background: transparent; }
#chatSections::-webkit-scrollbar-thumb {
  background: transparent; border-radius: 99px;
  transition: background .35s ease;
}
#chatSections.scrolling { scrollbar-color: rgba(128,128,128,.55) transparent; }
#chatSections.scrolling::-webkit-scrollbar-thumb { background: rgba(128,128,128,.55); }
/* collapsed sidebar becomes a slim icon rail (desktop only) */
.rail { display: none; }
@media (min-width: 900px) {
  body.side-collapsed .sidebar {
    width: 60px; min-width: 60px;
    padding: 10px 0;
    align-items: center;
    overflow: hidden;
  }
  body.side-collapsed .side-head,
  body.side-collapsed .side-nav,
  body.side-collapsed #chatSections,
  body.side-collapsed .side-user { display: none; }
  body.side-collapsed .rail {
    display: flex; flex-direction: column; align-items: center;
    gap: 4px; width: 100%; height: 100%;
  }
}
.rail-logo {
  position: relative; width: 42px; height: 42px; border-radius: 12px;
  background: none; border: 0; cursor: pointer;
  display: grid; place-items: center; margin-bottom: 8px;
}
.rail-logo:hover { background: rgba(128,128,128,.14); }
.logo-rail { width: 26px; height: 26px; }
.rail-logo .rail-open-ic { display: none; width: 22px; height: 22px; color: var(--ink-3); }
/* hovering anywhere on the collapsed rail swaps the logo for the open-panel glyph */
body.side-collapsed .sidebar:hover .rail-logo .logo-rail { display: none; }
body.side-collapsed .sidebar:hover .rail-logo .rail-open-ic { display: block; }
.rail-btn {
  width: 42px; height: 42px; border-radius: 12px;
  background: none; border: 0; cursor: pointer; color: var(--ink-3);
  display: grid; place-items: center;
}
.rail-btn:hover { background: rgba(128,128,128,.14); color: var(--ink); }
.rail-btn .ic { width: 19px; height: 19px; }
.rail-spacer { flex: 1; }
.rail-avatar {
  background: none; border: 0; cursor: pointer; padding: 0;
  border-radius: 50%; display: grid; place-items: center;
}
.rail-avatar .avatar { width: 32px; height: 32px; }
.avatar-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }

.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 4px 12px 6px;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 650; }
.side-head-actions { display: flex; align-items: center; gap: 2px; }
.drawer-share { display: none; }

.side-nav { display: flex; flex-direction: column; gap: 1px; padding-bottom: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 7px 10px;
  background: none; border: none; border-radius: 9px; cursor: pointer;
  font-size: 13px; color: var(--ink-3); text-align: left;
}
.nav-item .ic { width: 16px; height: 16px; color: #8a8a8a; }
.nav-item:hover { background: #e8e6e3; }

.side-label {
  font-size: 11.5px; font-weight: 500; color: #9a9895;
  padding: 14px 10px 4px;
}
.side-list { display: flex; flex-direction: column; gap: 1px; }
.chat-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 7px 10px;
  background: none; border: none; border-radius: 10px; cursor: pointer;
  font-size: 13px; color: var(--ink-3); text-align: left;
}
.chat-item:hover { background: #e8e6e3; }
.chat-item .chat-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item.active {
  background: var(--card); color: #333; font-weight: 500;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.dots { color: #b5b3b0; letter-spacing: 2px; font-size: 12px; flex: none; }

.side-user {
  margin-top: auto;
  display: flex; align-items: center; gap: 9px;
  padding: 12px 6px 2px;
  border-top: 1px solid #e0dedb;
  font-size: 13px; color: #444;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: #d5d3d0; display: inline-grid; place-items: center;
  overflow: hidden; flex: none;
}
.avatar-sm { width: 30px; height: 30px; }
.user-name { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verified-tick {
  width: 15px; height: 15px; flex: none;
  display: inline-block; vertical-align: -2px; margin-left: 5px;
}

/* ---------- scrim ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(0,0,0,.25);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}

/* far-left strip: park the cursor here 2s to reopen a closed sidebar */
#edgeZone {
  position: fixed; left: 0; top: 0; bottom: 0; width: 10px;
  z-index: 40; /* below scrim/sidebar, above page content */
}

/* ---------- main ---------- */
.main {
  flex: 1; min-width: 0; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg-main);
  position: relative;
}

/* mobile top bars (hidden on desktop) */
.topbar { display: none; }

.view { flex: 1; min-height: 0; }

/* ---------- home view ---------- */
.view-home {
  display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative;
}
body[data-view="chat"] .view-home { display: none; }

.getpro { position: absolute; top: 16px; right: 18px; z-index: 5; }

.hero { width: 100%; max-width: 700px; text-align: center; }
.hero h1 {
  font-size: 23px; font-weight: 550; color: #2e2e2e;
  margin-bottom: 26px; letter-spacing: -.2px;
}

/* ---------- composer ---------- */
.composer {
  background: var(--card);
  border: 1px solid #eceae7;
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.07);
  padding: 14px 14px 10px;
  text-align: left;
}
.composer-input {
  width: 100%; border: none; outline: none; background: transparent;
  font: inherit; font-size: 13.5px; color: var(--ink);
  min-height: 44px; padding: 2px 2px 0;
}
.composer-input::placeholder { color: var(--faint); }
.composer-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px;
}
.plus-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid #e3e1de; background: #fff; cursor: pointer;
  display: grid; place-items: center; color: #8a8a8a;
}
.plus-btn:hover { background: #f4f3f1; }
.plus-btn .ic { width: 14px; height: 14px; }
.composer-tools { display: flex; align-items: center; gap: 4px; }
.model {
  display: flex; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  font-size: 12.5px; font-weight: 550; color: #6f6f6f;
  padding: 6px 4px; border-radius: 7px;
  max-width: 200px;
}
.model:hover { background: #f4f3f1; }
.model-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model .ic-xs { flex: none; }

/* ---------- model picker menu ---------- */
.model-menu {
  position: fixed; z-index: 300; width: 288px;
  background: #fff; border: 1px solid #eceae7; border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .16);
  padding: 8px;
  animation: mmin .18s cubic-bezier(.2, .9, .3, 1.2) both;
}
@keyframes mmin { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.mm-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: #8a8a8a; padding: 8px 10px 4px;
}
.mm-item {
  display: flex; gap: 10px; align-items: flex-start;
  width: 100%; text-align: left; background: none; border: 0;
  border-radius: 10px; padding: 10px; cursor: pointer; font: inherit;
}
.mm-item:hover { background: #f6f5f3; }
.mm-check { width: 18px; flex: none; color: #111; font-size: 14px; margin-top: 1px; }
.mm-name { display: block; font-size: 14px; font-weight: 600; color: #111; }
.mm-sub { display: block; font-size: 12px; color: #8a8a8a; margin-top: 2px; }
.mm-foot {
  font-size: 12px; color: #8a8a8a; padding: 8px 10px 6px;
  border-top: 1px solid #f0efec; margin-top: 4px; line-height: 1.5;
}
.mm-foot b { color: #555; }

/* ---------- all-models popup ---------- */
.modal.modal-models { text-align: left; }
.modal-models .modal-h { margin-bottom: 10px; }
.mm-list { display: flex; flex-direction: column; gap: 2px; max-height: 56dvh; overflow-y: auto; }
.mm-item .mm-main { flex: 1; min-width: 0; }
.mm-more .mm-go { transform: rotate(-90deg); color: #a5a3a0; flex: none; align-self: center; }
/* Glyph Series folder: chevron points right on the folder row */
.mm-folder .mm-go { color: #a5a3a0; flex: none; align-self: center; }
/* Sub-view header: back button (not close) + section title */
.mm-back {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: 0; cursor: pointer; padding: 6px 8px 6px 0;
  font-size: 14px; color: #555; font-weight: 600;
}
.mm-back svg { transform: rotate(90deg); }
.mm-back:active { opacity: .6; }
.mm-subtitle { font-size: 13px; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: .06em; margin: 4px 0 8px; }
/* Slide animations: smooth on desktop, Apple-style spring on touch */
@keyframes mmIn { from { transform: translateX(28px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes mmBack { from { transform: translateX(-28px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.mm-slide-in { animation: mmIn .28s cubic-bezier(.32,.72,.35,1); }
.mm-slide-back { animation: mmBack .28s cubic-bezier(.32,.72,.35,1); }
@media (pointer: coarse) {
  @keyframes mmInTouch { 0% { transform: translateX(44px) scale(.98); opacity: 0; } 60% { transform: translateX(-4px) scale(1); opacity: 1; } 100% { transform: translateX(0) scale(1); opacity: 1; } }
  @keyframes mmBackTouch { 0% { transform: translateX(-44px) scale(.98); opacity: 0; } 60% { transform: translateX(4px) scale(1); opacity: 1; } 100% { transform: translateX(0) scale(1); opacity: 1; } }
  .mm-slide-in { animation: mmInTouch .38s cubic-bezier(.32,.9,.35,1.05); }
  .mm-slide-back { animation: mmBackTouch .38s cubic-bezier(.32,.9,.35,1.05); }
}

/* ---------- model loading bar ---------- */
.loadbar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 200;
  background: rgba(0, 0, 0, .06);
}
.loadbar-fill { height: 100%; width: 0; background: #111; transition: width .2s ease; }
.loadbar.indet .loadbar-fill { width: 40%; animation: loadslide 1.1s ease-in-out infinite; }
@keyframes loadslide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 400;
  transform: translateX(-50%) translateY(12px);
  background: #161616; color: #fff; font-size: 13.5px; line-height: 1.45;
  padding: 12px 16px; border-radius: 12px;
  display: flex; gap: 12px; align-items: center;
  max-width: min(92vw, 540px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
  opacity: 0; transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast b { font-weight: 650; }
.toast-btn {
  background: #fff; color: #111; border: 0; border-radius: 8px;
  padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 650;
  cursor: pointer; white-space: nowrap; flex: none;
}
.toast-btn:hover { background: #e8e8e8; }
.send-btn {
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--black); color: #fff; border: none; cursor: pointer;
  display: grid; place-items: center;
}
.send-btn:hover { background: #2b2b2b; }
.send-btn .ic { width: 15px; height: 15px; }

/* ---------- chat view ---------- */
.view-chat { display: none; flex-direction: column; }
body[data-view="chat"] .view-chat { display: flex; }

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  flex: none;
}

.messages { flex: 1; overflow-y: auto; min-height: 0; overflow-anchor: none; }
.thread { max-width: 720px; margin: 0 auto; padding: 24px 28px 12px; }

.ai-text {
  font-size: 13.5px; line-height: 1.6; color: var(--ink-2);
  margin: 10px 0; max-width: 640px;
}
.faded { opacity: .32; }

.msg-row { display: flex; justify-content: flex-end; margin: 12px 0; }
.bubble {
  background: var(--bubble); border-radius: 14px;
  padding: 10px 14px; max-width: min(480px, 82%);
  font-size: 13.5px; line-height: 1.55; color: #2c2c2c;
}
.bubble-text { display: block; margin-top: 8px; }
.bubble-text:first-child { margin-top: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--chip-bg); color: var(--chip-ink);
  border-radius: 8px; padding: 5px 10px;
  font-size: 12.5px; font-weight: 550; line-height: 1.3;
}
.chip-attach { margin-bottom: 2px; }

.meta-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted);
  margin: 14px 0 4px;
}
.meta-row .ic { color: #9a9a9a; }
.spin { animation: rot 1.4s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

.ai-h { font-size: 15px; font-weight: 700; color: #222; margin: 18px 0 8px; }
.ai-p { font-size: 13.5px; line-height: 1.65; color: var(--ink-2); margin: 0 0 6px; }
.ai-ol { margin: 8px 0 0; padding-left: 22px; font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
.ai-ol li { margin-bottom: 10px; padding-left: 2px; }
.ai-ol li::marker { font-weight: 600; color: #333; }

/* mobile-only bulleted variant (per reference) */
.ai-ul { display: none; }
.ai-h-faded { display: none; }

.composer-wrap { padding: 6px 20px 10px; flex: none; }
.composer-wrap .composer { max-width: 720px; margin: 0 auto; }
.disclaimer {
  text-align: center; font-size: 11px; color: #a8a6a3; margin-top: 8px;
}

/* ---------- responsive: mobile ---------- */
@media (max-width: 899px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 272px; min-width: 272px;
    transform: translateX(-105%);
    transition: transform .28s ease;
    box-shadow: 8px 0 30px rgba(0,0,0,.12);
    background: var(--bg-main);
  }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .scrim { opacity: 1; pointer-events: auto; }
  body.side-collapsed .sidebar { display: flex; } /* collapse only applies on desktop */

  .drawer-share { display: inline-block; }

  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 10px; flex: none;
    background: var(--bg-main);
  }
  body[data-view="home"] .topbar-chat { display: none; }
  body[data-view="chat"] .topbar-home { display: none; }
  .tb-group { display: flex; align-items: center; gap: 2px; min-width: 0; }
  .tb-title {
    font-size: 13px; font-weight: 600; color: #2b2b2b;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-left: 4px; max-width: 52vw;
  }

  .getpro { display: none; }
  .chat-header { display: none; }

  .hero h1 { font-size: 21px; margin-bottom: 22px; }
  .view-home { padding: 16px; align-items: center; }

  .thread { padding: 18px 18px 8px; }

  /* reference mobile thread: bullets instead of the numbered list */
  .ai-ol, .ai-h-desktop { display: none; }
  .ai-ul {
    display: block;
    margin: 10px 0 0; padding-left: 18px;
    font-size: 13.5px; line-height: 1.6; color: var(--ink-2);
    list-style: disc;
  }
  .ai-ul li { margin-bottom: 10px; padding-left: 2px; }
  .ai-h-faded { display: block; opacity: .32; }

  .thread > .ai-text.faded:first-child { display: none; }

  .composer-wrap { padding: 6px 12px 10px; }
}

@media (max-width: 899px) and (max-height: 700px) {
  .hero h1 { margin-bottom: 16px; }
}

/* ================= live chat + motion system ================= */

/* AI message row */
.ai-msg { display: flex; gap: 10px; margin: 16px 0; max-width: 700px; }
.ai-mark {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  color: #111; margin-top: 3px;
}
.logo-xs { width: 17px; height: 17px; }
.ai-body { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.65; color: var(--ink-2); }
.ai-body .ai-p { margin: 0 0 8px; }
.ai-body .ai-h { margin: 14px 0 6px; }
.ai-ulist { margin: 6px 0 10px; padding-left: 20px; list-style: disc; }
.ai-ulist li { margin-bottom: 6px; }
.ai-olist { margin: 8px 0 10px; padding-left: 22px; font-size: 13.5px; line-height: 1.6; }
.ai-olist li { margin-bottom: 8px; }
.ai-olist li::marker { font-weight: 600; color: #333; }
.ai-body code {
  background: #eceae8; border-radius: 6px; padding: 1px 6px;
  font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.ai-code {
  background: #1e1e1e; color: #e8e8e8; border-radius: 12px;
  padding: 12px 14px; font-size: 12.5px; overflow-x: auto;
  margin: 8px 0 12px; line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* thinking indicator */
.thinking { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--muted); font-size: 13px; }
.tdots { display: inline-flex; gap: 5px; }
.tdots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #b9b7b4; animation: tb 1.1s ease-in-out infinite;
}
.tdots span:nth-child(2) { animation-delay: .15s; }
.tdots span:nth-child(3) { animation-delay: .3s; }
@keyframes tb {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-5px); opacity: 1; }
}
.ai-mark.pulsing { animation: markpulse 1.5s ease-in-out infinite; }
@keyframes markpulse {
  0%, 100% { transform: scale(1); opacity: .65; }
  50% { transform: scale(1.18); opacity: 1; }
}

/* message entrance: fade in + rise from below */
@keyframes msg-in {
  from { opacity: 0; transform: translateY(18px) scale(.995); }
  to { opacity: 1; transform: none; }
}
.msg-anim { animation: msg-in .55s cubic-bezier(.21, .9, .25, 1) both; }

/* typewriter caret + finished swap */
.ai-body.typing::after {
  content: ""; display: inline-block;
  width: 8px; height: 15px; margin-left: 3px; vertical-align: -2px;
  background: #111; border-radius: 2px;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
/* while streaming, the fresh text fades from top to down */
.ai-body.typing {
  -webkit-mask-image: linear-gradient(to bottom, #000 70%, rgba(0,0,0,.4) 94%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 70%, rgba(0,0,0,.4) 94%, transparent 100%);
}
.swap-in { animation: swapin .35s ease both; }
@keyframes swapin { from { opacity: .15; } to { opacity: 1; } }

/* view + hero entrances */
.view-home, .view-chat { animation: viewin .35s ease both; }
@keyframes viewin { from { opacity: 0; } to { opacity: 1; } }
.hero h1 { animation: fadeup .7s cubic-bezier(.21, .9, .25, 1) both; }
.hero .composer { animation: fadeup .7s .12s cubic-bezier(.21, .9, .25, 1) both; }
@keyframes fadeup {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* micro-interactions */
.chat-item, .nav-item { transition: background .18s ease, transform .18s ease, box-shadow .18s ease; }
.chat-item:hover { transform: translateX(2px); }
.btn-dark, .send-btn, .plus-btn, .icon-btn, .model {
  transition: transform .12s ease, background .18s ease, box-shadow .2s ease;
}
.btn-dark:active, .send-btn:active, .plus-btn:active, .icon-btn:active { transform: scale(.92); }
.composer { transition: box-shadow .25s ease, border-color .25s ease; }
.composer:focus-within { border-color: #d8d6d3; box-shadow: 0 12px 34px rgba(0, 0, 0, .1); }
.composer-input { transition: opacity .2s ease; }
.composer-input:disabled { opacity: .45; }
.side-head, .chat-header, .topbar { animation: viewin .4s ease both; }

/* delete affordance on real chats */
.chat-item .del {
  display: none; width: 22px; height: 22px; flex: none;
  border: none; background: none; border-radius: 6px;
  color: #a5a3a0; font-size: 16px; line-height: 1; cursor: pointer;
}
.chat-item:hover .del, .chat-item.active .del { display: grid; place-items: center; }
.chat-item .del:hover { background: #e0dedb; color: #555; }

/* error bubble */
.bubble-err { background: #fbe9e7; color: #8a3b2e; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.retry {
  background: #141414; color: #fff; border: none; cursor: pointer;
  border-radius: 999px; padding: 5px 13px; font-size: 12px; font-weight: 550;
  transition: transform .12s ease, background .18s ease;
}
.retry:hover { background: #2b2b2b; }
.retry:active { transform: scale(.94); }

/* empty sidebar keeps its calm */
#chatSections:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  .msg-anim, .hero h1, .hero .composer, .view-home, .view-chat { animation: none; }
  .tdots span, .ai-mark.pulsing, .ai-body.typing::after { animation: none; }
  .model-menu, .loadbar.indet .loadbar-fill { animation: none; }
  * { transition-duration: .01ms !important; }
}

/* ================= v4: login, settings, search, attachments ================= */

.login-btn {
  background: var(--black); color: #fff; border: none; cursor: pointer;
  border-radius: 999px; padding: 6px 13px;
  font-size: 12px; font-weight: 600; white-space: nowrap; flex: none;
  transition: transform .12s ease, background .18s ease;
}
.login-btn:hover { background: #2b2b2b; }
.login-btn:active { transform: scale(.94); }

/* ---------- overlays & modals ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(20, 20, 20, .38);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;
  animation: viewin .22s ease both;
}
.overlay-top { align-items: flex-start; padding-top: 12vh; }
.modal {
  position: relative; width: 100%; max-width: 380px;
  background: var(--card); border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .25);
  padding: 28px 26px 22px; text-align: center;
  margin: auto;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  animation: mmin .25s cubic-bezier(.2, .9, .3, 1.15) both;
}
.modal-wide { max-width: 440px; text-align: left; }
/* one-time welcome popup (Untle Pro account) */
.welcome-modal { max-width: 400px; padding: 40px 28px 30px; }
.welcome-later {
  display: block; width: 100%; margin-top: 10px;
  background: none; border: 0; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--muted, #8a8a8a);
}
.welcome-later:active { opacity: .6; }
.welcome-handles {
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--line, #eceae7);
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.wh-title { font-size: 13px; font-weight: 650; color: var(--ink-3, #6f6f6f); }
.welcome-handles a {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 550; color: var(--ink, #1d1d1f);
  text-decoration: none; padding: 8px 14px; border-radius: 999px;
  background: var(--chip-bg, #f1efec);
  transition: transform .25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.welcome-handles a:active { transform: scale(.94); }
.welcome-title { font-size: 21px; margin: 0 0 14px; line-height: 1.35; }
.welcome-text { font-size: 15px; line-height: 1.7; color: var(--ink-soft, #6b6a68); margin: 0; }
.welcome-text code {
  font-family: inherit; font-weight: 600;
  background: rgba(127, 127, 127, .14); border-radius: 6px; padding: 1px 7px;
}
/* owner admin panel */
.admin-modal { max-width: 420px; text-align: left; padding-top: 40px; }
.admin-title { font-size: 20px; margin: 0 0 4px; }
.admin-sub { font-size: 13px; color: var(--ink-3); margin: 0 0 18px; }
.admin-field { margin-bottom: 14px; }
.admin-field label { display: block; font-size: 12px; font-weight: 650; color: var(--ink-3); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .06em; }
.admin-field input, .admin-field textarea {
  width: 100%; box-sizing: border-box;
  background: var(--bg-main); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; resize: vertical;
}
.admin-field input:focus, .admin-field textarea:focus { outline: none; border-color: var(--ink-3); }
.admin-actions { display: flex; gap: 10px; margin-top: 18px; }
.admin-actions .btn-dark { padding: 9px 20px; font-size: 13.5px; }
.admin-actions .btn-dark:disabled { opacity: .5; cursor: default; }
.admin-note { font-size: 13px; color: var(--ink-3); min-height: 20px; margin: 12px 0 0; }
/* fullscreen popups */
.modal.fullscreen, .article-modal.fullscreen {
  width: calc(100vw - 20px); height: calc(100dvh - 20px);
  max-width: none; max-height: none; border-radius: 18px;
}
.article-modal.fullscreen { overflow-y: auto; }
.modal.fullscreen .admin-grow { display: flex; flex-direction: column; flex: 1; }
.modal.fullscreen .admin-grow textarea { flex: 1; min-height: 140px; }
.x-second { right: 58px !important; }
.modal-x {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: #a5a3a0; line-height: 1;
  width: 32px; height: 32px; border-radius: 8px;
}
.modal-x:hover { background: #f1efec; color: #555; }
.modal-brand { display: grid; place-items: center; margin-bottom: 12px; }
.modal-h { font-size: 19px; font-weight: 650; color: #1d1d1f; margin-bottom: 6px; }
.modal-wide .modal-h { margin-bottom: 14px; }
.modal-sub { font-size: 13.5px; color: #6f6f6f; line-height: 1.5; margin-bottom: 18px; }
.field { display: block; text-align: left; margin-bottom: 12px; }
.field span { display: block; font-size: 12.5px; font-weight: 600; color: #444; margin-bottom: 6px; }
.field input {
  width: 100%; font: inherit; font-size: 14px;
  border: 1px solid #e0dedb; border-radius: 12px;
  padding: 11px 13px; outline: none; background: #fbfbfa;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.field input:focus { border-color: #111; box-shadow: 0 0 0 3px rgba(0,0,0,.06); background: #fff; }
.modal-cta { width: 100%; padding: 12px; font-size: 14px; margin-top: 6px; }
.modal-fine { font-size: 11.5px; color: #a5a3a0; margin-top: 14px; line-height: 1.5; }

/* ---------- settings ---------- */
.set-group { border-top: 1px solid #f0efec; padding: 14px 0 4px; }
.set-group:first-of-type { border-top: none; padding-top: 0; }
.set-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8a8a8a; font-weight: 650; margin-bottom: 10px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.set-row.col { flex-direction: column; align-items: stretch; }
.set-info { min-width: 0; }
.set-name { font-size: 14px; font-weight: 600; color: #222; }
.set-val { color: #8a8a8a; font-weight: 500; }
.set-sub { font-size: 12.5px; color: #8a8a8a; margin-top: 3px; line-height: 1.45; }
.btn-ghost {
  background: #f1efec; color: #222; border: none; cursor: pointer;
  border-radius: 999px; padding: 7px 15px; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; transition: transform .12s ease, background .18s ease;
}
.btn-ghost:hover { background: #e6e3df; }
.btn-ghost:active { transform: scale(.94); }
.btn-danger {
  background: #fdeceb; color: #b3261e; border: none; cursor: pointer;
  border-radius: 999px; padding: 7px 15px; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; transition: transform .12s ease, background .18s ease;
}
.btn-danger:hover { background: #f9dcd9; }
.btn-danger:active { transform: scale(.94); }
.slider { width: 100%; margin-top: 10px; accent-color: #141414; cursor: pointer; }

/* ---------- search ---------- */
.search-box {
  width: 100%; max-width: 520px;
  background: #fff; border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .25);
  overflow: hidden;
  animation: mmin .22s cubic-bezier(.2, .9, .3, 1.15) both;
}
.search-input-row { display: flex; align-items: center; gap: 10px; padding: 15px 17px; border-bottom: 1px solid #f0efec; color: #8a8a8a; }
.search-input-row input { flex: 1; border: none; outline: none; font: inherit; font-size: 15px; background: transparent; }
.search-results { max-height: 320px; overflow-y: auto; padding: 6px; }
.search-close {
  border: 0; background: none; font-size: 22px; line-height: 1;
  color: var(--ink-soft); cursor: pointer; padding: 2px 8px; border-radius: 8px;
}
.search-close:hover { background: var(--ink-faint); color: var(--ink); }
.search-hit {
  display: block; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer; border-radius: 12px;
  padding: 10px 12px; font: inherit;
}
.search-hit:hover { background: #f6f5f3; }
.search-hit .sh-title { font-size: 13.5px; font-weight: 600; color: #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-hit .sh-snip { font-size: 12.5px; color: #8a8a8a; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: 22px; text-align: center; font-size: 13px; color: #a5a3a0; }

/* ---------- attach menu ---------- */
.attach-menu {
  position: fixed; z-index: 300; width: 220px;
  background: #fff; border: 1px solid #eceae7; border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .16);
  padding: 6px;
  animation: mmin .18s cubic-bezier(.2, .9, .3, 1.2) both;
}
.am-item {
  display: flex; gap: 10px; align-items: center;
  width: 100%; text-align: left; background: none; border: 0;
  border-radius: 10px; padding: 10px 12px; cursor: pointer;
  font: inherit; font-size: 13.5px; color: #333;
}
.am-item:hover { background: #f6f5f3; }
.am-item .ic { width: 16px; height: 16px; color: #8a8a8a; }

/* ---------- attachment trays & chips ---------- */
.attach-tray {
  display: flex; flex-wrap: nowrap; gap: 8px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
  max-width: 100%;
}
.attach-tray::-webkit-scrollbar { display: none; }
.attach-tray:empty { display: none; }
.attach-tray:not(:empty) { margin-bottom: 10px; }
.att-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: #f1efec; border: 1px solid #e4e2df; border-radius: 12px;
  padding: 6px 8px 6px 6px; font-size: 12px; color: #444;
  max-width: 220px; flex: none;
  animation: mmin .18s ease both;
}
.att-chip.att-more {
  justify-content: center; min-width: 48px;
  font-size: 18px; font-weight: 700; letter-spacing: 2px; color: #8a8a8a;
  cursor: default;
}
.att-chip img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex: none; }
.att-chip .att-ic {
  width: 34px; height: 34px; border-radius: 8px; flex: none;
  background: #dbe7fd; color: #2b5fd9; display: grid; place-items: center;
}
.att-chip .att-ic .ic { width: 16px; height: 16px; }
.att-chip .att-meta { min-width: 0; line-height: 1.3; }
.att-chip .att-name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.att-chip .att-size { color: #8a8a8a; font-size: 11px; }
.att-x {
  background: none; border: none; cursor: pointer; color: #a5a3a0;
  font-size: 15px; line-height: 1; padding: 2px; border-radius: 6px; flex: none;
}
.att-x:hover { color: #555; background: #e4e2df; }

/* attachments inside a sent message bubble */
.msg-atts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.msg-atts:empty { display: none; }
.msg-att-img {
  width: 120px; height: 90px; object-fit: cover; border-radius: 10px;
  cursor: zoom-in; border: 1px solid rgba(0,0,0,.06);
}
.msg-att-file {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.65); border: 1px solid rgba(0,0,0,.06);
  border-radius: 10px; padding: 7px 11px 7px 8px;
  font-size: 12px; font-weight: 600; color: #444; max-width: 220px;
}
.msg-att-file .att-ic { width: 26px; height: 26px; border-radius: 7px; }
.msg-att-file .att-ic .ic { width: 13px; height: 13px; }
.msg-att-file span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (prefers-reduced-motion: reduce) {
  .overlay, .modal, .search-box, .attach-menu, .att-chip { animation: none; }
}

/* ---------- MNAI Pro ---------- */
.plan-tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 18px; }
.plan-tab {
  border: 1px solid var(--line, #e5e5e5); background: transparent; color: inherit;
  border-radius: 999px; padding: 7px 22px; font: inherit; font-size: 13.5px; font-weight: 650;
  cursor: pointer;
}
.plan-tab.active { background: #111; color: #fff; border-color: #111; }
.pro-hero { text-align: center; margin-bottom: 6px; }
.pro-crown { color: #d4a017; }
.pro-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 50%;
  background: #e9f9ef; color: #16a34a; font-size: 30px; font-weight: 700;
}
.pro-price { text-align: center; margin: 4px 0 16px; }
.pro-amount { font-size: 40px; font-weight: 750; letter-spacing: -.02em; color: #111; }
.pro-once {
  display: inline-block; font-size: 12px; color: #8a8a8a; font-weight: 600;
  border: 1px solid #e4e2df; border-radius: 999px; padding: 3px 10px;
  margin-left: 8px; vertical-align: middle;
}
.pro-feats { list-style: none; margin: 0 0 8px; padding: 0; text-align: left; }
.pro-feats li {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13.5px; color: #3d3d3d; padding: 7px 2px;
  border-top: 1px solid #f3f1ee;
}
.pro-feats li:first-child { border-top: none; }
.pro-tick {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  background: #e9f9ef; color: #16a34a;
  font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.pro-badge {
  display: inline-block; font-size: 10px; font-weight: 750; letter-spacing: .06em;
  color: #8a5a00; background: #fdf0d3; border: 1px solid #f3d98b;
  border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px;
}
.max-badge {
  display: inline-block; font-size: 10px; font-weight: 750; letter-spacing: .06em;
  color: #fff; background: linear-gradient(135deg, #7c3aed, #4f46e5); border: 1px solid #7c3aed;
  border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px;
}
.mm-lock { flex: none; color: #b6b2ac; margin-top: 3px; }
.mm-item.locked { opacity: .75; }
.getpro.is-pro {
  background: #fdf0d3; color: #8a5a00;
  border: 1px solid #f3d98b;
}

/* ---------------- message actions ----------------
   Mobile: hold a message 1s and a bottom sheet slides up (#msgSheetWrap). */
.msg-act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  color: #c9cdd4;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 550;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, transform .1s ease;
}
.msg-act:hover {
  background: rgba(255, 255, 255, .09);
  color: #fff;
}
.msg-act:active {
  transform: scale(.95);
}
.msg-act.danger:hover {
  background: rgba(239, 68, 68, .16);
  color: #ff9d9d;
}
.msg-act .ic-xs {
  width: 14px;
  height: 14px;
}

/* mobile bottom sheet (1s long-press): slides up + fades in */
#msgSheetWrap {
  position: fixed;
  inset: 0;
  z-index: 95;
}
#msgSheetBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  opacity: 0;
  transition: opacity .25s ease;
}
#msgSheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #17181d;
  border-top: 1px solid rgba(255, 255, 255, .09);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 44px rgba(0, 0, 0, .5);
  padding: 6px 10px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  opacity: 0;
  transition: transform .34s cubic-bezier(.2, .9, .3, 1), opacity .25s ease;
}
#msgSheetWrap.show #msgSheetBackdrop { opacity: 1; }
#msgSheetWrap.show #msgSheet { transform: none; opacity: 1; }
.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .22);
  margin: 8px auto 10px;
}
.sheet-opt {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  background: transparent;
  border: 0;
  border-radius: 14px;
  color: #eceef1;
  font-family: inherit;
  font-size: 15px;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease;
}
.sheet-opt:active { background: rgba(255, 255, 255, .07); }
.sheet-opt .ic { width: 20px; height: 20px; color: #aeb4bc; flex: none; }
.sheet-opt.danger { color: #ff8f8f; }
.sheet-opt.danger .ic { color: #ff8f8f; }
.sheet-opt.sheet-cancel {
  margin-top: 6px;
  background: rgba(255, 255, 255, .06);
  justify-content: center;
  color: #c9cdd4;
}

/* keep the iOS/Android callout from fighting the long-press sheet */
.msg-row, .ai-msg {
  -webkit-touch-callout: none;
}
.ic-xs {
  width: 14px;
  height: 14px;
}
.web-badge {
  font-size: 10px;
  font-weight: 600;
  color: #7dd3a8;
  background: rgba(125, 211, 168, .12);
  border: 1px solid rgba(125, 211, 168, .25);
  padding: 2px 7px;
  border-radius: 20px;
  margin-right: 4px;
}

/* copy button on code blocks */
pre.ai-code {
  position: relative;
}
.code-copy {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #c7c7cc;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.code-copy:hover {
  background: rgba(255, 255, 255, .16);
  color: #fff;
}
.code-copy .ic-xs {
  width: 12px;
  height: 12px;
}

/* inline edit composer */
.edit-ta {
  width: 100%;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px;
  color: #fff;
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
}
.edit-ta:focus {
  border-color: #4caf7d;
}
.edit-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.edit-save,
.edit-cancel {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  border: 0;
}
.edit-save {
  background: #4caf7d;
  color: #04120a;
}
.edit-save:hover {
  background: #5cbf8d;
}
.edit-cancel {
  background: rgba(255, 255, 255, .08);
  color: #e8e8ea;
}
.edit-cancel:hover {
  background: rgba(255, 255, 255, .14);
}

/* ---------- slash command menu ---------- */
.slash-menu {
  position: fixed; z-index: 800;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px; min-width: 240px; max-width: 90vw;
  box-shadow: 0 12px 32px rgba(0,0,0,.25);
  display: flex; flex-direction: column; gap: 2px;
}
.slash-menu[hidden] { display: none; }
.slash-item {
  display: flex; align-items: baseline; gap: 10px;
  background: none; border: 0; border-radius: 8px;
  padding: 8px 10px; cursor: pointer; text-align: left;
  color: inherit; font: inherit;
}
.slash-item:hover { background: rgba(128,128,128,.15); }
.slash-cmd { font-weight: 600; font-family: ui-monospace, monospace; font-size: 13px; }
.slash-desc { font-size: 12px; opacity: .65; }

/* ---------- MCP servers (Plugins) ---------- */
.mcp-card { flex-direction: column; align-items: stretch; gap: 10px; }
.mcp-head { display: flex; align-items: center; gap: 10px; }
.mcp-list { display: flex; flex-direction: column; gap: 8px; }
.mcp-empty { font-size: 13px; opacity: .6; margin: 0; }
.mcp-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line, #2c2c2e); border-radius: 10px;
}
.mcp-dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: #8e8e93; transition: background .25s;
}
.mcp-dot.ok { background: #34c759; box-shadow: 0 0 8px rgba(52,199,89,.8); }
.mcp-dot.bad { background: #ff3b30; box-shadow: 0 0 8px rgba(255,59,48,.8); }
.mcp-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mcp-name { font-weight: 600; font-size: 13px; }
.mcp-cmd { font-family: ui-monospace, monospace; font-size: 12px; opacity: .75; }
.mcp-url { font-size: 11px; opacity: .5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcp-test, .mcp-del { font-size: 12px; padding: 6px 10px; flex: none; }
.mcp-form { display: flex; gap: 8px; flex-wrap: wrap; }
.mcp-input {
  flex: 1 1 140px; min-width: 0;
  background: transparent; border: 1px solid var(--line, #2c2c2e);
  border-radius: 8px; padding: 8px 10px; color: inherit; font: inherit; font-size: 13px;
}

/* AI-generated images */
.voice-card { display: flex; flex-direction: column; gap: 10px; max-width: 480px; }
.voice-player { width: 100%; height: 40px; }
.voice-dl { align-self: flex-start; text-decoration: none; font-size: 13px; padding: 8px 14px; }
.voice-text { margin: 0; font-size: 13px; opacity: .75; }
.gen-img-wrap {
  position: relative;
  max-width: 480px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .1);
  background: #141416;
}
.gen-vid-wrap {
  position: relative;
  max-width: 480px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .1);
  background: #141416;
}
.gen-vid {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
}
.gen-img {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
}
.gen-img-cap {
  font-size: 12px;
  color: #aeaeb2;
  padding: 8px 10px;
}
.img-loading {
  min-height: 200px;
}
.img-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, .06) 50%, transparent 80%);
  animation: imgshimmer 1.2s infinite;
  pointer-events: none;
}
@keyframes imgshimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
.img-error .gen-img {
  display: none;
}
.img-error::before {
  content: "Image failed to load";
  display: block;
  padding: 32px;
  text-align: center;
  color: #8e8e93;
  font-size: 13px;
}

/* actions row wraps below the message (both are flex rows) */
.msg-row {
  flex-wrap: wrap;
}
.msg-row .msg-actions {
  flex: 0 0 100%;
}
.ai-msg {
  flex-wrap: wrap;
}
.ai-msg > .msg-actions {
  flex: 0 0 100%;
  margin-left: 36px;
  margin-top: 2px;
}

/* ---------- AI reply action row: compact, identical on every device ---------- */
.ai-msg > .ai-actions {
  flex: 0 0 100%;
  margin: 5px 0 10px 34px;
}
.ai-actions { display: flex; align-items: center; gap: 2px; }
.ai-act {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: none; border: 0; color: #a3a3a3; cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
}
.ai-act:hover { background: rgba(128,128,128,.15); color: inherit; }
.ai-act:active { transform: scale(.85); }
.ai-act .ic-sm { width: 16px; height: 16px; }
.ai-act.on { color: #2f7cf6; }
.ai-act.speaking { color: #2f7cf6; animation: speak-pulse 1.6s ease-in-out infinite; }
@keyframes speak-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
html[data-theme="light"] .ai-act { color: #8f8f8f; }
html[data-theme="light"] .ai-act.on, html[data-theme="light"] .ai-act.speaking { color: #2f7cf6; }
.ai-actions .web-badge { margin-left: 6px; }

/* ---------- AI "more" popup menu ---------- */
#aiMenu {
  position: fixed; z-index: 200; min-width: 208px;
  background: var(--card, #fff);
  border: 1px solid var(--line);
  border-radius: 14px; padding: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
#aiMenu[hidden] { display: none; }
.ai-menu-opt {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; background: none; border: 0; border-radius: 9px;
  font-size: 13.5px; color: var(--ink); cursor: pointer; text-align: left;
}
.ai-menu-opt:hover { background: rgba(128,128,128,.14); }
.ai-menu-opt .ic-sm { color: var(--ink-3); flex: none; }
.ai-menu-opt.danger { color: #e5484d; }
.ai-menu-opt.danger .ic-sm { color: #e5484d; }

/* ================= dark theme ================= */
[data-theme="dark"], [data-theme="amoled"] {
  --bg-main: #0f1013;
  --bg-side: #16171c;
  --card: #1b1c22;
  --ink: #f0f0f2;
  --ink-2: #c8c8ce;
  --ink-3: #a6a6ae;
  --muted: #8e8e96;
  --faint: #5f5f67;
  --line: #2a2b32;
  --bubble: #26272f;
  --chip-bg: #22304d;
  --chip-ink: #8db4ff;
  --black: #ececee;
  color-scheme: dark;
}

[data-theme="dark"] .icon-btn , [data-theme="amoled"] .icon-btn { color: #9a9aa2; }
[data-theme="dark"] .icon-btn:hover , [data-theme="amoled"] .icon-btn:hover { background: #26272e; }

[data-theme="dark"] .btn-dark, [data-theme="amoled"] .btn-dark,
[data-theme="dark"] .send-btn, [data-theme="amoled"] .send-btn,
[data-theme="dark"] .login-btn , [data-theme="amoled"] .login-btn { color: #141416; }
[data-theme="dark"] .btn-dark:hover, [data-theme="amoled"] .btn-dark:hover,
[data-theme="dark"] .send-btn:hover, [data-theme="amoled"] .send-btn:hover,
[data-theme="dark"] .login-btn:hover , [data-theme="amoled"] .login-btn:hover { background: #d5d5da; }

[data-theme="dark"] .nav-item .ic , [data-theme="amoled"] .nav-item .ic { color: #8e8e96; }
[data-theme="dark"] .nav-item:hover, [data-theme="amoled"] .nav-item:hover,
[data-theme="dark"] .chat-item:hover , [data-theme="amoled"] .chat-item:hover { background: #23242b; }
[data-theme="dark"] .chat-item.active , [data-theme="amoled"] .chat-item.active { color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.35); }
[data-theme="dark"] .chat-item .del , [data-theme="amoled"] .chat-item .del { color: #8e8e96; }
[data-theme="dark"] .chat-item .del:hover , [data-theme="amoled"] .chat-item .del:hover { background: #2e2f37; color: #d5d5da; }
[data-theme="dark"] .dots , [data-theme="amoled"] .dots { color: #5f5f67; }
[data-theme="dark"] .side-label , [data-theme="amoled"] .side-label { color: #8e8e96; }
[data-theme="dark"] .side-user , [data-theme="amoled"] .side-user { border-top-color: var(--line); color: var(--ink-3); }
[data-theme="dark"] .avatar , [data-theme="amoled"] .avatar { background: #2e2f37; }

[data-theme="dark"] .hero h1 , [data-theme="amoled"] .hero h1 { color: var(--ink); }
[data-theme="dark"] .tb-title , [data-theme="amoled"] .tb-title { color: var(--ink-2); }

[data-theme="dark"] .composer , [data-theme="amoled"] .composer { border-color: #2e2f37; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
[data-theme="dark"] .composer:focus-within , [data-theme="amoled"] .composer:focus-within { border-color: #3a3b44; box-shadow: 0 12px 34px rgba(0,0,0,.45); }
[data-theme="dark"] .plus-btn , [data-theme="amoled"] .plus-btn { border-color: #2e2f37; background: #23242b; color: #9a9aa2; }
[data-theme="dark"] .plus-btn:hover , [data-theme="amoled"] .plus-btn:hover { background: #2b2c34; }
[data-theme="dark"] .model , [data-theme="amoled"] .model { color: #9a9aa2; }
[data-theme="dark"] .model:hover , [data-theme="amoled"] .model:hover { background: #23242b; }

[data-theme="dark"] .model-menu , [data-theme="amoled"] .model-menu { background: #1e1f26; border-color: #2e2f37; box-shadow: 0 18px 50px rgba(0,0,0,.5); }
[data-theme="dark"] .mm-title, [data-theme="amoled"] .mm-title,
[data-theme="dark"] .mm-sub, [data-theme="amoled"] .mm-sub,
[data-theme="dark"] .mm-foot , [data-theme="amoled"] .mm-foot { color: #8e8e96; }
[data-theme="dark"] .mm-item:hover , [data-theme="amoled"] .mm-item:hover { background: #26272e; }
[data-theme="dark"] .mm-check, [data-theme="amoled"] .mm-check,
[data-theme="dark"] .mm-name , [data-theme="amoled"] .mm-name { color: var(--ink); }
[data-theme="dark"] .mm-foot , [data-theme="amoled"] .mm-foot { border-top-color: #2e2f37; }
[data-theme="dark"] .mm-foot b , [data-theme="amoled"] .mm-foot b { color: var(--ink-2); }

[data-theme="dark"] .loadbar , [data-theme="amoled"] .loadbar { background: rgba(255,255,255,.07); }
[data-theme="dark"] .loadbar-fill , [data-theme="amoled"] .loadbar-fill { background: var(--ink); }

[data-theme="dark"] .bubble , [data-theme="amoled"] .bubble { color: var(--ink-2); }
[data-theme="dark"] .ai-h , [data-theme="amoled"] .ai-h { color: var(--ink); }
[data-theme="dark"] .ai-ol li::marker, [data-theme="amoled"] .ai-ol li::marker,
[data-theme="dark"] .ai-olist li::marker , [data-theme="amoled"] .ai-olist li::marker { color: var(--ink-3); }
[data-theme="dark"] .ai-body code , [data-theme="amoled"] .ai-body code { background: #2a2b33; }
[data-theme="dark"] .disclaimer , [data-theme="amoled"] .disclaimer { color: #6d6d75; }
[data-theme="dark"] .meta-row .ic , [data-theme="amoled"] .meta-row .ic { color: #6d6d75; }
[data-theme="dark"] .tdots span , [data-theme="amoled"] .tdots span { background: #6d6d75; }
[data-theme="dark"] .ai-mark , [data-theme="amoled"] .ai-mark { color: var(--ink); }
[data-theme="dark"] .ai-body.typing::after , [data-theme="amoled"] .ai-body.typing::after { background: var(--ink); }

[data-theme="dark"] .retry , [data-theme="amoled"] .retry { background: var(--black); color: #141416; }
[data-theme="dark"] .retry:hover , [data-theme="amoled"] .retry:hover { background: #d5d5da; }

/* modals */
[data-theme="dark"] .modal , [data-theme="amoled"] .modal { box-shadow: 0 30px 80px rgba(0,0,0,.55); }
[data-theme="dark"] .modal-h , [data-theme="amoled"] .modal-h { color: var(--ink); }
[data-theme="dark"] .modal-sub , [data-theme="amoled"] .modal-sub { color: var(--ink-3); }
[data-theme="dark"] .modal-x , [data-theme="amoled"] .modal-x { color: #8e8e96; }
[data-theme="dark"] .modal-x:hover , [data-theme="amoled"] .modal-x:hover { background: #26272e; color: var(--ink-2); }
[data-theme="dark"] .modal-fine , [data-theme="amoled"] .modal-fine { color: #6d6d75; }
[data-theme="dark"] .field span , [data-theme="amoled"] .field span { color: var(--ink-2); }
[data-theme="dark"] .field input , [data-theme="amoled"] .field input { border-color: #2e2f37; background: #14151a; color: var(--ink); }
[data-theme="dark"] .field input:focus , [data-theme="amoled"] .field input:focus { border-color: #4a4b55; box-shadow: 0 0 0 3px rgba(255,255,255,.06); background: #1e1f26; }
[data-theme="dark"] .provider-btn:hover , [data-theme="amoled"] .provider-btn:hover { background: #23242b; }
[data-theme="dark"] .or-div::before, [data-theme="amoled"] .or-div::before,
[data-theme="dark"] .or-div::after , [data-theme="amoled"] .or-div::after { border-top-color: var(--line); }

/* settings */
[data-theme="dark"] .set-group , [data-theme="amoled"] .set-group { border-top-color: #26272e; }
[data-theme="dark"] .set-title , [data-theme="amoled"] .set-title { color: #8e8e96; }
[data-theme="dark"] .set-name , [data-theme="amoled"] .set-name { color: var(--ink); }
[data-theme="dark"] .set-val, [data-theme="amoled"] .set-val,
[data-theme="dark"] .set-sub , [data-theme="amoled"] .set-sub { color: #8e8e96; }
[data-theme="dark"] .btn-ghost , [data-theme="amoled"] .btn-ghost { background: #26272e; color: var(--ink); }
[data-theme="dark"] .btn-ghost:hover , [data-theme="amoled"] .btn-ghost:hover { background: #2e2f37; }
[data-theme="dark"] .btn-danger , [data-theme="amoled"] .btn-danger { background: #3a2320; color: #ff9d9d; }
[data-theme="dark"] .btn-danger:hover , [data-theme="amoled"] .btn-danger:hover { background: #462a26; }
[data-theme="dark"] .slider , [data-theme="amoled"] .slider { accent-color: var(--black); }

/* search */
[data-theme="dark"] .search-box , [data-theme="amoled"] .search-box { background: #1e1f26; box-shadow: 0 30px 80px rgba(0,0,0,.55); }
[data-theme="dark"] .search-input-row , [data-theme="amoled"] .search-input-row { border-bottom-color: #2e2f37; color: #8e8e96; }
[data-theme="dark"] .search-input-row input , [data-theme="amoled"] .search-input-row input { color: var(--ink); }
[data-theme="dark"] .search-hit:hover , [data-theme="amoled"] .search-hit:hover { background: #26272e; }
[data-theme="dark"] .search-hit .sh-title , [data-theme="amoled"] .search-hit .sh-title { color: var(--ink); }
[data-theme="dark"] .search-hit .sh-snip , [data-theme="amoled"] .search-hit .sh-snip { color: #8e8e96; }
[data-theme="dark"] .search-empty , [data-theme="amoled"] .search-empty { color: #6d6d75; }
[data-theme="dark"] .search-close , [data-theme="amoled"] .search-close { color: #8e8e96; }
[data-theme="dark"] .search-close:hover , [data-theme="amoled"] .search-close:hover { background: #26272e; color: var(--ink); }

/* attach menu + chips */
[data-theme="dark"] .attach-menu , [data-theme="amoled"] .attach-menu { background: #1e1f26; border-color: #2e2f37; box-shadow: 0 18px 50px rgba(0,0,0,.5); }
[data-theme="dark"] .am-item , [data-theme="amoled"] .am-item { color: var(--ink-2); }
[data-theme="dark"] .am-item:hover , [data-theme="amoled"] .am-item:hover { background: #26272e; }
[data-theme="dark"] .am-item .ic , [data-theme="amoled"] .am-item .ic { color: #8e8e96; }
[data-theme="dark"] .att-chip , [data-theme="amoled"] .att-chip { background: #26272e; border-color: #2e2f37; color: var(--ink-2); }
[data-theme="dark"] .att-chip .att-size , [data-theme="amoled"] .att-chip .att-size { color: #8e8e96; }
[data-theme="dark"] .att-x , [data-theme="amoled"] .att-x { color: #8e8e96; }
[data-theme="dark"] .att-x:hover , [data-theme="amoled"] .att-x:hover { color: var(--ink-2); background: #2e2f37; }
[data-theme="dark"] .msg-att-file , [data-theme="amoled"] .msg-att-file { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.08); color: var(--ink-2); }

/* pro */
[data-theme="dark"] .pro-amount , [data-theme="amoled"] .pro-amount { color: var(--ink); }
[data-theme="dark"] .pro-once , [data-theme="amoled"] .pro-once { color: #8e8e96; border-color: #2e2f37; }
[data-theme="dark"] .pro-feats li , [data-theme="amoled"] .pro-feats li { color: var(--ink-2); border-top-color: #26272e; }

/* ---------- normal toggle switch (theme) ---------- */
.switch { position: relative; display: inline-block; width: 46px; height: 27px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: #d8d6d3; transition: background .2s ease;
  pointer-events: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform .2s ease;
}
.switch input:checked + .track { background: #16a34a; }
.switch input:checked + .track::after { transform: translateX(19px); }
.switch input:focus-visible + .track { outline: 2px solid var(--chip-ink); outline-offset: 2px; }
[data-theme="dark"] .switch .track , [data-theme="amoled"] .switch .track { background: #3a3b44; }
[data-theme="dark"] .switch input:checked + .track , [data-theme="amoled"] .switch input:checked + .track { background: #16a34a; }

@media (max-width: 480px) {
  .overlay { padding: 12px; }
  .modal { padding: 22px 18px 18px; max-height: calc(100dvh - 24px); }
}

/* ---------- library / projects / plugins views ---------- */
.view-library, .view-projects, .view-plugins { display: none; flex-direction: column; }
body[data-view="library"] .view-library,
body[data-view="projects"] .view-projects,
body[data-view="plugins"] .view-plugins { display: flex; }
body[data-view="library"] .view-home,
body[data-view="projects"] .view-home,
body[data-view="plugins"] .view-home { display: none; }
.nav-item.active { background: #e8e6e3; font-weight: 600; }

.page { flex: 1; min-height: 0; overflow-y: auto; width: 100%; max-width: 880px; margin: 0 auto; padding: 30px 24px 70px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h2 { font-size: 22px; font-weight: 650; letter-spacing: -.3px; color: var(--ink); }
.page-sub { color: #8a8a8a; font-size: 13px; margin-top: 4px; }

.empty { text-align: center; padding: 64px 20px; color: var(--ink); font-size: 15px; font-weight: 550; }
.empty-sub { color: #8a8a8a; font-size: 13px; font-weight: 400; margin-top: 8px; }
.empty-sub b { color: var(--ink); }

/* library image grid */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.img-card { border-radius: 12px; overflow: hidden; border: 1px solid #eceae7; background: var(--card); cursor: pointer; padding: 0; text-align: left; font: inherit; }
.img-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #f4f2ef; }
.img-cap { padding: 8px 10px; font-size: 12px; color: var(--ink); overflow-wrap: anywhere; }

/* ---- /imagine generating loader: dot-matrix with roaming glow nodes ---- */
.img-gen-loader {
  position: relative;
  width: 100%; max-width: 480px; aspect-ratio: 1 / 1;
  background: #212121; border-radius: 16px; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.igl-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.igl-shine {
  background: linear-gradient(90deg, #8e8e8e 0%, #ffffff 50%, #8e8e8e 100%);
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: igl-shine 3s linear infinite;
}
@keyframes igl-shine {
  0% { background-position: 200% center; }
  100% { background-position: -200% center; }
}
.igl-status {
  position: absolute; top: 24px; left: 24px; z-index: 2; pointer-events: none;
  font-size: 14px; font-weight: 400; letter-spacing: -0.01em;
}
.igl-pct {
  position: absolute; bottom: 24px; right: 24px; z-index: 2; pointer-events: none;
  font-size: 12px; font-weight: 500; padding: 5px 12px; border-radius: 20px;
  border: 1px solid rgba(255,255,255,.08);
}
/* watermark fallback: shown when the canvas bake is blocked (CDN w/o CORS) —
   screen blend drops the logo's black background, leaving the white M */
.gen-wm {
  position: absolute; right: 12px; bottom: 12px; width: 8%; height: auto;
  opacity: .45; mix-blend-mode: screen; pointer-events: none;
}
/* in-site image viewer: watermark positioning context */
.img-full-wrap { position: relative; display: block; }
.img-full-wrap img#imgFull { display: block; width: 100%; height: auto; }
.img-full-wrap .gen-wm { width: 6%; right: 14px; bottom: 14px; }

/* lightbox */
.img-modal { max-width: 720px; }
.img-modal img { width: 100%; border-radius: 12px; display: block; max-height: 62vh; object-fit: contain; background: #111; }
.img-prompt { font-size: 13px; color: #6b6b6b; margin: 12px 2px; }
.img-actions { display: flex; gap: 8px; }
.img-actions .btn-dark { text-decoration: none; display: inline-grid; place-items: center; padding: 9px 18px; }

/* projects */
.inline-form { border: 1px solid #eceae7; border-radius: 14px; padding: 14px; background: var(--card); margin-bottom: 14px; }
.inline-form input { width: 100%; border: 1px solid #e2e0dc; border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 13.5px; margin-bottom: 10px; background: #fff; color: var(--ink); outline: none; }
.inline-form-row { display: flex; gap: 8px; }
.proj-card { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border: 1px solid #eceae7; border-radius: 14px; background: var(--card); margin-bottom: 10px; cursor: pointer; font: inherit; text-align: left; }
.proj-card:hover { border-color: #d6d3ce; }
.proj-ic { width: 38px; height: 38px; border-radius: 10px; background: #f4f2ef; display: grid; place-items: center; flex: none; }
.proj-ic .ic { width: 18px; height: 18px; color: #6b6b6b; }
.proj-info { flex: 1; min-width: 0; }
.proj-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.proj-meta { font-size: 12px; color: #8a8a8a; margin-top: 2px; }
.proj-open { font-size: 12.5px; color: #8a8a8a; flex: none; }
.row-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 1px solid #eceae7; border-radius: 12px; background: var(--card); margin-bottom: 8px; }
.row-item .row-title { flex: 1; min-width: 0; font-size: 13.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .row-sub { font-size: 12px; color: #8a8a8a; flex: none; }
.back-link { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; cursor: pointer; color: #8a8a8a; font: inherit; font-size: 13px; margin-bottom: 12px; padding: 0; }
.back-link:hover { color: var(--ink); }
.detail-actions { display: flex; gap: 8px; margin: 16px 0 8px; flex-wrap: wrap; }
.mini-btn { border: 1px solid #e2e0dc; background: #fff; border-radius: 9px; padding: 6px 12px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--ink); }
.mini-btn:hover { background: #f6f4f1; }
.mini-btn.danger { color: #c0362c; border-color: #f0d5d2; }
.mini-btn.danger:hover { background: #fdf0ef; }

/* plugins */
.plugin-card { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid #eceae7; border-radius: 14px; background: var(--card); margin-bottom: 10px; }
.plugin-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: #f4f2ef; flex: none; }
.plugin-ic .ic { width: 20px; height: 20px; color: #4b4b4b; }
.plugin-info { flex: 1; min-width: 0; }
.plugin-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.plugin-desc { font-size: 12.5px; color: #8a8a8a; margin-top: 3px; line-height: 1.45; }

[data-theme="dark"] .nav-item.active , [data-theme="amoled"] .nav-item.active { background: #2b2c33; }
[data-theme="dark"] .img-card, [data-theme="amoled"] .img-card, [data-theme="dark"] .proj-card, [data-theme="amoled"] .proj-card,
[data-theme="dark"] .plugin-card, [data-theme="amoled"] .plugin-card, [data-theme="dark"] .row-item, [data-theme="amoled"] .row-item,
[data-theme="dark"] .inline-form , [data-theme="amoled"] .inline-form { border-color: #2e2f37; }
[data-theme="dark"] .proj-card:hover , [data-theme="amoled"] .proj-card:hover { border-color: #3d3e47; }
[data-theme="dark"] .proj-ic, [data-theme="amoled"] .proj-ic, [data-theme="dark"] .plugin-ic , [data-theme="amoled"] .plugin-ic { background: #2b2c33; }
[data-theme="dark"] .inline-form input , [data-theme="amoled"] .inline-form input { background: #1d1e24; border-color: #2e2f37; }
[data-theme="dark"] .mini-btn , [data-theme="amoled"] .mini-btn { background: #232429; border-color: #2e2f37; }
[data-theme="dark"] .mini-btn:hover , [data-theme="amoled"] .mini-btn:hover { background: #2b2c33; }
[data-theme="dark"] .img-prompt, [data-theme="amoled"] .img-prompt, [data-theme="dark"] .proj-meta, [data-theme="amoled"] .proj-meta,
[data-theme="dark"] .row-item .row-sub, [data-theme="amoled"] .row-item .row-sub, [data-theme="dark"] .page-sub, [data-theme="amoled"] .page-sub,
[data-theme="dark"] .plugin-desc , [data-theme="amoled"] .plugin-desc { color: #9a9aa3; }
@media (max-width: 900px) {
  body[data-view="library"] .topbar-home, body[data-view="library"] .topbar-chat,
  body[data-view="projects"] .topbar-home, body[data-view="projects"] .topbar-chat,
  body[data-view="plugins"] .topbar-home, body[data-view="plugins"] .topbar-chat { display: none; }
  .page { padding: 20px 16px 70px; }
}
.plugin-name, .plugin-desc, .proj-name, .proj-meta { display: block; }

/* ---- global broadcast: article card popup ---- */
.article-modal { max-width: 880px; width: calc(100vw - 32px); padding: 14px; overflow: hidden; text-align: left; position: relative; background: #fff; color: #16213a; border-radius: 20px; }
/* Kimi-style broadcast card: media on top, dark card below */
.bc-modal { max-width: 520px; width: calc(100vw - 32px); padding: 0; overflow: hidden; position: relative; background: #111; color: #fff; border-radius: 20px; border: 1px solid rgba(255,255,255,.08); }
.bc-x { position: absolute; top: 12px; right: 12px; z-index: 3; width: 32px; height: 32px; border: none; background: rgba(0,0,0,.45); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; border-radius: 50%; backdrop-filter: blur(8px); }
.bc-x:hover { background: rgba(0,0,0,.65); }
.bc-media { position: relative; width: 100%; aspect-ratio: 16/9; overflow: hidden; background: #0a0a0a; }
.bc-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bc-media.bc-gradient img { display: none; }
.bc-card { padding: 22px 24px 20px; }
.bc-title { margin: 0 0 10px; font-size: 21px; line-height: 1.3; font-weight: 800; letter-spacing: -0.01em; }
.bc-desc { margin: 0 0 20px; font-size: 14.5px; line-height: 1.6; color: rgba(255,255,255,.72); }
.bc-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.bc-later { background: none; border: 0; color: rgba(255,255,255,.55); font-size: 14px; font-weight: 600; cursor: pointer; padding: 10px 14px; border-radius: 999px; }
.bc-later:hover { color: #fff; background: rgba(255,255,255,.06); }
.bc-cta { display: inline-flex; align-items: center; gap: 6px; background: #22c55e; color: #04120a; font-size: 14px; font-weight: 700; padding: 11px 20px; border-radius: 999px; text-decoration: none; cursor: pointer; border: 0; transition: transform .15s ease, background .15s ease; }
.bc-cta:hover { background: #4ade80; transform: translateY(-1px); }
.bc-cta:active { transform: translateY(0); }
.admin-hint { margin: 4px 0 0; font-size: 12px; color: #888; }
.article-x { position: absolute; top: 18px; right: 18px; z-index: 2; width: 32px; height: 32px; border: none; background: transparent; color: #16213a; font-size: 26px; line-height: 1; cursor: pointer; border-radius: 50%; }
.article-x:hover { background: #f1f4f9; }
/* animated view swap (teaser <-> full story) */
.article-view { display: grid; grid-template-rows: 1fr; opacity: 1; transform: none; transition: grid-template-rows .45s cubic-bezier(.2,.9,.25,1), opacity .3s ease, transform .35s ease; }
.article-view > .article-view-inner { overflow: hidden; min-height: 0; }
.article-view:not(.is-active) { grid-template-rows: 0fr; opacity: 0; transform: translateY(12px); pointer-events: none; }
.article-grid { display: grid; grid-template-columns: 46% 1fr; gap: 30px; align-items: stretch; }
.article-imgwrap { border-radius: 14px; overflow: hidden; min-height: 380px; background: #eef1f6; }
.article-imgwrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.article-body { padding: 26px 26px 26px 0; display: flex; flex-direction: column; }
.article-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.article-pill { background: #eef1f6; color: #5a6b85; font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; padding: 7px 14px; border-radius: 999px; white-space: nowrap; }
.article-date { color: #8a94a6; font-size: 13px; white-space: nowrap; }
.article-title { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: 40px; line-height: 1.15; color: #16213a; margin: 0 0 18px; }
.article-teaser { color: #5b6b85; font-size: 16px; line-height: 1.65; margin: 0 0 26px; }
.article-foot { margin-top: auto; padding-top: 20px; border-top: 1px solid #e8ecf3; display: flex; align-items: center; justify-content: space-between; }
.article-cta { background: #1c2b4a; color: #fff; border: none; border-radius: 999px; padding: 14px 28px; font-size: 15px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 10px; }
.article-cta:hover { background: #27395f; }
.article-bookmark { width: 52px; height: 52px; border-radius: 50%; border: none; background: #f1f4f9; color: #1c2b4a; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.article-bookmark.saved { background: #1c2b4a; color: #fff; }
.article-bookmark.saved svg { fill: currentColor; }
/* full-story view */
.article-full { padding: 12px 14px 6px; }
.article-fullimg { border-radius: 14px; overflow: hidden; margin-bottom: 22px; max-height: 240px; background: #eef1f6; }
.article-fullimg img { width: 100%; height: 100%; max-height: 240px; object-fit: cover; display: block; }
.article-story { color: #3d4c66; font-size: 16px; line-height: 1.75; white-space: pre-wrap; margin: 0 0 20px; }
.article-ctalink { display: inline-block; background: #1c2b4a; color: #fff; border-radius: 999px; padding: 12px 26px; font-size: 15px; font-weight: 600; text-decoration: none; margin-bottom: 20px; }
.article-back { display: inline-block; background: transparent; border: 1px solid #d5dcea; color: #1c2b4a; border-radius: 999px; padding: 12px 24px; font-size: 14px; font-weight: 600; cursor: pointer; margin-bottom: 14px; }
.article-back:hover { background: #f1f4f9; }
@media (max-width: 640px) {
  .article-modal { padding: 10px; }
  .article-imgwrap { display: none; } /* mobile: no image, like you asked */
  .article-grid { grid-template-columns: 1fr; gap: 0; }
  .article-body { padding: 20px 14px 14px; }
  .article-title { font-size: 30px; }
  .article-fullimg { display: none; }
}

/* ---------- Sam's custom loaders ---------- */
/* shimmer "Thinking" — theme-aware so it reads with no background pill */
.shimmer {
  font-family: "Lato", sans-serif;
  font-weight: 300;
  font-size: 17px; /* matches the AI logo mark beside it */
  margin: 0;
  padding: 0;
  display: inline-block;
  text-align: center;
  /* Base: solid readable color with a soft pulse (always works) */
  color: #6b6b6b;
  animation: shimmerPulse 1.6s ease-in-out infinite;
}
@keyframes shimmerPulse {
  0%, 100% { opacity: .45; }
  50% { opacity: 1; }
}
/* Enhance with gradient sweep only where background-clip:text works */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .shimmer {
    color: transparent;
    background: linear-gradient(90deg, #d9d9d9 0%, #d9d9d9 40%, #7a7a7a 50%, #d9d9d9 60%, #d9d9d9 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    animation: shimmer 1.6s linear infinite;
    background-repeat: no-repeat;
  }
}
[data-theme="dark"] .shimmer,
[data-theme="amoled"] .shimmer {
  color: #8a8a8a;
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  [data-theme="dark"] .shimmer,
  [data-theme="amoled"] .shimmer {
    color: transparent;
    background: linear-gradient(90deg, #222 0%, #222 40%, #fff 50%, #222 60%, #222 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    background-repeat: no-repeat;
  }
}
@-moz-keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@-webkit-keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@-o-keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* "Generating" image loader (Uiverse.io by dexter-st) */
.loader-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 180px;
  font-family: "Inter", sans-serif;
  font-size: 1.2em;
  font-weight: 300;
  color: white;
  border-radius: 50%;
  background-color: transparent;
  user-select: none;
}
.loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background-color: transparent;
  animation: loader-rotate 2s linear infinite;
  z-index: 0;
}
@keyframes loader-rotate {
  0% {
    transform: rotate(90deg);
    box-shadow:
      0 10px 20px 0 #fff inset,
      0 20px 30px 0 #ad5fff inset,
      0 60px 60px 0 #471eec inset;
  }
  50% {
    transform: rotate(270deg);
    box-shadow:
      0 10px 20px 0 #fff inset,
      0 20px 10px 0 #d60a47 inset,
      0 40px 60px 0 #311e80 inset;
  }
  100% {
    transform: rotate(450deg);
    box-shadow:
      0 10px 20px 0 #fff inset,
      0 20px 30px 0 #ad5fff inset,
      0 60px 60px 0 #471eec inset;
  }
}
.loader-letter {
  display: inline-block;
  opacity: 0.4;
  transform: translateY(0);
  animation: loader-letter-anim 2s infinite;
  z-index: 1;
  border-radius: 50ch;
  border: none;
}
.loader-letter:nth-child(1) { animation-delay: 0s; }
.loader-letter:nth-child(2) { animation-delay: 0.1s; }
.loader-letter:nth-child(3) { animation-delay: 0.2s; }
.loader-letter:nth-child(4) { animation-delay: 0.3s; }
.loader-letter:nth-child(5) { animation-delay: 0.4s; }
.loader-letter:nth-child(6) { animation-delay: 0.5s; }
.loader-letter:nth-child(7) { animation-delay: 0.6s; }
.loader-letter:nth-child(8) { animation-delay: 0.7s; }
.loader-letter:nth-child(9) { animation-delay: 0.8s; }
.loader-letter:nth-child(10) { animation-delay: 0.9s; }
@keyframes loader-letter-anim {
  0%, 100% { opacity: 0.4; transform: translateY(0); }
  20% { opacity: 1; transform: scale(1.15); }
  40% { opacity: 0.7; transform: translateY(0); }
}

/* web-search words loader (Uiverse.io by kennyotsu) — no dark card;
   the cycling words themselves carry the shimmer shine */
.search-loader {
  color: rgb(124, 124, 124);
  font-family: "Poppins", sans-serif;
  font-weight: 500;
  font-size: 17px;
  -webkit-box-sizing: content-box;
  box-sizing: content-box;
  height: 40px;
  padding: 10px 10px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  border-radius: 8px;
}
.search-words { overflow: hidden; position: relative; }
.search-word {
  display: block;
  height: 100%;
  padding-left: 6px;
  animation: spin_4991 4s infinite;
}
/* shimmer shine on the words + the cycling motion, both at once */
.search-word.shimmer {
  display: block;
  padding-left: 6px;
  font-size: 17px;
  font-family: "Poppins", sans-serif;
  animation: spin_4991 4s infinite, shimmer 2s infinite;
}
@keyframes spin_4991 {
  10% { -webkit-transform: translateY(-102%); transform: translateY(-102%); }
  25% { -webkit-transform: translateY(-100%); transform: translateY(-100%); }
  35% { -webkit-transform: translateY(-202%); transform: translateY(-202%); }
  50% { -webkit-transform: translateY(-200%); transform: translateY(-200%); }
  60% { -webkit-transform: translateY(-302%); transform: translateY(-302%); }
  75% { -webkit-transform: translateY(-300%); transform: translateY(-300%); }
  85% { -webkit-transform: translateY(-402%); transform: translateY(-402%); }
  100% { -webkit-transform: translateY(-400%); transform: translateY(-400%); }
}

/* /imagine pill next to the upload button */
.composer-left { display: flex; align-items: center; gap: 8px; }
.imagine-pill {
  border: 1px solid #e3e1de;
  background: #fff;
  color: #6f6f6f;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: pointer;
  white-space: nowrap;
}
.imagine-pill:hover { background: #f4f3f1; color: #1d1d1f; border-color: #cfcdc9; }
[data-theme="dark"] .imagine-pill,
[data-theme="amoled"] .imagine-pill {
  border-color: #2e2f37;
  background: #23242b;
  color: #9a9aa2;
}
[data-theme="dark"] .imagine-pill:hover { background: #2b2c34; color: #fff; },
[data-theme="amoled"] .imagine-pill:hover { background: #2b2c34; color: #fff; }

/* ================= appearance engine ================= */
:root {
  --accent: #16a34a;
  --glass-blur: 18px;
  --glass-alpha: 88;
  --radius: 14px;
  --chat-fs: 14px;
  --msg-width: 720px;
  --thread-py: 24px;
  --msg-gap: 12px;
}

/* AMOLED: pure-black palette (inherits every dark rule via the doubled selectors) */
[data-theme="amoled"] {
  --bg-main: #000000;
  --bg-side: #050507;
  --card: #0b0b0e;
  --ink: #f5f5f7;
  --ink-2: #d9d9df;
  --ink-3: #a9a9b3;
  --muted: #8e8e96;
  --faint: #55555e;
  --line: #1b1b21;
  --bubble: #141419;
  --chip-bg: #16203c;
  --chip-ink: #8db4ff;
  --black: #f5f5f7;
  color-scheme: dark;
}

/* accent color */
.switch input:checked + .track { background: var(--accent); }
.slider { accent-color: var(--accent); }
.ai-body a { color: var(--accent); }

/* ---------- settings with sidebar ---------- */
.modal-settings { max-width: 980px; text-align: left; width: calc(100vw - 32px); }
.set-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.set-title-h { margin: 0; }
.set-head-actions { display: flex; align-items: center; gap: 8px; }
.set-head-actions .modal-x { position: static; }
.pill-btn {
  border: 1px solid var(--line); background: var(--bg-main); border-radius: 999px;
  padding: 7px 18px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2);
}
.pill-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.set-layout { display: grid; grid-template-columns: 172px 1fr; min-height: 420px; }
.set-side {
  border-right: 1px solid var(--line); padding-right: 12px;
  display: flex; flex-direction: column; gap: 4px; align-self: start;
}
.set-cat {
  text-align: left; background: none; border: none; padding: 10px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 550; color: var(--ink-3); cursor: pointer; font-family: inherit;
}
.set-cat:hover { background: var(--bg-main); color: var(--ink); }
.set-cat.active { background: var(--bg-side); color: var(--ink); }
.set-main { padding-left: 20px; overflow-y: auto; max-height: 62vh; min-width: 0; }
.set-pane { display: none; }
.set-pane.active { display: block; }
.set-preview { display: none; }
@media (min-width: 1024px) {
  .set-layout { grid-template-columns: 172px 1fr 248px; }
  .set-preview { display: block; border-left: 1px solid var(--line); padding-left: 16px; align-self: start; }
}
@media (max-width: 720px) {
  .set-layout { grid-template-columns: 1fr; min-height: 0; }
  .set-side {
    flex-direction: row; border-right: none; border-bottom: 1px solid var(--line);
    padding: 0 0 10px; margin-bottom: 4px; overflow-x: auto;
  }
  .set-cat { white-space: nowrap; }
  .set-main { padding-left: 0; max-height: 56vh; }
}

/* segmented controls */
.seg {
  display: flex; flex-wrap: wrap; gap: 4px; background: var(--bg-side);
  border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-top: 10px;
}
.seg button {
  flex: 1 1 auto; border: none; background: none; padding: 8px 10px; border-radius: 8px;
  font-size: 13px; font-weight: 550; color: var(--ink-3); cursor: pointer; white-space: nowrap; font-family: inherit;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.14); }

/* accent swatches */
.swatches { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.sw {
  width: 34px; height: 34px; border-radius: 50%; background: var(--sw);
  border: 2px solid transparent; cursor: pointer; padding: 0; position: relative;
  transition: transform .15s ease;
}
.sw:hover { transform: scale(1.1); }
.sw.on { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--sw); }
.sw-custom {
  background: conic-gradient(#ef4444, #f97316, #22c55e, #2b5fd9, #8b5cf6, #ef4444);
  display: grid; place-items: center; overflow: hidden;
}
.sw-custom span { color: #fff; font-size: 18px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.5); pointer-events: none; }
.sw-custom input { position: absolute; inset: -8px; opacity: 0; cursor: pointer; }

/* ---------- live preview (desktop) ---------- */
.apv-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-3); margin-bottom: 10px;
}
.apv {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-main);
  overflow: hidden; display: flex; height: 380px; pointer-events: none;
  box-shadow: 0 12px 32px rgba(0,0,0,.10);
}
.apv-side {
  width: 52px; flex: none; background: var(--bg-side); border-right: 1px solid var(--line);
  padding: 12px 8px; display: flex; flex-direction: column; gap: 8px;
}
.apv-side i { display: block; height: 8px; border-radius: 4px; background: var(--line); }
.apv-side i:first-child { height: 22px; border-radius: 6px; background: var(--accent); opacity: .85; }
.apv-main { flex: 1; display: flex; flex-direction: column; padding: 12px; gap: 8px; min-width: 0; }
.apv-ai { display: flex; gap: 8px; align-items: flex-start; }
.apv-logo {
  width: 22px; height: 22px; flex: none; border-radius: 6px; background: var(--black); color: var(--bg-main);
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
}
.apv-ai-body { font-size: var(--chat-fs); color: var(--ink-2); line-height: 1.5; }
.apv-user {
  align-self: flex-end; background: var(--bubble); border-radius: var(--radius);
  padding: 8px 12px; font-size: var(--chat-fs); color: var(--ink-2); max-width: 85%; line-height: 1.45;
}
.apv-meta { display: flex; gap: 6px; align-items: center; font-size: 10px; color: var(--faint); align-self: flex-end; }
.apv-input {
  margin-top: auto; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); min-height: 38px; display: flex; align-items: center;
  padding: 0 8px 0 12px; gap: 8px;
}
.apv-ph { flex: 1; font-size: 12px; color: var(--faint); }
.apv-send {
  width: 24px; height: 24px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-style: normal;
}
.apv-note { margin-top: 10px; }

/* ---------- chat typography / width / density ---------- */
.ai-body, .ai-text { font-size: var(--chat-fs); }
.bubble { font-size: var(--chat-fs); }
.thread { max-width: var(--msg-width); padding-top: var(--thread-py); }
.msg-row { margin: var(--msg-gap) 0; }
.ai-msg { margin: calc(var(--msg-gap) + 4px) 0; }
body[data-density="compact"] { --thread-py: 12px; --msg-gap: 6px; }
body[data-density="spacious"] { --thread-py: 40px; --msg-gap: 20px; }

/* ---------- bubble styles ---------- */
body[data-bubble="minimal"] .bubble,
body[data-bubble="minimal"] .apv-user {
  background: none; border-radius: 0; padding: 4px 0; border: none; backdrop-filter: none;
}
body[data-bubble="glass"] .bubble,
body[data-bubble="glass"] .apv-user {
  background: color-mix(in srgb, var(--bubble) 55%, transparent);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.3);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.3);
  border: 1px solid var(--line);
}
.bubble, .apv-user, .apv-input, .apv { border-radius: var(--radius); }
.modal { border-radius: var(--radius); }
.composer { border-radius: var(--radius); }
.chat-item, .btn-dark, .btn-ghost, .btn-danger { border-radius: var(--radius); }

/* ---------- liquid glass ---------- */
body[data-glass="on"] .modal {
  background: color-mix(in srgb, var(--card) calc(var(--glass-alpha) * 1%), transparent);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  border: 1px solid var(--line);
}
body[data-glass="on"] .composer {
  background: color-mix(in srgb, var(--card) calc(var(--glass-alpha) * 1%), transparent);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
}

/* ---------- sidebar modes (desktop) ---------- */
@media (min-width: 721px) {
  body[data-sidebar-mode="collapsed"] .sidebar { width: 64px; min-width: 64px; padding: 12px 8px 10px; }
  body[data-sidebar-mode="collapsed"] .sidebar .brand span,
  body[data-sidebar-mode="collapsed"] .sidebar .nav-item span,
  body[data-sidebar-mode="collapsed"] .sidebar .chat-item span,
  body[data-sidebar-mode="collapsed"] .sidebar .side-label,
  body[data-sidebar-mode="collapsed"] .sidebar .new-chat span,
  body[data-sidebar-mode="collapsed"] .sidebar .side-user .login-btn,
  body[data-sidebar-mode="collapsed"] .sidebar .side-user .user-name,
  body[data-sidebar-mode="collapsed"] .sidebar .side-user .avatar,
  body[data-sidebar-mode="collapsed"] .sidebar .drawer-share { display: none; }
  body[data-sidebar-mode="collapsed"] .sidebar .side-head { justify-content: center; padding-bottom: 8px; }
  body[data-sidebar-mode="collapsed"] .sidebar .side-head-actions { display: none; }
  body[data-sidebar-mode="collapsed"] .sidebar .side-user { justify-content: center; }
  body[data-sidebar-mode="collapsed"] .sidebar .nav-item,
  body[data-sidebar-mode="collapsed"] .sidebar .chat-item,
  body[data-sidebar-mode="collapsed"] .sidebar .new-chat { justify-content: center; }
  body[data-sidebar-mode="floating"] .sidebar {
    position: fixed; top: 12px; bottom: 12px; left: 12px;
    border: 1px solid var(--line); border-right: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: 0 18px 50px rgba(0,0,0,.16);
    z-index: 80;
    background: color-mix(in srgb, var(--bg-side) calc(var(--glass-alpha) * 1%), transparent);
    -webkit-backdrop-filter: blur(var(--glass-blur));
    backdrop-filter: blur(var(--glass-blur));
  }
}

/* ---------- animation gates ---------- */
html[data-anim-ui="off"] *, html[data-anim-ui="off"] *::before, html[data-anim-ui="off"] *::after {
  transition-duration: .01ms !important;
}
html[data-msg-anim="off"] .msg-anim { animation: none !important; }
html[data-reduced-motion="on"] *, html[data-reduced-motion="on"] *::before, html[data-reduced-motion="on"] *::after {
  animation: none !important; transition: none !important;
}
html[data-smooth="on"] .messages { scroll-behavior: smooth; }

/* button hover effects off */
html[data-hover-fx="off"] .icon-btn:hover { background: none; }
html[data-hover-fx="off"] .btn-dark:hover { background: var(--black); }
html[data-hover-fx="off"] .login-btn:hover { background: var(--black); }
html[data-hover-fx="off"] .send-btn:hover { background: var(--black); }
html[data-hover-fx="off"] .btn-ghost:hover { background: none; }
html[data-hover-fx="off"] .btn-danger:hover { background: none; }
html[data-hover-fx="off"] .provider-btn:hover { background: var(--card); }
html[data-hover-fx="off"] .toast-btn:hover { background: none; }
html[data-hover-fx="off"] .plus-btn:hover { background: none; }
html[data-hover-fx="off"] .nav-item:hover { background: none; }
html[data-hover-fx="off"] .chat-item:hover { background: none; transform: none; }
html[data-hover-fx="off"] .modal-x:hover { background: none; color: #a5a3a0; }
html[data-hover-fx="off"] .pill-btn:hover { border-color: var(--line); color: var(--ink-2); }
html[data-hover-fx="off"] .set-cat:hover { background: none; color: var(--ink-3); }
html[data-hover-fx="off"] .seg button:hover { color: var(--ink-3); }
html[data-hover-fx="off"] .sw:hover { transform: none; }
html[data-hover-fx="off"] .btn-dark:active, html[data-hover-fx="off"] .send-btn:active,
html[data-hover-fx="off"] .plus-btn:active, html[data-hover-fx="off"] .icon-btn:active,
html[data-hover-fx="off"] .login-btn:active, html[data-hover-fx="off"] .btn-ghost:active,
html[data-hover-fx="off"] .btn-danger:active { transform: none; }

/* ---------- code block styles ---------- */
pre.ai-code {
  border-radius: 10px; padding: 12px 14px; overflow-x: auto;
  font-size: 12.5px; line-height: 1.55; margin: 10px 0;
}
body[data-code="dark"] pre.ai-code { background: #1b1c22; color: #e8e8ec; }
body[data-code="light"] pre.ai-code { background: #f0efed; color: #1d1d1f; }
body[data-code="auto"] pre.ai-code { background: var(--bubble); color: var(--ink-2); }
body[data-code="light"] .code-copy { background: rgba(0,0,0,.06); border-color: rgba(0,0,0,.1); color: #555; }
body[data-code="auto"] .code-copy { background: color-mix(in srgb, var(--ink) 8%, transparent); border-color: var(--line); color: var(--ink-3); }

/* ---------- message meta (timestamps / model badge) ---------- */
.msg-meta {
  display: flex; align-items: center; gap: 6px; margin-top: 6px;
  font-size: 11px; color: var(--faint); line-height: 1.2;
}
.msg-row .msg-meta { justify-content: flex-end; }
.model-badge {
  background: var(--bg-side); border: 1px solid var(--line); border-radius: 6px;
  padding: 1px 7px; font-weight: 650; font-size: 10.5px; color: var(--ink-3);
}

/* AI tables — clean columns, works on dark and light */
.ai-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; line-height: 1.5; display: block; overflow-x: auto; }
.ai-table thead { display: table-header-group; }
.ai-table tbody { display: table-row-group; }
.ai-table tr { display: table-row; }
.ai-table th, .ai-table td { display: table-cell; padding: 9px 14px; text-align: left; border-bottom: 1px solid rgba(128,128,128,.18); white-space: nowrap; }
.ai-table th { font-weight: 700; border-bottom: 1px solid rgba(128,128,128,.35); }
.ai-table tbody tr:last-child td { border-bottom: none; }
.ai-table tbody tr:hover td { background: rgba(128,128,128,.06); }

/* Math rendering */
.ai-math { margin: 12px 0; overflow-x: auto; padding: 8px 0; }
.ai-math .katex-display { margin: 0; }
.katex { font-size: 1.05em; }

/* Model menu sections */
.mm-section { padding: 14px 16px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .45; }
.mm-section:first-child { padding-top: 4px; }

/* Thought process (Settings → AI) */
/* (thought process styles moved below — Claude-style, no border) */

/* Model folder accordions */
.mm-folder-wrap { border-radius: 12px; }
.mm-folder-wrap.open .mm-go { transform: rotate(180deg); }
.mm-folder .mm-go { transition: transform .25s ease; }
.mm-folder-items { overflow: hidden; }
.mm-folder-items[hidden] { display: none; }
.mm-item.mm-sub { padding-left: 28px; }
.mm-folder-items .mm-item { animation: mmSlideDown .25s ease; }
@keyframes mmSlideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Archive button in sidebar */
.chat-item .arch { opacity: 0; margin-left: 4px; cursor: pointer; font-size: 13px; flex: none; }
.chat-item:hover .arch { opacity: .7; }
.chat-item .arch:hover { opacity: 1; }
.archived-item { opacity: .65; }
/* AI settings */
.set-col { flex-direction: column; align-items: stretch; gap: 8px; }
.set-textarea { width: 100%; background: var(--bg-input, #f5f5f5); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; font-family: inherit; resize: vertical; color: inherit; }
.set-select { background: var(--bg-input, #f5f5f5); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13.5px; color: inherit; cursor: pointer; max-width: 180px; }

/* Voice select: fix dark theme */
.set-select { color-scheme: light; }
[data-theme="dark"] .set-select, [data-theme="amoled"] .set-select { color-scheme: dark; background: #2a2a2e; border-color: #3a3a3e; color: #fff; }
.set-select option { background: #fff; color: #111; }
[data-theme="dark"] .set-select option, [data-theme="amoled"] .set-select option { background: #2a2a2e; color: #fff; }

/* Thinking status: solid text + soft pulse. NO background-clip:text — it caused the white rectangle glitch. */
.think-status {
  display: inline-block;
  font-size: 15px;
  font-weight: 400;
  padding: 4px 0;
  color: #8a8a8a;
  animation: thinkPulse 1.6s ease-in-out infinite;
}
[data-theme="dark"] .think-status, [data-theme="amoled"] .think-status { color: #9a9a9a; }
@keyframes thinkPulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

}

/* Thought process: Claude-style — shimmer text, click to expand, separator line, no border, no ^ */
.ai-thought {
  margin: 0 0 10px;
  border: none !important;
  background: none !important;
}
.ai-thought-sum {
  display: inline-block;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 4px 0;
  /* Shimmer text like the thinking status */
  color: #8a8a8a;
}
.ai-thought-sum::-webkit-details-marker { display: none; }
.ai-thought-chev { display: none !important; }

.ai-thought-body {
  margin-top: 6px;
  padding: 10px 0 10px 12px;
  border-left: 2px solid rgba(128,128,128,.25);
  font-size: 13px;
  line-height: 1.6;
  opacity: .8;
  white-space: pre-wrap;
  color: inherit;
}

/* Prowl desktop link inputs */
.set-input {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid rgba(128,128,128,.3); background: transparent;
  color: inherit; font-size: 14px; outline: none; box-sizing: border-box;
}
.set-input:focus { border-color: #8a8a8a; }
.set-input::placeholder { opacity: .4; }

/* Prowl permission pill */
.prowl-perm-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  padding: 5px 12px; border-radius: 20px;
  border: 1px solid rgba(128,128,128,.3);
  background: rgba(128,128,128,.08);
  color: inherit; cursor: pointer; opacity: .85; white-space: nowrap;
  transition: all .2s ease;
}
.prowl-perm-pill:hover { opacity: 1; transform: translateY(-1px); }
.prowl-perm-pill .pp-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #f0a020; box-shadow: 0 0 6px rgba(240,160,32,.7);
  flex-shrink: 0;
}
.prowl-perm-pill.full { border-color: rgba(76,175,80,.5); background: rgba(76,175,80,.1); opacity: 1; }
.prowl-perm-pill.full .pp-dot { background: #4caf50; box-shadow: 0 0 6px rgba(76,175,80,.8); }


/* Coming soon pill */
.coming-soon-pill {
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  padding: 5px 12px; border-radius: 20px; white-space: nowrap;
  background: rgba(128,128,128,.15); border: 1px dashed rgba(128,128,128,.4);
  opacity: .75;
}

/* ============ Boot skeleton screen ============ */
#bootSkeleton {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; background: var(--bg, #fff);
  transition: opacity .35s ease;
}
#bootSkeleton.hide { opacity: 0; pointer-events: none; }
[data-theme="dark"] #bootSkeleton, [data-theme="amoled"] #bootSkeleton { --bg: #111; }
.sk-sidebar {
  width: 260px; flex-shrink: 0; padding: 18px 14px;
  border-right: 1px solid rgba(128,128,128,.15);
  display: flex; flex-direction: column; gap: 12px;
}
.sk-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sk-topbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; }
.sk-chat { flex: 1; padding: 24px; display: flex; flex-direction: column; gap: 16px; overflow: hidden; }
.sk-composer { padding: 16px 24px 24px; }
.sk {
  border-radius: 10px;
  background: linear-gradient(100deg, rgba(128,128,128,.14) 30%, rgba(128,128,128,.28) 50%, rgba(128,128,128,.14) 70%);
  background-size: 200% 100%;
  animation: skShimmer 1.4s linear infinite;
}
@keyframes skShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.sk-logo { width: 120px; height: 28px; }
.sk-line { height: 36px; }
.sk-line.short { width: 60%; }
.sk-pill { width: 140px; height: 32px; border-radius: 16px; }
.sk-avatar { width: 36px; height: 36px; border-radius: 50%; }
.sk-bubble { height: 64px; width: 55%; }
.sk-bubble.right { align-self: flex-end; width: 40%; }
.sk-input { height: 56px; border-radius: 18px; }
@media (max-width: 720px) { .sk-sidebar { display: none; } }

/* ============ Chat/Coder mode toggle ============ */
.chat-header { position: relative; }
.mode-toggle {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center;
  background: rgba(128,128,128,.14); border-radius: 20px; padding: 3px;
}
.mode-opt {
  position: relative; z-index: 1; border: none; background: none; color: inherit;
  font-size: 13px; font-weight: 600; padding: 7px 18px; border-radius: 17px;
  cursor: pointer; opacity: .6; transition: opacity .25s ease, color .25s ease;
  display: flex; align-items: center; gap: 5px;
}
.mode-opt.active { opacity: 1; }
.mode-spark { font-size: 12px; }
.mode-thumb {
  position: absolute; top: 3px; bottom: 3px; border-radius: 17px;
  background: rgba(128,128,128,.28);
  transition: left .3s cubic-bezier(.4,0,.2,1), width .3s cubic-bezier(.4,0,.2,1);
  z-index: 0;
}
/* Coder mode gradient: #a3c1d1 top → blends into theme */
.view-chat.coder-mode::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: linear-gradient(180deg, rgba(163,193,209,.55) 0%, rgba(163,193,209,.22) 28%, transparent 55%);
}
[data-theme="dark"] .view-chat.coder-mode::before,
[data-theme="amoled"] .view-chat.coder-mode::before {
  background: linear-gradient(180deg, rgba(163,193,209,.28) 0%, rgba(163,193,209,.1) 28%, transparent 55%);
}
.view-chat.coder-mode .chat-body,
.view-chat.coder-mode .chat-header,
.view-chat.coder-mode .composer-wrap { position: relative; z-index: 1; }
/* Mode switch animation */
.view-chat .chat-body, .view-chat .messages { transition: opacity .3s ease, transform .3s ease; }
.view-chat.switching .chat-body { opacity: 0; transform: translateY(8px); }
/* Hide model switcher in coder mode */
.view-chat.coder-mode .model { display: none !important; }

/* ============ Artifact panel (code preview) ============ */
.chat-body { display: flex; min-height: 0; flex: 1; }
.messages { flex: 1; min-width: 0; }
.artifact-panel {
  width: 46%; min-width: 340px; flex-shrink: 0;
  display: flex; flex-direction: column;
  border-left: 1px solid rgba(128,128,128,.2);
  background: var(--bg, #fff);
  animation: artifactIn .35s cubic-bezier(.4,0,.2,1);
}
@keyframes artifactIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.artifact-panel[hidden] { display: none; }
.artifact-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid rgba(128,128,128,.15);
}
.artifact-title { font-weight: 700; font-size: 14px; }
.artifact-tabs { display: flex; gap: 4px; margin-left: 8px; }
.artifact-tab {
  border: none; background: none; color: inherit; font-size: 12.5px; font-weight: 600;
  padding: 6px 12px; border-radius: 10px; cursor: pointer; opacity: .55;
}
.artifact-tab.active { opacity: 1; background: rgba(128,128,128,.16); }
.artifact-head .icon-btn { margin-left: auto; }
.artifact-close { font-size: 20px; line-height: 1; }
.artifact-view { flex: 1; min-height: 0; border: none; }
#artifactFrame { width: 100%; height: 100%; border: none; background: #fff; }
.artifact-code { margin: 0; padding: 16px; overflow: auto; font-size: 12.5px; line-height: 1.6; }
.artifact-code code { font-family: ui-monospace, monospace; white-space: pre; }
/* Mobile: toggle hidden, artifact becomes overlay */
@media (max-width: 720px) {
  .mode-toggle { display: none; }
  .artifact-panel { position: fixed; inset: 0; width: 100%; z-index: 60; }
}

/* Download bar under AI messages */
.dl-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.dl-btn { font-size: 12.5px; padding: 7px 14px; border-radius: 10px; }

/* Home page mode picker — top center */
.home-topbar { display: flex; justify-content: center; padding: 14px 0 4px; }
.home-mode-toggle {
  position: relative; left: auto; top: auto; transform: none;
  margin: 0;
}
/* Chat header toggle is locked (display-only) */
.view-chat .mode-toggle { pointer-events: none; }
.view-chat .mode-toggle .mode-opt { cursor: default; }

/* Temporarily-down models */
.mm-down { opacity: .55; }
.mm-down-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 10px; margin-left: 8px;
  background: rgba(220,60,60,.15); color: #d43c3c; border: 1px solid rgba(220,60,60,.35);
}
