:root {
  --bg: #0c0e14;
  --bg-secondary: #12151d;
  --bg-tertiary: #1a1e29;
  --border: #2a2f3d;
  --text: #e2e5ec;
  --text-dim: #8b919e;
  --accent: #7c6ff0;
  --accent-hover: #9688ff;
  --green: #4ade80;
  --red: #f87171;
  --yellow: #facc15;
  --code-bg: #161922;
  --radius: 12px;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Hero ──────────────────────────────────────────── */

.hero {
  background: linear-gradient(180deg, rgba(124,111,240,0.08) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
  padding: 3rem 1rem 2rem;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(124,111,240,0.12);
  border: 1px solid rgba(124,111,240,0.3);
  border-radius: 100px;
  padding: 0.35rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent-hover);
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero .accent { color: var(--accent); }

.hero-sub {
  color: var(--text-dim);
  margin-top: 0.5rem;
  font-size: 1.05rem;
}

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

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  margin-top: 1.75rem;
  flex-wrap: wrap;
}

.stat { text-align: center; }

.stat-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-hover);
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

/* ── App Layout ────────────────────────────────────── */

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
}

/* ── Config Panel ───────────────────────────────────── */

.config-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  height: fit-content;
  position: sticky;
  top: 1rem;
}

.config-panel h2 { font-size: 1rem; margin-bottom: 0.75rem; }

.config-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
  line-height: 1.45;
}

.config-hint code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  display: block;
  margin-top: 0.35rem;
  overflow-x: auto;
  white-space: nowrap;
}

.config-row { margin-bottom: 0.85rem; }

.config-row label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

.config-row .val { color: var(--accent-hover); font-family: var(--font-mono); }

.config-row input[type="url"],
.config-row input[type="password"],
.config-row input[type="number"] {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.2s;
}

.config-row input:focus { border-color: var(--accent); }

.config-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.advanced { margin: 0.85rem 0; }

.advanced summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 0.5rem 0;
  user-select: none;
}

.advanced summary:hover { color: var(--text); }

.config-grid { margin-top: 0.5rem; }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 0.5rem;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.connection-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-dot.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.error { background: var(--red); }
.status-dot.thinking { background: var(--yellow); animation: pulse 1s infinite; }

@keyframes pulse { 50% { opacity: 0.4; } }

/* ── Chat ──────────────────────────────────────────── */

.chat-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  height: 75vh;
  min-height: 500px;
}

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

.chat-header h2 { font-size: 1rem; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover { border-color: var(--red); color: var(--red); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.message {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message.system-message {
  align-self: center;
  max-width: 90%;
  text-align: center;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  font-size: 0.82rem;
}

.message.error-message {
  align-self: center;
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--red);
  font-size: 0.82rem;
}

.message code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--code-bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* Thinking block inside assistant messages */

.thinking-block {
  margin-bottom: 0.65rem;
  border: 1px solid rgba(250,204,21,0.25);
  border-radius: 8px;
  overflow: hidden;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  background: rgba(250,204,21,0.06);
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--yellow);
  user-select: none;
}

.thinking-header .chevron { transition: transform 0.2s; }
.thinking-block.open .chevron { transform: rotate(90deg); }

.thinking-content {
  display: none;
  padding: 0.55rem 0.7rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: pre-wrap;
  max-height: 250px;
  overflow-y: auto;
}

.thinking-block.open .thinking-content { display: block; }

/* Typing indicator */

.typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 0.65rem 1rem;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: bounce 1.2s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Examples ───────────────────────────────────────── */

.examples {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  overflow-x: auto;
  border-top: 1px solid var(--border);
}

.example-btn {
  flex-shrink: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-dim);
  font-size: 0.78rem;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.example-btn:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  background: rgba(124,111,240,0.08);
}

/* ── Chat Input ────────────────────────────────────── */

.chat-input-area { padding: 0.85rem 1rem; border-top: 1px solid var(--border); }

.chat-input-wrapper {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
}

#chatInput {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  padding: 0.65rem 0.85rem;
  resize: none;
  max-height: 150px;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.45;
}

#chatInput:focus { border-color: var(--accent); }
#chatInput::placeholder { color: var(--text-dim); opacity: 0.6; }

.btn-send {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  width: 42px;
  height: 42px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Benchmarks ─────────────────────────────────────── */

.benchmarks {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.benchmarks h2 { text-align: center; margin-bottom: 1.25rem; }

.bench-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.bench-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
}

.bench-card h3 {
  font-size: 0.9rem;
  color: var(--accent-hover);
  margin-bottom: 0.75rem;
}

.bench-row {
  display: grid;
  grid-template-columns: 1fr 80px 44px;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
  font-size: 0.78rem;
}

.bench-label { color: var(--text-dim); }

.bench-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.bench-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 3px;
}

.bench-val {
  font-family: var(--font-mono);
  color: var(--accent-hover);
  text-align: right;
  font-weight: 600;
}

/* ── Footer ─────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
}

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

/* ── Scrollbar ──────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
