:root {
  --cyan: #25F4EE; --pink: #FF2D95; --red: #FE2C55;
  --grad: linear-gradient(135deg, #25F4EE, #FF2D95);
  --bg: #000; --s1: #0b0b0f; --s2: #121218; --line: rgba(255,255,255,0.07);
  --text: #F2F2F2; --muted: #8a8a99;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font-family: 'Sora', sans-serif; background: #000; color: var(--text); }

.app { display: flex; height: 100vh; height: 100dvh; position: relative; background:
  radial-gradient(ellipse at 10% 0%, rgba(37,244,238,0.09), transparent 45%),
  radial-gradient(ellipse at 95% 100%, rgba(255,45,149,0.10), transparent 45%), var(--bg); color: var(--text); }
.app.light { --bg: #fafafa; --s1: #ffffff; --s2: #f1f1f5; --line: rgba(0,0,0,0.08); --text: #141418; --muted: #6b6b78; }
.x-watermark { position: fixed; inset: 0; display: grid; place-items: center; font-family: 'Permanent Marker'; font-size: 70vh;
  color: rgba(255,255,255,0.018); pointer-events: none; user-select: none; transform: rotate(-8deg); }
.light .x-watermark { color: rgba(0,0,0,0.025); }
.text-muted { color: var(--muted); }
.text-cyan { color: var(--cyan); }

/* Badge */
.xen-badge { position: relative; border-radius: 50%; flex-shrink: 0; padding: 2px; background: var(--grad);
  box-shadow: -3px 0 14px rgba(37,244,238,0.45), 3px 0 14px rgba(255,45,149,0.45); }
.xen-badge img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; background: #000; }
.xen-badge.spin::before { content: ''; position: absolute; inset: -4px; border-radius: 50%;
  background: conic-gradient(var(--cyan), transparent 30%, var(--pink) 60%, transparent 85%, var(--cyan));
  z-index: -1; animation: rot 3s linear infinite; filter: blur(3px); }
@keyframes rot { to { transform: rotate(360deg); } }

.wordmark { position: relative; font-family: 'Permanent Marker', cursive; font-size: 1.6rem; line-height: 1;
  background: linear-gradient(180deg, #fff, #bdbdbd); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(-2px 0 0 var(--cyan)) drop-shadow(2px 0 0 var(--red)); padding-bottom: 4px; }
.light .wordmark { background: linear-gradient(180deg, #333, #000); -webkit-background-clip: text; background-clip: text; }
.wordmark::after { content: ''; position: absolute; left: 0; right: 10%; bottom: -2px; height: 3px; border-radius: 3px; background: var(--grad); transform: skewX(-20deg); }
.wordmark .chat { font-family: 'Sora'; font-weight: 200; font-size: 0.75em; margin-left: 4px; letter-spacing: 0.05em; }
.wordmark .crown { position: absolute; top: -12px; left: 18px; font-size: 0.55em; filter: none; -webkit-text-fill-color: initial; }

.glitch { text-shadow: -2px 0 var(--cyan), 2px 0 var(--red); }

/* Sidebar */
.sidebar { width: 280px; display: flex; flex-direction: column; background: var(--s1); border-right: 1px solid var(--line); z-index: 40; transition: transform .25s; }
@media (max-width: 767px) { .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); } .sidebar.open { transform: none; } }
.chat-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; cursor: pointer; border-left: 3px solid transparent; transition: .2s; }
.chat-item:hover { background: var(--s2); }
.chat-item.active { background: linear-gradient(90deg, rgba(37,244,238,0.10), rgba(255,45,149,0.08)); border-image: var(--grad) 1; border-left-width: 3px; }
.chat-item.active p:first-child { text-shadow: -1px 0 rgba(37,244,238,.6), 1px 0 rgba(254,44,85,.6); }
.del { color: var(--muted); transition: .2s; } .del:hover { color: var(--red); }
@media (hover: none) { .del { opacity: 1 !important; } }
.side-foot { padding: 14px; text-align: center; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); letter-spacing: .08em; }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--s1) 80%, transparent); backdrop-filter: blur(10px); }
.icon-btn { padding: 8px; border-radius: 10px; color: var(--muted); transition: .2s; }
.icon-btn:hover { color: var(--cyan); background: var(--s2); box-shadow: 0 0 12px rgba(37,244,238,.25); }
.icon-btn.pink:hover { color: var(--red); box-shadow: 0 0 12px rgba(254,44,85,.3); }
.icon-btn.gear:hover svg { transform: rotate(60deg); } .icon-btn svg { transition: transform .3s; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #555; }
.status-dot.ok { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.status-dot.error { background: var(--red); box-shadow: 0 0 8px var(--red); }
.status-dot.busy { background: var(--pink); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.messages { flex: 1; overflow-y: auto; padding: 20px 14px; }
.messages::-webkit-scrollbar { width: 6px; } .messages::-webkit-scrollbar-thumb { background: var(--grad); border-radius: 3px; }

.empty { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; animation: rise .6s ease both; }
.empty-title { font-family: 'Permanent Marker'; font-size: clamp(1.8rem, 5vw, 3rem); margin-top: 16px; text-shadow: -3px 0 var(--cyan), 3px 0 var(--red); }
.chip { padding: 8px 14px; border-radius: 999px; font-size: 13px; border: 1px solid var(--line); background: var(--s2); animation: rise .5s ease both; transition: .2s; color: var(--text); }
.chip:hover { border-color: var(--cyan); box-shadow: -3px 0 10px rgba(37,244,238,.3), 3px 0 10px rgba(255,45,149,.3); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.msg-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 18px; animation: rise .3s ease both; }
.bubble { max-width: 85%; padding: 12px 16px; border-radius: 14px; position: relative; min-width: 0; }
@media (min-width: 768px) { .bubble { max-width: 78%; } }
.b-user { background: rgba(254,44,85,0.14); border: 1px solid rgba(255,45,149,0.4); box-shadow: 0 0 18px rgba(255,45,149,0.12); border-bottom-right-radius: 4px; }
.b-ai { background: var(--s2); border: 1px solid var(--line); border-left: 3px solid var(--cyan); border-top-left-radius: 4px; }
.b-err { border-color: var(--red); border-left-color: var(--red); background: rgba(254,44,85,0.07); }
.msg-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 11px; color: var(--muted); opacity: 0; transition: .2s; }
.bubble:hover .msg-actions, .b-err .msg-actions { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: 1; } }
.msg-actions button:hover { color: var(--cyan); }
.usage { padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); font-family: 'JetBrains Mono'; }

.prose-x { line-height: 1.65; font-size: 0.95rem; overflow-wrap: anywhere; }
.prose-x p { margin: 0 0 .6em; } .prose-x p:last-child { margin: 0; }
.prose-x ul { list-style: disc; margin: 0 0 .6em 1.3em; } .prose-x ol { list-style: decimal; margin: 0 0 .6em 1.3em; }
.prose-x h1, .prose-x h2, .prose-x h3 { font-weight: 800; margin: .8em 0 .4em; text-shadow: -1px 0 var(--cyan), 1px 0 var(--red); }
.prose-x h1 { font-size: 1.4em; } .prose-x h2 { font-size: 1.2em; }
.prose-x strong { color: var(--pink); } .prose-x a { color: var(--cyan); text-decoration: underline; }
.prose-x code { font-family: 'JetBrains Mono'; font-size: .85em; background: rgba(37,244,238,.1); color: var(--cyan); padding: 1px 5px; border-radius: 5px; }
.prose-x blockquote { border-left: 3px solid var(--pink); padding-left: 12px; color: var(--muted); font-style: italic; }
.prose-x table { border-collapse: collapse; margin: .5em 0; } .prose-x td, .prose-x th { border: 1px solid var(--line); padding: 4px 8px; }

.code-wrap { margin: 10px 0; border-radius: 12px; overflow: hidden; border: 1px solid rgba(255,255,255,0.08); background: #07070b; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: #101018; font-family: 'JetBrains Mono'; font-size: 12px; color: #8a8a99; border-bottom: 1px solid rgba(255,255,255,.06); }
.code-wrap pre { margin: 0; padding: 14px; overflow-x: auto; }
.code-wrap code { font-family: 'JetBrains Mono'; font-size: 13px; background: transparent !important; padding: 0 !important; }
.btn-mini { display: flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; background: #1c1c26; color: #ccc; }
.btn-mini:hover { color: var(--cyan); }
.btn-launch { padding: 3px 10px; border-radius: 6px; background: var(--grad); color: #000; font-weight: 600; box-shadow: 0 0 12px rgba(255,45,149,.4); }
.btn-launch:hover { filter: brightness(1.15); }

.typing { display: flex; gap: 6px; padding: 14px 16px; background: var(--s2); border-radius: 14px; border-left: 3px solid var(--cyan); }
.typing i { width: 8px; height: 8px; border-radius: 50%; animation: dot 1.2s infinite; }
.typing i:nth-child(1) { background: var(--cyan); } .typing i:nth-child(2) { background: #fff; animation-delay: .15s; } .typing i:nth-child(3) { background: var(--pink); animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-7px); opacity: 1; } }

.composer { padding: 12px 14px 8px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--s1) 85%, transparent); }
.input-ring { display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 14px; border-radius: 16px; background: var(--s2); border: 1px solid var(--line); transition: .2s; }
.input-ring:focus-within { border-color: transparent; background: linear-gradient(var(--s2), var(--s2)) padding-box, var(--grad) border-box; box-shadow: -4px 0 16px rgba(37,244,238,.2), 4px 0 16px rgba(255,45,149,.2); }
.input-ring textarea { flex: 1; background: transparent; outline: none; resize: none; color: var(--text); font-family: inherit; font-size: 16px; padding: 6px 0; max-height: 220px; }
.send { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: #000; box-shadow: -3px 0 0 var(--cyan), 3px 0 0 var(--red); transition: .2s; flex-shrink: 0; }
.send:hover:not(:disabled) { transform: scale(1.07); }
.send:disabled { background: #2a2a33; color: #666; box-shadow: none; cursor: not-allowed; }
.footer { text-align: center; font-size: 11px; color: var(--muted); padding: 6px; }
.footer a { color: var(--text); transition: .2s; }
.footer a:hover { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 6px rgba(255,45,149,.6)); }

/* Buttons & form */
.btn-grad { padding: 9px 16px; border-radius: 12px; background: var(--grad); color: #000; font-weight: 600; transition: .2s; }
.btn-grad:hover { box-shadow: -4px 0 14px rgba(37,244,238,.5), 4px 0 14px rgba(255,45,149,.5); }
.btn-outline { padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--s2); color: var(--text); transition: .2s; }
.btn-outline:hover { border-color: var(--cyan); color: var(--cyan); }
.btn-danger { padding: 8px 14px; border-radius: 12px; border: 1px solid var(--red); color: var(--red); background: rgba(254,44,85,.08); }
.btn-danger:hover { background: var(--red); color: #fff; }
.x-input { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; color: var(--text); outline: none; font-family: inherit; font-size: 14px; }
.x-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(37,244,238,.12); }
.f-label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 6px; }
.card { padding: 16px; border-radius: 14px; background: var(--s2); border: 1px solid var(--line); margin-bottom: 14px; }
.pill { display: flex; padding: 4px; border-radius: 999px; background: var(--s2); margin-bottom: 14px; border: 1px solid var(--line); }
.pill button { flex: 1; padding: 8px; border-radius: 999px; color: var(--muted); font-weight: 600; transition: .2s; }
.pill .act-c { background: var(--cyan); color: #000; box-shadow: 0 0 14px rgba(37,244,238,.5); }
.pill .act-p { background: var(--pink); color: #000; box-shadow: 0 0 14px rgba(255,45,149,.5); }
.toggle { width: 46px; height: 26px; border-radius: 999px; background: #2a2a33; padding: 3px; transition: .2s; }
.toggle span { display: block; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle.on { background: var(--grad); } .toggle.on span { transform: translateX(20px); }
.x-range { width: 100%; -webkit-appearance: none; appearance: none; height: 6px; border-radius: 3px; background: var(--grad); outline: none; }
.x-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 0 10px var(--pink); cursor: pointer; }
.x-range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 10px var(--pink); }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 50; display: flex; justify-content: flex-end; animation: fade .2s; }
.overlay.center { justify-content: center; align-items: center; padding: 16px; }
.drawer { width: min(440px, 100%); height: 100%; overflow-y: auto; padding: 22px; background: var(--s1); border-left: 1px solid var(--line); animation: slide .3s ease; color: var(--text); }
.dialog { width: min(380px, 100%); padding: 24px; border-radius: 18px; background: var(--s1); color: var(--text); border: 1px solid var(--line); box-shadow: -10px 0 40px rgba(37,244,238,.15), 10px 0 40px rgba(255,45,149,.15); animation: rise .25s; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }