:root {
  --bg: #000000;
  --surface: #1C1C1E;
  --surface-hover: #2C2C2E;
  --border: #2C2C2E;
  --separator: #38383A;
  --fg: #FFFFFF;
  --muted: #8E8E93;
  --tertiary: #636366;
  --accent: #0A84FF;
  --accent-hover: #0070E0;
  --accent-success: #30D158;
  --accent-error: #FF453A;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
  --space-3xl: 32px;
  --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
}

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

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

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-hover); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
  font-family: var(--font-display);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--fg); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--fg); }
.btn-danger { background: var(--accent-error); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: var(--space-sm) var(--space-md); font-size: 0.8125rem; min-height: 36px; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  border: 1px solid var(--border);
}

/* ===== FORMS ===== */
input, textarea, select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md) var(--space-lg);
  color: var(--fg);
  font-size: 0.9375rem;
  font-family: var(--font-display);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--tertiary); }
textarea { min-height: 100px; resize: vertical; }

.form-group { margin-bottom: var(--space-lg); }
.form-group label {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: var(--space-xs);
  font-weight: 500;
}

/* ===== TOP NAV ===== */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 100;
}
.top-nav .logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.top-nav .logo em { font-style: normal; color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: var(--space-lg); }
.nav-links a {
  font-size: 0.9375rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
  font-weight: 500;
}
.nav-links a:hover, .nav-links a.active { color: var(--fg); }

.search-bar input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: var(--space-sm) var(--space-lg);
  color: var(--fg);
  font-size: 0.875rem;
  outline: none;
  width: 200px;
  transition: border-color 0.15s;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar input::placeholder { color: var(--tertiary); }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 9999;
  padding: var(--space-sm) 0;
  padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
}
.bottom-nav ul { display: flex; justify-content: space-around; list-style: none; }
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 500;
  padding: var(--space-xs) var(--space-sm);
  transition: color 0.15s;
}
.bottom-nav a:hover, .bottom-nav a.active { color: var(--accent); }
.bottom-nav svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.5; }

/* ===== GLASS CONTAINER ===== */
.glass-container {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 80px;
}

/* ===== FEED POSTS ===== */
.post {
  background: var(--surface);
  border-radius: var(--radius-lg);
  margin: var(--space-md);
  padding: var(--space-lg);
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}
.post:hover { border-color: var(--separator); }
.post-header { display: flex; align-items: center; gap: var(--space-md); margin-bottom: var(--space-md); }
.post-author { font-weight: 600; font-size: 0.9375rem; }
.post-time { font-size: 0.8125rem; color: var(--muted); }
.post-content { font-size: 0.9375rem; line-height: 1.6; margin-bottom: var(--space-md); white-space: pre-wrap; word-break: break-word; }
.post-media { border-radius: var(--radius); overflow: hidden; margin-bottom: var(--space-md); max-height: 400px; }
.post-media img { width: 100%; height: auto; max-height: 400px; object-fit: contain; display: block; background: #000; }
.post-media video { width: 100%; height: auto; max-height: 400px; display: block; border-radius: var(--radius); background: #000; }
.post-actions { display: flex; gap: var(--space-lg); }
.post-actions button {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8125rem;
  cursor: pointer;
  padding: var(--space-xs) 0;
  transition: color 0.15s;
  font-family: var(--font-display);
}
.post-actions button:hover { color: var(--fg); }
.post-actions button.liked { color: var(--accent-error); }
.post-actions svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.post-actions button.liked svg { fill: currentColor; }

/* ===== AVATAR ===== */
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4DABF7, #9775FA);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  font-size: 1.125rem;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: 0.875rem; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.25rem; }
.avatar-xl { width: 80px; height: 80px; font-size: 1.75rem; }

.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
}
.verified-badge svg { width: 12px; height: 12px; stroke: #fff; fill: none; stroke-width: 2; }

/* ===== PROFILE ===== */
.profile-header { padding: var(--space-xl) var(--space-lg); }
.profile-info { display: flex; gap: var(--space-xl); align-items: flex-start; }
.profile-details { flex: 1; }
.profile-name { font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; }
.profile-username { font-size: 0.875rem; color: var(--muted); margin-top: 2px; }
.profile-bio { font-size: 0.875rem; margin-top: var(--space-sm); line-height: 1.4; }
.profile-stats { display: flex; gap: var(--space-2xl); margin-top: var(--space-lg); }
.stat { text-align: center; }
.stat-number { font-size: 1.125rem; font-weight: 700; }
.stat-label { font-size: 0.8125rem; color: var(--muted); }
.profile-actions { margin-top: var(--space-lg); display: flex; gap: var(--space-md); }
.profile-actions .btn { flex: 1; }

.profile-tabs { display: flex; border-bottom: 1px solid var(--border); margin-top: var(--space-lg); }
.profile-tab {
  flex: 1;
  text-align: center;
  padding: var(--space-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.profile-tab:hover { color: var(--fg); }
.profile-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== CLIPS ===== */
.clips-viewport { height: calc(100vh - 60px); overflow-y: auto; scroll-snap-type: y mandatory; }
.clip { height: calc(100vh - 60px); scroll-snap-align: start; display: flex; align-items: center; justify-content: center; position: relative; background: #000; }
.clip-media { width: min(360px, 80vw); aspect-ratio: 9/16; max-height: calc(100vh - 100px); border-radius: var(--radius-lg); overflow: hidden; }
.clip-media video, .clip-media img { width: 100%; height: 100%; object-fit: cover; }
.clip-actions { position: absolute; right: 12px; bottom: 100px; display: flex; flex-direction: column; gap: var(--space-xl); align-items: center; }
.clip-actions button { display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: none; color: #fff; cursor: pointer; }
.clip-actions svg { width: 32px; height: 32px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.clip-actions .liked svg { fill: var(--accent-error); stroke: var(--accent-error); color: var(--accent-error); }
.clip-footer { position: absolute; bottom: 80px; left: 16px; right: 80px; color: #fff; }
.clip-username { font-weight: 700; font-size: 1rem; }
.clip-caption { font-size: 0.875rem; margin-top: 4px; opacity: 0.9; }

/* ===== MESSENGER ===== */
.messenger-layout { display: flex; flex-direction: column; height: calc(100vh - 140px); }
.conversation-list { flex: 1; overflow-y: auto; }
.conversation-item { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--separator); cursor: pointer; transition: background 0.15s; }
.conversation-item:hover { background: var(--surface); }
.conversation-info { flex: 1; }
.conversation-name { font-weight: 600; font-size: 0.9375rem; }
.conversation-preview { font-size: 0.8125rem; color: var(--muted); margin-top: 2px; }
.conversation-time { font-size: 0.75rem; color: var(--muted); margin-left: var(--space-sm); }

.chat-area { display: flex; flex-direction: column; height: 100%; }
.chat-messages { flex: 1; overflow-y: auto; padding: var(--space-md); display: flex; flex-direction: column; gap: var(--space-sm); }
.message { max-width: 75%; padding: var(--space-md) var(--space-lg); border-radius: var(--radius-xl); font-size: 0.9375rem; line-height: 1.4; }
.message.sent { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.message.received { align-self: flex-start; background: var(--surface); color: var(--fg); border-bottom-left-radius: 4px; }
.chat-input { display: flex; gap: var(--space-md); padding: var(--space-md); border-top: 1px solid var(--border); }
.chat-input input { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: var(--space-md) var(--space-lg); color: var(--fg); font-size: 0.875rem; outline: none; }
.chat-input input:focus { border-color: var(--accent); }

/* ===== NOTIFICATIONS ===== */
.notif-item { display: flex; align-items: flex-start; gap: var(--space-md); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--separator); }
.notif-item.unread { background: var(--surface); }
.notif-content { flex: 1; }
.notif-text { font-size: 0.875rem; line-height: 1.4; }
.notif-time { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }

/* ===== SEARCH / FRIENDS ===== */
.friends-search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: var(--space-md) var(--space-lg);
  color: var(--fg);
  font-size: 0.875rem;
  outline: none;
}
.friends-search input:focus { border-color: var(--accent); }

.user-item { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--separator); cursor: pointer; transition: background 0.15s; }
.user-item:hover { background: var(--surface); }
.user-info { flex: 1; }
.user-name { font-weight: 600; font-size: 0.9375rem; }
.user-handle { font-size: 0.8125rem; color: var(--muted); }

/* ===== SETTINGS ===== */
.settings-item { display: flex; align-items: center; justify-content: space-between; padding: var(--space-lg); border-bottom: 1px solid var(--separator); cursor: pointer; transition: background 0.15s; }
.settings-item:hover { background: var(--surface); }
.settings-label { font-size: 0.9375rem; }

/* ===== AUTH ===== */
.auth-page { display: flex; min-height: 100vh; }
.auth-left { flex: 1; display: flex; align-items: center; justify-content: center; padding: var(--space-xl); }
.auth-form { width: 100%; max-width: 400px; }
.auth-form h1 { font-size: 1.75rem; margin-bottom: var(--space-sm); }
.auth-form .subtitle { color: var(--muted); margin-bottom: var(--space-xl); }
.auth-right { width: 480px; background: var(--surface); display: none; align-items: center; justify-content: center; }
.auth-right .logo-big { font-size: 3rem; font-weight: 700; color: var(--fg); }
.auth-right .logo-big em { font-style: normal; color: var(--accent); }
.auth-form .divider { display: flex; align-items: center; gap: var(--space-md); margin: var(--space-xl) 0; color: var(--tertiary); font-size: 0.8125rem; }
.auth-form .divider::before, .auth-form .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ===== CREDIT FOOTER ===== */
.credit-footer { border-top: 1px solid var(--border); padding: var(--space-lg); text-align: center; font-size: 0.75rem; color: var(--muted); line-height: 1.8; }
.credit-footer a { color: var(--accent); }
.credit-footer strong { color: var(--fg); }

/* ===== PAGE HEADER ===== */
.page-header { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--border); position: sticky; top: 57px; z-index: 50; background: var(--bg); }
.page-header h2 { font-size: 1.125rem; font-weight: 600; }

.back-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: var(--space-xs); display: flex; align-items: center; }
.back-btn:hover { color: var(--fg); }
.back-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.5; }

/* ===== EMPTY STATE ===== */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-3xl) var(--space-lg); text-align: center; color: var(--tertiary); }
.empty-state h3 { font-size: 1rem; color: var(--muted); margin-top: var(--space-md); }
.empty-state p { font-size: 0.875rem; margin-top: var(--space-xs); }

/* ===== NOTIF DOT ===== */
.notif-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; }
.notif-link { position: relative; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.glass-container { animation: fadeIn 0.3s ease-out; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== COMMENT SHEET ===== */
.comment-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 9998; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.comment-overlay.active { opacity: 1; pointer-events: auto; }
.comment-sheet { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0; z-index: 9999; transform: translateY(100%); transition: transform 0.3s ease-out; max-height: 70vh; display: flex; flex-direction: column; }
.comment-sheet.active { transform: translateY(0); }
.comment-sheet-header { display: flex; justify-content: space-between; align-items: center; padding: var(--space-lg); border-bottom: 1px solid var(--border); }
#comment-list { flex: 1; overflow-y: auto; padding: var(--space-md); }
.comment-input-row { display: flex; gap: var(--space-md); padding: var(--space-md); border-top: 1px solid var(--border); }
.comment-input-row input { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: var(--space-md) var(--space-lg); color: var(--fg); font-size: 0.875rem; outline: none; }
.comment-input-row input:focus { border-color: var(--accent); }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .top-nav .nav-links { display: none; }
  .top-nav .search-bar { display: none; }
  .bottom-nav { display: block !important; }
  .glass-container { max-width: 100%; }
  .auth-right { display: none; }
  .profile-info { flex-direction: column; align-items: center; text-align: center; }
  .profile-stats { justify-content: center; }
  .profile-actions { flex-direction: column; }
  .hero h1 { font-size: 2.25rem; }
}
@media (min-width: 768px) { .auth-right { display: flex; } }
