/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #171717;
  --bg-sidebar: #212121;
  --bg-surface: #2a2a2a;
  --bg-hover: #333333;
  --border: #3a3a3a;
  --text: #ececec;
  --text-secondary: #9e9e9e;
  --accent: #10a37f;
  --accent-hover: #0d8c6d;
  --danger: #ef4444;
  --user-msg: #2b3b2b;
  --radius: 8px;
  --sidebar-w: 260px;
  --input-h: 72px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.sidebar-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-title { font-weight: 600; font-size: 15px; }

.sidebar-actions { padding: 10px 12px; }

.btn-new-chat {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
}
.btn-new-chat:hover { background: var(--bg-hover); }

.conversation-list {
  flex: 1; overflow-y: auto;
  padding: 4px 8px;
}

.conv-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  transition: background .15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item:hover { background: var(--bg-hover); color: var(--text); }
.conv-item.active { background: var(--bg-surface); color: var(--text); }

.conv-icon { flex-shrink: 0; opacity: .5; font-size: 13px; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex; align-items: center; gap: 10px;
}

.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10a37f, #0d8c6d);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 500; }
.user-plan { font-size: 11px; color: var(--text-secondary); }

/* ===== Main Chat Area ===== */
.main-area {
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
}

.chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.chat-header-title {
  font-size: 16px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 50vw;
}

.chat-header-nav { display: flex; align-items: center; gap: 14px; }
.chat-header-nav a { font-size: 13px; color: var(--text-secondary); }
.chat-header-nav a:hover { color: var(--text); text-decoration: none; }
.chat-header-cta {
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
}
.chat-header-cta:hover { border-color: var(--accent); color: var(--text); }

.model-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.model-pill:hover { border-color: var(--accent); color: var(--text); }
.model-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(16,163,127,.18);
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-surface);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
}

.message-row {
  display: flex; gap: 16px;
  padding: 16px 24px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

.message-row.user { background: transparent; }
.message-row.assistant { background: var(--bg-sidebar); }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 4px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.msg-avatar.user-av { background: #4a4a6a; color: #fff; }
.msg-avatar.ai-av { background: var(--accent); color: #fff; }

.msg-content { flex: 1; min-width: 0; line-height: 1.65; }
.msg-content p + p { margin-top: 10px; }
.msg-content pre {
  margin-top: 10px;
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
}
.msg-content code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
}
.msg-content :not(pre) > code {
  background: #1a1a1a;
  padding: 2px 6px;
  border-radius: 4px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.chip {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--bg-hover);
}

.typing-cursor {
  display: inline-block;
  width: 8px; height: 16px;
  background: var(--text);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

.streaming-body { white-space: normal; }
.streaming-body p:first-child { margin-top: 0; }
.streaming-body p:last-child { margin-bottom: 0; }

.reasoning-drawer {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .02);
  font-size: 13px;
}
.reasoning-drawer summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 12px;
  color: var(--text-secondary);
  user-select: none;
}
.reasoning-drawer summary::-webkit-details-marker { display: none; }
.reasoning-drawer summary::after {
  content: '▸';
  float: right;
  transition: transform .15s;
  font-size: 11px;
  opacity: .6;
}
.reasoning-drawer[open] summary::after { transform: rotate(90deg); }
.reasoning-label {
  display: inline-flex; align-items: center; gap: 8px;
}
.reasoning-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulseDot 1.4s ease-in-out infinite;
}
.reasoning-drawer:not([open]) .reasoning-dot { animation: none; opacity: .5; }
.reasoning-body {
  padding: 0 14px 12px;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  max-height: 360px;
  overflow-y: auto;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.85); }
}

.msg-error {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(239, 68, 68, .08);
  border: 1px solid rgba(239, 68, 68, .35);
  color: #fda4a4;
  font-size: 13px;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ===== Chat Input ===== */
.chat-input-area {
  padding: 0 24px 20px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

.input-wrapper {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}

.input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 160px;
  line-height: 1.5;
}

.input-wrapper textarea::placeholder { color: var(--text-secondary); }

.btn-send {
  width: 36px; height: 36px;
  border: none; border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: .4; cursor: default; }

.chat-disclaimer {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 10px;
}

/* ===== Auth Pages (login / register) ===== */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%; max-width: 420px;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  width: 48px; height: 48px;
  background: var(--accent);
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 22px; color: #fff;
  margin-bottom: 16px;
}

.auth-header h1 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.auth-header p { color: var(--text-secondary); font-size: 14px; }

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px; font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.form-input:focus { border-color: var(--accent); }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }

.auth-banner {
  display: none;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid transparent;
  line-height: 1.45;
}
.auth-banner[data-kind="error"] {
  background: rgba(239, 68, 68, .08);
  border-color: rgba(239, 68, 68, .35);
  color: #fda4a4;
}
.auth-banner[data-kind="info"] {
  background: rgba(16, 163, 127, .08);
  border-color: rgba(16, 163, 127, .35);
  color: #7fd2b9;
}

.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0;
  color: var(--text-secondary);
  font-size: 13px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.btn-sso {
  width: 100%;
  padding: 10px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s;
}
.btn-sso:hover { background: var(--bg-hover); }
.btn-sso + .btn-sso { margin-top: 10px; }

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===== Pricing Page ===== */
.pricing-page {
  min-height: 100vh;
  padding: 60px 24px;
}

.pricing-header {
  text-align: center;
  margin-bottom: 48px;
}

.pricing-header h1 { font-size: 32px; font-weight: 700; margin-bottom: 8px; }
.pricing-header p { color: var(--text-secondary); font-size: 16px; }

.pricing-grid {
  display: flex; gap: 20px;
  max-width: 960px;
  margin: 0 auto;
  justify-content: center;
}

.pricing-card {
  flex: 1; max-width: 300px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px;
  display: flex; flex-direction: column;
}

.pricing-card.featured {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(16,163,127,.15);
}

.pricing-name { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.pricing-desc { color: var(--text-secondary); font-size: 13px; margin-bottom: 20px; }

.pricing-price {
  font-size: 36px; font-weight: 700;
  margin-bottom: 20px;
}
.pricing-price span { font-size: 16px; font-weight: 400; color: var(--text-secondary); }

.pricing-features {
  list-style: none;
  flex: 1;
  margin-bottom: 24px;
}
.pricing-features li {
  padding: 6px 0;
  font-size: 14px;
  color: var(--text-secondary);
}
.pricing-features li::before { content: '✓ '; color: var(--accent); font-weight: 600; }

/* ===== Blog ===== */
.blog-page, .post-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px;
}

.blog-page h1, .post-page h1 { font-size: 28px; font-weight: 700; margin-bottom: 24px; }

.post-meta { color: var(--text-secondary); font-size: 13px; margin-bottom: 24px; }

.post-card {
  display: block;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 12px;
  color: var(--text);
  transition: border-color .15s;
}
.post-card:hover { border-color: var(--accent); text-decoration: none; }
.post-card h2 { font-size: 18px; margin-bottom: 6px; }
.post-card p { color: var(--text-secondary); font-size: 14px; }

.post-body { line-height: 1.8; }
.post-body h2 { font-size: 20px; margin: 28px 0 12px; }
.post-body h3 { font-size: 17px; margin: 24px 0 10px; }
.post-body p { margin-bottom: 14px; color: #ccc; }
.post-body ul, .post-body ol { margin: 10px 0 14px 24px; color: #ccc; }
.post-body li { margin-bottom: 6px; }
.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  color: var(--text-secondary);
  margin: 16px 0;
}
.post-body pre {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 14px 0;
}

.post-back { display: inline-block; margin-top: 32px; font-size: 14px; }

/* ===== Legal Pages ===== */
.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px;
}

.legal-page h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.legal-page .last-updated { color: var(--text-secondary); font-size: 13px; margin-bottom: 32px; }
.legal-page h2 { font-size: 20px; margin: 28px 0 12px; }
.legal-page p { margin-bottom: 14px; color: #ccc; line-height: 1.7; }

/* ===== Navigation (non-app pages) ===== */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 16px;
  color: var(--text);
}
.nav-brand:hover { text-decoration: none; }

.nav-links { display: flex; gap: 20px; align-items: center; }
.nav-links a { color: var(--text-secondary); font-size: 14px; }
.nav-links a:hover { color: var(--text); text-decoration: none; }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
}

.footer-links { display: flex; gap: 16px; justify-content: center; margin-bottom: 8px; }
.footer-links a { color: var(--text-secondary); font-size: 13px; }

/* ===== Utility ===== */
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

/* ===== Mobile ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .message-row { padding: 14px 16px; }
  .chat-input-area { padding: 0 16px 16px; }
  .pricing-grid { flex-direction: column; align-items: center; }
  .pricing-card { max-width: 100%; }

  .navbar { flex-wrap: wrap; gap: 10px; }
  .nav-links { gap: 12px; }
}
