* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Bricolage Grotesque', sans-serif; overflow: hidden; }

.theme-dark {
  --bg: #12121f; --bg2: #1a1a2e; --bg3: #23233a; --text: #f1f0f7; --muted: #9a98b5;
  --accent: #7c3aed; --accent2: #a78bfa; --hot: #ec4899; --border: #2e2e48;
  --user: linear-gradient(135deg, #7c3aed, #a855f7); --user-text: #fff;
  --appbg: radial-gradient(circle at 20% 0%, #2a1a4a 0%, #12121f 55%);
}
.theme-light {
  --bg: #ffffff; --bg2: #ffffff; --bg3: #f4f3f8; --text: #222230; --muted: #6b6a7d;
  --accent: #7c3aed; --accent2: #7c3aed; --hot: #7c3aed; --border: #e6e4ef;
  --user: #ede7fd; --user-text: #2b1a5a;
  --appbg: #fbfaff;
}
.theme-pink {
  --bg: #faf7f5; --bg2: #ffffff; --bg3: #ffffff; --text: #2b2426; --muted: #8a8a8a;
  --accent: #ec6f9a; --accent2: #ec6f9a; --hot: #d62828; --border: #e8dfdc;
  --user: #f4a7b9; --user-text: #3a1520;
  --appbg:
    linear-gradient(#ddd6d3 1px, transparent 1px) 0 0 / 120px 120px,
    linear-gradient(90deg, #ddd6d3 1px, transparent 1px) 0 0 / 120px 120px,
    #faf7f5;
}

.app { display: flex; height: 100vh; height: 100dvh; background: var(--appbg); color: var(--text); }
.display { font-family: 'Archivo Black', sans-serif; letter-spacing: -0.02em; }
.theme-pink .display { text-transform: uppercase; color: var(--hot); }
.brand { font-size: 1.35rem; color: var(--accent2); }

.sidebar { width: 288px; display: flex; flex-direction: column; background: var(--bg2); border-right: 1px solid var(--border); z-index: 40; transition: transform .3s; }
.theme-pink .sidebar { background: linear-gradient(180deg, rgba(217,185,138,.28), rgba(217,185,138,.12)), #fffaf3; }
@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: .6rem; padding: .65rem .75rem; border-radius: 14px; cursor: pointer; border: 1px solid transparent; transition: .15s; }
.chat-item:hover { background: var(--bg3); border-color: var(--border); }
.chat-item.active { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: var(--accent); }
.chat-item .del { opacity: 0; color: var(--muted); transition: .15s; }
.chat-item:hover .del { opacity: 1; }
.chat-item .del:hover { color: #d62828; }
.side-thumb { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.header { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1rem; background: color-mix(in srgb, var(--bg2) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.icon-btn { padding: .5rem; border-radius: 10px; color: var(--muted); transition: .15s; }
.icon-btn:hover { color: var(--accent2); background: var(--bg3); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot-ok { background: #22c55e; } .dot-err { background: #d62828; } .dot-busy { background: #f59e0b; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.logo { width: 36px; height: 36px; display: grid; place-items: center; }
.cap-drop { animation: capdrop .6s cubic-bezier(.3,1.6,.5,1) both; transform: rotate(-15deg); }
@keyframes capdrop { from { transform: translateY(-40px) rotate(-60deg); opacity: 0; } to { transform: translateY(0) rotate(-15deg); opacity: 1; } }

.btn-primary { background: var(--accent); color: #fff; padding: .55rem 1rem; border-radius: 999px; font-weight: 600; transition: .15s; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost { background: var(--bg3); color: var(--text); padding: .55rem 1rem; border-radius: 999px; border: 1px solid var(--border); }
.btn-danger { background: #d62828; color: #fff; padding: .55rem 1rem; border-radius: 999px; font-weight: 600; }

.messages { flex: 1; overflow-y: auto; padding: 1.25rem 1rem; }
.bubble { max-width: 85%; padding: .9rem 1.1rem; border-radius: 22px; position: relative; }
@media (min-width: 768px) { .bubble { max-width: 75%; } }
.b-user { background: var(--user); color: var(--user-text); border-bottom-right-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.b-ai { background: var(--bg3); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.b-err { border-color: #d62828; }
.ai-tag { font-size: .72rem; font-weight: 800; color: var(--accent2); margin-bottom: .35rem; letter-spacing: .04em; text-transform: uppercase; }
.meta { display: flex; gap: .6rem; align-items: center; margin-top: .5rem; font-size: .72rem; opacity: 0; transition: .2s; color: inherit; }
.b-ai .meta { color: var(--muted); }
.group:hover .meta, .b-err .meta { opacity: .75; }
.retry { display: inline-flex; align-items: center; gap: 2px; color: #d62828; font-weight: 700; }
.msg-in { animation: msgin .3s ease both; }
@keyframes msgin { from { opacity: 0; transform: translateY(8px); } }
.thumb { width: 130px; height: 130px; object-fit: cover; border-radius: 14px; cursor: zoom-in; border: 2px solid rgba(255,255,255,.5); }

.msg-content { line-height: 1.65; }
.prose-b p { margin-bottom: .55rem; } .prose-b p:last-child { margin-bottom: 0; }
.prose-b ul { list-style: disc; margin: 0 0 .5rem 1.4rem; } .prose-b ol { list-style: decimal; margin: 0 0 .5rem 1.4rem; }
.prose-b h1, .prose-b h2, .prose-b h3 { font-weight: 800; margin: .8rem 0 .4rem; color: var(--accent2); }
.prose-b a { color: var(--hot); text-decoration: underline; }
.prose-b strong { color: var(--hot); }
.prose-b code { background: color-mix(in srgb, var(--accent) 15%, transparent); padding: .1rem .35rem; border-radius: 5px; font-family: 'JetBrains Mono', monospace; font-size: .85em; }
.prose-b blockquote { border-left: 3px solid var(--accent); padding-left: .8rem; color: var(--muted); }

.code-wrap { border-radius: 14px; overflow: hidden; background: #1e1e2e; border: 1px solid #333348; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: .4rem .75rem; background: #16161f; font-family: 'JetBrains Mono', monospace; font-size: .72rem; color: #9a98b5; }
.code-wrap pre { padding: .9rem; overflow-x: auto; margin: 0; }
.code-wrap code { font-family: 'JetBrains Mono', monospace; font-size: .82rem; background: transparent !important; padding: 0 !important; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: .25rem .6rem; font-size: .72rem; border-radius: 999px; background: #2a2a3c; color: #ddd; }
.chip-launch { background: #d62828; color: #fff; font-weight: 700; }
.drawer .chip { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }

.typing { display: flex; gap: 5px; padding: .8rem 1rem; background: var(--bg3); border: 1px solid var(--border); border-radius: 18px; width: fit-content; margin-bottom: 1rem; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(-7px); } }

.welcome { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2rem 0; }
.hello-word { font-family: 'Archivo Black', sans-serif; font-size: clamp(3rem, 11vw, 6.5rem); line-height: 1; color: var(--hot); animation: hello .6s ease both; letter-spacing: -0.03em; }
.theme-pink .hello-word { text-transform: uppercase; text-shadow: 4px 4px 0 #f4a7b9; }
.wave { display: inline-block; animation: wave 1.8s ease-in-out infinite; transform-origin: 70% 70%; font-size: .6em; }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(16deg); } 20% { transform: rotate(-8deg); } }
@keyframes hello { from { opacity: 0; transform: translateY(14px) scale(.96); filter: blur(4px); } }
.welcome-sub { margin-top: 1rem; color: var(--muted); font-size: 1.1rem; font-weight: 300; }
.starters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-top: 2rem; width: 100%; max-width: 520px; }
.starter { display: flex; align-items: center; gap: .6rem; padding: .9rem 1rem; text-align: left; border-radius: 18px; background: var(--bg2); border: 1px solid var(--border); font-weight: 600; transition: .2s; animation: msgin .4s ease both; }
.starter:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 22%, transparent); }

.input-wrap { padding: .75rem 1rem .5rem; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg2) 90%, transparent); }
.composer { display: flex; align-items: flex-end; gap: .4rem; background: var(--bg3); border: 1.5px solid var(--border); border-radius: 24px; padding: .4rem; transition: .15s; }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; resize: none; background: transparent; outline: none; padding: .55rem .25rem; color: var(--text); font: inherit; font-size: 1rem; max-height: 220px; }
.send { background: var(--hot); color: #fff; padding: .6rem; border-radius: 999px; transition: .15s; }
.send:disabled { opacity: .35; cursor: not-allowed; }
.send:not(:disabled):hover { transform: scale(1.08) rotate(-8deg); }
.hint { display: flex; justify-content: space-between; font-size: .7rem; color: var(--muted); margin-top: .4rem; padding: 0 .5rem; gap: 1rem; }
.att { position: relative; }
.att img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; border: 2px solid var(--accent); }
.att button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: #d62828; color: #fff; font-size: .65rem; }
.warn { color: #d62828; }

.footer { text-align: center; font-size: .72rem; color: var(--muted); padding: .35rem; }
.footer a { color: var(--accent2); font-weight: 600; }

.overlay { position: fixed; inset: 0; background: rgba(20,10,15,.5); z-index: 50; display: flex; justify-content: flex-end; animation: fade .2s; }
.overlay.center { justify-content: center; align-items: center; padding: 1rem; }
@keyframes fade { from { opacity: 0; } }
.drawer { width: 100%; max-width: 440px; height: 100%; overflow-y: auto; background: var(--bg2); color: var(--text); animation: slide .3s ease; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg2); z-index: 1; font-size: 1.2rem; }
.card { padding: 1rem; border-radius: 16px; background: var(--bg3); border: 1px solid var(--border); }
.theme-pink .card { background: #fdf3f5; }
.lbl { font-size: .82rem; font-weight: 600; color: var(--muted); }
.tiny { font-size: .7rem; color: var(--muted); }
.num { font-family: 'JetBrains Mono', monospace; font-size: .8rem; color: var(--accent2); }
.row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.field { padding: .55rem .75rem; border-radius: 12px; background: var(--bg2); border: 1px solid var(--border); color: var(--text); outline: none; font: inherit; }
.field:focus { border-color: var(--accent); }
.range { accent-color: var(--accent); }
.seg { display: flex; background: var(--bg3); border-radius: 999px; padding: 4px; border: 1px solid var(--border); }
.seg button { flex: 1; padding: .5rem; border-radius: 999px; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--accent); color: #fff; }
.toggle { width: 44px; height: 24px; border-radius: 999px; background: var(--border); position: relative; transition: .2s; flex-shrink: 0; }
.toggle span { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle.on { background: var(--accent); } .toggle.on span { left: 23px; }
.dialog { background: var(--bg2); color: var(--text); border-radius: 22px; padding: 1.5rem; max-width: 360px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.3); }

.drop-zone { position: fixed; inset: 0; z-index: 60; background: color-mix(in srgb, var(--accent) 25%, transparent); display: grid; place-items: center; pointer-events: none; }
.drop-zone div { border: 3px dashed var(--accent); background: var(--bg2); padding: 2rem 3rem; border-radius: 28px; font-weight: 800; font-size: 1.4rem; }
.lightbox { max-width: 92vw; max-height: 90vh; border-radius: 16px; }
.toast { position: fixed; bottom: 6.5rem; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .6rem 1.1rem; border-radius: 999px; font-size: .85rem; font-weight: 600; z-index: 70; animation: msgin .25s; }

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }
@media (max-width: 640px) { .starters { grid-template-columns: 1fr; } .thumb { width: 100px; height: 100px; } }