:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface-hover: #1a1a26;
  --border: #1e1e2e;
  --text: #e4e4ef;
  --text-dim: #6b6b80;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --code-bg: #1e1b3a;
  --danger: #e74c3c;
  --success: #2ecc71;
  --warning: #f39c12;
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Header ─────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-left h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.3s;
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

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

.status-text {
  font-size: 12px;
  color: var(--text-dim);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-count {
  font-size: 13px;
  color: var(--text-dim);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  background: var(--surface-hover);
}

.btn-ghost {
  border: none;
  padding: 6px 10px;
  font-size: 16px;
}

.btn-danger {
  color: var(--danger);
  border-color: rgba(231, 76, 60, 0.3);
}

.btn-danger:hover {
  background: rgba(231, 76, 60, 0.1);
}

/* ── Empty state ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 15px;
  margin-bottom: 4px;
}

.empty-hint {
  font-size: 13px !important;
  color: var(--text-dim);
  opacity: 0.6;
}

/* ── Message list ───────────────────────────────────────── */
.message-list {
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Message card ───────────────────────────────────────── */
.msg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all 0.2s;
  animation: slideIn 0.3s ease-out;
}

.msg-card:hover {
  border-color: rgba(108, 92, 231, 0.3);
}

.msg-card.new {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(108, 92, 231, 0.08);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.msg-from {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-time {
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.7;
}

.msg-device {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface-hover);
  padding: 2px 8px;
  border-radius: 4px;
}

.msg-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Code highlight ─────────────────────────────────────── */
.code-section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(108, 92, 231, 0.2);
}

.code-label {
  font-size: 12px;
  color: var(--accent-light);
  font-weight: 500;
  white-space: nowrap;
}

.code-value {
  font-size: 28px;
  font-weight: 700;
  font-family: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
  color: #fff;
  letter-spacing: 4px;
  flex: 1;
}

.code-copy {
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.code-copy:hover {
  background: var(--accent-light);
}

.code-copy.copied {
  background: var(--success);
}

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface);
  color: var(--text);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  transition: transform 0.3s ease;
  z-index: 100;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ── Confirm dialog ─────────────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.confirm-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: 90%;
}

.confirm-dialog h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.confirm-dialog p {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .app { padding: 0 12px; }
  .header { flex-wrap: wrap; gap: 8px; }
  .header-left h1 { font-size: 16px; }
  .code-value { font-size: 22px; letter-spacing: 2px; }
}
