:root {
  --bg: #f4f6fa;
  --bg-glow: rgba(37, 99, 235, 0.10);
  --card: rgba(255, 255, 255, 0.86);
  --card-solid: #ffffff;
  --text: #101828;
  --muted: #667085;
  --line: rgba(16, 24, 40, 0.09);
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: rgba(37, 99, 235, 0.10);
  --danger: #d92d20;
  --ok: #12b76a;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 32px -8px rgba(16, 24, 40, 0.14);
  --radius: 18px;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f1a;
    --bg-glow: rgba(70, 130, 255, 0.16);
    --card: rgba(19, 27, 43, 0.82);
    --card-solid: #131b2b;
    --text: #e7edf7;
    --muted: #8fa3c0;
    --line: rgba(255, 255, 255, 0.09);
    --accent: #4c8dff;
    --accent-ink: #061022;
    --accent-soft: rgba(76, 141, 255, 0.14);
    --danger: #ff6b5e;
    --ok: #32d583;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -12px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 18% -10%, var(--bg-glow), transparent 62%),
    radial-gradient(700px 420px at 92% 4%, rgba(120, 80, 255, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.locked { overflow: hidden; }

.page {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(28px, 6vw, 64px) 0 48px;
}

/* ---------- header ---------- */

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

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

.logo {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--line);
}

.logo svg { width: 24px; height: 24px; }

.brand-text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  font-family: var(--mono);
}

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.badge-live i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 18%, transparent);
  animation: pulse 2.4s ease-in-out infinite;
}

.badge-live.is-off i { background: var(--muted); box-shadow: none; animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.addr-card { padding: 22px 22px 18px; }

.addr-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.eyebrow {
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.countdown {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--accent-soft);
}

.countdown.is-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }

.addr-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.addr-line code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: clamp(17px, 3.4vw, 23px);
  font-weight: 600;
  letter-spacing: -0.2px;
}

.addr-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

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

.tip code { font-family: var(--mono); color: var(--text); }

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card-solid);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  padding: 9px 16px;
  border-radius: 11px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}

.btn.primary:hover { filter: brightness(1.06); }

.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

.btn.tiny { padding: 5px 11px; font-size: 12.5px; border-radius: 9px; }

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
  flex: none;
}

.icon-btn:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }

/* ---------- inbox ---------- */

.inbox-card { margin-top: 18px; overflow: hidden; }

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

.inbox-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.count {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 8px;
}

.inbox-tools { display: flex; align-items: center; gap: 9px; }

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

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  transition: background 0.2s ease;
}

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

.list { list-style: none; margin: 0; padding: 0; }

.item {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 15px 22px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease;
  animation: rise 0.28s ease both;
}

.item:last-child { border-bottom: 0; }
.item:hover { background: var(--accent-soft); }

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.avatar {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 650;
  color: var(--accent);
  background: var(--accent-soft);
  text-transform: uppercase;
}

.item-main { flex: 1; min-width: 0; }

.item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.from {
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.time { font-size: 11.5px; color: var(--muted); font-family: var(--mono); flex: none; }

.subject {
  margin-top: 2px;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-pill {
  flex: none;
  align-self: center;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 4px 9px;
}

.empty {
  padding: 46px 24px 52px;
  text-align: center;
  color: var(--muted);
}

.empty[hidden] { display: none; }

.empty-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--accent-soft);
}

.empty-icon svg { width: 26px; height: 26px; }

.empty p { margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--text); }
.empty span { font-size: 12.5px; }

.foot {
  margin-top: 22px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.foot b { font-weight: 600; }

/* ---------- viewer ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 12, 20, 0.46);
  backdrop-filter: blur(6px);
  animation: fade 0.18s ease both;
}

.overlay[hidden] { display: none; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.viewer {
  width: min(820px, 100%);
  max-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--card-solid);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 32px 80px -24px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: pop 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.viewer-title { min-width: 0; }

.viewer-title h3 {
  margin: 0 0 4px;
  font-size: 16.5px;
  font-weight: 650;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.viewer-title p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.viewer-head .icon-btn {
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 14px;
}

.viewer-body {
  padding: 18px 22px 22px;
  overflow: auto;
  min-height: 0;
}

.code-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: 13px;
  background: var(--accent-soft);
  border: 1px dashed color-mix(in srgb, var(--accent) 40%, transparent);
}

.code-box[hidden] { display: none; }

.code-box span { font-size: 12px; color: var(--muted); }

.code-box strong {
  font-family: var(--mono);
  font-size: 26px;
  letter-spacing: 5px;
  color: var(--accent);
  flex: 1;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  padding: 5px 11px;
  border-radius: 8px;
  cursor: pointer;
}

.tab.is-active { color: var(--text); background: var(--accent-soft); }

.tab[hidden] { display: none; }

.spacer { flex: 1; }
.v-time { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }

.text-body {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
}

.text-body[hidden] { display: none; }

.html-body {
  width: 100%;
  height: 56vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.html-body[hidden] { display: none; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  z-index: 80;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 14px 34px -12px rgba(37, 99, 235, 0.7);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  max-width: calc(100% - 40px);
}

.toast.is-visible { opacity: 1; transform: translateX(-50%); }
.toast[hidden] { display: none; }

@media (max-width: 560px) {
  .page { width: calc(100% - 24px); padding-top: 24px; }
  .addr-card, .inbox-head, .item { padding-left: 16px; padding-right: 16px; }
  .viewer-head, .viewer-body { padding-left: 16px; padding-right: 16px; }
  .addr-actions .btn { flex: 1; }
  .badge-live { display: none; }
  .code-box strong { font-size: 22px; letter-spacing: 3px; }
}
