:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-soft: #eef2f7;
  --sidebar: #101114;
  --sidebar-muted: #a9b1bd;
  --text: #17202a;
  --muted: #667085;
  --border: #d9dee8;
  --user: #202631;
  --user-text: #ffffff;
  --assistant: #ffffff;
  --focus: #0f766e;
  --shadow: 0 20px 60px rgba(21, 32, 43, 0.12);
  --mobile-header: 52px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--sidebar);
  color: #ffffff;
}

.brand,
.mobile-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark,
.empty-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #0f766e;
  color: #ffffff;
  font-weight: 750;
}

.brand-mark {
  width: 38px;
  height: 38px;
  font-size: 18px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
}

.brand-status {
  margin-top: 2px;
  color: var(--sidebar-muted);
  font-size: 13px;
}

.new-chat,
.history-item {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
}

.new-chat:hover,
.history-item:hover,
.history-item.active {
  background: rgba(255, 255, 255, 0.08);
}

.new-chat:active,
.history-item:active,
.send-button:active,
.icon-button:active {
  transform: scale(0.98);
}

.plus {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: 19px;
  line-height: 1;
}

.chat-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.history-item {
  overflow: hidden;
  min-height: 40px;
  padding: 10px 12px;
  color: #eeeae4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  min-height: 0;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 62px;
  padding: 12px 22px;
  border-bottom: 1px solid rgba(217, 222, 232, 0.85);
  background: rgba(246, 247, 251, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.mobile-brand {
  display: none;
  font-weight: 700;
}

.icon-button,
.send-button {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.icon-button {
  width: 40px;
  height: 40px;
  background: transparent;
  color: var(--muted);
}

.icon-button:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.icon-button svg,
.send-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.conversation {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 36px 18px 26px;
  scroll-padding-bottom: 120px;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(100%, 720px);
  margin: 18vh auto 0;
  text-align: center;
}

.empty-mark {
  width: 54px;
  height: 54px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  font-size: 24px;
}

.empty-state h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.message {
  display: flex;
  gap: 14px;
  width: min(100%, 820px);
  margin: 0 auto 22px;
  animation: message-in 180ms ease-out both;
}

.message.user {
  justify-content: flex-end;
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #0f766e;
  color: #ffffff;
  font-size: 14px;
  font-weight: 750;
}

.message.user .avatar {
  order: 2;
  background: #3f3f46;
}

.bubble {
  max-width: min(640px, calc(100% - 46px));
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--assistant);
  box-shadow: 0 1px 0 rgba(25, 25, 25, 0.03);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .bubble {
  border-color: var(--user);
  background: var(--user);
  color: var(--user-text);
}

.composer-wrap {
  padding: 16px 18px max(24px, env(safe-area-inset-bottom));
  background: linear-gradient(rgba(246, 247, 251, 0), var(--bg) 22%);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: end;
  gap: 10px;
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.composer:focus-within {
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow:
    0 0 0 3px rgba(15, 118, 110, 0.12),
    var(--shadow);
}

textarea {
  display: block;
  width: 100%;
  max-height: 190px;
  min-height: 42px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 10px 6px 9px;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  scrollbar-width: thin;
}

textarea::placeholder {
  color: #85817a;
}

.send-button {
  width: 42px;
  height: 42px;
  background: #111111;
  color: #ffffff;
}

.send-button:hover {
  background: #0f766e;
}

.send-button:disabled {
  cursor: default;
  background: #d1d5db;
  color: #777b82;
}

.sr-only {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.45);
  outline-offset: 2px;
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

  .sidebar {
    display: none;
  }

  .topbar {
    justify-content: space-between;
    min-height: var(--mobile-header);
    padding: 7px 10px;
  }

  .mobile-brand {
    display: flex;
  }

  .mobile-brand .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }

  .conversation {
    padding: 18px 10px 12px;
    scroll-padding-bottom: 96px;
  }

  .empty-state {
    gap: 9px;
    margin-top: 11vh;
    padding: 0 12px;
  }

  .empty-state h1 {
    font-size: 26px;
  }

  .empty-state p {
    font-size: 16px;
  }

  .message {
    gap: 10px;
    margin-bottom: 16px;
  }

  .avatar {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    font-size: 12px;
  }

  .bubble {
    max-width: calc(100% - 40px);
    padding: 11px 13px;
    font-size: 15px;
  }

  .composer-wrap {
    padding: 8px 10px max(10px, env(safe-area-inset-bottom));
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 40px;
    gap: 8px;
    padding: 8px;
  }

  textarea {
    min-height: 40px;
    max-height: 132px;
    padding: 9px 5px;
  }

  .send-button {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 420px) {
  .message.user {
    padding-left: 18px;
  }

  .message.assistant {
    padding-right: 18px;
  }

  .bubble {
    max-width: calc(100% - 34px);
  }
}
