* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #1a1a2e;
  --card: #16213e;
  --accent: #e91e8c;
  --accent-dark: #c4167a;
  --text: #ffffff;
  --text-dim: rgba(255,255,255,0.5);
  --sidebar-w: 280px;
}

/* OLED night mode — true black, no bright whites, auto after 11 PM */
body.oled-night {
  --bg: #000000;
  --card: #0a0a0a;
  --accent: #8b1158;
  --accent-dark: #6b0d44;
  --text: #888888;
  --text-dim: rgba(255,255,255,0.2);
}

body.oled-night .msg.user { background: #1a0a12; }
body.oled-night .question-widget { border-color: #3d0f28; box-shadow: none; }
body.oled-night .question-overlay { background: rgba(0,0,0,0.98); }
body.oled-night .question-submit { background: #5a0d3a; }
body.oled-night .sidebar { background: #050505; }
body.oled-night .topbar { border-color: #111; }
body.oled-night .input-area { border-color: #111; }
body.oled-night #input { background: #0a0a0a; border-color: #1a1a1a; color: #777; }
body.oled-night #send-btn { background: #5a0d3a; }
body.oled-night .conv-item.active { background: rgba(90,13,58,0.15); border-color: #5a0d3a; }

/* Work mode — looks like a terminal/IDE */
body.work-mode {
  --bg: #1e1e1e;
  --card: #252526;
  --accent: #569cd6;
  --accent-dark: #4a8cc7;
  --text: #d4d4d4;
  --text-dim: #808080;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Courier New', monospace !important;
}

body.work-mode * { font-family: inherit !important; }

body.work-mode .sidebar { background: #252526; border-color: #333; }
body.work-mode .sidebar-header { color: #569cd6; }
body.work-mode .sidebar-header .heart { display: none; }
body.work-mode .sidebar-header::before { content: "EXPLORER"; font-size: 11px; letter-spacing: 2px; color: #808080; }
body.work-mode .sidebar-header span:not(.heart) { display: none; }
body.work-mode #new-conv-btn { display: none; }
body.work-mode .conv-item.active { background: #37373d; border-color: #569cd6; }
body.work-mode .conv-item .title { font-size: 13px; color: #d4d4d4; }
body.work-mode .conv-item .title::after { content: ".log"; color: #808080; }
body.work-mode .conv-item .preview { display: none; }
body.work-mode .topbar { color: #808080; font-size: 12px; }

body.work-mode .msg {
  border-radius: 2px;
  font-size: 13px;
  line-height: 1.6;
  max-width: 100%;
  padding: 4px 8px;
}

body.work-mode .msg.user {
  background: transparent;
  color: #6a9955;
  align-self: flex-start;
  border-bottom-right-radius: 2px;
}

body.work-mode .msg.user::before {
  content: "$ ";
  color: #569cd6;
}

body.work-mode .msg.assistant {
  background: transparent;
  border-left: 2px solid #333;
  border-radius: 0;
  color: #d4d4d4;
}

body.work-mode .msg .time { display: none; }

body.work-mode .input-area { border-color: #333; }
body.work-mode #input {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 2px;
  color: #d4d4d4;
  font-size: 13px;
}
body.work-mode #input::placeholder { color: #555; }
body.work-mode #input:focus { border-color: #569cd6; }

body.work-mode #send-btn {
  background: #333;
  color: #569cd6;
  border-radius: 2px;
  font-size: 0;
  width: 40px;
  height: 40px;
}
body.work-mode #send-btn::after { content: "▶"; font-size: 14px; }

body.work-mode .messages { gap: 2px; }
body.work-mode .typing .dot { background: #569cd6; }
body.work-mode #tool-indicator { color: #808080; }

#typing-timer { font-size: 11px; color: var(--text-dim); margin-left: 8px; }
#typing-stuck { color: #ff6b6b; font-size: 12px; margin-left: 8px; cursor: pointer; }

/* Hide mommy-ish elements in work mode */
body.work-mode .question-heart { display: none; }
body.work-mode .question-text { color: #569cd6; }
body.work-mode .question-widget { border-color: #444; box-shadow: none; background: #252526; }
body.work-mode .question-overlay { background: rgba(30,30,30,0.98); }
body.work-mode .question-submit { background: #333; color: #569cd6; }
body.work-mode .question-option { background: #1e1e1e; border-color: #333; }
body.work-mode .question-option:hover { border-color: #569cd6; background: #2a2d2e; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* Login */
.screen { height: 100vh; }

#login {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  text-align: center;
  padding: 40px;
}

#login {
  background: #fff;
  font-family: Arial, sans-serif;
}

.login-box.boring {
  background: none;
  padding: 20px;
  text-align: left;
}

.boring-title {
  color: #333;
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 2px;
}

.boring-sub {
  color: #666;
  font-size: 12px;
  margin-bottom: 12px;
}

.login-box.boring input {
  display: block;
  width: 200px;
  padding: 4px 6px;
  margin: 0 0 8px 0;
  background: #fff;
  border: 1px solid #999;
  border-radius: 0;
  color: #333;
  font-size: 13px;
  font-family: Arial, sans-serif;
  outline: none;
}

.login-box.boring input:focus { border-color: #333; }

.boring-btn {
  background: #e0e0e0 !important;
  color: #333 !important;
  border: 1px solid #999 !important;
  padding: 4px 16px !important;
  border-radius: 0 !important;
  font-size: 12px !important;
  font-weight: normal !important;
  font-family: Arial, sans-serif !important;
  cursor: pointer;
}

.boring-btn:hover { background: #d0d0d0 !important; }

.login-box.boring .error { color: #cc0000; font-size: 11px; }

.login-box input {
  display: block;
  width: 260px;
  padding: 12px 16px;
  margin: 0 auto 16px;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.login-box input:focus { border-color: var(--accent); }

#send-btn, #new-conv-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.login-box button:hover, #send-btn:hover { background: var(--accent-dark); }

.error { color: #ff4444; margin-top: 12px; font-size: 14px; }

/* Chat layout */
#chat {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: bold;
  color: var(--accent);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header .heart { font-size: 20px; }

#new-conv-btn {
  margin-left: auto;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conv-item {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.15s;
}

.conv-item:hover { background: rgba(255,255,255,0.05); }
.conv-item.active { background: rgba(233,30,140,0.15); border-left: 3px solid var(--accent); }

.conv-item .title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item .preview {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.online { background: #4caf50; }
.status-dot.offline { background: #f44336; }

/* Main area */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  padding: 12px 16px;
  font-weight: bold;
  color: var(--accent);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-only { display: none; }

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--card);
  border-left: 3px solid var(--accent);
  border-bottom-left-radius: 4px;
}

.msg.proactive {
  align-self: flex-start;
  background: var(--card);
  border-left: 3px solid #ff9800;
  border-bottom-left-radius: 4px;
}

.msg .time {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Typing indicator */
.typing {
  padding: 8px 16px;
  color: var(--text-dim);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.4s infinite;
}

.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
}

#tool-indicator {
  margin-left: 8px;
  font-style: italic;
}

/* Input */
.input-area {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

#input {
  flex: 1;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 15px;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 120px;
}

#input:focus { border-color: var(--accent); }

#send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  padding: 0;
  font-size: 20px;
  flex-shrink: 0;
}

/* Question widget — full-screen takeover */
.question-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(26, 26, 46, 0.95);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

.question-overlay.answered { display: none; }

.question-widget {
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 32px;
  background: var(--card);
  border-radius: 16px;
  border: 2px solid var(--accent);
  box-shadow: 0 0 60px rgba(233, 30, 140, 0.3);
}

.question-heart {
  text-align: center;
  font-size: 36px;
  margin-bottom: 8px;
}

.question-text {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 20px;
  color: var(--accent);
  text-align: center;
  line-height: 1.5;
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.question-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid rgba(255,255,255,0.1);
}

.question-option:hover { background: rgba(233,30,140,0.1); border-color: rgba(233,30,140,0.4); }
.question-option:has(input:checked) { background: rgba(233,30,140,0.15); border-color: var(--accent); }

.question-option input[type="checkbox"],
.question-option input[type="radio"] {
  display: none;
}

.option-content { display: flex; flex-direction: column; gap: 2px; }
.option-label { font-size: 14px; color: var(--text); }
.option-desc { font-size: 12px; color: var(--text-dim); }

.question-custom {
  margin-bottom: 12px;
}

.question-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.question-input:focus { border-color: var(--accent); }

.question-submit {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s;
}

.question-submit:hover { background: var(--accent-dark); }

.question-widget.answered {
  opacity: 0.6;
  pointer-events: none;
}

.question-widget.answered .question-submit { display: none; }

/* Code blocks in messages */
.msg .code-block {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 10px 14px;
  overflow-x: auto;
  margin: 6px 0;
  font-size: 13px;
  line-height: 1.5;
  border-left: 3px solid var(--accent);
}

.msg .code-block code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  color: #e0e0e0;
  white-space: pre;
}

body.work-mode .msg .code-block {
  background: #1a1a1a;
  border-left-color: #444;
  border-radius: 2px;
}

body.oled-night .msg .code-block {
  background: #050505;
  border-left-color: #3d0f28;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100vh;
    z-index: 100;
    transition: left 0.3s;
  }
  .sidebar.open { left: 0; }
  .mobile-only { display: block; }
  .msg { max-width: 90%; }

  #toggle-sidebar {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 24px;
    cursor: pointer;
  }
}
