:root {
  --bg: #070b16;
  --card: rgba(20, 26, 45, 0.72);
  --border: rgba(255, 255, 255, 0.09);
  --text: #e9edf7;
  --muted: #93a0bd;
  --brand: #5b8cff;
  --brand-2: #8b5cf6;
  --ok: #34d399;
  --danger: #f87171;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.aurora {
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 70vh;
  background:
    radial-gradient(45% 55% at 22% 28%, rgba(91, 140, 255, 0.42), transparent 70%),
    radial-gradient(40% 50% at 78% 18%, rgba(139, 92, 246, 0.38), transparent 70%),
    radial-gradient(38% 48% at 55% 45%, rgba(56, 189, 248, 0.22), transparent 70%);
  filter: blur(28px);
  pointer-events: none;
}

.app {
  position: relative;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 20px;
}

.card {
  width: min(520px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  padding: 28px;
  animation: rise 0.35s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.hidden {
  display: none !important;
}

/* ------------------------------ 通用元素 ------------------------------ */

.brand {
  text-align: center;
  margin-bottom: 24px;
}

.logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  font-size: 26px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.35), rgba(139, 92, 246, 0.35));
  border: 1px solid var(--border);
}

h1 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: 1px;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type='text'],
textarea {
  width: 100%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
  resize: none;
  line-height: 1.5;
}

input[type='text']:focus,
textarea:focus {
  border-color: rgba(91, 140, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.16);
}

.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  transition: transform 0.12s, background 0.2s, opacity 0.2s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.09);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  font-weight: 600;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
}

.btn.danger {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

.btn.block {
  display: block;
  width: 100%;
}

.btn.small {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 10px;
}

.split {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin: 18px 0;
}

.split::before,
.split::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.features {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.features li {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  padding-left: 26px;
  position: relative;
}

.features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 0;
  color: var(--ok);
  font-size: 12px;
}

.features strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.foot {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
  color: rgba(147, 160, 189, 0.7);
}

.invite-box {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.invite-box input {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.warn {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.7;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.24);
}

.warn strong {
  color: #fcd34d;
}

/* ------------------------------ 聊天页 ------------------------------ */

.view.chat {
  width: min(720px, 100%);
  height: min(680px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-title h2 {
  margin: 0;
  font-size: 16px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.18);
  transition: background 0.25s;
}

.dot.online {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2);
}

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

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

.secure-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(52, 211, 153, 0.06);
  border-bottom: 1px solid var(--border);
}

.secure-bar .lock {
  color: var(--ok);
}

.secure-bar code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text);
  letter-spacing: 1px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
}

.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

.row.system {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 5px 12px;
  border-radius: 999px;
  max-width: 90%;
  text-align: center;
}

.row {
  display: flex;
}

.row.self {
  justify-content: flex-end;
}

.bubble {
  max-width: 78%;
  padding: 10px 13px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  word-break: break-word;
  white-space: pre-wrap;
  font-size: 14.5px;
  line-height: 1.6;
}

.row.self .bubble {
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.32), rgba(139, 92, 246, 0.28));
  border-color: rgba(91, 140, 255, 0.35);
}

.meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 11px;
  margin-bottom: 4px;
  color: rgba(255, 255, 255, 0.55);
}

.meta .who {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.placeholder {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 30px 10px;
}

.placeholder .ph-title {
  font-size: 15px;
  margin-bottom: 6px;
}

.placeholder .ph-sub {
  font-size: 12.5px;
  opacity: 0.8;
}

.typing {
  height: 18px;
  padding: 0 18px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}

.composer textarea {
  flex: 1;
  max-height: 140px;
}

.composer .btn {
  height: 44px;
}

/* ------------------------------ Toast ------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  background: rgba(20, 26, 45, 0.95);
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  z-index: 50;
  animation: rise 0.25s ease both;
}

.toast.ok {
  border-color: rgba(52, 211, 153, 0.5);
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.5);
}

/* 图片消息 */

.bubble.img-bubble {
  width: min(300px, 80%);
  padding: 8px 8px 6px;
}

.photo-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.28);
}

.photo {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  cursor: zoom-in;
}

.photo:not([src]) {
  min-height: 110px;
  visibility: hidden;
}

.photo.broken {
  min-height: 90px;
  visibility: visible;
  filter: grayscale(1);
  opacity: 0.25;
}

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.14);
}

.progress .bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width 0.18s ease, opacity 0.35s ease;
}

.progress.done .bar {
  opacity: 0;
}

.caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
}

.caption .cap-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.caption .dl {
  flex-shrink: 0;
  color: #93b4ff;
  text-decoration: none;
}

.messages.dropping {
  outline: 2px dashed rgba(91, 140, 255, 0.7);
  outline-offset: -8px;
  border-radius: 12px;
}

.btn.icon {
  height: 44px;
  padding: 10px 12px;
  font-size: 17px;
  line-height: 1;
  background: transparent;
  border-color: var(--border);
}

/* 大图预览 */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 6, 14, 0.93);
  animation: rise 0.2s ease both;
}

.lightbox img {
  max-width: 92vw;
  max-height: 84vh;
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.lb-close,
.lb-download {
  position: absolute;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  text-decoration: none;
}

.lb-close {
  top: 18px;
  right: 20px;
  width: 38px;
  height: 38px;
  font-size: 16px;
}

.lb-download {
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 18px;
}

@media (max-width: 520px) {
  .card {
    padding: 22px 18px;
  }

  .view.chat {
    height: calc(100vh - 24px);
  }

  .bubble {
    max-width: 85%;
  }

  .secure-bar {
    font-size: 11px;
  }
}
