:root {
  --bg-top: #0c1523;
  --bg-bottom: #07101a;
  --panel: rgba(19, 31, 49, 0.88);
  --panel-strong: rgba(28, 44, 69, 0.96);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(155, 189, 231, 0.24);
  --text: #e8eef8;
  --muted: #b7c8dd;
  --soft: #edf4fb;
  --metal-1: #dde6ef;
  --metal-2: #bcc9d8;
  --metal-border: #5f748d;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.4);
  --glow: 0 0 0 1px rgba(150, 190, 245, 0.12), 0 16px 48px rgba(42, 90, 150, 0.18);
  --danger-top: #d96d7f;
  --danger-bottom: #a34255;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 680px at 50% -10%, rgba(82, 130, 188, 0.3), transparent 60%),
    radial-gradient(800px 600px at 10% 10%, rgba(42, 75, 122, 0.35), transparent 60%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.shell {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  margin: 0;
  padding: 20px 20px 24px;
}

.hero {
  display: block;
  padding: 30px 34px;
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(34, 53, 82, 0.98), rgba(16, 28, 45, 0.98));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow), var(--glow);
}

.hero-pill,
.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: #dce9f7;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hero h1,
.auth-card h2 {
  margin: 14px 0 8px;
  font-family: "Sora", "Manrope", sans-serif;
}

.hero h1 {
  font-size: 44px;
}

.hero p,
.card-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 16px;
}

.meta-card,
.mini-card {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.meta-label,
.mini-label,
.code-label,
.token-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.meta-value,
.mini-value {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--soft);
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(360px, 1fr);
  gap: 22px;
  margin-top: 24px;
}

.hidden {
  display: none !important;
}

.auth-card {
  padding: 32px;
  border-radius: 30px;
  background: linear-gradient(180deg, var(--panel-strong), rgba(14, 24, 40, 0.98));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow), var(--glow);
}

.qr-frame {
  display: grid;
  place-items: center;
  width: min(100%, 280px);
  aspect-ratio: 1;
  margin: 24px auto 18px;
  padding: 18px;
  border-radius: 28px;
  background: linear-gradient(180deg, #eff5fb, #bcc8d6);
  border: 1px solid #667e98;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.qr-frame img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0;
    image-rendering: pixelated;
}

.code-panel,
.token-panel,
.actions,
.status-stack {
  display: flex;
  align-items: center;
  gap: 12px;
}

.code-panel,
.token-panel {
  justify-content: space-between;
  padding: 14px 16px;
  margin-top: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.code-value {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #f2f7ff;
}

.token-panel {
  display: block;
}

.token-value {
  margin-top: 8px;
  word-break: break-all;
  color: var(--soft);
  font-size: 14px;
}

.actions,
.status-stack {
  margin-top: 20px;
}

.qr-actions {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.qr-refresh-btn {
  min-width: 220px;
}

button {
  appearance: none;
  cursor: pointer;
  border: none;
  transition: transform 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

button:disabled {
  cursor: default;
  opacity: 0.78;
  transform: none;
  filter: none;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 800;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  color: #102036;
  background: linear-gradient(180deg, var(--metal-1), var(--metal-2));
  border: 1px solid var(--metal-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.primary-btn {
  flex: 1;
}

.secondary-btn {
  background: linear-gradient(180deg, #d7e1ea, #b9c7d6);
}

.secondary-btn.danger {
  color: #fff5f6;
  background: linear-gradient(180deg, var(--danger-top), var(--danger-bottom));
  border-color: rgba(123, 30, 49, 0.55);
  box-shadow: none;
}

.primary-btn.pending {
  color: #102036;
  background: linear-gradient(180deg, #cde4ff, #89aed7);
}

.state-card {
  display: flex;
  flex-direction: column;
}

.status-hero {
  margin-top: 18px;
  padding: 20px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.status-pill-large {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  color: #102036;
  background: linear-gradient(180deg, #dce9f7, #b7cadf);
  border: 1px solid rgba(125, 151, 182, 0.72);
}

.status-note {
  margin-top: 14px;
  color: #f1f6fc;
  font-size: 16px;
  line-height: 1.6;
}

.status-steps {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.status-step {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px 4px;
}

.status-step-dot {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, #93c9ff, #5f8fbd);
  box-shadow: 0 0 0 4px rgba(111, 176, 239, 0.12);
}

.status-step-title {
  font-size: 14px;
  font-weight: 800;
  color: #eef5ff;
}

.status-step-copy {
  margin-top: 4px;
  color: #c9d7e6;
  line-height: 1.55;
  font-size: 14px;
}

.status-stack {
  margin-top: auto;
}

.status-stack.session-done {
  display: none;
}

.desktop-shell {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 20px;
  margin-top: 24px;
  min-height: calc(100vh - 64px);
  height: calc(100vh - 64px);
}

.shell-sidebar,
.shell-main {
  border-radius: 30px;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow), var(--glow);
}

.shell-sidebar {
  padding: 18px 14px;
  background: linear-gradient(180deg, rgba(16, 28, 45, 0.96), rgba(10, 18, 30, 0.98));
}

.side-logo {
  display: grid;
  place-items: center;
  width: 100%;
  height: 54px;
  border-radius: 18px;
  margin-bottom: 20px;
  font-family: "Sora", "Manrope", sans-serif;
  font-weight: 700;
  color: #dce9f7;
  background: linear-gradient(180deg, rgba(120, 175, 235, 0.24), rgba(69, 112, 161, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.side-pill {
  display: grid;
  place-items: center;
  min-height: 42px;
  margin-bottom: 12px;
  border-radius: 15px;
  font-size: 12px;
  font-weight: 700;
  color: #d6e4f5;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.side-pill.active {
  background: linear-gradient(180deg, rgba(120, 175, 235, 0.24), rgba(69, 112, 161, 0.18));
}

.shell-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(18, 30, 48, 0.92), rgba(11, 20, 33, 0.98));
}

.shell-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(12, 20, 34, 0.36);
}

.topbar-title,
.panel-title {
  font-size: 22px;
  font-weight: 800;
  color: #f2f7ff;
}

.topbar-subtitle,
.panel-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.compact {
  min-height: 44px;
  padding: 0 14px;
}

.shell-body {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 22px;
  padding: 22px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.chat-list-panel,
.chat-stage {
  border-radius: 24px;
  background: rgba(19, 31, 49, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--glow);
}

.chat-list-panel {
  padding: 16px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel-head {
  padding-bottom: 14px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-list {
  display: grid;
  gap: 12px;
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding-right: 4px;
}

.chat-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  width: 100%;
  gap: 12px;
  align-items: center;
  padding: 14px;
  text-align: left;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.chat-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chat-row.active {
  background: linear-gradient(180deg, rgba(104, 157, 217, 0.16), rgba(62, 96, 140, 0.12));
  border-color: rgba(141, 192, 248, 0.28);
}

.chat-row.has-unread:not(.active) {
  border-color: rgba(141, 192, 248, 0.18);
  background: linear-gradient(180deg, rgba(57, 85, 122, 0.16), rgba(28, 45, 69, 0.12));
}

.chat-row-avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #14304a;
  background: linear-gradient(180deg, #d7e4f1, #b8c8da);
  border: 1px solid #647b95;
}

.chat-row-name {
  font-size: 15px;
  font-weight: 800;
  color: #f2f7ff;
}

.chat-row.has-unread .chat-row-name,
.chat-row.has-unread .chat-row-preview {
  color: #edf5ff;
}

.chat-row-meta,
.chat-row-preview {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.chat-row-badge {
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #c6566a, #973546);
}

.chat-stage {
  display: flex;
  min-height: 0;
  padding: 28px;
}

.chat-workspace {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  border: 1px solid rgba(146, 180, 221, 0.14);
  background: linear-gradient(180deg, rgba(18, 30, 48, 0.72), rgba(15, 26, 40, 0.88));
  overflow: hidden;
}

.chat-workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.chat-workspace-profile {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chat-workspace-avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #14304a;
  background: linear-gradient(180deg, #d7e4f1, #b8c8da);
  border: 1px solid #647b95;
}

.chat-workspace-title {
  font-size: 20px;
  font-weight: 800;
  color: #f2f7ff;
}

.chat-workspace-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  overflow: auto;
  min-height: 0;
  flex: 1;
  scroll-behavior: smooth;
}

.message-bubble {
  max-width: min(78%, 640px);
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.12);
}

.message-bubble.own {
  align-self: flex-end;
  color: #102036;
  background: linear-gradient(180deg, #dce9f7, #b7cadf);
  border-color: rgba(125, 151, 182, 0.7);
}

.message-bubble.peer {
  align-self: flex-start;
}

.message-author {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
}

.message-text {
  margin-top: 8px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-meta {
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.7;
}

.message-system {
  display: grid;
  place-items: center;
  min-height: 260px;
  text-align: center;
  color: var(--muted);
  line-height: 1.6;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 18px 20px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(12, 20, 34, 0.32);
}

.composer-input {
  width: 100%;
  min-height: 56px;
  max-height: 160px;
  resize: none;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(155, 189, 231, 0.18);
  background: rgba(255, 255, 255, 0.05);
  color: #f2f7ff;
  font: inherit;
  outline: none;
}

.composer-input::placeholder {
  color: var(--muted);
}

.composer-input:focus {
  border-color: rgba(141, 192, 248, 0.42);
  box-shadow: 0 0 0 3px rgba(104, 157, 217, 0.14);
}

.composer-send {
  flex: 0 0 auto;
  min-width: 132px;
}

.chat-list::-webkit-scrollbar,
.messages-list::-webkit-scrollbar {
  width: 10px;
}

.chat-list::-webkit-scrollbar-thumb,
.messages-list::-webkit-scrollbar-thumb {
  background: rgba(141, 192, 248, 0.22);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.chat-list::-webkit-scrollbar-track,
.messages-list::-webkit-scrollbar-track {
  background: transparent;
}

.empty-state {
  height: 100%;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  border-radius: 24px;
  border: 1px solid rgba(146, 180, 221, 0.14);
  background: linear-gradient(180deg, rgba(18, 30, 48, 0.72), rgba(15, 26, 40, 0.88));
}

.empty-orb {
  width: 108px;
  height: 108px;
  border-radius: 32px;
  background: radial-gradient(circle at 35% 30%, #9fd6ff, #39689c 52%, #16304f 100%);
  box-shadow: 0 0 0 10px rgba(114, 195, 255, 0.08), 0 0 38px rgba(114, 195, 255, 0.18);
}

.empty-state h3 {
  margin: 0;
  font-family: "Sora", "Manrope", sans-serif;
  font-size: 30px;
}

.empty-state p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 15px;
}

.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

.quick-actions span {
  padding: 9px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: #dbe8f6;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

@media (max-width: 1080px) {
  .hero,
  .auth-layout,
  .desktop-shell,
  .shell-body {
    grid-template-columns: 1fr;
  }

  .desktop-shell {
    height: auto;
    min-height: 0;
  }

  .shell-main,
  .shell-body,
  .chat-list-panel,
  .chat-stage,
  .chat-workspace {
    min-height: 0;
  }
}

@media (max-width: 680px) {
  .shell {
    padding: 14px 14px 20px;
  }

  .hero,
  .auth-card {
    padding: 22px;
    border-radius: 24px;
  }

  .hero h1 {
    font-size: 34px;
  }

  .actions,
  .status-stack,
  .code-panel,
  .topbar-actions,
  .composer {
    flex-direction: column;
    align-items: stretch;
  }

  .code-panel {
    align-items: flex-start;
  }

  .shell-sidebar {
    display: none;
  }
}
