:root {
  --bg: #050806;
  --ink: #edf9f4;
  --muted: #9db2aa;
  --soft: rgba(255, 255, 255, 0.07);
  --softer: rgba(255, 255, 255, 0.045);
  --panel: rgba(8, 15, 13, 0.88);
  --panel-solid: #0b1411;
  --panel-deep: #07100d;
  --line: rgba(111, 255, 201, 0.15);
  --accent: #20e69f;
  --accent-2: #0aa987;
  --blue: #2d8cff;
  --danger: #ff5a72;
  --warning: #ffd166;
  --shadow: 0 26px 88px rgba(0, 0, 0, 0.52);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background:
    radial-gradient(circle at 74% 4%, rgba(32, 230, 159, 0.2), transparent 30%),
    radial-gradient(circle at 12% 88%, rgba(45, 140, 255, 0.22), transparent 32%),
    linear-gradient(145deg, #030504, #09110e 48%, #030504);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.024) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.024) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 84%);
}

.ambient {
  position: fixed;
  width: 520px;
  height: 520px;
  border-radius: 999px;
  filter: blur(58px);
  opacity: .34;
  pointer-events: none;
  animation: drift 10s ease-in-out infinite alternate;
}

.ambient-one { top: -12%; right: 15%; background: var(--accent); }
.ambient-two { bottom: -14%; left: 6%; background: var(--blue); animation-delay: -4s; }

.scanline {
  position: fixed;
  inset-inline: 0;
  top: -38%;
  height: 38%;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(32, 230, 159, .09), transparent);
  animation: scan 7s linear infinite;
  opacity: .28;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-52px, 38px, 0) scale(1.1); }
}

@keyframes scan {
  from { transform: translateY(0); }
  to { transform: translateY(360%); }
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
textarea { resize: none; }
h1, h2, p { margin: 0; }
h2 { font-size: 17px; }

.app-shell {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: 76px 380px minmax(0, 1fr);
  background: rgba(0, 0, 0, 0.16);
}

.tool-strip,
.chats-pane,
.chat-main,
.tool-drawer {
  min-width: 0;
  min-height: 0;
  border-inline-start: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.tool-strip {
  display: grid;
  grid-auto-rows: 64px;
  align-content: start;
  gap: 10px;
  padding: 14px 10px;
  background: linear-gradient(180deg, rgba(12, 22, 19, .94), rgba(6, 12, 10, .92));
  box-shadow: inset -1px 0 0 rgba(255,255,255,.04);
}

.brand-mark,
.avatar,
.conversation-avatar {
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #03100c;
  font-weight: 900;
  box-shadow: 0 0 24px rgba(32, 230, 159, .28);
}

.brand-mark {
  width: 52px;
  height: 52px;
  font-size: 20px;
  position: relative;
}

.tool-button {
  width: 52px;
  height: 64px;
  position: relative;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 0 18px;
  background: rgba(255,255,255,.06);
  color: var(--ink);
  font-size: 21px;
  font-weight: 900;
}

.tool-button:hover,
.tool-button.active {
  border-color: rgba(32, 230, 159, .55);
  background: rgba(32, 230, 159, .16);
  box-shadow: 0 0 24px rgba(32, 230, 159, .15);
}

.tool-button::before {
  content: attr(data-label);
  position: absolute;
  inset-inline: 4px;
  bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(237, 249, 244, .72);
  font-size: 10px;
  line-height: 1;
}

.tool-button::after,
.brand-mark::after {
  content: attr(data-help);
  position: absolute;
  top: 50%;
  right: calc(100% + 14px);
  z-index: 30;
  width: 280px;
  min-height: 70px;
  display: grid;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid rgba(32, 230, 159, .34);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(15, 28, 24, .98), rgba(6, 12, 10, .98));
  box-shadow: 0 24px 70px rgba(0,0,0,.46), 0 0 35px rgba(32, 230, 159, .12);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.65;
  text-align: right;
  pointer-events: none;
  opacity: 0;
  transform: translate(10px, -50%) scale(.98);
  transition: opacity .16s ease, transform .16s ease;
}

.tool-button:hover::after,
.brand-mark:hover::after {
  opacity: 1;
  transform: translate(0, -50%) scale(1);
}

.tool-button::after {
  white-space: normal;
}

.chats-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: rgba(6, 13, 11, .9);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 78px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.pane-header div,
.chat-header div:not(.avatar),
.panel-head,
.risk-line {
  display: grid;
  gap: 4px;
}

.pane-header strong,
.chat-header strong { font-size: 20px; }

.pane-header span,
.chat-header span,
.item span,
.conversation-preview,
.conversation-phone,
.tiny,
.review-strip p,
.media-card span,
.panel-head span,
.rewrite-box span {
  color: var(--muted);
}

.live-dot {
  width: 12px;
  height: 12px;
  border-radius: 99px;
  background: var(--accent);
  box-shadow: 0 0 0 7px rgba(32, 230, 159, .12), 0 0 25px rgba(32, 230, 159, .45);
}

.chat-search {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.025);
}

.chat-search button { grid-column: 1 / -1; }

input, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(2, 8, 6, .62);
  color: var(--ink);
  outline: none;
}

input::placeholder,
textarea::placeholder { color: rgba(237, 249, 244, .42); }

input:focus,
textarea:focus {
  border-color: rgba(32, 230, 159, .75);
  box-shadow: 0 0 0 3px rgba(32, 230, 159, .12), 0 0 30px rgba(32, 230, 159, .12);
}

button,
.file-drop {
  border: 0;
  border-radius: 8px;
  padding: 11px 13px;
  background: rgba(255,255,255,.08);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  font-weight: 800;
}

button:hover,
.file-drop:hover { box-shadow: 0 0 22px rgba(32, 230, 159, .16); }

.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #03100c;
}

.conversation-list {
  overflow: auto;
  padding: 8px;
}

.conversation-row {
  width: 100%;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 10px;
  background: transparent;
  text-align: right;
}

.conversation-row:hover {
  background: rgba(255,255,255,.06);
}

.conversation-item.active .conversation-row {
  border-color: rgba(32, 230, 159, .42);
  background: rgba(32, 230, 159, .12);
  box-shadow: inset 0 0 0 1px rgba(32, 230, 159, .2);
}

.conversation-avatar {
  width: 46px;
  height: 46px;
  box-shadow: none;
}

.conversation-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.conversation-title,
.conversation-preview,
.conversation-phone {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 900;
}

.conversation-time {
  color: rgba(237, 249, 244, .58);
  font-size: 12px;
  white-space: nowrap;
}

.conversation-meta {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.unread-badge {
  min-width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 99px;
  padding: 0 7px;
  background: var(--accent);
  color: #03100c;
  font-size: 12px;
  font-weight: 900;
}

.delete-conversation {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  color: #ffdbe1;
  background: rgba(255, 90, 114, .16);
}

.chat-main {
  display: grid;
  grid-template-rows: 78px minmax(0, 1fr) auto;
  background:
    radial-gradient(circle at 16% 20%, rgba(32, 230, 159, .1) 0 2px, transparent 2px 50px),
    radial-gradient(circle at 78% 75%, rgba(45, 140, 255, .12), transparent 34%),
    rgba(3, 8, 6, .68);
}

.chat-header {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 17, 14, .78);
}

.avatar {
  width: 50px;
  height: 50px;
}

.status-pill,
.risk-badge {
  width: fit-content;
  border-radius: 999px;
  padding: 7px 13px;
  background: rgba(32, 230, 159, .18);
  color: #9cf7d0;
  border: 1px solid rgba(32, 230, 159, .32);
  font-weight: 900;
  white-space: nowrap;
}

.risk-badge.warn {
  background: rgba(255, 209, 102, .18);
  color: #ffe2a1;
  border-color: rgba(255, 209, 102, .34);
}

.risk-badge.block {
  background: rgba(255, 90, 114, .2);
  color: #ffdbe1;
  border-color: rgba(255, 90, 114, .36);
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 28px clamp(20px, 4vw, 56px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble {
  width: fit-content;
  max-width: min(74ch, 72%);
  padding: 11px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,.095);
  border: 1px solid rgba(255,255,255,.08);
  line-height: 1.65;
  box-shadow: 0 14px 30px rgba(0,0,0,.18);
  animation: messageIn .22s ease-out both;
}

.bubble.sent {
  align-self: flex-start;
  background: linear-gradient(135deg, rgba(32, 230, 159, .28), rgba(10, 169, 135, .2));
  border-color: rgba(32, 230, 159, .28);
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.composer-card {
  display: grid;
  gap: 10px;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--line);
  background: rgba(6, 12, 10, .92);
  box-shadow: 0 -20px 70px rgba(0,0,0,.28);
}

.composer-top,
.review-strip,
.panel-head,
.button-row,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.actions,
.button-row { flex-wrap: wrap; }

#replyInput {
  min-height: 116px;
  max-height: 220px;
  font-size: 17px;
  line-height: 1.7;
}

.review-strip,
.rewrite-box,
.panel,
.media-info,
.connect-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.055);
}

.review-strip {
  padding: 10px 12px;
}

.rewrite-box {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
}

.connect-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  background:
    radial-gradient(circle at 16% 0, rgba(32, 230, 159, .16), transparent 42%),
    rgba(255,255,255,.055);
}

.connect-card > div:first-child {
  display: grid;
  gap: 6px;
}

.connect-card strong {
  font-size: 18px;
}

.connect-card span {
  color: var(--muted);
  line-height: 1.65;
}

.tool-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 8;
  width: min(420px, calc(100vw - 76px));
  padding: 16px;
  background: linear-gradient(180deg, rgba(10, 18, 15, .96), rgba(6, 11, 9, .97));
  box-shadow: 30px 0 80px rgba(0, 0, 0, .42);
  transform: translateX(-104%);
  transition: transform .22s ease;
  overflow: auto;
}

.tool-drawer.open { transform: translateX(0); }

.tool-page {
  display: none;
  gap: 14px;
}

.tool-page.active { display: grid; }

.stack,
.list,
.media-list {
  display: grid;
  gap: 9px;
}

.item,
.media-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.account-row { grid-template-columns: minmax(0, 1fr) auto; }

.item-main,
.media-info {
  padding: 11px;
  color: var(--ink);
  text-align: right;
  display: grid;
  gap: 4px;
}

.item-main {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.055);
}

.item.active .item-main {
  border-color: rgba(32, 230, 159, .86);
  box-shadow: inset 0 0 0 1px rgba(32, 230, 159, .72), 0 0 18px rgba(32, 230, 159, .14);
}

.mini-action {
  min-width: 62px;
  background: rgba(255,255,255,.1);
}

.mini-action.danger,
.delete-conversation {
  background: rgba(255, 90, 114, .18);
  color: #ffdbe1;
}

.switch { width: 52px; height: 30px; position: relative; }
.switch input { display: none; }
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
}
.switch span::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  top: 3px;
  right: 3px;
  border-radius: 50%;
  background: white;
  transition: transform .18s ease;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(-22px); }

.file-drop {
  display: block;
  border: 1px dashed rgba(32, 230, 159, .32);
}

.file-drop input { display: none; }

.qr-box {
  width: 100%;
  aspect-ratio: 1.15;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.055);
  overflow: hidden;
}

.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-placeholder {
  width: 58%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 10px solid rgba(237, 249, 244, .9);
  color: var(--ink);
  font-size: 30px;
}

.media-card video,
.media-card img {
  width: 84px;
  height: 62px;
  object-fit: cover;
  border-radius: 7px;
  background: var(--soft);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 68px minmax(280px, 34vw) minmax(0, 1fr);
  }

  .tool-strip {
    grid-auto-rows: 48px;
    padding: 10px;
  }

  .brand-mark,
  .tool-button {
    width: 48px;
    height: 48px;
  }

  .status-pill { display: none; }
}

@media (max-width: 760px) {
  body { overflow: hidden; }

  .app-shell {
    grid-template-columns: 62px minmax(0, 1fr);
  }

  .tool-strip {
    grid-auto-rows: 44px;
    gap: 8px;
    padding: 8px;
  }

  .brand-mark,
  .tool-button {
    width: 44px;
    height: 44px;
  }

  .chats-pane {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 62px;
    z-index: 4;
    width: min(330px, calc(100vw - 62px));
    transform: translateX(0);
  }

  .chat-main {
    grid-column: 2;
    min-width: calc(100vw - 62px);
  }

  .chat-header {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .chat-search,
  .actions,
  .composer-top,
  .review-strip,
  .item,
  .account-row,
  .media-card {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .messages {
    padding: 18px 14px;
  }

  .bubble {
    max-width: 88%;
  }

  #replyInput {
    min-height: 98px;
  }
}
