* {
  box-sizing: border-box;
}

:root {
  --ink: #3f2d2d;
  --soft: #72545d;
  --muted: rgba(75,47,56,.68);
  --pink: #ff7eb3;
  --orange: #ffac62;
  --cream: #fff5c9;
  --paper: rgba(255,255,255,.82);
  --line: rgba(226,193,207,.55);
  --shadow: 0 18px 54px rgba(111,63,78,.13);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(255,255,255,.9), transparent 28rem),
    linear-gradient(135deg, #fff2bd 0%, #ffd6a7 36%, #ffb6c7 72%, #d6f0ff 100%);
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(100%, 430px);
  padding: 30px;
  border-radius: 28px;
  background: rgba(255,255,255,.86);
  border: 1px solid rgba(255,255,255,.8);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 10px;
  font-size: 2.2rem;
  letter-spacing: -0.06em;
}

.login-card p {
  color: var(--soft);
  line-height: 1.6;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: rgba(255,255,255,.72);
  border-right: 1px solid rgba(255,255,255,.68);
  backdrop-filter: blur(18px);
}

.admin-logo {
  display: block;
  margin-bottom: 22px;
  color: #8b4d6b;
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .16em;
}

.admin-nav {
  display: grid;
  gap: 8px;
}

.admin-nav a {
  padding: 11px 13px;
  border-radius: 16px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(255,255,255,.55);
  border: 1px solid rgba(226,193,207,.34);
  font-weight: 700;
}

.admin-nav a:hover {
  background: rgba(255,244,250,.92);
}

.admin-user {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.7);
}

.admin-user span {
  color: var(--muted);
  font-size: .85rem;
}

.admin-user a {
  color: #9b5c28;
  font-weight: 800;
}

.admin-main {
  padding: 26px;
}

.admin-hero,
.page-title,
.panel {
  border: 1px solid rgba(255,255,255,.75);
  background: rgba(255,255,255,.78);
  box-shadow: var(--shadow);
  border-radius: 26px;
}

.admin-hero,
.page-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 24px;
}

.kicker {
  margin: 0 0 7px;
  color: #9b5c28;
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .72rem;
  font-weight: 900;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: -.055em;
}

h2,
h3 {
  letter-spacing: -.03em;
}

.admin-hero p {
  margin: 8px 0 0;
  color: var(--soft);
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 16px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 900;
}

.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  box-shadow: 0 12px 28px rgba(255,126,179,.26);
}

.btn-soft {
  color: #704545;
  background: rgba(255,255,255,.82);
  border: 1px solid var(--line);
}

.btn-full {
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: 0 12px 34px rgba(111,63,78,.09);
}

.stat-card span {
  color: #9b5c28;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .68rem;
  font-weight: 900;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.panel {
  padding: 22px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid rgba(226,193,207,.55);
  text-align: left;
  vertical-align: top;
}

th {
  color: #9b5c28;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .68rem;
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.status {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255,245,210,.92);
  color: #9b5c28;
  font-size: .75rem;
  font-weight: 900;
}

.status-published,
.status-active {
  background: rgba(211,255,226,.9);
  color: #1e7143;
}

.status-draft {
  background: rgba(255,245,210,.92);
  color: #9b5c28;
}

.status-archived,
.status-disabled {
  background: rgba(240,240,240,.9);
  color: #777;
}

.actions {
  display: flex;
  gap: 9px;
  align-items: center;
}

.actions form {
  margin: 0;
}

.actions button {
  border: 0;
  color: #9b3d3d;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.filter-form {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: #5e424c;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 11px 13px;
  color: var(--ink);
  background: rgba(255,255,255,.86);
  outline: none;
}

textarea {
  resize: vertical;
}

.check {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  margin: 12px 0;
}

.check input {
  width: auto;
}

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

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

.editor-layout-narrow {
  grid-template-columns: minmax(0, 860px);
}

.editor-main,
.editor-side {
  margin: 0;
}

.code-editor {
  font-family: Consolas, Monaco, monospace;
  min-height: 520px;
  line-height: 1.55;
}

.editor-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 14px;
}

.editor-tools button,
.editor-tools select {
  width: auto;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.78);
  color: #704545;
  cursor: pointer;
  font-weight: 800;
}

.upload-box {
  display: grid;
  gap: 9px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255,244,250,.65);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

.upload-box-wide {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.media-card {
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,.7);
  border: 1px solid var(--line);
}

.media-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 13px;
}

.media-card code {
  display: block;
  margin-top: 8px;
  font-size: .72rem;
  word-break: break-all;
}

.flash {
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: 16px;
  font-weight: 800;
}

.flash-success {
  background: rgba(211,255,226,.88);
  color: #1e7143;
}

.flash-error {
  background: rgba(255,220,220,.88);
  color: #8f2727;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(255,244,250,.9);
}

@media (max-width: 980px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
  }

  .admin-user {
    position: static;
    margin-top: 16px;
  }

  .admin-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .admin-hero,
  .page-title {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .admin-main,
  .admin-sidebar {
    padding: 14px;
  }

  .admin-nav {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .filter-form,
  .upload-box-wide {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .panel {
    padding: 16px;
  }
}


/* WYSIWYG editor */
.wysiwyg-panel {
  display: grid;
  gap: 12px;
}

.wysiwyg-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px;
  border: 1px solid rgba(226,193,207,.55);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.94), rgba(255,244,250,.88));
  box-shadow: 0 10px 30px rgba(111,63,78,.08);
}

.wysiwyg-toolbar button,
.wysiwyg-toolbar select {
  width: auto;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid rgba(226,193,207,.65);
  border-radius: 999px;
  color: #704545;
  background: rgba(255,255,255,.82);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 900;
}

.wysiwyg-toolbar input[type="file"] {
  width: min(100%, 260px);
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: .78rem;
}

.wysiwyg-help {
  padding: 10px 12px;
  border-radius: 15px;
  background: rgba(255,245,210,.72);
  color: #7f4e2b;
  font-size: .86rem;
  line-height: 1.5;
}

.wysiwyg-editor {
  min-height: 620px;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid rgba(226,193,207,.65);
  border-radius: 22px;
  background: rgba(255,255,255,.88);
  color: #3f2d2d;
  outline: none;
  overflow: auto;
  line-height: 1.75;
}

.wysiwyg-editor:focus {
  border-color: rgba(255,126,179,.72);
  box-shadow: 0 0 0 4px rgba(255,126,179,.10);
}

.wysiwyg-editor p,
.wysiwyg-editor li {
  font-size: 1rem;
  line-height: 1.8;
}

.wysiwyg-editor h2 {
  margin: 1.25em 0 .55em;
  color: #5d3434;
  font-size: 1.7rem;
  line-height: 1.15;
}

.wysiwyg-editor h3 {
  margin: 1.1em 0 .5em;
  color: #5d3434;
  font-size: 1.35rem;
}

.wysiwyg-editor .warning-line {
  margin: 22px 0;
  padding: 20px 22px;
  border-left: 5px solid #ffac62;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 245, 210, 0.96), rgba(255, 255, 255, 0.78));
  color: #4d3939;
  font-weight: 700;
}

.wysiwyg-editor .note-box {
  position: relative;
  margin: 24px 0;
  padding: 22px 22px 22px 26px;
  border-radius: 22px;
  border: 1px solid rgba(240, 199, 134, 0.65);
  background: linear-gradient(135deg, rgba(255,252,242,0.96), rgba(255,246,237,0.88));
  box-shadow: 0 14px 34px rgba(120,70,55,.08);
}

.wysiwyg-editor .note-box::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 16px;
  bottom: 16px;
  width: 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffc76b, #ff9a74);
}

.wysiwyg-editor .note-box p,
.wysiwyg-editor .note-box li {
  margin: 0 0 12px;
  max-width: none;
}

.wysiwyg-editor .note-box p:last-child,
.wysiwyg-editor .note-box li:last-child {
  margin-bottom: 0;
}

.wysiwyg-editor .note-box__title {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-bottom: 14px !important;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.76);
  color: #9b5c28;
  font-size: .76rem !important;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.wysiwyg-editor .note-box--soft {
  background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(255,244,250,0.9));
  border-color: rgba(230, 196, 213, 0.75);
}

.wysiwyg-editor .note-box--soft::before {
  background: linear-gradient(180deg, #f1c8da, #ffb8c8);
}

.wysiwyg-editor .note-box--outline {
  background: rgba(255,255,255,0.55);
  border: 2px solid rgba(240, 199, 134, 0.85);
  box-shadow: none;
}

.wysiwyg-editor .note-box--outline::before {
  background: linear-gradient(180deg, #ffd274, #f7bb62);
}

.wysiwyg-editor .facts-box,
.wysiwyg-editor .final-line {
  margin: 24px 0;
  padding: 22px;
  border-radius: 22px;
  background: linear-gradient(135deg, #fff5c9, #ffe0ea);
  box-shadow: 0 12px 30px rgba(255,145,77,.12);
}

.wysiwyg-editor .final-line {
  text-align: center;
}

.wysiwyg-editor .article-image {
  max-width: 720px;
  margin: 24px auto;
  padding: 10px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 239, 246, 0.82));
  border: 1px solid rgba(255,255,255,.9);
  box-shadow: 0 12px 30px rgba(120,70,55,.10);
}

.wysiwyg-editor .article-image img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: cover;
  border-radius: 18px;
  border: 4px solid rgba(255,255,255,.86);
}

.wysiwyg-editor .article-image figcaption {
  margin-top: 9px;
  color: rgba(77,57,57,.72);
  text-align: center;
  font-size: .9rem;
  font-style: italic;
}

.wysiwyg-editor .article-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.wysiwyg-editor .article-gallery .article-image {
  margin: 0;
}

.wysiwyg-editor .glossary-ref {
  display: inline;
  padding: 0 .08em;
  border-bottom: 2px solid rgba(157,84,38,.36);
  color: #7e3f20;
  background: linear-gradient(180deg, transparent 62%, rgba(248,241,184,.85) 62%);
  cursor: pointer;
}

.js-source-editor {
  font-family: Consolas, Monaco, monospace;
  min-height: 620px;
}

@media (max-width: 700px) {
  .wysiwyg-toolbar {
    max-height: 220px;
    overflow: auto;
  }

  .wysiwyg-editor {
    min-height: 480px;
  }

  .wysiwyg-editor .article-gallery {
    grid-template-columns: 1fr;
  }
}


/* WYSIWYG preview: improved facts list */
.wysiwyg-editor .facts-list {
  list-style: none;
  counter-reset: facts-counter;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.wysiwyg-editor .facts-list li {
  counter-increment: facts-counter;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.42);
  text-align: left;
}

.wysiwyg-editor .facts-list li::before {
  content: counter(facts-counter);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.88);
  color: #7d4c2f;
  font-weight: 800;
}


.field-help {
  display: block;
  margin-top: 6px;
  color: rgba(82, 61, 67, 0.68);
  font-size: 0.78rem;
  line-height: 1.45;
}


/* Editor preview alignment for note boxes and article blocks */
.wysiwyg-editor > p,
.wysiwyg-editor > h2,
.wysiwyg-editor > h3,
.wysiwyg-editor > ul,
.wysiwyg-editor > ol,
.wysiwyg-editor > .note-box,
.wysiwyg-editor > .warning-line,
.wysiwyg-editor > .facts-box,
.wysiwyg-editor > .final-line,
.wysiwyg-editor > .life-belongs,
.wysiwyg-editor > .article-image,
.wysiwyg-editor > .article-gallery {
  width: min(100%, 820px);
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.wysiwyg-editor > h2,
.wysiwyg-editor > h3,
.wysiwyg-editor > p {
  text-align: left;
}


.warning-help {
  display: block;
  margin: -4px 0 14px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 243, 199, 0.8);
  color: #7a4d18;
  border: 1px solid rgba(234, 188, 90, 0.45);
}


/* The featured image column has been added; hide old upgrade warning if cached markup appears. */
.warning-help {
  display: none !important;
}


.body-upload-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  color: rgba(82, 61, 67, 0.78);
  background: rgba(255,255,255,0.62);
  font-size: 0.76rem;
  line-height: 1.3;
}

.warning-help {
  display: none !important;
}


.body-upload-version {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 5px 9px;
  border-radius: 999px;
  color: rgba(82, 61, 67, 0.62);
  background: rgba(255,255,255,0.46);
  font-size: 0.68rem;
  line-height: 1.2;
}


.danger-link {
  color: #b42318 !important;
  font-weight: 800;
}

.actions form {
  display: inline;
}

.actions button {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  margin: 0 6px;
  color: #9b2f2f;
  font: inherit;
  font-weight: 800;
}
