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

:root {
  --bg: #000000;
  --surface: #16181c;
  --surface-2: #1d1f23;
  --surface-3: #2f3336;
  --border: #2f3336;
  --border-hover: #404348;
  --text: #e7e9ea;
  --text-2: #71767b;
  --text-3: #536471;
  --green: #00ba7c;
  --red: #f4212e;
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --accent-bg: rgba(29,155,240,0.1);
  --accent-border: rgba(29,155,240,0.2);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { scroll-behavior: auto; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }

/* ===== TOPBAR ===== */
.topbar { position: sticky; top: 0; z-index: 100; display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 20px; background: rgba(0,0,0,0.75); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); }
.topbar-left { display: flex; align-items: center; gap: 16px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-text { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.5px; }
.topbar-search { flex: 0 1 420px; margin: 0 24px; }
.topbar-btn { padding: 7px 16px; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 600; background: var(--accent); color: #fff; border: none; transition: background 0.15s; }
.topbar-btn:hover { background: var(--accent-hover); }
.topbar-btn.outline { background: transparent; border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.topbar-btn.outline:hover { background: var(--surface); }
.topbar-btn.sm { padding: 5px 12px; font-size: 0.75rem; }

/* ===== BUTTONS ===== */
.btn-primary { padding: 9px 20px; border-radius: var(--radius-sm); border: none; background: var(--accent); color: #fff; font-size: 0.85rem; font-weight: 600; transition: background 0.15s; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary.sm { padding: 5px 14px; font-size: 0.78rem; }

/* ===== FEED LAYOUT ===== */
.main { flex: 1; padding: 0 0 60px; }
.feed-layout { display: grid; grid-template-columns: 240px 1fr 300px; max-width: 1160px; margin: 0 auto; min-height: calc(100vh - 56px); }
.feed-sidebar { padding: 12px 12px 12px 16px; border-right: 1px solid var(--border); position: sticky; top: 56px; height: fit-content; }
.feed-main { min-width: 0; border-right: 1px solid var(--border); }
.feed-right { padding: 12px 16px; position: sticky; top: 56px; height: fit-content; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
.sidebar-link { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 1rem; font-weight: 500; color: var(--text-2); transition: all 0.12s; }
.sidebar-link:hover { color: var(--text); background: var(--surface); }
.sidebar-link.active { color: var(--text); font-weight: 700; background: var(--surface); }

.sidebar-user { padding-top: 16px; border-top: 1px solid var(--border); }
.sidebar-user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sidebar-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; color: var(--text-2); overflow: hidden; flex-shrink: 0; }
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-name { font-size: 0.85rem; font-weight: 700; }
.sidebar-handle { font-size: 0.75rem; color: var(--text-3); }

/* ===== FEED TABS ===== */
.feed-tabs { display: flex; border-bottom: 1px solid var(--border); }
.feed-tab { flex: 1; padding: 14px; text-align: center; font-size: 0.85rem; font-weight: 500; color: var(--text-2); border: none; background: none; transition: all 0.12s; position: relative; }
.feed-tab:hover { color: var(--text); background: var(--surface); }
.feed-tab.active { color: var(--text); font-weight: 700; }
.feed-tab.active::after { content: ''; position: absolute; bottom: 0; left: 25%; right: 25%; height: 3px; background: var(--accent); border-radius: 2px 2px 0 0; }

/* ===== COMPOSE ===== */
.compose { display: flex; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); }
.compose-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem; color: var(--text-2); flex-shrink: 0; overflow: hidden; }
.compose-avatar img { width: 100%; height: 100%; object-fit: cover; }
.compose-body { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.compose-body textarea { width: 100%; background: none; border: none; outline: none; color: var(--text); font-size: 1rem; font-family: var(--font); resize: none; min-height: 48px; }
.compose-body textarea::placeholder { color: var(--text-3); }
.compose-gif-preview { position: relative; display: inline-block; }
.compose-gif-preview img { max-width: 200px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.gif-remove { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(0,0,0,0.75); color: #fff; font-size: 0.8rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.compose-bar { display: flex; align-items: center; justify-content: space-between; }
.compose-tools { display: flex; align-items: center; gap: 4px; }
.compose-tool { width: 32px; height: 32px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--accent); cursor: pointer; transition: background 0.12s; background: none; border: none; }
.compose-tool:hover { background: var(--accent-bg); }
.compose-char-count { font-size: 0.75rem; color: var(--text-3); }

/* GIF Search */
.gif-search-box { border-top: 1px solid var(--border); padding-top: 10px; }
.gif-results { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; max-height: 200px; overflow-y: auto; margin-top: 8px; }
.gif-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; cursor: pointer; transition: opacity 0.12s; border: none; }
.gif-thumb:hover { opacity: 0.8; }

/* ===== POST CARD ===== */
.post-card { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background 0.1s; }
.post-card:hover { background: var(--surface); }
.post-left { flex-shrink: 0; }
.post-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; color: var(--text-2); overflow: hidden; }
.post-avatar img { width: 100%; height: 100%; object-fit: cover; }
.post-right { flex: 1; min-width: 0; }
.post-header { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-bottom: 2px; }
.post-name { font-size: 0.88rem; font-weight: 700; }
.post-name:hover { text-decoration: underline; }
.post-handle { font-size: 0.8rem; color: var(--text-2); }
.post-dot { color: var(--text-2); font-size: 0.8rem; }
.post-time { font-size: 0.8rem; color: var(--text-2); }
.post-content { font-size: 0.92rem; line-height: 1.45; margin-bottom: 8px; white-space: pre-wrap; word-break: break-word; }
.post-gif { margin-bottom: 8px; }
.post-gif img { max-width: 320px; max-height: 300px; border-radius: var(--radius-sm); border: 1px solid var(--border); object-fit: cover; }

/* ===== POST ACTIONS ===== */
.post-actions { display: flex; align-items: center; gap: 0; }
.post-action { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: var(--radius-sm); font-size: 0.78rem; color: var(--text-2); background: none; border: none; transition: all 0.12s; }
.post-action:hover { color: var(--text); background: var(--surface); }
.post-action.voted { color: var(--accent); }
.vote-btn[data-dir="1"]:hover, .vote-btn[data-dir="1"].voted { color: var(--green); }
.vote-btn[data-dir="-1"]:hover, .vote-btn[data-dir="-1"].voted { color: var(--red); }
.vote-count { font-weight: 600; min-width: 8px; text-align: center; }

/* ===== COMMENTS ===== */
.comments-section { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; }
.comment-compose { display: flex; gap: 8px; margin-bottom: 10px; }
.comment-compose .form-input { flex: 1; }
.comment-item { display: flex; gap: 8px; padding: 8px 0; }
.comment-avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-size: 0.65rem; font-weight: 700; color: var(--text-3); flex-shrink: 0; overflow: hidden; }
.comment-avatar img { width: 100%; height: 100%; object-fit: cover; }
.comment-body { flex: 1; }
.comment-name { font-size: 0.8rem; font-weight: 600; }
.comment-name:hover { text-decoration: underline; }
.comment-time { font-size: 0.7rem; color: var(--text-2); margin-left: 6px; }
.comment-text { font-size: 0.82rem; color: var(--text-2); line-height: 1.4; margin-top: 2px; }

/* ===== SEARCH (YouTube-style) ===== */
.search-box { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; transition: border-color 0.15s; }
.search-box:focus-within { border-color: var(--accent); }
.search-box svg { color: var(--text-2); flex-shrink: 0; margin-left: 12px; }
.search-box .form-input { border: none; background: transparent; padding: 8px 12px; font-size: 0.88rem; }
.search-box .form-input:focus { border: none; }
.search-box .search-go { padding: 7px 14px; border: none; border-left: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); cursor: pointer; transition: all 0.12s; font-size: 0.82rem; }
.search-box .search-go:hover { background: var(--surface-3); color: var(--text); }

/* ===== RIGHT SIDEBAR SEARCH ===== */
.sidebar-search { margin-bottom: 16px; }

.form-input { width: 100%; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 0.85rem; font-family: var(--font); outline: none; transition: border-color 0.15s; }
.form-input:focus { border-color: var(--accent); }
.form-input.sm { padding: 7px 12px; font-size: 0.82rem; }
textarea.form-input { resize: vertical; }

.search-result { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-radius: var(--radius-sm); transition: background 0.12s; }
.search-result:hover { background: var(--surface); }
.sr-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; color: var(--text-3); overflow: hidden; flex-shrink: 0; }
.sr-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sr-name { font-size: 0.82rem; font-weight: 700; }
.sr-handle { font-size: 0.72rem; color: var(--text-2); }

.feed-empty { text-align: center; padding: 48px; color: var(--text-2); }
.loading { text-align: center; padding: 24px; color: var(--text-2); font-size: 0.85rem; }
.empty-state { text-align: center; padding: 20px; color: var(--text-2); font-size: 0.82rem; }

/* ===== AUTH ===== */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 200px); }
.auth-card { width: 100%; max-width: 400px; padding: 32px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 28px; }
.auth-tab { flex: 1; padding: 9px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: transparent; color: var(--text-2); font-size: 0.82rem; font-weight: 600; transition: all 0.15s; }
.auth-tab.active { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-error { font-size: 0.78rem; color: var(--red); min-height: 18px; }
.hidden { display: none !important; }
.full { width: 100%; }

/* ===== DASHBOARD ===== */
.dash-layout { display: flex; gap: 24px; max-width: 1000px; margin: 0 auto; padding: 24px 20px; }
.dash-sidebar { width: 160px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 80px; align-self: flex-start; }
.dash-nav { padding: 9px 14px; border-radius: var(--radius-sm); border: none; background: transparent; color: var(--text-2); font-size: 0.85rem; font-weight: 500; text-align: left; transition: all 0.12s; }
.dash-nav:hover { color: var(--text); background: var(--surface); }
.dash-nav.active { color: var(--accent); font-weight: 600; background: var(--accent-bg); }
.dash-content { flex: 1; min-width: 0; }
.dash-section { display: none; }
.dash-section.active { display: block; }
.dash-section h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.form-hint { font-size: 0.72rem; color: var(--text-3); margin-top: 4px; display: block; }
.toggle-label { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.toggle { width: 40px; height: 22px; appearance: none; background: var(--surface-3); border-radius: 11px; position: relative; cursor: pointer; transition: background 0.2s; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-2); transition: all 0.2s; }
.toggle:checked { background: var(--accent); }
.toggle:checked::after { left: 21px; background: #fff; }

.link-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border); margin-bottom: 6px; }
.link-drag { color: var(--text-3); cursor: grab; font-size: 0.85rem; }
.link-icon-display { font-size: 1rem; }
.link-title-display { font-size: 0.85rem; font-weight: 600; flex: 1; }
.link-url-display { font-size: 0.75rem; color: var(--text-2); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-delete { width: 26px; height: 26px; border-radius: 6px; border: none; background: rgba(244,33,46,0.1); color: var(--red); font-size: 0.95rem; display: flex; align-items: center; justify-content: center; transition: background 0.12s; flex-shrink: 0; }
.link-delete:hover { background: rgba(244,33,46,0.2); }
.link-add-form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.post-compose { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.posts-list { display: flex; flex-direction: column; gap: 8px; }
.post-card-dash { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border); position: relative; }
.post-time-dash { font-size: 0.72rem; color: var(--text-2); margin-bottom: 6px; }
.post-body-dash { font-size: 0.85rem; line-height: 1.5; }

.friend-search { display: flex; gap: 8px; margin-bottom: 16px; }
.friend-results { display: flex; flex-direction: column; gap: 6px; }
.friend-result { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border); }
.friend-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--surface-3); }
.friends-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* ===== THEME EDITOR ===== */
.theme-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.theme-card { padding: 10px; border-radius: var(--radius-sm); border: 2px solid var(--border); cursor: pointer; transition: all 0.12s; text-align: center; }
.theme-card:hover { border-color: var(--border-hover); }
.theme-card.active { border-color: var(--accent); }
.theme-preview { height: 36px; border-radius: 6px; margin-bottom: 6px; }
.theme-name { font-size: 0.72rem; font-weight: 600; color: var(--text-2); }

.custom-theme { margin-top: 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.custom-theme h3 { font-size: 0.88rem; font-weight: 600; margin-bottom: 12px; color: var(--text-2); }
.color-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.color-row label { font-size: 0.78rem; font-weight: 500; color: var(--text-2); min-width: 80px; }
.color-swatch { width: 32px; height: 32px; border-radius: 6px; border: 2px solid var(--border); cursor: pointer; padding: 0; }
.color-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.color-swatch::-webkit-color-swatch { border: none; border-radius: 4px; }
.color-hex { font-size: 0.78rem; font-family: monospace; color: var(--text-3); min-width: 70px; }

/* ===== PROFILE PAGE ===== */
.profile-page { max-width: 560px; margin: 0 auto; padding-top: 24px; padding-left: 16px; padding-right: 16px; }
.profile-card { border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.profile-banner { width: 100%; height: 180px; overflow: hidden; }
.profile-banner img { width: 100%; height: 100%; object-fit: cover; }
.profile-info { padding: 12px 16px 16px; position: relative; }
.profile-avatar-wrap { margin-bottom: 12px; }
.profile-avatar { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; border: 3px solid var(--bg); margin-top: -40px; }
.profile-name { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.3px; margin-bottom: 0; }
.profile-handle { font-size: 0.85rem; color: var(--text-2); }
.profile-bio { font-size: 0.88rem; color: var(--text); line-height: 1.5; margin-top: 10px; }
.profile-section-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 14px 16px 8px; color: var(--text-2); }
.profile-links { display: flex; flex-direction: column; gap: 6px; padding: 0 16px 8px; }
.profile-link { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); transition: all 0.12s; }
.profile-link:hover { background: var(--surface); border-color: var(--border-hover); }
.pl-icon { font-size: 1rem; }
.pl-title { font-size: 0.85rem; font-weight: 600; }
.profile-posts { display: flex; flex-direction: column; gap: 0; padding: 0 16px 16px; }
.profile-post { padding: 12px 0; border-bottom: 1px solid var(--border); }
.profile-post:last-child { border-bottom: none; }
.pp-time { font-size: 0.72rem; color: var(--text-2); margin-bottom: 6px; }
.pp-body { font-size: 0.88rem; line-height: 1.45; }

.not-found { text-align: center; padding: 80px 20px; }
.not-found h1 { font-size: 3rem; font-weight: 900; letter-spacing: -2px; margin-bottom: 8px; }
.not-found p { color: var(--text-2); margin-bottom: 20px; }

/* ===== TOAST ===== */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); padding: 10px 20px; border-radius: var(--radius-sm); background: var(--surface-3); border: 1px solid var(--border-hover); color: var(--text); font-size: 0.82rem; font-weight: 500; opacity: 0; transition: all 0.3s; z-index: 200; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== DISCOVER ===== */
.discover-card { border-radius: var(--radius); background: var(--bg); border: 1px solid var(--border); overflow: hidden; transition: all 0.12s; text-align: center; }
.discover-card:hover { border-color: var(--border-hover); }
.discover-card.small { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 14px; }
.discover-banner { height: 72px; width: 100%; object-fit: cover; }
.discover-avatar { width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--bg); margin: -28px auto 8px; display: block; object-fit: cover; background: var(--surface-3); }
.discover-avatar.sm { width: 32px; height: 32px; margin: 0; flex-shrink: 0; border: none; }
.discover-name { font-size: 0.85rem; font-weight: 700; padding: 0 10px; }
.discover-handle { font-size: 0.72rem; color: var(--text-2); padding: 0 10px; margin-bottom: 8px; }

/* ===== HERO ===== */
.landing { max-width: 900px; margin: 0 auto; padding: 60px 20px; }
.hero { text-align: center; margin-bottom: 50px; }
.hero h1 { font-size: clamp(2.4rem, 5vw, 3.8rem); font-weight: 900; letter-spacing: -2px; line-height: 1.1; margin-bottom: 14px; }
.hero-accent { color: var(--accent); }
.hero-sub { font-size: 1.05rem; color: var(--text-2); max-width: 440px; margin: 0 auto 28px; line-height: 1.5; }
.hero-actions { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .feed-layout { grid-template-columns: 240px 1fr; }
  .feed-right { display: none; }
  .topbar-search { flex: 0 1 300px; }
}
@media (max-width: 900px) {
  .feed-layout { grid-template-columns: 1fr; }
  .feed-sidebar, .feed-right { display: none; }
  .topbar-search { display: none; }
  .theme-grid { grid-template-columns: repeat(3, 1fr); }
  .friends-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .topbar { padding: 0 14px; }
  .post-card { padding: 10px 14px; }
  .compose { padding: 12px 14px; }
  .theme-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-layout { flex-direction: column; }
  .dash-sidebar { width: 100%; flex-direction: row; overflow-x: auto; position: static; }
  .dash-nav { white-space: nowrap; }
  .friends-grid { grid-template-columns: 1fr; }
  .gif-results { grid-template-columns: repeat(3, 1fr); }
  .color-row { flex-wrap: wrap; }
}
