:root {
  color-scheme: dark;
  font-family: Arial, sans-serif;
  background: #343434;
  color: #ffffff;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: #343434;
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  color: #ffffff;
}

button:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: -2px;
}

.app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100dvh;
}

.sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 24px 14px 16px;
  background: #272727;
}

.sidebar-top {
  padding: 0 2px;
}

.logo {
  margin: 0 8px 24px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.new-chat-button {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
}

.new-chat-icon {
  font-size: 1.25em;
  font-weight: 400;
  line-height: 1;
}

.new-chat {
  width: 100%;
  min-height: 46px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  padding: 0 14px;
  font-weight: 700;
}

.history-heading {
  margin: 28px 10px 8px;
  color: #bdbdbd;
  font-size: 0.875rem;
  font-weight: 700;
}

.history {
  min-height: 0;
  overflow-y: auto;
}

.history,
.conversation,
textarea {
  scrollbar-width: none;
}

.history-item {
  display: block;
  width: 100%;
  min-height: 44px;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
  padding: 10px 12px;
  text-align: left;
  text-overflow: ellipsis;
  touch-action: pan-y;
  user-select: none;
  white-space: nowrap;
}

.chat-menu {
  position: fixed;
  inset: 0 auto auto 0;
  max-width: calc(100vw - 16px);
  margin: 0;
  border: 0;
  border-radius: 22px;
  background: #484848;
  padding: 4px;
}

#delete-chat {
  min-height: 44px;
  background: transparent;
  cursor: pointer;
  padding: 0 14px;
  font-size: 0.875rem;
}

#delete-chat:hover {
  background: #343434;
}

.history-item[aria-current="true"] {
  background: #343434;
}

.new-chat:hover,
.history-item:hover,
.mobile-header button:hover {
  background: #424242;
}

.chat-column {
  --chat-width: 780px;
  --chat-gutter: clamp(16px, 4vw, 28px);
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #343434;
}

.mobile-header {
  display: none;
}

.conversation,
.composer {
  width: 100%;
  max-width: var(--chat-width);
  margin-inline: auto;
  padding-inline: var(--chat-gutter);
}

.conversation {
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.conversation:focus-visible {
  outline: 2px solid #888888;
  outline-offset: -2px;
}

.empty-state {
  display: grid;
  min-height: 100%;
  place-content: center;
  padding-block: 16px;
  text-align: center;
}

.empty-state h1 {
  margin: 0 0 8px;
  font-size: 2.25rem;
  letter-spacing: -0.04em;
}

.empty-state p {
  margin: 0;
  color: #c8c8c8;
  font-size: 1rem;
}

.empty-state[hidden],
.messages:empty,
.typing-indicator[hidden],
.status:empty {
  display: none;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-block: clamp(24px, 6vh, 56px) 18px;
}

.message {
  min-width: 0;
}

.message--user {
  align-self: flex-end;
  max-width: 82%;
  border-radius: 22px;
  background: #484848;
  padding: 10px 16px;
}

.message-content {
  font-size: 1rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.typing-indicator {
  display: flex;
  width: fit-content;
  min-height: 34px;
  align-items: center;
  margin-bottom: 18px;
  border-radius: 999px;
  background: #484848;
  padding: 0 13px;
}

.typing-dots {
  display: flex;
  gap: 5px;
}

.typing-dots > span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #d0d0d0;
}

.status {
  margin: 0 0 24px;
  color: #d0d0d0;
  font-size: 0.9375rem;
}

.status.error {
  color: #ffd0d0;
}

.composer {
  padding-block: 12px max(18px, env(safe-area-inset-bottom));
  background: #343434;
}

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border-radius: 30px;
  background: #484848;
  padding: 10px 10px 10px 16px;
}

.input-wrap:focus-within {
  background: #505050;
}

textarea {
  flex: 1;
  align-self: center;
  min-width: 0;
  max-height: 160px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: #ffffff;
  padding: 7px 0;
  line-height: 1.5;
}

textarea::placeholder {
  color: #c4c4c4;
  opacity: 1;
}

#send-button {
  min-width: 62px;
  min-height: 38px;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

#send-button:enabled:hover {
  background: #343434;
}

#send-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.disclaimer {
  margin: 9px 4px 0;
  color: #bdbdbd;
  font-size: 0.8125rem;
  text-align: center;
}

.sidebar-backdrop {
  display: none;
}

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

@media (max-width: 720px) {
  .app {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    display: none;
    width: min(84vw, 300px);
  }

  .sidebar.open {
    display: flex;
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 10;
    inset: 0;
    width: 100%;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.55);
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .chat-column {
    height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .mobile-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    min-height: 56px;
    padding: 6px 14px;
  }

  .mobile-header button {
    min-height: 44px;
    background: transparent;
    cursor: pointer;
    padding: 0 12px;
  }

  #open-sidebar {
    justify-self: start;
  }

  #mobile-new-chat {
    justify-self: end;
  }

  .mobile-logo {
    font-size: 1.125rem;
    font-weight: 700;
  }

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

  .disclaimer {
    font-size: 0.75rem;
  }
}

@media (max-width: 420px) {
  #send-button {
    min-width: 56px;
  }

  .input-wrap {
    padding-left: 14px;
  }
}
