:root {
  --talker-radius: 18px;
  --talker-soft-shadow: 0 8px 24px rgba(31, 41, 55, 0.08);
}

.main {
  position: relative;
  grid-template-rows: calc(64px + env(safe-area-inset-top)) minmax(0, 1fr) auto;
  overflow: hidden;
}

.chatHead {
  grid-row: 1;
  position: relative;
  z-index: 30;
  min-height: 64px;
  padding-top: env(safe-area-inset-top);
  background: rgba(250, 250, 250, 0.97);
  box-shadow: 0 1px 0 var(--line);
}

.chatTitle[data-profile-ready="true"] {
  cursor: pointer;
  border-radius: 14px;
  padding: 7px 9px;
  margin-left: -5px;
}

.chatTitle[data-profile-ready="true"]:active {
  background: rgba(0, 0, 0, 0.05);
}

.messages {
  grid-row: 2;
  min-height: 0;
  padding: 16px clamp(12px, 2.5vw, 24px);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overflow-anchor: auto;
  contain: layout paint;
}

.composer {
  grid-row: 3;
  position: relative;
  z-index: 25;
  padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
  background: rgba(250, 250, 250, 0.98);
}

.gcBar {
  position: absolute !important;
  z-index: 40;
  top: calc(64px + env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  width: auto !important;
  border-radius: 0 0 18px 18px;
  box-shadow: var(--talker-soft-shadow);
}

.msg {
  content-visibility: auto;
  contain-intrinsic-size: 64px;
  transform: translateZ(0);
}

.msg .avatar,
.messageAvatar {
  border-radius: 50%;
  cursor: pointer;
}

.bubble {
  border-radius: 6px 18px 18px 18px;
  box-shadow: 0 2px 10px rgba(31, 41, 55, 0.06);
}

.mine .bubble {
  border-radius: 18px 6px 18px 18px;
}

.composeRow textarea {
  border-radius: 20px;
  padding: 10px 14px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.composeRow textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--green) 60%, #ccc);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 14%, transparent);
}

.round,
.sendBtn,
.fileMenu button {
  border-radius: 16px;
}

.listRow,
.nav button,
.identityProfile,
.icon,
.round,
.sendBtn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.listRow {
  transition: background-color 120ms ease, transform 120ms ease;
}

.listRow:active,
.round:active,
.sendBtn:active,
.icon:active {
  transform: scale(0.97);
}

.sheet {
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

@media (max-width: 720px) {
  .main {
    grid-template-rows: calc(60px + env(safe-area-inset-top)) minmax(0, 1fr) auto;
  }

  .chatHead {
    height: auto;
    min-height: 60px;
  }

  .gcBar {
    top: calc(60px + env(safe-area-inset-top));
  }

  .messages {
    padding-top: 14px;
    padding-bottom: 14px;
    gap: 10px;
  }

  .msg {
    max-width: 94%;
  }

  .bubble {
    padding: 9px 12px;
  }
}

/* Avatar geometry is owned by its context, never by the uploaded image ratio. */
.identity .avatar,
.listRow .avatar,
.checkRow .avatar,
.conversationActionHead .avatar {
  width: 48px !important;
  height: 48px !important;
  min-width: 48px !important;
  min-height: 48px !important;
  flex: 0 0 48px !important;
  border-radius: 16px !important;
  overflow: hidden !important;
}

.msg .avatar,
.messageAvatar {
  width: 38px !important;
  height: 38px !important;
  min-width: 38px !important;
  min-height: 38px !important;
  flex: 0 0 38px !important;
  border-radius: 13px !important;
  overflow: hidden !important;
}

.avatar > img,
.messageAvatar > img,
.friendCardAvatar > img,
.member .avatar > img {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover !important;
  object-position: center !important;
}

.friendCardAvatar {
  display: grid !important;
  width: 92px !important;
  height: 92px !important;
  margin: 8px auto 14px !important;
  overflow: hidden !important;
  place-items: center;
  border-radius: 28px !important;
  background: linear-gradient(145deg, #ffd89a, #ff921d);
  box-shadow: 0 12px 28px rgba(214, 105, 7, 0.2);
}

/* One icon language across the browser client. */
.identityActions button,
.chatHead .icon,
.round,
.sendBtn,
.fileMenu button {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  min-height: 40px;
  border: 1px solid rgba(105, 76, 48, 0.1) !important;
  border-radius: 14px !important;
  color: #7b4a20 !important;
  background: rgba(255, 255, 255, 0.76) !important;
  box-shadow: 0 5px 14px rgba(91, 56, 24, 0.08);
  transition:
    transform 0.16s ease,
    color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
}

.identityActions button:hover,
.chatHead .icon:hover,
.round:hover,
.fileMenu button:hover {
  color: #ffffff !important;
  background: linear-gradient(145deg, #ffad3f, #ff7c0a) !important;
  box-shadow: 0 8px 19px rgba(229, 104, 0, 0.22);
  transform: translateY(-1px);
}

.sendBtn {
  color: #ffffff !important;
  border: 0 !important;
  background: linear-gradient(145deg, #ffad3f, #ff7c0a) !important;
}

@media (prefers-reduced-motion: reduce) {
  .messages {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Talker 2026 visual system: glass surfaces with explicit readable contrast. */
:root {
  color-scheme: light;
  --talker-orange: #ff8614;
  --talker-orange-strong: #f36b00;
  --talker-ink: #251b14;
  --talker-muted: #75675d;
  --talker-surface: rgba(255, 253, 249, 0.86);
  --talker-surface-solid: #fffdf9;
  --talker-line: rgba(105, 76, 48, 0.13);
  --talker-glow: rgba(255, 134, 20, 0.18);
  --talker-card-shadow: 0 12px 34px rgba(91, 56, 24, 0.11);
}

html,
body {
  color: var(--talker-ink) !important;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 190, 112, 0.24), transparent 34%),
    linear-gradient(145deg, #fffaf2 0%, #f7f4ef 52%, #fff7ea 100%) !important;
}

.side,
.main,
.card,
.sheet,
.fileMenu,
.identityProfile,
.gcIncoming > div,
.gcLayer > div {
  color: var(--talker-ink) !important;
}

.side,
.chatHead,
.composer,
.sheet,
.fileMenu,
body.page-login > .card {
  background: var(--talker-surface) !important;
  border-color: var(--talker-line) !important;
  -webkit-backdrop-filter: blur(22px) saturate(145%);
  backdrop-filter: blur(22px) saturate(145%);
}

.side {
  box-shadow: 16px 0 44px rgba(67, 42, 20, 0.09);
}

.chatHead {
  box-shadow: 0 10px 28px rgba(67, 42, 20, 0.07);
}

.identityProfile,
.listRow,
.nav button,
.bubble,
input,
textarea,
select,
.round,
.icon,
.sendBtn,
.fileMenu button {
  transition:
    transform 160ms cubic-bezier(.2, .8, .2, 1),
    box-shadow 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease;
}

.identityProfile,
.listRow {
  border: 1px solid transparent;
  border-radius: 20px !important;
}

.listRow:hover,
.identityProfile:hover {
  background: rgba(255, 255, 255, 0.72) !important;
  border-color: var(--talker-line);
  box-shadow: 0 8px 22px rgba(79, 49, 22, 0.08);
  transform: translateY(-1px);
}

.nav {
  gap: 7px;
  padding: 7px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.48);
}

.nav button {
  color: var(--talker-muted) !important;
  border-radius: 15px !important;
}

.nav button.active,
.sendBtn {
  color: #3a2008 !important;
  background: linear-gradient(135deg, #ffb341, var(--talker-orange)) !important;
  box-shadow: 0 8px 20px var(--talker-glow);
}

.chatTitle,
.chatTitle *,
.listRow b,
.identityProfile b {
  color: var(--talker-ink) !important;
}

.me,
.preview,
.time,
.chatSub,
.hint,
small {
  color: var(--talker-muted) !important;
}

.messages {
  background:
    linear-gradient(rgba(255, 252, 247, 0.74), rgba(255, 252, 247, 0.74)),
    radial-gradient(circle at 80% 15%, var(--talker-glow), transparent 38%) !important;
}

.bubble {
  color: var(--talker-ink) !important;
  background: rgba(255, 255, 255, 0.94) !important;
  border: 1px solid rgba(105, 76, 48, 0.1);
  box-shadow: 0 7px 22px rgba(62, 42, 24, 0.08);
}

.mine .bubble {
  color: #321b08 !important;
  background: linear-gradient(145deg, #ffd999, #ffb54b) !important;
  border-color: rgba(210, 108, 0, 0.2);
}

input,
textarea,
select {
  color: var(--talker-ink) !important;
  -webkit-text-fill-color: var(--talker-ink) !important;
  caret-color: var(--talker-orange-strong);
  background: rgba(255, 255, 255, 0.9) !important;
  border: 1px solid var(--talker-line) !important;
  border-radius: 16px !important;
}

input::placeholder,
textarea::placeholder {
  color: #9a8c82 !important;
  -webkit-text-fill-color: #9a8c82 !important;
  opacity: 1;
}

button {
  color: var(--talker-ink);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(255, 134, 20, 0.25) !important;
  outline-offset: 2px;
}

body.page-login > .card {
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 24px 70px rgba(99, 56, 18, 0.17);
}

.talkerBrandLogo {
  filter: drop-shadow(0 12px 22px rgba(229, 104, 0, 0.16));
}

html[data-theme="night"] {
  color-scheme: dark;
  --talker-ink: #fff8ef;
  --talker-muted: #c8bbae;
  --talker-surface: rgba(31, 27, 24, 0.88);
  --talker-surface-solid: #211d1a;
  --talker-line: rgba(255, 226, 194, 0.14);
}

html[data-theme="night"] body {
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 134, 20, 0.14), transparent 34%),
    #151311 !important;
}

html[data-theme="night"] .messages {
  background: rgba(20, 18, 16, 0.86) !important;
}

html[data-theme="night"] .bubble {
  color: #fff8ef !important;
  background: #302b27 !important;
}

html[data-theme="night"] .mine .bubble {
  color: #2d1907 !important;
  background: linear-gradient(145deg, #ffc66d, #ff941f) !important;
}

html[data-theme="night"] input,
html[data-theme="night"] textarea,
html[data-theme="night"] select {
  color: #fff8ef !important;
  -webkit-text-fill-color: #fff8ef !important;
  background: rgba(50, 45, 41, 0.94) !important;
}

.retentionCountdown {
  display: block;
  margin-top: 2px;
  color: #a85a10 !important;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
}

html[data-theme="night"] .retentionCountdown {
  color: #ffc06b !important;
}

/* Compact voice messages: a familiar chat bubble instead of browser controls. */
.voiceMessage {
  appearance: none;
  min-width: 96px;
  max-width: 230px;
  border: 0;
  padding: 2px 1px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.bubble.voiceBubble,
.bubble:has(.voiceMessage) {
  padding: 9px 15px !important;
  color: #422206 !important;
  background: linear-gradient(145deg, #ffc45f, #ff981f) !important;
  border: 0 !important;
  border-radius: 999px !important;
  box-shadow: 0 5px 14px rgba(218, 107, 0, 0.18) !important;
}

.mine .bubble.voiceBubble,
.mine .bubble:has(.voiceMessage) {
  color: #3a1c03 !important;
  background: linear-gradient(145deg, #ffbd4b, #ff8612) !important;
  border-radius: 999px !important;
}

.mine .voiceMessage {
  flex-direction: row-reverse;
}

.voiceMessage audio {
  display: none !important;
}

.talkerVoiceMark {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 0 0 24px;
  border-radius: 50%;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.32);
}

.talkerVoiceMark i {
  display: block;
  width: 2px;
  height: 5px;
  border-radius: 99px;
  background: currentColor;
  opacity: 0.92;
}

.talkerVoiceMark i:nth-child(2) {
  height: 10px;
}

.talkerVoiceMark i:nth-child(3) {
  height: 7px;
}

.talkerVoiceMark i:nth-child(4) {
  height: 3px;
}

.voiceDuration {
  min-width: 28px;
  font-size: 14px;
  font-weight: 650;
  text-align: start;
  opacity: 0.75;
}

.voiceMessage.playing .talkerVoiceMark i {
  animation: talkerVoiceWave 0.72s ease-in-out infinite alternate;
}

.voiceMessage.playing .talkerVoiceMark i:nth-child(2) {
  animation-delay: 0.12s;
}

.voiceMessage.playing .talkerVoiceMark i:nth-child(3) {
  animation-delay: 0.24s;
}

.voiceMessage.playing .talkerVoiceMark i:nth-child(4) {
  animation-delay: 0.36s;
}

@keyframes talkerVoiceWave {
  from { transform: scaleY(0.48); opacity: 0.55; }
  to { transform: scaleY(1); opacity: 1; }
}

#voiceBtn {
  position: relative;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

#voiceBtn.recording {
  color: #ffffff !important;
  background: #25a769 !important;
  transform: scale(1.08);
}

#voiceBtn.recording::after {
  content: "放開發送";
  position: fixed;
  left: 50%;
  bottom: 94px;
  z-index: 9999;
  min-width: 130px;
  padding: 12px 18px;
  border-radius: 18px;
  color: #ffffff;
  background: rgba(28, 31, 34, 0.88);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  font-size: 15px;
  font-weight: 650;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

/* Shared responsive shell: web and Android landscape use the same visual rhythm. */
@media (min-width: 721px) {
  body {
    padding: clamp(12px, 2.2vw, 30px);
    background:
      radial-gradient(circle at 12% 8%, rgba(255, 183, 91, 0.34), transparent 30%),
      radial-gradient(circle at 88% 90%, rgba(255, 134, 20, 0.2), transparent 34%),
      linear-gradient(135deg, #fffaf2, #f8f3ec) !important;
  }

  .app {
    width: min(1480px, 100%);
    height: calc(100vh - clamp(24px, 4.4vw, 60px));
    height: calc(100dvh - clamp(24px, 4.4vw, 60px));
    max-width: 1480px;
    grid-template-columns: clamp(330px, 29vw, 410px) minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 30px;
    background: rgba(255, 253, 249, 0.74);
    box-shadow: 0 28px 80px rgba(91, 56, 24, 0.17);
    backdrop-filter: blur(24px) saturate(1.15);
    -webkit-backdrop-filter: blur(24px) saturate(1.15);
  }

  .side {
    border-right-color: var(--talker-line);
    background: rgba(255, 248, 238, 0.78);
  }

  .identity {
    min-height: 88px;
    padding: 16px 18px;
    background: rgba(255, 253, 249, 0.76);
  }

  .avatar {
    width: 50px;
    height: 50px;
    border-radius: 17px;
    box-shadow: 0 7px 18px rgba(200, 103, 18, 0.13);
  }

  .search {
    padding: 11px 15px;
  }

  .nav {
    margin: 0 12px 8px;
    padding: 5px;
    border: 1px solid var(--talker-line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.6);
  }

  .nav button {
    border-radius: 14px;
  }

  .list {
    padding: 3px 10px 16px;
  }

  .listRow {
    margin: 5px 0;
    border: 1px solid transparent;
    border-radius: 20px;
  }

  .listRow:hover {
    border-color: rgba(255, 134, 20, 0.13);
    background: rgba(255, 255, 255, 0.78) !important;
    transform: translateY(-1px);
  }

  .listRow.on,
  .listRow.active {
    border-color: rgba(255, 134, 20, 0.22);
    background: linear-gradient(135deg, #fff0d8, #ffe5bd) !important;
  }

  .chatHead {
    min-height: 76px;
    padding-inline: 20px;
    background: rgba(255, 253, 249, 0.74);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .messages {
    padding: 22px clamp(22px, 4vw, 58px);
  }

  .composer {
    margin: 0 16px 14px;
    padding: 9px;
    border: 1px solid var(--talker-line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 10px 30px rgba(91, 56, 24, 0.09);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
  }
}

@media (max-width: 720px) {
  body {
    padding: 0;
  }

  .app {
    border-radius: 0;
  }
}
