:root {
  color-scheme: dark;
  --bg: #0b141a;
  --bg-soft: #0f1b21;
  --panel: #111b21;
  --panel-2: #16232b;
  --incoming: #202c33;
  --outgoing: #005c4b;
  --text: #e9edef;
  --muted: #8696a0;
  --accent: #00a884;
  --accent-2: #06cf9f;
  --danger: #ea0038;
  --warning: #f0b429;
  --border: #2a3942;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  scrollbar-color: #374b55 transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(0, 168, 132, 0.18), transparent 32rem),
    linear-gradient(135deg, #0b141a 0%, #0d171d 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1rem;
  background: var(--accent);
  color: #03251e;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

button:hover {
  background: var(--accent-2);
  transform: translateY(-1px);
}

button.secondary {
  background: #22313b;
  color: var(--text);
}

button.secondary:hover {
  background: #2c414d;
}

button.danger {
  background: var(--danger);
  color: #fff;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.82rem 0.95rem;
  background: #0f1a20;
  color: var(--text);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.15);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #374b55;
  border-radius: 999px;
}

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

.shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid rgba(42, 57, 66, 0.9);
  padding: 1.15rem;
  background: rgba(11, 20, 26, 0.9);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand h1,
.card h2 {
  margin: 0;
  letter-spacing: -0.02em;
}

.brand h1 {
  font-size: 1.35rem;
}

.brand p,
.hint,
.card p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.dot {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 18px currentColor;
}

.dot.ready {
  background: var(--accent-2);
}

.dot.error {
  background: var(--danger);
}

.card {
  background: linear-gradient(180deg, rgba(22, 35, 43, 0.94), rgba(17, 27, 33, 0.98));
  border: 1px solid rgba(42, 57, 66, 0.92);
  border-radius: 20px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.card-head,
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-head h2 {
  font-size: 1.05rem;
}

.qr-card img {
  width: 100%;
  max-width: 270px;
  display: block;
  margin: 0.85rem auto 0;
  border-radius: 16px;
  background: #fff;
  padding: 0.65rem;
}

.qr-card.hidden {
  display: none;
}

.account-card .row {
  margin-top: 0.8rem;
}

.tabs {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.tab {
  background: transparent;
  color: var(--muted);
  text-align: left;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0.78rem 0.9rem;
}

.tab:hover {
  background: rgba(0, 168, 132, 0.08);
  transform: none;
}

.tab.active {
  background: rgba(0, 168, 132, 0.14);
  color: var(--text);
  border-color: rgba(0, 168, 132, 0.35);
}

.content {
  padding: 1.15rem;
  min-width: 0;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.chats-layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 1rem;
  height: calc(100vh - 2.3rem);
}

.chat-list-card,
.conversation-card {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-list-card input,
#contactSearch {
  margin-top: 0.85rem;
}

.chat-list {
  overflow: auto;
  margin-top: 0.9rem;
  padding-right: 0.15rem;
  display: grid;
  gap: 0.5rem;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  border: 1px solid rgba(42, 57, 66, 0.8);
  border-radius: 16px;
  padding: 0.38rem;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
}

.chat-item:hover {
  border-color: rgba(0, 168, 132, 0.5);
  background: rgba(0, 168, 132, 0.07);
}

.chat-item.active {
  border-color: var(--accent);
  background: rgba(0, 168, 132, 0.13);
}

.chat-open {
  min-width: 0;
  flex: 1;
  border: 0;
  border-radius: 12px;
  padding: 0.62rem 0.68rem;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.chat-open:hover {
  background: rgba(255, 255, 255, 0.03);
  transform: none;
}

.chat-open strong {
  display: block;
  margin-bottom: 0.22rem;
  font-weight: 750;
}

.chat-open span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-delete {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.42rem 0.62rem;
  background: #263942;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1;
}

.chat-delete:hover {
  background: var(--danger);
  color: #fff;
}

.conversation-card {
  background:
    linear-gradient(rgba(17, 27, 33, 0.94), rgba(17, 27, 33, 0.94)),
    radial-gradient(circle at top right, rgba(0, 168, 132, 0.12), transparent 26rem);
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 1rem 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.message {
  position: relative;
  max-width: min(76%, 680px);
  border: 1px solid rgba(42, 57, 66, 0.72);
  border-radius: 16px 16px 16px 6px;
  padding: 0.62rem 0.75rem;
  background: var(--incoming);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
}

.message.me {
  align-self: flex-end;
  border-radius: 16px 16px 6px 16px;
  background: linear-gradient(180deg, #006b58, var(--outgoing));
  border-color: rgba(6, 207, 159, 0.25);
}

.message .meta {
  display: block;
  color: rgba(233, 237, 239, 0.58);
  font-size: 0.74rem;
  margin-top: 0.32rem;
}

.message .media-actions {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.message .media-actions button {
  padding: 0.45rem 0.68rem;
  border-radius: 999px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 0.55rem;
  border-top: 1px solid rgba(42, 57, 66, 0.8);
  padding-top: 0.85rem;
}

.composer input {
  border-radius: 999px;
}

.form-card {
  max-width: 820px;
  margin-bottom: 1rem;
}

.stack {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
}

.check input {
  width: auto;
  accent-color: var(--accent);
}

.logs {
  min-height: 60vh;
  max-height: 74vh;
  overflow: auto;
  white-space: pre-wrap;
  color: #c7d3da;
  font-size: 0.88rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: min(460px, calc(100vw - 2rem));
  background: rgba(15, 26, 32, 0.96);
  border: 1px solid rgba(0, 168, 132, 0.35);
  border-radius: 14px;
  padding: 0.82rem 1rem;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 160ms ease;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1020px) {
  .shell,
  .chats-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .chats-layout {
    height: auto;
  }

  .conversation-card {
    min-height: 72vh;
  }

  .composer {
    grid-template-columns: 1fr;
  }
}

.new-chat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}
