:root {
  --bg: #0a0a0a;
  --bg-elevated: #111;
  --text: #fff;
  --text-secondary: #ffffff8c;
  --text-dim: #ffffff4d;
  --border: #ffffff1a;
  --border-strong: #ffffffd9;
  --frame: #ffffffe6;
  --accent: #5FD4CF;
  --font-display: "Space Grotesk", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 16px;
}

/* thin, trackless scrollbars (Claude-desktop style) */
* { scrollbar-width: thin; scrollbar-color: #ffffff30 transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ffffff2e; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #ffffff4d; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-corner { background: transparent; }

.site {
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-left: 3px solid var(--frame);
  border-right: 3px solid var(--frame);
  border-bottom: 3px solid var(--frame);
}

.body-row {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-head {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--text-dim);
  padding: 18px 18px 10px;
  flex-shrink: 0;
}

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

.conv-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 8px 10px;
  cursor: pointer;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
}
.conv-item:hover { background: var(--bg-elevated); color: var(--text); }
.conv-item.active { border-left-color: var(--accent); color: var(--text); }

.conv-title {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.conv-del {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1;
  padding: 3px 6px;
  cursor: pointer;
  visibility: hidden;
  flex-shrink: 0;
}
.conv-item:hover .conv-del { visibility: visible; }
.conv-del:hover { color: var(--text); }
.conv-del.confirm {
  visibility: visible;
  color: #ff7a6e;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.conv-empty {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
  padding: 8px 10px;
}

/* ------------------------------------------------------------------ nav */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 3px solid var(--frame);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 19px;
}

.logo-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.22em;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 3px 7px;
  margin-left: 6px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-btn {
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 8px 16px;
  cursor: pointer;
}
.nav-btn:hover { background: var(--text); color: var(--bg); }

/* ------------------------------------------------------------------ chat */
.chat-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 28px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.empty-state { margin: auto; text-align: center; max-width: 640px; }
.empty-title { font-size: 30px; font-weight: 600; letter-spacing: -0.01em; }
.empty-sub { color: var(--text-secondary); margin-top: 10px; font-size: 15px; line-height: 1.5; }
.suggestions { margin-top: 28px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.suggestion {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 10px 16px;
  cursor: pointer;
  max-width: 560px;
}
.suggestion:hover { border-color: var(--border-strong); color: var(--text); }

.msg { max-width: 860px; width: 100%; margin: 0 auto; }

.msg-user .msg-body {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  border-left: 3px solid var(--accent);
  padding: 6px 0 6px 14px;
  white-space: pre-wrap;
}
.msg-user .msg-label, .msg-assistant .msg-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.msg-assistant .msg-body { line-height: 1.62; font-size: 15.5px; }
.msg-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 10px;
}

/* rendered markdown */
.msg-body h1, .msg-body h2 { font-size: 19px; margin: 18px 0 8px; }
.msg-body h3, .msg-body h4 { font-size: 16px; margin: 16px 0 6px; }
.msg-body p { margin: 10px 0; }
.msg-body ul, .msg-body ol { margin: 10px 0 10px 22px; }
.msg-body li { margin: 4px 0; }
.msg-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 1px 5px;
}
.msg-body pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 12px;
  overflow-x: auto;
  margin: 10px 0;
}
.msg-body pre code { border: none; background: none; padding: 0; }
.msg-body blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 14px;
  color: var(--text-secondary);
  margin: 10px 0;
  font-style: normal;
}
.msg-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.msg-body .tbl-wrap { overflow-x: auto; margin: 12px 0; }
.msg-body table { border-collapse: collapse; font-size: 13.5px; min-width: 480px; }
.msg-body th, .msg-body td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.msg-body th {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  text-transform: uppercase;
}
.msg-body strong { font-weight: 600; }

/* charts */
.chart { margin: 16px 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.chart-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.chart-ylab { color: var(--text-dim); text-transform: none; letter-spacing: 0.04em; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-item {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.legend-dot { width: 8px; height: 8px; display: inline-block; }
.chart-pending {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  padding: 10px 0;
}

/* export controls */
.tbl-export {
  display: block;
  margin: 10px 0 -8px auto;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 2px 0;
}
.tbl-export:hover { color: var(--accent); }
.tbl-export:disabled { color: var(--text-dim); cursor: default; }

.msg-actions { margin-top: 10px; display: flex; gap: 18px; }
.action-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 0;
}
.action-btn:hover { color: var(--accent); }
.action-btn:disabled { color: var(--text-dim); cursor: default; }

/* ------------------------------------------------------------------ composer */
.composer {
  padding: 14px 28px 12px;
  flex-shrink: 0;
}

.status {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  margin: 0 auto 10px;
  max-width: 860px;
}
.status::before { content: "▎ "; }

/* processing steps (website "intelligence engine" style) */
.progress {
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 4px 0 6px;
  transition: opacity 0.4s;
}
.progress.fading { opacity: 0; }
.pstep { color: var(--text-dim); }
.pstep::before { content: "▎ "; color: var(--text-dim); }
.pstep.active { color: var(--accent); }
.pstep.active::before { color: var(--accent); }
.pstep.active .ptxt::after {
  content: "...";
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  width: 0;
  animation: pdots 1.2s steps(4, end) infinite;
}
@keyframes pdots { to { width: 1.3em; } }
.pnote { color: var(--text-dim); margin-left: 8px; }

/* The shell is the visible box: full answer width, textarea on top, a
   reserved bottom strip for the Submit button (text never enters that row). */
.input-shell {
  max-width: 860px;
  margin: 0 auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.input-shell:focus-within { border-color: var(--border-strong); }

/* Sizing contract with app.js autosize(): line-height 22px, padding 12+2px,
   borderless. 3 lines = 80px default, 8 lines = 190px max, then scrolls. */
#input {
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 22px;
  padding: 12px 15px 2px;
  resize: none;
  outline: none;
  height: 80px;
  min-height: 80px;
  max-height: 190px;
  overflow-y: auto;
}

.shell-bar {
  display: flex;
  justify-content: flex-end;
  padding: 6px 10px 8px;
  flex-shrink: 0;
}

.send-btn {
  background: var(--text);
  color: var(--bg);
  border: none;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 5px 14px;
  cursor: pointer;
}
.send-btn:disabled { opacity: 0.35; cursor: default; }

.composer-note {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-align: center;
  margin-top: 10px;
}

@media (max-width: 900px) {
  .sidebar { display: none; }
}

@media (max-width: 700px) {
  .site { border-left: none; border-right: none; }
  .nav, .messages, .composer { padding-left: 16px; padding-right: 16px; }
  .logo-tag { display: none; }
}

/* ------------------------------------------------------- account menu */
.account {
  position: relative;
  display: flex;
  align-items: center;
}

.account-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: 1px solid transparent;
  color: var(--text);          /* matches the "New conversation" label */
  cursor: pointer;
  transition: border-color 0.12s;
}

.account-btn:hover,
.account.open .account-btn {
  border-color: var(--border-strong);
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.12s, transform 0.12s, visibility 0.12s;
}

/* keeps hover alive while the pointer crosses the gap to the menu */
.account-menu::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 10px;
}

.account.open .account-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.account-email {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.account-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 13.5px;
  cursor: pointer;
}

.account-item:hover {
  background: #ffffff0f;
  color: var(--text);
}

/* ---------------------------------------------------------------- auth */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.auth-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

/* website-matching header on the full-screen auth states */
.auth-nav {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 40px;
  border-bottom: 3px solid var(--frame);
}

.auth-nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.14em;
}

.auth-nav-links {
  display: flex;
  align-items: center;
  gap: 30px;
}

.auth-nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  text-transform: uppercase;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  transition: color 0.2s;
  white-space: nowrap;
}

.auth-nav-links a:hover { color: var(--text); }

.auth-nav-cta {
  border: 1px solid var(--border);
  color: var(--text) !important;
  padding: 8px 18px;
  transition: background 0.2s, color 0.2s;
}

.auth-nav-cta:hover { background: var(--text); color: var(--bg) !important; }

@media (max-width: 820px) {
  .auth-nav { padding: 16px 20px; }
  .auth-nav-links { gap: 18px; }
  .auth-nav-links a:not(.auth-nav-cta) { display: none; }
}

.auth-modal {
  background: #000000c4;
  backdrop-filter: blur(3px);
}

.auth-card {
  width: 380px;
  max-width: calc(100vw - 48px);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 36px 32px 28px;
}

.auth-brand {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 15px;
  margin-bottom: 26px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.auth-tag {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--accent);
}

.auth-title {
  font-size: 21px;
  font-weight: 600;
  margin-bottom: 8px;
}

.auth-sub {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.auth-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  margin: 14px 0 6px;
}

.auth-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 15px;
  padding: 10px 12px;
  outline: none;
}

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

.auth-error {
  margin-top: 14px;
  font-size: 13px;
  color: #f78c6c;
  line-height: 1.45;
}

.auth-error.ok { color: var(--accent); }   /* confirmations, not failures */

.auth-btn {
  width: 100%;
  margin-top: 20px;
  background: var(--text);
  color: var(--bg);
  border: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: 0.02em;
  padding: 11px 0;
  cursor: pointer;
}

.auth-btn:hover:not(:disabled) { background: var(--accent); }
.auth-btn:disabled { opacity: 0.6; cursor: default; }

.auth-foot {
  margin-top: 22px;
  font-size: 12px;
  color: var(--text-dim);
}

.auth-foot a { color: var(--text-secondary); }
