:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #7b8794;
  --accent: #2b6cb0;
  --accent-dark: #1f4e7a;
  --border: #e2e8f0;
  --light-tag: #9aa5b1;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 6px 18px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; }
.logo { display: flex; align-items: center; gap: 12px; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo-text { display: flex; flex-direction: column; font-weight: 700; font-size: 1.25rem; line-height: 1.1; }
.logo-text small { font-weight: 400; font-size: .72rem; color: var(--muted); }
.main-nav { display: flex; align-items: center; gap: 18px; }
.main-nav a { color: var(--text); font-weight: 500; }
.main-nav a.active { color: var(--accent); }

main.container { padding-top: 28px; padding-bottom: 48px; min-height: 60vh; }

/* Hero */
.hero { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; padding: 48px 36px; border-radius: var(--radius); margin-bottom: 36px; }
.hero h1 { margin: 0 0 10px; font-size: 2rem; }
.hero p { margin: 0 0 20px; max-width: 60ch; opacity: .95; }

/* Buttons */
.btn { display: inline-block; background: var(--accent); color: #fff; padding: 10px 20px; border-radius: 8px; border: none; font-size: 1rem; cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.hero .btn { background: #fff; color: var(--accent-dark); }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 1rem; font-family: inherit; }
.link-btn.danger { color: #c0392b; }
.inline-form { display: inline; }

/* Sections */
.section-title { font-size: 1.4rem; margin: 0 0 18px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }
.home-section { margin-bottom: 40px; }
.home-columns { display: grid; grid-template-columns: 2fr 1fr; gap: 36px; }
.home-aside { }

/* Grid + cards */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-title { margin: 0 0 8px; font-size: 1.15rem; }
.card-desc { margin: 0 0 12px; color: #52606d; }
.card-meta { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-bottom: 10px; }

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags .tag { font-size: .82rem; }
.tags-light .tag { color: var(--light-tag); font-weight: 400; }
.tags-light .tag:hover { color: var(--accent); }
.post-tags { margin: 28px 0; align-items: center; }
.tags-label { color: var(--light-tag); font-size: .82rem; margin-right: 4px; }

/* Popular ranking */
.rank-list { list-style: none; counter-reset: rank; padding: 0; margin: 0; }
.rank-list li { counter-increment: rank; display: flex; align-items: baseline; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.rank-list li::before { content: counter(rank); font-weight: 700; color: var(--accent); min-width: 22px; }
.rank-views { margin-left: auto; font-size: .78rem; color: var(--muted); white-space: nowrap; }

/* Post */
.post { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; box-shadow: var(--shadow); max-width: 820px; margin: 0 auto 32px; }
.post-header h1 { margin: 0 0 10px; font-size: 2rem; }
.post-meta { display: flex; gap: 16px; color: var(--muted); font-size: .85rem; margin-bottom: 24px; }
.post-body { font-size: 1.06rem; }
.post-body p { margin: 0 0 18px; }

/* Related */
.related { margin-top: 32px; padding: 20px 24px; background: #eef3f9; border-radius: var(--radius); border-left: 4px solid var(--accent); }
.related h2 { margin: 0 0 12px; font-size: 1.1rem; }
.related ul { margin: 0; padding-left: 18px; }
.related li { margin-bottom: 6px; }

/* Comments */
.comments { max-width: 820px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.comments h2 { margin-top: 0; }
.comment-form { display: grid; gap: 14px; margin-bottom: 28px; max-width: 520px; }
.comment-list { list-style: none; padding: 0; margin: 0; }
.comment { padding: 16px 0; border-top: 1px solid var(--border); }
.comment-head { display: flex; gap: 12px; align-items: baseline; }
.comment-date { font-size: .78rem; color: var(--muted); }
.comment p { margin: 6px 0 0; white-space: pre-wrap; }

/* Forms */
label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=password], textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 1rem; font-family: inherit; margin-top: 4px; font-weight: 400;
}
textarea { resize: vertical; }
.stack-form { display: grid; gap: 18px; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; font-weight: 400; }
.checkbox-row input { width: auto; margin: 0; }
.seo-fields { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.seo-fields legend { font-weight: 700; padding: 0 8px; }
.seo-fields label { margin-top: 12px; }
.seo-fields label:first-of-type { margin-top: 0; }

.auth-box { max-width: 380px; margin: 40px auto; background: var(--surface); padding: 32px; border-radius: var(--radius); box-shadow: var(--shadow); }
.auth-box h1 { margin-top: 0; }
.article-form { max-width: 760px; }

/* Admin table */
.admin-head { display: flex; align-items: center; justify-content: space-between; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.admin-table th, .admin-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { background: #eef3f9; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.row-actions { display: flex; gap: 14px; }

/* Misc */
.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0 0 4px; }
.accent { color: var(--accent); }
.muted { color: var(--muted); }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.alert-ok { background: #e6f4ea; color: #1e7e34; }
.alert-err { background: #fdecea; color: #c0392b; }

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: .9rem; }

/* Responsive */
@media (max-width: 860px) {
  .home-columns { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; gap: 10px; }
  .hero { padding: 32px 20px; }
  .post, .comments { padding: 22px; }
}
