/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:    #374151;
    --primary-h:  #1f2937;
    --success:    #059669;
    --warning:    #d97706;
    --danger:     #dc2626;
    --bg:         #fafafa;
    --card-bg:    #ffffff;
    --text:       #111827;
    --muted:      #6b7280;
    --border:     #e5e7eb;
    --border-dark:#d1d5db;
    --radius:     8px;
    --shadow:     0 1px 2px rgba(0,0,0,.05);
    --shadow-md:  0 4px 6px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
}

body { font-family: -apple-system, 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.65; font-size: 15px; }
a    { color: var(--text); text-decoration: none; }
a:hover { color: var(--primary); }
img  { max-width: 100%; height: auto; display: block; }

/* ===== Layout ===== */
.container { max-width: 820px; margin: 0 auto; padding: 0 20px; }

/* ===== Header ===== */
.site-header { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 18px 0; }
.site-header .container { display: flex; justify-content: space-between; align-items: center; }
.site-header h1 a { font-size: 1.1rem; color: var(--text); font-weight: 600; letter-spacing: -.3px; display: inline-flex; align-items: center; gap: 8px; }
.site-header h1 a:hover { color: var(--text); }
.blog-logo { width: 32px !important; height: 32px !important; min-width: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; display: inline-block; }
.site-header nav a { margin-left: 24px; color: var(--muted); font-size: .85rem; font-weight: 500; }
.site-header nav a:hover { color: var(--text); }

/* ===== Footer ===== */
.site-footer { background: var(--card-bg); border-top: 1px solid var(--border); padding: 24px 0; margin-top: 80px; text-align: center; color: var(--muted); font-size: .82rem; }

/* ===== Blog: Post Grid ===== */
main.container { padding-top: 48px; padding-bottom: 48px; }

.post-grid { display: grid; gap: 20px; }
@media (min-width: 768px) { .post-grid { grid-template-columns: 1fr 1fr; } }

.post-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: border-color .2s, box-shadow .2s; }
.post-card:hover { border-color: var(--border-dark); box-shadow: var(--shadow-md); }
.post-thumb img { width: 100%; height: 220px; object-fit: cover; }
.post-card-body { padding: 24px 28px; }
.post-card-body h2 { font-size: 1.15rem; margin-bottom: 4px; font-weight: 600; letter-spacing: -.2px; }
.post-card-body h2 a { color: var(--text); }
.post-card-body h2 a:hover { color: var(--primary-h); }
.post-card-body time { font-size: .78rem; color: var(--muted); display: block; margin-bottom: 12px; }
.post-card-body p { color: var(--muted); font-size: .9rem; margin-bottom: 18px; line-height: 1.6; }

/* ===== Blog: Single Post ===== */
.post-single { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 48px; }
.post-header { margin-bottom: 36px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.post-header h1 { font-size: 1.75rem; margin-bottom: 8px; font-weight: 700; letter-spacing: -.4px; color: var(--text); }
.post-header time { color: var(--muted); font-size: .85rem; }
.post-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 10px; margin-bottom: 32px; }
.post-gallery a img { border-radius: 6px; height: 160px; object-fit: cover; transition: opacity .2s; border: 1px solid var(--border); }
.post-gallery a:hover img { opacity: .8; }
.post-content { font-size: 1rem; line-height: 1.85; color: #374151; margin-bottom: 36px; }

/* Auto-Links */
.auto-link { display: inline-flex; align-items: center; gap: 4px; color: #2563eb; background: #eff6ff; padding: 2px 8px; border-radius: 4px; font-size: .88rem; word-break: break-all; transition: all .15s; border: 1px solid #bfdbfe; }
.auto-link:hover { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.click-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; font-size: .7rem; font-weight: 600; background: #2563eb; color: #fff; border-radius: 9px; line-height: 1; }

.post-downloads { border-top: 1px solid var(--border); padding-top: 28px; }
.post-downloads h3 { margin-bottom: 16px; font-size: 1rem; font-weight: 600; }
.download-btn { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; transition: all .15s; }
.download-btn:hover { background: #f3f4f6; border-color: var(--border-dark); }
.download-btn .icon { font-size: 1.2rem; }
.download-btn strong { display: block; color: var(--text); font-size: .9rem; }
.download-btn small { color: var(--muted); font-size: .78rem; }

/* ===== Pagination ===== */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 48px; }
.pagination a { padding: 8px 14px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: .85rem; font-weight: 500; }
.pagination a.active { background: var(--text); color: #fff; border-color: var(--text); }
.pagination a:hover:not(.active) { background: #f3f4f6; border-color: var(--border-dark); }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; background: var(--text); color: #fff; border: 1px solid var(--text); border-radius: 6px; cursor: pointer; font-size: .85rem; font-weight: 500; transition: all .15s; }
.btn:hover { background: var(--primary-h); border-color: var(--primary-h); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-secondary { background: var(--card-bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f3f4f6; border-color: var(--border-dark); color: var(--text); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: #fef2f2; border-color: var(--danger); }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: .9rem; }

/* ===== Alerts ===== */
.alert { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 20px; font-size: .88rem; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert p { margin: 4px 0; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-state h2 { margin-bottom: 12px; font-weight: 600; color: var(--text); }

/* ===== Login Page ===== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-box { background: var(--card-bg); padding: 40px; border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 360px; }
.login-box h2 { text-align: center; margin-bottom: 32px; font-size: 1.2rem; font-weight: 600; }

/* ===== Forms ===== */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 6px; font-size: .9rem; font-family: inherit; background: #fff; color: var(--text); transition: border-color .15s; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: #9ca3af; box-shadow: 0 0 0 3px rgba(156,163,175,.15); }
.form-group textarea { resize: vertical; min-height: 200px; }
.form-group small { display: block; margin-top: 5px; color: var(--muted); font-size: .78rem; }
.form-group.inline { display: flex; align-items: center; gap: 12px; }
.form-group.inline label { margin: 0; white-space: nowrap; }
.form-group.inline select { width: auto; }

/* ===== Upload Area ===== */
.upload-area { position: relative; border: 2px dashed var(--border); border-radius: var(--radius); transition: border-color .15s; }
.upload-area:hover { border-color: #9ca3af; }
.upload-area input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-label { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; cursor: pointer; gap: 6px; }
.upload-icon { font-size: 1.8rem; opacity: .5; }
.upload-label span { font-size: .88rem; color: var(--muted); }
.upload-label small { color: #9ca3af; font-size: .78rem; }
.file-preview { margin-top: 10px; }
.file-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; margin-top: 6px; font-size: .85rem; }
.file-item small { color: var(--muted); margin-left: auto; }

/* ===== Admin Layout ===== */
.admin-body { background: #f3f4f6; }
.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar { width: 200px; min-height: 100vh; background: #111827; flex-shrink: 0; }
.sidebar-brand { padding: 20px 18px; font-weight: 600; color: #f9fafb; font-size: .9rem; border-bottom: 1px solid #1f2937; letter-spacing: -.2px; display: flex; align-items: center; gap: 8px; }
.blog-logo-sm { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.sidebar-nav { padding: 12px 0; }
.sidebar-nav a { display: flex; align-items: center; gap: 8px; padding: 10px 18px; color: #9ca3af; font-size: .84rem; transition: all .15s; }
.sidebar-nav a:hover { background: #1f2937; color: #f9fafb; text-decoration: none; }
.sidebar-nav a.active { background: #374151; color: #fff; }
.sidebar-nav a.logout { color: #f87171; }
.sidebar-nav a.logout:hover { background: #7f1d1d; color: #fff; }

.admin-content { flex: 1; padding: 32px; overflow-x: auto; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.admin-header h1 { font-size: 1.3rem; color: var(--text); font-weight: 600; letter-spacing: -.3px; }
.admin-header span { color: var(--muted); font-size: .85rem; }

/* ===== Stats ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card.green  { border-left: 3px solid var(--success); }
.stat-card.yellow { border-left: 3px solid var(--warning); }
.stat-card.blue   { border-left: 3px solid #6b7280; }
.stat-num { font-size: 1.8rem; font-weight: 700; color: var(--text); letter-spacing: -.5px; }
.stat-label { font-size: .78rem; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .3px; }

/* ===== Admin Cards ===== */
.admin-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; }
.admin-card h2 { font-size: 1rem; margin-bottom: 18px; font-weight: 600; }
.admin-card h3 { font-size: .9rem; margin-bottom: 16px; color: var(--muted); font-weight: 600; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.card-header h2 { margin: 0; }

/* ===== Admin Table ===== */
.admin-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.admin-table th { text-align: left; padding: 10px 12px; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); font-weight: 600; }
.admin-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border: none; }
.admin-table tr:hover td { background: #f9fafb; }
.actions { display: flex; gap: 6px; }
.empty { color: var(--muted); padding: 20px 0; text-align: center; font-size: .9rem; }

/* ===== Badges ===== */
.badge { padding: 3px 10px; border-radius: 20px; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.badge-green  { background: #ecfdf5; color: #065f46; }
.badge-yellow { background: #fffbeb; color: #92400e; }

/* ===== Form Footer ===== */
.form-footer { display: flex; justify-content: space-between; align-items: center; }
.form-actions { display: flex; gap: 10px; }

/* ===== Existing Files ===== */
.existing-files { display: flex; flex-direction: column; gap: 8px; }
.existing-file { display: flex; align-items: center; gap: 14px; padding: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.existing-file img { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.zip-icon { font-size: 1.6rem; opacity: .6; }
.file-info { flex: 1; }
.file-info span { font-size: .88rem; font-weight: 500; }
.file-info small { color: var(--muted); font-size: .78rem; display: block; margin-top: 2px; }

/* ===== Info List ===== */
.info-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.info-list li { padding: 10px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; font-size: .85rem; }
.info-list code { background: #e5e7eb; padding: 2px 6px; border-radius: 3px; font-size: .82rem; font-family: 'SF Mono', monospace; }
.hint { color: var(--muted); font-size: .82rem; margin-bottom: 18px; }

/* ===== Blog Hero ===== */
.blog-hero { background: #111827; color: #f9fafb; padding: 56px 0; }
.blog-hero .hero-content { max-width: 640px; font-size: 1rem; line-height: 1.8; color: #d1d5db; }
.blog-hero .hero-content h2 { font-size: 1.5rem; margin-bottom: 10px; color: #fff; font-weight: 600; letter-spacing: -.3px; }

/* ===== Footer Links ===== */
.footer-links { margin-top: 10px; display: flex; gap: 24px; justify-content: center; }
.footer-links a { color: var(--muted); font-size: .82rem; transition: color .15s; }
.footer-links a:hover { color: var(--text); }

/* ===== Modal ===== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(3px); }
.modal-overlay.show { display: flex; }

/* Image Lightbox Modal */
.image-modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 2000; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(6px); cursor: zoom-out; }
.image-modal-overlay.show { display: flex; }
.image-modal-img { max-width: 90vw; max-height: 90vh; border-radius: 6px; box-shadow: 0 8px 40px rgba(0,0,0,.5); cursor: default; animation: modalIn .15s ease; }
.image-modal-close { position: fixed; top: 16px; right: 20px; background: none; border: none; color: #fff; font-size: 2.2rem; cursor: pointer; z-index: 2001; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: background .15s; }
.image-modal-close:hover { background: rgba(255,255,255,.15); }
.image-modal-nav { position: fixed; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.1); border: none; color: #fff; font-size: 1.6rem; cursor: pointer; z-index: 2001; width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.image-modal-nav:hover { background: rgba(255,255,255,.25); }
.image-modal-prev { left: 16px; }
.image-modal-next { right: 16px; }
.modal { background: var(--card-bg); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.15); width: 100%; max-width: 620px; max-height: 85vh; display: flex; flex-direction: column; animation: modalIn .15s ease; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-header h2 { font-size: 1.05rem; margin: 0; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--muted); width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; font-size: .9rem; line-height: 1.85; color: #4b5563; }

/* ===== Settings Tabs ===== */
.settings-tabs { display: flex; gap: 0; margin-bottom: 24px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.settings-tabs a { flex: 1; padding: 13px 20px; text-align: center; color: var(--muted); font-weight: 600; font-size: .84rem; transition: all .15s; border-bottom: 2px solid transparent; }
.settings-tabs a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.settings-tabs a.active { color: var(--text); border-bottom-color: var(--text); background: var(--bg); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Contact Page ===== */
.contact-page { text-align: center; }
.contact-page h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 8px; letter-spacing: -.4px; }
.contact-intro { color: var(--muted); font-size: .95rem; margin-bottom: 36px; }
.contact-links { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }
.contact-card { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 32px 40px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); transition: border-color .2s, box-shadow .2s, transform .15s; min-width: 160px; }
.contact-card:hover { border-color: var(--border-dark); box-shadow: var(--shadow-md); transform: translateY(-2px); color: var(--text); }
.contact-icon { color: var(--muted); transition: color .2s; }
.contact-card:hover .contact-icon { color: var(--text); }
.contact-label { font-size: .95rem; font-weight: 600; color: var(--text); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-sidebar { display: none; }
    .post-single { padding: 28px; }
    .form-footer { flex-direction: column; gap: 14px; align-items: flex-start; }
    .category-filter { flex-wrap: wrap; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .post-card-body { padding: 20px; }
}

/* ===== Categories ===== */
.category-filter { display: flex; gap: 8px; margin-bottom: 28px; flex-wrap: wrap; }
.cat-tag { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 20px; font-size: .82rem; font-weight: 500; color: var(--muted); transition: all .15s; }
.cat-tag:hover { border-color: var(--border-dark); color: var(--text); background: #f3f4f6; }
.cat-tag.active { background: var(--text); color: #fff; border-color: var(--text); }
.cat-tag.active .cat-count { background: rgba(255,255,255,.2); color: #fff; }
.cat-count { font-size: .7rem; background: var(--bg); padding: 1px 6px; border-radius: 10px; color: var(--muted); }
.cat-badge { display: inline-block; padding: 3px 10px; background: #f3f4f6; border: 1px solid var(--border); border-radius: 4px; font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 8px; transition: all .15s; }
.cat-badge:hover { background: #e5e7eb; color: var(--text); }
.badge-cat { background: #f0f4ff; color: #3b5998; border: none; }
.filter-heading { font-size: 1.1rem; font-weight: 600; margin-bottom: 20px; color: var(--text); }