:root {
  --bg: #0a0a0a;
  --surface: #1a1a2e;
  --surface2: #16213e;
  --accent: #e94560;
  --accent2: #0f3460;
  --text: #eee;
  --text2: #aaa;
  --green: #4ecca3;
  --border: #2a2a4a;
  --toast-success: #4ecca3;
  --toast-error: #e94560;
  --toast-info: #4ecca3;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ─── Auth page ─── */

.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  font-size: 1.8rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.auth-card h1 span { color: var(--accent); }

.auth-card p.subtitle {
  text-align: center;
  color: var(--text2);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text2);
  margin-bottom: 0.3rem;
}

.form-group input {
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

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

.auth-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.btn {
  padding: 0.7rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
  flex: 1;
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.auth-error {
  color: var(--accent);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  min-height: 1.2rem;
}

/* ─── Header ─── */

header {
  background: linear-gradient(135deg, var(--surface), var(--surface2));
  padding: 0.8rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}

header h1 { font-size: 1.3rem; font-weight: 700; cursor: pointer; }
header h1 span { color: var(--accent); }

.header-right {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-left: auto;
}

.notification-bell {
  position: relative;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.3rem;
  transition: color 0.2s;
}

.notification-bell:hover { color: var(--text); }

.notification-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 1.2rem;
}

.display-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.btn-logout {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

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

/* ─── Layout ─── */

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1rem;
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.panel-header {
  padding: 0.8rem 1.2rem;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-header .right { margin-left: auto; }

/* ─── Create post ─── */

.create-post {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.create-post textarea {
  width: 100%;
  padding: 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  outline: none;
  margin-bottom: 0.5rem;
  transition: border-color 0.2s;
}

.create-post textarea:focus { border-color: var(--accent); }

.create-post-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.create-post select, .create-post button {
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}

.create-post button {
  background: var(--accent);
  border-color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  margin-left: auto;
}

.create-post button:hover { opacity: 0.85; }

/* Image input area */

.image-input-area { margin-bottom: 0.5rem; }

.image-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.file-upload-btn {
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text2);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.file-upload-btn:hover { border-color: var(--accent); color: var(--text); }

.image-input-row input[type="text"] {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  outline: none;
}

.image-input-row input[type="text"]:focus { border-color: var(--accent); }

.image-preview {
  position: relative;
  margin-top: 0.5rem;
  display: inline-block;
}

.image-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.image-preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.7);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Post image */

.post-image {
  margin-bottom: 0.7rem;
}

.post-image img {
  max-width: 100%;
  max-height: 500px;
  border-radius: 8px;
  object-fit: contain;
}

/* ─── Feed ─── */

.feed { max-height: 75vh; overflow-y: auto; }

.post-card {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.3s ease;
}

.post-card:last-child { border-bottom: none; }

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

.post-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.post-author-info {
  display: flex;
  flex-direction: column;
}

.post-author { font-weight: 600; font-size: 0.9rem; }

.post-time {
  font-size: 0.75rem;
  color: var(--text2);
}

.post-badges {
  display: flex;
  gap: 0.3rem;
  margin-left: auto;
  align-items: center;
}

.badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 1rem;
}

.badge-vis {
  background: var(--accent2);
  color: var(--text2);
}

.badge-vis.Public { background: #1a3a2a; color: var(--green); }
.badge-vis.Private { background: #3a1a1a; color: var(--accent); }

.badge-edited {
  background: #2a2a3a;
  color: var(--text2);
}

.post-content {
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 0.7rem;
  padding: 0.6rem;
  background: var(--bg);
  border-radius: 8px;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.4;
}

.post-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.post-actions button {
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
}

.post-actions button:hover { border-color: var(--accent); color: var(--text); }
.post-actions button.liked { color: var(--accent); border-color: var(--accent); }

.post-actions .like-count { font-size: 0.8rem; color: var(--text2); }

.post-actions select {
  padding: 0.3rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
}

.owner-actions {
  display: flex;
  gap: 0.3rem;
  margin-left: auto;
  align-items: center;
}

.owner-actions button { color: var(--text2); border-color: transparent; }
.owner-actions button:hover { color: var(--accent); }

/* ─── Comments ─── */

.comments-section { margin-top: 0.5rem; }

.comment-item {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.3rem 0;
  font-size: 0.8rem;
}

.comment-item .avatar { flex-shrink: 0; }
.comment-item .comment-body { color: var(--text2); line-height: 1.3; }
.comment-item .comment-body b { color: var(--text); }
.comment-item .comment-time { color: var(--text2); font-size: 0.7rem; white-space: nowrap; }
.comment-item .comment-delete {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 0 0.2rem;
}
.comment-item:hover .comment-delete { opacity: 1; }
.comment-item .comment-delete:hover { color: var(--accent); }

.comment-input {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.comment-input input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  outline: none;
}

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

.comment-input button {
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
}

/* ─── Edit post inline ─── */

.edit-post-inline textarea {
  width: 100%;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  min-height: 50px;
  outline: none;
  margin-bottom: 0.4rem;
}

.edit-post-inline .edit-btns {
  display: flex;
  gap: 0.3rem;
}

/* ─── Sidebar ─── */

.sidebar { display: flex; flex-direction: column; gap: 1rem; }

.profile-card {
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}

.profile-card .display-name { font-size: 1rem; }
.profile-card .username { color: var(--text2); font-size: 0.85rem; }
.profile-card .bio { color: var(--text2); font-size: 0.85rem; margin-top: 0.3rem; }

.profile-card .btn-edit-profile {
  margin-top: 0.5rem;
  padding: 0.3rem 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.8rem;
}

.profile-card .btn-edit-profile:hover { border-color: var(--accent); color: var(--text); }

/* Search */

.search-box {
  padding: 0.8rem 1rem;
}

.search-box input {
  width: 100%;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}

.search-box input:focus { border-color: var(--accent); }

.search-results { padding: 0 1rem 1rem; }

/* Sections */

.pod-section { padding: 0.8rem 1rem; }
.pod-section h3 { font-size: 0.8rem; color: var(--text2); margin-bottom: 0.4rem; }

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
}

.user-row .name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
}

.user-row button {
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.78rem;
  transition: all 0.15s;
}

.user-row button:hover { border-color: var(--accent); color: var(--text); }
.user-row button.following { color: var(--green); border-color: var(--green); }

.badge.pending { background: #3a2a1a; color: #e9a560; }
.badge.granted { background: #1a3a2a; color: var(--green); }

.invariants {
  padding: 0.35rem 0.7rem;
  border-radius: 1rem;
  font-size: 0.7rem;
  font-weight: 600;
}

.invariants.ok { background: #1a3a2a; color: var(--green); }
.invariants.fail { background: #3a1a1a; color: var(--accent); }

.empty-state {
  color: var(--text2);
  font-size: 0.85rem;
  padding: 1rem 1.2rem;
  text-align: center;
}

/* ─── Notifications dropdown ─── */

.notif-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 100;
  display: none;
}

.notif-dropdown.open { display: block; }

.notif-header {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
}

.notif-header button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.78rem;
}

.notif-item {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text2);
  cursor: pointer;
  transition: background 0.15s;
}

.notif-item:hover { background: var(--bg); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { color: var(--text); background: rgba(233, 69, 96, 0.05); }
.notif-item .notif-time { font-size: 0.7rem; color: var(--text2); margin-top: 0.2rem; }

/* ─── Toast ─── */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
}

.toast {
  padding: 0.7rem 1.2rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  max-width: 350px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.toast.success { background: var(--green); color: #0a0a0a; }
.toast.error { background: var(--accent); }
.toast.info { background: var(--accent2); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(10px); }
}

/* ─── Edit profile modal ─── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
}

.modal h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.modal .form-group { margin-bottom: 0.8rem; }

.modal-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: flex-end;
}
