:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f7f9;
  color: #202329;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

body.locked .app {
  display: none;
}

body:not(.locked) .login-view {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  background: #ffffff;
}

#loginError {
  min-height: 20px;
  color: #c2410c;
  font-size: 14px;
}

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

.sidebar {
  border-right: 1px solid #d9dee7;
  background: #ffffff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
  overflow: hidden;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
}

#status {
  margin-top: 8px;
  color: #667085;
  font-size: 14px;
}

.field {
  display: grid;
  gap: 8px;
  color: #475467;
  font-size: 14px;
}

.field input,
.quality-picker select,
textarea {
  border: 1px solid #cfd6e2;
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

.field input:focus,
.quality-picker select:focus,
textarea:focus {
  border-color: #3478f6;
  box-shadow: 0 0 0 3px rgba(52, 120, 246, 0.15);
}

.files-head,
.composer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quality-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #475467;
  font-size: 14px;
}

.quality-picker select {
  height: 40px;
  padding: 0 30px 0 10px;
  background: #ffffff;
  color: #243043;
}

.files-head {
  justify-content: space-between;
}

button,
.file-picker span {
  border: 1px solid #c6cfdb;
  background: #ffffff;
  color: #243043;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
}

button:hover,
.file-picker span:hover {
  background: #f1f4f8;
}

#send {
  margin-left: auto;
  border-color: #1f6feb;
  background: #1f6feb;
  color: #ffffff;
}

#loginButton {
  border-color: #1f6feb;
  background: #1f6feb;
  color: #ffffff;
}

#send:disabled {
  opacity: 0.65;
  cursor: wait;
}

.files {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.chats {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}

.chat-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: stretch;
  border: 1px solid #e2e6ee;
  border-radius: 8px;
  background: #fbfcfe;
}

.chat-item.active {
  border-color: #1f6feb;
  background: #eaf2ff;
}

.chat-row {
  min-width: 0;
  display: grid;
  gap: 3px;
  text-align: left;
  border: 0;
  background: transparent;
}

.chat-row:hover {
  background: transparent;
}

.chat-row small {
  color: #667085;
}

.chat-delete {
  width: 40px;
  border: 0;
  border-left: 1px solid #e2e6ee;
  border-radius: 0 8px 8px 0;
  color: #9a3412;
  background: transparent;
  padding: 0;
}

.chat-delete:hover,
.message-delete:hover {
  color: #7f1d1d;
  background: #fff1f0;
}

.file-row {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid #e2e6ee;
  border-radius: 8px;
  text-decoration: none;
  color: #202329;
  background: #fbfcfe;
}

.file-row small {
  color: #667085;
}

.chat {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.chat-bar {
  min-height: 62px;
  border-bottom: 1px solid #d9dee7;
  background: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chat-bar p {
  color: #667085;
  font-size: 14px;
}

.chat.dragging {
  outline: 3px solid rgba(31, 111, 235, 0.28);
  outline-offset: -8px;
}

.messages {
  padding: 28px;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bubble {
  position: relative;
  max-width: 850px;
  border: 1px solid #e0e5ee;
  border-radius: 8px;
  padding: 14px 52px 14px 16px;
  white-space: pre-wrap;
  line-height: 1.55;
  background: #ffffff;
}

.bubble-text {
  min-width: 0;
}

.bubble.user {
  align-self: flex-end;
  background: #eaf2ff;
  border-color: #c9ddff;
}

.bubble.error {
  background: #fff1f0;
  border-color: #ffccc7;
}

.bubble.pending {
  align-self: flex-start;
  color: #475467;
  background: #ffffff;
}

.dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #667085;
  animation: pulse-dot 1.15s infinite ease-in-out;
}

.dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes pulse-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.bubble a {
  color: #1f6feb;
}

.message-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 0;
  padding: 5px 7px;
  color: #9a3412;
  background: transparent;
  font-size: 12px;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  border: 1px solid #cfd6e2;
  border-radius: 8px;
  padding: 6px 8px;
  color: #344054;
  text-decoration: none;
  background: #ffffff;
  font-size: 13px;
}

.attachment img {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 6px;
}

.composer {
  border-top: 1px solid #d9dee7;
  padding: 18px;
  background: #ffffff;
  display: grid;
  gap: 12px;
  flex: none;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 92px;
}

.file-picker input {
  display: none;
}

.picked-files {
  min-width: 0;
  color: #667085;
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow: hidden;
}

.picked-files button {
  max-width: min(260px, 100%);
  padding: 6px 8px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.picked-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picked-files-summary {
  align-self: center;
  color: #667085;
  font-size: 13px;
}

.picked-files-summary.warning {
  color: #b42318;
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid #d9dee7;
    max-height: 38dvh;
    overflow: auto;
  }

  .messages {
    padding: 18px;
  }
}
