:root {
  --bg: #0f1220;
  --surface: #ffffff;
  --ink: #1a1d2e;
  --muted: #6b7280;
  --line: #e6e8ef;
  --accent: #5b6cff;
  --accent-dark: #4453e6;
  --soft: #f5f6fb;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(20, 24, 60, 0.08);
  --font: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--soft);
  line-height: 1.6;
}

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

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 66px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}
.brand-name { font-size: 18px; }
.main-nav { display: flex; gap: 8px; }
.main-nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
}
.main-nav a:hover { background: var(--soft); color: var(--ink); }
.main-nav a.active { color: var(--accent); }

/* Hero */
.hero {
  background: linear-gradient(135deg, #141833, #2a2160);
  color: #fff;
  padding: 64px 0;
  text-align: center;
}
.hero h1 { font-size: 42px; margin-bottom: 12px; letter-spacing: -0.5px; }
.hero p { font-size: 18px; opacity: 0.85; max-width: 620px; margin: 0 auto; }

/* Posts */
.main-content { padding: 48px 20px 64px; }
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}
.post-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  display: flex;
  flex-direction: column;
}
.post-card:hover { transform: translateY(-3px); box-shadow: 0 14px 40px rgba(20,24,60,0.14); }
.post-card .topic {
  display: inline-block;
  align-self: flex-start;
  margin: 20px 20px 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: #eef0ff;
  padding: 4px 10px;
  border-radius: 999px;
}
.post-card h2 { font-size: 21px; margin: 14px 20px 8px; line-height: 1.3; }
.post-card .excerpt { color: var(--muted); margin: 0 20px 16px; flex: 1; }
.post-card .meta { color: #9aa0b4; font-size: 13px; margin: 0 20px 20px; }
.post-card a.read {
  margin: 0 20px 22px;
  align-self: flex-start;
  text-decoration: none;
  color: var(--accent-dark);
  font-weight: 700;
}
.post-card a.read:hover { text-decoration: underline; }

.loading, .empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

/* Article page */
.article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 44px;
  max-width: 760px;
  margin: 40px auto;
}
.article .topic {
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 13px;
}
.article h1 { font-size: 34px; margin: 10px 0 12px; line-height: 1.2; }
.article .meta { color: #9aa0b4; font-size: 14px; margin-bottom: 28px; }
.article .body { font-size: 17px; color: #2b2f45; }
.article .body p { margin-bottom: 18px; }
.article .body h2 { font-size: 25px; margin: 30px 0 12px; }
.article .body h3 { font-size: 20px; margin: 24px 0 10px; }
.article .body ul, .article .body ol { margin: 0 0 18px 24px; }
.article .body img { max-width: 100%; border-radius: 10px; margin: 10px 0; }
.article .body a { color: var(--accent-dark); }
.back-link {
  display: inline-block;
  margin: 30px auto 0;
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 26px 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* Admin */
.admin-wrap { padding: 40px 20px 64px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 400px;
  margin: 50px auto;
  padding: 36px;
}
.auth-card h2 { font-size: 24px; margin-bottom: 6px; }
.auth-card p.sub { color: var(--muted); margin-bottom: 22px; font-size: 15px; }

label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
input, textarea, select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 15px;
  font-family: var(--font);
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 260px; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.btn {
  display: inline-block;
  border: none;
  border-radius: 9px;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  background: var(--accent);
  color: #fff;
  transition: background 0.15s;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: #eceef6; color: var(--ink); }
.btn.secondary:hover { background: #dfe2ef; }
.btn.ghost { background: transparent; color: var(--accent-dark); padding: 8px 12px; }
.btn.danger { background: #fdecec; color: #d13438; }
.btn.danger:hover { background: #f9d7d7; }
.btn.full { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

.msg { margin-top: 14px; font-size: 14px; min-height: 18px; }
.msg.error { color: #d13438; }
.msg.ok { color: #1a8f4c; }

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.admin-header h1 { font-size: 28px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 26px;
}
.panel h3 { font-size: 18px; margin-bottom: 4px; }
.panel .hint { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

.topic-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #eef0ff;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
  font-size: 14px;
}
.topic-chip button {
  border: none;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form > div { flex: 1; min-width: 180px; }

.status-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-badge.published { background: #e3f7ea; color: #1a8f4c; }
.status-badge.draft { background: #fdf1dc; color: #b7791f; }

.post-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.post-row:last-child { border-bottom: none; }
.post-row .info { flex: 1; min-width: 220px; }
.post-row .info h4 { font-size: 16px; margin-bottom: 2px; }
.post-row .info small { color: var(--muted); }
.post-row .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.ai-box {
  background: var(--soft);
  border: 1px dashed #c7cbe0;
  border-radius: 10px;
  padding: 16px;
  margin: 16px 0;
}
.ai-box .inline-form { align-items: stretch; }

.hidden { display: none !important; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 620px) {
  .grid-2 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 32px; }
  .article { padding: 26px; }
}
