[hidden] { display: none !important; }
/* ============ THEMES ============ */
:root, [data-theme="galaxy"] {
  --bg: #05030f;
  --side: rgba(12, 8, 30, 0.72);
  --panel: rgba(255, 255, 255, 0.06);
  --panel-2: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.12);
  --text: #eef0ff;
  --muted: #a9aed0;
  --accent: #a66bff;
  --user-bg: linear-gradient(135deg, #4fd8ff, #a66bff 55%, #ff5fc8);
  --user-text: #fff;
  --code-bg: rgba(0, 0, 0, 0.45);
  --grad: linear-gradient(135deg, #4fd8ff, #a66bff 50%, #ff5fc8);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] {
  --bg: #141417;
  --side: #1b1b1f;
  --panel: #232328;
  --panel-2: #2c2c32;
  --border: #33333a;
  --text: #ececf1;
  --muted: #9a9aa5;
  --accent: #a66bff;
  --user-bg: #2f2f37;
  --user-text: #ececf1;
  --code-bg: #0e0e10;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
[data-theme="light"] {
  --bg: #f7f6fb;
  --side: #efedf6;
  --panel: #ffffff;
  --panel-2: #e9e6f3;
  --border: #dcd8ea;
  --text: #1b1830;
  --muted: #6b6787;
  --accent: #7b3fe4;
  --user-bg: #e6defa;
  --user-text: #1b1830;
  --code-bg: #1e1b2e;
  --shadow: 0 10px 40px rgba(40, 20, 90, 0.15);
}
:root { --font-scale: 1; --side-w: 280px; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Montserrat", "Segoe UI", system-ui, sans-serif;
  font-size: calc(15px * var(--font-scale));
  background: var(--bg); color: var(--text); overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }

/* galaxy background only in galaxy theme */
#stars { position: fixed; inset: 0; z-index: -1; }
[data-theme]:not([data-theme="galaxy"]) #stars { display: none; }
[data-theme="galaxy"] body::before {
  content: ""; position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(123, 63, 228, 0.35), transparent 50%),
    radial-gradient(ellipse at 85% 80%, rgba(255, 95, 200, 0.18), transparent 50%),
    radial-gradient(ellipse at 60% 40%, rgba(79, 216, 255, 0.12), transparent 60%);
}

/* ============ LAYOUT ============ */
.layout { display: flex; height: 100dvh; }
.sidebar {
  width: var(--side-w); flex-shrink: 0; display: flex; flex-direction: column; gap: 4px;
  background: var(--side); border-right: 1px solid var(--border); padding: 12px 10px;
  backdrop-filter: blur(14px);
}
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.side-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; }
.brand img { width: 32px; height: 32px; }

.side-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: 10px; color: var(--text);
}
.side-item:hover, .side-item.active { background: var(--panel-2); }
.side-item .ico { width: 20px; text-align: center; }
.side-item kbd { margin-left: auto; font-size: .68rem; color: var(--muted); font-family: inherit; }
.side-item.primary { font-weight: 700; }
.search { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; margin: 4px 0 6px; }
.search .ico { color: var(--muted); }
.search input { flex: 1; background: none; border: none; outline: none; padding: 9px 0; }
.side-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }

.side-section-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 4px; font-weight: 700;
}
.chat-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.group-label { font-size: .75rem; color: var(--muted); padding: 12px 10px 4px; text-transform: uppercase; letter-spacing: .05em; }
.chat-row {
  display: flex; align-items: center; border-radius: 10px; padding: 0 4px 0 10px; position: relative;
}
.chat-row:hover, .chat-row.active { background: var(--panel-2); }
.chat-row .name { flex: 1; padding: 8px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.chat-row .more { opacity: 0; padding: 4px 8px; border-radius: 6px; color: var(--muted); }
.chat-row:hover .more, .chat-row.active .more { opacity: 1; }
.chat-row .more:hover { background: var(--panel); color: var(--text); }
.chat-row input { flex: 1; background: var(--panel); border: 1px solid var(--accent); border-radius: 6px; padding: 6px 8px; outline: none; margin: 2px 0; }
.empty-list { color: var(--muted); padding: 14px 10px; font-size: .9rem; }

.side-bottom { border-top: 1px solid var(--border); padding-top: 10px; }
.brain-pill { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted); padding: 6px 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #f5b942; box-shadow: 0 0 8px currentColor; }
.dot.ready { background: #3ddc84; }
.dot.error { background: #ff5f5f; }

.icon-btn { padding: 6px 9px; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ============ TOP BAR ============ */
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; min-height: 56px; }
.chat-title { font-weight: 700; padding: 6px 10px; border-radius: 8px; cursor: text; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.chat-title:hover { background: var(--panel); }
.chat-title input { background: var(--panel); border: 1px solid var(--accent); border-radius: 6px; padding: 4px 8px; outline: none; font-weight: 700; width: 100%; }
.top-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.project-chip { font-size: .8rem; background: var(--panel); border: 1px solid var(--border); padding: 4px 10px; border-radius: 99px; }
.progress-strip { height: 3px; background: var(--panel); }
.progress-strip > div { height: 100%; width: 0; background: var(--grad, var(--accent)); transition: width .3s; }

/* ============ MESSAGES ============ */
.messages { flex: 1; overflow-y: auto; padding: 10px 16px 30px; }
.thread { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.msg { display: flex; gap: 12px; }
.msg.user { justify-content: flex-end; }
.msg .avatar { width: 30px; height: 30px; flex-shrink: 0; margin-top: 2px; }
.bubble { line-height: 1.65; word-wrap: break-word; min-width: 0; }
.msg.user .bubble { background: var(--user-bg); color: var(--user-text); padding: 10px 16px; border-radius: 18px 18px 4px 18px; max-width: 80%; white-space: pre-wrap; }
.msg.bot .bubble { flex: 1; }
.msg.bot .content > * + * { margin-top: .7em; }
.content h1, .content h2, .content h3 { font-size: 1.1em; }
.content ul, .content ol { padding-left: 1.4em; }
.content a { color: var(--accent); text-decoration: underline; }
.content code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; font-family: Consolas, "Cascadia Code", monospace; font-size: .9em; }
.content pre { background: var(--code-bg); color: #e8e6f5; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.content pre .code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; font-size: .75rem; color: #a9aed0; background: rgba(255,255,255,.05); }
.content pre .code-head button { color: #a9aed0; font-size: .75rem; }
.content pre .code-head button:hover { color: #fff; }
.content pre code { display: block; background: none; padding: 12px 14px; overflow-x: auto; white-space: pre; }
.content blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--muted); }
.typing-dots span { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .2s; } .typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

.msg-actions { display: flex; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg:last-child .msg-actions { opacity: 1; }
.msg-actions button { font-size: .8rem; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.msg-actions button:hover { background: var(--panel-2); color: var(--text); }
.msg.user .msg-actions { justify-content: flex-end; }

/* empty state */
.hello { max-width: 720px; margin: 8vh auto 0; text-align: center; }
.hello img { width: 96px; filter: drop-shadow(0 0 25px rgba(166,107,255,.55)); }
.hello h1 { font-size: 1.9rem; margin: 14px 0 6px; }
.hello p { color: var(--muted); }
.chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 28px; text-align: left; }
.chip { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px; color: var(--text); }
.chip:hover { background: var(--panel-2); }
.chip b { display: block; margin-bottom: 2px; }
.chip span { color: var(--muted); font-size: .88rem; }

/* composer */
.composer-wrap { padding: 0 16px calc(10px + env(safe-area-inset-bottom)); }
.composer {
  max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 22px; padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow);
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; resize: none; background: none; border: none; outline: none; padding: 8px 0; max-height: 200px; line-height: 1.5; }
.composer-actions { display: flex; gap: 6px; align-items: center; }
.send { width: 38px; height: 38px; border-radius: 50%; background: var(--grad, var(--accent)); color: #fff; font-size: 1.1rem; font-weight: 800; }
[data-theme="dark"] .send, [data-theme="light"] .send { background: var(--accent); }
.send:disabled { opacity: .4; cursor: default; }
.send.stop { background: var(--text); color: var(--bg); font-size: .8rem; }
.disclaimer { text-align: center; font-size: .72rem; color: var(--muted); margin-top: 8px; }

/* ============ MODAL / MENU / TOAST ============ */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--side); backdrop-filter: blur(20px); border: 1px solid var(--border); border-radius: 18px; width: min(560px, 100%); max-height: 88dvh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
[data-theme="dark"] .modal-card { background: #1e1e23; } [data-theme="light"] .modal-card { background: #fff; }
[data-theme="galaxy"] .modal-card { background: rgba(18, 12, 42, .95); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 8px; }
.modal-body { padding: 8px 20px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); margin-top: 4px; }
.field input[type=text], .field textarea, .field select {
  width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button { flex: 1; min-width: 100px; padding: 12px; border-radius: 12px; background: var(--panel); border: 2px solid var(--border); }
.seg button.on { border-color: var(--accent); background: var(--panel-2); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { width: 44px; height: 24px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--border); position: relative; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: .2s; }
.switch.on { background: var(--accent); } .switch.on::after { left: 22px; background: #fff; }
.btn { padding: 10px 16px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); font-weight: 600; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.danger { color: #ff6b6b; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.hr { height: 1px; background: var(--border); }
.project-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border); cursor: pointer; }
.project-card:hover { border-color: var(--accent); }
.project-card .emoji { font-size: 1.5rem; }
.project-card .info { flex: 1; min-width: 0; }
.project-card .info small { color: var(--muted); }

.menu { position: fixed; z-index: 60; background: var(--side); border: 1px solid var(--border); border-radius: 12px; padding: 6px; min-width: 190px; box-shadow: var(--shadow); backdrop-filter: blur(20px); }
[data-theme="galaxy"] .menu { background: rgba(18, 12, 42, .97); } [data-theme="light"] .menu { background: #fff; } [data-theme="dark"] .menu { background: #232328; }
.menu button { display: flex; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; }
.menu button:hover { background: var(--panel-2); }
.menu button.danger { color: #ff6b6b; }
.menu .sub { font-size: .75rem; color: var(--muted); padding: 6px 10px 2px; }

.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-weight: 600; z-index: 70; font-size: .9rem; }

/* ============ MOBILE ============ */
.only-mobile { display: none; }
.scrim { display: none; }
@media (max-width: 800px) {
  .only-mobile { display: inline-block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-100%); transition: transform .25s; width: min(300px, 85vw); }
  [data-theme="galaxy"] .sidebar { background: rgba(10, 6, 26, .97); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 39; }
  .chat-row .more { opacity: 1; }
  .side-item kbd { display: none; }
  .msg .avatar { display: none; }
  .hello { margin-top: 4vh; }
}

/* ============ IMAGES ============ */
.attach-row { max-width: 780px; margin: 0 auto 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.attach-row .thumb { position: relative; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.attach-row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-row .thumb button { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.7); color: #fff; font-size: .7rem; line-height: 20px; }
.composer .attach-btn { align-self: flex-end; margin-left: -8px; }
.composer-wrap.drag .composer { border-color: var(--accent); border-style: dashed; }
.msg-images { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 6px; }
.msg-images img { max-width: 220px; max-height: 220px; border-radius: 14px; border: 1px solid var(--border); cursor: zoom-in; object-fit: cover; }
.lightbox img { max-width: 100%; max-height: 75dvh; border-radius: 12px; display: block; margin: 0 auto; }

/* ============ VOICE ============ */
.icon-btn.recording { background: #e5484d; color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,72,77,.6); } 50% { box-shadow: 0 0 0 8px rgba(229,72,77,0); } }
.voice { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px;
  background: radial-gradient(ellipse at 50% 40%, #3a1d7a, #05030f 70%); color: #fff; text-align: center; }
[data-theme="light"] .voice { background: radial-gradient(ellipse at 50% 40%, #e3d6ff, #f7f6fb 70%); color: var(--text); }
[data-theme="light"] .voice-btns button:not(.end) { background: rgba(0,0,0,.06); border-color: rgba(0,0,0,.12); }
.voice-orb { --level: 0; width: 200px; height: 200px; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
  transform: scale(calc(1 + var(--level) * .35)); transition: transform .08s linear;
  box-shadow: 0 0 calc(40px + var(--level) * 120px) rgba(166,107,255,.8), 0 0 0 6px rgba(255,255,255,.08); }
.voice-orb img { width: 100%; height: 100%; }
.voice.thinking .voice-orb { animation: spin 2.4s linear infinite; }
.voice.speaking .voice-orb { animation: breathe 1.4s ease-in-out infinite; }
@keyframes spin { to { rotate: 360deg; } }
@keyframes breathe { 50% { transform: scale(1.12); } }
.voice-state { font-size: 1.4rem; font-weight: 800; }
.voice-text { max-width: 620px; min-height: 3em; opacity: .8; line-height: 1.5; max-height: 30dvh; overflow-y: auto; }
.voice-btns { display: flex; gap: 12px; }
.voice-btns button { padding: 14px 24px; border-radius: 99px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); color: inherit; font-weight: 700; }
.voice-btns button.on { background: #e5484d; }
.voice-btns .end { background: #e5484d; border-color: transparent; color: #fff; }

/* ============ ACCOUNT ============ */
.account { margin-bottom: 6px; }
.account a.signin { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--border); font-weight: 700; }
.account a.signin:hover { border-color: var(--accent); }
.account .me { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; cursor: pointer; width: 100%; text-align: left; }
.account .me:hover { background: var(--panel-2); }
.account .me img, .account .me .ph { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.account .me .ph { display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; }
.account .me .who { min-width: 0; }
.account .me .who b, .account .me .who small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account .me .who small { color: var(--muted); font-size: .75rem; }
.mem-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.mem-item { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.mem-item span { flex: 1; line-height: 1.4; }
.mem-add { display: flex; gap: 8px; margin-top: 8px; }
.mem-add input { flex: 1; }

/* ============ TABLES & CHECKLISTS ============ */
.content .table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.content table { border-collapse: collapse; width: 100%; font-size: .93em; }
.content th, .content td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.content th { background: var(--panel-2); font-weight: 700; }
.content tr:last-child td { border-bottom: none; }
.content tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--panel) 60%, transparent); }
.content ul.checklist { list-style: none; padding-left: 0; }
.content ul.checklist li { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0; }
.content ul.checklist .box { width: 20px; height: 20px; flex-shrink: 0; border-radius: 6px; border: 2px solid var(--accent); display: grid; place-items: center; font-size: .8rem; font-weight: 800; margin-top: 2px; }
.content ul.checklist li.done .box { background: var(--accent); color: #fff; }
.content ul.checklist li.done > span:last-child { text-decoration: line-through; color: var(--muted); }
.content hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

.share-btn { font-size: .85rem; border: 1px solid var(--border); }

/* ============ PLANS ============ */
.upgrade-btn { display: block; text-align: center; padding: 10px; margin-bottom: 8px; border-radius: 12px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #4fd8ff, #a66bff 50%, #ff5fc8); box-shadow: 0 0 24px rgba(166,107,255,.4); }
.plan-badge { font-size: .65rem; font-weight: 800; padding: 2px 7px; border-radius: 99px; vertical-align: middle; margin-left: 4px; background: var(--panel-2); color: var(--muted); }
.plan-badge.pro { background: #a66bff; color: #fff; }
.plan-badge.max { background: linear-gradient(135deg, #4fd8ff, #ff5fc8); color: #fff; }
.mini-plans { display: grid; gap: 10px; }
.mini-plan { padding: 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--border); }
.mini-plan.max { border-color: var(--accent); }
.mini-plan b { display: block; margin-bottom: 4px; }
.mini-plan span { color: var(--muted); font-size: .9rem; }

/* ============ OWNER ============ */
.owner-btn { opacity: .45; }
.owner-btn:hover, .owner-btn.on { opacity: 1; }
.owner-btn.on { background: linear-gradient(135deg, rgba(255,200,60,.25), rgba(255,95,200,.2)); }
.own-err { color: #ff6b6b; min-height: 1.2em; font-size: .9rem; }
.own-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.own-stat { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 12px; text-align: center; }
.own-stat b { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 1.5rem; }
.own-stat span { color: var(--muted); font-size: .78rem; }
.own-stat i.live { width: 9px; height: 9px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 10px #3ddc84; animation: blink 1.6s infinite; }
.own-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.own-row { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.own-row span { flex: 1; min-width: 0; }
.own-row b, .own-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.own-row small { color: var(--muted); font-size: .78rem; }
.own-note { color: var(--muted); font-size: .9rem; }
@media (max-width: 520px) { .own-grid { grid-template-columns: repeat(2, 1fr); } }

/* ============ THINKING & STEPS ============ */
.activity:empty { display: none; }
.activity { margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.think { border: 1px solid var(--border); border-radius: 12px; background: var(--panel); overflow: hidden; }
.think summary { cursor: pointer; list-style: none; padding: 8px 12px; font-size: .88rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.think summary::after { content: "›"; margin-left: auto; transition: transform .2s; font-size: 1.1rem; }
.think[open] summary::after { transform: rotate(90deg); }
.think-text { padding: 0 12px 12px; font-size: .84rem; color: var(--muted); line-height: 1.55; max-height: 260px; overflow-y: auto; border-top: 1px solid var(--border); padding-top: 10px; }
.think-peek { font-size: .8rem; color: var(--muted); opacity: .75; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; mask-image: linear-gradient(90deg, transparent, #000 15%); }
.shimmer { background: linear-gradient(90deg, var(--muted) 30%, var(--text) 50%, var(--muted) 70%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.steps { display: flex; flex-direction: column; gap: 4px; }
.step { display: flex; align-items: center; gap: 8px; font-size: .84rem; color: var(--muted); padding: 2px 4px; }
.step.live { color: var(--text); }
.step.live::after { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent); border-top-color: transparent; animation: spin 0.8s linear infinite; }
.gen-images:empty { display: none; }
.gen-images { display: grid; gap: 10px; margin-top: 10px; max-width: 420px; }
.gen-img { margin: 0; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); background: var(--panel); position: relative; }
.gen-img img { display: block; width: 100%; cursor: zoom-in; }
.gen-img figcaption { position: absolute; right: 8px; bottom: 8px; }
.gen-img figcaption button { background: rgba(0,0,0,.65); color: #fff; padding: 6px 10px; border-radius: 99px; font-size: .78rem; }
.gen-img.loading { aspect-ratio: 1; display: grid; place-items: center; }
.gen-img.loading span { position: relative; color: var(--muted); font-weight: 600; font-size: .9rem; }
.gen-shimmer { position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(166,107,255,.25) 50%, transparent 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }

/* Upgrade button in the top bar */
.top-upgrade { display: inline-flex; align-items: center; gap: 4px; padding: 7px 14px; border-radius: 999px; font-weight: 800; font-size: .88rem; color: #fff; white-space: nowrap;
  background: linear-gradient(135deg, #4fd8ff, #a66bff 50%, #ff5fc8); box-shadow: 0 0 18px rgba(166,107,255,.45); transition: transform .15s, box-shadow .15s; }
.top-upgrade:hover { transform: translateY(-1px); box-shadow: 0 0 28px rgba(166,107,255,.7); }
.top-upgrade[hidden] { display: none !important; }
@media (max-width: 520px) { .top-upgrade { padding: 6px 10px; font-size: .8rem; } }

/* rank chip */
.rank-chip { border: none; cursor: pointer; padding: 7px 13px; border-radius: 999px; font: inherit; font-weight: 800; font-size: .86rem; color: #fff; white-space: nowrap; }
.rank-chip.rank-pro { background: linear-gradient(135deg, #4fd8ff, #a66bff); box-shadow: 0 0 16px rgba(79,216,255,.4); }
.rank-chip.rank-max { background: linear-gradient(135deg, #a66bff, #ff5fc8); box-shadow: 0 0 18px rgba(255,95,200,.45); }
.rank-chip.rank-owner { background: linear-gradient(135deg, #ffd84f, #ff9f43 50%, #ff5fc8); color: #2a1300; box-shadow: 0 0 18px rgba(255,200,60,.5); }
.rank-chip[hidden] { display: none !important; }
h2.rank-pro { background: linear-gradient(135deg, #4fd8ff, #a66bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2.rank-max { background: linear-gradient(135deg, #a66bff, #ff5fc8); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2.rank-owner { background: linear-gradient(135deg, #ffd84f, #ff5fc8); -webkit-background-clip: text; background-clip: text; color: transparent; }
/* announcement bar */
.announce { display: flex; align-items: center; gap: 10px; margin: 0 16px 6px; padding: 10px 14px; border-radius: 14px; font-weight: 600;
  background: linear-gradient(135deg, rgba(79,216,255,.18), rgba(166,107,255,.22) 50%, rgba(255,95,200,.18)); border: 1px solid rgba(166,107,255,.5); box-shadow: 0 0 24px rgba(166,107,255,.25); }
.announce[hidden] { display: none !important; }
.announce #announceText { flex: 1; line-height: 1.4; word-break: break-word; }
.announce button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; }
.announce.pop { animation: annpop .6s ease; }
@keyframes annpop { 0% { transform: translateY(-14px) scale(.96); opacity: 0; } 60% { transform: translateY(2px) scale(1.01); opacity: 1; } 100% { transform: none; } }
.ann-icon { font-size: 1.2rem; }
/* gift popup */
.gift-pop { text-align: center; }
.gift-pop h2 { font-size: 1.9rem; margin: 6px 0; font-weight: 900; }
.gift-box { font-size: 4rem; animation: giftbounce 1s ease infinite; }
@keyframes giftbounce { 50% { transform: translateY(-8px) rotate(-6deg); } }
.gift-perks { list-style: none; display: grid; gap: 6px; margin: 14px auto; max-width: 280px; text-align: left; }
.gift-perks li::before { content: "✓ "; color: var(--accent); font-weight: 900; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105%; transform: translateX(40px) rotate(720deg); } }
/* owner: players */
.own-row .pnum { font-weight: 900; }
.own-row .tag { display: inline-block; font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 99px; margin-left: 6px; vertical-align: middle; }
.tag.pro { background: rgba(79,216,255,.2); color: #4fd8ff; } .tag.max { background: rgba(255,95,200,.2); color: #ff8fd8; } .tag.owner { background: rgba(255,200,60,.2); color: #ffd84f; }
.own-row .mini { padding: 6px 10px; font-size: .85rem; }
#annText { width: 100%; min-height: 64px; resize: vertical; }

/* 💬 talk to the owner */
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: #ff4d6d; color: #fff; font-size: .7rem; font-weight: 900; margin-left: auto; box-shadow: 0 0 10px rgba(255,77,109,.6); }
.badge[hidden] { display: none !important; }
.inbox-btn { position: relative; }
.inbox-btn .badge { position: absolute; top: -4px; right: -4px; margin: 0; }
.inbox-btn[hidden] { display: none !important; }
.main { position: relative; }
.talk-bubble { position: absolute; right: 18px; bottom: 118px; z-index: 5; display: flex; align-items: center; gap: 10px; border: 1px solid rgba(166,107,255,.6); cursor: pointer;
  padding: 10px 12px 10px 16px; border-radius: 18px 18px 4px 18px; font: inherit; font-size: .9rem; color: var(--text);
  background: linear-gradient(135deg, rgba(79,216,255,.22), rgba(166,107,255,.3) 50%, rgba(255,95,200,.22)); backdrop-filter: blur(10px); box-shadow: 0 0 24px rgba(166,107,255,.35); animation: bubblein .5s ease, bob2 3s ease-in-out 1s infinite; }
.talk-bubble[hidden] { display: none !important; }
.talk-bubble i { font-style: normal; color: var(--muted); padding: 2px 4px; }
@keyframes bubblein { from { transform: translateY(16px); opacity: 0; } }
@keyframes bob2 { 50% { transform: translateY(-4px); } }
@media (max-width: 700px) { .talk-bubble { right: 10px; bottom: 112px; font-size: .82rem; } }
.dm { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; min-height: 160px; overflow-y: auto; padding: 10px; border-radius: 14px; background: rgba(0,0,0,.2); border: 1px solid var(--border); }
.dm .b { max-width: 82%; padding: 8px 12px; border-radius: 16px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.dm .b small { display: block; font-size: .68rem; opacity: .7; margin-top: 3px; }
.dm .me { align-self: flex-end; background: linear-gradient(135deg, #4fd8ff, #a66bff 55%, #ff5fc8); color: #fff; border-bottom-right-radius: 4px; }
.dm .them { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.dm .who { font-size: .72rem; font-weight: 800; color: #ffd84f; margin-bottom: 2px; }
.dm-empty { margin: auto; text-align: center; color: var(--muted); font-size: .9rem; }
.dm-send { display: flex; gap: 8px; margin-top: 10px; }
.dm-send textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; }
.dm-thread { cursor: pointer; }
.dm-thread.unread b { color: #fff; }
.dm-thread .dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; display: inline-block; margin-right: 4px; }
.own-list .own-row { width: 100%; align-self: stretch; text-align: left; }
.dm-thread .badge { margin-left: 8px; flex: none; }
.dm-send textarea, #annText { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; font: inherit; outline: none; }
.dm-send textarea:focus, #annText:focus { border-color: var(--accent); }
.own-row.dm-thread { display: flex !important; flex-wrap: nowrap; justify-content: flex-start; }
.own-row.dm-thread > span:first-child { flex: 1 1 auto; text-align: left; }
.own-row.dm-thread > .badge { flex: 0 0 auto; min-width: 20px; }
.own-row.dm-thread b, .own-row.dm-thread small { text-align: left; }

/* nickname gate */
.nick-gate { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: rgba(5,3,15,.82); backdrop-filter: blur(14px); }
.nick-gate[hidden] { display: none !important; }
.nick-card { width: min(400px, 100%); text-align: center; background: var(--side, #120a2a); border: 1px solid rgba(166,107,255,.5); border-radius: 24px; padding: 28px 24px 20px;
  box-shadow: 0 0 70px rgba(166,107,255,.35); display: flex; flex-direction: column; gap: 10px; animation: bubblein .4s ease; }
.nick-card img { width: 84px; height: 84px; margin: 0 auto; filter: drop-shadow(0 0 22px rgba(166,107,255,.7)); }
.nick-card h2 { font-size: 1.45rem; }
.nick-card p { color: var(--muted); }
.grad-text { background: linear-gradient(135deg, #4fd8ff, #a66bff 50%, #ff5fc8); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nick-card input { text-align: center; font: inherit; font-size: 1.15rem; font-weight: 700; padding: 13px; border-radius: 14px; outline: none;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); }
.nick-card input:focus { border-color: var(--accent, #a66bff); box-shadow: 0 0 0 3px rgba(166,107,255,.25); }
.nick-card input.shake { animation: shake .35s; border-color: #ff4d6d; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.nick-err { color: #ff6b81 !important; min-height: 1.2em; font-size: .88rem; font-weight: 600; }
.nick-card .btn { padding: 13px; font-size: 1rem; }
.nick-card small { color: var(--muted); font-size: .76rem; line-height: 1.5; }

/* files + web search */
.file-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; padding: 7px 10px; border-radius: 12px; font-size: .85rem; font-weight: 600;
  background: var(--panel); border: 1px solid var(--border); }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button { background: none; border: none; color: var(--muted); cursor: pointer; }
.attach-row .file-chip { align-self: center; }
.msg-files { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.search-btn.on { background: linear-gradient(135deg, rgba(79,216,255,.35), rgba(166,107,255,.35)); box-shadow: 0 0 14px rgba(79,216,255,.5); opacity: 1; }
.searching { color: var(--muted); animation: blink 1.4s infinite; }
.more-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.more-row[hidden] { display: none !important; }
.more-row button { padding: 6px 12px; border-radius: 99px; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--text);
  background: var(--panel); border: 1px solid var(--border); transition: border-color .15s, transform .15s; }
.more-row button:hover { border-color: var(--accent); transform: translateY(-1px); }
/* phone-size fixes: roomier top bar + composer */
@media (max-width: 520px) {
  .topbar { gap: 6px; padding: 8px 10px; }
  .chat-title { flex: 1; min-width: 0; max-width: none; padding: 6px 4px; }
  .top-actions { gap: 4px; flex-shrink: 0; }
  .share-btn { padding: 6px 8px; white-space: nowrap; }
  .share-btn .lbl { display: none; }
  .top-upgrade { padding: 6px 10px; }
  .composer { gap: 4px; }
  .composer-actions { gap: 2px; }
  .composer .icon-btn { padding: 6px 6px; }
  .composer textarea { min-width: 0; }
}

/* computer helper */
.beta { font-size: .65rem; font-weight: 800; padding: 2px 6px; border-radius: 99px; background: rgba(166,107,255,.25); color: #cdb4ff; margin-left: auto; }
.folder-chip { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 8px 12px; border-radius: 14px; font-size: .88rem;
  background: linear-gradient(135deg, rgba(79,216,255,.14), rgba(166,107,255,.18)); border: 1px solid rgba(79,216,255,.4); }
.folder-chip[hidden] { display: none !important; }
.folder-chip span { color: var(--muted); flex: 1; }
.folder-chip button { background: none; border: none; color: var(--muted); cursor: pointer; }
.extras:empty { display: none; }
.extras { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.act-links { display: flex; flex-wrap: wrap; gap: 8px; }
.act-link { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 99px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #4fd8ff, #a66bff 50%, #ff5fc8); box-shadow: 0 0 18px rgba(166,107,255,.4); }
.timer-chip { align-self: flex-start; padding: 10px 16px; border-radius: 14px; background: var(--panel); border: 1px solid var(--border); font-size: 1rem; }
.timer-chip .tleft { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--accent); }
.timer-chip.done { border-color: #3ddc84; }
.plan-card { border-radius: 16px; padding: 14px 16px; background: var(--panel); border: 1px solid rgba(166,107,255,.5); }
.plan-card.done { border-color: rgba(61,220,132,.6); }
.plan-card.cancelled { opacity: .6; }
.plan-head { font-weight: 700; margin-bottom: 8px; }
.plan-card ul { list-style: none; display: grid; gap: 6px; margin-bottom: 10px; font-size: .9rem; max-height: 260px; overflow-y: auto; }
.plan-card li { padding: 6px 10px; border-radius: 10px; background: rgba(0,0,0,.2); word-break: break-word; }
.plan-card small { color: var(--muted); display: block; margin-top: 6px; }
.folder-chip { max-width: 780px; width: 100%; margin: 0 auto 8px; }

/* build a project */
.build-card { border-radius: 16px; padding: 14px 16px; background: var(--panel); border: 1px solid rgba(79,216,255,.45); }
.build-card .plan-head small { color: var(--muted); font-weight: 600; margin-left: 6px; }
.proj-files { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.proj-file { font: inherit; font-size: .82rem; padding: 6px 10px; border-radius: 10px; cursor: pointer; color: var(--text); background: rgba(0,0,0,.25); border: 1px solid var(--border); }
.proj-file:hover { border-color: var(--accent); }
.build-card .btn-row { flex-wrap: wrap; }
.file-view { max-height: 60vh; overflow: auto; background: rgba(0,0,0,.35); border-radius: 12px; padding: 12px; font-size: .82rem; white-space: pre; }
.modal.wide .modal-card { width: min(1100px, 100%); }
.preview-wrap { border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: #fff; }
.preview-frame { display: block; width: 100%; height: min(68vh, 720px); border: 0; background: #fff; }
.build-idea { width: 100%; min-height: 110px; margin-top: 10px; resize: vertical; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 12px; font: inherit; outline: none; }
.build-idea:focus { border-color: var(--accent); }
.build-ideas { display: flex; flex-wrap: wrap; gap: 6px; }
.build-ideas button { font: inherit; font-size: .82rem; padding: 6px 12px; border-radius: 99px; cursor: pointer; color: var(--text); background: var(--panel); border: 1px solid var(--border); }
.build-ideas button:hover { border-color: var(--accent); }
.code-head button + button { margin-left: 6px; }
.writing { margin-top: 10px; padding: 10px 14px; border-radius: 12px; background: var(--panel); border: 1px dashed rgba(79,216,255,.5); color: var(--muted); animation: blink 1.4s infinite; }
.dm .who.mine { color: rgba(255,255,255,.85); text-align: right; }
.rank-chip.rank-owner { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }

/* coding friends */
.fr-row { display: flex; gap: 8px; }
.fr-row input { flex: 1; min-width: 0; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font: inherit; outline: none; }
.fr-row input:focus { border-color: var(--accent); }
.rm-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.rm-code { font: inherit; font-weight: 800; font-size: .85rem; padding: 4px 10px; border-radius: 99px; cursor: pointer; color: var(--text); background: rgba(79,216,255,.15); border: 1px solid rgba(79,216,255,.45); margin-left: 6px; }
.rm-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.rm-members { display: flex; flex-wrap: wrap; gap: 6px; }
.rm-mem { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 99px; font-size: .82rem; background: var(--panel); border: 1px solid var(--border); color: var(--muted); }
.rm-mem.on { color: var(--text); border-color: rgba(61,220,132,.5); }
.rm-mem button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0 2px; }
.rm-mem .dot, .dm-thread .dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; display: inline-block; }
.rm-msgs { max-height: 50vh; min-height: 260px; }
.rm-sys { align-self: center; font-size: .78rem; color: var(--muted); padding: 2px 10px; }
.dm .b.pinged { box-shadow: 0 0 0 2px #ffd84f; }
.dm .at { color: #ffd84f; }
.dm .me .at { color: #fff; text-decoration: underline; }
.rm-ai { max-width: 92% !important; }
.rm-ai-body { line-height: 1.5; }
.rm-ai-body pre { max-height: 240px; overflow: auto; }
.rm-proj:empty { display: none; }
.rm-proj { margin-top: 8px; }
.rm-tips { display: flex; flex-wrap: wrap; gap: 6px; }
.rm-tips button { font: inherit; font-size: .8rem; padding: 6px 12px; border-radius: 99px; cursor: pointer; color: var(--text); background: var(--panel); border: 1px solid var(--border); }
.rm-tips .danger-txt { color: #ff6b81; margin-left: auto; }
.btn.danger { background: #e5484d; color: #fff; border-color: #e5484d; }
.call-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 120; display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 18px; border-radius: 99px;
  background: linear-gradient(135deg, rgba(61,220,132,.25), rgba(79,216,255,.25)); border: 1px solid rgba(61,220,132,.6); backdrop-filter: blur(14px); box-shadow: 0 10px 40px rgba(0,0,0,.5); font-size: .9rem; max-width: calc(100vw - 24px); }
.call-bar button { font: inherit; font-weight: 700; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; }
.call-bar .leave { background: #e5484d; border-color: #e5484d; color: #fff; }
.rank-chip.rank-sup { background: linear-gradient(135deg, #ff5fc8, #ff8f6b); box-shadow: 0 0 16px rgba(255,95,200,.45); }

/* invites */
.inv-hero { text-align: center; }
.inv-gift { font-size: 3.4rem; animation: giftbounce 1.2s ease infinite; }
.inv-hero h2 { font-size: 1.5rem; margin: 6px 0 4px; }
.inv-bar { height: 14px; border-radius: 99px; background: var(--panel); border: 1px solid var(--border); overflow: hidden; }
.inv-bar > div { height: 100%; background: linear-gradient(90deg, #4fd8ff, #a66bff, #ff5fc8); border-radius: 99px; transition: width .6s; }
.inv-count { text-align: center; }
.call-bar[hidden] { display: none !important; }
@media (max-width: 560px) {
  .call-bar { top: 10px; bottom: auto; padding: 6px 6px 6px 12px; font-size: .8rem; gap: 6px; }
  .call-bar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
  .call-bar button { padding: 5px 10px; }
  .rm-actions .btn { padding: 8px 12px; font-size: .85rem; }
  .rm-msgs { max-height: 42vh; min-height: 200px; }
}
.call-bar .hear { background: #3ddc84; border-color: #3ddc84; color: #04210f; animation: blink 1.2s infinite; }
.rank-chip.rank-admin { background: linear-gradient(135deg, #3ddc84, #4fd8ff); color: #04210f; box-shadow: 0 0 16px rgba(61,220,132,.45); }
.adm-wallet { text-align: center; padding: 14px; border-radius: 16px; background: linear-gradient(135deg, rgba(255,216,79,.15), rgba(255,159,67,.12)); border: 1px solid rgba(255,216,79,.45); }
.adm-coins { font-size: 2.6rem; font-weight: 900; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* 📋 review plans + 💖 donate */
.upgrade-btn.review, .top-upgrade.review { background: rgba(166,107,255,.14) !important; border: 1px solid rgba(166,107,255,.45); box-shadow: none; }
.donate-btn { display: block; text-align: center; padding: 8px; margin-bottom: 8px; border-radius: 12px; font-weight: 700; font-size: .86rem;
  color: #ffd6ea; background: rgba(255,92,170,.12); border: 1px solid rgba(255,92,170,.4); text-decoration: none; }
.donate-btn:hover { background: rgba(255,92,170,.22); }
.donate-btn[hidden] { display: none !important; }
