* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: manipulation;
}

:root {
  --color-darkgrey: #111111;
  --color-bg-overlay: rgba(0, 0, 0, 0.5);
  --color-border: rgba(255, 255, 255, 0.1);
  --color-fill-025: rgba(255, 255, 255, 0.025);
  --color-fill-25: rgba(255, 255, 255, 0.25);
  --color-input-fill: rgba(255, 255, 255, 0.05);
  --color-mark: var(--color-border);
  --color-muted: rgba(255, 255, 255, 0.5);
  --color-shadow: rgba(0, 0, 0, 0.08);
  --color-shell: #111111;
  --color-text: var(--color-white);
  --color-text-inset: var(--color-border);
  --color-text-inset-strong: var(--color-fill-25);
  --color-white: #ffffff;
  --content-max-width: 640px;
  --font-family: "Inter", sans-serif;
  --font-size-base: 0.8125rem;
  --font-size-icon: 1.25rem;
  --font-size-input: 0.875rem;
  --font-size-mark: 2rem;
  --font-size-user: 0.75rem;
  --font-weight-light: 300;
  --font-weight-medium: 500;
  --font-weight-normal: 400;
  --line-height-base: 1.6;
  --line-height-ui: calc(var(--font-size-base) * var(--line-height-base));
  --sidebar-accent: var(--color-white);
  --sidebar-width: 320px;
}

html {
  background: var(--color-shell);
  touch-action: manipulation;
}

body {
  -webkit-user-select: none;
  background: var(--color-shell);
  color: var(--color-text);
  color-scheme: dark;
  font-family: var(--font-family);
  font-optical-sizing: auto;
  font-size: var(--font-size-base);
  font-style: normal;
  font-synthesis: none;
  font-variation-settings: "opsz" auto;
  height: 100dvh;
  line-height: var(--line-height-base);
  overflow: hidden;
  position: relative;
  touch-action: manipulation;
  user-select: none;
  width: 100%;
}

button {
  font-weight: var(--font-weight-medium);
}

html.has-camera .header-bar,
html.has-camera .input-bar,
html.has-camera .main-shell {
  background: transparent;
}

html.has-camera .sidebar,
html.has-camera .sidebar .header-bar {
  background: var(--color-shell);
}

.camera-layer {
  inset: 0;
  position: fixed;
  z-index: 0;
}

.camera-overlay {
  backdrop-filter: blur(50px);
  -webkit-backdrop-filter: blur(50px);
  background: var(--color-bg-overlay);
  inset: 0;
  position: absolute;
}

.camera-video {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.camera-video-mirrored {
  transform: scaleX(-1);
}

.main-shell {
  background: var(--color-shell);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: relative;
  width: 100%;
}

.sidebar {
  background: var(--color-shell);
  border-right: 1px solid var(--color-border);
  bottom: 0;
  display: flex;
  flex-direction: column;
  left: 0;
  overflow: hidden;
  padding: 0;
  position: fixed;
  scrollbar-width: none;
  top: 0;
  z-index: 3;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.sidebar-empty {
  color: var(--color-muted);
  font-size: var(--font-size-base);
  padding: 1rem;
}

.sidebar .new-chat-button {
  align-items: center;
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border);
  color: var(--sidebar-accent);
  cursor: pointer;
  display: flex;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-light);
  gap: 0.75rem;
  line-height: var(--line-height-base);
  margin: 0 1rem;
  padding: 1rem 0;
  text-align: left;
  width: calc(100% - 2rem);
}

.sidebar-row {
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  gap: 0.5rem;
}

.sidebar-item {
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  flex: 1;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-base);
  min-width: 0;
  overflow: hidden;
  padding: 1rem 0;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-item-loading {
  font-style: italic;
}

.sidebar-delete {
  background: none;
  border: none;
  color: var(--sidebar-accent);
  cursor: pointer;
  flex-shrink: 0;
  line-height: 0;
  padding: 0;
}

.sidebar-list {
  list-style: none;
  padding: 0 1rem;
}

.header-button {
  background: none;
  border: none;
  color: var(--sidebar-accent);
  cursor: pointer;
  flex-shrink: 0;
  font-size: var(--font-size-input);
  line-height: 1;
  padding: 0;
}

.sidebar-overlay-button {
  display: none;
}

@media (max-width: 1023px) {
  .sidebar {
    border-right: none;
    inset: 0;
    transform: translateX(-100%);
    width: 100%;
    z-index: 4;
  }

  html.sidebar-open .sidebar {
    transform: translateX(0);
  }

  html.sidebar-open.has-camera .main-shell {
    visibility: hidden;
  }

  .sidebar-overlay-button {
    display: block;
  }

  .header-button,
  .sidebar-delete {
    position: relative;
  }

  .header-button::before,
  .sidebar-delete::before {
    content: "";
    inset: -0.5rem;
    position: absolute;
  }
}

@media (min-width: 1024px) {
  html.sidebar-open .main-shell {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
  }

  .sidebar {
    transform: translateX(0);
    width: var(--sidebar-width);
  }

  html:not(.sidebar-open) .sidebar {
    transform: translateX(-100%);
  }
}

.header-bar {
  align-items: center;
  background: var(--color-shell);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-shrink: 0;
  gap: 1rem;
  padding-bottom: 1rem;
  padding-left: 1rem;
  padding-right: 1rem;
  padding-top: calc(1rem + env(safe-area-inset-top, 0px));
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 2;
}

.icon {
  color: inherit;
  display: block;
  height: var(--font-size-icon);
  stroke-width: 1px;
  width: var(--font-size-icon);
}

.icon-attachment,
.icon-stop-action {
  height: 0.875rem;
  width: 0.875rem;
}

.prompt-attach-button .icon {
  height: 1rem;
  width: 1rem;
}

.icon-stop-action {
  color: var(--color-white);
}

.sidebar-button .icon-sidebar-open {
  display: none;
}

html.sidebar-open .sidebar-button .icon-sidebar-closed {
  display: none;
}

html.sidebar-open .sidebar-button .icon-sidebar-open {
  display: block;
}

.chat-title-untitled {
  color: var(--color-muted);
}

.page-title {
  flex: 1;
  font-size: var(--font-size-base);
  height: var(--line-height-ui);
  line-height: var(--line-height-ui);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-title {
  color: var(--color-white);
  font-weight: var(--font-weight-medium);
}

.sidebar-header-chats {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 1rem;
}

.sidebar-view {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.sidebar-view-chats {
  overflow-y: auto;
  padding-bottom: 1rem;
  scrollbar-width: none;
}

.sidebar-view-chats::-webkit-scrollbar {
  display: none;
}

.sidebar-view-key,
.sidebar-view-style {
  gap: 1.5rem;
  overflow-y: auto;
  padding: 1rem;
  scrollbar-width: none;
}

.sidebar-view-key::-webkit-scrollbar,
.sidebar-view-style::-webkit-scrollbar {
  display: none;
}

.style-colors {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(5, 1fr);
  width: 100%;
}

.style-color {
  align-items: center;
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  height: auto;
  justify-content: center;
  padding: 0;
  width: 100%;
}

.style-color-check {
  color: var(--color-darkgrey);
  flex-shrink: 0;
  height: 50%;
  width: 50%;
}

.style-label {
  color: var(--color-muted);
  font-size: var(--font-size-base);
}

.style-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.style-typeface {
  display: flex;
  gap: 0.5rem;
}

.style-typeface-option {
  border: none;
  border-radius: 9999px;
  color: var(--color-text);
  cursor: pointer;
  flex: 1;
  font-size: var(--font-size-base);
  line-height: var(--line-height-ui);
  padding: 0.5rem 0.75rem;
}

.style-typeface-option-active {
  background: color-mix(in srgb, var(--sidebar-accent) 80%, transparent);
  color: var(--color-darkgrey);
}

.messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow-anchor: none;
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: 1rem;
  padding-top: 1rem;
  scroll-behavior: smooth;
  scrollbar-width: none;
  width: 100%;
}

.messages::-webkit-scrollbar {
  display: none;
}

.input,
.message,
select {
  font-family: var(--font-family);
  -webkit-user-select: text;
  user-select: text;
}

.input::selection,
.message *::selection,
.message::selection,
select::selection {
  background: var(--sidebar-accent);
  color: var(--color-darkgrey);
}

.input::-moz-selection,
.message *::-moz-selection,
.message::-moz-selection,
select::-moz-selection {
  background: var(--sidebar-accent);
  color: var(--color-darkgrey);
}

.message {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-light);
  line-height: var(--line-height-base);
  margin-left: auto;
  margin-right: auto;
  max-width: var(--content-max-width);
  padding-left: 1rem;
  padding-right: 1rem;
  width: 100%;
}

.message-assistant {
  margin-bottom: 1.5rem;
}

.message-assistant code {
  background: var(--color-fill-025);
  border-radius: 0.25rem;
  font-size: var(--font-size-user);
  padding: 0.125rem 0.375rem;
}

.message-assistant blockquote {
  border-left: 1px solid var(--color-border);
  margin: 0 0 0.5rem;
  padding-left: 0.75rem;
}

.message-assistant em {
  font-style: italic;
}

.message-assistant h1,
.message-assistant h2,
.message-assistant h3 {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-base);
  margin: 0 0 0.5rem;
}

.message-assistant li {
  margin-bottom: 0.25rem;
}

.message-assistant li:last-child {
  margin-bottom: 0;
}

.message-assistant ol,
.message-assistant ul {
  list-style-position: inside;
  margin: 0 0 0.5rem;
  padding-left: 0;
}

.message-assistant ol:last-child,
.message-assistant ul:last-child {
  margin-bottom: 0;
}

.message-assistant p {
  margin: 0 0 0.5rem;
}

.message-assistant p:last-child {
  margin-bottom: 0;
}

.message-assistant pre {
  background: var(--color-fill-025);
  border-radius: 0.5rem;
  margin: 0 0 0.5rem;
  overflow-x: auto;
  padding: 0.75rem 1rem;
}

.message-assistant pre:last-child {
  margin-bottom: 0;
}

.message-assistant pre code {
  background: none;
  padding: 0;
}

.message-assistant strong {
  font-weight: var(--font-weight-medium);
}

.message-assistant .table-wrap {
  margin: 0 0 0.5rem;
  overflow-x: auto;
}

.message-assistant .table-wrap:last-child {
  margin-bottom: 0;
}

.message-assistant table {
  border-collapse: collapse;
  width: 100%;
}

.message-assistant td,
.message-assistant th {
  border: 1px solid var(--color-text);
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

.message-assistant th {
  font-weight: var(--font-weight-medium);
}

.message-loading {
  color: var(--sidebar-accent);
  font-style: italic;
  margin-bottom: 1.5rem;
}

.message-error {
  color: var(--sidebar-accent);
  font-style: italic;
  margin-bottom: 1.5rem;
  white-space: pre-wrap;
}

.message-user {
  color: var(--color-muted);
  font-size: var(--font-size-user);
  margin-bottom: 0.5rem;
  white-space: pre-wrap;
}

.empty-state {
  align-items: center;
  display: flex;
  flex: 1;
  justify-content: center;
  min-height: 0;
  pointer-events: none;
}

.main-shell.has-messages .empty-state {
  display: none;
}

.main-shell:not(.has-messages) .messages {
  display: none;
}

.mark {
  color: var(--color-mark);
  font-family: "DM Sans", sans-serif;
  font-size: var(--font-size-mark);
  font-weight: var(--font-weight-medium);
}

.input-bar {
  background: var(--color-shell);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 0.5rem;
  margin-left: auto;
  margin-right: auto;
  max-width: var(--content-max-width);
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  padding-left: 1rem;
  padding-right: 1rem;
  width: 100%;
  z-index: 2;
}

.glass {
  backdrop-filter: blur(50px);
  -webkit-backdrop-filter: blur(50px);
  box-shadow:
    0 0 2px var(--color-shadow),
    0 1px 1px var(--color-shadow),
    0 4px 4px var(--color-shadow),
    inset -1px -1px 0 var(--color-text-inset),
    inset 1px 1px 0 var(--color-text-inset-strong);
}

.glass.scroll-bottom-button,
.glass.prompt-attach-button,
.glass.style-typeface-option:not(.style-typeface-option-active),
body.is-submitting .glass.prompt-send-button {
  background: var(--color-input-fill);
}

.scroll-bottom-button {
  align-items: center;
  border: none;
  border-radius: 9999px;
  bottom: calc(var(--input-bar-height, 0px) + 0.5rem);
  color: var(--color-white);
  cursor: pointer;
  display: flex;
  height: 2rem;
  justify-content: center;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
  width: 2rem;
  z-index: 3;
}

.input {
  background: var(--color-input-fill);
  border: none;
  border-radius: 1rem;
  color: var(--color-text);
  font-size: var(--font-size-input);
  font-weight: var(--font-weight-light);
  line-height: var(--line-height-base);
  outline: none;
  padding: 0.75rem 1rem;
  resize: none;
  width: 100%;
}

.prompt-input-wrap {
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
}

.input.prompt-input {
  background: transparent;
  border-radius: 1rem 1rem 0 0;
  box-shadow: none;
  flex-shrink: 0;
  max-height: calc(
    0.625rem + var(--font-size-input) * var(--line-height-base) * 3
  );
  min-height: calc(
    0.625rem + var(--font-size-input) * var(--line-height-base) * 2
  );
  overflow-y: auto;
  padding: 0.625rem 0.75rem 0;
  scrollbar-width: none;
}

.input.prompt-input::-webkit-scrollbar {
  display: none;
}

.attachment-row {
  display: flex;
  flex-shrink: 0;
  flex-wrap: nowrap;
  gap: 0.5rem;
  -webkit-overflow-scrolling: touch;
  overflow-x: auto;
  padding: 0 0.75rem;
  scrollbar-width: none;
}

.attachment-row::-webkit-scrollbar {
  display: none;
}

.attachment-chip {
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  color: var(--color-white);
  display: flex;
  flex-shrink: 0;
  gap: 0.25rem;
  height: 2rem;
  padding: 0 0.25rem 0 0.5rem;
}

.attachment-chip > .icon {
  margin-right: 0.25rem;
}

.attachment-chip-label {
  font-size: var(--font-size-user);
  font-weight: var(--font-weight-light);
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip-remove {
  align-items: center;
  background: none;
  border: none;
  color: var(--color-white);
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  height: 1.5rem;
  justify-content: center;
  width: 1.5rem;
}

.attachment-chip-remove .icon {
  height: 1rem;
  width: 1rem;
}

.prompt-input-actions {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 0.5rem;
  padding: 0 0.75rem 0.75rem;
}

.prompt-attach-button {
  align-items: center;
  border: none;
  border-radius: 9999px;
  color: var(--color-white);
  cursor: pointer;
  display: flex;
  height: 2rem;
  justify-content: center;
  width: 2rem;
}

.prompt-send-button {
  align-items: center;
  background: color-mix(in srgb, var(--sidebar-accent) 80%, transparent);
  border: none;
  border-radius: 9999px;
  color: var(--color-darkgrey);
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  height: 2rem;
  justify-content: center;
  margin-left: auto;
  width: 2rem;
}

.message-user-attachments {
  -webkit-user-select: none;
  margin-top: 0.25rem;
  user-select: none;
}

.message-attachment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.message-attachment-item {
  align-items: center;
  color: var(--color-muted);
  display: inline-flex;
  gap: 0.25rem;
}

.message-attachment-item .icon-attachment {
  height: 0.75rem;
  margin-top: -1px;
  width: 0.75rem;
}

.message-attachment-count {
  font-size: var(--font-size-user);
  line-height: 1;
}

body.is-submitting .attachment-chip-remove,
body.is-submitting .prompt-attach-button {
  cursor: default;
  pointer-events: none;
}

.input.sidebar-key-input {
  height: calc(var(--font-size-input) * var(--line-height-base) * 6 + 1.5rem);
  overflow-x: hidden;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

body.is-submitting .prompt-input {
  cursor: default;
  pointer-events: none;
}

.input::placeholder {
  color: var(--color-fill-25);
}

.footer {
  font-size: var(--font-size-base);
  min-height: var(--line-height-ui);
}

.footer-new {
  align-items: center;
  display: flex;
  min-height: var(--line-height-ui);
}

.footer-connected {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  min-height: var(--line-height-ui);
  width: 100%;
}

.footer-link {
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-light);
  height: var(--line-height-ui);
  line-height: var(--line-height-ui);
  min-width: 0;
  padding: 0;
  text-align: left;
}

.footer-add-key {
  align-items: center;
  color: var(--sidebar-accent);
  display: flex;
  gap: 0.75rem;
}

.footer-usage {
  color: var(--color-muted);
  flex-shrink: 0;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-light);
  line-height: var(--line-height-ui);
  text-align: right;
  white-space: nowrap;
}

.footer-link:hover:not(.footer-add-key) {
  color: var(--sidebar-accent);
}

.model-select {
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  color: var(--color-muted);
  flex: 1;
  min-width: 0;
  outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.model-select:hover {
  color: var(--sidebar-accent);
}

.model-select:focus {
  box-shadow: none;
  outline: none;
}

.hidden {
  display: none;
}
