:root {
  color-scheme: dark;
  --bg: #131314;
  --sidebar-bg: #131314;
  --surface: #1e1f20;
  --surface-hover: #2d2e30;
  --surface-elevated: #282a2c;
  --text: #e3e3e3;
  --text-secondary: #c4c7c5;
  --muted: #9aa0a6;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #8ab4f8;
  --warning: #f28b82;
  --sidebar-width: 68px;
  --sidebar-expanded: 280px;
  --composer-max: 760px;
  --thread-max: 720px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Google Sans Flex", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 22px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
  transition: width 0.32s var(--ease-out);
}

.sidebar-top,
.sidebar-nav,
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav {
  margin-top: 8px;
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 12px;
}

.sidebar-logo {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 4px auto 8px;
  text-decoration: none;
}

.brand-mark {
  width: 28px;
  height: 28px;
  animation: starPulse 4s ease-in-out infinite;
}

@keyframes starPulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 0 transparent);
  }
  50% {
    transform: scale(1.06);
    filter: drop-shadow(0 0 12px rgba(138, 180, 248, 0.28));
  }
}

.sidebar-btn,
.profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  width: 48px;
  height: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  overflow: hidden;
  transition:
    width 0.32s var(--ease-out),
    background 0.18s ease,
    color 0.18s ease,
    transform 0.18s var(--ease-spring);
}

.sidebar-btn:hover,
.profile-btn:hover,
.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar-btn:active,
.profile-btn:active,
.icon-btn:active,
.model-chip:active {
  transform: scale(0.96);
}

.sidebar-btn.is-active,
.icon-btn.is-active {
  background: var(--surface-hover);
  color: var(--text);
  animation: buttonPop 0.35s var(--ease-spring);
}

.sidebar-label {
  display: none;
  font-size: 14px;
  white-space: nowrap;
}

.profile-btn {
  justify-content: flex-start;
}

.profile-letter {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #1a73e8;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% 38%, rgba(66, 133, 244, 0.11), transparent 44%),
    var(--bg);
  animation: glowBreath 8s ease-in-out infinite;
}

@keyframes glowBreath {
  0%, 100% {
    background:
      radial-gradient(circle at 50% 38%, rgba(66, 133, 244, 0.08), transparent 44%),
      var(--bg);
  }
  50% {
    background:
      radial-gradient(circle at 50% 38%, rgba(66, 133, 244, 0.15), transparent 48%),
      var(--bg);
  }
}

.topbar {
  display: flex;
  justify-content: flex-end;
  padding: 14px 20px 0;
  animation: fadeDown 0.6s var(--ease-out) both;
}

.main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-stage {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 24px;
}

.chat-stage.is-empty {
  justify-content: center;
}

.landing {
  width: 100%;
  max-width: var(--composer-max);
  text-align: center;
  padding: 24px 0 28px;
  animation: fadeUp 0.7s var(--ease-out) 0.08s both;
  transition: opacity 0.35s ease, transform 0.4s var(--ease-out);
}

.landing.is-hiding {
  opacity: 0;
  transform: translateY(-16px);
  pointer-events: none;
}

.welcome-title {
  margin: 0;
  font-size: clamp(28px, 4.2vw, 44px);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.welcome-name {
  color: var(--text);
}

.thread {
  width: 100%;
  max-width: var(--thread-max);
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 8px 0 24px;
}

.thread[hidden] {
  display: none !important;
}

.message {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  opacity: 0;
  animation: messageIn 0.5s var(--ease-out) forwards;
}

.message.user {
  grid-template-columns: minmax(0, 1fr);
}

.message.user .message-avatar {
  display: none;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-elevated);
  color: var(--accent);
  overflow: hidden;
}

.message-avatar svg {
  width: 22px;
  height: 22px;
}

.message-body {
  min-width: 0;
  padding-top: 4px;
}

.message-meta {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.message-text {
  margin: 0;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.message.system .message-text {
  color: var(--warning);
}

.message.user .message-text {
  font-size: 15px;
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  animation: typingDot 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

.composer-shell {
  flex-shrink: 0;
  padding: 0 24px 28px;
  animation: fadeUp 0.7s var(--ease-out) 0.18s both;
}

.composer {
  width: 100%;
  max-width: var(--composer-max);
  margin: 0 auto;
}

.composer-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: 8px 10px 8px 8px;
  border-radius: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  transition:
    border-color 0.22s ease,
    box-shadow 0.3s var(--ease-out),
    transform 0.3s var(--ease-out);
}

.composer-inner:focus-within {
  border-color: rgba(138, 180, 248, 0.28);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.28),
    0 0 0 3px rgba(138, 180, 248, 0.1);
}

.composer-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  outline: none;
  padding: 8px 4px;
}

.composer-input::placeholder {
  color: var(--muted);
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  transition:
    background 0.18s ease,
    color 0.18s ease,
    transform 0.18s var(--ease-spring),
    opacity 0.22s var(--ease-out);
}

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 36px;
  padding: 0 10px 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  transition: background 0.18s ease, color 0.18s ease;
}

.model-chip:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.chip-arrow {
  font-size: 18px !important;
  transition: transform 0.25s var(--ease-out);
}

.model-chip.is-switching .chip-arrow {
  transform: rotate(180deg);
}

.model-chip.is-switching span:first-child {
  animation: labelSwap 0.35s var(--ease-out);
}

.composer-send {
  color: var(--accent);
  opacity: 0;
  transform: scale(0.72);
  pointer-events: none;
}

.composer-send.is-visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  background: rgba(138, 180, 248, 0.12);
}

.composer-send.is-visible:hover {
  background: rgba(138, 180, 248, 0.2);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(16px) scale(0.96);
  max-width: min(90vw, 420px);
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(30, 31, 32, 0.96);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.28s var(--ease-out),
    transform 0.32s var(--ease-spring);
  z-index: 20;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

.app.sidebar-open .sidebar {
  width: var(--sidebar-expanded);
}

.app.sidebar-open .sidebar-btn,
.app.sidebar-open .profile-btn {
  width: 100%;
}

.app.sidebar-open .sidebar-label {
  display: inline;
}

@keyframes buttonPop {
  0% { transform: scale(0.92); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes typingDot {
  0%, 80%, 100% {
    opacity: 0.35;
    transform: translateY(0) scale(0.85);
  }
  40% {
    opacity: 1;
    transform: translateY(-4px) scale(1);
  }
}

@keyframes labelSwap {
  0% { opacity: 1; transform: translateY(0); }
  45% { opacity: 0; transform: translateY(-8px); }
  55% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.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;
}

@media (max-width: 768px) {
  .sidebar {
    width: 56px;
    padding-inline: 6px;
  }

  .sidebar-btn,
  .profile-btn,
  .sidebar-logo {
    width: 44px;
    height: 44px;
  }

  .composer-shell,
  .chat-stage {
    padding-inline: 12px;
  }

  .composer-shell {
    padding-bottom: 16px;
  }

  .model-chip span:first-child {
    display: none;
  }
}
