:root {
  --bg: #f3f1eb;
  --bg-2: #e6e0d7;
  --ink: #1c1b1a;
  --muted: #6c6862;
  --accent: #0a6b6b;
  --accent-2: #c58b3c;
  --card: #ffffff;
  --shadow: 0 20px 60px rgba(28, 27, 26, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans 3", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fdf7ef, var(--bg)) fixed;
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  min-height: 100vh;
}

.sidebar {
  padding: 32px 24px;
  background: linear-gradient(180deg, #1c1b1a 0%, #252320 100%);
  color: #f5efe6;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo {
  width: 44px;
  height: 44px;
  background: var(--accent-2);
  color: #1c1b1a;
  font-family: "Playfair Display", serif;
  font-weight: 700;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

.brand-title {
  font-family: "Playfair Display", serif;
  font-size: 20px;
}

.brand-sub {
  font-size: 12px;
  color: #d7d0c5;
}

.new-chat {
  border: 1px solid #544f49;
  background: transparent;
  color: #f5efe6;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
}

.section-title {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: #9b948a;
}

.convo-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.convo {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.convo.active {
  background: rgba(255, 255, 255, 0.2);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.pill {
  background: rgba(255, 255, 255, 0.14);
  padding: 8px 12px;
  border-radius: 999px;
}

#modeSelect {
  background: #2e2a26;
  color: #f5efe6;
  border: 1px solid #544f49;
  padding: 8px 12px;
  border-radius: 10px;
}

.chat {
  padding: 32px 48px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  background: linear-gradient(150deg, rgba(197, 139, 60, 0.08), transparent 60%);
  position: relative;
}

.chat::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 70% 10%, rgba(10, 107, 107, 0.12), transparent 60%);
  pointer-events: none;
}

.chat-header h1 {
  font-family: "Playfair Display", serif;
  margin: 0 0 8px 0;
}

.chat-header p {
  margin: 0;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.dot {
  width: 8px;
  height: 8px;
  background: #2ecc71;
  border-radius: 50%;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 12px;
  overflow-y: auto;
}

.message {
  display: flex;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 70%;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  line-height: 1.5;
}

.message.user .bubble {
  background: var(--accent);
  color: #f7f4ef;
}

.composer {
  display: grid;
  gap: 12px;
}

.upload {
  border: 1px dashed #b6b0a6;
  background: rgba(255, 255, 255, 0.6);
  padding: 14px;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
}

.upload input {
  display: none;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
}

textarea {
  resize: none;
  min-height: 68px;
  border-radius: 12px;
  border: 1px solid #c9c1b6;
  padding: 12px;
  font-family: "Source Sans 3", sans-serif;
  background: #fff;
}

#sendBtn {
  background: var(--accent-2);
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

.sources {
  padding: 32px 24px;
  background: var(--bg-2);
}

.sources-list {
  display: grid;
  gap: 12px;
}

.source-card {
  background: #fff;
  padding: 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.source-card.empty {
  color: var(--muted);
}

.login {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 6, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #fff;
  padding: 32px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  min-width: 320px;
  display: grid;
  gap: 12px;
}

.login-card h2 {
  margin: 0;
  font-family: "Playfair Display", serif;
}

.login-card input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #c9c1b6;
}

.login-card button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}

.login-error {
  color: #b3261e;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar,
  .sources {
    display: none;
  }
  .chat {
    padding: 24px;
  }
}
