:root {
  --bg: #0e0f13;
  --bg-elevated: #171a21;
  --bg-elevated-2: #1e222c;
  --border: #272c38;
  --border-strong: #333a49;
  --text: #e8eaf0;
  --text-dim: #9aa2b1;
  --text-faint: #6b7280;
  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --accent-glow: rgba(139, 92, 246, 0.35);
  --good: #34d399;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  --maxw: 1180px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(139, 92, 246, 0.14), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(236, 72, 153, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button, input { font-family: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(14, 15, 19, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 26px;
  filter: drop-shadow(0 0 10px var(--accent-glow));
}
.brand-text h1 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.2px;
  background: linear-gradient(90deg, #fff, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }

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

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.user-chip .avatar { width: 26px; height: 26px; }
.user-name { font-size: 13px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.2s;
  color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 20px -8px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 26px -6px var(--accent-glow); }
.btn-ghost { background: var(--bg-elevated); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); }
.btn-block { width: 100%; margin-top: 4px; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  gap: 28px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 40px) 80px;
}

.sidebar {
  position: sticky;
  top: 84px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 108px);
  overflow: auto;
}

.panel {
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg-elevated-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.panel-title {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; font-size: 12px; color: var(--text-dim); }
.field:last-child { margin-bottom: 0; }
.field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  color: var(--text);
  font-size: 13px;
  color-scheme: dark;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* Toggle */
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 12px; }
.toggle input { display: none; }
.toggle-track {
  width: 40px; height: 22px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border-strong);
  position: relative; flex: 0 0 auto; transition: background 0.2s;
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-dim); transition: transform 0.2s, background 0.2s;
}
.toggle input:checked + .toggle-track { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); background: #fff; }
.toggle-label { font-size: 12.5px; color: var(--text); }

.relay-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.relay-list li {
  font-size: 12px; color: var(--text-dim);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 10px;
  display: flex; align-items: center; gap: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.relay-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; background: var(--text-faint); }
.relay-dot.on { background: var(--good); box-shadow: 0 0 8px var(--good); }

/* Segmented control */
.segmented { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.seg {
  flex: 1; border: none; background: transparent; color: var(--text-dim);
  font-size: 12px; font-weight: 600; padding: 7px 4px; border-radius: 6px; cursor: pointer; transition: all 0.15s;
}
.seg:hover { color: var(--text); }
.seg.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }

/* ---------- Content / feed ---------- */
.content { min-width: 0; }
.status { min-height: 20px; margin-bottom: 14px; font-size: 13px; color: var(--text-dim); }
.status.error { color: #fca5a5; }

.feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.card {
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg-elevated-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: rise 0.4s ease both;
  transition: transform 0.15s ease, border-color 0.2s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  object-fit: cover; background: var(--bg-elevated-2);
  border: 1px solid var(--border); flex: 0 0 auto;
}
.card-author { min-width: 0; }
.card-author .name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-author .handle { font-size: 12px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card-reaction {
  margin-left: auto; flex: 0 0 auto;
  font-size: 16px; line-height: 1;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 10px;
}

.card-body { padding: 4px 16px 12px; }
.card-text { font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.card-text a { color: #c4b5fd; text-decoration: none; }
.card-text a:hover { text-decoration: underline; }

.card-media {
  display: grid; gap: 4px; padding: 0 4px 4px;
  grid-template-columns: 1fr;
}
.card-media.multi { grid-template-columns: 1fr 1fr; }
.card-media img {
  width: 100%; height: 100%; max-height: 340px; object-fit: cover;
  background: var(--bg); cursor: zoom-in; display: block;
  border-radius: 8px;
}

.card-foot {
  margin-top: auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-faint);
}
.card-foot a { color: var(--text-faint); text-decoration: none; }
.card-foot a:hover { color: var(--text-dim); }

/* Loaders / markers */
.sentinel { height: 1px; }
.loader { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 28px; color: var(--text-dim); font-size: 13px; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.end-marker { text-align: center; padding: 30px; color: var(--text-faint); font-size: 13px; }

.empty {
  grid-column: 1 / -1;
  text-align: center; padding: 60px 20px; color: var(--text-dim);
}
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* Skeletons */
.skeleton { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.sk-card { height: 220px; border-radius: var(--radius); background: linear-gradient(100deg, var(--bg-elevated) 30%, var(--bg-elevated-2) 50%, var(--bg-elevated) 70%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.9);
  display: flex; align-items: center; justify-content: center;
  padding: 30px;
}
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.lightbox-close {
  position: absolute; top: 20px; right: 24px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 16px; cursor: pointer;
}

/* Responsive */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .brand-text p { display: none; }
}
