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

:root {
  --bg:       #0d0f14;
  --surface:  #161922;
  --border:   #252a3a;
  --text:     #dde3f0;
  --muted:    #5a6278;
  --accent:   #7b9cff;
  --green:    #3ecf72;
  --red:      #ff5c5c;
  --yellow:   #f5a623;
  --radius:   12px;
  --max:      780px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

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

/* ── Шапка ── */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(13,15,20,.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -.3px; flex-shrink: 0; }
.logo:hover { text-decoration: none; color: var(--accent); }

.site-nav { display: flex; align-items: center; gap: 16px; flex-wrap: nowrap; overflow: hidden; }
.site-nav a { font-size: 14px; color: var(--muted); transition: color .2s; white-space: nowrap; }
.site-nav a:hover { color: var(--text); text-decoration: none; }
.nav-crm  { color: var(--accent) !important; }
.nav-exit { color: var(--muted) !important; font-size: 13px; }

.nav-dot {
  font-size: 22px;
  color: var(--border) !important;
  line-height: 1;
  transition: color .3s;
  user-select: none;
}
.nav-dot:hover { color: var(--muted) !important; }

/* ── Флэш ── */
.flash { text-align: center; padding: 10px 20px; font-size: 14px; }
.flash-ok    { background: rgba(62,207,114,.12); color: var(--green); }
.flash-error { background: rgba(255,92,92,.12);  color: var(--red);   }
.flash-info  { background: rgba(123,156,255,.12);color: var(--accent); }

/* ── Теги ── */
.tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 20px;
  background: rgba(123,156,255,.1);
  color: var(--accent);
  border: 1px solid rgba(123,156,255,.25);
  white-space: nowrap;
}

/* ── Время чтения ── */
.read-time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Блог ── */
.blog-index { max-width: var(--max); margin: 0 auto; padding: 48px 24px; flex: 1; width: 100%; }

.blog-hero { margin-bottom: 48px; }
.blog-hero h1 { font-size: 32px; font-weight: 700; margin-bottom: 8px; }
.blog-hero p  { color: var(--muted); font-size: 16px; }

.post-grid { display: flex; flex-direction: column; gap: 16px; }

.post-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--text);
  transition: border-color .2s, transform .15s;
}
.post-card:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }

.post-card-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.post-date { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.post-title { font-size: 20px; font-weight: 600; margin-bottom: 10px; line-height: 1.3; }
.post-excerpt { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 14px; }
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.empty-blog { color: var(--muted); font-size: 15px; margin-top: 24px; }

/* ── Статья ── */
.post-page { max-width: var(--max); margin: 0 auto; padding: 48px 24px; flex: 1; width: 100%; }
.post-meta { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.back-link { color: var(--muted); }
.back-link:hover { color: var(--text); text-decoration: none; }
.post-page h1 { font-size: 28px; font-weight: 700; line-height: 1.3; margin-bottom: 20px; }

.post-tags-header { margin-bottom: 28px; display: flex; flex-wrap: wrap; gap: 6px; }

.post-body { font-size: 16px; line-height: 1.75; color: #c8d0e0; }
.post-body h2  { font-size: 20px; font-weight: 600; margin: 28px 0 12px; color: var(--text); }
.post-body h3  { font-size: 17px; margin: 20px 0 8px; color: var(--text); }
.post-body p   { margin-bottom: 16px; }
.post-body ul, .post-body ol { padding-left: 24px; margin-bottom: 16px; }
.post-body li  { margin-bottom: 6px; }
.post-body code { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 13px; font-family: 'Menlo', monospace; }
.post-body pre  { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; overflow-x: auto; margin-bottom: 20px; }
.post-body pre code { background: none; border: none; padding: 0; }
.post-body blockquote { border-left: 3px solid var(--accent); padding-left: 16px; margin: 20px 0; color: var(--muted); font-style: italic; }

/* ── Поделиться ── */
.share-block {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.share-label { font-size: 13px; color: var(--muted); }
.share-btn {
  display: inline-block;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: border-color .2s, background .2s;
  white-space: nowrap;
}
.share-btn:hover { border-color: var(--accent); background: rgba(123,156,255,.08); text-decoration: none; }
.share-tg { border-color: rgba(42,171,238,.35); color: #29ace8; }
.share-tg:hover { background: rgba(42,171,238,.1); }
.share-vk { border-color: rgba(75,107,183,.35); color: #6a8dd4; }
.share-vk:hover { background: rgba(75,107,183,.1); }

/* ── Авторизация ── */
.auth-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}
.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}
.auth-box h1 { font-size: 22px; font-weight: 600; margin-bottom: 24px; }
.auth-note  { font-size: 13px; color: var(--muted); margin-bottom: 20px; line-height: 1.5; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
label input, label select, label textarea {
  display: block; width: 100%; margin-top: 5px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
  color: var(--text); font-size: 14px; font-family: inherit;
  outline: none; transition: border-color .2s;
}
label input:focus, label textarea:focus { border-color: var(--accent); }

button, .btn-ok {
  width: 100%; background: var(--accent); color: #0d0f14;
  font-weight: 600; font-size: 14px; border: none;
  border-radius: 8px; padding: 11px; cursor: pointer;
  margin-top: 4px; transition: opacity .2s;
}
button:hover { opacity: .85; }

.auth-link { font-size: 13px; color: var(--muted); text-align: center; margin-top: 16px; }
.auth-link a { color: var(--accent); }

/* ── Админка ── */
.admin-page { max-width: 1000px; margin: 0 auto; padding: 40px 24px; flex: 1; }
.admin-page h1 { font-size: 26px; font-weight: 700; margin-bottom: 32px; }
.admin-section { margin-bottom: 40px; }
.admin-section h2 { font-size: 16px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 12px; }

.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); font-size: 13px; }
.admin-table th { background: #1e2333; padding: 10px 14px; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.admin-table td { padding: 11px 14px; border-top: 1px solid var(--border); }
.admin-table tr:hover td { background: rgba(255,255,255,.02); }

.admin-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn-ok   { display: inline-block; width: auto; background: var(--green); color: #000; padding: 5px 14px; border-radius: 6px; font-size: 12px; font-weight: 600; border: none; cursor: pointer; }
.btn-del  { display: inline-block; width: auto; background: rgba(255,92,92,.15); color: var(--red); border: 1px solid rgba(255,92,92,.3); padding: 5px 14px; border-radius: 6px; font-size: 12px; cursor: pointer; }
.btn-edit { display: inline-block; background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 5px 14px; border-radius: 6px; font-size: 12px; }
.btn-new  { display: inline-block; background: var(--accent); color: #000; padding: 4px 14px; border-radius: 20px; font-size: 12px; font-weight: 600; }

.role-badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.role-admin   { background: rgba(245,166,35,.15); color: var(--yellow); }
.role-user    { background: rgba(62,207,114,.15); color: var(--green); }
.role-pending { background: rgba(123,156,255,.15); color: var(--accent); }

.empty { color: var(--muted); font-size: 14px; }

/* ── Форма поста ── */
.post-form { display: flex; flex-direction: column; gap: 18px; max-width: 720px; }
.post-form label textarea { min-height: 360px; font-family: 'Menlo', monospace; font-size: 13px; }
.checkbox-label { display: flex; align-items: center; gap: 10px; flex-direction: row; font-size: 14px; color: var(--text); }
.checkbox-label input { display: inline; width: auto; margin: 0; }
.form-actions { display: flex; gap: 12px; }
.form-actions .btn-ok, .form-actions .btn-edit { width: auto; padding: 10px 24px; }

/* ── Подвал ── */
.site-footer {
  padding: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--border);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ── Мобильная версия ── */
@media (max-width: 640px) {
  html, body { font-size: 15px; }

  .site-header { padding: 0 16px; height: 48px; }
  .logo { font-size: 15px; }
  .site-nav { gap: 12px; }
  .site-nav a { font-size: 13px; }

  .blog-index { padding: 28px 16px; }
  .blog-hero { margin-bottom: 28px; }
  .blog-hero h1 { font-size: 24px; }
  .blog-hero p  { font-size: 14px; }

  .post-card { padding: 18px 16px; border-radius: 10px; }
  .post-title { font-size: 17px; }
  .post-excerpt { font-size: 13px; }

  .post-page { padding: 24px 16px; }
  .post-page h1 { font-size: 22px; }
  .post-meta { gap: 10px; font-size: 12px; }
  .post-body { font-size: 15px; }
  .post-body h2 { font-size: 18px; }
  .post-body h3 { font-size: 16px; }
  .post-body pre { padding: 12px; font-size: 12px; }

  .share-block { gap: 8px; }
  .share-btn { font-size: 12px; padding: 5px 12px; }

  .auth-box { padding: 24px 20px; }
  .admin-page { padding: 24px 16px; }

  /* Таблица на мобилке: скролл */
  .admin-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
