:root{
  --bg:#fff;
  --sidebar:#f7f7f8;
  --surface:#fff;
  --surface-2:#f5f5f5;
  --text:#1f1f1f;
  --muted:#777;
  --border:#e8e8e8;
  --hover:#ececec;
  --accent:#111;
  --user:#f5f5f5;
  --danger:#b42318;
  --shadow:0 10px 35px rgba(0,0,0,.08);
}
*{box-sizing:border-box}
html,body{margin:0;width:100%;height:100%;font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:var(--text);background:var(--bg)}
body{overflow:hidden}
button,input,textarea,select{font:inherit}
button{border:0;background:none;color:inherit;cursor:pointer}
button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:2px solid #999;outline-offset:1px}
.app{display:flex;height:100dvh;background:var(--bg)}
.sidebar{width:275px;flex:0 0 275px;background:var(--sidebar);border-right:1px solid var(--border);display:flex;flex-direction:column;transition:width .2s ease,transform .2s ease}
.sidebar.collapsed{width:0;flex-basis:0;overflow:hidden;border-right:0}
.sidebar-top{display:flex;align-items:center;gap:8px;padding:14px}
.new-chat{height:42px;flex:1;border:1px solid var(--border);border-radius:13px;background:var(--surface);display:flex;align-items:center;gap:10px;padding:0 13px;font-weight:600;box-shadow:0 1px 1px rgba(0,0,0,.02)}
.new-chat:hover{background:var(--hover)}
.new-chat-icon{font-size:22px;line-height:1}
.icon-button{width:38px;height:38px;border-radius:10px;display:grid;place-items:center}
.icon-button:hover{background:var(--hover)}
.sidebar-search-wrap{padding:0 12px 6px}
.sidebar-search{display:flex;align-items:center;gap:8px;height:38px;border:1px solid var(--border);border-radius:10px;background:var(--surface);padding:0 10px;color:var(--muted)}
.sidebar-search input{width:100%;border:0;outline:0;background:transparent;color:var(--text);font-size:13px}
.sidebar-section{padding:6px 10px;overflow:auto;flex:1}
.section-label{padding:11px 10px 7px;font-size:12px;color:var(--muted);font-weight:600}
.chat-list{display:flex;flex-direction:column;gap:3px}
.chat-item{display:flex;align-items:center;gap:8px;padding:10px 11px;border-radius:10px;min-width:0}
.chat-item:hover{background:var(--hover)}
.chat-item.active{background:#e9e9ea}
.chat-title{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:13px;flex:1}
.chat-delete{opacity:0;width:28px;height:28px;border-radius:8px}
.chat-item:hover .chat-delete{opacity:1}
.chat-delete:hover{background:#ddd}
.chat-empty{font-size:12px;color:var(--muted);padding:16px 11px}
.sidebar-bottom{padding:10px;border-top:1px solid var(--border)}
.sidebar-item{width:100%;display:flex;align-items:center;gap:11px;padding:11px;border-radius:10px;text-align:left;font-size:13px}
.sidebar-item:hover{background:var(--hover)}
.sidebar-item.danger{color:var(--danger)}
.sidebar-item-icon{width:18px;text-align:center}
.main{min-width:0;flex:1;display:flex;flex-direction:column}
.topbar{height:62px;display:flex;align-items:center;justify-content:space-between;padding:0 20px;border-bottom:1px solid var(--border);background:rgba(255,255,255,.92);backdrop-filter:blur(12px);z-index:5}
.topbar-left,.topbar-right{display:flex;align-items:center;gap:10px}
.brand-mark{font-size:22px;font-weight:700}
.brand-name{font-size:16px;font-weight:700;letter-spacing:-.02em}
.model-wrap{display:flex;align-items:center;gap:7px}
.model-select{height:40px;min-width:200px;border:1px solid var(--border);background:var(--surface);padding:8px 34px 8px 11px;border-radius:11px;color:var(--text);outline:none}
.model-select:hover{background:var(--surface-2)}
.model-status{font-size:10px;color:var(--muted);min-width:44px}
.topbar-action{height:36px;padding:0 12px;border:1px solid var(--border);border-radius:9px}
.topbar-action:hover{background:var(--hover)}
.chat-view{min-height:0;flex:1;overflow:auto;scroll-behavior:smooth;overscroll-behavior:contain}
.empty-state{max-width:840px;margin:0 auto;padding:80px 24px 48px;text-align:center}
.pearl-logo{width:54px;height:54px;margin:0 auto 20px;border-radius:18px;display:grid;place-items:center;background:#111;color:#fff;font-size:26px;box-shadow:var(--shadow)}
.empty-state h1{font-size:34px;margin:0 0 10px;letter-spacing:-.04em}
.empty-state p{color:var(--muted);margin:0 0 30px}
.starter-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;text-align:left}
.starter{border:1px solid var(--border);padding:16px;border-radius:14px;background:var(--surface);transition:transform .15s ease,background .15s ease}
.starter:hover{background:var(--surface-2);transform:translateY(-1px)}
.starter strong{display:block;font-size:14px;margin-bottom:7px}
.starter span{display:block;color:var(--muted);font-size:12px;line-height:1.5}
.messages{max-width:880px;margin:0 auto;padding:24px 20px 40px;display:flex;flex-direction:column;gap:24px;contain:layout paint}
.message{display:flex;gap:12px;align-items:flex-start}
.message.user{justify-content:flex-end}
.avatar{width:31px;height:31px;flex:0 0 31px;border-radius:10px;display:grid;place-items:center;font-size:13px;font-weight:700}
.avatar.pearl{background:#111;color:#fff}
.avatar.user{background:#e9e9ea}
.bubble{max-width:min(760px,100%);line-height:1.65;font-size:14px;word-break:break-word;min-width:0;overflow-wrap:anywhere}
.user .bubble{background:var(--user);border-radius:18px 18px 5px 18px;padding:12px 15px;white-space:pre-wrap}
.assistant .bubble{padding-top:2px}
.message-tools{display:flex;gap:6px;margin-top:10px}
.message-tool{font-size:12px;color:var(--muted);border:1px solid var(--border);padding:5px 9px;border-radius:8px;background:var(--surface)}
.message-tool:hover{background:var(--surface-2);color:var(--text)}
.bubble p{margin:0 0 12px}
.bubble p:last-child{margin-bottom:0}
.bubble h1,.bubble h2,.bubble h3{margin:16px 0 8px;line-height:1.25}
.bubble ul,.bubble ol{padding-left:20px}
.bubble li{margin:3px 0}
.bubble code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;background:#f1f1f1;padding:2px 5px;border-radius:5px;font-size:12px}
.code-block{position:relative;margin:12px 0;background:#111;color:#f5f5f5;border-radius:12px;overflow:hidden;border:1px solid #242424}
.code-block-header{height:34px;display:flex;align-items:center;justify-content:space-between;padding:0 8px 0 12px;background:#181818;border-bottom:1px solid #2a2a2a}
.code-language{font-size:11px;color:#a7a7a7;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
.code-copy{background:#242424;color:#ddd;padding:5px 8px;border-radius:7px;font-size:11px}
.code-copy:hover{background:#303030}
.code-block pre{margin:0;padding:14px 16px;font:12px/1.65 ui-monospace,SFMono-Regular,Menlo,monospace;color:#f5f5f5;white-space:pre;tab-size:2;overflow:auto;max-width:100%}
.code-block pre code{display:block;background:transparent;color:inherit;padding:0;border-radius:0;font:inherit;white-space:inherit}
.code-block.streaming-code{animation:codeReveal .16s ease-out}
@keyframes codeReveal{from{opacity:.55}to{opacity:1}}
.thinking-indicator{display:inline-flex;align-items:center;gap:7px;min-height:30px;color:var(--muted);font-size:14px;line-height:1;user-select:none}
.thinking-label{font-weight:500;letter-spacing:-.01em}
.thinking-dots{display:inline-flex;align-items:center;gap:4px;height:14px}
.thinking-dots i{width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.28;animation:thinkingPulse 1.15s ease-in-out infinite}
.thinking-dots i:nth-child(2){animation-delay:.16s}.thinking-dots i:nth-child(3){animation-delay:.32s}
@keyframes thinkingPulse{0%,60%,100%{transform:translateY(0) scale(.8);opacity:.28}30%{transform:translateY(-3px) scale(1);opacity:.9}}
.composer-wrap{padding:10px 16px 14px;background:linear-gradient(to top,var(--bg) 75%,transparent)}
.composer-shell{max-width:880px;margin:0 auto;border:1px solid #d9d9d9;border-radius:18px;background:var(--surface);box-shadow:0 2px 14px rgba(0,0,0,.05);padding:10px 11px 8px}
#composer{display:block;width:100%;resize:none;border:0;outline:0;background:transparent;color:var(--text);max-height:180px;min-height:28px;padding:7px 8px;font-size:14px;line-height:1.55}
.composer-toolbar{display:flex;justify-content:space-between;align-items:center;padding:3px 2px 0 8px}
.composer-hint,.token-hint{font-size:11px;color:var(--muted)}
.composer-actions{display:flex;align-items:center;gap:8px}
.send-button{width:34px;height:34px;border-radius:50%;background:#111;color:#fff;display:grid;place-items:center;font-size:18px;font-weight:700}
.send-button:disabled{opacity:.35;cursor:not-allowed}
.stop-button{height:34px;padding:0 11px;border-radius:9px;border:1px solid var(--border);background:var(--surface)}
.disclaimer{text-align:center;color:#999;font-size:10px;margin-top:7px}
.hidden{display:none!important}
.toast{position:fixed;left:50%;bottom:90px;transform:translate(-50%,10px);opacity:0;pointer-events:none;background:#111;color:#fff;padding:9px 12px;border-radius:9px;font-size:12px;transition:.2s;z-index:20}
.toast.show{opacity:1;transform:translate(-50%,0)}
.mobile-only{display:none}

@media (prefers-reduced-motion: reduce){
  .thinking-dots i{animation:none;opacity:.55}
  .chat-view{scroll-behavior:auto}
  .starter{transition:none}
  .code-block.streaming-code{animation:none}
}

@media (max-width:800px){
  .sidebar{position:fixed;left:0;top:0;bottom:0;z-index:15;box-shadow:var(--shadow)}
  .sidebar.collapsed{transform:translateX(-100%);width:275px;flex-basis:275px}
  .mobile-only{display:grid}
  .starter-grid{grid-template-columns:1fr}
  .empty-state{padding-top:55px}
  .empty-state h1{font-size:28px}
  .topbar{padding:0 12px}
  .topbar-action{display:none}
  .model-status{display:none}
  .model-select{min-width:0;width:155px;max-width:155px}
  .messages{padding-left:13px;padding-right:13px}
  .bubble{font-size:15px}
  .composer-wrap{padding-left:12px;padding-right:12px}
  .composer-shell{border-radius:18px}
  .composer-hint{font-size:10px}
}
