/* Оформление админки. Спокойное и плотное: это рабочий инструмент,
   а не витрина. Цвета - те же, что на сайте. */

:root {
  --bg: #F5F4EF;
  --ink: #1F1F1D;
  --muted: #6E6B63;
  --line: #E4E1D8;
  --card: #FFFFFF;
  --accent: #A87213;
  --accent-soft: #F5B754;
  --danger: #B3261E;
}

* { box-sizing: border-box; }

/* Скрытая кнопка обязана быть скрытой: собственный display у .btn иначе
   перебивает браузерное правило для [hidden], и кнопка «Удалить статью»
   висит на экране у ещё не созданной статьи. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

h1 { font-family: "Inter Tight", "Inter", sans-serif; font-size: 1.5rem; margin: 0; letter-spacing: -0.01em; }

/* ---------- вход ---------- */

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

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  display: grid;
  gap: 14px;
  justify-items: stretch;
  text-align: center;
}

.login-card img { justify-self: center; border-radius: 10px; }
.login-card label { display: grid; gap: 6px; text-align: left; font-size: 0.9rem; color: var(--muted); }
.login-card .error { margin: 0; color: var(--danger); font-size: 0.9rem; }
.login-card .btn { justify-content: center; }

input[type="text"], input[type="password"], input[type="url"], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input:focus, textarea:focus { outline: 2px solid var(--accent-soft); outline-offset: 1px; border-color: var(--accent-soft); }
textarea { resize: vertical; }

/* ---------- шапка ---------- */

.admin-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(245, 244, 239, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.admin-top-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); text-decoration: none; }
.brand img { border-radius: 7px; }
.admin-top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-top-actions form { margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { background: rgba(31, 31, 29, 0.06); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #000; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(179, 38, 30, 0.08); }

.save-state { font-size: 0.85rem; color: var(--muted); min-width: 1px; }
.save-state-ok { color: #1F7A3D; }
.save-state-error { color: var(--danger); }

/* ---------- список статей ---------- */

.admin-main { max-width: 1000px; margin: 0 auto; padding: 26px 20px 80px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.empty { color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }

.post-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.post-table th, .post-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.post-table tr:last-child td { border-bottom: none; }
.post-table th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.post-title { display: block; color: var(--ink); font-weight: 600; text-decoration: none; }
.post-title:hover { color: var(--accent); }
.post-slug { display: block; font-size: 0.8rem; color: var(--muted); font-family: "JetBrains Mono", ui-monospace, monospace; }
.nowrap { white-space: nowrap; color: var(--muted); font-size: 0.88rem; }
.actions { white-space: nowrap; }
.actions a { color: var(--accent); text-decoration: none; margin-right: 12px; font-size: 0.9rem; }
.actions a:hover { text-decoration: underline; }

.status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; white-space: nowrap; }
.status-published { background: rgba(31, 122, 61, 0.12); color: #1F7A3D; }
.status-draft { background: rgba(110, 107, 99, 0.14); color: var(--muted); }

/* ---------- редактор ---------- */

.editor-main { max-width: 800px; }
.editor-fields { display: grid; gap: 16px; margin-bottom: 20px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }

#f-title { font-family: "Inter Tight", "Inter", sans-serif; font-size: 1.4rem; font-weight: 600; padding: 12px 14px; }

.cover-box { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
#cover-preview { width: 200px; height: 120px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.cover-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.editor-holder {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 8px 40px;
  min-height: 400px;
}

/* Редактор сам добавляет отступы под тулбар - оставляем ему место слева */
.codex-editor--narrow .codex-editor__redactor { margin-right: 0; }
.ce-block__content, .ce-toolbar__content { max-width: 640px; }

.editor-extra { margin-top: 22px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0 18px; }
.editor-extra summary { cursor: pointer; padding: 14px 0; font-weight: 600; }
.editor-extra[open] { padding-bottom: 18px; }
.editor-extra .field { margin-bottom: 14px; }

.slug-row { display: flex; align-items: center; gap: 0; }
.slug-prefix { padding: 10px 8px 10px 12px; border: 1px solid var(--line); border-right: none; border-radius: 10px 0 0 10px; background: #FAF9F5; color: var(--muted); font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.85rem; }
.slug-row input { border-radius: 0 10px 10px 0; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.85rem; }

.danger-row { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 6px; border-top: 1px solid var(--line); margin-top: 6px; }

@media (max-width: 640px) {
  .admin-top-inner { padding: 10px 14px; }
  .admin-main { padding: 20px 14px 60px; }
  .admin-head { flex-direction: column; align-items: flex-start; }
  .post-table thead { display: none; }
  .post-table, .post-table tbody, .post-table tr, .post-table td { display: block; width: 100%; }
  .post-table td { border-bottom: none; padding: 6px 14px; }
  .post-table tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  #cover-preview { width: 100%; height: 160px; }
}
