:root {
  color-scheme: dark;
  --ink: #02050a;
  --panel: rgba(12, 19, 30, 0.7);
  --panel-strong: rgba(17, 25, 39, 0.88);
  --line: rgba(137, 168, 212, 0.18);
  --text: #f3f7ff;
  --muted: #9eabbf;
  --faint: rgba(200, 211, 230, 0.44);
  --brand: #2d8cff;
  --brand-2: #6ab4ff;
  --brand-3: #1976ff;
  --citrus: #6ab4ff;
  --coral: #ff7a7a;
  --sky: #82a9ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(90, 124, 170, 0.05) 1px, transparent 1px) 0 0 / 72px 72px,
    linear-gradient(90deg, rgba(90, 124, 170, 0.05) 1px, transparent 1px) 0 0 / 72px 72px,
    radial-gradient(circle at 22% 78%, rgba(25, 118, 255, 0.26), transparent 30rem),
    radial-gradient(circle at 72% 16%, rgba(25, 118, 255, 0.16), transparent 30rem),
    linear-gradient(180deg, #02050a 0%, #050912 48%, #02050a 100%);
  z-index: -1;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.glass {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(117, 164, 255, 0.08);
  backdrop-filter: blur(20px);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  display: flex;
  flex-direction: column;
  border-top: 0;
  border-bottom: 0;
  border-left: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(47, 143, 255, 0.1);
  border: 1px solid rgba(137, 168, 212, 0.18);
  color: var(--brand);
  box-shadow: 0 0 28px rgba(47, 143, 255, 0.15);
}

.brand-mark svg {
  width: 30px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 24px;
  letter-spacing: -0.02em;
}

.brand span,
.eyebrow,
.contact-data dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.nav {
  margin-top: 28px;
  display: grid;
  gap: 6px;
}

.nav-item {
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  text-align: left;
  text-decoration: none;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.nav-item span {
  width: 24px;
  color: var(--brand);
  text-align: center;
}

.mini-panel {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  padding: 14px;
}

.mini-panel strong,
.mini-panel span {
  display: block;
}

.mini-panel span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 5px rgba(255, 122, 122, 0.12);
}

.status-dot.online {
  background: var(--brand);
  box-shadow: 0 0 0 5px rgba(47, 143, 255, 0.14);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.topbar h1,
h2,
p {
  margin: 0;
}

.topbar h1 {
  margin-top: 6px;
  font-size: 34px;
  line-height: 1.05;
}

.top-actions,
.chat-actions,
.connect-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.button,
.icon-button {
  min-height: 42px;
  border-radius: 14px;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  font-weight: 800;
  color: var(--text);
}

.button.primary {
  background: linear-gradient(135deg, var(--brand-3), #3ba6ff);
  border-color: rgba(117, 164, 255, 0.7);
  color: white;
  box-shadow: 0 18px 42px rgba(47, 143, 255, 0.24);
}

.button.muted,
.icon-button {
  background: rgba(255, 255, 255, 0.06);
}

.button.danger {
  background: rgba(255, 122, 122, 0.14);
  color: #ffd9d9;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.conversation-layout {
  display: grid;
  grid-template-columns: minmax(270px, 340px) minmax(420px, 1fr) minmax(250px, 310px);
  gap: 16px;
  min-height: calc(100vh - 116px);
}

.conversation-list,
.chat-panel,
.contact-panel,
.connect-card,
.checklist,
.event-panel,
.settings-panel {
  border-radius: 22px;
  padding: 18px;
}

.conversation-list,
.thread,
.thread-row {
  min-width: 0;
}

.panel-head,
.chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2,
.chat-head h2 {
  margin-top: 5px;
  font-size: 20px;
}

.pill {
  border-radius: 999px;
  background: rgba(47, 143, 255, 0.16);
  color: #9cc3ff;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
}

.search {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.search input,
.composer input,
.settings-form input,
.select {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.threads {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.thread {
  border: 1px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  padding: 12px;
  text-align: left;
  color: var(--text);
}

.thread.active,
.thread:hover {
  border-color: rgba(47, 143, 255, 0.58);
  background: rgba(47, 143, 255, 0.11);
}

.thread-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.thread strong {
  display: block;
}

.thread small,
.thread p {
  color: var(--muted);
  font-size: 12px;
}

.thread p {
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.select {
  width: auto;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  padding: 0 10px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
  margin-top: 12px;
}

.tag {
  border-radius: 999px;
  background: rgba(117, 164, 255, 0.16);
  color: #dce8ff;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.messages {
  overflow-y: auto;
  padding: 18px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  max-width: min(76%, 620px);
  border-radius: 16px;
  padding: 10px 12px;
  line-height: 1.45;
  font-size: 14px;
}

.bubble small {
  display: block;
  color: rgba(255, 255, 255, 0.48);
  margin-top: 6px;
  font-size: 11px;
}

.bubble.in {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
}

.bubble.out {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(15, 109, 255, 0.3), rgba(47, 143, 255, 0.18));
  border: 1px solid rgba(117, 164, 255, 0.28);
}

.bubble.note {
  align-self: center;
  background: rgba(248, 214, 109, 0.12);
  border: 1px solid rgba(248, 214, 109, 0.2);
  color: #fff4c5;
}

.composer {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.contact-data {
  display: grid;
  gap: 14px;
  margin: 18px 0 0;
}

.contact-data div {
  display: grid;
  gap: 4px;
}

.contact-data dd {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

.divider {
  height: 1px;
  margin: 20px 0;
  background: var(--line);
}

.notes {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.note-card {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.connection-grid {
  display: grid;
  grid-template-columns: minmax(300px, 520px) minmax(280px, 1fr);
  gap: 16px;
}

.qr-box {
  margin: 22px auto;
  width: min(100%, 320px);
  aspect-ratio: 1;
  border-radius: 22px;
  background: #f6f7fb;
  padding: 18px;
  display: grid;
  place-items: center;
}

.qr-fake {
  width: 100%;
  height: 100%;
  background:
    linear-gradient(90deg, #0a0b10 10px, transparent 10px) 0 0 / 26px 26px,
    linear-gradient(#0a0b10 10px, transparent 10px) 0 0 / 26px 26px,
    radial-gradient(circle at 20% 20%, #0a0b10 0 34px, transparent 35px),
    radial-gradient(circle at 80% 20%, #0a0b10 0 34px, transparent 35px),
    radial-gradient(circle at 20% 80%, #0a0b10 0 34px, transparent 35px),
    #f6f7fb;
  border-radius: 10px;
}

.checklist ol {
  margin: 20px 0 0;
  padding: 0;
  display: grid;
  gap: 14px;
  list-style: none;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.checklist li span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
}

.event-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.event {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  padding: 12px;
  display: grid;
  gap: 6px;
}

.event code {
  color: var(--brand);
  white-space: normal;
}

.settings-panel {
  max-width: 760px;
}

.settings-form {
  margin-top: 20px;
  display: grid;
  gap: 14px;
}

.settings-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.settings-form input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  padding: 0 12px;
}

@media (max-width: 1180px) {
  .conversation-layout {
    grid-template-columns: 310px 1fr;
  }

  .contact-panel {
    display: none;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .nav {
    margin-top: 14px;
    display: flex;
    overflow-x: auto;
  }

  .mini-panel {
    display: none;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .conversation-layout,
  .connection-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .conversation-layout {
    min-height: auto;
  }

  .chat-panel {
    min-height: 620px;
  }
}
