:root {
  --bg-main: #090d16;
  --bg-sidebar: #060910;
  --bg-surface: #0f172a;
  --bg-card: #131d33;
  --bg-input: #090d16;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #38bdf8;
  --primary: #38bdf8;
  --primary-hover: #0284c7;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --success: #4ade80;
  --danger: #f87171;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
}

/* Layout */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 50;
}

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

.brand-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-sm);
}

.btn-new-chat {
  margin: 14px 16px 8px 16px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-new-chat:hover {
  background: var(--bg-card);
  border-color: rgba(56, 189, 248, 0.4);
  color: var(--primary);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s;
}

.history-item:hover, .history-item.active {
  background: var(--bg-surface);
  color: var(--text-main);
}

.history-item.active {
  border-left: 2px solid var(--primary);
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}

/* Main Chat Section */
.main-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-main);
  position: relative;
}

.chat-navbar {
  height: 60px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(12px);
  z-index: 10;
}

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

.btn-menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
}

.persona-select-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.persona-select {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 7px 12px;
  font-size: 13.5px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.persona-select:focus {
  border-color: var(--border-focus);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-action:hover {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-focus);
}

/* Chat Messages Canvas */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.chat-welcome {
  max-width: 640px;
  margin: 40px auto 0 auto;
  text-align: center;
}

.welcome-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.welcome-subtitle {
  font-size: 14.5px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  text-align: left;
}

.suggestion-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.suggestion-card:hover {
  background: var(--bg-card);
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateY(-2px);
}

.suggestion-card h4 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
}

.suggestion-card p {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Message Rows */
.message-row {
  display: flex;
  gap: 14px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.message-row.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar.bot {
  background: #0369a1;
  color: #fff;
}

.avatar.user {
  background: #334155;
  color: #fff;
}

.message-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-main);
  max-width: calc(100% - 60px);
  word-break: break-word;
}

.message-row.user .message-content {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

.message-content p {
  margin-bottom: 10px;
}
.message-content p:last-child {
  margin-bottom: 0;
}

.message-content code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}

.message-content pre {
  background: #04060d;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin: 10px 0;
  position: relative;
}

.message-content pre code {
  background: transparent;
  padding: 0;
  color: #38bdf8;
}

.copy-code-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.copy-code-btn:hover {
  opacity: 1;
  color: #fff;
}

/* Chat Input Bar */
.chat-input-wrapper {
  padding: 16px 20px;
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
}

.chat-form {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  transition: border-color 0.15s;
}

.chat-form:focus-within {
  border-color: var(--border-focus);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 140px;
  min-height: 24px;
  line-height: 1.5;
}

.btn-send {
  background: var(--primary-hover);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.btn-send:hover {
  background: #0284c7;
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .btn-menu-toggle {
    display: block;
  }
}
