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

.app-container {
  --bg: #12121f; --bg2: #191930; --bg3: #22223d; --text: #f3f0ff; --muted: #a5a3c4;
  --accent: #2EE6A0; --accent2: #A020F0; --border: #2e2e50; --on-accent: #06281b;
  display: flex; height: 100vh; color: var(--text); position: relative;
  background: radial-gradient(1200px 600px at 90% -10%, rgba(160,32,240,.22), transparent 60%),
              radial-gradient(800px 500px at -10% 110%, rgba(46,230,160,.12), transparent 60%), var(--bg);
}
.theme-light {
  --bg: #f7f5ff; --bg2: #ffffff; --bg3: #f0ecfb; --text: #1d1b2e; --muted: #6b6889;
  --accent: #10b981; --accent2: #7c3aed; --border: #e3def5; --on-accent: #fff;
  background: radial-gradient(1000px 500px at 100% 0%, rgba(124,58,237,.12), transparent 60%), var(--bg);
}
.theme-sketch {
  --bg: #FFFDF7; --bg2: #FFFDF7; --bg3: #ffffff; --text: #222; --muted: #6a6458;
  --accent: #14c287; --accent2: #A020F0; --border: #222; --on-accent: #fff;
  background-color: #FFFDF7;
  background-image: linear-gradient(#e8edf5 1px, transparent 1px), linear-gradient(90deg, #e8edf5 1px, transparent 1px);
  background-size: 24px 24px;
}

.hand, .hw .hero-title, .hw .logo-text { font-family: 'Gochi Hand', cursive; }
.accent-text { color: var(--accent); }
.border-soft { border-color: var(--border); }

.sidebar { background: var(--bg2); border-right: 1px solid var(--border); }
.header { background: color-mix(in srgb, var(--bg2) 85%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(8px); }
.theme-sketch .header, .theme-sketch .sidebar { border-width: 0 2px 2px 0; border-style: solid; border-color: #222; }

.logo-text { font-size: 1.6rem; font-weight: 800; color: var(--accent); line-height: 1; display: flex; align-items: baseline; gap: .4rem; }
.logo-sub { font-size: .8rem; color: var(--accent2); font-family: 'Gochi Hand', cursive; transform: rotate(-6deg); display: inline-block; }
.pig-wrap { position: relative; display: inline-block; flex-shrink: 0; }
.pig-bow { position: absolute; top: -28%; left: 50%; transform: translateX(-50%) rotate(-10deg); filter: hue-rotate(260deg) saturate(2); }
.logo-wiggle:hover .pig-bow { animation: wiggle .5s ease-in-out infinite; }
@keyframes wiggle { 0%,100% { transform: translateX(-50%) rotate(-14deg); } 50% { transform: translateX(-50%) rotate(14deg) scale(1.15); } }

.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.status-dot.ok { background: #2EE6A0; box-shadow: 0 0 8px #2EE6A0; }
.status-dot.busy { background: #FFD23F; animation: pulse 1s infinite; }
.status-dot.error { background: #ff4d6d; }
@keyframes pulse { 50% { opacity: .3; } }

.icon-btn { padding: .45rem; border-radius: .6rem; color: var(--muted); transition: all .15s; }
.icon-btn:hover { color: var(--text); background: var(--bg3); }
.silly-on { background: var(--accent2) !important; transform: rotate(-8deg); }

.btn-primary { background: var(--accent); color: var(--on-accent); padding: .5rem 1rem; border-radius: .7rem; font-weight: 700; transition: transform .1s, filter .15s; }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost { background: var(--bg3); color: var(--text); padding: .5rem 1rem; border-radius: .7rem; border: 1px solid var(--border); transition: all .15s; }
.btn-ghost:hover { border-color: var(--accent2); }
.btn-danger { background: #ff4d6d; color: #fff; padding: .5rem 1rem; border-radius: .7rem; font-weight: 700; }
.btn-mini { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; font-size: 12px; border-radius: 6px; background: #2b2b40; color: #ddd; }
.btn-launch { background: #10b981; color: #fff; }
.theme-sketch .btn-primary, .theme-sketch .btn-ghost, .theme-sketch .btn-danger { border: 2px solid #222; box-shadow: 3px 3px 0 #222; border-radius: 12px 4px 14px 5px; }
.theme-sketch .btn-primary:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 #222; }

.chat-item { padding: .7rem; border-radius: .7rem; cursor: pointer; border: 1px solid transparent; transition: all .15s; }
.chat-item:hover { background: var(--bg3); }
.chat-item.active { background: color-mix(in srgb, var(--accent2) 18%, transparent); border-color: var(--accent2); }

.messages-area { scrollbar-width: thin; scrollbar-color: var(--accent2) transparent; }
.message { padding: .9rem 1.15rem; position: relative; }
.message-user { background: linear-gradient(135deg, var(--accent2), #6d28d9); color: #fff; border-radius: 1.2rem 1.2rem .3rem 1.2rem; box-shadow: 0 6px 18px rgba(160,32,240,.25); }
.message-ai { background: var(--bg3); border: 1px solid var(--border); border-radius: 1.2rem 1.2rem 1.2rem .3rem; }
.theme-sketch .message-user { background: #f3e3ff; color: #222; border: 2px solid #222; box-shadow: 3px 3px 0 var(--accent2); border-radius: 18px 6px 4px 20px; }
.theme-sketch .message-ai { border: 2px solid #222; box-shadow: 3px 3px 0 var(--accent); border-radius: 6px 20px 18px 4px; }
.msg-in { animation: pop .3s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.message-content { line-height: 1.65; word-wrap: break-word; }
.prose-b p { margin-bottom: .5rem; } .prose-b p:last-child { margin-bottom: 0; }
.prose-b ul, .prose-b ol { margin: 0 0 .5rem 1.4rem; } .prose-b ul { list-style: disc; } .prose-b ol { list-style: decimal; }
.prose-b h1, .prose-b h2, .prose-b h3 { font-weight: 800; margin: .8rem 0 .4rem; color: var(--accent); }
.prose-b a { color: var(--accent); text-decoration: underline; }
.prose-b code { background: rgba(160,32,240,.18); padding: .1rem .35rem; border-radius: .25rem; font-family: 'JetBrains Mono', monospace; font-size: .85em; }
.prose-b blockquote { border-left: 3px solid var(--accent2); padding-left: .8rem; opacity: .85; font-style: italic; }
.prose-b table { border-collapse: collapse; margin: .5rem 0; } .prose-b td, .prose-b th { border: 1px solid var(--border); padding: .3rem .6rem; }
.message-user .prose-b code { background: rgba(255,255,255,.2); }

.code-block-wrapper { border-radius: .6rem; overflow: hidden; background: #1e1e2e; border: 1px solid #363646; }
.code-head { background: #16161f; color: #ccc; border-bottom: 1px solid #333; }
.code-block-wrapper pre { margin: 0; padding: 1rem; overflow-x: auto; background: #1e1e2e !important; }
.code-block-wrapper code { font-family: 'JetBrains Mono', monospace; background: transparent !important; }
.theme-sketch .code-block-wrapper { border: 2px solid #222; }

.msg-thumb { width: 120px; height: 120px; object-fit: cover; border-radius: .6rem; cursor: zoom-in; border: 2px solid rgba(255,255,255,.4); }
.sticker-row { position: absolute; top: -14px; right: -6px; display: flex; gap: 2px; }
.sticker { font-size: 22px; background: #fff; border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.3); cursor: pointer; animation: slap .35s cubic-bezier(.3,1.8,.5,1); }
@keyframes slap { from { transform: scale(2.2) rotate(30deg); opacity: 0; } }
.react-bar { display: inline-flex; gap: 1px; margin-left: .3rem; }
.react-btn { font-size: 15px; padding: 1px 3px; border-radius: 6px; transition: transform .1s; }
.react-btn:hover { transform: scale(1.35) rotate(-8deg); }

.typing-indicator { padding: .4rem .9rem; background: var(--bg3); border-radius: 1rem; border: 1px solid var(--border); }
.whisker { stroke: var(--accent2); stroke-width: 4; stroke-linecap: round; fill: none; stroke-dasharray: 16; stroke-dashoffset: 16; animation: draw 1.2s ease-in-out infinite; }
@keyframes draw { 0% { stroke-dashoffset: 16; } 40%,70% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -16; } }

.input-box { display: flex; gap: .5rem; align-items: flex-start; background: var(--bg3); border: 1.5px solid var(--border); border-radius: 1rem; padding: .5rem; transition: border-color .15s; }
.input-box:focus-within { border-color: var(--accent); }
.theme-sketch .input-box { border: 2px solid #222; box-shadow: 4px 4px 0 var(--accent2); border-radius: 18px 6px 16px 8px; }
.chat-input { background: transparent; border: none; outline: none; resize: none; color: var(--text); font: inherit; font-size: 1rem; padding: .4rem; max-height: 200px; }
.chat-input::placeholder { color: var(--muted); }
.send-btn { background: var(--accent); color: var(--on-accent); padding: .6rem; border-radius: .7rem; transition: all .15s; }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }
.pending-thumb { position: relative; width: 64px; height: 64px; }
.pending-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: .5rem; border: 2px solid var(--accent); }
.pt-btn { position: absolute; top: -8px; width: 22px; height: 22px; border-radius: 50%; background: var(--bg2); border: 1px solid var(--border); font-size: 11px; display: grid; place-items: center; }
.pt-btn.left { left: -8px; } .pt-btn.right { right: -8px; }

.empty-pig { animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-10px) rotate(3deg); } }
.hero-title { font-size: clamp(2.4rem, 6vw, 4rem); font-weight: 800; line-height: 1; margin-top: 1rem; letter-spacing: -.02em; }
.scribble { color: var(--accent2); position: relative; display: inline-block; transform: rotate(-3deg); }
.scribble::after { content: ''; position: absolute; left: -4%; right: -4%; bottom: -6px; height: 10px; border-bottom: 4px solid var(--accent); border-radius: 50%; }
.idk-btn:hover { animation: wiggle2 .4s ease-in-out; }
@keyframes wiggle2 { 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }

.modal-overlay { position: fixed; inset: 0; background: rgba(5,5,15,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.panel { background: var(--bg2); color: var(--text); border: 1px solid var(--border); border-radius: 1rem; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.theme-sketch .panel { border: 2.5px solid #222; box-shadow: 6px 6px 0 #222; }
.drawer-wrap { justify-content: flex-end; padding: 0; }
.drawer { width: 100%; max-width: 440px; height: 100%; overflow-y: auto; border-radius: 1rem 0 0 1rem; animation: slidein .3s ease; }
@keyframes slidein { from { transform: translateX(100%); } }
.card { background: var(--bg3); border: 1px solid var(--border); border-radius: .8rem; padding: 1rem; }
.lbl { font-size: .85rem; color: var(--muted); }
.field { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: .5rem; padding: .5rem .65rem; outline: none; font: inherit; font-size: .9rem; }
.field:focus { border-color: var(--accent); }
.toggle { width: 44px; height: 24px; border-radius: 99px; background: var(--border); position: relative; transition: background .2s; flex-shrink: 0; }
.toggle span { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle.on { background: var(--accent); } .toggle.on span { transform: translateX(20px); }
input[type=range] { accent-color: var(--accent2); }

.doodle-panel { width: 100%; max-width: 820px; max-height: 95vh; overflow-y: auto; padding: 1rem; }
.tool-btn { padding: .35rem .7rem; border-radius: .6rem; background: var(--bg3); border: 1px solid var(--border); font-size: .85rem; }
.tool-btn.active { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.tool-btn:disabled { opacity: .35; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); transition: transform .1s; }
.swatch.sm { width: 22px; height: 22px; }
.swatch.on { transform: scale(1.2); outline: 2px solid var(--text); outline-offset: 2px; }
.doodle-stage { position: relative; display: grid; place-items: center; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0/20px 20px; border-radius: .6rem; overflow: hidden; }
.doodle-canvas { grid-area: 1/1; max-width: 100%; max-height: 62vh; touch-action: none; }

.toast { position: fixed; bottom: 7rem; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--bg2); border: 2px solid var(--accent2); padding: .8rem 1rem; border-radius: 1rem; box-shadow: 0 10px 30px rgba(0,0,0,.35); max-width: 92vw; width: 420px; animation: pop .3s; }
.chip { text-align: left; padding: .45rem .7rem; border-radius: .6rem; background: var(--bg3); border: 1px dashed var(--accent); font-size: .88rem; }
.chip:hover { background: color-mix(in srgb, var(--accent) 20%, var(--bg3)); }
.drop-hint { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(160,32,240,.25); border: 5px dashed var(--accent); pointer-events: none; font-family: 'Gochi Hand', cursive; font-size: 3rem; color: #fff; }

.floaters { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.floaters span { position: absolute; bottom: -60px; opacity: .13; animation: floatup linear infinite; }
@keyframes floatup { to { transform: translateY(-115vh) rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .floaters span, .empty-pig, .whisker { animation: none !important; } .floaters span { bottom: auto; top: 50%; } }

@media (max-width: 768px) { .chat-input { font-size: 16px; } .logo-sub { display: none; } }