:root {
  --color-ink: #0C0F16;
  --color-ink-soft: #11141B;
  --color-soot: #1a1d24;
  --color-steel: #252830;
  --color-mint: #75DAB4;
  --color-mint-deep: #3FBE94;
  --color-mint-soft: #C5EDD9;
  --color-mint-glow: rgba(117, 218, 180, 0.13);
  --color-signal: #FF6B00;
  --color-bone: #EDE8DA;
  --color-cream: #F5F1E8;
  --color-paper: #FAFAFA;
  --color-gray-300: #d4d4d4;
  --color-gray-400: #a3a3a3;
  --color-gray-500: #737373;
  --color-gray-700: #404040;
  --color-danger: #ef4444;

  --font-display: "Fraunces", ui-serif, Georgia, serif;
  --font-body: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-grotesk: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / .3), 0 2px 4px -2px rgb(0 0 0 / .2);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .35), 0 4px 6px -4px rgb(0 0 0 / .2);
  --shadow-glow: 0 0 32px rgb(117 218 180 / .18);

  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--color-ink);
  color: var(--color-bone);
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.screen { display: none; height: 100%; }
.screen.active { display: flex; }

.brand-mark {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-bone);
  letter-spacing: -0.01em;
}
.brand-mark--accent { color: var(--color-mint); }

/* ---------------- LOGIN ---------------- */
#login-screen {
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at top, rgba(117,218,180,0.08), transparent 60%),
    var(--color-ink);
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 40px;
  background: var(--color-ink-soft);
  border: 1px solid var(--color-steel);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
}
.login-card .brand { font-size: 22px; margin-bottom: 28px; }
.login-card h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 6px;
}
.login-card .subtitle {
  color: var(--color-gray-400);
  font-size: 14px;
  margin: 0 0 28px;
}
#login-form { display: flex; flex-direction: column; gap: 16px; }
#login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-family: var(--font-grotesk);
  color: var(--color-gray-400);
}
#login-form input {
  background: var(--color-soot);
  border: 1px solid var(--color-steel);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  color: var(--color-bone);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
  transition: border-color .15s var(--ease-out);
}
#login-form input:focus { border-color: var(--color-mint); }
#login-form button {
  margin-top: 8px;
  background: var(--color-mint);
  color: var(--color-ink);
  border: none;
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: var(--font-grotesk);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: background .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
#login-form button:hover { background: var(--color-mint-deep); box-shadow: var(--shadow-glow); }
.error-msg { color: var(--color-danger); font-size: 13px; min-height: 18px; }

/* ---------------- APP LAYOUT ---------------- */
#app-screen { width: 100%; }

.sidebar {
  width: 272px;
  flex-shrink: 0;
  background: var(--color-ink-soft);
  border-right: 1px solid var(--color-steel);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.sidebar-brand { font-size: 18px; padding: 4px 8px 20px; }
.new-chat-btn {
  background: transparent;
  border: 1px solid var(--color-mint);
  color: var(--color-mint);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: var(--font-grotesk);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s var(--ease-out), box-shadow .15s var(--ease-out);
  margin-bottom: 16px;
}
.new-chat-btn:hover { background: var(--color-mint-glow); box-shadow: var(--shadow-glow); }

.conversation-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.conversation-item {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  color: var(--color-gray-300);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background .12s var(--ease-out);
}
.conversation-item:hover { background: var(--color-steel); }
.conversation-item.active { background: var(--color-mint-glow); color: var(--color-mint-soft); }
.conversation-item .del-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--color-gray-500);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
}
.conversation-item:hover .del-btn { opacity: 1; }
.conversation-item .del-btn:hover { color: var(--color-danger); }

.sidebar-footer {
  border-top: 1px solid var(--color-steel);
  padding-top: 14px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--color-gray-400);
}
.link-btn {
  background: none;
  border: none;
  color: var(--color-gray-400);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.link-btn:hover { color: var(--color-mint); }

/* ---------------- CHAT ---------------- */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--color-ink);
  position: relative;
}

.drop-overlay {
  position: absolute;
  inset: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 15, 22, 0.88);
  border: 2px dashed var(--color-mint);
  border-radius: var(--radius-2xl);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s var(--ease-out);
}
.drop-overlay.active { opacity: 1; pointer-events: auto; }
.drop-overlay-inner {
  text-align: center;
  color: var(--color-mint-soft);
}
.drop-overlay-inner svg { display: block; margin: 0 auto 12px; }
.drop-overlay-inner p {
  font-family: var(--font-grotesk);
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.empty-state {
  margin: auto;
  text-align: center;
  color: var(--color-gray-400);
  position: relative;
}
.empty-glow {
  position: absolute;
  top: 50%; left: 50%;
  width: 240px; height: 240px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(117,218,180,0.15), transparent 70%);
  filter: blur(10px);
  z-index: -1;
}
.empty-state h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  color: var(--color-bone);
  margin: 0 0 8px;
}

.msg-row { width: 100%; max-width: 760px; padding: 0 24px; margin-bottom: 22px; }
.msg-bubble { display: flex; gap: 14px; align-items: flex-start; }
.msg-avatar {
  width: 30px; height: 30px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-grotesk); font-weight: 700; font-size: 12px;
  flex-shrink: 0; margin-top: 2px;
}
.msg-row.user .msg-avatar { background: var(--color-steel); color: var(--color-gray-300); }
.msg-row.assistant .msg-avatar { background: var(--color-mint); color: var(--color-ink); }
.msg-body { flex: 1; padding-top: 3px; }
.msg-content {
  line-height: 1.65;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg-row.user .msg-content { color: var(--color-bone); }
.msg-row.assistant .msg-content { color: var(--color-cream); }
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.msg-attachments .attachment-chip {
  background: var(--color-steel);
  color: var(--color-gray-300);
  font-size: 12px;
  padding: 4px 10px;
  margin: 0;
}
.msg-content code {
  font-family: var(--font-mono);
  background: var(--color-soot);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.tool-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-grotesk);
  font-size: 12px;
  color: var(--color-mint-soft);
  background: var(--color-mint-glow);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  margin: 4px 0;
}

.chat-input-form {
  width: 100%;
  max-width: 760px;
  margin: 0 auto 24px;
  padding: 0 24px;
}
.composer {
  background: var(--color-ink-soft);
  border: 1px solid var(--color-steel);
  border-radius: var(--radius-xl);
  padding: 10px 10px 8px;
  transition: border-color .15s var(--ease-out);
}
.composer:focus-within { border-color: var(--color-mint); }

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.chat-input-form textarea {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  padding: 8px 4px;
  color: var(--color-bone);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  max-height: 200px;
  outline: none;
}
.chat-input-form textarea::placeholder { color: var(--color-gray-500); }

.icon-btn {
  background: transparent;
  color: var(--color-gray-400);
  border: none;
  border-radius: var(--radius-full);
  width: 36px; height: 36px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s var(--ease-out), color .15s var(--ease-out);
}
.icon-btn:hover { background: var(--color-steel); color: var(--color-mint); }

#send-btn {
  background: var(--color-mint);
  color: var(--color-ink);
  border: none;
  border-radius: var(--radius-full);
  width: 36px; height: 36px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s var(--ease-out), box-shadow .15s var(--ease-out), opacity .15s;
}
#send-btn:hover { background: var(--color-mint-deep); box-shadow: var(--shadow-glow); }
#send-btn:disabled { opacity: .4; cursor: default; box-shadow: none; }

.composer-toolbar {
  display: flex;
  gap: 14px;
  padding: 8px 8px 2px;
  border-top: 1px solid var(--color-steel);
  margin-top: 8px;
}
.toolbar-select {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-grotesk);
  font-size: 11.5px;
  color: var(--color-gray-500);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.toolbar-select select {
  background: var(--color-soot);
  border: 1px solid var(--color-steel);
  border-radius: var(--radius-sm);
  color: var(--color-mint-soft);
  font-family: var(--font-grotesk);
  font-size: 12.5px;
  text-transform: none;
  letter-spacing: normal;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}
.toolbar-select select:hover, .toolbar-select select:focus { border-color: var(--color-mint); }

.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 6px;
}
.attachment-chips:empty { display: none; }
.attachment-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-steel);
  color: var(--color-gray-300);
  border-radius: var(--radius-md);
  padding: 5px 8px 5px 10px;
  font-size: 12.5px;
  margin-bottom: 6px;
}
.attachment-chip .remove {
  background: none;
  border: none;
  color: var(--color-gray-500);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px;
}
.attachment-chip .remove:hover { color: var(--color-danger); }
.attachment-chip.uploading { color: var(--color-mint-soft); }

.typing-dots span {
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 3px;
  border-radius: 50%;
  background: var(--color-mint);
  animation: blink 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--color-steel); border-radius: var(--radius-full); }
::-webkit-scrollbar-track { background: transparent; }
