:root {
  --page-bg: #f8f9fa;
  --surface: #ffffff;
  --surface-muted: #f3f4f6;
  --navy: #0f172a;
  --navy-light: #1e293b;
  --text: #333333;
  --muted: #667085;
  --border: #e5e7eb;
  --shadow: 0 2px 14px rgba(15, 23, 42, .07);
  --content-width: 1200px;
}

* { box-sizing: border-box; }
html { background: var(--page-bg); }
body { margin: 0; min-width: 320px; background: var(--page-bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.7; }
a { color: inherit; text-decoration: none; outline: none; border: none; }
a:hover { color: #475569; }
a:focus { outline: none; border: none; }
img { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.container { width: min(var(--content-width), calc(100% - 40px)); margin: 0 auto; padding: 0 20px; }

/* Public shell */
.site-header { background: var(--navy); color: #ffffff; border-bottom: 1px solid #243247; }
.site-header-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 28px; min-height: 72px; }
.brand { color: #ffffff; font-size: 1.25rem; font-weight: 800; letter-spacing: .01em; }
.brand:hover { color: #ffffff; }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; color: #dbe1ea; font-size: .92rem; }
.site-nav a { color: #dbe1ea; }
.site-nav a:hover { color: #ffffff; }
.site-search { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.site-search input { width: 150px; margin: 0; padding: 6px 9px; color: #111827; background: #ffffff; border: 1px solid #cbd5e1; border-radius: 5px; font-size: .82rem; }
.site-search button { padding: 6px 10px; color: #ffffff; background: var(--navy-light); border: 1px solid #64748b; border-radius: 5px; font-size: .82rem; }
.site-search button:hover { background: #334155; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.page-content { padding-top: 48px; padding-bottom: 48px; }
.site-footer { margin-top: 64px; background: #f3f4f6; border-top: 1px solid var(--border); color: var(--muted); font-size: .875rem; text-align: center; }
.footer-inner { padding-top: 32px; padding-bottom: 32px; }
.site-footer p { margin: 0 0 6px; }
.footer-nav { display: flex; justify-content: center; gap: 18px; margin-top: 14px; }
.footer-nav a { color: #475569; }
.footer-nav a:hover { color: var(--navy); }

/* Homepage */
.home-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; gap: 40px; }
.section-heading { margin-bottom: 28px; padding: 4px 0 18px 18px; border-left: 6px solid var(--navy); border-bottom: 1px solid #e5e7eb; }
.section-heading h1 { margin: 8px 0 0; color: #111827; font-size: clamp(2rem, 4vw, 2.7rem); font-weight: 800; line-height: 1.18; }
.eyebrow { margin: 0; color: var(--navy); font-size: .78rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.post-list { display: grid; gap: 28px; }
.post-card { display: grid; grid-template-columns: 40% 60%; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.post-card-media { min-height: 190px; background: #e5e7eb; }
.post-card-media img { width: 100%; height: 100%; object-fit: cover; }
.post-card-placeholder { width: 100%; height: 100%; min-height: 190px; background: linear-gradient(135deg, #e5e7eb, #cbd5e1); }
.post-card-body { padding: 24px; }
.post-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--navy); font-size: .78rem; font-weight: 700; }
.post-meta time { color: var(--muted); font-weight: 400; }
.post-card h2 { margin: 10px 0 0; color: #111827; font-size: 1.45rem; line-height: 1.3; }
.post-card h2 a:hover { color: #475569; }
.post-excerpt { margin: 12px 0 0; color: var(--muted); line-height: 1.65; }
.post-byline { margin: 18px 0 0; color: #8490a0; font-size: .82rem; }
.popular-panel { padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.popular-panel h2 { margin: 0; color: #111827; font-size: 1.15rem; line-height: 1.3; }
.popular-panel ol { display: grid; gap: 18px; margin: 20px 0 0; padding: 0; list-style: none; }
.popular-panel li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; align-items: start; }
.popular-panel .rank { color: var(--navy); font-size: 1.35rem; font-weight: 800; line-height: 1.2; }
.popular-panel li a { color: #374151; font-size: .95rem; font-weight: 700; line-height: 1.45; }
.popular-panel li a:hover { color: #475569; }
.popular-panel li p { margin: 3px 0 0; color: var(--muted); font-size: .75rem; }
.empty-state { display: grid; min-height: 300px; place-items: center; align-content: center; gap: 16px; padding: 40px 24px; color: var(--muted); background: var(--surface); border: 1px solid #e5e7eb; border-radius: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, .05); text-align: center; word-break: normal; white-space: normal; }
.empty-state-icon { width: 96px; height: 96px; }
.empty-state p { max-width: 30rem; margin: 0; font-size: 1rem; }
.popular-panel .sidebar-empty-state { display: block; min-height: 0; padding: 18px 0 0; background: transparent; border: 0; border-radius: 0; box-shadow: none; color: var(--muted); text-align: left; word-break: normal; white-space: normal; }
.sidebar-stack { display: grid; gap: 20px; }
.sidebar-card, .authority-card { padding: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.sidebar-card h2, .authority-card h2 { margin: 0; color: #111827; font-size: 1.08rem; line-height: 1.3; }
.latest-links { display: grid; gap: 14px; margin: 18px 0 0; padding: 0; list-style: none; }
.latest-links li { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.latest-links li:last-child { padding-bottom: 0; border-bottom: 0; }
.latest-links a { color: #374151; font-size: .9rem; font-weight: 700; line-height: 1.5; }
.latest-links a:hover { color: var(--navy); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.tag-cloud a { padding: 5px 10px; color: #475569; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 999px; font-size: .78rem; }
.tag-cloud a:hover { color: #ffffff; background: var(--navy); border-color: var(--navy); }
.tag-link { text-decoration: none; }
.authority-card { background: #f3f4f6; }
.authority-card p { margin: 12px 0 16px; color: #4b5563; font-size: .88rem; line-height: 1.7; }
.authority-card a { color: var(--navy); font-size: .86rem; font-weight: 700; }
.author-list { display: grid; gap: 12px; margin-top: 16px; }
.author-chip { display: flex; align-items: center; gap: 10px; color: #374151; font-size: .9rem; font-weight: 700; }
.author-chip:hover { color: var(--navy); }
.author-chip img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.author-page { max-width: 960px; margin: 0 auto; }
.author-profile { display: flex; align-items: center; gap: 24px; margin-bottom: 42px; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.author-profile img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; }
.author-profile h1 { margin: 8px 0 10px; color: #111827; font-size: 2rem; }
.author-profile p:last-child { margin: 0; color: var(--muted); line-height: 1.7; }
.author-articles h2 { margin: 8px 0 0; color: #111827; font-size: 2rem; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 32px; color: var(--muted); font-size: .9rem; }
.pagination a { padding: 8px 12px; color: #ffffff; background: var(--navy); border-radius: 5px; }
.pagination a:hover { color: #ffffff; background: var(--navy-light); }

/* Article content */
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; gap: 40px; }
.article-page { max-width: none; margin: 0; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; color: var(--muted); font-size: .85rem; }
.breadcrumbs a { color: var(--navy); }
.breadcrumbs a:hover { color: var(--navy-light); }
.breadcrumb-current { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.article-header { padding-bottom: 30px; border-bottom: 1px solid var(--border); }
.article-header h1 { margin: 10px 0 0; color: #111827; font-size: clamp(2.25rem, 5vw, 3.4rem); font-weight: 800; line-height: 1.18; }
.update-time { margin: 12px 0 0; color: var(--navy); font-size: .9rem; font-weight: 700; }
.article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 22px; color: var(--muted); font-size: .88rem; }
.article-meta img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.article-page .prose { max-width: none; margin-top: 28px; }
.data-card { margin-top: 26px; padding: 18px 20px; color: #123b70; background: #eff6ff; border: 2px solid #1d4e89; border-radius: 8px; font-size: 1rem; line-height: 1.7; }
.risk-notice { margin: 34px 0; padding: 16px 18px; color: #7f1d1d; background: #fef2f2; border: 1px solid #fecaca; border-radius: 7px; font-size: .9rem; }
.static-page { padding: 36px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.text-link { color: var(--navy); font-weight: 700; }
.contact-form { display: grid; gap: 18px; margin-top: 30px; }
.form-note { margin: 0; color: var(--muted); font-size: .85rem; }
.prose { max-width: 860px; margin: 0 auto; color: var(--text); font-size: 1.08rem; line-height: 1.8; }
.prose h1, .prose h2, .prose h3 { margin: 1.8em 0 .7em; color: #111827; font-weight: 800; line-height: 1.3; }
.prose h1 { font-size: 2.15rem; }
.prose h2 { font-size: 1.6rem; }
.prose p { margin: 1.2em 0; }
.prose img { margin: 28px auto; border-radius: 8px; }
.prose table { width: 100%; margin: 28px 0; border-collapse: collapse; background: var(--surface); text-align: center; }
.prose th, .prose td { padding: 11px 14px; border: 1px solid var(--border); text-align: center; vertical-align: middle; }
.prose th { background: var(--surface-muted); color: #1f2937; font-weight: 700; }
.ad-slot { min-height: 12px; }

/* Admin shell */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar { position: fixed; inset: 0 auto 0 0; width: 256px; padding: 24px; background: var(--navy); color: #ffffff; border-right: 1px solid #243247; }
.admin-sidebar .brand { color: #ffffff; }
.admin-sidebar .brand span { color: #cbd5e1; }
.admin-nav { display: grid; gap: 8px; margin-top: 40px; }
.admin-nav a { padding: 12px 14px; border-radius: 7px; color: #ffffff; }
.admin-nav a:hover { background: var(--navy-light); color: #ffffff; }
.admin-main { width: 100%; margin-left: 256px; padding: 40px; color: var(--text); }
.admin-main h1 { margin: 0; color: #111827; font-size: 2rem; font-weight: 800; line-height: 1.2; }
.admin-main h1 + * { margin-top: 28px; }
.admin-main table { width: 100%; border-collapse: collapse; background: var(--surface); box-shadow: var(--shadow); }
.admin-main th, .admin-main td { padding: 14px 18px; border: 1px solid var(--border); text-align: center; }
.admin-main th { background: var(--surface-muted); color: #374151; font-weight: 700; }
.admin-main td { color: #4b5563; }
.admin-main td:first-child { color: #111827; font-weight: 600; text-align: left; }
.form-stack { display: grid; gap: 24px; max-width: 960px; margin-top: 32px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
label { display: block; color: #374151; font-size: .9rem; }
input, select, textarea { display: block; width: 100%; margin-top: 8px; padding: 11px 13px; color: var(--text); background: #ffffff; border: 1px solid #d1d5db; border-radius: 7px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #64748b; outline-offset: 1px; }
.button, button { padding: 11px 18px; border: 0; border-radius: 7px; }
.primary { width: fit-content; color: #ffffff; background: var(--navy); font-weight: 700; }
.primary:hover, .login-card button:hover { color: #ffffff; background: var(--navy-light); }
.editor-toolbar { display: flex; gap: 6px; margin-top: 8px; padding: 8px; background: var(--surface-muted); border: 1px solid #d1d5db; border-bottom: 0; border-radius: 7px 7px 0 0; }
.editor-toolbar button { padding: 5px 10px; color: var(--navy); background: #ffffff; border: 1px solid var(--border); }
.editor { min-height: 320px; padding: 16px; color: var(--text); background: #ffffff; border: 1px solid #d1d5db; border-radius: 0 0 7px 7px; line-height: 1.8; }
.editor h2 { margin: 1em 0 .5em; font-size: 1.5rem; }
.editor p { margin: .8em 0; }
.success { color: #166534; }
.error { color: #b91c1c; }
.hidden { display: none; }

/* Admin login */
.login-shell { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: min(100%, 390px); padding: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.login-card h1 { margin: 12px 0 28px; color: #111827; font-size: 1.6rem; }
.login-card form { display: grid; gap: 18px; }
.login-card button { width: 100%; color: #ffffff; background: var(--navy); font-weight: 700; }
.login-card p { margin: 0; }
.login-card .text-sky-400 { color: var(--navy); font-size: .8rem; letter-spacing: .2em; text-transform: uppercase; }

@media (max-width: 820px) {
  .home-layout { grid-template-columns: 1fr; }
  .article-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; width: 100%; padding: 16px; }
  .admin-layout { display: block; }
  .admin-nav { display: flex; flex-wrap: wrap; margin-top: 16px; }
  .admin-nav a { padding: 8px 10px; }
  .admin-main { margin-left: 0; padding: 24px 16px; }
}
@media (max-width: 620px) {
  .container { width: calc(100% - 24px); padding: 0 12px; }
  .site-header-inner { gap: 14px; }
  .page-content { padding-top: 32px; padding-bottom: 32px; }
  .post-card { grid-template-columns: 1fr; }
  .site-search { width: 100%; margin-left: 0; }
  .site-search input { flex: 1; width: auto; }
  .author-profile { align-items: flex-start; flex-direction: column; }
  .post-card-media, .post-card-placeholder { min-height: 160px; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-main { overflow-x: auto; }
  .admin-main table { min-width: 650px; }
}
