:root {
  --bg: #ffffff;
  --sidebar-bg: #f7f6f3;
  --border: #e5e3df;
  --text: #1f1d1a;
  --muted: #6b6760;
  --accent: #c1502b;
  --accent-contrast: #ffffff;
  --bubble-user-bg: #f0eee9;
  --bubble-assistant-bg: #ffffff;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text);
}

.app { display: flex; height: 100vh; }

.sidebar {
  width: 260px; background: var(--sidebar-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 12px; flex-shrink: 0;
}
.new-chat-btn {
  background: var(--accent); color: var(--accent-contrast); border: none; border-radius: 8px;
  padding: 10px 14px; font-size: 14px; font-weight: 600; cursor: pointer; margin-bottom: 12px;
}
.new-chat-btn:hover { opacity: 0.9; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.chat-item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.chat-item:hover { background: var(--border); }
.chat-item.active { background: #ece8e2; font-weight: 600; }
.chat-item span { overflow: hidden; text-overflow: ellipsis; }
.chat-delete { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; opacity: 0; padding: 0 4px; line-height: 1; }
.chat-item:hover .chat-delete { opacity: 1; }
.logout-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px; padding: 8px;
  font-size: 13px; color: var(--muted); cursor: pointer; margin-top: 8px;
}
.logout-btn:hover { background: var(--border); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chat-header h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#model-select { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px; background: #fff; color: var(--text); flex-shrink: 0; }

.messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; max-width: 760px; margin: 0 auto; width: 100%; }
.bubble { padding: 12px 16px; border-radius: 12px; line-height: 1.5; font-size: 15px; max-width: 100%; white-space: pre-wrap; }
.bubble.user { background: var(--bubble-user-bg); align-self: flex-end; }
.bubble.assistant { background: var(--bubble-assistant-bg); border: 1px solid var(--border); align-self: flex-start; }
.bubble pre { background: #f5f4f1; border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 13px; white-space: pre; }
.status-line { font-size: 12px; color: var(--muted); align-self: flex-start; padding-left: 4px; }
.status-line.error { color: #b3261e; }

.composer { display: flex; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); max-width: 760px; margin: 0 auto; width: 100%; }
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  font-size: 15px; font-family: inherit; max-height: 200px;
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
.composer button {
  background: var(--accent); color: var(--accent-contrast); border: none; border-radius: 10px;
  padding: 0 20px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.composer button:hover { opacity: 0.9; }
.composer button:disabled { opacity: 0.5; cursor: default; }

.login-body { display: flex; align-items: center; justify-content: center; height: 100%; background: var(--sidebar-bg); }
.login-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 32px; width: 320px;
  display: flex; flex-direction: column; gap: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card .muted { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.login-card input { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button { background: var(--accent); color: var(--accent-contrast); border: none; border-radius: 8px; padding: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.login-card .error { color: #b3261e; font-size: 13px; margin: 0; }

.composer button.stop { background: #b3261e; }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: flex;
  align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: #fff; border-radius: 14px; width: 420px; max-width: 90vw; max-height: 85vh;
  overflow-y: auto; padding: 20px 24px; box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-header h3 { margin: 0; font-size: 17px; }
.icon-btn { background: none; border: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; }
.icon-btn:hover { color: var(--text); }
.modal-section { border-top: 1px solid var(--border); padding: 16px 0; }
.modal-section:first-of-type { border-top: none; }
.modal-section h4 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.modal-section form { display: flex; flex-direction: column; gap: 8px; }
.modal-section input { border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 14px; }
.modal-section input:focus { outline: none; border-color: var(--accent); }
.modal-section button { align-self: flex-start; background: var(--accent); color: var(--accent-contrast); border: none; border-radius: 8px; padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; }
.modal-section button:hover { opacity: 0.9; }
#claude-reconnect { margin-top: 8px; }
#claude-login-flow { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
#claude-login-link { font-size: 13px; word-break: break-all; }
.form-msg { font-size: 13px; margin: 6px 0 0; }
.form-msg.error { color: #b3261e; }
.form-msg.ok { color: #1a7f37; }
