* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

.gradient-bg {
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  width: 100%;
  background: linear-gradient(90deg, #df2a00 0%, #6b2f63 52%, #123285 100%);
  color: #ffffff;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 20px;
  padding: 26px;
  backdrop-filter: blur(4px);
}

.login-card h1 {
  margin-bottom: 18px;
  text-align: center;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form input,
.login-form button {
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
}

.login-form input {
  background: #111111;
  color: #ffffff;
}

.login-form button {
  background: #16a34a;
  color: #ffffff;
  cursor: pointer;
  font-weight: 600;
}

.error-message {
  color: #ffd8d8;
  margin-top: 10px;
  min-height: 22px;
  text-align: center;
}

.hint {
  text-align: center;
  opacity: 0.9;
  margin-top: 6px;
}

.chat-body {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.app-shell {
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  min-height: -webkit-fill-available;
  width: min(100%, 1200px);
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
}

.top-profile {
  position: sticky;
  top: 0;
  z-index: 12;
  padding: calc(env(safe-area-inset-top) + 8px) 10px 6px;
}

.profile-strip {
  background: linear-gradient(90deg, #ffffff 0%, #cfcfcf 100%);
  border-radius: 32px;
  padding: 7px 10px 7px 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.profile-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar-upload {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #e9e9e9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #2a2a2a;
  cursor: pointer;
}

.avatar-upload input {
  display: none;
}

.avatar-upload img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

#avatarFallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #333333;
}

.name-wrap h2 {
  color: #ffffff;
  font-weight: 500;
  font-size: clamp(26px, 6vw, 40px);
  line-height: 1;
}

.name-wrap small {
  display: none;
}

.presence-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4b5563;
}

.status-dot.online {
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

.main-dot {
  width: 12px;
  height: 12px;
}

.presence-hidden {
  display: none;
}

.settings-btn {
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
  color: #ffffff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.chat-messages {
  overflow-y: auto;
  padding: 12px 0 128px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  width: fit-content;
  max-width: min(75vw, 330px);
  background: #000000;
  color: #ffffff;
  padding: 18px 28px;
  font-size: clamp(20px, 4.6vw, 30px);
  line-height: 1;
}

.bubble-top {
  display: none;
}

.bubble p {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.bubble.theirs {
  align-self: flex-start;
  border-radius: 22px 22px 22px 0;
}

.bubble.mine {
  align-self: flex-end;
  border-radius: 22px 22px 0 22px;
}

.chat-input-bar {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  z-index: 8;
  padding: 8px 0 calc(env(safe-area-inset-bottom) + 10px);
}

.chat-input-bar input {
  width: min(72vw, 360px);
  border: none;
  border-radius: 26px;
  background: #000000;
  color: #ffffff;
  padding: 16px 24px;
  font-size: clamp(28px, 4.5vw, 34px);
  outline: none;
  margin-left: 0;
}

.chat-input-bar input::placeholder {
  color: #f0f0f0;
}

.chat-input-bar button {
  display: none;
}

.settings-panel {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 78px);
  right: 10px;
  width: 210px;
  background: rgba(0, 0, 0, 0.92);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 8px;
  z-index: 20;
}

.settings-panel h3 {
  margin-bottom: 4px;
  font-size: 15px;
}

.settings-panel button {
  border: none;
  border-radius: 8px;
  padding: 8px;
  text-align: left;
  background: #1a1a1a;
  color: #ffffff;
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 30;
}

.modal-content {
  width: 100%;
  max-width: 380px;
  background: #111111;
  border-radius: 14px;
  padding: 16px;
}

.modal-content h3 {
  margin-bottom: 10px;
}

.modal-content form {
  display: grid;
  gap: 10px;
}

.modal-content input {
  border: 1px solid #333333;
  border-radius: 8px;
  background: #000000;
  color: #ffffff;
  padding: 10px;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.modal-actions button {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 10px;
  background: #1f2937;
  color: #ffffff;
  cursor: pointer;
}

.info-message {
  min-height: 22px;
  margin-top: 8px;
  font-size: 14px;
}

.hidden {
  display: none;
}

@media (min-width: 641px) {
  .top-profile {
    padding: 16px;
  }

  .profile-strip {
    max-width: 620px;
    margin: 0 auto;
  }

  .chat-messages {
    padding: 20px 16px 150px;
    gap: 14px;
  }

  .bubble {
    max-width: min(58vw, 440px);
    font-size: 28px;
  }

  .chat-input-bar {
    padding-left: 16px;
    bottom: 20px;
  }

  .chat-input-bar input {
    width: min(440px, 56vw);
    font-size: 30px;
  }
}

@media (min-width: 1025px) {
  .profile-strip {
    max-width: 760px;
  }

  .chat-messages {
    padding-left: 20px;
    padding-right: 20px;
  }

  .bubble {
    max-width: 460px;
  }
}
