* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111827;
  color: #f9fafb;
  overflow: hidden;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 290px 1fr;
}

.sidebar {
  background: #0b1220;
  border-right: 1px solid rgba(255,255,255,0.08);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: #ffffff;
  color: #111827;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 13px;
  color: #9ca3af;
}

.new-chat {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  cursor: pointer;
}

.new-chat:hover {
  background: rgba(255,255,255,0.1);
}

.info {
  margin-top: 10px;
  padding: 14px;
  background: rgba(255,255,255,0.05);
  border-radius: 16px;
}

.info-title {
  color: #9ca3af;
  font-size: 13px;
  margin-bottom: 6px;
}

.info-value {
  font-size: 14px;
  word-break: break-word;
}

.hint {
  margin-top: auto;
  color: #9ca3af;
  font-size: 13px;
  line-height: 1.45;
}

.chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  background:
    radial-gradient(circle at top left, rgba(59,130,246,0.16), transparent 30%),
    #111827;
}

.chat-header {
  padding: 20px 26px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chat-header h1 {
  margin: 0;
  font-size: 21px;
}

.chat-header p {
  margin: 5px 0 0;
  color: #9ca3af;
  font-size: 14px;
}

.status {
  font-size: 13px;
  color: #d1d5db;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 8px 12px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.status.ok {
  color: #86efac;
}

.status.error {
  color: #fca5a5;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 900px;
  width: fit-content;
}

.message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 34px;
}

.user .avatar {
  background: #ffffff;
  color: #111827;
}

.bubble {
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.55;
  white-space: pre-wrap;
  background: rgba(255,255,255,0.08);
  color: #f9fafb;
  overflow-wrap: anywhere;
}

.user .bubble {
  background: #ffffff;
  color: #111827;
}

.composer {
  padding: 18px 28px 26px;
  display: flex;
  gap: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

textarea {
  flex: 1;
  resize: none;
  min-height: 48px;
  max-height: 160px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  outline: none;
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 15px;
  line-height: 1.4;
}

textarea::placeholder {
  color: #9ca3af;
}

button {
  border: none;
}

#sendBtn {
  min-width: 120px;
  padding: 0 18px;
  border-radius: 18px;
  background: #ffffff;
  color: #111827;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

#sendBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

  .sidebar {
    display: none;
  }

  .messages {
    padding: 18px;
  }

  .message {
    max-width: 100%;
  }

  .bubble {
    max-width: calc(100vw - 84px);
  }

  .composer {
    padding: 14px;
  }

  #sendBtn {
    min-width: auto;
  }
}

@media (max-width: 640px) {
  body {
    overflow: hidden;
  }

  .chat {
    background: #111827;
  }

  .chat-header {
    align-items: flex-start;
    padding: 14px 14px 12px;
  }

  .chat-header h1 {
    font-size: 17px;
    line-height: 1.25;
  }

  .chat-header p {
    display: none;
  }

  .status {
    padding: 6px 9px;
    font-size: 12px;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .messages {
    padding: 14px 10px 12px;
    gap: 14px;
  }

  .message {
    gap: 8px;
  }

  .avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    flex-basis: 30px;
    font-size: 11px;
  }

  .bubble {
    max-width: calc(100vw - 58px);
    padding: 11px 12px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.5;
  }

  .composer {
    padding: 10px;
    gap: 8px;
    align-items: flex-end;
  }

  textarea {
    min-height: 44px;
    max-height: 128px;
    padding: 12px 13px;
    border-radius: 15px;
    font-size: 16px;
  }

  #sendBtn {
    width: 48px;
    height: 44px;
    padding: 0;
    border-radius: 15px;
    font-size: 0;
    position: relative;
    flex: 0 0 48px;
  }

  #sendBtn::before {
    content: ">";
    font-size: 22px;
    line-height: 1;
  }
}

@media (max-width: 380px) {
  .chat-header {
    gap: 10px;
  }

  .chat-header h1 {
    font-size: 16px;
  }

  .status {
    max-width: 38vw;
  }

  .messages {
    padding-left: 8px;
    padding-right: 8px;
  }

  .bubble {
    max-width: calc(100vw - 54px);
  }
}
