:root {
  --panel-bg: #f7f3ed;
  --card-bg: #ffffff;
  --border: #e4d7c7;
  --text: #3b2a1f;
  --muted: #7a6857;
  --primary: #b27a3d;
  --primary-hover: #8f5f2d;
  --danger: #b74848;
  --success: #2f8f5b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--panel-bg);
  color: var(--text);
}

a { color: inherit; }

.admin-layout {
  display: block;
  min-height: 100vh;
}

.admin-nav-toggle,
.admin-mobile-menu-btn,
.admin-mobile-menu-overlay,
.admin-mobile-menu-close {
  display: none;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 74px;
  overflow: hidden;
  background: #2d221b;
  color: #f5ede3;
  padding: 24px 16px;
  transition: width 180ms ease;
  z-index: 30;
}

.sidebar:hover {
  width: 260px;
}

.sidebar h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  font-size: 1.15rem;
  white-space: nowrap;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  white-space: nowrap;
}
.nav-link i,
.sidebar h1 i {
  min-width: 22px;
  text-align: center;
  font-size: 1.05rem;
}
.sidebar h1 span,
.nav-link span {
  opacity: 0;
  transition: opacity 120ms ease;
}
.sidebar:hover h1 span,
.sidebar:hover .nav-link span {
  opacity: 1;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.14);
}

.main {
  margin-left: 74px;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 6px 18px rgba(54, 37, 25, 0.05);
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  font-size: 0.86rem;
  color: var(--muted);
  display: block;
  margin-bottom: 5px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  background: #fff;
}
input[type="color"] {
  width: 56px;
  min-width: 56px;
  height: 44px;
  border-radius: 10px;
  padding: 2px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 8px;
}
.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-row code {
  color: var(--muted);
  font-size: .86rem;
}

textarea { min-height: 88px; }

.btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--primary);
}

.btn:hover { background: var(--primary-hover); }
.btn.secondary { background: #7b6b5a; }
.btn.danger { background: var(--danger); }

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

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  border: 1px solid var(--border);
}

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  margin: 10px 0;
  font-size: 0.92rem;
}

.alert.success { background: #e6f6ee; color: #246b45; }
.alert.error { background: #fdeaea; color: #8c2d2d; }

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 10px;
  vertical-align: top;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
}

.badge.published { background: #def4e7; color: #226841; }
.badge.draft { background: #efe7df; color: #6d5540; }

.image-preview {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.admin-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 20000;
}

.admin-modal.is-open {
  display: block;
}

.admin-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 20, 15, 0.55);
}

.admin-modal__dialog {
  position: relative;
  width: min(760px, calc(100% - 24px));
  margin: 70px auto 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 22px 60px rgba(20, 12, 8, 0.35);
  overflow: hidden;
}

.admin-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.admin-modal__body {
  padding: 14px;
}
.admin-center-alert {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 26000;
}
.admin-center-alert.is-open {
  display: block;
}
.admin-center-alert__bg {
  position: absolute;
  inset: 0;
  background: rgba(25, 15, 10, 0.5);
}
.admin-center-alert__card {
  position: relative;
  width: min(560px, calc(100% - 24px));
  margin: 18vh auto 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 22px 56px rgba(20, 12, 8, 0.35);
  padding: 16px;
}
.admin-center-alert__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 1.1rem;
}
.admin-center-alert__title .bi {
  color: #b74848;
  font-size: 1.3rem;
}
.seo-thumb {
  margin-top: 10px;
  width: 100%;
  max-height: 190px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

.seo-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 124px;
  border: 2px dashed #d5c3af;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  color: #7a6857;
  cursor: pointer;
  overflow: hidden;
}

.seo-dropzone.has-image {
  padding: 8px;
}

.seo-thumb--inside {
  margin-top: 0;
  max-height: 106px;
  border: 0;
  border-radius: 8px;
}

@media (max-width: 960px) {
  .admin-mobile-menu-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1200;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: linear-gradient(180deg, #5b3820 0%, #3f2513 100%);
    border: 1px solid rgba(255, 229, 196, 0.42);
    box-shadow: 0 8px 18px rgba(45, 26, 12, 0.45), inset 0 1px 0 rgba(255, 240, 220, 0.22);
    color: #f6e7d4;
    cursor: pointer;
  }

  .admin-mobile-menu-btn .bi {
    font-size: 1.85rem;
    line-height: 1;
  }

  .admin-nav-toggle:checked ~ .admin-mobile-menu-btn {
    display: none;
  }

  .admin-mobile-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(66, 45, 28, 0.26);
    cursor: pointer;
  }

  .admin-nav-toggle:not(:checked) ~ .admin-mobile-menu-overlay {
    display: none;
  }

  .admin-nav-toggle:checked ~ .admin-mobile-menu-overlay {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 196px;
    max-width: 196px;
    height: 100vh;
    padding: 44px 10px 14px 13px;
    overflow-x: hidden;
    overflow-y: auto;
    display: block;
    z-index: 1100;
    background: linear-gradient(180deg, #f2dfca 0%, #ead3bb 100%);
    color: #6f4828;
    border-right: 1px solid rgba(176, 124, 72, 0.24);
    box-shadow: 10px 0 28px rgba(79, 50, 25, 0.24);
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

  .admin-nav-toggle:checked ~ .sidebar {
    transform: translateX(0);
  }

  .sidebar:hover {
    width: 196px;
  }

  .sidebar h1 {
    display: flex;
    margin: 0 0 10px;
    padding: 0 6px 10px;
    border-bottom: 1px solid rgba(176, 124, 72, 0.22);
    color: #6f4828;
    font-size: .94rem;
    line-height: 1.2;
    white-space: normal;
  }

  .sidebar h1 span,
  .nav-link span,
  .sidebar:hover h1 span,
  .sidebar:hover .nav-link span {
    display: inline;
    opacity: 1;
    transition: none;
  }

  .nav-link {
    margin: 0;
    min-width: 0;
    height: auto;
    padding: 9px 6px;
    justify-content: flex-start;
    border-radius: 10px;
    display: flex;
    gap: 8px;
    color: #6f4828;
    font-family: "Segoe UI", Tahoma, sans-serif;
    font-size: .98rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: normal;
  }

  .nav-link i,
  .sidebar h1 i {
    min-width: 17px;
    width: 17px;
    text-align: center;
    font-size: .95rem;
    color: #8f6238;
    flex: 0 0 auto;
  }

  .nav-link:hover,
  .nav-link:focus,
  .nav-link.active {
    background: rgba(255, 255, 255, 0.5);
    color: #5c391f;
  }

  .admin-mobile-menu-close {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(255,255,255,.55);
    color: #7f5530;
    cursor: pointer;
  }

  .admin-mobile-menu-close .bi {
    font-size: 16px;
    line-height: 1;
  }

  .main {
    margin-left: 0;
    padding: 14px 12px 28px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 12px;
  }

  .topbar strong {
    font-size: 1rem;
  }

  .topbar span {
    font-size: 0.82rem;
    line-height: 1.35;
    color: var(--muted);
    word-break: break-word;
  }

  .card {
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 12px;
  }

  .btn {
    width: 100%;
  }

  .grid,
  .grid-3 { grid-template-columns: 1fr; }
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.post-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 14px;
}
.post-card__thumb {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.post-card h4 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.post-card p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.post-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  background: transparent;
  padding: 0;
  margin-bottom: 10px;
  cursor: pointer;
  color: inherit;
}

.card-toggle .bi {
  transition: transform 160ms ease;
}

.card-collapsible.is-collapsed .card-toggle .bi {
  transform: rotate(-90deg);
}

.card-collapsible .card-body {
  display: block;
}

.card-collapsible.is-collapsed .card-body {
  display: none;
}

.favicon-uploader {
  display: grid;
  gap: 8px;
  width: min(320px, 100%);
}

.favicon-uploader__input {
  display: none;
}

.favicon-uploader__dropzone {
  border: 2px dashed #cdb8a0;
  border-radius: 10px;
  padding: 10px;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  background: #fffaf5;
}

.favicon-uploader__dropzone.is-dragover {
  border-color: var(--primary);
  background: #fff3e7;
}

.favicon-uploader__dropzone.is-uploading {
  opacity: .7;
  pointer-events: none;
}

.favicon-uploader__hint {
  font-weight: 700;
  font-size: .86rem;
  color: #6d5540;
}

.favicon-uploader__subhint {
  color: #907766;
  font-size: .8rem;
  margin-top: 2px;
}

.favicon-uploader__preview-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.favicon-uploader__preview {
  width: 88px;
  height: 88px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 6px;
}

.favicon-uploader__preview.is-hidden {
  display: none;
}

.sensitive-field {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sensitive-field__unlock {
  white-space: nowrap;
}

.sensitive-field__hint {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.8rem;
}

.req-label {
  color: #b74848;
  font-weight: 700;
}

.field-error {
  border-color: #b74848 !important;
  box-shadow: 0 0 0 2px rgba(183, 72, 72, 0.12);
}

.post-meta-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.post-meta-grid > div:nth-child(1),
.post-meta-grid > div:nth-child(2) {
  grid-column: span 1;
}
.post-meta-grid > div:nth-child(3) {
  grid-column: span 1;
}

.post-search {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.post-search input {
  min-width: 260px;
  flex: 1;
}

.post-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 12px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}
.status-pill.published {
  background: #def4e7;
  color: #226841;
}
.status-pill.draft {
  background: #efe7df;
  color: #6d5540;
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #b9aa99;
  transition: .2s;
  border-radius: 999px;
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  top: 4px;
  background: white;
  transition: .2s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .switch-slider {
  background: #35a26b;
}
.switch input:checked + .switch-slider:before {
  transform: translateX(22px);
}

@media (max-width: 1100px) {
  .post-meta-grid {
    grid-template-columns: 1fr 1fr;
  }
}
