/* ═══ Админка ════════════════════════════════════════════════════════════ */

.admin-bar .brand-name::after {
  content: ' · админка';
  font-style: normal;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted-mono);
  margin-left: 8px;
  white-space: nowrap;
}

/* ── buttons & fields ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--link);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, opacity .16s ease;
}
.btn:hover { border-color: var(--accent-soft); background: var(--soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:disabled:hover { background: var(--surface); border-color: var(--line-strong); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #dd7c96; border-color: #dd7c96; }
.btn-primary:disabled:hover { background: var(--accent); border-color: var(--accent); }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--soft); border-color: transparent; }

.btn-danger { color: #b3455c; }
.btn-danger:hover { background: #fdeaee; border-color: #f0c2cd; }

.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-icon {
  min-height: 34px;
  width: 34px;
  padding: 0;
  border-radius: 10px;
  font-size: 15px;
  color: var(--muted);
}

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  margin-bottom: 7px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted-mono);
}

.input {
  width: 100%;
  min-height: 46px;
  padding: 11px 16px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: none;
  transition: border-color .16s ease;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus { border-color: var(--accent-soft); }
.input::placeholder { color: var(--muted-faint); }

.hint-text {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.form-error {
  margin: 0 0 14px;
  padding: 11px 16px;
  border-radius: 12px;
  background: #fdeaee;
  border: 1px solid #f2c8d2;
  color: #a33c55;
  font-size: 14px;
}
.form-error:empty { display: none; }

/* ── login ───────────────────────────────────────────────────────────── */

.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-h) - 90px);
  padding: 40px 0 80px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px 30px;
}
.auth-card h1 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  color: var(--ink-serif);
}
.auth-card .hint-text { margin-bottom: 22px; }
.auth-card .btn { width: 100%; }

/* ── toolbar above a list ────────────────────────────────────────────── */

.adm-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.adm-head .page-title, .adm-head .page-meta { margin: 0; }
.adm-head .titles { min-width: 0; }

/* ── sortable rows ───────────────────────────────────────────────────── */

.adm-list { display: flex; flex-direction: column; gap: 10px; }

.adm-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color .16s ease;
}
.adm-item:hover { border-color: var(--accent-soft); }

.adm-item .chip {
  width: 26px; height: 26px;
  border-radius: 9px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, .05);
}

.adm-item .name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  padding: 6px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.adm-item .name:hover { color: var(--link); }

.adm-item .sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted-mono);
  white-space: nowrap;
}
.adm-item .sub.is-empty { color: var(--muted-faint); }

.adm-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.adm-actions .btn-icon:disabled { opacity: .25; }

/* ── inline add / edit form ──────────────────────────────────────────── */

.adm-form {
  background: var(--surface);
  border: 1px dashed var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 14px;
}
.adm-form .row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.adm-form .row .field { flex: 1; min-width: 200px; margin-bottom: 0; }
.adm-form .actions { display: flex; gap: 8px; margin-top: 16px; }

.tints { display: flex; gap: 8px; flex-wrap: wrap; }
.tint {
  width: 34px; height: 34px;
  border-radius: 11px;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .05);
  cursor: pointer;
  padding: 0;
  transition: transform .14s ease;
}
.tint:hover { transform: scale(1.08); }
.tint.is-selected { border-color: var(--ink-serif); }

/* ── markdown editor ─────────────────────────────────────────────────── */

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.editor-pane {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-width: 0;
}

.pane-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted-mono);
}

.md-toolbar {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: #fffdfe;
}
.md-toolbar button {
  min-height: 32px;
  padding: 5px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  font-size: 13px;
  color: var(--muted-warm);
  cursor: pointer;
  transition: background .14s ease;
}
.md-toolbar button:hover { background: var(--soft); color: var(--link); }
.md-toolbar .mono { font-family: var(--mono); }
.md-toolbar .bold { font-weight: 700; }
.md-toolbar .ital { font-style: italic; }

.md-input {
  display: block;
  width: 100%;
  min-height: 58vh;
  padding: 20px 22px;
  border: none;
  outline: none;
  resize: vertical;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--ink);
  tab-size: 2;
}

.md-preview {
  padding: 24px 26px;
  min-height: 58vh;
  max-height: 78vh;
  overflow-y: auto;
}
.md-preview .prose { font-size: 15.5px; }

.preview-empty {
  color: var(--muted-faint);
  font-family: var(--mono);
  font-size: 13px;
  text-align: center;
  padding: 40px 0;
}

/* parsed headings, shown so the author sees the site's contents panel */
.toc-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--soft-2);
}
.toc-preview:empty { display: none; }
.toc-chip {
  font-size: 12.5px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted-warm);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc-chip.h1 { font-weight: 700; color: var(--ink-serif); }
.toc-chip.h3 { color: var(--muted); font-size: 12px; }
.toc-note {
  width: 100%;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted-mono);
}

/* sticky save bar */
.save-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 14px 18px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  background: rgba(251, 242, 244, .94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
}
.save-state {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted-mono);
}
.save-state.is-dirty { color: #b3455c; }
.save-state.is-saved { color: #5d8a5f; }

/* ── settings ────────────────────────────────────────────────────────── */

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

/* ── tablet ──────────────────────────────────────────────────────────── */

@media (max-width: 1023px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .md-input { min-height: 44vh; }
  .md-preview { min-height: 0; max-height: none; }

  /* Editor and preview become tabs so neither is squeezed. */
  .editor-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
  .editor-tabs button {
    flex: 1;
    min-height: 42px;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    font-size: 14px;
    font-weight: 600;
    color: var(--muted-warm);
    cursor: pointer;
  }
  .editor-tabs button.is-active {
    background: var(--soft);
    border-color: var(--accent-soft);
    color: var(--link-hover);
  }
  .editor-grid[data-tab='write'] .pane-preview,
  .editor-grid[data-tab='preview'] .pane-write { display: none; }
}
@media (min-width: 1024px) {
  .editor-tabs { display: none; }
}

/* ── phone ───────────────────────────────────────────────────────────── */

@media (max-width: 700px) {
  .admin-bar .brand-name::after { display: none; }

  .adm-item {
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px;
  }
  .adm-item .name { flex-basis: calc(100% - 90px); font-size: 15px; }
  .adm-item .sub { order: 3; }
  .adm-actions { order: 4; margin-left: auto; }

  .adm-head { gap: 10px; }
  .adm-head .btn { flex: 1; }

  .md-input { padding: 16px; font-size: 16px; min-height: 50vh; }
  .md-preview { padding: 18px; }
  .toc-preview { padding: 12px 14px; }

  .save-bar { gap: 10px; }
  .save-bar .btn { flex: 1; }
  .save-state { width: 100%; order: -1; }

  .auth-card { padding: 26px 22px; }
  .settings-card { padding: 20px; }
}
