:root {
  /* light theme: neutral gray main with darker sidebar */
  --bg: #efefef;
  --panel: #f5f5f5;
  --border: #d8d8d8;
  --text: #1b1b1b;
  --muted: #6f6f6f;
  --accent: #8a8a8a;
  --accent-soft: #e4e4e4;
  --sidebar-bg: #dadada;
  --bubble-user: #f1f1f1;
  --bubble-user-border: #e2e2e2;
  --bubble-bot: transparent;
  --bubble-bot-border: transparent;
  --dash-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1100' height='1100' viewBox='0 0 1100 1100'%3E%3Cpath d='M-150 260 Q520 120 1180 280' stroke='%23e6e7eb' stroke-width='2' stroke-dasharray='12 12' fill='none'/%3E%3Cpath d='M-120 420 Q520 260 1150 420' stroke='%23e6e7eb' stroke-width='2' stroke-dasharray='12 12' fill='none'/%3E%3Cpath d='M-90 580 Q520 420 1120 580' stroke='%23e6e7eb' stroke-width='2' stroke-dasharray='12 12' fill='none'/%3E%3Cpath d='M-60 740 Q520 580 1090 740' stroke='%23e6e7eb' stroke-width='2' stroke-dasharray='12 12' fill='none'/%3E%3C/svg%3E");
  --shadow: none;
  color-scheme: light;
}

[data-theme='dark'] {
  /* dark theme: deep charcoal main with darker sidebar like reference */
  --bg: #111214;
  --panel: #17191d;
  --border: #26292f;
  --text: #f4f4f4;
  --muted: #9a9da5;
  --accent: #8c8f94;
  --accent-soft: #202226;
  --sidebar-bg: #0d0f12;
  --bubble-user: #1d2028;
  --bubble-user-border: #2b303b;
  --bubble-bot: transparent;
  --bubble-bot-border: transparent;
  --dash-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1100' height='1100' viewBox='0 0 1100 1100'%3E%3Cpath d='M-150 260 Q520 120 1180 280' stroke='%23343a45' stroke-width='2' stroke-dasharray='12 12' fill='none'/%3E%3Cpath d='M-120 420 Q520 260 1150 420' stroke='%23343a45' stroke-width='2' stroke-dasharray='12 12' fill='none'/%3E%3Cpath d='M-90 580 Q520 420 1120 580' stroke='%23343a45' stroke-width='2' stroke-dasharray='12 12' fill='none'/%3E%3Cpath d='M-60 740 Q520 580 1090 740' stroke='%23343a45' stroke-width='2' stroke-dasharray='12 12' fill='none'/%3E%3C/svg%3E");
  --shadow: none;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  transition: background 200ms ease, color 200ms ease;
}

/* dashed background overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--dash-bg);
  background-size: cover;
  background-repeat: repeat;
  opacity: 0.22;
  pointer-events: none;
  z-index: -1;
}

.fullpage {
  width: 100%;
  min-height: 100vh;
  padding: 48px 20px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--panel);
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  width: 100%;
  min-height: 100vh;
}

.sidebar {
  position: relative;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 14px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}

.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600' viewBox='0 0 600 600'%3E%3Cpath d='M-80 120 Q260 40 580 140' stroke='%23a0a0a0' stroke-width='2' stroke-dasharray='10 10' fill='none'/%3E%3Cpath d='M-60 240 Q260 160 560 260' stroke='%23a0a0a0' stroke-width='2' stroke-dasharray='10 10' fill='none'/%3E%3Cpath d='M-40 360 Q260 280 540 380' stroke='%23a0a0a0' stroke-width='2' stroke-dasharray='10 10' fill='none'/%3E%3C/svg%3E");
  opacity: 0.2;
  pointer-events: none;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  z-index: 1;
}

.sidebar-label {
  font-size: 12px;
  color: var(--muted);
}

#model-select {
  width: 100%;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, #000 10%);
  background: color-mix(in srgb, var(--panel) 90%, #000 6%);
  color: var(--text);
  font: inherit;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.chat-list {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-list-label {
  font-size: 12px;
  color: var(--muted);
  padding: 0 2px;
}

.chat-list-items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-list-items li {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--border) 90%, #000 4%);
  background: color-mix(in srgb, var(--panel) 92%, #000 4%);
  color: var(--muted);
  font-size: 14px;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

[data-theme='dark'] .chat-list-items li {
  border-color: color-mix(in srgb, var(--border) 80%, #fff 6%);
  background: color-mix(in srgb, var(--panel) 90%, #fff 4%);
  color: var(--muted);
}

.chat-list-items li:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

.chat-list-items li.active {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.1);
}

.nav-item {
  text-align: left;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--border) 90%, #000 6%);
  background: color-mix(in srgb, var(--panel) 92%, #000 8%);
  color: var(--text);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.nav-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.nav-item:active {
  transform: translateY(0);
}

.nav-item.active {
  border-color: var(--accent);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.12);
}

.headline {
  text-align: center;
  margin: 12px 0 4px;
}

.headline h1 {
  font-size: clamp(26px, 3vw, 32px);
  margin: 8px 0 6px;
  font-weight: 600;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
  color: var(--muted);
  margin: 0;
}

.empty-hint {
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  padding: 6px 12px;
}

.ask-bar {
  width: min(1080px, 96vw);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 15px 20px;
  background: color-mix(in srgb, var(--panel) 78%, #000 22%);
  border: 1px solid color-mix(in srgb, var(--border) 75%, #000 18%);
  border-radius: 18px;
  box-shadow: none;
  transition: transform 200ms ease, box-shadow 200ms ease;
  position: relative;
  z-index: 1;
  overflow: hidden;
  isolation: isolate;
}

.ask-bar::before {
  content: '';
  position: absolute;
  inset: -2px;
  background-image: var(--dash-bg);
  background-size: 800px 800px;
  background-repeat: repeat;
  opacity: 0.32;
  pointer-events: none;
  z-index: 0;
}

.ask-bar > * {
  position: relative;
  z-index: 1;
}

.left-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.inline-model {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 90%, #000 10%);
  color: var(--text);
  font: inherit;
}

.ask-bar svg {
  stroke: var(--muted);
  fill: none;
  stroke-width: 1.6;
  width: 18px;
  height: 18px;
  transition: stroke 150ms ease, transform 150ms ease;
}

.ask-bar input {
  width: 100%;
  border: none;
  font-size: 16px;
  padding: 10px 4px;
  background: transparent;
  color: var(--text);
}

.ask-bar input:focus {
  outline: none;
}

.icon-btn {
  width: auto;
  height: auto;
  padding: 6px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 140ms ease, color 140ms ease, background-color 140ms ease;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  stroke: currentColor;
}

.icon-btn:hover {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--panel) 80%, #000 6%);
  color: color-mix(in srgb, var(--text) 80%, #000 20%);
}

.icon-btn:active {
  transform: translateY(0);
}

.right-icons {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.icon-btn.send,
.icon-btn.mic {
  background: transparent;
  border: none;
  color: var(--muted);
}

.icon-btn.send svg,
.icon-btn.mic svg {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.4;
}

.chat-window {
  position: relative;
  width: min(900px, 94vw);
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 6px 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 60vh;
  overflow-y: auto;
  display: none;
  animation: fadeIn 360ms ease;
}

.chat-window::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--dash-bg);
  background-size: cover;
  background-repeat: repeat;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

.chat-window > * {
  position: relative;
  z-index: 1;
}

.chat-window::-webkit-scrollbar {
  width: 10px;
}

.chat-window::-webkit-scrollbar-track {
  background: transparent;
}

.chat-window::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text) 20%, transparent);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.chat-window::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--text) 32%, transparent);
  background-clip: content-box;
}

.chat-window {
  scrollbar-color: color-mix(in srgb, var(--text) 20%, transparent) transparent;
  scrollbar-width: thin;
}

.attachments {
  width: min(900px, 94vw);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 4px 2px;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
  backdrop-filter: blur(6px);
}

[data-theme='dark'] .attachment-chip {
  background: rgba(0, 0, 0, 0.35);
  border-color: var(--border);
}

.attachment-chip span {
  font-size: 14px;
}

.chip-thumb {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.chip-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.07);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.chip-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition: transform 120ms ease, opacity 120ms ease;
}

.chip-close:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

.chip-close:active {
  transform: scale(0.97);
}

.message {
  display: flex;
  align-items: flex-start;
  width: 100%;
  gap: 8px;
  animation: messageIn 220ms ease;
}

.message.user {
  justify-content: flex-end;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.bot-avatar {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(15, 155, 142, 0.25);
}

.user-avatar {
  background: #eef1f5;
  color: #4b5563;
  border: 1px solid #d8dce2;
}

.bubble {
  padding: 0;
  border-radius: 12px;
  border: none;
  background: transparent;
  box-shadow: none;
  width: fit-content;
  max-width: 68ch;
  line-height: 1.5;
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.message.bot .bubble {
  padding: 0;
}

.message.user .bubble {
  padding: 8px 12px;
  background: color-mix(in srgb, var(--panel) 75%, #000 25%);
  border: 1px solid color-mix(in srgb, var(--border) 70%, #000 22%);
  box-shadow: none;
  border-radius: 14px;
}

.bubble pre {
  margin: 8px 0 4px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
}

[data-theme='dark'] .bubble pre {
  background: rgba(255, 255, 255, 0.04);
  border-color: #303540;
}

.bubble code {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, ui-monospace, monospace;
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
}

[data-theme='dark'] .bubble code {
  background: rgba(255, 255, 255, 0.06);
  border-color: #303540;
}

.bubble code.math {
  font-style: italic;
}

.bubble.loading {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 6px 4px;
}

.loader-dots {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.loader-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  animation: pulse 900ms ease-in-out infinite;
}

.loader-dots span:nth-child(2) {
  animation-delay: 120ms;
}

.loader-dots span:nth-child(3) {
  animation-delay: 240ms;
}

.has-messages .chat-window {
  display: flex;
}

.has-messages .fullpage {
  justify-content: flex-start;
  padding-top: 56px;
  gap: 16px;
}

.typing .headline,
.has-messages .headline,
.typing .empty-hint,
.has-messages .empty-hint {
  display: none;
}

.bar-docked .fullpage {
  justify-content: flex-end;
  padding-bottom: 40px;
}

.bar-docked .ask-bar {
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.06);
  margin-top: auto;
  transform: translateY(4px);
}

.sent-once .ask-bar {
  transform: translateY(6px);
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  50% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .fullpage {
    padding: 28px 14px;
  }

  .ask-bar {
    grid-template-columns: auto 1fr auto;
  }

  .chat-window {
    max-height: 50vh;
  }
}
