:root {
  --bg: #0a0a0b;
  --bg-elevated: #121214;
  --bg-hover: #1a1a1d;
  --border: #27272a;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --accent: #a78bfa;
  --accent-hover: #c4b5fd;
  --danger: #f87171;
  --success: #34d399;
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

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

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
}

/* ===== Shared card screens (connect + auth) ===== */
#connect-screen,
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(167, 139, 250, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(52, 211, 153, 0.05) 0%, transparent 50%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo svg {
  color: var(--accent);
}

.logo h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.tagline {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.tagline .accent {
  color: var(--accent);
  font-weight: 500;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
}

.tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.tab.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.auth-form .field {
  margin-bottom: 16px;
}

.auth-form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.auth-form input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

.auth-form input:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn.primary {
  background: var(--accent);
  color: #0a0a0b;
  width: 100%;
  margin-top: 8px;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 16px;
  text-align: center;
}

.status-text {
  color: var(--success);
  font-size: 13px;
  margin-top: 16px;
  text-align: center;
}

.link-btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  transition: color 0.15s;
}

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

/* ===== Main ===== */
#main-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

.topbar-left svg {
  color: var(--accent);
}

.brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.3px;
}

.server-badge {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 3px 8px;
  border-radius: 6px;
  margin-left: 4px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  font-size: 14px;
  color: var(--text-muted);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  transition: all 0.15s;
}

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

.layout {
  display: flex;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

.sidebar {
  width: 220px;
  padding: 24px 16px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  transition: background 0.15s;
}

.nav-item:hover,
.nav-item.active {
  background: var(--bg-hover);
}

.nav-item svg {
  color: var(--accent);
}

.feed {
  flex: 1;
  max-width: 600px;
  border-right: 1px solid var(--border);
}

.compose {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.compose-header {
  display: flex;
  gap: 14px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #0a0a0b;
  flex-shrink: 0;
}

.compose textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 17px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.5;
  min-height: 80px;
}

.compose textarea::placeholder {
  color: var(--text-muted);
}

.compose-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 12px;
  padding-left: 56px;
}

#char-count {
  font-size: 13px;
  color: var(--text-muted);
}

#post-btn {
  width: auto;
  padding: 10px 22px;
  margin: 0;
}

/* Posts */
.posts {
  display: flex;
  flex-direction: column;
}

.post {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  animation: fadeIn 0.25s ease;
}

.post:hover {
  background: var(--bg-hover);
}

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

.post-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.post-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a78bfa, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #0a0a0b;
  flex-shrink: 0;
}

.post-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.post-name {
  font-weight: 600;
  font-size: 15px;
}

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

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

.post-content {
  font-size: 15.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  margin-left: 52px;
  margin-bottom: 12px;
}

.post-actions {
  display: flex;
  gap: 8px;
  margin-left: 52px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
}

.action-btn:hover {
  background: rgba(167, 139, 250, 0.12);
  color: var(--accent);
}

.action-btn.liked {
  color: var(--accent);
}

.action-btn svg {
  width: 18px;
  height: 18px;
}

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

.empty svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .feed { border-right: none; max-width: 100%; }
  .topbar { padding: 0 16px; }
  .compose, .post { padding-left: 16px; padding-right: 16px; }
  .post-content, .post-actions, .compose-footer { margin-left: 0; }
  .compose-header { flex-direction: column; }
  .compose-footer { padding-left: 0; }
  .server-badge { display: none; }
}
