/* Swei AI theme: "Aurora" - violet to ocean blue to mint.
   The studio styles (css/studios.css) use the same token names, so keep them. */
:root {
  --bg: #f6f6fb; --side: #eeeef8; --panel: #ffffff; --text: #15142a; --muted: #63627e;
  --line: #e2e1f0; --accent: #5b45f5; --accent-2: #0fae95; --accent-text: #ffffff; --soft: #ecebfb; --hover: #e7e6f5;
  --code: #12121f; --danger: #c62a3c; --good: #0e8a6f; --shadow: 0 6px 24px rgba(40, 30, 120, .08);
  --grad: linear-gradient(135deg, #6c4dff 0%, #3a7bff 55%, #14d1b4 100%);
  --ring: 0 0 0 3px rgba(91, 69, 245, .18);
  --display: "Space Grotesk", "Manrope", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e1a; --side: #090a14; --panel: #161729; --text: #ecebfa; --muted: #9c9bba;
    --line: #26273f; --accent: #7a66ff; --accent-2: #2de0c2; --soft: #1f2038; --hover: #1d1e35;
    --code: #0a0b15; --danger: #ff8a95; --good: #45e0bd; --shadow: 0 8px 30px rgba(0, 0, 0, .45);
    --ring: 0 0 0 3px rgba(122, 102, 255, .3);
  }
}
:root[data-theme="dark"] {
  --bg: #0d0e1a; --side: #090a14; --panel: #161729; --text: #ecebfa; --muted: #9c9bba;
  --line: #26273f; --accent: #7a66ff; --accent-2: #2de0c2; --soft: #1f2038; --hover: #1d1e35;
  --code: #0a0b15; --danger: #ff8a95; --good: #45e0bd; --shadow: 0 8px 30px rgba(0, 0, 0, .45);
  --ring: 0 0 0 3px rgba(122, 102, 255, .3);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.65 "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif; display: flex; overflow: hidden; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: none; box-shadow: var(--ring); }
::selection { background: rgba(91, 69, 245, .25); }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* ---------- Sidebar ---------- */
#side { width: 276px; flex-shrink: 0; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 12px 10px; gap: 8px; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 4px 6px; }
.brand { font-family: var(--display); font-weight: 700; font-size: 21px; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
.brand { text-decoration: none; color: inherit; cursor: pointer; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.brand em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ghost-ic { background: none; border: none; color: var(--muted); width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; }
.ghost-ic:hover { background: var(--hover); color: var(--text); }
.ghost-ic.on { color: var(--accent); background: var(--soft); }
#newChat { background: var(--grad); color: #fff; border: none; border-radius: 12px; padding: 10px 14px; text-align: left; font-weight: 700; display: flex; align-items: center; gap: 8px; box-shadow: 0 6px 18px rgba(91, 69, 245, .28); transition: transform .12s, box-shadow .12s; }
#newChat:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(91, 69, 245, .36); }
.side-nav { display: flex; flex-direction: column; gap: 1px; }
.nav-btn { background: none; border: none; border-radius: 9px; padding: 7px 10px; display: flex; align-items: center; gap: 10px; font-size: 14px; text-align: left; color: var(--text); }
.nav-btn svg { color: var(--muted); }
.nav-btn:hover, .nav-btn.on { background: var(--hover); }
.side-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; min-height: 0; margin: 0 -4px; padding: 0 4px; }
.sec { font-size: 11px; font-weight: 700; color: var(--muted); padding: 10px 10px 4px; text-transform: uppercase; letter-spacing: .08em; }
details.group > summary { list-style: none; cursor: pointer; user-select: none; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary.sec::after { content: ""; display: inline-block; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); margin-left: 8px; vertical-align: 2px; transition: transform .15s; }
details.group[open] > summary.sec::after { transform: rotate(45deg); }
details.group > summary.sec-row::after { margin-left: auto; order: 3; }
.studios { display: flex; flex-direction: column; gap: 1px; }
.studio-btn { background: none; border: none; border-radius: 9px; padding: 6px 10px; text-align: left; font-size: 14px; color: var(--text); }
.studio-btn:hover { background: var(--hover); }
.studio-btn.on { background: var(--soft); color: var(--accent); font-weight: 600; }
#chatList { display: flex; flex-direction: column; gap: 1px; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 10px; }
.ci { display: flex; align-items: center; border-radius: 9px; }
.ci:hover { background: var(--hover); }
.ci.on { background: var(--soft); }
.ci .t { flex: 1; min-width: 0; background: none; border: none; text-align: left; padding: 7px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.ci .x { background: none; border: none; color: var(--muted); padding: 4px 6px; visibility: hidden; display: flex; border-radius: 6px; }
.ci .x:hover { color: var(--text); background: var(--line); }
.ci:hover .x, .ci.on .x { visibility: visible; }
.ci .x svg { width: 15px; height: 15px; }
.sidefoot { border-top: 1px solid var(--line); padding-top: 8px; }
.user-btn { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: none; border-radius: 12px; padding: 7px 8px; text-align: left; }
.user-btn:hover { background: var(--hover); }
.user-btn > svg { color: var(--muted); width: 16px; height: 16px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.user-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.user-txt b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-txt small { font-size: 12px; color: var(--muted); }
body.collapsed #side { display: none; }

/* ---------- Main ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#top { display: flex; align-items: center; gap: 6px; padding: 8px 14px; min-height: 52px; }
#menu { display: none; }
body.collapsed #menu { display: inline-flex; }
.top-grow { flex: 1; }
.chat-title { background: none; border: none; border-radius: 9px; padding: 6px 10px; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; max-width: 520px; min-width: 0; flex: 0 1 auto; }
#top > * { flex-shrink: 0; }
#top > .chat-title, #top > .top-grow { flex-shrink: 1; }
body.has-artifact .row .pill span { display: none; }
.chat-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title svg { width: 15px; height: 15px; color: var(--muted); }
.chat-title:hover { background: var(--hover); }
.top-btn { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.top-btn:hover { background: var(--hover); }
.top-btn svg { width: 16px; height: 16px; }
#scroll { flex: 1; overflow-y: auto; }
#msgs { max-width: 780px; margin: 0 auto; padding: 12px 20px 8px; }

/* Empty chat: greeting and message box sit in the middle of the page */
#main.empty { justify-content: center; }
#main.empty #top { position: absolute; top: 0; left: 0; right: 0; }
#main.empty #scroll { flex: 0 0 auto; overflow: visible; }
#welcome { max-width: 780px; margin: 0 auto; padding: 0 20px 18px; text-align: center; }
.hello { display: flex; align-items: center; justify-content: center; gap: 14px; }
#welcome .hero { width: 46px; height: 46px; border-radius: 14px; box-shadow: 0 8px 26px rgba(91, 69, 245, .35); }
#welcome h1 { font-family: var(--display); font-weight: 600; font-size: 40px; letter-spacing: -.03em; margin: 0; }
#welcome p { color: var(--muted); margin: 10px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.chips button { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 7px 13px; font-size: 14px; display: inline-flex; align-items: center; gap: 7px; color: var(--text); }
.chips button svg { width: 16px; height: 16px; color: var(--accent); }
.chips button:hover { border-color: var(--accent); background: var(--soft); }

/* ---------- Messages ---------- */
.m { margin: 0 0 26px; }
.m.user { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.m.user .b { background: var(--soft); border: 1px solid var(--line); border-radius: 18px 18px 4px 18px; padding: 10px 16px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.tag { font-size: 12px; color: var(--accent); font-weight: 600; display: block; }
.m.ai { position: relative; padding-left: 40px; }
.m.ai::before { content: ""; position: absolute; left: 0; top: 2px; width: 28px; height: 28px; border-radius: 9px; background: url("../icon.svg") center / cover; }
.m.ai .b { overflow-wrap: anywhere; }
.m.ai .b p { margin: 0 0 12px; }
.m.ai .b h1, .m.ai .b h2, .m.ai .b h3 { font-family: var(--display); letter-spacing: -.01em; line-height: 1.3; margin: 18px 0 8px; }
.m.ai .b a { color: var(--accent); }
.m.ai .b pre { background: var(--code); color: #e8e8f4; border-radius: 12px; padding: 14px; overflow-x: auto; position: relative; font-size: 14px; border: 1px solid var(--line); }
.m.ai .b code { font-family: "JetBrains Mono", Consolas, "Courier New", monospace; }
.m.ai .b :not(pre) > code { background: var(--soft); padding: 1px 6px; border-radius: 6px; font-size: 14px; }
.m.ai .b table { border-collapse: collapse; margin: 8px 0 12px; display: block; overflow-x: auto; }
.m.ai .b th, .m.ai .b td { border: 1px solid var(--line); padding: 6px 10px; }
.m.ai .b th { background: var(--soft); }
.m.ai .b blockquote { margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--accent); color: var(--muted); }
.cpy { position: absolute; top: 6px; right: 6px; background: #2a2a3d; color: #ddd; border: none; border-radius: 6px; font-size: 12px; padding: 3px 8px; }
.think { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--grad); animation: pulse 1s infinite ease-in-out; flex-shrink: 0; }
@keyframes pulse { 50% { transform: scale(.5); opacity: .5; } }
.err { color: var(--danger); }
.acts { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-top: 6px; }
.acts button { background: none; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.acts button:hover { background: var(--hover); color: var(--text); }
.acts button.ic { width: 30px; height: 30px; padding: 0; justify-content: center; }
.acts button.ic svg { width: 16px; height: 16px; }
.acts button.voted { color: var(--accent); }
.acts .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }

.filechip { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 13px; max-width: 100%; }
.filechip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filechip small { color: var(--muted); }
.filechip button { background: none; border: none; color: var(--muted); padding: 0; display: flex; }
.filechip svg { width: 14px; height: 14px; }

.media { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px; max-width: 540px; }
.media img, .media video { width: 100%; border-radius: 10px; display: block; background: #000; }
.media .ph { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); border-radius: 10px; background: var(--soft); padding: 16px; text-align: center; }
.media .cap { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* Chat list: search, groups, menu, rename */
.search { width: 100%; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 9px; padding: 7px 10px; font-size: 13px; outline: none; margin-bottom: 4px; }
.search:focus { border-color: var(--accent); box-shadow: var(--ring); }
.sub { font-size: 11px; color: var(--muted); padding: 8px 10px 2px; text-transform: uppercase; letter-spacing: .06em; }
.ci .pin svg { width: 13px; height: 13px; color: var(--accent); }
.rename { width: 100%; border: 1px solid var(--accent); border-radius: 9px; padding: 7px 10px; font-size: 14px; background: var(--panel); color: var(--text); outline: none; }
.pop { position: fixed; z-index: 40; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 5px; display: flex; flex-direction: column; min-width: 180px; }
.pop button { background: none; border: none; text-align: left; padding: 7px 12px; border-radius: 8px; font-size: 14px; display: flex; align-items: center; gap: 10px; }
.pop button:hover { background: var(--hover); }
.pop button.danger { color: var(--danger); }
.pop button.on::after { content: "✓"; margin-left: auto; color: var(--accent); font-weight: 700; }
.pop .pop-head { padding: 8px 12px 6px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.pop .pop-head b { display: block; color: var(--text); font-size: 14px; }
.pop small { display: block; color: var(--muted); font-size: 12px; }
.pop hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }

/* Message extras: hover actions, versions, thinking, edit box, diagrams, math */
.m.user .acts { justify-content: flex-end; margin-top: 0; }
.acts.hover { opacity: 0; transition: opacity .15s; }
.m:hover .acts.hover, .m:focus-within .acts.hover { opacity: 1; }
@media (hover: none) { .acts.hover { opacity: 1; } }
.vnav { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); margin-right: 4px; }
.vnav button { padding: 2px 8px !important; font-size: 16px !important; }
.vnav button:disabled { opacity: .3; cursor: default; }
.thoughts { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; background: var(--panel); }
.thoughts summary { cursor: pointer; color: var(--muted); font-size: 14px; user-select: none; }
.thoughts .tx { color: var(--muted); font-size: 14px; white-space: pre-wrap; max-height: 220px; overflow-y: auto; margin: 6px 0 4px; }
.editbox { width: min(100%, 640px); min-height: 70px; max-height: 300px; resize: vertical; border: 1px solid var(--accent); border-radius: 14px; padding: 10px 14px; background: var(--panel); color: var(--text); font: inherit; outline: none; box-shadow: var(--ring); }
.acts.edit button { border-color: var(--line); }
.acts.edit button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.diagram { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 0 0 12px; overflow-x: auto; text-align: center; }
.diagram svg { max-width: 100%; height: auto; }
.m.ai .b .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.tobottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: 170px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--text); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; z-index: 5; }
.tobottom:hover { background: var(--hover); }

/* Code tools: Preview / Run, output box, preview panel */
.code-tools { position: absolute; top: 6px; right: 62px; display: flex; gap: 4px; }
.code-tools button { background: #2a2a3d; color: #ddd; border: none; border-radius: 6px; font-size: 12px; padding: 3px 8px; }
.code-tools button:hover, .cpy:hover { background: #3a3a55; }
.run-out { margin: -6px 0 14px; border: 1px solid var(--line); border-top: none; border-radius: 0 0 12px 12px; background: var(--panel); padding: 8px 12px; }
.run-out .run-head { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.run-out pre { margin: 6px 0 0; white-space: pre-wrap; font-family: Consolas, "Courier New", monospace; font-size: 13px; max-height: 320px; overflow: auto; background: none !important; color: var(--text) !important; padding: 0 !important; border: none !important; }
.run-out pre.err { color: var(--danger) !important; }
.artifact { width: 46vw; flex-shrink: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--panel); }
.artifact.full { position: fixed; inset: 0; width: auto; z-index: 30; }
.artifact-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.artifact-head button { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 13px; }
.artifact-head button:hover { background: var(--hover); }
.artifact-head .seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.artifact-head .seg button { border: none; border-radius: 0; }
.artifact-head .seg button.on { background: var(--accent); color: var(--accent-text); }
.artifact-head .grow { flex: 1; }
.artifact-frame { flex: 1; width: 100%; border: none; background: #fff; }
.artifact-code { flex: 1; margin: 0; overflow: auto; padding: 14px; background: var(--code); color: #eee; font-size: 13px; }
@media (max-width: 900px) { .artifact { position: fixed; inset: 0; width: auto; z-index: 30; } }

/* Artifact cards and panel */
.art-card { display: flex; align-items: center; gap: 12px; width: min(100%, 460px); margin: 4px 0 14px; padding: 10px 12px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); color: var(--text); }
.art-card:hover { border-color: var(--accent); }
.art-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--grad); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.art-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.art-txt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.art-txt small { color: var(--muted); font-size: 12px; }
.art-open { font-size: 13px; font-weight: 700; color: var(--accent); }
.artifact { min-width: 0; }
.artifact-head.tools { padding-top: 6px; padding-bottom: 6px; }
.art-title { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.art-title b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 28vw; }
.art-title small { color: var(--muted); font-size: 12px; }
.art-ver { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.art-ver button { padding: 2px 8px !important; }
.art-ver button:disabled { opacity: .35; cursor: default; }
.artifact-codewrap { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; background: var(--code); }
.artifact-codewrap .artifact-code { flex: none; overflow: visible; }
.artifact-codewrap .run-out { margin: 0; border-radius: 0; border: none; border-top: 1px solid var(--line); }
body.has-artifact #comp, body.has-artifact #msgs { max-width: 680px; }

/* Pictures in messages and the message box */
.filechip.pic img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; cursor: zoom-in; }
.m.user .filechip.pic img { width: 160px; height: auto; max-height: 200px; }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(5, 5, 15, .85); display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

/* All chats page */
.cp { max-width: 820px; margin: 0 auto; }
.cp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cp-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.cp-tools button { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 7px 13px; font-size: 14px; font-weight: 600; }
.cp-tools button:hover { background: var(--hover); }
.cp-tools button.primary { background: var(--grad); color: #fff; border: none; }
.cp-tools button.danger { color: var(--danger); }
.cp-tools button:disabled { opacity: .5; cursor: default; }
.cp-search { font-size: 15px; padding: 11px 14px; border-radius: 12px; margin: 14px 0 6px; }
.cp-info { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.cp-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.cp-row { display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 8px; }
.cp-row:hover, .cp-row.on { background: var(--hover); }
.cp-row input { accent-color: var(--accent); width: 17px; height: 17px; }
.cp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cp-main b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-main span { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-row small { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* Voice mode */
.voice { position: fixed; inset: 0; z-index: 45; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; text-align: center; }
.voice-orb { width: 160px; height: 160px; border-radius: 50%; border: none; background: var(--grad); box-shadow: 0 14px 50px rgba(91, 69, 245, .45); }
.voice-orb.listening { animation: breathe 1.6s infinite ease-in-out; }
.voice-orb.thinking { animation: glow 1s infinite ease-in-out; }
.voice-orb.speaking { animation: talk .5s infinite alternate ease-in-out; }
@keyframes breathe { 50% { transform: scale(1.08); } }
@keyframes talk { from { transform: scale(.96); } to { transform: scale(1.06); } }
.voice-state { font-size: 20px; font-family: var(--display); }
.voice-heard { min-height: 1.6em; max-width: 640px; color: var(--muted); font-size: 17px; }
.voice-ctrl { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.voice-ctrl select, .voice-ctrl button { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font-size: 14px; }

/* Projects */
.sec-row { display: flex; align-items: center; justify-content: space-between; }
.sec-btn { background: none; border: none; color: var(--muted); font-size: 12px; padding: 0 4px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.sec-btn:hover { color: var(--accent); }
.studio-btn .count { float: right; font-size: 12px; color: var(--muted); }
.proj-note { display: block; max-width: 740px; margin: 12px auto 0; background: none; border: 1px solid var(--line); border-radius: 10px; padding: 6px 14px; font-size: 13px; color: var(--muted); text-align: left; }
.proj-note:hover { border-color: var(--accent); color: var(--text); }
.proj-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.proj-chats { display: flex; flex-direction: column; gap: 6px; }
.proj-chat { display: flex; justify-content: space-between; gap: 10px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.proj-chat:hover { border-color: var(--accent); }

/* Search sources */
.sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; }
.sources span { color: var(--muted); margin-right: 2px; }
.sources a { color: var(--text); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; background: var(--panel); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sources a:hover { border-color: var(--accent); }

/* Text size, temporary chat, memory note */
html[data-size="small"] body { font-size: 15px; }
html[data-size="large"] body { font-size: 18px; }
.temp-note { max-width: 740px; margin: 12px auto 0; padding: 8px 14px; border: 1px dashed var(--accent); border-radius: 10px; color: var(--muted); font-size: 13px; text-align: center; }
.memnote { display: inline-block; margin-top: 4px; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }

/* Settings dialog */
dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text); padding: 24px; width: min(420px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 8, 20, .55); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 4px; font-family: var(--display); font-weight: 600; letter-spacing: -.02em; }
dialog.settings { width: min(780px, calc(100vw - 24px)); max-height: calc(100vh - 40px); padding: 0; overflow: hidden; }
dialog.settings[open] { display: flex; flex-direction: column; }
.set-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.set-head h2 { margin: 0; font-size: 22px; }
.set-wrap { display: flex; min-height: 0; flex: 1; }
.set-tabs { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-right: 1px solid var(--line); min-width: 160px; }
.set-tabs button { background: none; border: none; text-align: left; padding: 8px 12px; border-radius: 9px; font-size: 14px; }
.set-tabs button:hover { background: var(--hover); }
.set-tabs button.on { background: var(--soft); color: var(--accent); font-weight: 700; }
.set-body { padding: 4px 22px 22px; overflow-y: auto; flex: 1; }
.set-body h3 { font-size: 16px; margin: 18px 0 8px; font-family: var(--display); }
.set-body .hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.set-body .hint.bad { color: var(--danger); }
.set-body .hint.good { color: var(--good); }
.set-body .field input[type=password], .set-body .field input[type=email] { font: inherit; font-size: 15px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; }
.set-body .field input[type=password] { margin-top: 0; }
.set-body .st-actions .field input { font: inherit; font-size: 15px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; }
.set-line { margin: 12px 0; font-size: 14px; }
.keys { border-collapse: collapse; font-size: 14px; }
.keys td { padding: 5px 16px 5px 0; }
kbd { background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-family: inherit; font-size: 13px; }
.mem-list, .asst-list { display: flex; flex-direction: column; gap: 6px; }
.mem, .asst { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.btn.danger { color: var(--danger); }
@media (max-width: 600px) {
  .set-wrap { flex-direction: column; }
  .set-tabs { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); min-width: 0; }
}

/* ---------- Composer ---------- */
#comp { max-width: 780px; width: 100%; margin: 0 auto; padding: 6px 20px 14px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 14px 14px 10px; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.box:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: var(--shadow), var(--ring); }
#files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
#files:empty { display: none; }
#inp { width: 100%; border: none; outline: none; resize: none; background: transparent; color: var(--text); font: inherit; max-height: 240px; min-height: 28px; padding: 0 4px; }
#inp::placeholder { color: var(--muted); }
#inp:focus-visible { box-shadow: none; }
#assistant { max-width: 150px; }
#pop.pop { min-width: 220px; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.row-l, .row-r { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-r { margin-left: auto; }
.iconbtn { background: none; border: 1px solid var(--line); border-radius: 10px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.iconbtn:hover { background: var(--hover); color: var(--text); }
.iconbtn.rec { background: var(--accent); border-color: var(--accent); color: var(--accent-text); animation: glow 1.2s infinite ease-in-out; }
@keyframes glow { 50% { opacity: .55; } }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; background: none; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; }
.pill:hover { background: var(--hover); color: var(--text); }
.pill svg { width: 16px; height: 16px; }
.pill.tog input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.pill.tog:has(input:checked), .pill.active { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); background: var(--soft); }
.pill.tog:has(input:focus-visible) { box-shadow: var(--ring); }
.modes { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; height: 34px; }
.mode { background: none; border: none; padding: 0 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.mode:hover { color: var(--text); }
.mode.on { background: var(--soft); color: var(--accent); }
.opt { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; height: 34px; padding: 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
#send { background: var(--grad); color: #fff; border: none; border-radius: 11px; width: 38px; height: 34px; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(91, 69, 245, .35); }
#send:disabled { opacity: .4; cursor: default; }
.note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }
#main:not(.empty) .chips { display: none; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
#toast.show { opacity: 1; }

/* ---------- Sign in / create account ---------- */
#auth { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg); overflow-y: auto; }
.auth-art { position: relative; overflow: hidden; background: #0b0b1d; color: #fff; padding: 40px 48px; display: flex; flex-direction: column; }
.auth-art::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 20% 15%, rgba(108, 77, 255, .55), transparent 45%), radial-gradient(circle at 85% 80%, rgba(20, 209, 180, .45), transparent 45%), radial-gradient(circle at 70% 25%, rgba(58, 123, 255, .4), transparent 40%); }
.auth-art > * { position: relative; }
.auth-brand { font-family: var(--display); font-weight: 700; font-size: 22px; display: flex; align-items: center; gap: 12px; }
.auth-brand img { width: 36px; height: 36px; border-radius: 11px; }
.auth-pitch { margin: auto 0; max-width: 520px; }
.auth-pitch h1 { font-family: var(--display); font-size: clamp(32px, 4vw, 50px); line-height: 1.08; letter-spacing: -.035em; margin: 0 0 16px; }
.auth-pitch p { font-size: 18px; color: rgba(255, 255, 255, .78); margin: 0 0 22px; }
.auth-pitch ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.auth-pitch li { padding-left: 28px; position: relative; color: rgba(255, 255, 255, .88); }
.auth-pitch li::before { content: ""; position: absolute; left: 0; top: 7px; width: 14px; height: 14px; border-radius: 50%; background: linear-gradient(135deg, #8a74ff, #14d1b4); }
.auth-orbs span { position: absolute; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .12); }
.auth-orbs span:nth-child(1) { width: 420px; height: 420px; right: -140px; bottom: -160px; }
.auth-orbs span:nth-child(2) { width: 280px; height: 280px; right: -70px; bottom: -90px; }
.auth-orbs span:nth-child(3) { width: 150px; height: 150px; right: 0; bottom: -20px; }
.auth-side { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; }
.auth-logo { width: 48px; height: 48px; border-radius: 14px; display: none; }
.auth-card h2 { font-family: var(--display); font-size: 32px; letter-spacing: -.03em; margin: 0; }
.auth-sub { color: var(--muted); margin: -6px 0 4px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); border-radius: 12px; padding: 4px; }
.auth-tabs button { border: none; background: none; border-radius: 9px; padding: 8px; font-weight: 700; font-size: 14px; color: var(--muted); }
.auth-tabs button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.af { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.af input { width: 100%; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 12px; padding: 11px 14px; font-size: 15px; font-weight: 500; outline: none; }
.af input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.af input.bad { border-color: var(--danger); }
.pw { position: relative; display: block; }
.pw input { padding-right: 70px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--accent); font-size: 13px; font-weight: 700; padding: 6px 8px; border-radius: 8px; }
.pw-eye:hover { background: var(--soft); }
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: -4px; }
.meter i { height: 4px; border-radius: 4px; background: var(--line); transition: background .2s; }
.meter span { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.meter[data-s="1"] i:nth-child(-n+1) { background: #e5484d; }
.meter[data-s="2"] i:nth-child(-n+2) { background: #f5a524; }
.meter[data-s="3"] i:nth-child(-n+3) { background: #3a7bff; }
.meter[data-s="4"] i:nth-child(-n+4) { background: #12b886; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; flex-wrap: wrap; }
.auth-terms { font-size: 13px; color: var(--muted); align-items: flex-start; }
.auth-terms input { margin-top: 3px; }
.linkbtn { background: none; border: none; color: var(--accent); font-weight: 700; font-size: 14px; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
#authMsg { margin: 0; min-height: 1.3em; font-size: 14px; color: var(--danger); }
#authMsg.ok { color: var(--good); }
.auth-primary { background: var(--grad); color: #fff; border: none; border-radius: 12px; padding: 12px; font-weight: 800; font-size: 15px; box-shadow: 0 8px 22px rgba(91, 69, 245, .32); }
.auth-primary:disabled { opacity: .6; cursor: wait; }
.auth-secondary { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 11px; font-weight: 700; font-size: 14px; }
.auth-secondary:hover { background: var(--hover); }
.auth-back { align-self: center; }
.auth-or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-note { font-size: 12px; color: var(--muted); text-align: center; margin: 0; }
body.authing #side, body.authing #main { visibility: hidden; }

@media (max-width: 900px) {
  #auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-logo { display: block; }
}
@media (max-width: 760px) {
  #side { position: fixed; inset: 0 auto 0 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; display: flex !important; }
  body.open #side { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  #menu { display: inline-flex; }
  #collapse { display: none; }
  #welcome h1 { font-size: 30px; }
  #msgs, #comp { padding-left: 16px; padding-right: 16px; }
  .m.ai { padding-left: 0; }
  .m.ai::before { display: none; }
  .top-btn { padding: 6px 9px; }
  .pill span, .pill { font-size: 12px; }
}
