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

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

body {
  font-family: Arial, sans-serif;
  background: #111;
  color: #222;
}

#app {
  width: 100%;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;

  background: #f1f3f5;

  display: flex;
  flex-direction: column;

  overflow: hidden;
}

/* =========================
   HEADER
========================= */

header {
  flex: 0 0 auto;
  height: 58px;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  background: #111;
  color: #fff;

  padding: 5px 12px;
}

header h1 {
  font-size: 19px;
  line-height: 22px;
  font-weight: 700;
}

header p {
  margin-top: 2px;
  font-size: 11px;
  opacity: 0.65;
}

/* =========================
   MAIN
========================= */

main {
  flex: 1;
  min-height: 0;

  display: flex;
  flex-direction: column;

  overflow: hidden;
}

/* =========================
   CHAT AREA
========================= */

#chatBox {
  flex: 1;
  min-height: 0;

  overflow-y: auto;
  overflow-x: hidden;

  padding: 14px 12px;

  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* =========================
   CHAT BUBBLE
========================= */

.chat-message {
  width: fit-content;
  max-width: 86%;

  margin-bottom: 10px;
  padding: 9px 12px 7px;

  background: #fff;

  border-radius: 4px 15px 15px 15px;

  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.08);

  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.chat-username {
  margin-bottom: 3px;

  font-size: 13px;
  font-weight: 700;

  color: #111;
}

.chat-text {
  font-size: 14px;
  line-height: 20px;

  color: #333;
}

.chat-time {
  margin-top: 4px;

  font-size: 9px;
  line-height: 12px;

  color: #999;
  text-align: right;
}

/* =========================
   EMPTY CHAT
========================= */

.empty-chat {
  padding: 25px 10px;

  text-align: center;

  font-size: 13px;
  color: #999;
}

/* =========================
   INPUT AREA
========================= */

#chatForm {
  flex: 0 0 auto;

  padding: 8px;

  background: #fff;

  border-top: 1px solid #ddd;

  padding-bottom:
    calc(8px + env(safe-area-inset-bottom));
}

/* =========================
   USERNAME
========================= */

#username {
  width: 100%;
  height: 40px;

  border: 1px solid #d5d7da;
  border-radius: 10px;

  padding: 0 12px;

  font-size: 14px;

  outline: none;

  background: #f8f9fa;
}

#username:focus {
  border-color: #888;
}

/* =========================
   MESSAGE INPUT
========================= */

.message-row {
  display: flex;

  gap: 7px;

  margin-top: 7px;
}

#message {
  flex: 1;
  min-width: 0;

  height: 42px;

  border: 1px solid #d5d7da;
  border-radius: 10px;

  padding: 0 12px;

  font-size: 14px;

  outline: none;

  background: #fff;
}

#message:focus {
  border-color: #888;
}

/* =========================
   SEND BUTTON
========================= */

button {
  flex: 0 0 auto;

  height: 42px;
  min-width: 72px;

  border: none;
  border-radius: 10px;

  background: #111;
  color: #fff;

  font-size: 13px;
  font-weight: 600;

  cursor: pointer;

  transition:
    transform 0.1s ease,
    opacity 0.2s ease;
}

button:active {
  transform: scale(0.96);
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* =========================
   SCROLLBAR
========================= */

#chatBox::-webkit-scrollbar {
  width: 4px;
}

#chatBox::-webkit-scrollbar-thumb {
  background: #bbb;
  border-radius: 10px;
}

#chatBox::-webkit-scrollbar-track {
  background: transparent;
}

/* =========================
   MOBILE
========================= */

@media (max-width: 600px) {

  #app {
    max-width: 100%;
  }

  header {
    height: 54px;
  }

  header h1 {
    font-size: 18px;
  }

  #chatBox {
    padding: 10px;
  }

  .chat-message {
    max-width: 90%;

    margin-bottom: 8px;

    padding: 8px 11px 6px;
  }

  .chat-username {
    font-size: 12px;
  }

  .chat-text {
    font-size: 14px;
    line-height: 19px;
  }

  .chat-time {
    font-size: 9px;
  }

  #chatForm {
    padding: 7px;

    padding-bottom:
      calc(7px + env(safe-area-inset-bottom));
  }

  #username {
    height: 38px;
  }

  #message,
  button {
    height: 40px;
  }

  button {
    min-width: 68px;
  }
}