:root {
  --bg: #0a0a0a;
  --card: #1a1a1a;
  --border: #2a2a2a;
  --text: #e0e0e0;
  --dim: #888;
  --accent: #6b8afd;
  --user-bg: #1a3a5c;
  --asst-bg: #1a1a1a;
  --red: #e74c3c;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); height: 100vh; height: 100dvh; overflow: hidden; }

/* Toast */
#toast { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); background: var(--card); color: var(--text); padding: 8px 16px; border-radius: 8px; font-size: 13px; z-index: 999; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
#toast.show { opacity: 1; }
#toast.error { border: 1px solid var(--red); }

/* Login */
#login-view { display: flex; align-items: center; justify-content: center; height: 100vh; height: 100dvh; animation: fadeIn 0.6s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.login-box { text-align: center; }
.login-box h1 { font-size: 52px; font-weight: 200; color: var(--text); margin-bottom: 8px; letter-spacing: 8px; text-transform: lowercase; text-shadow: 0 0 40px rgba(107,138,253,0.3), 0 0 80px rgba(107,138,253,0.1); }
.login-tagline { color: var(--dim); font-size: 13px; letter-spacing: 4px; text-transform: uppercase; margin-bottom: 40px; font-weight: 300; }
.login-row { display: flex; align-items: center; justify-content: center; gap: 0; }
.login-box input { background: var(--card); border: 1px solid var(--border); border-right: none; color: var(--text); padding: 14px 20px; border-radius: 12px 0 0 12px; font-size: 15px; width: 240px; outline: none; text-align: center; letter-spacing: 2px; transition: border-color 0.2s, box-shadow 0.2s; }
.login-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.login-box input::placeholder { color: #555; letter-spacing: 1px; }
.login-box button { background: var(--accent); border: 1px solid var(--accent); color: white; padding: 14px 20px; border-radius: 0 12px 12px 0; font-size: 18px; cursor: pointer; transition: background 0.2s, transform 0.1s; line-height: 1; }
.login-box button:hover { background: #5a7bf0; }
.login-box button:active { transform: scale(0.96); }

/* Header */
.header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--bg); height: 48px; }
.header-title { font-size: 18px; font-weight: 500; letter-spacing: 1px; }
.header-right { display: flex; gap: 8px; }
.header button { background: none; border: none; color: var(--dim); font-size: 20px; cursor: pointer; padding: 4px 8px; }

/* Conversations */
#conv-view { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
#conv-list { flex: 1; overflow-y: auto; padding: 8px; }
.conv-card { padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; display: flex; align-items: center; }
.conv-card:hover { background: var(--card); }
.conv-card:active { background: #222; }
.conv-info { flex: 1; min-width: 0; }
.conv-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { color: var(--dim); font-size: 11px; margin-top: 4px; }

/* Chat */
#chat-view { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
#chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.5; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--user-bg); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--asst-bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.thinking { color: var(--dim); font-style: italic; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.msg a { color: var(--accent); }
.msg code { background: #2a2a2a; padding: 2px 5px; border-radius: 3px; font-size: 13px; }
.msg pre { background: #1e1e1e; padding: 10px; border-radius: 6px; overflow-x: auto; margin: 6px 0; }
.msg pre code { background: none; padding: 0; }

/* Input */
.chat-input { display: flex; align-items: flex-end; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--bg); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.chat-input textarea { flex: 1; background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 10px 14px; border-radius: 20px; font-size: 16px; font-family: inherit; resize: none; max-height: 120px; outline: none; line-height: 1.4; margin: 0 6px; }
.chat-input textarea:focus { border-color: var(--accent); }
.chat-input button { background: var(--card); border: 1px solid var(--border); color: var(--dim); border-radius: 50%; width: 44px; height: 44px; font-size: 18px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
#chat-send { background: var(--accent); color: white; border: none; }

/* Pending files */
#pending-files { padding: 4px 16px; font-size: 12px; color: var(--dim); display: flex; flex-wrap: wrap; gap: 4px; }
.file-chip { background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; display: inline-flex; align-items: center; gap: 4px; }
.file-chip button { background: none; border: none; color: var(--red); cursor: pointer; font-size: 14px; padding: 0 2px; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Work toggle (after done) */
.work-toggle { margin-bottom: 8px; border-radius: 6px; background: #151515; border: 1px solid var(--border); font-size: 12px; }
.work-toggle summary { padding: 4px 10px; cursor: pointer; color: var(--dim); list-style: none; font-style: italic; }
.work-toggle summary::-webkit-details-marker { display: none; }
.work-toggle summary::before { content: '▶ '; font-size: 9px; }
.work-toggle[open] summary::before { content: '▼ '; }
.work-content { padding: 6px 10px; border-top: 1px solid var(--border); max-height: 400px; overflow-y: auto; color: var(--dim); font-size: 12px; }