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

:root {
  --bg:        #0e0e11;
  --surface:   #16161a;
  --surface2:  #1e1e24;
  --border:    #2a2a32;
  --border2:   #34343e;
  --accent:    #7c6af7;
  --accent-dim:#4e3fb5;
  --text:      #e8e8f0;
  --text-2:    #9898aa;
  --text-3:    #5c5c6e;
  --user-bg:   #1f1d2e;
  --radius:    10px;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Fira Code', monospace;
  --sidebar-w: 248px;
  --input-h:   60px;
}

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

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

.sidebar-header {
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  color: #fff;
  flex-shrink: 0;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 12px 4px;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  width: calc(100% - 24px);
}

.new-chat-btn:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border2);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 0;
}

.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 6px 8px 4px;
  font-weight: 600;
}

.example-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 7px;
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.example-item:hover {
  background: var(--surface2);
  color: var(--text);
}

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

.settings-label {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  display: block;
  margin-bottom: 4px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-row input[type="range"] {
  flex: 1;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border2);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s;
}

.slider-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  min-width: 30px;
  text-align: right;
}

/* ── Main ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 48px 24px;
  gap: 12px;
  text-align: center;
}

.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 4px;
}

.empty-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
}

.empty-sub {
  color: var(--text-2);
  font-size: 14px;
  max-width: 360px;
  line-height: 1.6;
}

.empty-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
  max-width: 500px;
}

.chip {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 99px;
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.chip:hover {
  background: var(--surface);
  border-color: var(--accent-dim);
  color: var(--text);
}

/* ── Messages ── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 0;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

.message {
  display: flex;
  gap: 14px;
  padding: 10px 28px;
  transition: background 0.1s;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.message:hover { background: rgba(255,255,255,0.015); }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  margin-top: 1px;
}

.avatar.user {
  background: var(--accent-dim);
  color: #c5b8ff;
}

.avatar.assistant {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--accent);
}

.bubble {
  flex: 1;
  min-width: 0;
}

.bubble-role {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 6px;
}

.message.user   .bubble-role { color: #8b80d0; }
.message.assistant .bubble-role { color: var(--text-3); }

.bubble-content {
  color: var(--text);
  font-size: 14px;
  line-height: 1.75;
  word-break: break-word;
}

/* Markdown-like rendering */
.bubble-content p { margin-bottom: 10px; }
.bubble-content p:last-child { margin-bottom: 0; }
.bubble-content ul, .bubble-content ol { padding-left: 20px; margin-bottom: 10px; }
.bubble-content li { margin-bottom: 3px; }
.bubble-content strong { color: #fff; font-weight: 600; }
.bubble-content em { color: var(--text-2); font-style: italic; }
.bubble-content h1,.bubble-content h2,.bubble-content h3 {
  font-weight: 600;
  margin: 14px 0 6px;
  color: #fff;
}
.bubble-content h1 { font-size: 18px; }
.bubble-content h2 { font-size: 16px; }
.bubble-content h3 { font-size: 14px; }

/* Inline code */
.bubble-content code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 1px 5px;
  color: #c9b6ff;
}

/* Code blocks */
.code-block {
  margin: 12px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: #141417;
}

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

.code-lang {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  text-transform: lowercase;
}

.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 11px;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.12s;
}

.copy-btn:hover { color: var(--text-2); }
.copy-btn.copied { color: #6fcf97; }

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.7;
  font-family: var(--font-mono);
}

.code-block pre::-webkit-scrollbar { height: 4px; }
.code-block pre::-webkit-scrollbar-track { background: transparent; }
.code-block pre::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* hljs override */
.hljs { background: transparent !important; }

/* Cursor blink */
.cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--accent);
  border-radius: 1px;
  margin-left: 2px;
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Input area ── */
.input-area {
  padding: 12px 28px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px 10px 10px 14px;
  transition: border-color 0.15s;
  max-width: 800px;
  margin: 0 auto;
}

.input-wrapper:focus-within {
  border-color: var(--accent-dim);
}

textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  max-height: 180px;
  overflow-y: auto;
}

textarea::placeholder { color: var(--text-3); }

.send-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.send-btn:hover { background: #6a58e6; }
.send-btn:active { transform: scale(0.93); }
.send-btn:disabled { background: var(--border2); cursor: not-allowed; }

.input-hint {
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  margin-top: 7px;
}

/* ── Responsive ── */
@media (max-width: 680px) {
  .sidebar { display: none; }
  .message { padding: 10px 16px; }
  .input-area { padding: 10px 16px 14px; }
}
