:root {
  --bg: #000000;
  --surface: #0f0f0f;
  --surface-2: #161616;
  --surface-3: #1e1e1e;
  --border: rgba(255, 255, 255, 0.07);
  --border-2: rgba(255, 255, 255, 0.12);
  --text: #e7e9ea;
  --muted: #71767b;
  --subtle: #3e4144;
  --accent: #1d9bf0;
  --accent-dim: rgba(29, 155, 240, 0.12);
  --heart: #f91880;
  --heart-dim: rgba(249, 24, 128, 0.12);
  --share: #00ba7c;
  --share-dim: rgba(0, 186, 124, 0.12);
  --save: #1d9bf0;
  --save-dim: rgba(29, 155, 240, 0.12);
  --gold: #FFD700;
  --gold-dim: rgba(255, 215, 0, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --mono: 'DM Mono', monospace;
  --sans: 'Syne', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.shell {
  max-width: 640px;
  margin: 0 auto;
  border-left: 0.5px solid var(--border);
  border-right: 0.5px solid var(--border);
  min-height: 100vh;
}

.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 0.5px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.topnav-brand {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.04em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--share);
  animation: livepulse 1.8s ease-in-out infinite;
}

@keyframes livepulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}

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

.tabs {
  display: flex;
  border-bottom: 0.5px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 40;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
}

.tab {
  flex: 1;
  text-align: center;
  padding: 14px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: -0.01em;
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.tab.active {
  color: var(--text);
  border-color: var(--accent);
}

button {
  font-family: var(--sans);
  cursor: pointer;
  border: none;
  transition: all 0.12s;
}

button:active {
  transform: scale(0.96);
}

.btn-ghost {
  background: transparent;
  border: 0.5px solid var(--border-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 999px;
}

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

.btn-primary {
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 700;
  padding: 7px 18px;
  border-radius: 999px;
  letter-spacing: -0.01em;
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-icon {
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0.5px solid var(--border-2);
}

.btn-icon:hover {
  background: var(--surface-3);
  color: var(--text);
}

.sort-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 0.5px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.sort-bar::-webkit-scrollbar {
  display: none;
}

.sort-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  margin-right: 4px;
}

.sort-chip {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--sans);
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--muted);
  border: 0.5px solid var(--border);
  cursor: pointer;
  transition: all 0.12s;
}

.sort-chip:hover {
  color: var(--text);
  border-color: var(--border-2);
}

.sort-chip.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(29, 155, 240, 0.3);
}

.sort-dir {
  font-size: 11px;
  margin-left: 2px;
}

.feed {
  display: flex;
  flex-direction: column;
}

.post {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--border);
  transition: background 0.1s;
}

.post:hover {
  background: rgba(255, 255, 255, 0.02);
}

.post-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
}

.post-body {
  flex: 1;
  min-width: 0;
}

.post-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.post-handle {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.post-time {
  font-size: 13px;
  color: var(--muted);
}

.post-rank-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  padding: 2px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-3);
  border: 0.5px solid var(--border);
}

.post-rank-badge.rank-1 {
  color: var(--gold);
  background: var(--gold-dim);
  border-color: rgba(255, 215, 0, 0.25);
}

.post-rank-badge.rank-2 {
  color: #C0C0C0;
  background: rgba(192, 192, 192, 0.1);
  border-color: rgba(192, 192, 192, 0.25);
}

.post-rank-badge.rank-3 {
  color: #CD7F32;
  background: rgba(205, 127, 50, 0.1);
  border-color: rgba(205, 127, 50, 0.25);
}

.post-text {
  font-size: 15px;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 10px;
  word-break: break-word;
}

.score-bar-wrap {
  margin-bottom: 12px;
}

.score-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

.score-label-text {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

.score-label-val {
  font-size: 11px;
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 500;
}

.score-bar-track {
  height: 2px;
  background: var(--surface-3);
  border-radius: 1px;
}

.score-bar-fill {
  height: 100%;
  border-radius: 1px;
  background: linear-gradient(90deg, var(--accent), var(--share));
  transition: width 0.4s ease;
}

.post-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-dot.heart {
  background: var(--heart);
}

.stat-dot.share {
  background: var(--share);
}

.stat-dot.save {
  background: var(--save);
}

.stat-val {
  font-family: var(--mono);
  font-size: 12px;
}

.post-engage {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.eng-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
  background: transparent;
  border: 0.5px solid var(--border);
  color: var(--muted);
  transition: all 0.15s;
  font-family: var(--sans);
}

.eng-btn:hover {
  border-color: var(--border-2);
}

.eng-btn.like:hover {
  color: var(--heart);
  background: var(--heart-dim);
  border-color: rgba(249, 24, 128, 0.25);
}

.eng-btn.share:hover {
  color: var(--share);
  background: var(--share-dim);
  border-color: rgba(0, 186, 124, 0.25);
}

.eng-btn.save:hover {
  color: var(--save);
  background: var(--save-dim);
  border-color: rgba(29, 155, 240, 0.25);
}

.eng-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.eng-btn.like .eng-icon {
  color: var(--heart);
}

.eng-btn.share .eng-icon {
  color: var(--share);
}

.eng-btn.save .eng-icon {
  color: var(--save);
}

.eng-icon svg {
  width: 8px;
  height: 8px;
  fill: currentColor;
}

.eng-count {
  font-family: var(--mono);
  font-size: 12px;
}


.empty {
  padding: 4rem 2rem;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--subtle);
}

.empty h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.empty p {
  font-size: 14px;
  color: var(--muted);
}


.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  backdrop-filter: blur(4px);
  overflow: hidden;
}

.modal {
  background: var(--surface);
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius);
  max-height: 85vh;
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: modalIn 0.18s ease;
  display: flex;
  flex-direction: column;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-head {
  padding: 16px 20px;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field textarea,
.field input[type="number"],
.field input[type="text"] {
  width: 100%;
  background: var(--surface-2);
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s;
}

.field textarea:focus,
.field input[type="number"]:focus,
.field input[type="text"]:focus {
  border-color: var(--accent);
}

.field textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.grid-3 label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}


.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--sans);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
}

.hist-btn {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
  background: transparent;
  border: 0.5px solid var(--border);
  color: var(--muted);
}

.hist-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.eng-btn.history:hover {
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(167, 139, 250, 0.25);
}

.eng-btn.history .eng-icon {
  color: #a78bfa;
}

#stats-feed .post {
  border-left: 3px solid var(--accent);
}

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 2px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: #111;
  padding: 16px;
  border-radius: 12px;
}

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

.kpi-value {
  font-size: 28px;
  font-weight: 700;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.stat-card {
  background: #111;
  padding: 16px;
  border-radius: 12px;
}

.stat-title {
  font-weight: 600;
  margin-bottom: 10px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 2px 0;
}

.chart-card {
  background: #111;
  padding: 16px;
  border-radius: 12px;
  margin-top: 20px;
}

.insight-card {
  background: #111;
  padding: 16px;
  border-radius: 12px;
  margin-top: 20px;
  font-size: 14px;
}