@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ═══════════════════════════════════════════════════
   AI Tool Interface — HTML/CSS Kit v1.0.0 — NexusAI design system
   © 2026 Ashlar Studio · https://ohgotit.com/creator/ashlar-studio
   Support: seller-ashlar@ohgotit.com
   ═══════════════════════════════════════════════════ */

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

/* ── Tokens ── */
:root {
  /* Colors — Deep Space palette with neon accents */
  --bg-primary:      #0a0a0f;
  --bg-secondary:    #12121a;
  --bg-tertiary:     #1a1a26;
  --bg-elevated:     #222233;
  --bg-hover:        #2a2a3a;
  --bg-input:        #16161f;

  --surface-glass:   rgba(255, 255, 255, 0.04);
  --surface-glass-hover: rgba(255, 255, 255, 0.07);

  --text-primary:    #e8e8ed;
  --text-secondary:  #9494a8;
  --text-tertiary:   #8585a0;
  --text-inverse:    #0a0a0f;

  --accent-primary:  #7c5cfc;
  --accent-light:    #9b7fff;
  --accent-dark:     #5a3dd6;
  --accent-glow:     rgba(124, 92, 252, 0.25);
  --accent-subtle:   rgba(124, 92, 252, 0.12);

  --green:           #34d399;
  --green-subtle:    rgba(52, 211, 153, 0.12);
  --red:             #f87171;
  --red-subtle:      rgba(248, 113, 113, 0.12);
  --amber:           #fbbf24;
  --amber-subtle:    rgba(251, 191, 36, 0.12);
  --cyan:            #22d3ee;
  --cyan-subtle:     rgba(34, 211, 238, 0.12);

  --border:          rgba(255, 255, 255, 0.08);
  --border-strong:   rgba(255, 255, 255, 0.14);
  --border-accent:   rgba(124, 92, 252, 0.3);

  /* Typography */
  --font-sans:       'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:       'JetBrains Mono', 'Fira Code', monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.8125rem;
  --text-base: 0.9375rem;
  --text-lg:   1.125rem;
  --text-xl:   1.375rem;
  --text-2xl:  1.75rem;
  --text-3xl:  2.25rem;

  /* Spacing */
  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem;
  --s-4: 1rem; --s-5: 1.25rem; --s-6: 1.5rem;
  --s-8: 2rem; --s-10: 2.5rem; --s-12: 3rem;
  --s-16: 4rem;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --r-xl: 20px; --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --accent-gradient: linear-gradient(135deg, #6d4aef, var(--accent-dark));
  --code-bg: #07070b;

  /* Layout */
  --sidebar-width: 280px;
  --header-height: 56px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 16px; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}
a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main__header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-6);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.main__content {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-elevated) transparent;
}

.main__content::-webkit-scrollbar { width: 6px; }
.main__content::-webkit-scrollbar-track { background: transparent; }
.main__content::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: var(--r-full); }

/* ── Sidebar ── */
.sidebar__header {
  padding: var(--s-5) var(--s-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--text-primary);
}

.sidebar__logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent-primary), var(--cyan));
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
}

.sidebar__new-btn {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  margin: var(--s-4) var(--s-4) var(--s-2);
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.sidebar__new-btn:hover { box-shadow: var(--shadow-glow); transform: translateY(-1px); }

.sidebar__section-label {
  padding: var(--s-4) var(--s-5) var(--s-2);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.sidebar__nav { flex: 1; overflow-y: auto; padding-bottom: var(--s-4); }

.sidebar__item {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  margin: 1px var(--s-2);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.sidebar__item:hover { background: var(--surface-glass-hover); color: var(--text-primary); }
.sidebar__item.active { background: var(--accent-subtle); color: var(--accent-light); }

.sidebar__item-icon { width: 18px; height: 18px; opacity: 0.6; }
.sidebar__item.active .sidebar__item-icon { opacity: 1; }

.sidebar__item-time {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.sidebar__footer {
  border-top: 1px solid var(--border);
  padding: var(--s-3);
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.sidebar__user {
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.sidebar__user:hover { background: var(--surface-glass-hover); }

.sidebar__avatar {
  width: 34px; height: 34px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--accent-primary), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: var(--text-sm); color: white;
}

.sidebar__user-info { flex: 1; min-width: 0; }
.sidebar__username { font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); }
.sidebar__plan { font-size: var(--text-xs); color: var(--text-tertiary); }

/* ── Chat UI ── */
.chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-8) 0;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-elevated) transparent;
}

.chat__message {
  padding: var(--s-6) var(--s-8);
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.chat__message--user {
  display: flex;
  justify-content: flex-end;
}

.chat__bubble-user {
  background: var(--bg-elevated);
  border-radius: var(--r-lg) var(--r-lg) var(--r-sm) var(--r-lg);
  padding: var(--s-4) var(--s-5);
  max-width: 75%;
  font-size: var(--text-base);
  line-height: 1.6;
}

.chat__message--ai {
  display: flex;
  gap: var(--s-4);
}

.chat__ai-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--accent-primary), var(--cyan));
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat__ai-content {
  flex: 1;
  min-width: 0;
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text-primary);
}

.chat__ai-content p { margin-bottom: var(--s-4); }
.chat__ai-content p:last-child { margin-bottom: 0; }

.chat__ai-content code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--cyan);
}

.chat__code-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin: var(--s-4) 0;
  overflow: hidden;
}

.chat__code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-2) var(--s-4);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.chat__code-copy {
  background: none; border: none;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  cursor: pointer;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
}
.chat__code-copy:hover { background: var(--surface-glass-hover); color: var(--text-primary); }

.chat__code-body {
  padding: var(--s-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  overflow-x: auto;
  color: var(--text-secondary);
}

.chat__actions {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

.chat__action-btn {
  background: none; border: none;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  cursor: pointer;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  display: flex; align-items: center; gap: 4px;
  transition: all 0.15s var(--ease);
}
.chat__action-btn:hover { background: var(--surface-glass-hover); color: var(--text-primary); }

/* Streaming indicator */
.chat__typing {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: var(--s-2) 0;
}

.chat__typing-dot {
  width: 6px; height: 6px;
  background: var(--accent-primary);
  border-radius: var(--r-full);
  animation: blink 1.4s infinite both;
}
.chat__typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat__typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ── Input Bar ── */
.chat__input-area {
  padding: var(--s-4) var(--s-8) var(--s-6);
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.chat__input-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  transition: border-color 0.2s var(--ease);
}
.chat__input-box:focus-within { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-subtle); }

.chat__textarea {
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 160px;
  line-height: 1.5;
}
.chat__textarea::placeholder { color: var(--text-tertiary); }

.chat__input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat__input-tools {
  display: flex;
  gap: var(--s-1);
}

.chat__tool-btn {
  background: none; border: none;
  color: var(--text-tertiary);
  padding: var(--s-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex; align-items: center;
  transition: all 0.15s var(--ease);
}
.chat__tool-btn:hover { background: var(--surface-glass-hover); color: var(--text-primary); }

.chat__send-btn {
  width: 36px; height: 36px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--r-md);
  color: white;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s var(--ease);
}
.chat__send-btn:hover { box-shadow: var(--shadow-glow); transform: scale(1.05); }

.chat__disclaimer {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--s-3);
}

/* ── Model Selector ── */
.model-selector {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  background: var(--surface-glass);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.model-selector:hover { background: var(--surface-glass-hover); border-color: var(--border-strong); }

.model-selector__dot {
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: var(--r-full);
}

.model-selector__name { font-weight: 500; color: var(--text-primary); }

/* ── Header actions ── */
.header__actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.header__btn {
  background: none; border: none;
  color: var(--text-secondary);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: var(--text-sm);
  display: flex; align-items: center; gap: var(--s-2);
  transition: all 0.15s var(--ease);
}
.header__btn:hover { background: var(--surface-glass-hover); color: var(--text-primary); }

/* ── Page Layout (for non-chat pages) ── */
.page {
  padding: var(--s-8);
  max-width: 1100px;
  margin: 0 auto;
}

.page__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--s-2);
}

.page__subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin-bottom: var(--s-6);
}

/* ── Cards ── */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
}

.card--glass {
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-5);
}

.card__title {
  font-size: var(--text-lg);
  font-weight: 600;
}

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-5);
  margin-bottom: var(--s-8);
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}

.stat-card__label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--s-2);
}

.stat-card__value {
  font-size: var(--text-2xl);
  font-weight: 700;
}

.stat-card__change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 500;
  margin-top: var(--s-2);
  padding: 2px 8px;
  border-radius: var(--r-full);
}

.stat-card__change--up { background: var(--green-subtle); color: var(--green); }
.stat-card__change--down { background: var(--red-subtle); color: var(--red); }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg-tertiary); }

th {
  text-align: left;
  padding: var(--s-3) var(--s-5);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

td {
  padding: var(--s-4) var(--s-5);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-glass); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 500;
}

.badge--green  { background: var(--green-subtle); color: var(--green); }
.badge--red    { background: var(--red-subtle); color: var(--red); }
.badge--amber  { background: var(--amber-subtle); color: var(--amber); }
.badge--cyan   { background: var(--cyan-subtle); color: var(--cyan); }
.badge--purple { background: var(--accent-subtle); color: var(--accent-light); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  font-family: var(--font-sans);
}

.btn--primary {
  background: var(--accent-gradient);
  color: white;
}
.btn--primary:hover { box-shadow: var(--shadow-glow); transform: translateY(-1px); }

.btn--secondary {
  background: var(--surface-glass);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn--secondary:hover { background: var(--surface-glass-hover); border-color: var(--border-strong); }

.btn--danger {
  background: var(--red-subtle);
  color: var(--red);
}
.btn--danger:hover { background: rgba(248, 113, 113, 0.2); }

.btn--sm { padding: var(--s-2) var(--s-3); font-size: var(--text-xs); }

/* ── Form Controls ── */
.input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  outline: none;
  width: 100%;
  transition: border-color 0.2s var(--ease);
}
.input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-subtle); }
.input::placeholder { color: var(--text-tertiary); }

.select {
  appearance: none;
  background: var(--bg-input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238585a0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-10) var(--s-3) var(--s-4);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
}
.select:focus { border-color: var(--accent-primary); }

/* ── Toggle ── */
.toggle {
  position: relative;
  display: block;
  flex-shrink: 0;
  border: none;
  padding: 0;
  width: 42px; height: 24px;
  background: var(--bg-elevated);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background 0.2s var(--ease);
}
.toggle.active { background: var(--accent-primary); }
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: white;
  border-radius: var(--r-full);
  transition: transform 0.2s var(--ease);
}
.toggle.active::after { transform: translateX(18px); }

/* ── Slider (range) ── */
.slider-group { margin-bottom: var(--s-5); }
.slider-group__header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--s-2);
}
.slider-group__label { font-size: var(--text-sm); color: var(--text-secondary); }
.slider-group__value { font-size: var(--text-sm); font-weight: 600; color: var(--accent-light); font-family: var(--font-mono); }

.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: var(--r-full);
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--accent-primary);
  border-radius: var(--r-full);
  cursor: pointer;
  box-shadow: var(--shadow-glow);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: var(--s-1);
  margin-bottom: var(--s-6);
}

.tab {
  padding: var(--s-3) var(--s-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-light); border-bottom-color: var(--accent-primary); }

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: var(--s-16);
}

.empty-state__icon {
  width: 64px; height: 64px;
  background: var(--accent-subtle);
  border-radius: var(--r-xl);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--s-6);
}

.empty-state__title {
  font-size: var(--text-xl);
  font-weight: 600;
  margin-bottom: var(--s-2);
}

.empty-state__desc {
  font-size: var(--text-base);
  color: var(--text-secondary);
  max-width: 420px;
  margin-bottom: var(--s-6);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(var(--sidebar-width), 85vw);
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar--open { transform: none; }
  .chat__message { padding: var(--s-4); }
  .chat__input-area { padding: var(--s-3) var(--s-4) var(--s-4); }
  .page { padding: var(--s-4); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

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

/* ── Playground-specific ── */
.playground {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100%;
}

.playground__controls {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: var(--s-6);
  overflow-y: auto;
}

.playground__output {
  display: flex;
  flex-direction: column;
}

.playground__output-header {
  padding: var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.playground__output-body {
  flex: 1;
  padding: var(--s-6);
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* ── API Key Styles ── */
.key-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  margin-bottom: var(--s-3);
}

.key-card__info { flex: 1; min-width: 0; }
.key-card__name { font-weight: 600; font-size: var(--text-sm); margin-bottom: 2px; }
.key-card__value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.key-card__actions {
  display: flex;
  gap: var(--s-2);
}

/* ── Usage Meter ── */
.usage-meter {
  margin-bottom: var(--s-5);
}

.usage-meter__header {
  display: flex; justify-content: space-between;
  font-size: var(--text-sm);
  margin-bottom: var(--s-2);
}

.usage-meter__label { color: var(--text-secondary); }
.usage-meter__value { color: var(--text-primary); font-weight: 600; }

.usage-meter__bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--r-full);
  overflow: hidden;
}

.usage-meter__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--cyan));
  border-radius: var(--r-full);
  transition: width 0.5s var(--ease);
}

/* ── Conversation list ── */
.conv-list { list-style: none; }

.conv-item {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.conv-item:hover { background: var(--surface-glass); }
.conv-item:last-child { border-bottom: none; }

.conv-item__icon {
  width: 36px; height: 36px;
  background: var(--accent-subtle);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.conv-item__info { flex: 1; min-width: 0; }
.conv-item__title { font-size: var(--text-sm); font-weight: 500; margin-bottom: 2px; }
.conv-item__preview {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item__meta {
  text-align: right;
  flex-shrink: 0;
}
.conv-item__time { font-size: var(--text-xs); color: var(--text-tertiary); }
.conv-item__tokens { font-size: var(--text-xs); color: var(--text-tertiary); }

/* ── Code syntax highlight colors (mock) ── */
.tok-keyword { color: var(--accent-light); }
.tok-string  { color: var(--green); }
.tok-comment { color: var(--text-tertiary); font-style: italic; }
.tok-func    { color: var(--cyan); }
.tok-num     { color: var(--amber); }


/* ══════════════════════════════════════════════════════
   LIGHT THEME
   ══════════════════════════════════════════════════════ */
[data-theme="light"] {
  --bg-primary:      #f7f7fb;
  --bg-secondary:    #ffffff;
  --bg-tertiary:     #f0f0f6;
  --bg-elevated:     #e7e7f0;
  --bg-hover:        #dedeea;
  --bg-input:        #ffffff;
  --surface-glass:        rgba(20, 20, 40, 0.03);
  --surface-glass-hover:  rgba(20, 20, 40, 0.06);
  --text-primary:    #16161f;
  --text-secondary:  #4a4a5e;
  --text-tertiary:   #666679;
  --text-inverse:    #ffffff;
  --accent-light:    #5b3ee0;
  --accent-glow:     rgba(124, 92, 252, 0.18);
  --accent-subtle:   rgba(124, 92, 252, 0.1);
  --green:           #047857;
  --green-subtle:    rgba(4, 120, 87, 0.1);
  --red:             #c81e1e;
  --red-subtle:      rgba(200, 30, 30, 0.08);
  --amber:           #a14a04;
  --amber-subtle:    rgba(217, 119, 6, 0.12);
  --cyan:            #0e6b82;
  --cyan-subtle:     rgba(14, 116, 144, 0.1);
  --border:          rgba(20, 20, 40, 0.09);
  --border-strong:   rgba(20, 20, 40, 0.16);
  --border-accent:   rgba(124, 92, 252, 0.35);
  --code-bg:         #fafafe;
  --shadow-sm: 0 1px 3px rgba(20, 20, 40, 0.08);
  --shadow-md: 0 4px 12px rgba(20, 20, 40, 0.1);
  --shadow-lg: 0 8px 30px rgba(20, 20, 40, 0.14);
}
[data-theme="light"] .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666679' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }

/* ── Accessibility & shell ── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--s-4); top: -100px; z-index: 100;
  background: var(--accent-gradient); color: #fff;
  padding: var(--s-2) var(--s-4); border-radius: var(--r-md); font-weight: 600;
}
.skip-link:focus { top: var(--s-3); text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }
.input:focus-visible, .select:focus-visible, .chat__textarea:focus-visible { outline: none; }
main:focus { outline: none; }
.icon { width: 16px; height: 16px; flex-shrink: 0; }
[data-theme="dark"] .icon--moon, [data-theme="light"] .icon--sun { display: none; }

.header__left { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.header__title { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.header__icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--r-md);
  background: none; border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer;
  transition: all 0.15s var(--ease);
}
.header__icon-btn:hover { background: var(--surface-glass-hover); color: var(--text-primary); }
.header__icon-btn .icon { width: 18px; height: 18px; }
.header__menu-btn { display: none; border: none; }
.btn:hover { text-decoration: none; }
.btn .icon { width: 14px; height: 14px; }
.btn--ghost { background: none; color: var(--accent-light); padding-inline: var(--s-2); }
.btn--ghost:hover { background: var(--accent-subtle); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.sidebar__logo:hover { text-decoration: none; }
.sidebar__logo-icon .icon { width: 18px; height: 18px; color: #fff; }
.sidebar__new-btn .icon { width: 16px; height: 16px; }
.sidebar__new-btn:hover { text-decoration: none; color: #fff; }
.sidebar__item:hover { text-decoration: none; }
.sidebar__recent { list-style: none; }
.sidebar__item--recent { padding-block: var(--s-2); }
.sidebar__item-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__username, .sidebar__plan { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__signout {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-md); color: var(--text-tertiary); flex-shrink: 0;
}
.sidebar__signout:hover { background: var(--surface-glass-hover); color: var(--red); }
.sidebar__signout .icon { width: 18px; height: 18px; }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.5); }
@media (min-width: 769px) { .sidebar-backdrop { display: none !important; } }

/* ── Model menu ── */
.dropdown { position: relative; }
.model-selector { font: inherit; font-size: var(--text-sm); }
.model-selector .icon { width: 14px; height: 14px; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;
  width: 300px; padding: var(--s-1);
  background: var(--bg-secondary); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
}
.dropdown-menu__item {
  display: grid; grid-template-columns: 1fr auto; column-gap: var(--s-3); align-items: center;
  width: 100%; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
  background: none; border: none; font: inherit; text-align: left; color: var(--text-primary); cursor: pointer;
}
.dropdown-menu__item:hover { background: var(--surface-glass-hover); }
.dropdown-menu__title { font-size: var(--text-sm); font-weight: 500; }
.dropdown-menu__desc { grid-column: 1; font-size: var(--text-xs); color: var(--text-tertiary); }
.dropdown-menu__check { grid-row: 1 / span 2; grid-column: 2; color: var(--accent-light); visibility: hidden; }
.dropdown-menu__item[aria-pressed="true"] .dropdown-menu__check { visibility: visible; }

/* ── Chat additions ── */
.chat__ai-avatar .icon, .chat__ai-avatar svg { color: #fff; }
.chat__ai-content ul { margin: 0 0 var(--s-4) var(--s-5); }
.chat__ai-content li { margin-bottom: var(--s-1); }
.chat__bubble-user { overflow-wrap: anywhere; }
.chat__bubble-user--live { white-space: pre-wrap; }
.chat__code-body { white-space: pre; tab-size: 2; }
pre.chat__code-body { margin: var(--s-4) 0; white-space: pre-wrap; }
.chat__textarea { width: 100%; }
.chat__send-group { display: flex; align-items: center; gap: var(--s-3); }
.chat__hint { font-size: var(--text-xs); color: var(--text-tertiary); }
.chat__tool-btn[aria-pressed="true"] { background: var(--accent-subtle); color: var(--accent-light); }
.chat__send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.chat__message--pending .chat__ai-content { display: flex; align-items: center; min-height: 30px; }

/* ── Forms, settings, lists ── */
.field { margin-bottom: var(--s-4); }
.field__label { display: block; font-size: var(--text-xs); font-weight: 500; color: var(--text-secondary); margin-bottom: var(--s-2); }
.form-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--s-5); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-4); margin-top: var(--s-2); }
.form-status { font-size: var(--text-sm); color: var(--green); }
.card + .card, .card + form.card, form.card + .card { margin-top: var(--s-5); }
.profile { display: flex; gap: var(--s-8); align-items: flex-start; }
.profile__avatar { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); }
.avatar-lg {
  width: 80px; height: 80px; border-radius: var(--r-xl);
  background: linear-gradient(135deg, var(--accent-primary), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-2xl); font-weight: 700; color: #fff;
}
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-4) 0; border-top: 1px solid var(--border);
}
.card__header + .setting-row { border-top: none; padding-top: 0; }
.setting-row__label { font-size: var(--text-sm); font-weight: 500; display: flex; align-items: center; gap: var(--s-2); }
.setting-row__desc { font-size: var(--text-xs); color: var(--text-tertiary); }
.plan-compare { display: flex; gap: var(--s-6); margin-bottom: var(--s-5); }
.invite-row { display: flex; gap: var(--s-2); }
.invite-row .input { flex: 1; }
.member-list { list-style: none; }
.member { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
.member:last-child { border-bottom: none; }
.member__avatar {
  width: 36px; height: 36px; border-radius: var(--r-full); flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-primary), var(--cyan));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: var(--text-xs); font-weight: 600;
}
.member__info { flex: 1; min-width: 0; }
.member__name { display: block; font-size: var(--text-sm); font-weight: 500; }
.member__email { display: block; font-size: var(--text-xs); color: var(--text-tertiary); }
.table-scroll { overflow-x: auto; }
.filters { display: flex; gap: var(--s-3); margin-bottom: var(--s-5); flex-wrap: wrap; }
.filters__search { position: relative; flex: 1; min-width: 220px; }
.filters__search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); }
.filters__search .input { padding-left: 36px; }
.tab[aria-pressed="true"] { color: var(--accent-light); border-bottom-color: var(--accent-primary); }
.conv-item { position: relative; }
.conv-item__title { display: block; color: var(--text-primary); }
.conv-item__title::after { content: ''; position: absolute; inset: 0; }
.conv-item__title:hover { text-decoration: none; }
.conv-item:hover .conv-item__title { color: var(--accent-light); }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: var(--s-5); gap: var(--s-3); flex-wrap: wrap; }
.empty-note { text-align: center; color: var(--text-tertiary); padding: var(--s-8) 0; }

/* ── Playground additions ── */
.main__content--flush { display: flex; flex-direction: column; }
.main__content--flush .playground { flex: 1; min-height: 0; }
.panel-title { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); margin-bottom: var(--s-4); }
output.slider-group__value { display: inline-block; }
.slider { accent-color: var(--accent-primary); }
.slider::-moz-range-thumb { width: 16px; height: 16px; border: none; background: var(--accent-primary); border-radius: var(--r-full); cursor: pointer; }
.playground__meta { font-size: var(--text-xs); color: var(--text-tertiary); margin-left: var(--s-3); }
.playground__output-body:focus-visible { outline-offset: -2px; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-3); }
.chip {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 10px;
  border-radius: var(--r-full); background: var(--accent-subtle); color: var(--accent-light);
  font-family: var(--font-mono); font-size: var(--text-xs);
}
.chip__remove {
  width: 20px; height: 20px; border-radius: var(--r-full); border: none; background: none;
  color: inherit; cursor: pointer; font-size: 14px; line-height: 1;
}
.chip__remove:hover { background: var(--accent-subtle); }

/* ── Prompt library ── */
.prompt-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-4); }
.prompt-card {
  display: flex; flex-direction: column; gap: var(--s-2);
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-5);
  transition: border-color 0.15s var(--ease);
}
.prompt-card:hover { border-color: var(--border-accent); }
.prompt-card__title { font-size: var(--text-base); font-weight: 600; }
.prompt-card__desc { font-size: var(--text-sm); color: var(--text-secondary); flex: 1; }
.prompt-card__actions { display: flex; gap: var(--s-2); margin-top: var(--s-2); }

/* ── Auth & error pages ── */
.auth {
  min-height: 100vh; min-height: 100dvh; overflow-y: auto;
  display: grid; place-items: center; padding: var(--s-6) var(--s-4);
  background: radial-gradient(ellipse at top, var(--accent-subtle), transparent 60%), var(--bg-primary);
}
body:has(.auth) { overflow: auto; height: auto; }
.auth__theme { position: fixed; top: var(--s-4); right: var(--s-4); z-index: 5; }
.auth__card {
  width: 100%; max-width: 400px; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: var(--s-8); box-shadow: var(--shadow-lg);
}
.auth__brand { display: flex; align-items: center; justify-content: center; gap: var(--s-2); font-weight: 700; font-size: var(--text-lg); color: var(--text-primary); margin-bottom: var(--s-6); }
.auth__brand:hover { text-decoration: none; }
.auth__title { font-size: var(--text-xl); font-weight: 700; text-align: center; }
.auth__subtitle { color: var(--text-secondary); text-align: center; font-size: var(--text-sm); margin: var(--s-1) 0 var(--s-6); }
.auth__oauth { display: grid; gap: var(--s-2); }
.auth__oauth .btn { justify-content: center; }
.auth__divider { display: flex; align-items: center; gap: var(--s-3); margin: var(--s-5) 0; color: var(--text-tertiary); font-size: var(--text-xs); text-transform: uppercase; }
.auth__divider::before, .auth__divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth__row { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-5); font-size: var(--text-sm); }
.checkbox-label { display: flex; align-items: center; gap: var(--s-2); cursor: pointer; color: var(--text-secondary); }
.checkbox-label input { accent-color: var(--accent-primary); }
.auth__submit { width: 100%; justify-content: center; }
.auth__reset { display: none; margin-top: var(--s-6); padding-top: var(--s-5); border-top: 1px solid var(--border); }
.auth__reset:target { display: block; }
.auth__reset-title { font-size: var(--text-base); font-weight: 600; margin-bottom: var(--s-3); }
.auth__reset .form-status { margin-top: var(--s-3); }
.auth__footer { text-align: center; color: var(--text-tertiary); font-size: var(--text-xs); margin-top: var(--s-6); }
.error-page { text-align: center; max-width: 440px; }
.error-page__code {
  font-size: 5rem; font-weight: 700; line-height: 1; font-family: var(--font-mono);
  background: linear-gradient(135deg, var(--accent-light), var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.error-page__title { font-size: var(--text-2xl); font-weight: 700; margin: var(--s-4) 0 var(--s-2); }
.error-page__text { color: var(--text-secondary); margin-bottom: var(--s-6); }
.error-page__actions { display: flex; gap: var(--s-3); justify-content: center; flex-wrap: wrap; }

/* ── Responsive additions ── */
@media (max-width: 1024px) {
  .playground { grid-template-columns: 1fr; height: auto; }
  .main__content--flush { overflow-y: auto; }
  .playground__controls { border-right: none; border-bottom: 1px solid var(--border); overflow: visible; }
}
@media (max-width: 768px) {
  .header__menu-btn { display: inline-flex; }
  .main__header { padding: 0 var(--s-3); gap: var(--s-2); }
  .header__link, .chat__hint { display: none; }
  .header__actions .btn { padding-inline: var(--s-3); }
  .dropdown-menu { width: min(300px, calc(100vw - 24px)); }
  .form-grid { grid-template-columns: 1fr; }
  .profile { flex-direction: column; gap: var(--s-4); }
  .plan-compare { flex-direction: column; gap: var(--s-4); }
  .invite-row { flex-wrap: wrap; }
  .invite-row .input { flex-basis: 100%; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tab { white-space: nowrap; }
  .key-card { flex-wrap: wrap; }
  .key-card__actions { width: 100%; }
  .conv-item { padding: var(--s-3) var(--s-4); }
  .conv-item__icon { display: none; }
  .chat__bubble-user { max-width: 88%; }
  .chat__message--ai { gap: var(--s-3); }
  .auth__card { padding: var(--s-6); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
