* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111;
  color: #fff;
}
.calc-shell {
  max-width: 430px;
  min-height: 100vh;
  margin: auto;
  padding: 20px 18px 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.calc-top {
  font-size: 14px;
  color: #888;
  display: flex;
  justify-content: space-between;
  padding: 10px;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #555;
}
.calc-display {
  height: 145px;
  font-size: 62px;
  text-align: right;
  padding: 30px 8px;
  overflow: hidden;
}
.keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.keys button {
  height: 76px;
  border: 0;
  border-radius: 50%;
  background: #303030;
  color: #fff;
  font-size: 27px;
}
.keys .light {
  background: #aaa;
  color: #111;
}
.keys .op,
.keys .equals {
  background: #ff9f0a;
}
.keys .zero {
  grid-column: span 2;
  border-radius: 40px;
  text-align: left;
  padding-left: 29px;
}
.keys .equals {
  border-radius: 40px;
}
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.hidden {
  display: none !important;
}
.unlock-card {
  width: min(360px, 100%);
  background: #fff;
  color: #111;
  border-radius: 26px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 20px 60px #000;
}
.heart {
  font-size: 30px;
}
.unlock-card h2 {
  margin: 8px 0 4px;
}
.unlock-card p {
  color: #777;
}
.unlock-card input {
  width: 100%;
  padding: 15px;
  border: 1px solid #ddd;
  border-radius: 14px;
  font-size: 25px;
  text-align: center;
}
.hint {
  font-size: 12px;
  color: #777;
  margin: 12px 0 14px;
}
.primary {
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 14px;
  background: #111;
  color: #fff;
  font-size: 16px;
}
.unlock-card #err {
  height: 20px;
  color: #d00;
  margin-top: 8px;
  font-size: 13px;
}
.chat-body {
  height: 100vh;
  background: #0b141a;
  color: #e9edef;
  display: flex;
  flex-direction: column;
}
.chat-head {
  height: 68px;
  background: #202c33;
  display: flex;
  align-items: center;
  padding: 10px 15px;
  border-bottom: 1px solid #ddd;
  position: relative;
}
.avatar {
  width: 43px;
  height: 43px;
  border-radius: 50%;
  background: #6b7c85;
  color: #fff;
  display: grid;
  place-items: center;
}
.head-info {
  margin-left: 11px;
  flex: 1;
}
.head-info small {
  display: block;
  color: #8696a0;
  font-size: 11px;
}
.head-info i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3aa655;
  margin-right: 4px;
}
.icon-btn {
  border: 0;
  background: none;
  font-size: 26px;
}
.menu-box {
  display: none;
  position: absolute;
  right: 12px;
  top: 57px;
  background: #233138;
  border: 1px solid #37474f;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  z-index: 4;
}
.menu-box.show {
  display: block;
}
.menu-box button,
.menu-box a {
  display: block;
  border: 0;
  background: #233138;
  padding: 12px 16px;
  text-decoration: none;
  color: #e9edef;
  font-size: 14px;
}
.chat-body main {
  flex: 1;
  overflow: auto;
  padding: 15px 12px;
}
.row {
  display: flex;
  margin: 7px 0;
}
.mine {
  justify-content: flex-end;
}
.bubble {
  max-width: 78%;
  padding: 10px 13px;
  border-radius: 18px;
  background: #202c33;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  color: #e9edef;
  white-space: pre-wrap;
  word-break: break-word;
}
.mine .bubble {
  background: #005c4b;
}
.bubble small {
  position: absolute;
  right: 10px;
  bottom: 3px;
  color: #777;
  font-size: 8px;
  line-height: 9px;
  white-space: nowrap;
}

.bubble .msg-text {
  padding-right: 45px;
}
.typing {
  font-size: 11px;
  color: #8696a0;
  padding: 0 16px 5px;
}
.chat-body form {
  display: flex;
  gap: 7px;
  background: #202c33;
  padding: 9px;
}
.chat-body input {
  flex: 1;
  border: 1px solid #37474f;
  background: #2a3942;
  color: #e9edef;
  border-radius: 25px;
  padding: 12px 15px;
  font-size: 16px;
  outline: none;
}
.round,
.send {
  border: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 20px;
}
.round {
  background: #2a3942;
  color: #e9edef;
}
.send {
  background: #00a884;
  color: #fff;
}
.chat-body #toast {
  position: fixed;
  bottom: 75px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111;
  color: #fff;
  padding: 9px 14px;
  border-radius: 20px;
  opacity: 0;
  transition: 0.2s;
  font-size: 12px;
}
.chat-body #toast.show {
  opacity: 1;
  transform: translateX(-50%);
}
@media (max-width: 380px) {
  .keys button {
    height: 65px;
  }
  .calc-display {
    height: 120px;
    font-size: 50px;
  }
}
.chat-image {
  display: block;
  max-width: 230px;
  max-height: 300px;
  border-radius: 13px;
  object-fit: cover;
  margin-bottom: 3px;
}
.chat-audio {
  max-width: 230px;
  height: 38px;
}
.msg-text {
  white-space: pre-wrap;
}
.emoji-panel {
  position: fixed;
  bottom: 63px;
  left: 8px;
  right: 8px;
  max-width: 500px;
  margin: auto;
  background: #202c33;
  border: 1px solid #37474f;
  border-radius: 16px;
  padding: 12px;
  line-height: 2;
  font-size: 25px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  z-index: 5;
  word-spacing: 5px;
}
.attach {
  display: grid;
  place-items: center;
  cursor: pointer;
}
.mic {
  font-size: 12px;
}
.mic.recording {
  background: #d33;
  color: #fff;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}
.call-panel {
  position: fixed;
  inset: 0;
  background: #111;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}
.call-panel #remoteVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
}
.call-panel #localVideo {
  position: absolute;
  right: 14px;
  top: 78px;
  width: 110px;
  height: 155px;
  object-fit: cover;
  border-radius: 14px;
  border: 2px solid #fff;
  background: #222;
}
.call-top {
  position: absolute;
  top: 17px;
  left: 18px;
  right: 18px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  z-index: 2;
}
.call-controls {
  position: absolute;
  bottom: 28px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 16px;
  z-index: 3;
}
.call-controls button {
  width: 55px;
  height: 55px;
  border: 0;
  border-radius: 50%;
  font-size: 20px;
  background: #fff;
}
.call-controls .hang {
  background: #d33;
  color: #fff;
  transform: rotate(135deg);
}
.incoming {
  position: fixed;
  left: 50%;
  top: 75px;
  transform: translateX(-50%);
  z-index: 25;
  background: #fff;
  color: #111;
  padding: 17px 20px;
  border-radius: 17px;
  box-shadow: 0 10px 35px #555;
  text-align: center;
}
.incoming button {
  border: 0;
  border-radius: 10px;
  padding: 9px 16px;
  margin: 12px 4px 0;
}
.incoming #accept {
  background: #111;
  color: #fff;
}
.incoming #decline {
  background: #eee;
}

.emoji-panel .emoji-item {
  border: 0;
  background: transparent;
  padding: 3px 4px;
  margin: 0;
  cursor: pointer;
  font-size: 25px;
  line-height: 1.35;
  border-radius: 8px;
}
.emoji-panel .emoji-item:hover {
  background: #37474f;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 0;
}
img,
video {
  max-width: 100%;
}
.chat,
.app,
.calculator,
.screen,
.container {
  max-width: 100%;
  min-width: 0;
}
input,
button,
textarea {
  font-size: 16px;
}
@media (max-width: 600px) {
  .chat-head {
    padding: 10px 12px;
  }
  .chat-head .icon-btn {
    padding: 7px;
  }
  #messages {
    padding: 10px 8px;
  }
  .bubble {
    max-width: 82vw;
  }
  #composer {
    width: 100%;
    padding: 7px;
    gap: 5px;
  }
  #composer #text {
    min-width: 0;
    width: 100%;
  }
  .emoji-panel {
    left: 6px;
    right: 6px;
    bottom: 64px;
    max-height: 42vh;
    overflow-y: auto;
    font-size: 23px;
    padding: 8px;
  }
  .emoji-panel .emoji-item {
    font-size: 23px;
    padding: 2px;
  }
  .call-panel #localVideo {
    width: 88px;
    height: 124px;
    right: 10px;
    top: 68px;
  }
  .call-controls {
    bottom: 20px;
    gap: 10px;
  }
  .call-controls button {
    width: 50px;
    height: 50px;
  }
}

.v61-typing-indicator {
  display: none;
  padding: 3px 12px;
  min-height: 20px;
  font-size: 12px;
  line-height: 18px;
  opacity: 0.72;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 600px) {
  .v61-typing-indicator {
    padding: 3px 10px;
    font-size: 12px;
  }
}

#v63AudioCallButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* v6.4 WhatsApp-style reply UI */
.v64-reply-bar {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  background: rgba(128, 128, 128, 0.1);
  border-left: 3px solid currentColor;
}
.v64-reply-preview {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 12px;
}
.v64-reply-preview span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0.75;
}
.v64-reply-bar button {
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.v64-selected-message {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 8px;
}

/* v6.4 reply/long-press fixes */
#messages .row[data-message-id] {
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}
.v64-message-reply {
  border-left: 3px solid currentColor;
  background: rgba(128, 128, 128, 0.1);
  padding: 5px 8px;
  margin: -2px 0 7px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  font-size: 11px;
}
.v64-message-reply span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0.75;
}

/* WhatsApp-style message delivery/read states */
.msg-status {
  font-size: 11px;
  letter-spacing: -2px;
  margin-left: 2px;
  font-weight: 600;
}
.msg-status.sent,
.msg-status.delivered {
  color: #777;
}
.msg-status.read {
  color: #1e88e5;
}

/* Sender name shown above every message */
.bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}
.sender-name {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.65;
  margin: 0 8px 4px;
}
.row.mine .bubble-wrap {
  align-items: flex-end;
}
.row.theirs .bubble-wrap {
  align-items: flex-start;
}

/* Online/offline presence */
#presence {
  display: flex;
  align-items: center;
  gap: 5px;
}
#presence i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  background: #999;
}
#presence.online i {
  background: #2eaf55;
}
#presence.online {
  color: #2eaf55;
}

/* v6.5 message editing */
.bubble {
  position: relative;
}
.v65-edit-btn {
  position: absolute;
  right: 6px;
  top: 5px;
  width: 27px;
  height: 27px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  color: #555;
  font-size: 16px;
  line-height: 27px;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.mine .bubble:hover .v65-edit-btn,
.mine .bubble:focus-within .v65-edit-btn {
  opacity: 1;
}
.mine .bubble .v65-edit-btn:active {
  transform: scale(0.94);
}
@media (max-width: 600px) {
  .v65-edit-btn {
    opacity: 0.9;
    right: 5px;
    top: 4px;
  }
}

/* v6.6 mobile-friendly message action menu */
.v65-message-actions {
  position: fixed;
  z-index: 9999;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 5px;
  border-radius: 12px;
  background: var(--card-bg, #233138);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(128, 128, 128, 0.2);
  max-width: calc(100vw - 20px);
  box-sizing: border-box;
}
.v65-message-actions button {
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.v65-message-actions button:active {
  background: rgba(128, 128, 128, 0.14);
}
@media (max-width: 600px) {
  .v65-message-actions {
    padding: 4px;
    border-radius: 14px;
    gap: 1px;
  }
  .v65-message-actions button {
    padding: 10px 12px;
    font-size: 14px;
  }
  .v65-edit-btn {
    display: none;
  }
}

/* WhatsApp Dark chat background */
.chat-body main {
  position: relative;
  background-color: #0b141a;
  background-image: linear-gradient(
      rgba(11, 20, 26, 0.78),
      rgba(11, 20, 26, 0.78)
    ),
    url("chat-bg.jpg");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

/* Dark WhatsApp-style refinements */
.chat-body .chat-head {
  border-bottom: 1px solid #2a3942;
}
.chat-body .icon-btn {
  color: #e9edef;
}
.chat-body .bubble small {
  color: #8696a0;
}
.chat-body .v64-reply-bar {
  background: #202c33;
  border-left-color: #00a884;
}
.chat-body .v64-message-reply {
  background: #18252c;
  border-left-color: #00a884;
  color: #d1d7db;
}
.chat-body .sender-name {
  color: #53bdeb;
}
.chat-body .msg-status.sent,
.chat-body .msg-status.delivered {
  color: #8696a0;
}
.chat-body .msg-status.read {
  color: #53bdeb;
}
.chat-body .v65-edit-btn {
  background: #2a3942;
  color: #d1d7db;
}
.chat-body .v65-message-actions {
  background: #233138;
  border-color: #37474f;
}
.chat-body .v65-message-actions button {
  color: #e9edef;
}
.chat-body .v65-message-actions button:active {
  background: #37474f;
}

/* WhatsApp-style attachment sheet and camera switch */
.attach {
  position: relative;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.attach-menu {
  position: absolute;
  left: 8px;
  bottom: 62px;
  display: flex;
  gap: 10px;
  padding: 12px;
  background: #202c33;
  border: 1px solid #37474f;
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  z-index: 15;
}
.attach-menu button {
  width: 62px;
  height: 68px;
  border: 0;
  border-radius: 14px;
  background: #2a3942;
  color: #e9edef;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
}
.attach-menu button span {
  font-size: 24px;
}
.attach-menu button small {
  font-size: 11px;
  color: #d1d7db;
}
.chat-file {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #18252c;
  color: #53bdeb;
  text-decoration: none;
  max-width: 230px;
  word-break: break-word;
}
.call-controls #switchCamBtn {
  background: #2a3942;
  color: #fff;
}
@media (max-width: 600px) {
  .attach-menu {
    left: 4px;
    bottom: 60px;
    gap: 7px;
    padding: 10px;
  }
  .attach-menu button {
    width: 58px;
    height: 64px;
  }
  .call-controls {
    gap: 9px;
  }
  .call-controls button {
    width: 50px;
    height: 50px;
  }
}

/* v7.0 WhatsApp-style in-app floating call window */
.call-panel {
  transition: all 0.22s ease;
}
.call-panel.minimized {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;

  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  inset: auto;
  left: auto;
  right: 14px;
  bottom: 76px;
  width: 170px;
  height: 235px;
  border-radius: 18px;
  overflow: hidden;
  z-index: 1000;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.18);
  align-items: stretch;
  justify-content: stretch;
}
.call-panel.minimized #remoteVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.call-panel.minimized #localVideo {
  width: 55px;
  height: 78px;
  right: 7px;
  top: 7px;
  border-radius: 9px;
  border-width: 1px;
}
.call-panel.minimized .call-top {
  top: auto;
  bottom: 8px;
  left: 9px;
  right: 9px;
  font-size: 11px;
  text-shadow: 0 1px 3px #000;
}
.call-panel.minimized:active {
  cursor: grabbing;
}

.call-panel.minimized .call-controls {
  top: 7px;
  right: 7px;
  left: auto;
  bottom: auto;
  gap: 4px;
  justify-content: flex-end;
}
.call-panel.minimized .call-controls button {
  width: 32px;
  height: 32px;
  font-size: 13px;
  background: rgba(20, 30, 35, 0.78);
  color: #fff;
  backdrop-filter: blur(5px);
}
.call-panel.minimized .call-controls #muteBtn,
.call-panel.minimized .call-controls #camBtn,
.call-panel.minimized .call-controls #switchCamBtn {
  display: none;
}
.call-panel.minimized .call-controls #hangBtn {
  display: flex;
  width: 34px;
  height: 34px;
}
.call-panel.minimized .call-audio-info {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #172127;
}
.call-panel.minimized .call-audio-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #60747e;
  font-size: 27px;
  margin-bottom: 8px;
}
.call-panel.minimized .call-audio-name {
  font-size: 13px;
  font-weight: 600;
}
.call-panel.minimized .call-audio-status {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 3px;
}
.call-audio-info {
  position: absolute;
  inset: 70px 0 110px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.call-audio-avatar {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #60747e;
  font-size: 38px;
  margin-bottom: 12px;
}
.call-audio-name {
  font-size: 20px;
  font-weight: 600;
}
.call-audio-status {
  font-size: 13px;
  opacity: 0.7;
  margin-top: 5px;
}
.call-panel:not(.minimized) #minCallBtn {
  background: #2a3942;
  color: #fff;
}
@media (max-width: 600px) {
  .call-panel.minimized {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;

    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
    right: 10px;
    bottom: 72px;
    width: 145px;
    height: 200px;
    border-radius: 16px;
  }
  .call-panel.minimized #localVideo {
    width: 48px;
    height: 68px;
  }
}

/* Keep hang-up button red when call is minimized */
.call-panel.minimized #hangBtn {
  background: #e53935 !important;
  color: #fff !important;
  border-color: #e53935 !important;
}

.call-panel.minimized #hangBtn:hover {
  background: #c62828 !important;
}

.call-panel.minimized #hangBtn:active {
  background: #b71c1c !important;
}

/* Put minimized-call controls on the left */
.call-panel.minimized .call-controls {
  position: absolute;
  left: 8px;
  top: 8px;
  right: auto;
  bottom: auto;

  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Restore/minimize button */
.call-panel.minimized #minCallBtn {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hang-up button */
.call-panel.minimized #hangBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e53935 !important;
  color: #fff !important;
}
/* WhatsApp-style auto-hide controls for minimized call */
.call-panel.minimized .call-controls {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.call-panel.minimized.controls-hidden .call-controls {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-5px);
}
