/* ─────────────────────────────────────────────────────────
   Тёмная тема. Строго, монохромно.
   ───────────────────────────────────────────────────────── */
:root {
  --bg: #09090b;
  --surface: #101013;
  --surface-2: #16161a;
  --line: #232329;
  --text: #e8e8ec;
  --muted: #8f8f98;
  --white: #fafafa;
  --danger: #f87171;
  --ok: #4ade80;
  --warn: #fbbf24;
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(.22, .8, .36, 1);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--text);
  min-height: 100vh;
  background: var(--bg);
  overflow-x: hidden;
}

::selection { background: var(--white); color: var(--bg); }

a { color: inherit; -webkit-tap-highlight-color: transparent; }

button { font-family: inherit; -webkit-tap-highlight-color: transparent; }

:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }

/* ── Кнопка «наверх» ────────────────────────────────────── */
.to-top {
  position: fixed;
  right: 20px;
  right: calc(16px + env(safe-area-inset-right));
  bottom: 20px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 50;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
  background: var(--surface);
  transition: transform .2s ease, border-color .2s ease;
}

.to-top:hover { transform: translateY(-3px); border-color: var(--muted); }
.to-top:active { transform: scale(.94); }

/* ── Главная ────────────────────────────────────────────── */
.welcome {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 22px;
}

.title {
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--white);
}

.subtitle {
  margin-top: 16px;
  font-size: clamp(1rem, 2.4vw, 1.125rem);
  line-height: 1.7;
  max-width: 420px;
  color: var(--muted);
}

/* ── Шапка ──────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(9, 9, 11, .82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: .95rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--white);
  text-decoration: none;
}

.visit-badge {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ── Страницы ───────────────────────────────────────────── */
.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 44px clamp(16px, 4vw, 48px) 80px;
}

.blog-hero { margin-bottom: 42px; }

.blog-hero h1 {
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--white);
}

/* ── Карточки записей ───────────────────────────────────── */
.posts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.post-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  transition: transform .22s var(--ease), border-color .22s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.post-card:hover {
  transform: translateY(-4px);
  border-color: #3a3a42;
}

.post-card .post-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.post-date,
.article .post-date {
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.post-num {
  font-family: var(--font-mono);
  font-size: .74rem;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.post-card h2 {
  color: var(--white);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -.01em;
}

.post-card p {
  font-size: .92rem;
  line-height: 1.65;
  color: var(--muted);
  flex: 1;
}

.post-more {
  color: var(--text);
  font-weight: 600;
  font-size: .85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: gap .2s ease;
}

.post-card:hover .post-more { gap: 10px; }

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

/* ── Статья ─────────────────────────────────────────────── */
.article {
  background: var(--surface);
  border-radius: var(--radius);
  padding: clamp(26px, 5vw, 56px);
  border: 1px solid var(--line);
}

.article h1 {
  color: var(--white);
  font-size: clamp(1.7rem, 4.5vw, 2.4rem);
  margin: 12px 0 0;
  line-height: 1.25;
  letter-spacing: -.02em;
}

.article .markdown { margin-top: 30px; line-height: 1.85; font-size: 1.02rem; }

.article .markdown p { margin-bottom: 20px; }

.article .markdown h2,
.article .markdown h3,
.article .markdown h4 {
  color: var(--white);
  margin: 32px 0 12px;
  line-height: 1.35;
  letter-spacing: -.01em;
}

.article .markdown blockquote {
  border-left: 2px solid #3a3a42;
  padding: 10px 20px;
  color: var(--muted);
  margin: 22px 0;
}

.article .markdown a { color: var(--white); text-underline-offset: 3px; }
.article .markdown ul, .article .markdown ol { margin: 0 0 20px 22px; }
.article .markdown li { margin-bottom: 6px; }
.article .markdown hr { border: none; border-top: 1px solid var(--line); margin: 28px 0; }

.article .markdown img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.article .markdown table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 22px 0;
}

.article .markdown th,
.article .markdown td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
}

.article .markdown code {
  font-family: var(--font-mono);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: .88em;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: .92rem;
  transition: color .2s ease;
}

.back-link:hover { color: var(--white); }

.footer-note { text-align: center; margin-top: 48px; color: var(--muted); }

/* ── Реакции ────────────────────────────────────────────── */
.reactions-block {
  margin-top: 38px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.reactions-title {
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}

.reactions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: transform .16s ease, border-color .2s ease, background .2s ease;
}

.reaction-btn .reaction-emoji { font-size: 1.05rem; line-height: 1; }
.reaction-btn .reaction-count {
  font-family: var(--font-mono);
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  min-width: 14px;
}

.reaction-btn:hover { transform: translateY(-2px); border-color: #3f3f47; }

.reaction-btn.active {
  background: var(--white);
  border-color: var(--white);
}

.reaction-btn.active .reaction-count { color: var(--bg); }

/* ── Ползунок настроения ────────────────────────────────── */
.mood-block {
  margin-top: 30px;
  text-align: center;
}

.mood-title {
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}

.mood-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.mood-slider {
  -webkit-appearance: none;
  appearance: none;
  width: min(320px, 70vw);
  height: 4px;
  border-radius: 999px;
  background: #2c2c33;
  outline: none;
  cursor: pointer;
}

.mood-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--white);
  cursor: pointer;
  transition: transform .15s ease;
}

.mood-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }

.mood-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--white);
  border: none;
  cursor: pointer;
}

.mood-slider::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: #2c2c33;
}

.mood-num {
  font-family: var(--font-mono);
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  min-width: 52px;
  text-align: left;
}

.mood-saved {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--muted);
}

/* ── Админка: каркас ────────────────────────────────────── */
.admin-page {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px clamp(16px, 4vw, 48px) 80px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 26px;
  border: 1px solid var(--line);
}

.admin-login {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.admin-login .card {
  width: min(400px, 100%);
  text-align: center;
  padding: 38px 32px;
}

.admin-login h1 {
  color: var(--white);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-bottom: 6px;
}

.admin-login .card-sub {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: 26px;
}

.admin-login .btn { width: 100%; justify-content: center; }

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-header h1 {
  color: var(--white);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

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

/* ── Админка: статистика ────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 18px;
}

.stat b {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--white);
  line-height: 1.1;
}

.stat span { font-size: .78rem; color: var(--muted); }

/* ── Админка: секции и строки ───────────────────────────── */
.admin-section { margin-bottom: 26px; }

.admin-section > h2 {
  color: var(--white);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -.01em;
  margin-bottom: 14px;
}

.post-rows { display: flex; flex-direction: column; gap: 8px; }

.post-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .2s ease;
}

.post-row:hover { border-color: #3a3a42; }

.post-row .row-icon {
  font-family: var(--font-mono);
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.post-row .row-main { flex: 1; min-width: 0; }

.post-row .row-title {
  color: var(--white);
  font-weight: 600;
  font-size: .98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-row .row-sub {
  font-family: var(--font-mono);
  font-size: .76rem;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-row .badge { margin-left: auto; flex-shrink: 0; }

.post-row .row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Таблицы-строки (визиты / реакции / настроение) ─────── */
.visit-list { display: flex; flex-direction: column; }

.visit-row {
  display: grid;
  grid-template-columns: 96px 120px 130px 84px 1fr;
  gap: 12px;
  align-items: center;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
}

.visit-row:last-child { border-bottom: none; }

.visit-row.visit-head {
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--muted);
  padding-top: 0;
  padding-bottom: 10px;
}

.visit-row .visit-when,
.visit-row .visit-ip,
.visit-row .visit-screen {
  font-family: var(--font-mono);
  font-size: .84rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.visit-row .visit-browser {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  color: var(--muted);
  font-size: .84rem;
}

.visit-row .visit-empty { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; }

.reaction-emoji-big {
  font-size: 1.2rem;
  line-height: 1;
  white-space: nowrap;
}

.visit-post {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
  text-decoration: none;
}

.visit-post:hover { color: var(--white); text-decoration: underline; text-underline-offset: 3px; }

.visit-row:has(.visit-post),
.visit-row.row-reactions { grid-template-columns: 96px 84px 1fr; }

.visit-row:has(.mood-bar),
.visit-row.row-moods { grid-template-columns: 96px minmax(120px, 1fr) 56px 1fr; }

.mood-bar {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: #2c2c33;
  overflow: hidden;
}

.mood-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--white);
}

.mood-pct {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: .84rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .visit-row { grid-template-columns: 84px 110px 1fr; }
  .visit-row .visit-screen,
  .visit-row .visit-browser { grid-column: 1 / -1; }
  .visit-row .visit-screen { order: 2; }
  .visit-row .visit-browser { order: 3; }
  .visit-row.visit-head .visit-screen,
  .visit-row.visit-head .visit-browser { display: none; }
  .visit-row:has(.visit-post),
  .visit-row.row-reactions { grid-template-columns: 84px 64px 1fr; }
  .visit-row:has(.mood-bar),
  .visit-row.row-moods { grid-template-columns: 84px minmax(80px, 1fr) 48px; }
  .visit-row:has(.mood-bar) .visit-post,
  .visit-row.row-moods .visit-post { grid-column: 1 / -1; }
}

/* ── Бейджи ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.on  { background: rgba(74, 222, 128, .1);  color: var(--ok); }
.badge.off { background: rgba(248, 113, 113, .1); color: var(--danger); }
.badge.new { background: rgba(251, 191, 36, .1);  color: var(--warn); }

/* ── Кнопки ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  cursor: pointer;
  background: var(--white);
  color: var(--bg);
  text-decoration: none;
  transition: transform .18s ease, opacity .18s ease;
}

.btn:hover { transform: translateY(-1px); opacity: .9; }
.btn:active { transform: translateY(0) scale(.98); }

.btn.lg { padding: 14px 32px; font-size: 1rem; }

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn.ghost:hover { border-color: #3f3f47; opacity: 1; }

.btn.small { padding: 8px 14px; font-size: .84rem; }

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  transition: border-color .2s ease, color .2s ease;
}

.btn-icon:hover { border-color: #3f3f47; color: var(--white); }
.btn-icon.danger:hover { border-color: var(--danger); color: var(--danger); }

.error {
  background: rgba(248, 113, 113, .08);
  border: 1px solid rgba(248, 113, 113, .25);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: .88rem;
}

/* ── Формы ──────────────────────────────────────────────── */
.field { margin-bottom: 18px; text-align: left; }

.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-bottom: 8px;
  color: var(--muted);
}

.field input,
.field textarea {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color .2s ease;
}

.field textarea { min-height: 340px; resize: vertical; line-height: 1.7; }

.field input::placeholder,
.field textarea::placeholder { color: #55555e; }

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: #4a4a54;
}

.check {
  display: flex;
  gap: 9px;
  align-items: center;
  font-weight: 500;
  font-size: .92rem;
  margin-bottom: 20px;
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 17px;
  height: 17px;
  accent-color: var(--white);
  cursor: pointer;
}

/* ── Редактор: вкладки ──────────────────────────────────── */
.editor-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
  width: fit-content;
}

.editor-tab {
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 600;
  font-size: .86rem;
  color: var(--muted);
  padding: 7px 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}

.editor-tab.active {
  background: var(--white);
  color: var(--bg);
}

.editor-panel { display: none; }
.editor-panel.active { display: block; }

.preview-box {
  min-height: 340px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  line-height: 1.8;
  font-size: .98rem;
  color: var(--text);
}

.preview-box p { margin-bottom: 14px; }
.preview-box h1, .preview-box h2, .preview-box h3 {
  color: var(--white);
  margin: 20px 0 10px;
}
.preview-box blockquote {
  border-left: 2px solid #3a3a42;
  padding: 8px 16px;
  color: var(--muted);
  margin: 14px 0;
}
.preview-box ul, .preview-box ol { margin: 0 0 14px 22px; }
.preview-box code {
  font-family: var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: .88em;
}

.char-count {
  font-family: var(--font-mono);
  font-size: .76rem;
  color: var(--muted);
  margin-top: 6px;
  text-align: right;
}

/* ── Анимации появления ─────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .6s ease, transform .6s ease;
}

.reveal.visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ── Скроллбар ──────────────────────────────────────────── */
html { scrollbar-width: thin; scrollbar-color: #2c2c33 var(--bg); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2c2c33; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a42; }

/* ── Мобильные ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .posts { grid-template-columns: 1fr; }
  .topbar .brand { font-size: .85rem; }
  .visit-badge { font-size: .72rem; }
  .btn.lg { padding: 13px 26px; font-size: .95rem; }
  .reaction-btn { padding: 10px 17px; }
  .post-row { flex-wrap: wrap; }
  .post-row .row-main { flex-basis: 100%; }
  .post-row .badge { margin-left: 0; }
  .admin-header { flex-direction: column; align-items: flex-start; }
}
