:root {
  --navy: #12203a;
  --navy-dark: #0b1526;
  --gold: #c9a24b;
  --gold-light: #e6cd8a;
  --gold-tint: #f5efe0;
  --sidebar-bg: #fafaf8;
  --sidebar-hover: #efe9db;
  --sidebar-border: #e7e4dc;
  --ink: #1c2431;
  --muted: #6b7280;
  --border: #e5e5e5;
  --main-bg: #ffffff;
  --row-bot-bg: #f7f7f8;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--main-bg);
}

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

/* Sidebar */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  padding: 10px;
  transition: width 0.18s ease, padding 0.18s ease, opacity 0.15s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  padding: 10px 0;
  opacity: 0;
  border-right: none;
}

.sidebar-top { margin-bottom: 6px; }

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.new-chat-btn:hover { background: var(--sidebar-hover); }
.new-chat-btn span {
  font-size: 1rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-top: 2px;
}
.search-icon { font-size: 0.8rem; opacity: 0.6; }
.sidebar-search input {
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  width: 100%;
}
.sidebar-search input::placeholder { color: var(--muted); }

.sidebar-history {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}

.sidebar-item {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-item:hover { background: var(--sidebar-hover); }
.sidebar-item.active { background: var(--gold-tint); }

.sidebar-bottom {
  border-top: 1px solid var(--sidebar-border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-brand {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
  padding: 4px 12px;
}

/* Main chat area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.chat-topbar {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-topbar strong { font-size: 1.05rem; font-weight: 600; color: var(--navy); }
.chat-topbar .chevron { color: var(--muted); font-size: 0.9rem; }

.sidebar-toggle {
  background: transparent;
  border: none;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
  color: var(--navy);
  cursor: pointer;
}
.sidebar-toggle:hover { background: var(--row-bot-bg); }

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.chat-messages {
  display: flex;
  flex-direction: column;
}

/* Empty hero (centered composer, like ChatGPT's start screen) */
.empty-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 20px;
  text-align: center;
}
.empty-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}
.empty-hero h1 { font-size: 1.8rem; font-weight: 400; margin: 0; color: var(--ink); }

#composerSlotCentered { width: min(620px, 90vw); }

.suggestions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 680px;
}
.chip {
  border: 1px solid var(--border);
  background: var(--main-bg);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
}
.chip:hover { background: var(--gold-tint); border-color: var(--gold); }

.msg-row {
  padding: 24px 16px;
}
.msg-row.msg-row-bot { background: var(--row-bot-bg); }

.msg-row-inner {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.avatar-bot { background: var(--navy); color: var(--gold-light); }
.avatar-user { background: #d1d5db; color: #1c2431; }

.msg-text {
  font-size: 0.95rem;
  line-height: 1.7;
  white-space: pre-wrap;
  padding-top: 3px;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  padding-top: 8px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9a9ba5;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Composer (shared by centered + docked states) */
.chat-input-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--main-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 12px 12px 12px 20px;
  box-shadow: 0 6px 18px rgba(18, 32, 58, 0.08);
}

.chat-input-form textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  max-height: 200px;
  background: transparent;
}
.chat-input-form textarea:disabled { opacity: 0.6; cursor: not-allowed; }

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--navy);
  color: var(--gold-light);
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.15s ease;
}
.send-btn:hover { background: var(--navy-dark); transform: scale(1.06); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn:disabled:hover { background: var(--navy); transform: none; }

/* Input area (docked at bottom once conversation has messages) */
.chat-input-area {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--border);
}

#composerSlotDocked { width: 100%; }

.chat-input-area #composerSlotDocked {
  max-width: 620px;
  margin: 0 auto;
}

.disclaimer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
  padding: 10px 16px 16px;
}
.disclaimer a { color: var(--muted); text-decoration: underline; }
.disclaimer a:hover { color: var(--navy); }

/* Responsive */
@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .empty-hero h1 { font-size: 1.4rem; }
}
