:root {
  --bg: #0a0e17;
  --bg-gradient-top: #0f1629;
  --bg-gradient-bottom: #0a0e17;
  --surface: #141b2d;
  --surface-elevated: #1a2238;
  --surface-hover: #1f2942;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --accent: #00d09c;
  --accent-hover: #00b386;
  --accent-muted: rgba(0, 208, 156, 0.12);
  --accent-glow: rgba(0, 208, 156, 0.25);
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.2);
  --refusal-bg: rgba(251, 191, 36, 0.08);
  --refusal-border: rgba(251, 191, 36, 0.25);
  --refusal-text: #fde68a;
  --warning-bg: rgba(251, 191, 36, 0.1);
  --warning-border: rgba(251, 191, 36, 0.3);
  --warning-text: #fcd34d;
  --success-bg: rgba(0, 208, 156, 0.06);
  --success-border: rgba(0, 208, 156, 0.2);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sidebar-width: 56px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 208, 156, 0.08), transparent),
    linear-gradient(180deg, var(--bg-gradient-top) 0%, var(--bg-gradient-bottom) 320px);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-right: 1px solid var(--border);
  background: rgba(10, 14, 23, 0.6);
}

.sidebar__top,
.sidebar__bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.sidebar__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar__btn:hover,
.sidebar__btn:focus-visible {
  background: var(--surface-hover);
  color: var(--text);
  outline: none;
}

.sidebar__btn--active {
  color: var(--text);
  background: var(--surface-elevated);
}

.sidebar__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-muted);
  color: var(--accent);
  border: 1px solid var(--success-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Main shell */
.main-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top bar */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0.875rem 1.25rem;
  min-height: 52px;
}

.topbar__center {
  justify-self: center;
}

.topbar__right {
  justify-self: end;
}

.topbar__mark {
  color: var(--muted);
  opacity: 0.7;
}

.disclaimer-pill {
  margin: 0;
  padding: 0.35rem 0.875rem;
  border-radius: var(--radius-pill);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

/* Chat view */
.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1.5rem 1rem;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}

.chat-view--has-response .hero {
  padding-top: 1rem;
}

.chat-view--has-response .greeting {
  transform: scale(0.85);
  transform-origin: center top;
  margin-bottom: 0.5rem;
}

.chat-view--has-response .hero__subtitle {
  display: none;
}

.chat-view--has-response .quick-actions {
  display: none;
}

/* Hero / empty state */
.hero {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4vh 0 1.5rem;
  transition: padding 0.25s ease;
}

.greeting {
  margin-bottom: 0.75rem;
  transition: transform 0.25s ease;
}

.greeting__title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 2.375rem);
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
}

.greeting__comma {
  margin-right: 0.25rem;
}

.greeting__name {
  font-style: normal;
  font-weight: 600;
}

.hero__subtitle {
  margin: 0 0 2rem;
  max-width: 540px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* Composer (main input box) */
.composer {
  width: 100%;
  max-width: 680px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.125rem 0.75rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer:focus-within {
  border-color: var(--border-strong);
  box-shadow: var(--shadow), 0 0 0 1px var(--border-strong);
}

.composer__input {
  width: 100%;
  min-height: 3rem;
  max-height: 160px;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  padding: 0;
  margin-bottom: 0.75rem;
}

.composer__input::placeholder {
  color: var(--muted);
}

.composer__input:focus {
  outline: none;
}

.composer__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.composer__char-count {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.composer__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.composer__send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #0a0e17;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.composer__send:hover:not(:disabled) {
  background: var(--accent-hover);
}

.composer__send:active:not(:disabled) {
  transform: scale(0.95);
}

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

.composer__spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(10, 14, 23, 0.25);
  border-top-color: #0a0e17;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.composer__spinner--hidden {
  display: none;
}

.composer__send--loading .composer__spinner--hidden {
  display: block;
}

.composer__send--loading svg {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Quick action pills */
.quick-actions {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  max-width: 680px;
}

.quick-action {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.quick-action__icon {
  display: flex;
  color: var(--muted);
  flex-shrink: 0;
}

.quick-action:hover,
.quick-action:focus-visible {
  border-color: var(--accent);
  background: var(--surface-hover);
  color: var(--text);
  outline: none;
}

.quick-action:hover .quick-action__icon,
.quick-action:focus-visible .quick-action__icon {
  color: var(--accent);
}

/* Response thread */
.response-thread {
  width: 100%;
  max-width: 680px;
  margin-top: 1.25rem;
  animation: fadeUp 0.3s ease;
}

.response-thread__inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.375rem;
  box-shadow: var(--shadow-sm);
}

.response-thread__body {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--text);
  line-height: 1.65;
}

.response-thread__meta {
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 0.5rem;
}

.response-thread__row {
  margin: 0;
  font-size: 0.8125rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}

.response-thread__label {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.6875rem;
  min-width: 4.5rem;
}

.response-thread__link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
  transition: color 0.15s;
}

.response-thread__link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.response-thread__external {
  flex-shrink: 0;
  opacity: 0.8;
}

.response-thread--success .response-thread__inner {
  background: var(--success-bg);
  border-color: var(--success-border);
}

.response-thread--refusal .response-thread__inner {
  background: var(--refusal-bg);
  border-color: var(--refusal-border);
}

.response-thread--refusal .response-thread__body {
  color: var(--refusal-text);
}

.response--hidden,
.response__meta--hidden,
.status-banner--hidden {
  display: none;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Status banner */
.status-banner {
  width: 100%;
  max-width: 680px;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.status-banner--warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

/* Footer */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.75rem 1rem 1.25rem;
  opacity: 0.7;
}

/* Collapsed sidebar (mobile) */
.app-shell--sidebar-collapsed .sidebar {
  width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    background: var(--bg);
    box-shadow: var(--shadow);
  }

  .app-shell--sidebar-collapsed .sidebar {
    width: 0;
  }

  .greeting {
    text-align: center;
  }

  .greeting__title {
    font-size: 1.625rem;
  }

  .hero {
    padding-top: 2vh;
  }

  .hero__subtitle {
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
  }

  .quick-actions {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
  }

  .quick-action {
    flex-shrink: 0;
  }

  .disclaimer-pill {
    font-size: 0.75rem;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 480px) {
  .chat-view {
    padding: 0 1rem 1rem;
  }

  .composer {
    padding: 0.875rem 1rem 0.625rem;
  }

  .greeting__name {
    display: block;
    margin-top: 0.15rem;
  }
}
