/* Hermes Simple Chat — dark, minimal, smooth */

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

:root {
  --bg: #0f1115;
  --bg-2: #161922;
  --bg-3: #1f2330;
  --fg: #e6e8ee;
  --fg-dim: #9aa0b3;
  --accent: #7c8cff;
  --accent-2: #5a6dd0;
  --border: #262a37;
  --user-bubble: #2a3247;
  --assistant-bubble: transparent;
  --err: #ff7a7a;
  --ok: #6ddc8d;
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
  --radius: 12px;
  --radius-sm: 8px;
}

html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Inter", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }
input, textarea {
  font: inherit; color: inherit;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
  transition: border-color .15s, background .15s;
}
input:focus, textarea:focus { border-color: var(--accent); }

.grow { flex: 1; }

/* --- Login --- */
#login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f1115 0%, #1a1d29 100%);
}
.login-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  width: 360px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow);
  animation: slide-up .4s ease;
}
.login-card h1 { font-size: 22px; }
.login-card .hint { color: var(--fg-dim); font-size: 13px; }
.login-card input { font-size: 15px; }
.login-card button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 500;
  transition: background .15s;
}
.login-card button:hover { background: var(--accent-2); }
.err { color: var(--err); font-size: 13px; min-height: 18px; }

/* --- App --- */
#app-screen {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
}

/* --- Sidebar --- */
#sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.logo { font-weight: 600; font-size: 16px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 6px;
  color: var(--fg-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.icon-btn {
  background: transparent; border: none;
  color: var(--fg-dim);
  width: 28px; height: 28px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-3); color: var(--fg); }

.projects-list {
  list-style: none;
  padding: 0 8px;
  overflow-y: auto;
  flex: 1;
}
.project-item {
  margin-bottom: 4px;
}
.project-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s;
}
.project-row:hover { background: var(--bg-3); }
.project-row.active { background: var(--bg-3); }
.project-name { font-size: 13px; flex: 1; }
.project-actions { display: flex; gap: 2px; }
.session-list {
  list-style: none;
  margin: 2px 0 6px 18px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}
.session-list.open { max-height: 600px; overflow-y: auto; }
.session-row {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--fg-dim);
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-row:hover { background: var(--bg-3); color: var(--fg); }
.session-row.active { background: var(--accent-2); color: white; }
.new-session-btn {
  display: block;
  margin: 4px 0 4px 18px;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--fg-dim);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  width: calc(100% - 30px);
}
.new-session-btn:hover { background: var(--bg-3); color: var(--fg); }

/* --- Chat pane --- */
#chat-pane { display: flex; flex-direction: column; min-width: 0; }

.empty-state {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-dim);
  text-align: center;
}
.empty-state h2 { font-weight: 400; font-size: 18px; line-height: 1.6; }

.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
}
.chat-head h2 { font-size: 16px; font-weight: 500; }
.chat-controls { display: flex; align-items: center; gap: 12px; }

.toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  font-size: 12px;
  color: var(--fg-dim);
  transition: all .15s;
}
.toggle input { display: none; }
.toggle:has(input:checked) {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  scroll-behavior: smooth;
}
.msg {
  padding: 14px 24px;
  display: flex;
  gap: 12px;
  animation: msg-in .25s ease;
}
.msg.user { background: var(--user-bubble); }
.msg.assistant { background: var(--assistant-bubble); }
.msg-role {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-dim);
}
.msg.user .msg-role { background: var(--accent); color: white; }
.msg-body { flex: 1; min-width: 0; }
.msg-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--fg-dim);
  margin-bottom: 4px;
}
.msg-text { white-space: pre-wrap; word-wrap: break-word; }
.msg-text code {
  background: var(--bg-3);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 12.5px;
}
.msg-text pre {
  background: var(--bg-3);
  padding: 10px 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
}
.msg-text pre code { background: transparent; padding: 0; }
.typing-dots {
  display: inline-flex; gap: 4px;
}
.typing-dots span {
  width: 6px; height: 6px;
  background: var(--fg-dim);
  border-radius: 50%;
  animation: dot 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dot {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* --- Composer --- */
.composer {
  display: flex; gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 200px;
  font-size: 14px;
  line-height: 1.5;
  font-family: inherit;
}
.composer button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 18px;
  font-weight: 500;
  transition: background .15s;
}
.composer button:hover:not(:disabled) { background: var(--accent-2); }
.composer button:disabled { opacity: .4; cursor: not-allowed; }

/* --- Modal --- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fade-in .2s;
}
.modal-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 420px;
  max-width: 90vw;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow);
}
.modal-card label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--fg-dim);
}
.modal-actions {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px;
}
.modal-actions button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
}
.modal-actions button:not(.ghost) {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
}
.modal-actions button.link {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 4px 0;
  font-size: 12px;
}
.hint { font-size: 12px; color: var(--fg-dim); }
.err { font-size: 12px; color: var(--err); }

/* --- Animations --- */
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
