/* ============================
   Postim — Global Styles
   Dark theme · Onest font
   ============================ */

:root {
  --bg:          #0d0d14;
  --bg-2:        #12121c;
  --bg-3:        #1a1a28;
  --bg-4:        #22223a;
  --surface:     #181825;
  --surface-2:   #20203a;
  --border:      #2a2a42;
  --border-2:    #363660;
  --text:        #e8e8f0;
  --text-2:      #9898b8;
  --text-3:      #5c5c82;
  --accent:      #7c6aff;
  --accent-2:    #9d8fff;
  --accent-glow: rgba(124, 106, 255, 0.18);
  --danger:      #ff5c5c;
  --success:     #4ade80;
  --warn:        #facc15;
  --radius:      14px;
  --radius-sm:   8px;
  --radius-lg:   20px;
  --sidebar-w:   260px;
  --shadow:      0 4px 24px rgba(0,0,0,0.45);
  --shadow-sm:   0 2px 10px rgba(0,0,0,0.3);
  --transition:  0.2s cubic-bezier(0.4,0,0.2,1);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Onest', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

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

/* ====== LAYOUT ====== */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ====== SIDEBAR ====== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 24px 16px;
  overflow-y: auto;
}

/* ====== LOGO ====== */
.logo, .logo-mobile {
  display: flex;
  align-items: center;
  margin-bottom: 36px;
  padding: 0 8px;
}
.logo-mark {
  width: 36px;
  height: 36px;
}
.logo-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

/* ====== NAV LIST ====== */
.nav-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-4); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent-2); }
.nav-item.active svg { stroke: var(--accent-2); }
.nav-logout { margin-top: auto; color: var(--text-3); }
.nav-logout:hover { color: var(--danger); background: rgba(255,92,92,0.08); }

.nav-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

/* ====== MOBILE HEADER ====== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
}
.logo-mobile .logo-mark { width: 30px; height: 30px; font-size: 15px; border-radius: 8px; }
.logo-mobile .logo-text { font-size: 18px; }
.logo-mobile { margin-bottom: 0; }

.burger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
}
.burger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-2);
  border-radius: 2px;
  transition: var(--transition);
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ====== MAIN CONTENT ====== */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.content-wrap {
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

/* ====== PAGE TITLE ====== */
.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
  margin-bottom: 24px;
}

/* ====== CARD ====== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

/* ====== FORM ELEMENTS ====== */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.form-hint { font-size: 12px; color: var(--text-3); }

.form-input {
  background: var(--bg-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 11px 14px;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input::placeholder { color: var(--text-3); }
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input.error { border-color: var(--danger); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* SELECT */
select.form-input { appearance: none; cursor: pointer; }

/* TEXTAREA */
textarea.form-input { resize: vertical; min-height: 110px; line-height: 1.5; }

/* ====== BUTTON ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: 1.5px solid transparent;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(124,106,255,0.35);
}
.btn-primary:hover {
  background: var(--accent-2);
  box-shadow: 0 4px 20px rgba(124,106,255,0.5);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--bg-4);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-2); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { color: var(--text); background: var(--bg-3); }
.btn-danger { background: rgba(255,92,92,0.1); color: var(--danger); border-color: rgba(255,92,92,0.3); }
.btn-danger:hover { background: rgba(255,92,92,0.2); }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ====== ALERT ====== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  border: 1px solid;
}
.alert-error { background: rgba(255,92,92,0.08); border-color: rgba(255,92,92,0.3); color: #ff8080; }
.alert-success { background: rgba(74,222,128,0.08); border-color: rgba(74,222,128,0.3); color: #4ade80; }
.alert-info { background: var(--accent-glow); border-color: rgba(124,106,255,0.3); color: var(--accent-2); }

/* ====== POST CARD ====== */
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color var(--transition);
}
.post-card:hover { border-color: var(--border-2); }
.post-card + .post-card { margin-top: 14px; }

.post-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.post-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border);
}
.post-author { display: flex; flex-direction: column; gap: 2px; }
.post-author-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  transition: color var(--transition);
}
.post-author-name:hover { color: var(--accent-2); }
.post-author-nick { font-size: 13px; color: var(--text-3); }
.post-date { font-size: 13px; color: var(--text-3); margin-left: auto; white-space: nowrap; }

.post-body { font-size: 15px; line-height: 1.65; color: var(--text); word-break: break-word; }
.post-body p + p { margin-top: 10px; }

.post-image {
  margin-top: 14px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  max-height: 500px;
  display: flex;
}
.post-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.posts-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
  font-size: 15px;
}
.posts-empty strong { display: block; font-size: 18px; color: var(--text-2); margin-bottom: 8px; }

/* ====== PROFILE ====== */
.profile-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
}
.profile-avatar-wrap { flex-shrink: 0; }
.profile-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
}
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.profile-nick { font-size: 15px; color: var(--text-3); margin-top: 2px; font-family: 'JetBrains Mono', monospace; }
.profile-bio { font-size: 14px; color: var(--text-2); margin-top: 10px; }
.profile-meta { font-size: 13px; color: var(--text-3); margin-top: 10px; display: flex; gap: 16px; flex-wrap: wrap; }
.profile-meta span { display: flex; align-items: center; gap: 4px; }
.profile-actions { margin-top: 14px; }

/* ====== AUTH PAGE ====== */
.auth-wrap { max-width: 420px; margin: 0 auto; padding-top: 40px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; }
.auth-title { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 6px; }
.auth-subtitle { font-size: 14px; color: var(--text-2); margin-bottom: 28px; }
.auth-steps { display: none; }
.auth-step { display: none; }
.auth-step.active { display: block; }
.auth-email-badge {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.auth-email-badge button { font-size: 12px; color: var(--accent-2); }

/* ====== NEW POST FORM ====== */
.new-post-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}
.new-post-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.new-post-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.new-post-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  resize: none;
  width: 100%;
  padding: 8px 0;
  min-height: 60px;
  line-height: 1.6;
}
.new-post-input::placeholder { color: var(--text-3); }
.new-post-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.new-post-actions { display: flex; gap: 8px; align-items: center; }
.img-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg-3);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.img-btn:hover { color: var(--accent-2); border-color: var(--accent); }
.img-btn svg { width: 16px; height: 16px; }

.image-preview-wrap {
  margin-top: 14px;
  position: relative;
  display: inline-block;
  max-width: 100%;
}
.image-preview-wrap img {
  border-radius: var(--radius-sm);
  max-height: 300px;
  max-width: 100%;
  border: 1px solid var(--border);
  object-fit: cover;
}
.remove-image-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.char-count { font-size: 12px; color: var(--text-3); font-family: 'JetBrains Mono', monospace; }
.char-count.over { color: var(--danger); }

/* ====== SETTINGS ====== */
.settings-section { margin-bottom: 32px; }
.settings-section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.avatar-upload-area {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
}
.avatar-current {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.avatar-upload-btn {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ====== DIVIDER ====== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ====== 404 / ERROR ====== */
.error-page {
  text-align: center;
  padding: 80px 20px;
}
.error-code {
  font-size: 80px;
  font-weight: 800;
  letter-spacing: -4px;
  color: var(--border-2);
  line-height: 1;
  font-family: 'JetBrains Mono', monospace;
}
.error-message { font-size: 20px; font-weight: 600; margin-top: 16px; }
.error-sub { font-size: 15px; color: var(--text-2); margin-top: 8px; }
.error-back { margin-top: 28px; }

/* ====== FEED HEADER ====== */
.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

/* ====== NICKNAME BADGE ====== */
.nick-input-wrap { position: relative; }
.nick-prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  pointer-events: none;
}
.nick-input { padding-left: 26px !important; font-family: 'JetBrains Mono', monospace; }

/* ====== BACK LINK ====== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 20px;
  transition: color var(--transition);
}
.back-link:hover { color: var(--text); }
.back-link svg { width: 16px; height: 16px; }

/* ====== GENDER RADIO ====== */
.gender-options { display: flex; gap: 10px; flex-wrap: wrap; }
.gender-option { display: none; }
.gender-label {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--border);
  color: var(--text-2);
  background: var(--bg-3);
  transition: all var(--transition);
  user-select: none;
}
.gender-option:checked + .gender-label {
  border-color: var(--accent);
  color: var(--accent-2);
  background: var(--accent-glow);
}

/* ====== TABS ====== */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab-btn {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent-2); border-bottom-color: var(--accent); }

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    height: 100vh;
    z-index: 150;
    transition: left 0.3s cubic-bezier(0.4,0,0.2,1);
    width: 260px;
  }
  .sidebar.open { left: 0; }
  .overlay.visible { display: block; }
  .mobile-header { display: flex; }
  .main-content { padding-top: 56px; }
  .content-wrap { padding: 20px 14px 80px; }
  .auth-card { padding: 24px 18px; }
  .form-row { grid-template-columns: 1fr; }
  .profile-hero { flex-direction: column; align-items: center; text-align: center; }
  .profile-meta { justify-content: center; }
  .profile-actions { text-align: center; }
}

/* ====== SKELETON LOADER ====== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-4) 50%, var(--bg-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ====== ANIMATIONS ====== */
@keyframes fadeUp {
  from { opacity:0; transform:translateY(12px); }
  to { opacity:1; transform:translateY(0); }
}
.fade-up { animation: fadeUp 0.35s ease both; }

.post-card { animation: fadeUp 0.3s ease both; }
.post-card:nth-child(2) { animation-delay: 0.04s; }
.post-card:nth-child(3) { animation-delay: 0.08s; }
.post-card:nth-child(4) { animation-delay: 0.12s; }
