/* ═══════════════════════════════════════════════════════════
   AskSree — Complete Application Stylesheet
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  --primary: #1A3C6D;
  --primary-light: #2E75B6;
  --primary-dark: #0F2444;
  --accent: #E74C3C;
  --accent-light: #FF6B6B;
  --success: #1E8449;
  --success-light: #27AE60;
  --warning: #F39C12;
  --warning-light: #F1C40F;
  --info: #2980B9;
  --danger: #C0392B;
  --bg: #F4F7FB;
  --bg-card: #FFFFFF;
  --bg-nav: #1A3C6D;
  --text: #1A1A2E;
  --text-muted: #6C757D;
  --text-light: #ADB5BD;
  --border: #DEE2E6;
  --border-light: #F1F3F5;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.16);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;
  --transition: 0.2s ease;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%; /* Prevent iOS font scaling on orientation change */
  text-size-adjust: 100%;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: -webkit-fill-available; /* iOS Safari full height */
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent; /* Remove tap flash on Android/iOS */
  tap-highlight-color: transparent;
  overflow-x: hidden;
}
#app { display: flex; flex-direction: column; min-height: 100vh; overflow-x: hidden; }
#page { flex: 1; }
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button {
  cursor: pointer;
  font-family: var(--font);
  touch-action: manipulation; /* Remove 300ms tap delay on mobile */
  -webkit-tap-highlight-color: transparent;
}
input, select, textarea {
  font-family: var(--font);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
/* Prevent iOS auto-zoom on focus (needs font-size >= 16px on inputs) */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], textarea, select {
  font-size: 16px;
}
ul { list-style: none; }
h1,h2,h3,h4,h5,h6 { line-height: 1.3; }

/* Safe area insets for iPhone notch and home bar */
#navbar { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
#global-footer { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }


/* ── Splash Screen ───────────────────────────────────────── */
.splash { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:100vh; gap:12px; }
.splash-logo { display:block; }
.splash-logo img { height:90px; width:auto; }
.splash-sub { color:var(--text-muted); font-size:0.9rem; }
.splash-spinner { width:32px; height:32px; border:3px solid var(--border); border-top-color:var(--primary-light); border-radius:50%; animation:spin 0.8s linear infinite; margin-top:8px; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ── Navbar ──────────────────────────────────────────────── */
#navbar { background:var(--bg-nav); color:#fff; position:sticky; top:0; z-index:1000; box-shadow:0 2px 12px rgba(0,0,0,0.2); -webkit-transform:translateZ(0); }
.nav-inner { max-width:1280px; margin:0 auto; padding:0 16px; display:flex; align-items:center; height:60px; gap:8px; }
.nav-logo { display:flex; align-items:center; flex-shrink:0; text-decoration:none; background:none; border:none; cursor:pointer; padding:0; margin-right:4px; }
.nav-logo img { height:40px; width:auto; display:block; }
.nav-search { flex:1; max-width:400px; position:relative; min-width:0; }
.nav-search input { width:100%; box-sizing:border-box; padding:8px 16px 8px 38px; border-radius:var(--radius-full); border:none; background:rgba(255,255,255,0.15); color:#fff; font-size:0.875rem; outline:none; }
.nav-search input::placeholder { color:rgba(255,255,255,0.6); }
.nav-search input:focus { background:rgba(255,255,255,0.25); }
.nav-search-icon { position:absolute; left:12px; top:50%; transform:translateY(-50%); opacity:0.7; font-size:0.875rem; pointer-events:none; }
.nav-links { display:flex; align-items:center; gap:2px; margin-left:auto; flex-shrink:0; }
.nav-link { padding:6px 10px; border-radius:var(--radius); color:rgba(255,255,255,0.85); font-size:0.85rem; cursor:pointer; white-space:nowrap; border:none; background:none; display:flex; align-items:center; gap:4px; }
.nav-link:hover { background:rgba(255,255,255,0.12); color:#fff; }
.nav-icon-btn { position:relative; padding:7px; border-radius:50%; color:rgba(255,255,255,0.85); cursor:pointer; border:none; background:none; font-size:1.1rem; flex-shrink:0; }
.nav-icon-btn:hover { background:rgba(255,255,255,0.12); }
.nav-badge { position:absolute; top:2px; right:2px; width:15px; height:15px; background:var(--accent); color:#fff; border-radius:50%; font-size:0.62rem; font-weight:700; display:flex; align-items:center; justify-content:center; }
.nav-avatar { width:32px; height:32px; border-radius:50%; background:rgba(255,255,255,0.2); display:flex; align-items:center; justify-content:center; font-weight:700; font-size:0.875rem; cursor:pointer; border:2px solid rgba(255,255,255,0.3); flex-shrink:0; }
.nav-dropdown { position:absolute; top:calc(100% + 8px); right:0; background:#fff; border-radius:var(--radius-lg); box-shadow:var(--shadow-lg); min-width:200px; overflow:hidden; z-index:1001; border:1px solid var(--border); }
.nav-dropdown-item { display:flex; align-items:center; gap:10px; padding:10px 16px; color:var(--text); cursor:pointer; font-size:0.875rem; border:none; background:none; width:100%; text-align:left; }
.nav-dropdown-item:hover { background:var(--bg); }
.nav-dropdown-item.danger { color:var(--danger); }
.nav-dropdown-divider { height:1px; background:var(--border); margin:4px 0; }
/* Hamburger — hidden on desktop, shown on mobile */
.nav-menu-btn { display:none; align-items:center; justify-content:center; width:40px; height:40px; border-radius:8px; background:rgba(255,255,255,0.12); border:none; color:#fff; font-size:1.25rem; cursor:pointer; flex-shrink:0; margin-left:4px; }

/* ── Layout ──────────────────────────────────────────────── */
#page { min-height: calc(100vh - 64px); }
.container { max-width:1280px; margin:0 auto; padding:0 16px; }
.page-layout { display:grid; grid-template-columns:260px 1fr; gap:24px; padding:24px 16px; max-width:1280px; margin:0 auto; }
.page-layout-wide { grid-template-columns:1fr; }
.page-content { min-width:0; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar { position:sticky; top:88px; height:fit-content; }
.sidebar-section { background:var(--bg-card); border-radius:var(--radius-lg); padding:16px; margin-bottom:16px; box-shadow:var(--shadow); }
.sidebar-title { font-size:0.75rem; font-weight:700; text-transform:uppercase; letter-spacing:0.5px; color:var(--text-muted); margin-bottom:12px; }
.sidebar-link { display:flex; align-items:center; gap:10px; padding:9px 12px; border-radius:var(--radius); color:var(--text); cursor:pointer; transition:var(--transition); font-size:0.9rem; border:none; background:none; width:100%; text-align:left; }
.sidebar-link:hover { background:var(--bg); color:var(--primary); }
.sidebar-link.active { background:rgba(26,60,109,0.08); color:var(--primary); font-weight:600; }
.sidebar-link .icon { width:24px; text-align:center; font-size:1rem; }
.sidebar-link .count { margin-left:auto; background:var(--primary-light); color:#fff; border-radius:var(--radius-full); padding:1px 7px; font-size:0.72rem; font-weight:700; }
.sidebar-link .count.red { background:var(--accent); }

/* ── Cards ───────────────────────────────────────────────── */
.card { background:var(--bg-card); border-radius:var(--radius-lg); box-shadow:var(--shadow); overflow:hidden; }
.card-header { padding:16px 20px; border-bottom:1px solid var(--border-light); display:flex; align-items:center; justify-content:space-between; }
.card-title { font-size:1rem; font-weight:700; color:var(--text); }
.card-body { padding:20px; }
.card-footer { padding:12px 20px; border-top:1px solid var(--border-light); background:var(--bg); }

/* ── Post Cards ──────────────────────────────────────────── */
.post-card { background:var(--bg-card); border-radius:var(--radius-lg); box-shadow:var(--shadow); padding:16px 20px; transition:var(--transition); cursor:pointer; border:2px solid transparent; position:relative; overflow:hidden; }
.post-card:hover { box-shadow:var(--shadow-md); border-color:var(--border); transform:translateY(-1px); }
.post-card.pinned { border-color:var(--accent); }
.post-card.pinned::before { content:'🚨 EMERGENCY'; position:absolute; top:0; left:0; right:0; background:var(--accent); color:#fff; text-align:center; font-size:0.7rem; font-weight:700; padding:2px; letter-spacing:1px; }
.post-card.pinned { padding-top:28px; }
.post-card.featured { border-color:var(--warning); }
.post-card-top { display:flex; align-items:flex-start; gap:12px; margin-bottom:10px; }
.post-cat-icon { width:40px; height:40px; border-radius:var(--radius); display:flex; align-items:center; justify-content:center; font-size:1.2rem; flex-shrink:0; }
.post-card-info { flex:1; min-width:0; }
.post-card-title { font-size:0.95rem; font-weight:700; color:var(--text); margin-bottom:3px; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.post-card-meta { display:flex; align-items:center; gap:8px; flex-wrap:wrap; font-size:0.78rem; color:var(--text-muted); }
.post-card-desc { font-size:0.875rem; color:var(--text-muted); display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; margin-bottom:12px; line-height:1.5; }
.post-card-footer { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; }
.post-card-tags { display:flex; gap:6px; flex-wrap:wrap; }
.post-card-actions { display:flex; align-items:center; gap:8px; }
.post-list { display:flex; flex-direction:column; gap:12px; }
.posts-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); gap:16px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display:inline-flex; align-items:center; gap:4px; padding:2px 10px; border-radius:var(--radius-full); font-size:0.75rem; font-weight:600; white-space:nowrap; }
.badge-blue   { background:#EAF2FB; color:#1A5276; }
.badge-green  { background:#EAFAF1; color:#1E5631; }
.badge-red    { background:#FDEDEC; color:#922B21; }
.badge-amber  { background:#FEF9E7; color:#7D5A0B; }
.badge-purple { background:#F5EEF8; color:#6C3483; }
.badge-gray   { background:#F2F3F4; color:#566573; }
.badge-teal   { background:#E8F8F5; color:#0E6655; }
.badge-offered { background:#EAFAF1; color:#1E5631; }
.badge-looking { background:#EAF2FB; color:#1A5276; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; padding:8px 18px; border-radius:var(--radius); font-size:0.875rem; font-weight:600; cursor:pointer; transition:var(--transition); border:none; white-space:nowrap; }
.btn-sm { padding:5px 12px; font-size:0.8rem; }
.btn-lg { padding:12px 28px; font-size:1rem; }
.btn-primary { background:var(--primary); color:#fff; }
.btn-primary:hover { background:var(--primary-dark); }
.btn-secondary { background:var(--bg); color:var(--text); border:1px solid var(--border); }
.btn-secondary:hover { background:var(--border-light); }
.btn-accent { background:var(--accent); color:#fff; }
.btn-accent:hover { background:#a93226; }
.btn-success { background:var(--success); color:#fff; }
.btn-success:hover { background:#186a3b; }
.btn-outline { background:transparent; color:var(--primary); border:2px solid var(--primary); }
.btn-outline:hover { background:var(--primary); color:#fff; }
.btn-ghost { background:transparent; color:var(--text-muted); border:none; }
.btn-ghost:hover { background:var(--bg); color:var(--text); }
.btn-danger { background:var(--danger); color:#fff; }
.btn-danger:hover { background:#922b21; }
.btn-full { width:100%; }
.btn:disabled { opacity:0.6; cursor:not-allowed; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom:18px; }
.form-label { display:block; font-size:0.875rem; font-weight:600; color:var(--text); margin-bottom:5px; }
.form-label span.req { color:var(--accent); margin-left:3px; }
.form-input { width:100%; padding:10px 14px; border:1.5px solid var(--border); border-radius:var(--radius); font-size:0.9rem; color:var(--text); background:#fff; transition:var(--transition); outline:none; }
.form-input:focus { border-color:var(--primary-light); box-shadow:0 0 0 3px rgba(46,117,182,0.1); }
.form-input.error { border-color:var(--accent); }
.form-input::placeholder { color:var(--text-light); }
.form-select { width:100%; padding:10px 14px; border:1.5px solid var(--border); border-radius:var(--radius); font-size:0.9rem; color:var(--text); background:#fff; cursor:pointer; appearance:none; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236C757D' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 12px center; padding-right:36px; transition:var(--transition); outline:none; }
.form-select:focus { border-color:var(--primary-light); box-shadow:0 0 0 3px rgba(46,117,182,0.1); }
.form-textarea { width:100%; padding:10px 14px; border:1.5px solid var(--border); border-radius:var(--radius); font-size:0.9rem; color:var(--text); background:#fff; resize:vertical; min-height:100px; transition:var(--transition); outline:none; }
.form-textarea:focus { border-color:var(--primary-light); box-shadow:0 0 0 3px rgba(46,117,182,0.1); }
.form-hint { font-size:0.78rem; color:var(--text-muted); margin-top:4px; }
.form-error { font-size:0.78rem; color:var(--accent); margin-top:4px; display:flex; align-items:center; gap:4px; }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.form-row-3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; }
.input-group { display:flex; }
.input-group .form-input { border-radius:var(--radius) 0 0 var(--radius); flex:1; }
.input-group .btn { border-radius:0 var(--radius) var(--radius) 0; }
.password-toggle { position:relative; }
.password-toggle input { padding-right:44px; }
.password-toggle .toggle-btn { position:absolute; right:12px; top:50%; transform:translateY(-50%); border:none; background:none; cursor:pointer; color:var(--text-muted); font-size:1rem; padding:2px; }
.strength-bar { display:flex; gap:3px; margin-top:6px; }
.strength-segment { flex:1; height:3px; border-radius:2px; background:var(--border); transition:var(--transition); }
.strength-segment.weak { background:#E74C3C; }
.strength-segment.fair { background:#F39C12; }
.strength-segment.strong { background:#27AE60; }
.strength-segment.very-strong { background:#1A8A4A; }
.char-count { font-size:0.75rem; color:var(--text-muted); text-align:right; margin-top:3px; }

/* ── Location Filter ─────────────────────────────────────── */
.location-filter { background:#fff; border-radius:var(--radius-lg); padding:12px 14px; box-shadow:var(--shadow); display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:16px; border:1px solid var(--border); }
.location-filter-icon { color:var(--primary-light); font-size:1.1rem; }
.location-filter-label { font-size:0.8rem; font-weight:600; color:var(--text-muted); white-space:nowrap; }
.location-filter select { padding:6px 30px 6px 10px; border:1.5px solid var(--border); border-radius:var(--radius); font-size:0.85rem; color:var(--text); cursor:pointer; background:#fff; appearance:none; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236C757D' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 8px center; outline:none; min-width:130px; }
.location-filter select:focus { border-color:var(--primary-light); }
.location-filter .reset-btn { margin-left:auto; font-size:0.78rem; color:var(--primary-light); cursor:pointer; background:none; border:none; white-space:nowrap; }
.location-filter .reset-btn:hover { text-decoration:underline; }

/* ── Category Tabs ───────────────────────────────────────── */
.cat-tabs { display:flex; gap:6px; overflow-x:auto; padding-bottom:4px; margin-bottom:20px; scrollbar-width:none; }
.cat-tabs::-webkit-scrollbar { display:none; }
.cat-tab { flex-shrink:0; display:flex; align-items:center; gap:6px; padding:7px 14px; border-radius:var(--radius-full); font-size:0.82rem; font-weight:600; cursor:pointer; transition:var(--transition); border:1.5px solid var(--border); background:#fff; color:var(--text-muted); white-space:nowrap; }
.cat-tab:hover { border-color:var(--primary-light); color:var(--primary-light); background:#EAF2FB; }
.cat-tab.active { background:var(--primary); color:#fff; border-color:var(--primary); }
.cat-tab .cat-count { background:rgba(255,255,255,0.25); color:inherit; border-radius:var(--radius-full); padding:0 6px; font-size:0.7rem; }
.cat-tab:not(.active) .cat-count { background:var(--bg); color:var(--text-muted); }

/* ── Hero / Landing ──────────────────────────────────────── */
.hero { background:linear-gradient(135deg, #0F2444 0%, #1A3C6D 60%, #2E75B6 100%); color:#fff; padding:80px 16px; text-align:center; position:relative; overflow:hidden; }
.hero::before { content:''; position:absolute; inset:0; background:url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); }
.hero-content { position:relative; max-width:800px; margin:0 auto; }
.hero-logo { font-size:3.5rem; font-weight:900; letter-spacing:-2px; margin-bottom:8px; }
.hero-logo span { color:#5BC8F5; }
.hero-tagline { font-size:1.4rem; font-weight:300; opacity:0.9; margin-bottom:16px; }
.hero-desc { font-size:1rem; opacity:0.75; max-width:560px; margin:0 auto 36px; line-height:1.7; }
.hero-btns { display:flex; gap:12px; justify-content:center; flex-wrap:wrap; margin-bottom:48px; }
.hero-btn-primary { background:#fff; color:var(--primary); padding:13px 32px; border-radius:var(--radius-full); font-size:1rem; font-weight:700; border:none; cursor:pointer; transition:var(--transition); }
.hero-btn-primary:hover { background:#EAF2FB; transform:translateY(-2px); box-shadow:0 6px 20px rgba(0,0,0,0.2); }
.hero-btn-outline { background:transparent; color:#fff; padding:13px 32px; border-radius:var(--radius-full); font-size:1rem; font-weight:700; border:2px solid rgba(255,255,255,0.5); cursor:pointer; transition:var(--transition); }
.hero-btn-outline:hover { background:rgba(255,255,255,0.1); border-color:#fff; }
.hero-stats { display:flex; gap:32px; justify-content:center; flex-wrap:wrap; }
.hero-stat { text-align:center; }
.hero-stat-num { font-size:1.8rem; font-weight:800; }
.hero-stat-label { font-size:0.8rem; opacity:0.7; margin-top:2px; }

/* ── Category Grid (Landing) ─────────────────────────────── */
.cat-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:12px; padding:24px 0; }
.cat-card { background:#fff; border-radius:var(--radius-lg); padding:20px 16px; text-align:center; cursor:pointer; transition:var(--transition); box-shadow:var(--shadow); border:2px solid transparent; }
.cat-card:hover { box-shadow:var(--shadow-md); border-color:var(--primary-light); transform:translateY(-2px); }
.cat-card-icon { font-size:2rem; margin-bottom:8px; }
.cat-card-name { font-size:0.875rem; font-weight:700; color:var(--text); margin-bottom:4px; }
.cat-card-count { font-size:0.75rem; color:var(--text-muted); }

/* ── Auth Pages ──────────────────────────────────────────── */
.auth-page { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px; background:linear-gradient(135deg, #F4F7FB 0%, #EAF2FB 100%); }
.auth-card { background:#fff; border-radius:var(--radius-xl); box-shadow:var(--shadow-lg); padding:40px; width:100%; max-width:520px; }
.auth-logo { text-align:center; margin-bottom:28px; }
.auth-logo-text { font-size:2rem; font-weight:900; color:var(--primary); letter-spacing:-1px; }
.auth-logo-text span { color:var(--primary-light); }
.auth-title { font-size:1.5rem; font-weight:800; color:var(--text); margin-bottom:4px; }
.auth-sub { font-size:0.9rem; color:var(--text-muted); margin-bottom:28px; }
.auth-footer { text-align:center; margin-top:20px; font-size:0.875rem; color:var(--text-muted); }
.auth-divider { display:flex; align-items:center; gap:12px; margin:20px 0; color:var(--text-muted); font-size:0.8rem; }
.auth-divider::before, .auth-divider::after { content:''; flex:1; height:1px; background:var(--border); }

/* ── Profile ─────────────────────────────────────────────── */
.profile-header { background:linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); color:#fff; padding:40px 20px 80px; border-radius:var(--radius-xl) var(--radius-xl) 0 0; }
.profile-wrap { position:relative; }
.profile-card { background:#fff; border-radius:0 0 var(--radius-xl) var(--radius-xl); box-shadow:var(--shadow-lg); padding:0 20px 24px; margin-bottom:24px; }
.profile-avatar-wrap { display:flex; justify-content:center; margin-top:-48px; margin-bottom:12px; }
.profile-avatar { width:96px; height:96px; border-radius:50%; border:4px solid #fff; background:linear-gradient(135deg,var(--primary),var(--primary-light)); display:flex; align-items:center; justify-content:center; font-size:2.2rem; font-weight:800; color:#fff; box-shadow:var(--shadow-md); }
.profile-name { text-align:center; font-size:1.5rem; font-weight:800; margin-bottom:4px; }
.profile-username { text-align:center; color:var(--text-muted); font-size:0.9rem; margin-bottom:12px; }
.profile-stats { display:flex; justify-content:center; gap:32px; padding:16px 0; border-top:1px solid var(--border-light); border-bottom:1px solid var(--border-light); margin:12px 0; }
.profile-stat { text-align:center; }
.profile-stat-num { font-size:1.3rem; font-weight:800; color:var(--primary); }
.profile-stat-label { font-size:0.75rem; color:var(--text-muted); }
.profile-tabs { display:flex; border-bottom:2px solid var(--border); margin-bottom:20px; overflow-x:auto; }
.profile-tab { padding:10px 18px; font-size:0.875rem; font-weight:600; color:var(--text-muted); cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-2px; transition:var(--transition); white-space:nowrap; }
.profile-tab.active { color:var(--primary); border-bottom-color:var(--primary); }
.profile-tab:hover:not(.active) { color:var(--text); }

/* ── Post Detail ─────────────────────────────────────────── */
.post-detail-header { background:#fff; border-radius:var(--radius-lg); padding:24px; box-shadow:var(--shadow); margin-bottom:16px; }
.post-detail-cat { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.post-detail-title { font-size:1.4rem; font-weight:800; color:var(--text); margin-bottom:12px; line-height:1.4; }
.post-detail-meta { display:flex; flex-wrap:wrap; gap:12px; font-size:0.85rem; color:var(--text-muted); padding:14px 0; border-top:1px solid var(--border-light); border-bottom:1px solid var(--border-light); margin:14px 0; }
.post-detail-meta span { display:flex; align-items:center; gap:5px; }
.post-detail-body { font-size:0.95rem; color:var(--text); line-height:1.8; white-space:pre-wrap; }

/* ── Messages ────────────────────────────────────────────── */
.messages-layout { display:grid; grid-template-columns:300px 1fr; gap:0; background:#fff; border-radius:var(--radius-lg); box-shadow:var(--shadow); overflow:hidden; min-height:500px; }
.messages-sidebar { border-right:1px solid var(--border); overflow-y:auto; }
.messages-header { padding:16px; border-bottom:1px solid var(--border); font-weight:700; font-size:1rem; }
.message-thread-item { padding:14px 16px; border-bottom:1px solid var(--border-light); cursor:pointer; transition:var(--transition); }
.message-thread-item:hover { background:var(--bg); }
.message-thread-item.active { background:var(--bg); border-left:3px solid var(--primary); }
.message-thread-name { font-weight:700; font-size:0.875rem; margin-bottom:3px; }
.message-thread-preview { font-size:0.8rem; color:var(--text-muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.message-thread-time { font-size:0.72rem; color:var(--text-light); }
.messages-main { display:flex; flex-direction:column; }
.messages-chat-header { padding:14px 18px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:10px; }
.messages-chat-body { flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:10px; min-height:300px; }
.message-bubble { max-width:70%; padding:10px 14px; border-radius:var(--radius-lg); font-size:0.9rem; line-height:1.5; }
.message-bubble.mine { background:var(--primary); color:#fff; align-self:flex-end; border-radius:var(--radius-lg) var(--radius-lg) 4px var(--radius-lg); }
.message-bubble.theirs { background:var(--bg); color:var(--text); align-self:flex-start; border-radius:var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px; }
.message-bubble-time { font-size:0.7rem; opacity:0.65; margin-top:4px; }
.messages-chat-footer { padding:12px; border-top:1px solid var(--border); display:flex; gap:10px; }
.messages-chat-footer textarea { flex:1; padding:10px 14px; border:1.5px solid var(--border); border-radius:var(--radius); resize:none; height:44px; font-family:var(--font); font-size:0.9rem; outline:none; transition:var(--transition); }
.messages-chat-footer textarea:focus { border-color:var(--primary-light); }

/* ── Admin ───────────────────────────────────────────────── */
.admin-layout { display:flex; min-height:calc(100vh - 64px); }
.admin-sidebar { width:240px; background:var(--primary-dark); flex-shrink:0; padding:20px 0; }
.admin-sidebar-title { padding:8px 20px; font-size:0.7rem; font-weight:700; text-transform:uppercase; letter-spacing:1px; color:rgba(255,255,255,0.4); margin-top:12px; }
.admin-sidebar-link { display:flex; align-items:center; gap:10px; padding:10px 20px; color:rgba(255,255,255,0.7); cursor:pointer; transition:var(--transition); font-size:0.875rem; border:none; background:none; width:100%; text-align:left; }
.admin-sidebar-link:hover { color:#fff; background:rgba(255,255,255,0.08); }
.admin-sidebar-link.active { color:#fff; background:rgba(255,255,255,0.12); border-left:3px solid #5BC8F5; }
.admin-content { flex:1; padding:24px; overflow-y:auto; }
.admin-page-title { font-size:1.4rem; font-weight:800; color:var(--text); margin-bottom:4px; }
.admin-page-sub { font-size:0.875rem; color:var(--text-muted); margin-bottom:24px; }
.stat-cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:16px; margin-bottom:24px; }
.stat-card { background:#fff; border-radius:var(--radius-lg); padding:20px; box-shadow:var(--shadow); border-left:4px solid; }
.stat-card-blue   { border-color:var(--primary-light); }
.stat-card-green  { border-color:var(--success); }
.stat-card-amber  { border-color:var(--warning); }
.stat-card-red    { border-color:var(--danger); }
.stat-card-purple { border-color:#8E44AD; }
.stat-card-teal   { border-color:#16A085; }
.stat-card-value  { font-size:2rem; font-weight:800; margin-bottom:4px; }
.stat-card-label  { font-size:0.8rem; color:var(--text-muted); font-weight:600; }
.stat-card-sub    { font-size:0.75rem; color:var(--text-light); margin-top:4px; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x:auto; }
table { width:100%; border-collapse:collapse; font-size:0.875rem; }
thead th { background:var(--bg); padding:10px 14px; text-align:left; font-size:0.78rem; font-weight:700; text-transform:uppercase; letter-spacing:0.5px; color:var(--text-muted); border-bottom:2px solid var(--border); white-space:nowrap; }
tbody td { padding:12px 14px; border-bottom:1px solid var(--border-light); vertical-align:middle; }
tbody tr:hover { background:var(--bg); }
tbody tr:last-child td { border-bottom:none; }

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.5); z-index:2000; display:flex; align-items:center; justify-content:center; padding:16px; backdrop-filter:blur(2px); }
.modal { background:#fff; border-radius:var(--radius-xl); box-shadow:var(--shadow-lg); width:100%; max-width:560px; max-height:90vh; overflow-y:auto; animation:modal-in 0.2s ease; }
@keyframes modal-in { from { transform:scale(0.95); opacity:0; } to { transform:scale(1); opacity:1; } }
.modal-header { display:flex; align-items:center; justify-content:space-between; padding:20px 24px; border-bottom:1px solid var(--border); }
.modal-title { font-size:1.1rem; font-weight:800; }
.modal-close { width:32px; height:32px; border-radius:50%; border:none; background:var(--bg); cursor:pointer; font-size:1rem; display:flex; align-items:center; justify-content:center; transition:var(--transition); }
.modal-close:hover { background:var(--border); }
.modal-body { padding:24px; }
.modal-footer { padding:16px 24px; border-top:1px solid var(--border); display:flex; gap:10px; justify-content:flex-end; }

/* ── Toast Notifications ─────────────────────────────────── */
#toast-container { position:fixed; bottom:24px; right:24px; z-index:3000; display:flex; flex-direction:column; gap:8px; }
.toast { background:#fff; border-radius:var(--radius-lg); box-shadow:var(--shadow-lg); padding:12px 16px; display:flex; align-items:center; gap:10px; min-width:280px; max-width:380px; animation:toast-in 0.3s ease; border-left:4px solid; }
.toast.success { border-color:var(--success); }
.toast.error   { border-color:var(--danger); }
.toast.info    { border-color:var(--info); }
.toast.warning { border-color:var(--warning); }
.toast-icon { font-size:1.1rem; flex-shrink:0; }
.toast-msg  { flex:1; font-size:0.875rem; color:var(--text); font-weight:500; }
.toast-close { color:var(--text-muted); cursor:pointer; font-size:1rem; border:none; background:none; padding:2px; }
@keyframes toast-in { from { transform:translateX(100%); opacity:0; } to { transform:translateX(0); opacity:1; } }

/* ── Stars ───────────────────────────────────────────────── */
.stars { display:inline-flex; gap:2px; }
.star { font-size:1rem; color:#F1C40F; }
.star.empty { color:var(--border); }
.star-input { display:flex; gap:4px; }
.star-input .star { font-size:1.5rem; cursor:pointer; transition:var(--transition); }
.star-input .star:hover, .star-input .star.hover { color:#F39C12; transform:scale(1.1); }

/* ── Loading ─────────────────────────────────────────────── */
.spinner { display:inline-block; width:20px; height:20px; border:2px solid var(--border); border-top-color:var(--primary-light); border-radius:50%; animation:spin 0.7s linear infinite; }
.loading-page { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:300px; gap:12px; color:var(--text-muted); }
.skeleton { background:linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%); background-size:200% 100%; animation:shimmer 1.5s infinite; border-radius:var(--radius); }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.skeleton-text { height:14px; margin-bottom:8px; }
.skeleton-title { height:20px; width:70%; margin-bottom:12px; }
.skeleton-card { padding:16px; border-radius:var(--radius-lg); background:#fff; box-shadow:var(--shadow); }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state { text-align:center; padding:48px 20px; color:var(--text-muted); }
.empty-state-icon { font-size:3rem; margin-bottom:12px; }
.empty-state-title { font-size:1.1rem; font-weight:700; color:var(--text); margin-bottom:6px; }
.empty-state-desc { font-size:0.875rem; margin-bottom:20px; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display:flex; align-items:center; justify-content:center; gap:6px; padding:16px 0; }
.page-btn { width:36px; height:36px; border-radius:var(--radius); border:1.5px solid var(--border); background:#fff; cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:0.875rem; font-weight:600; color:var(--text); transition:var(--transition); }
.page-btn:hover { border-color:var(--primary-light); color:var(--primary-light); }
.page-btn.active { background:var(--primary); color:#fff; border-color:var(--primary); }
.page-btn:disabled { opacity:0.4; cursor:not-allowed; }

/* ── Section Header ──────────────────────────────────────── */
.section-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; }
.section-title { font-size:1.1rem; font-weight:800; color:var(--text); }
.section-sub { font-size:0.825rem; color:var(--text-muted); margin-top:2px; }

/* ── Alert ───────────────────────────────────────────────── */
.alert { padding:12px 16px; border-radius:var(--radius); margin-bottom:16px; display:flex; gap:10px; align-items:flex-start; font-size:0.875rem; }
.alert-info    { background:#EAF2FB; border:1px solid #2980B9; color:#1A5276; }
.alert-success { background:#EAFAF1; border:1px solid #27AE60; color:#1E5631; }
.alert-warning { background:#FEF9E7; border:1px solid #F39C12; color:#7D5A0B; }
.alert-danger  { background:#FDEDEC; border:1px solid #E74C3C; color:#922B21; }
.alert-icon { font-size:1.1rem; flex-shrink:0; margin-top:1px; }

/* ── Post type filter bar ────────────────────────────────── */
.filter-bar { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:16px; }
.filter-chip { padding:6px 14px; border-radius:var(--radius-full); font-size:0.8rem; font-weight:600; cursor:pointer; transition:var(--transition); border:1.5px solid var(--border); background:#fff; color:var(--text-muted); }
.filter-chip:hover { border-color:var(--primary-light); color:var(--primary); }
.filter-chip.active { background:var(--primary); color:#fff; border-color:var(--primary); }
.sort-select { margin-left:auto; padding:6px 28px 6px 10px; border:1.5px solid var(--border); border-radius:var(--radius); font-size:0.82rem; background:#fff; cursor:pointer; outline:none; appearance:none; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236C757D' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 8px center; }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer { background:var(--primary-dark); color:rgba(255,255,255,0.7); padding:48px 16px 24px; margin-top:48px; }
.footer-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:32px; max-width:1280px; margin:0 auto 32px; }
.footer-brand { font-size:1.5rem; font-weight:800; color:#fff; margin-bottom:8px; }
.footer-brand span { color:#5BC8F5; }
.footer-desc { font-size:0.85rem; line-height:1.7; }
.footer-col-title { font-size:0.8rem; font-weight:700; text-transform:uppercase; letter-spacing:0.5px; color:#fff; margin-bottom:12px; }
.footer-link { display:block; font-size:0.85rem; color:rgba(255,255,255,0.6); margin-bottom:6px; cursor:pointer; transition:var(--transition); background:none; border:none; text-align:left; }
.footer-link:hover { color:#fff; }
.footer-bottom { border-top:1px solid rgba(255,255,255,0.1); padding-top:20px; text-align:center; font-size:0.8rem; max-width:1280px; margin:0 auto; }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile-first, works on ALL devices
   iPhone SE → iPhone Pro Max → Android → Tablet → Desktop 4K
   ════════════════════════════════════════════════════════════ */

/* ── Navbar hamburger — hidden on desktop, shown on mobile ── */
.nav-menu-btn {
  display: none !important;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.nav-menu-btn:hover, .nav-menu-btn:active { background: rgba(255,255,255,0.25); }

/* ── iOS safe area support ───────────────────────────────── */
body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  overflow-x: hidden;
}
#app { overflow-x: hidden; width: 100%; }
#page { width: 100%; overflow-x: hidden; }

/* ── Prevent iOS input zoom (font must be ≥16px) ──────────── */
input, select, textarea { font-size: 16px !important; }

/* ── Scrollable containers ───────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ════ WIDE DESKTOP (≥1400px) ═══════════════════════════════ */
@media (min-width: 1400px) {
  .container, .page-layout, .nav-inner { max-width: 1400px; }
}

/* ════ TABLET LANDSCAPE / SMALL DESKTOP (769px – 1024px) ════ */
@media (min-width: 769px) and (max-width: 1024px) {
  .nav-inner { padding: 0 12px; gap: 12px; }
  .nav-link { padding: 6px 9px; font-size: 0.82rem; }
  .page-layout { grid-template-columns: 200px 1fr; padding: 16px 12px; gap: 16px; }
  .posts-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .admin-sidebar { width: 200px; }
  .stat-cards { grid-template-columns: repeat(3, 1fr); }
}

/* ════ TABLET PORTRAIT (481px – 768px) ══════════════════════ */
@media (min-width: 481px) and (max-width: 768px) {
  /* Navbar */
  .nav-inner { height: 56px; padding: 0 12px; gap: 8px; }
  .nav-search { display: none; }
  .nav-links { display: none; }
  .nav-menu-btn { display: flex !important; }

  /* Layout */
  .page-layout { grid-template-columns: 1fr; padding: 14px 12px; gap: 12px; }
  .sidebar { display: none; }
  .page-content { padding: 0; }
  .container { padding: 0 12px; }

  /* Posts */
  .posts-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .post-card { padding: 12px; }

  /* Forms */
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 12px; }
  .auth-card { padding: 24px 20px; margin: 16px; }

  /* Admin */
  .admin-layout { flex-direction: column; }
  .admin-sidebar { width: 100%; display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.1); max-height: 200px; overflow-y: auto; }
  .admin-sidebar-link { width: auto; padding: 7px 10px; font-size: 0.78rem; border-left: none !important; }
  .admin-sidebar-title { display: none; }
  .admin-content { padding: 14px; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }

  /* Messages */
  .messages-layout { grid-template-columns: 1fr; }
  .messages-sidebar { display: none; }

  /* Cat grid */
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }

  /* Location filter */
  .location-filter { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .location-filter select { min-width: 0; flex: 1; }
  .location-filter .reset-btn { margin-left: 0; }

  /* Cards */
  .card-body { padding: 14px; }

  /* Footer */
  #global-footer > div { flex-direction: column !important; gap: 10px !important; align-items: center; }
}

/* ════ MOBILE (≤480px) — Phone portrait ══════════════════════ */
@media (max-width: 480px) {
  /* Navbar */
  .nav-inner { height: 52px; padding: 0 10px; gap: 6px; }
  .nav-search { display: none; }
  .nav-links { display: none; }
  .nav-menu-btn { display: flex !important; width: 40px; height: 40px; font-size: 1.25rem; }
  .nav-logo button { padding: 0; }

  /* Core layout */
  .page-layout { grid-template-columns: 1fr; padding: 10px 10px; gap: 10px; }
  .sidebar { display: none; }
  .sidebar.mobile-open { display: block; position: fixed; top: 52px; left: 0; bottom: 0; width: 270px; z-index: 900; background: #fff; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
  .container { padding: 0 10px; }
  .page-content { padding: 0; min-width: 0; }
  #page > div > div { box-sizing: border-box; }

  /* Auth */
  .auth-card { margin: 8px; padding: 20px 14px; border-radius: 12px; }
  .auth-logo img { height: 50px; }

  /* Posts */
  .posts-grid { grid-template-columns: 1fr; gap: 10px; }
  .post-card { padding: 12px; }
  .post-card-title { font-size: 0.9rem; }

  /* Forms */
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 10px; }
  .form-group { margin-bottom: 12px; }
  .form-label { font-size: 0.82rem; }

  /* Category grid */
  .cat-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .cat-card { padding: 10px 6px; }
  .cat-card-icon { font-size: 1.3rem; }
  .cat-card-name { font-size: 0.68rem; }

  /* Filter chips */
  .filter-bar { gap: 6px; flex-wrap: wrap; }
  .filter-chip { padding: 5px 10px; font-size: 0.76rem; }

  /* Location filter */
  .location-filter { flex-wrap: wrap; gap: 6px; padding: 10px; }
  .location-filter-label { display: none; }
  .location-filter select { flex: 1; min-width: 0; font-size: 0.8rem; padding: 5px 8px; }
  .location-filter .reset-btn { margin-left: 0; font-size: 0.75rem; }

  /* Cards */
  .card { border-radius: 10px; }
  .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .card-body { padding: 12px; }
  .card-title { font-size: 0.9rem; }

  /* Buttons */
  .btn { padding: 9px 16px; font-size: 0.85rem; }
  .btn-lg { padding: 12px 20px; font-size: 0.9rem; }
  .btn-sm { padding: 5px 10px; font-size: 0.78rem; }

  /* Admin */
  .admin-layout { flex-direction: column; }
  .admin-sidebar { width: 100%; display: flex; flex-wrap: wrap; gap: 3px; padding: 6px; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.1); max-height: 150px; overflow-y: auto; }
  .admin-sidebar-link { width: auto; padding: 6px 8px; font-size: 0.73rem; border-left: none !important; }
  .admin-sidebar-title { display: none; }
  .admin-content { padding: 10px; }
  .admin-page-title { font-size: 1.15rem; }
  .admin-page-sub { font-size: 0.8rem; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* Tables - scroll horizontally */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
  table { min-width: 480px; font-size: 0.8rem; }
  th, td { padding: 8px 10px !important; }

  /* Messages */
  .messages-layout { grid-template-columns: 1fr; }
  .messages-sidebar { display: none; }

  /* Profile */
  .profile-header { flex-direction: column; align-items: center; text-align: center; gap: 12px; }

  /* Pagination */
  .pagination { gap: 4px; flex-wrap: wrap; justify-content: center; }
  .page-btn { width: 32px; height: 32px; font-size: 0.8rem; }

  /* Footer */
  #global-footer { padding: 12px 10px !important; }
  #global-footer > div { flex-direction: column !important; gap: 10px !important; align-items: center; text-align: center; }
}

/* ════ TOUCH TARGETS — all interactive elements ════════════ */
@media (max-width: 768px) {
  .sidebar-link,
  .filter-chip,
  .cat-card,
  .admin-sidebar-link,
  select { min-height: 40px; }
  .nav-link { min-height: 44px; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — All Devices
   Breakpoints: 320 | 480 | 640 | 768 | 1024 | 1280 | 1400+
   Tested: iPhone SE, iPhone 15 Pro Max, iPad, Android phones,
           Galaxy Tab, Pixel Tablet, all laptop/desktop sizes
═══════════════════════════════════════════════════════════════ */

/* ── Prevent horizontal scroll globally ───────────────────── */
html, body { max-width: 100%; overflow-x: hidden; }
#app, #page { overflow-x: hidden; max-width: 100%; }

/* ── Nav menu button (hidden on desktop, shown on mobile) ─── */
.nav-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.nav-menu-btn:hover, .nav-menu-btn:active { background: rgba(255,255,255,0.22); }

/* ── Wide desktop (≥1400px) ───────────────────────────────── */
@media (min-width: 1400px) {
  .container, .page-layout, .nav-inner { max-width: 1400px; }
  .posts-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}

/* ── Standard desktop (1025px–1399px) — no changes needed ─── */

/* ── Small laptop / large tablet landscape (769px–1024px) ─── */
@media (min-width: 769px) and (max-width: 1024px) {
  .nav-inner { padding: 0 14px; gap: 10px; }
  .nav-link { padding: 6px 8px; font-size: 0.82rem; }
  .page-layout { grid-template-columns: 200px 1fr; padding: 16px 12px; gap: 16px; }
  .admin-sidebar { width: 200px; }
  .admin-sidebar-link { padding: 8px 12px; font-size: 0.8rem; }
  .posts-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .stat-cards { grid-template-columns: repeat(3, 1fr); }
}

/* ── Tablet portrait (481px–768px) — iPad Mini, Galaxy Tab ── */
@media (min-width: 481px) and (max-width: 768px) {
  /* Navbar */
  .nav-inner { height: 56px; padding: 0 12px; gap: 8px; }
  .nav-search { display: none; }
  .nav-links { display: none; }
  .nav-menu-btn { display: flex !important; }

  /* Layout */
  .page-layout { grid-template-columns: 1fr; padding: 14px 14px; gap: 14px; }
  .sidebar { display: none; }
  .sidebar.mobile-open { top: 56px; }
  .container { padding: 0 14px; }
  .page-content { padding: 0; }

  /* Posts */
  .posts-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

  /* Forms */
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 12px; }
  .form-input, .form-select, .form-textarea { font-size: 16px !important; }
  .auth-card { margin: 16px; padding: 24px 20px; }

  /* Categories */
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }

  /* Location filter */
  .location-filter { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .location-filter select { min-width: 0; flex: 1; font-size: 15px; }
  .location-filter-label { display: none; }

  /* Admin */
  .admin-layout { flex-direction: column; }
  .admin-sidebar { width: 100%; display: flex; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 4px; padding: 8px; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.1); }
  .admin-sidebar-title { display: none; }
  .admin-sidebar-link { flex-shrink: 0; width: auto; border-left: none !important; padding: 7px 11px; font-size: 0.78rem; white-space: nowrap; border-radius: 8px; }
  .admin-content { padding: 14px; }
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Messages */
  .messages-layout { grid-template-columns: 1fr; }
  .messages-sidebar { display: none; }

  /* Footer */
  #global-footer > div { flex-direction: column !important; gap: 10px !important; align-items: center; text-align: center; }
}

/* ── Mobile phones (≤480px) — All iPhone/Android phones ────── */
@media (max-width: 480px) {
  /* Navbar */
  .nav-inner { height: 52px !important; padding: 0 10px !important; gap: 6px !important; }
  .nav-logo img { height: 32px !important; }
  .nav-search { display: none !important; }
  .nav-links { display: none !important; }
  .nav-menu-btn { display: flex !important; width: 38px; height: 38px; font-size: 1.2rem; }

  /* Layout */
  .page-layout { grid-template-columns: 1fr !important; padding: 10px !important; gap: 10px !important; }
  .sidebar { display: none !important; }
  .sidebar.mobile-open { display: block; position: fixed; top: 52px; left: 0; bottom: 0; width: 270px; z-index: 900; background: #fff; overflow-y: auto; box-shadow: 4px 0 24px rgba(0,0,0,0.2); -webkit-overflow-scrolling: touch; }
  .container { padding: 0 10px !important; }
  .page-content { padding: 0; min-width: 0; }

  /* Auth forms */
  .auth-card { margin: 8px !important; padding: 20px 14px !important; border-radius: 14px !important; }
  .auth-logo img { height: 48px; }
  .auth-divider { margin: 16px 0; }

  /* All inputs — CRITICAL: 16px prevents iOS auto-zoom */
  input, select, textarea,
  .form-input, .form-select, .form-textarea { font-size: 16px !important; }

  /* Forms */
  .form-row, .form-row-3 { grid-template-columns: 1fr !important; gap: 10px; }
  .form-group { margin-bottom: 12px; }
  .form-label { font-size: 0.82rem; }

  /* Posts */
  .posts-grid { grid-template-columns: 1fr !important; gap: 10px; }
  .post-card { padding: 12px; }

  /* Category grid — 3 columns on small phones */
  .cat-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 7px; padding: 10px 0; }
  .cat-card { padding: 10px 6px; }
  .cat-card-icon { font-size: 1.25rem; }
  .cat-card-name { font-size: 0.68rem; }

  /* Location filter — stacked */
  .location-filter { flex-direction: column !important; align-items: stretch; padding: 10px; gap: 8px; }
  .location-filter select { width: 100%; font-size: 16px !important; padding: 8px 10px; }
  .location-filter .reset-btn { align-self: flex-end; font-size: 0.78rem; }
  .location-filter-label { display: none; }
  .location-filter-icon { display: none; }

  /* Filter chips */
  .filter-bar { gap: 6px; flex-wrap: wrap; }
  .filter-chip { padding: 6px 10px; font-size: 0.76rem; min-height: 36px; }

  /* Cards */
  .card { border-radius: 10px; }
  .card-header { padding: 12px 12px; flex-wrap: wrap; gap: 8px; }
  .card-body { padding: 12px; }
  .card-title { font-size: 0.9rem; }

  /* Buttons */
  .btn { padding: 10px 16px; font-size: 0.85rem; }
  .btn-sm { padding: 6px 12px; font-size: 0.78rem; }
  .btn-lg { padding: 12px 20px; font-size: 0.9rem; }

  /* Admin */
  .admin-layout { flex-direction: column; }
  .admin-sidebar { width: 100% !important; display: flex !important; flex-wrap: nowrap !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch; gap: 3px; padding: 6px 8px; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.1); }
  .admin-sidebar-title { display: none !important; }
  .admin-sidebar-link { flex-shrink: 0 !important; width: auto !important; border-left: none !important; padding: 6px 9px; font-size: 0.72rem; white-space: nowrap; border-radius: 7px; }
  .admin-content { padding: 10px; }
  .admin-page-title { font-size: 1.1rem; margin-bottom: 4px; }
  .admin-page-sub { font-size: 0.78rem; }
  .stat-cards { grid-template-columns: 1fr 1fr !important; gap: 8px; }

  /* Tables */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
  table { min-width: 420px; font-size: 0.78rem; }
  th, td { padding: 7px 8px !important; }

  /* Messages */
  .messages-layout { grid-template-columns: 1fr !important; }
  .messages-sidebar { display: none !important; }

  /* Profile */
  .profile-header { flex-direction: column; align-items: center; text-align: center; gap: 10px; }

  /* Pagination */
  .pagination { gap: 4px; flex-wrap: wrap; justify-content: center; }
  .page-btn { width: 32px; height: 32px; font-size: 0.78rem; }

  /* Footer */
  #global-footer { padding: 14px 12px !important; }
  #global-footer > div { flex-direction: column !important; gap: 10px !important; align-items: center !important; text-align: center; }
}

/* ── Tiny phones (≤360px) — Galaxy A03, older Androids ──── */
@media (max-width: 360px) {
  .nav-inner { padding: 0 8px !important; gap: 4px !important; }
  .nav-logo img { height: 28px !important; }
  .cat-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 5px; }
  .cat-card-icon { font-size: 1.1rem; }
  .cat-card-name { font-size: 0.62rem; }
  .btn { padding: 9px 12px; font-size: 0.82rem; }
  table { min-width: 360px; font-size: 0.73rem; }
  th, td { padding: 6px 6px !important; }
}

/* ── Minimum touch targets — Apple HIG + Material Design ─── */
@media (hover: none) and (pointer: coarse) {
  button, a, select,
  .nav-link, .sidebar-link, .cat-card, .filter-chip,
  .admin-sidebar-link, .post-card { min-height: 44px; }
  .btn-sm { min-height: 40px; }
  .nav-icon-btn { min-width: 44px; min-height: 44px; }
}

/* ── iOS Safari specific ─────────────────────────────────── */
@supports (-webkit-touch-callout: none) {
  /* Fix for 100vh including iOS address bar */
  #page { min-height: -webkit-fill-available; }
  /* Smooth scrolling in containers */
  .table-wrap, .admin-sidebar, .messages-sidebar,
  .sidebar.mobile-open { -webkit-overflow-scrolling: touch; }
  /* Prevent callout on long press */
  img, button { -webkit-touch-callout: none; }
}

/* ── Android Chrome specific ─────────────────────────────── */
@media screen and (-webkit-min-device-pixel-ratio: 1.5) {
  .nav-inner { -webkit-font-smoothing: antialiased; }
  .post-card, .card { -webkit-font-smoothing: antialiased; }
}

/* ── Landscape phones ───────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 900px) {
  .nav-inner { height: 48px !important; }
  .auth-card { margin: 6px !important; padding: 16px 14px !important; }
  .auth-logo { margin-bottom: 10px !important; }
  .auth-logo img { height: 36px !important; }
}
