* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222c; --line: #262b38;
  --text: #e8eaf0; --muted: #9aa3b2; --accent: #de5833; --accent2: #f5a623;
  --user: #2b3a55; --assistant: #1e222c;
}
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
#app { display: flex; height: 100vh; height: 100dvh; }

/* Sidebar */
#sidebar { width: 280px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.side-head { padding: 14px; border-bottom: 1px solid var(--line); }
.brand { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.brand span { color: var(--accent2); }
#new-chat { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); color: var(--text); font-size: 14px; cursor: pointer; }
#new-chat:hover { border-color: var(--accent); }
#chat-list { flex: 1; overflow-y: auto; padding: 8px; }
.chat-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.chat-item:hover { background: var(--panel2); color: var(--text); }
.chat-item.active { background: var(--panel2); color: var(--text); border-left: 3px solid var(--accent); }
.chat-item .title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .del { border: none; background: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.chat-item .del:hover { color: #ff6b6b; background: #2a1d1d; }
.side-foot { padding: 12px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

/* Main */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#chat-header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
#menu-btn { display: none; border: 1px solid var(--line); background: var(--panel2); color: var(--text); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
#chat-title { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-badge { font-size: 12px; color: var(--accent2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }

#messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 420px; }
.empty-duck { font-size: 56px; }
.msg { max-width: 760px; padding: 12px 14px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--assistant); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.thinking { color: var(--muted); font-style: italic; }
.msg.error { border-color: #5b2b2b; color: #ff9a9a; }

#composer { display: flex; gap: 10px; padding: 12px 16px 6px; }
#input { flex: 1; resize: none; max-height: 140px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; outline: none; }
#input:focus { border-color: var(--accent); }
#send { width: 48px; flex: none; border: none; border-radius: 10px; background: var(--accent); color: #fff; font-size: 18px; cursor: pointer; }
#send:disabled { opacity: 0.5; cursor: default; }
.hint { text-align: center; color: var(--muted); font-size: 12px; padding: 0 16px 10px; }

@media (max-width: 720px) {
  #sidebar { position: fixed; z-index: 10; height: 100%; transform: translateX(-100%); transition: transform .2s; }
  #sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  #menu-btn { display: block; }
}
