:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #64748b;
  --line: rgba(15, 23, 42, 0.09);
  --line-strong: rgba(15, 23, 42, 0.16);
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --green: #059669;
  --green-soft: #ecfdf5;
  --gold: #b45309;
  --gold-bg: #fffbeb;
  --gold-border: rgba(217, 119, 6, 0.35);
  --amber: #d97706;
  --slate-soft: #f1f5f9;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.07);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 380px;
  background: radial-gradient(75% 100% at 15% 0%, rgba(37, 99, 235, 0.12), transparent 65%),
              radial-gradient(60% 90% at 88% 0%, rgba(217, 119, 6, 0.1), transparent 65%);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 16px 64px;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

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

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0f172a, #2563eb);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 19px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

.brand-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  display: inline-block;
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.16);
}

.live-dot.protect {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.18);
}

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

.host-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0f172a;
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.host-pill:hover {
  text-decoration: none;
  transform: translateY(-1px);
  opacity: 0.94;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn:hover:not(:disabled) {
  border-color: rgba(15, 23, 42, 0.28);
  transform: translateY(-1px);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.22);
}

.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.btn-success {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  box-shadow: 0 6px 18px rgba(5, 150, 105, 0.22);
}

.btn-success:hover:not(:disabled) {
  background: #047857;
}

.btn-dark {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}

.btn-dark:hover:not(:disabled) {
  background: #1e293b;
}

.btn-gold {
  background: linear-gradient(135deg, #d97706, #b45309);
  border-color: #b45309;
  color: #fff;
  box-shadow: 0 8px 20px rgba(217, 119, 6, 0.26);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-2);
}

.btn-danger-soft {
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.24);
  color: var(--danger);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn-lg {
  padding: 13px 20px;
  font-size: 15px;
  border-radius: 12px;
}

/* Host Profile Banner */
.host-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.host-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 320px;
}

.host-avatar-wrap {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  overflow: hidden;
  flex: 0 0 46px;
  background: linear-gradient(135deg, #0f172a, #2563eb);
  color: #fff;
  font-weight: 800;
  font-size: 19px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(37, 99, 235, 0.18);
  position: relative;
}

.host-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.host-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.host-bio {
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 2px;
}

/* Tree fixed-height scroll container */
.tree-viewport {
  overflow: auto;
  max-height: 440px;
  padding: 10px 6px 14px;
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.6);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.tree-viewport.expanded {
  max-height: none;
}

.share-preview-box {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 13px;
  color: #f1f5f9;
  white-space: pre-wrap;
  margin-top: 12px;
  line-height: 1.55;
}

.list-more-bar {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

/* Announcement banner */
.announce {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.truth-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--green-soft);
  color: var(--green);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 4px;
  line-height: 1.15;
}

.stat-foot {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 4px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  margin-bottom: 18px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-sub {
  font-size: 13px;
  color: var(--ink-3);
  margin: 2px 0 0;
}

/* Console special borders */
.console-card {
  border: 1.5px solid rgba(37, 99, 235, 0.22);
  background: linear-gradient(180deg, #ffffff 0%, #fafcff 100%);
}

.console-card.is-ready {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.12), var(--shadow-md);
}

.console-card.is-unlocked {
  border-color: var(--amber);
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.1), var(--shadow-md);
}

.console-card.is-verified {
  border-color: var(--gold-border);
  background: linear-gradient(180deg, #fffdf7 0%, #ffffff 100%);
}

/* Steps onboarding */
.steps-row {
  display: grid;
  grid-template-columns: 1fr 1.45fr;
  gap: 14px;
  margin-top: 12px;
}

.step-box {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 15px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  margin-right: 6px;
}

.input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.input, .textarea, .select {
  width: 100%;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

/* Code display box */
.code-reveal {
  background: #0f172a;
  color: #fff;
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.code-value {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fef08a;
}

.countdown-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: var(--gold-bg);
  color: var(--gold);
  border: 1px solid var(--gold-border);
}

.countdown-pill.urgent {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.3);
}

/* Seat choice radio cards */
.seat-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0 12px;
}

.seat-option {
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  padding: 11px 13px;
  cursor: pointer;
  background: #fff;
  transition: all 0.15s ease;
  display: flex;
  gap: 9px;
  align-items: flex-start;
}

.seat-option input {
  margin-top: 3px;
}

.seat-option.selected-gold {
  border-color: #d97706;
  background: #fffbeb;
}

.seat-option.selected-green {
  border-color: var(--green);
  background: var(--green-soft);
}

/* Snapshot quote card */
.snapshot-card {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-left: 3px solid #0f172a;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.snapshot-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 4px;
}

.snapshot-text {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-gold {
  background: var(--gold-bg);
  color: var(--gold);
  border: 1px solid var(--gold-border);
}

.badge-green {
  background: var(--green-soft);
  color: var(--green);
}

.badge-blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge-slate {
  background: var(--slate-soft);
  color: var(--ink-3);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Recovery pin box */
.pin-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--slate-soft);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 12px;
}

/* Binary Relay Tree */
.tree-roots {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.tree-branch {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tree-code-pill {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 8px 13px;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  width: fit-content;
  max-width: 100%;
}

.tree-code-pill > span {
  white-space: nowrap;
}

.tree-children {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  padding-left: 18px;
  border-left: 2px dashed rgba(37, 99, 235, 0.25);
  margin-left: 12px;
}

.tree-node {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.tree-node.node-gold {
  border-color: var(--gold-border);
  background: linear-gradient(180deg, #fffdf5 0%, #fff 100%);
}

.tree-node.node-green {
  border-color: rgba(5, 150, 105, 0.3);
  background: linear-gradient(180deg, #f3fdf8 0%, #fff 100%);
}

.tree-node.node-active {
  border-color: rgba(37, 99, 235, 0.35);
  background: #f8fbff;
}

.tree-node.node-pending {
  border-style: dashed;
  border-color: rgba(100, 116, 139, 0.35);
  background: #fafafa;
}

.tree-node.node-empty {
  border: 1.5px dashed rgba(5, 150, 105, 0.35);
  background: rgba(236, 253, 245, 0.45);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  font-size: 13px;
  font-weight: 600;
}

.tree-node-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.tree-sub {
  margin-top: 10px;
  padding-left: 12px;
  border-left: 2px solid rgba(217, 119, 6, 0.28);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid transparent;
  background: transparent;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-btn.active {
  background: #0f172a;
  color: #fff;
}

.tab-count {
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.14);
}

.tab-btn.active .tab-count {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

/* List items */
.grid-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.person-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.person-card.gold {
  border-color: var(--gold-border);
  background: linear-gradient(180deg, #fffdf4 0%, #fff 100%);
}

.person-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.handle-link {
  font-weight: 800;
  color: var(--ink);
  font-size: 15px;
}

/* Events feed */
.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-size: 13px;
}

/* Share Victory Card */
.victory-box {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #065f46 100%);
  color: #fff;
  border-radius: 18px;
  padding: 20px;
  margin: 12px 0;
}

.victory-box h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.victory-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  place-items: center;
  z-index: 50;
  padding: 16px;
}

.modal-backdrop.open {
  display: grid;
}

.modal {
  background: #fff;
  border-radius: 18px;
  max-width: 440px;
  width: 100%;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 60;
}

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

.empty-state {
  text-align: center;
  padding: 28px 14px;
  color: var(--ink-3);
  font-size: 14px;
  background: var(--surface-soft);
  border-radius: 14px;
  border: 1px dashed var(--line-strong);
}

.footer {
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 28px;
}

/* Tables (Admin) */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--ink-3);
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}

/* Guide Cards (3-step visual tutorial) */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.guide-step {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-thumb {
  width: 100%;
  height: 220px;
  object-fit: cover;
  object-position: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  cursor: zoom-in;
  background: #fff;
  transition: transform 0.15s ease;
}

.guide-thumb.pos-top {
  object-position: top center;
}

.guide-thumb.pos-bottom {
  object-position: bottom center;
}

.guide-thumb:hover {
  transform: scale(1.015);
}

.perk-banner {
  background: linear-gradient(90deg, #fffbeb 0%, #ecfdf5 100%);
  border: 1px solid var(--gold-border);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 13px;
  color: var(--ink);
  margin: 10px 0 12px;
}

.parsed-preview {
  font-size: 12.5px;
  color: var(--green);
  font-weight: 700;
  margin-top: 6px;
  min-height: 18px;
}

.lightbox-img {
  max-width: min(92vw, 460px);
  max-height: 82vh;
  border-radius: 14px;
  display: block;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

@media (max-width: 780px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .steps-row, .seat-choices, .guide-grid {
    grid-template-columns: 1fr;
  }
  .input-row {
    flex-direction: column;
  }
  .code-value {
    font-size: 28px;
  }
}
