:root {
  --primary: #FF3B6F;
  --primary-dark: #E02E5C;
  --primary-glow: rgba(255, 59, 111, 0.35);
  --secondary: #00D2FF;
  --accent: #FFD700;
  --bg: #0A0A0A;
  --card: #111111;
  --elev: #171717;
  --border: rgba(255, 255, 255, 0.08);
  --text: #FFFFFF;
  --muted: #8A8A8A;
  --dim: #555;
  --ok: #4CAF50;
  --danger: #ff5252;
  --font: "Poppins", system-ui, sans-serif;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --sidebar: 232px;
  --feed-w: 420px;
}
html[data-theme="light"] {
  --bg: #f4f5f8; --card: #fff; --elev: #fff; --text: #111; --muted: #5c5c5c;
  --dim: #999; --border: rgba(0, 0, 0, 0.08);
}
html[data-theme="blue"] { --primary: #3b82f6; --primary-dark: #2563eb; --bg: #07111f; --card: #0d1828; }
html[data-theme="green"] { --primary: #22c55e; --primary-dark: #16a34a; --bg: #07140d; --card: #0d1f14; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-decoration: none; }
button, input, textarea, select { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
img { max-width: 100%; display: block; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }

.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; background: rgba(10,10,10,.96);
  border-right: 1px solid var(--border); padding: 18px 12px; display: flex;
  flex-direction: column; overflow-y: auto; z-index: 30;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.35rem; margin-bottom: 22px; padding: 0 6px; }
.sidebar .brand img { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; }
.brand-grad { background: linear-gradient(135deg, var(--primary), #FF8E53); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.nav-list { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px;
  color: var(--muted); font-weight: 500; font-size: 0.9rem;
}
.nav-item i { width: 22px; text-align: center; font-size: 1.15rem; }
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--text); }
.nav-item.active { background: rgba(255,59,111,.12); color: var(--primary); }
.nav-item .badge { margin-left: auto; background: var(--primary); color: #fff; font-size: .55rem; padding: 2px 7px; border-radius: 20px; }
.sidebar .bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; color: var(--text); }
.user-card:hover { background: rgba(255,255,255,.05); }
.user-card img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.user-card .name { font-size: .8rem; font-weight: 600; }
.user-card .handle { font-size: .65rem; color: var(--muted); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 16px; padding-top: max(8px, var(--safe-top));
  background: rgba(10,10,10,.94); border-bottom: 1px solid var(--border); z-index: 20;
}
.brand-mobile { display: none; align-items: center; gap: 8px; font-weight: 800; }
.brand-mobile img { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn { position: relative; color: var(--muted); padding: 6px 8px; font-size: 1.1rem; }
.icon-btn:hover { color: #fff; }
.icon-btn .badge {
  position: absolute; top: -2px; right: -2px; background: var(--primary); color: #fff;
  font-size: .5rem; min-width: 16px; text-align: center; border-radius: 20px; padding: 1px 5px;
}

.page-body { flex: 1; overflow: auto; position: relative; display: flex; flex-direction: column; min-height: 0; }
body.feed-page .page-body { overflow: hidden; }
.page-pad { padding: 16px 18px 96px; max-width: 1080px; margin: 0 auto; width: 100%; }

.bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  background: rgba(10,10,10,.97); border-top: 1px solid var(--border);
  justify-content: space-around; align-items: center; padding: 6px 0 max(6px, var(--safe-bottom));
}
.bottom-nav a, .bottom-nav button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted);
  font-size: 1.15rem; min-width: 52px; padding: 4px; position: relative;
}
.bottom-nav span { font-size: .5rem; font-weight: 500; }
.bottom-nav .active { color: var(--primary); }
.nav-center {
  width: 48px; height: 48px; border-radius: 50%; background: var(--primary); color: #fff !important;
  display: flex; align-items: center; justify-content: center; margin-top: -16px;
  box-shadow: 0 4px 20px var(--primary-glow); font-size: 1.4rem;
}

.btn, .btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 14px; font-weight: 600; background: linear-gradient(135deg, var(--primary), #FF6B8A);
  color: #fff; width: 100%;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px var(--primary-glow); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-ghost { background: rgba(255,255,255,.08); }
.btn-sm { padding: 6px 14px; border-radius: 20px; font-size: .7rem; width: auto; }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); width: auto; padding: 6px 14px; border-radius: 20px; font-size: .7rem; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.input, .field {
  width: 100%; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.06);
  border: 1.5px solid var(--border); outline: none;
}
.input:focus, .field:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-glow); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 20px;
  background: rgba(255,255,255,.06); border: 1px solid var(--border); font-size: .7rem; color: var(--muted); cursor: pointer;
}
.chip.active { background: rgba(255,59,111,.15); color: var(--primary); border-color: rgba(255,59,111,.3); }

.section-h { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 10px; }
.section-h h2 { font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.section-h h2 i { color: var(--primary); }
.hscroll { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { flex: 0 0 auto; scroll-snap-align: start; width: 200px; }

.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty i { font-size: 2rem; opacity: .3; display: block; margin-bottom: 8px; }
.skeleton { background: linear-gradient(90deg, #1a1a1a, #262626, #1a1a1a); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%);
  background: rgba(12,12,16,.95); border: 1px solid var(--border); padding: 12px 18px;
  border-radius: 24px; z-index: 9999; font-size: .85rem; max-width: 90%;
}
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 200; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); width: 100%; max-width: 480px; border-radius: 22px 22px 0 0; max-height: 85vh; overflow: auto; padding: 16px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

.splash {
  position: fixed; inset: 0; z-index: 10000; background: #0e0714; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; transition: opacity .4s;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash img { width: 88px; height: 88px; border-radius: 22px; }
.splash p { color: var(--muted); font-size: .8rem; letter-spacing: 1px; }

.install-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9000; display: none;
  align-items: center; gap: 10px; padding: 12px 16px max(12px, var(--safe-bottom));
  background: rgba(16,16,22,.96); border-top: 1px solid var(--border);
}
.install-banner.show { display: flex; }

.tabs { display: flex; gap: 8px; justify-content: center; padding: 8px; }
.tab { padding: 6px 16px; border-radius: 20px; color: var(--muted); font-weight: 600; font-size: .8rem; }
.tab.active { color: #fff; background: rgba(255,255,255,.08); }

.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.stat .n { font-size: 1.3rem; font-weight: 700; }
.stat .l { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.feed-wrap { flex: 1; overflow: hidden; display: flex; justify-content: center; background: #000; }
.feed { width: 100%; max-width: var(--feed-w); height: 100%; overflow-y: scroll; scroll-snap-type: y mandatory; scrollbar-width: none; }
.feed::-webkit-scrollbar { display: none; }
.post-card { height: 100%; min-height: 100%; scroll-snap-align: start; position: relative; background: #000; }
.post-card video, .post-card img.cover { width: 100%; height: 100%; object-fit: cover; }
.post-meta { position: absolute; left: 14px; bottom: 88px; z-index: 5; max-width: 70%; text-shadow: 0 1px 8px #000; }
.side-actions { position: absolute; right: 12px; bottom: 100px; z-index: 5; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.side-actions button { color: #fff; display: flex; flex-direction: column; align-items: center; font-size: 1.4rem; }
.side-actions span { font-size: .6rem; font-weight: 600; }
.side-actions .liked { color: #ff3040; }

.more-panel { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 120; display: none; }
.more-panel.open { display: block; }
.more-sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--card); border-radius: 20px 20px 0 0; padding: 16px 16px 80px; }
.more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.more-grid a { background: var(--elev); padding: 14px; border-radius: 14px; color: var(--text); display: flex; align-items: center; gap: 10px; }

.passport {
  background: linear-gradient(135deg, #1a0a14, #2a1020 40%, #0e0714);
  border: 1px solid rgba(255,59,111,.3); border-radius: 20px; padding: 20px;
}
.tick { display: inline-flex; width: 18px; height: 18px; border-radius: 50%; align-items: center; justify-content: center; font-size: .55rem; }
.tick-white { background: #fff; color: #111; }
.tick-yellow { background: #FFD700; color: #111; }
.tick-blue { background: #1DA1F2; color: #fff; }
.tick-silver { background: #C0C0C0; color: #111; }
.tick-gold { background: linear-gradient(135deg,#FFD700,#FF8E53); color: #111; }

.offline-banner { display: none; background: #3a1a00; color: #ffcc80; text-align: center; font-size: .75rem; padding: 6px; }
.offline-banner.show { display: block; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .brand-mobile { display: flex; }
  .post-meta { bottom: 78px; }
  .side-actions { bottom: 86px; }
}
@media (min-width: 769px) {
  .bottom-nav { display: none; }
  .feed-tabs-mobile { display: none !important; }
  .post-card { max-height: 780px; border-radius: 16px; margin: 8px auto; height: calc(100vh - 24px); }
}
