:root {
  --fb-blue: #3b5bdb;
  --fb-blue-dark: #364fc7;
  --fb-green: #2f9e44;
  --bg: #eef1f6;
  --card: #fff;
  --text: #1b2430;
  --muted: #5c6672;
  --border: #dde3ec;
  --hover: #e8edf4;
  --danger: #e03131;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 18px 42px rgba(15, 23, 42, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(circle at 12% 0%, rgba(59, 91, 219, 0.12), transparent 34%),
    radial-gradient(circle at 88% 8%, rgba(47, 158, 68, 0.1), transparent 30%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
}

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

.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  height: 56px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.topnav-logo {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  color: var(--fb-blue);
  font-weight: 700;
  font-size: 1.35rem;
}

.logo-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fb-blue), #6a5acd);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.topnav-search { flex: 1; max-width: 280px; }
.topnav-search input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 999px;
  background: var(--bg);
  font: inherit;
}

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

.nav-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 1.25rem;
  text-decoration: none;
  color: inherit;
}
.nav-btn:hover { background: var(--hover); text-decoration: none; }

.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}
.health-dot.ok { background: var(--fb-green); }
.health-dot.err { background: var(--danger); }

.session-box { display: flex; align-items: center; gap: 0.5rem; }
.nav-me img { border-radius: 50%; border: 2px solid var(--border); }

.login-inline {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.login-inline input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  width: 7.5rem;
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn-fb { background: var(--fb-blue); color: #fff; }
.btn-fb:hover { background: var(--fb-blue-dark); }
.btn-block { width: 100%; }
.btn-text { background: none; border: none; color: var(--fb-blue); font-weight: 600; cursor: pointer; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: var(--hover); color: var(--text); }

.fb-layout {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 1rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem;
  align-items: start;
}

@media (max-width: 1000px) {
  .fb-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

.sidebar { position: sticky; top: 72px; }
.sidebar-link {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.sidebar-link:hover, .sidebar-link.active { background: var(--hover); text-decoration: none; }
.sidebar-title { font-size: 0.85rem; color: var(--muted); margin: 0.75rem 0 0.35rem; }
.sidebar-friends { font-size: 0.9rem; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.feed-main { min-width: 0; }

.composer { padding: 0.75rem 1rem; }
.composer-head { display: flex; gap: 0.75rem; }
.composer-head img { border-radius: 50%; }
.composer-head textarea {
  flex: 1;
  border: none;
  resize: vertical;
  font: inherit;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 0.65rem;
  min-height: 3rem;
}
.composer-emojis {
  position: relative;
  display: inline-flex;
  padding: 0.4rem 0 0.15rem 3.1rem;
}
.composer-emoji-toggle {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  height: 34px;
  padding: 0 0.85rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
}
.composer-emoji-toggle:hover { background: var(--hover); }
.emoji-picker {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 3.1rem;
  z-index: 30;
  width: min(340px, calc(100vw - 3rem));
  padding: 0.65rem;
  margin: 0;
}
.emoji-search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  font: inherit;
  margin-bottom: 0.55rem;
}
.emoji-grid {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 220px;
  overflow-y: auto;
}
.emoji-section-title {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}
.emoji-section-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.35rem;
}
.emoji-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.emoji-btn:hover { background: var(--hover); }
.emoji-empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.4rem;
}
.composer-preview { margin-top: 0.5rem; position: relative; }
.composer-preview img { max-width: 100%; border-radius: var(--radius); max-height: 280px; }
.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.composer-photo {
  color: var(--fb-green);
  font-weight: 600;
  cursor: pointer;
}

.guest-banner { padding: 1.25rem; text-align: center; }
.guest-banner h2 { margin: 0 0 0.5rem; color: var(--fb-blue); }

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

.post-card { padding: 0; overflow: hidden; }
.post-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
}
.post-header img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.post-header strong { display: block; font-size: 0.95rem; }
.post-header time { font-size: 0.8rem; color: var(--muted); }
.post-body { padding: 0 1rem 0.75rem; white-space: pre-wrap; word-break: break-word; }
.post-image { width: 100%; display: block; max-height: 480px; object-fit: cover; }
.post-stats {
  padding: 0.5rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}
.post-actions {
  display: flex;
  border-top: 1px solid var(--border);
}
.post-actions button {
  flex: 1;
  padding: 0.6rem;
  background: none;
  border: none;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.post-actions button:hover { background: var(--hover); }
.post-actions button.liked { color: var(--fb-blue); }
.post-actions .btn-delete-post { color: var(--danger); }

.post-comments { padding: 0 1rem 0.75rem; background: var(--bg); }
.comment {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.comment.pending { opacity: 0.7; }
.comment img { width: 32px; height: 32px; border-radius: 50%; }
.comment-bubble {
  background: var(--card);
  padding: 0.4rem 0.65rem;
  border-radius: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.comment-delete {
  align-self: flex-start;
  border: none;
  background: transparent;
  color: var(--danger);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}
.comment-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1rem 0.75rem;
  background: var(--bg);
}
.comment-form input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font: inherit;
}

.contacts-card { padding: 0.75rem 1rem; }
.contacts-card h3 { margin: 0 0 0.65rem; font-size: 1rem; }
.contact-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
}
.contact-row img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.contact-row button { margin-left: auto; font-size: 0.8rem; padding: 0.25rem 0.5rem; }

.view-register {
  max-width: 640px;
  margin: 1rem auto;
  padding: 0 1rem;
}
.register-card { padding: 1.5rem; }
.register-avatar-row { display: flex; gap: 1.25rem; margin-bottom: 1rem; flex-wrap: wrap; }
.avatar-lg, .avatar-xl { border-radius: 50%; object-fit: cover; border: 4px solid var(--card); background: var(--bg); }
.avatar-xl { width: 148px; height: 148px; margin-top: -72px; }

.avatar-options { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.5rem 0; }
.avatar-option {
  cursor: pointer;
  border-radius: 50%;
  border: 3px solid transparent;
  transition: 0.15s;
}
.avatar-option:has(input:checked) { border-color: var(--fb-blue); }
.avatar-option input { display: none; }
.avatar-option img { width: 44px; height: 44px; border-radius: 50%; display: block; }

.upload-label {
  display: inline-block;
  margin: 0.5rem 0;
  color: var(--fb-blue);
  font-weight: 600;
  cursor: pointer;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.field-grid label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; font-weight: 600; }
.field-hint { font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.field-grid input.invalid { border-color: var(--danger); }
.field-grid input, .field-grid textarea {
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.span-2 { grid-column: span 2; }
.field-error { color: var(--danger); font-size: 0.9rem; }
.muted { color: var(--muted); }
.center { text-align: center; }

.guest-banner { padding: 2rem; text-align: center; }
.guest-banner h2 { margin: 0 0 0.5rem; font-size: 1.5rem; }
.guest-lead { color: var(--muted); margin: 0 0 1.25rem; }
.guest-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

.view-auth {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.auth-card {
  width: min(420px, 100%);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; margin: 1.25rem 0; }
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
}
.auth-form input {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--fb-blue);
  box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.15);
}
.auth-links { text-align: center; font-size: 0.9rem; margin: 0; }
.auth-result {
  margin: 1rem 0;
  padding: 1rem;
  background: #e7f3ff;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}
.auth-result a { overflow-wrap: anywhere; }
.auth-result a { font-weight: 600; }

.view-profile { max-width: 940px; margin: 0 auto 3rem; padding: 0 1rem; }
.profile-hero {
  position: relative;
  margin-bottom: 0;
}
.profile-cover {
  height: 220px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(135deg, var(--fb-blue) 0%, #6a5acd 100%);
}
.profile-hero-inner {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 0 1.5rem 1.25rem;
  margin-top: -64px;
  position: relative;
}
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.avatar-xl {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--card);
  box-shadow: var(--shadow-md);
  background: var(--bg);
}
.avatar-upload-btn {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  color: var(--text);
}
.profile-info { flex: 1; min-width: 220px; padding-bottom: 0.25rem; }
.profile-info h1 { margin: 0; font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em; }
.profile-handle { color: var(--muted); font-size: 1rem; margin: 0.15rem 0 0.5rem; }
.profile-bio-text { margin: 0; line-height: 1.5; max-width: 520px; }
.profile-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.85rem; }

.profile-body {
  border-radius: 0 0 var(--radius) var(--radius);
  margin-top: -1px;
  padding: 0;
  overflow: hidden;
}
.profile-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 0.5rem;
  background: var(--card);
}
.profile-tab {
  padding: 0.85rem 1.25rem;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.profile-tab:hover { background: var(--hover); color: var(--text); }
.profile-tab.active {
  color: var(--fb-blue);
  border-bottom-color: var(--fb-blue);
}
.profile-tab-panel { padding: 1.25rem 1.5rem 1.5rem; }
.profile-posts-list { display: flex; flex-direction: column; gap: 0.75rem; }
.about-card h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.settings-section { margin-bottom: 2rem; }
.settings-section h3 { margin: 0 0 1rem; font-size: 1.05rem; }
.settings-fields { display: flex; flex-direction: column; gap: 1rem; margin: 1rem 0; }
.settings-fields label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
}
.settings-fields textarea,
.settings-fields input[type="text"] {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
}
.danger-zone {
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid #f5c2c7;
  background: #fff5f5;
}
.danger-zone h3 { color: var(--danger); }

.toast-root {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.75rem 1rem;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  animation: slideIn 0.25s ease;
}
.toast.error { background: var(--danger); }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

body.auth-page .topnav-search { display: none; }
body.auth-page .fb-layout { display: none; }

.site-footer {
  text-align: center;
  padding: 2rem 1rem 2.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--fb-blue); text-decoration: none; font-weight: 500; }
.site-footer a:hover { text-decoration: underline; }

[hidden] { display: none !important; }

.nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  display: grid;
  place-items: center;
}

.nav-btn, .notif-wrap button {
  position: relative;
}

.notif-wrap { position: relative; }
.notif-panel {
  position: absolute;
  right: 0;
  top: 48px;
  width: min(360px, 90vw);
  max-height: 420px;
  overflow-y: auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 60;
}
.notif-item {
  display: flex;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
}
.notif-item:hover { background: var(--hover); }
.notif-item.unread { background: #e7f3ff; }
.notif-item img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.notif-item p { margin: 0; font-size: 0.9rem; }
.notif-item time { font-size: 0.75rem; color: var(--muted); }

.shared-post {
  margin: 0.5rem 1rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}
.shared-post .post-header { padding: 0.5rem 0.75rem; }
.shared-post .post-body { padding: 0 0.75rem 0.5rem; font-size: 0.9rem; }
.shared-label {
  padding: 0.35rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.view-messages {
  max-width: 960px;
  margin: 1rem auto;
  padding: 0 1rem;
}
.messages-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 520px;
  overflow: hidden;
}
@media (max-width: 700px) {
  .messages-layout { grid-template-columns: 1fr; }
  .messages-list-panel { max-height: 200px; overflow-y: auto; }
}
.messages-list-panel {
  border-right: 1px solid var(--border);
  padding: 1rem;
}
.messages-list-panel h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.conv-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.conv-row:hover, .conv-row.active { background: var(--hover); }
.conv-row img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.conv-row .conv-meta { flex: 1; min-width: 0; }
.conv-row .conv-meta strong { display: block; font-size: 0.9rem; }
.conv-row .conv-preview { font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-unread {
  background: var(--fb-blue);
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 999px;
}

.messages-thread-panel {
  display: flex;
  flex-direction: column;
  padding: 1rem;
}
.thread-header { font-weight: 600; margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.thread-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 320px;
  max-height: 420px;
  padding: 0.5rem 0;
}
.thread-status {
  min-height: 1rem;
  font-size: 0.8rem;
  text-align: right;
  padding: 0 0.25rem;
}
.bubble {
  max-width: 75%;
  padding: 0.55rem 0.85rem;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.4;
}
.bubble.mine {
  align-self: flex-end;
  background: var(--fb-blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble.theirs {
  align-self: flex-start;
  background: var(--hover);
  border-bottom-left-radius: 4px;
}
.thread-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.thread-form input { flex: 1; padding: 0.55rem 0.85rem; border: 1px solid var(--border); border-radius: 999px; font: inherit; }
