:root {
  --ink: #172126;
  --muted: #64727a;
  --line: #d9e2e2;
  --paper: #f6f8f5;
  --panel: #ffffff;
  --accent: #0d8f78;
  --accent-2: #e4563a;
  --accent-3: #4f6fb6;
  --warn: #f5b841;
  --bubble-me: #dff5ee;
  --bubble-them: #ffffff;
  --shadow: 0 18px 50px rgba(24, 43, 45, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
}

.share-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(rgba(246, 248, 245, .94), rgba(246, 248, 245, .94)),
    radial-gradient(circle at 20% 20%, rgba(13, 143, 120, .25), transparent 28%),
    radial-gradient(circle at 80% 30%, rgba(228, 86, 58, .2), transparent 24%);
}

.share-page {
  width: min(620px, 100%);
}

.share-link {
  direction: ltr;
  overflow-wrap: anywhere;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--ink);
  font-weight: 800;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(rgba(16, 38, 42, .86), rgba(16, 38, 42, .86)),
    radial-gradient(circle at 30% 20%, rgba(13, 143, 120, .5), transparent 30%),
    radial-gradient(circle at 70% 60%, rgba(228, 86, 58, .38), transparent 28%);
}

.auth-screen.hidden {
  display: none;
}

.auth-card {
  width: min(430px, 100%);
  padding: 26px;
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 16px;
  border-radius: 8px;
  color: white;
  background: var(--accent-2);
  font-size: 28px;
  font-weight: 900;
}

.auth-card h1 {
  margin-bottom: 10px;
}

.auth-copy, .auth-status {
  color: var(--muted);
  line-height: 1.7;
}

.auth-card label {
  display: grid;
  gap: 7px;
  margin: 14px 0;
  color: #334146;
  font-weight: 700;
}

.auth-card input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: 0;
}

.otp-row {
  display: none !important;
}

.otp-row.visible {
  display: grid !important;
}

button, input, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 76px minmax(280px, 380px) minmax(360px, 1fr) minmax(260px, 330px);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.mobile-scrim, .mobile-list-btn {
  display: none;
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 10px;
  background: #10262a;
}

.brand, .rail-btn, .tool-btn, .send-btn {
  display: grid;
  place-items: center;
  border: 0;
}

.brand {
  width: 48px;
  height: 48px;
  margin-bottom: 14px;
  border-radius: 8px;
  color: white;
  background: var(--accent-2);
  font-size: 24px;
  font-weight: 800;
}

.rail-btn {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: #cfe4e2;
  background: transparent;
}

.rail-btn.active, .rail-btn:hover {
  background: rgba(255, 255, 255, .12);
  color: white;
}

.list-pane, .details-pane {
  background: var(--panel);
  border-inline-start: 1px solid var(--line);
  overflow: auto;
}

.list-pane {
  border-inline-end: 1px solid var(--line);
}

.pane-head, .chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

h1, h2, h3, h4, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

.tool-btn {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 8px;
  color: var(--ink);
  background: #edf3f1;
}

.tool-btn:hover {
  background: #dfecea;
}

.tool-btn.active-recording {
  color: white;
  background: var(--accent-2);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 18px 14px;
  padding: 0 12px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.quick-actions {
  display: flex;
  gap: 8px;
  padding: 0 18px 14px;
  overflow-x: auto;
}

.quick-actions button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--ink);
  background: white;
}

.conversation-list {
  display: grid;
  gap: 4px;
  padding: 0 10px 18px;
}

.conversation {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  text-align: start;
  color: var(--ink);
  background: transparent;
}

.conversation:hover, .conversation.active {
  background: #eef5f3;
}

.avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: white;
  background: var(--accent-3);
  font-weight: 800;
}

.avatar.large {
  width: 88px;
  height: 88px;
  font-size: 34px;
}

.avatar.huge {
  width: 108px;
  height: 108px;
  margin: auto;
  font-size: 42px;
  background: var(--accent);
}

.conversation h3 {
  margin: 0 0 5px;
  font-size: 16px;
}

.conversation p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  min-width: 25px;
  padding: 4px 7px;
  border-radius: 999px;
  color: white;
  background: var(--accent-2);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.chat-pane {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background:
    linear-gradient(rgba(246, 248, 245, .9), rgba(246, 248, 245, .9)),
    radial-gradient(circle at 20% 20%, rgba(13, 143, 120, .12), transparent 28%),
    radial-gradient(circle at 80% 30%, rgba(228, 86, 58, .11), transparent 24%);
}

.chat-head {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(10px);
}

.peer {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.peer h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.peer p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.smart-strip {
  margin: 14px 18px 0;
  padding: 12px 14px;
  border: 1px solid #c8dfd9;
  border-radius: 8px;
  background: #effaf6;
  color: #18443c;
  font-size: 14px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.message {
  max-width: min(72%, 620px);
  padding: 11px 13px 8px;
  border: 1px solid rgba(23, 33, 38, .08);
  border-radius: 8px;
  background: var(--bubble-them);
  box-shadow: 0 8px 22px rgba(23, 33, 38, .06);
}

.message.me {
  align-self: flex-start;
  background: var(--bubble-me);
}

.message.them {
  align-self: flex-end;
}

.message .name {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.message p {
  margin: 0;
  line-height: 1.6;
}

.message time {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  text-align: end;
}

.message.system {
  align-self: center;
  max-width: 80%;
  color: #47545a;
  background: #fff7df;
  border-color: #ecd384;
  text-align: center;
}

.composer {
  position: relative;
  display: grid;
  grid-template-columns: 42px 42px 42px 1fr 48px;
  align-items: end;
  gap: 8px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .86);
  z-index: 3;
}

.scroll-bottom {
  position: absolute;
  inset-inline-start: 50%;
  bottom: 82px;
  z-index: 4;
  transform: translateX(-50%);
  display: none;
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  color: white;
  background: var(--accent);
  box-shadow: var(--shadow);
  font-weight: 800;
}

.scroll-bottom.visible {
  display: block;
}

.emoji-panel {
  position: absolute;
  inset-inline-start: 18px;
  bottom: 70px;
  display: none;
  grid-template-columns: repeat(5, 38px);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  z-index: 5;
}

.emoji-panel.open {
  display: grid;
}

.emoji-panel button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: #f3f6f4;
  font-size: 20px;
}

.message-media {
  display: block;
  max-width: 260px;
  width: 100%;
  border-radius: 8px;
  margin-top: 8px;
}

.message-audio {
  display: block;
  width: min(260px, 100%);
  margin-top: 8px;
}

.composer textarea {
  min-height: 42px;
  max-height: 120px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: 0;
}

.send-btn {
  width: 48px;
  height: 42px;
  border-radius: 8px;
  color: white;
  background: var(--accent);
}

.details-pane {
  padding: 18px;
}

.profile-panel, .feature-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 8px 30px rgba(23, 33, 38, .05);
}

.profile-panel {
  display: grid;
  justify-items: center;
  text-align: center;
}

.profile-panel h3 {
  margin: 14px 0 6px;
}

.profile-panel p {
  color: var(--muted);
  line-height: 1.6;
}

.feature-panel {
  margin-top: 14px;
}

.feature-panel h4 {
  margin-bottom: 12px;
}

.feature-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  color: #334146;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.admin-grid div {
  padding: 12px;
  border-radius: 8px;
  background: #f3f6f4;
}

.admin-grid strong, .admin-grid span {
  display: block;
}

.admin-grid span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

dialog {
  width: min(430px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(16, 38, 42, .45);
}

.modal-card {
  position: relative;
  padding: 24px;
  text-align: center;
}

.modal-close {
  position: absolute;
  inset-inline-start: 12px;
  top: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: #edf3f1;
}

.call-preview {
  display: grid;
  gap: 16px;
  margin: 20px 0;
}

.call-bars {
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 5px;
  height: 34px;
}

.call-bars i {
  width: 8px;
  border-radius: 8px;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.call-bars i:nth-child(1) { height: 16px; animation-delay: .1s; }
.call-bars i:nth-child(2) { height: 28px; animation-delay: .2s; }
.call-bars i:nth-child(3) { height: 20px; animation-delay: .3s; }
.call-bars i:nth-child(4) { height: 30px; animation-delay: .4s; }

.primary-action {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  color: white;
  background: var(--accent);
  font-weight: 800;
}

.side-action {
  width: 100%;
  margin-top: 8px;
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  color: white;
  background: var(--accent);
  font-weight: 800;
}

.side-action.ghost {
  color: var(--ink);
  background: #edf3f1;
}

.link-action {
  display: block;
  text-align: center;
  text-decoration: none;
}

.icon {
  position: relative;
  display: inline-block;
  width: 20px;
  height: 20px;
}

.icon.chat { border: 2px solid currentColor; border-radius: 6px; }
.icon.chat::after { content: ""; position: absolute; right: 2px; bottom: -6px; border: 5px solid transparent; border-top-color: currentColor; transform: rotate(-25deg); }
.icon.group::before, .icon.group::after { content: ""; position: absolute; border: 2px solid currentColor; border-radius: 50%; }
.icon.group::before { width: 9px; height: 9px; right: 0; top: 2px; box-shadow: -9px 0 0 -2px currentColor; }
.icon.group::after { width: 18px; height: 8px; right: 0; bottom: 2px; border-radius: 8px 8px 3px 3px; }
.icon.channel { border: 2px solid currentColor; border-radius: 50%; }
.icon.channel::before { content: ""; position: absolute; width: 9px; height: 2px; background: currentColor; right: 8px; top: 8px; box-shadow: 4px -5px 0 -1px currentColor, 4px 5px 0 -1px currentColor; }
.icon.story { border: 2px dashed currentColor; border-radius: 50%; }
.icon.call::before { content: ""; position: absolute; width: 15px; height: 15px; border: 3px solid currentColor; border-top: 0; border-left: 0; border-radius: 0 0 10px 0; transform: rotate(38deg); right: 1px; top: 1px; }
.icon.lock { border: 2px solid currentColor; border-radius: 4px; top: 7px; height: 12px; }
.icon.lock::before { content: ""; position: absolute; width: 10px; height: 9px; border: 2px solid currentColor; border-bottom: 0; border-radius: 8px 8px 0 0; right: 3px; top: -10px; }
.icon.plus::before, .icon.plus::after, .icon.search::before, .icon.search::after, .icon.video::before, .icon.video::after, .icon.more::before, .icon.more::after, .icon.attach::before, .icon.mic::before, .icon.mic::after, .icon.send::before, .icon.emoji::before, .icon.emoji::after { content: ""; position: absolute; }
.icon.plus::before { width: 18px; height: 2px; background: currentColor; right: 1px; top: 9px; }
.icon.plus::after { width: 2px; height: 18px; background: currentColor; right: 9px; top: 1px; }
.icon.search::before { width: 12px; height: 12px; border: 2px solid currentColor; border-radius: 50%; right: 1px; top: 1px; }
.icon.search::after { width: 8px; height: 2px; background: currentColor; right: 12px; top: 14px; transform: rotate(45deg); }
.icon.video::before { width: 13px; height: 12px; border: 2px solid currentColor; border-radius: 4px; right: 0; top: 4px; }
.icon.video::after { border: 6px solid transparent; border-right-color: currentColor; left: -4px; top: 4px; }
.icon.more::before { width: 4px; height: 4px; border-radius: 50%; background: currentColor; right: 2px; top: 8px; box-shadow: 7px 0 0 currentColor, 14px 0 0 currentColor; }
.icon.attach::before { width: 10px; height: 18px; border: 2px solid currentColor; border-left: 0; border-radius: 0 8px 8px 0; transform: rotate(38deg); right: 4px; top: 0; }
.icon.mic::before { width: 9px; height: 13px; border: 2px solid currentColor; border-radius: 8px; right: 4px; top: 0; }
.icon.mic::after { width: 14px; height: 8px; border: 2px solid currentColor; border-top: 0; border-radius: 0 0 8px 8px; right: 2px; top: 10px; }
.icon.send::before { border: 10px solid transparent; border-right-color: currentColor; right: 0; top: 0; transform: rotate(180deg); }
.icon.emoji::before { width: 16px; height: 16px; border: 2px solid currentColor; border-radius: 50%; right: 0; top: 0; }
.icon.emoji::after { width: 3px; height: 3px; border-radius: 50%; background: currentColor; right: 5px; top: 6px; box-shadow: 7px 0 0 currentColor, 3px 6px 0 1px currentColor; }

@keyframes pulse {
  0%, 100% { transform: scaleY(.65); opacity: .55; }
  50% { transform: scaleY(1); opacity: 1; }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 68px minmax(260px, 340px) 1fr;
  }
  .details-pane {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 66px;
    position: relative;
  }
  .rail {
    grid-row: 2;
    flex-direction: row;
    justify-content: space-around;
    padding: 8px;
  }
  .brand {
    display: none;
  }
  .rail-btn {
    width: 44px;
    height: 44px;
  }
  .mobile-list-btn {
    display: grid;
  }
  .mobile-scrim {
    display: none !important;
  }
  .list-pane {
    grid-row: 1;
    display: none;
    width: 100%;
    min-width: 0;
    height: 100%;
    border: 0;
    box-shadow: none;
  }
  .list-pane.open {
    display: block;
  }
  .chat-pane {
    grid-row: 1;
    min-height: 0;
    height: calc(100dvh - 66px);
  }
  .app-shell.mobile-list-open .chat-pane {
    display: none;
  }
  .smart-strip {
    display: none;
  }
  .message {
    max-width: 88%;
  }
  .composer {
    grid-template-columns: 38px 38px 38px 1fr 44px;
    gap: 6px;
    padding: 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .scroll-bottom {
    bottom: 68px;
  }
  .tool-btn {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }
  .send-btn {
    width: 44px;
    height: 38px;
  }
  .composer textarea {
    min-height: 38px;
  }
  .head-actions {
    gap: 5px;
  }
  .chat-head {
    padding: 10px;
  }
  .peer h2 {
    font-size: 15px;
  }
  .avatar {
    width: 42px;
    height: 42px;
  }
}
