:root {
  --bg: #faf7f2;
  --paper: #ffffff;
  --paper-soft: #fff8ef;
  --panel-top: rgba(255, 250, 243, 0.92);
  --text: #2a1e16;
  --muted: #6a5343;
  --subtle-text: #7b6554;
  --line: #e5d6c8;
  --line-soft: #dcc9b7;
  --accent: #bf5b22;
  --accent-strong: #8f3f17;
  --input-bg: #ffffff;
  --status-bg: #fff2e4;
  --status-border: #e5c1a0;
  --status-text: #7a3817;
  --success: #3a6a48;
  --shadow-soft: 0 10px 24px rgba(54, 30, 18, 0.08);
}

html[data-theme="dark"] {
  --bg: #1a1512;
  --paper: #241c17;
  --paper-soft: #2d231d;
  --panel-top: rgba(36, 28, 23, 0.94);
  --text: #f5ece3;
  --muted: #ceb8a8;
  --subtle-text: #baa494;
  --line: #47362b;
  --line-soft: #584236;
  --accent: #d27a3e;
  --accent-strong: #e09a63;
  --input-bg: #201914;
  --status-bg: #3a281d;
  --status-border: #7c5942;
  --status-text: #ffdaba;
  --success: #8ad1a0;
  --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.35);
}

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

body {
  font-family: "Montserrat", sans-serif;
  color: var(--text);
  line-height: 1.65;
  background:
    radial-gradient(circle at 12% -8%, rgba(204, 111, 47, 0.08), transparent 32%),
    radial-gradient(circle at 88% 0%, rgba(112, 146, 116, 0.1), transparent 30%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar,
.hero,
.content,
footer {
  width: min(1040px, 92%);
}

.top-bar {
  margin: 1.8rem auto 0.9rem;
  padding: 0.95rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--panel-top);
  box-shadow: var(--shadow-soft);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.top-bar.compact {
  grid-template-columns: auto 1fr auto;
}

.brand {
  font-family: "Playfair Display", serif;
  font-size: clamp(1.55rem, 2.1vw, 2.1rem);
  letter-spacing: 0.02em;
}

nav {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  justify-self: start;
}

.top-bar.compact nav {
  justify-self: end;
}

nav a {
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

nav a:hover,
nav a:focus-visible {
  color: var(--accent-strong);
  border-color: var(--accent);
}

.top-search {
  justify-self: center;
  width: min(460px, 100%);
  display: inline-grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 0.45rem;
}

.top-search > input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--input-bg);
  color: var(--text);
  padding: 0.55rem 0.95rem;
  font: inherit;
}

.top-search > input:focus {
  outline: 2px solid rgba(191, 91, 34, 0.28);
  outline-offset: 2px;
}

.theme-toggle {
  justify-self: end;
  margin-top: 0;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.theme-toggle svg {
  width: 1.05rem;
  height: 1.05rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hero {
  margin: 0.8rem auto 1.5rem;
  padding: clamp(1.4rem, 2.3vw, 2.2rem);
  border: 1px solid var(--line);
  border-radius: 0.95rem;
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  animation: fade-up 0.45s ease both;
}

.hero h1 {
  font-family: "Playfair Display", serif;
  font-size: clamp(1.8rem, 4.2vw, 2.8rem);
  margin-bottom: 0.7rem;
}

.hero p {
  max-width: 66ch;
  color: var(--muted);
}

.status-note {
  display: inline-flex;
  align-items: center;
  margin-top: 0.95rem;
  padding: 0.35rem 0.72rem;
  border: 1px solid var(--status-border);
  border-radius: 999px;
  background: var(--status-bg);
  color: var(--status-text);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.content {
  margin: 0 auto 1.7rem;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 1rem;
}

.content.blog-only {
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  padding: 1.15rem;
  animation: fade-up 0.45s ease both;
}

article + article {
  margin-top: 1.15rem;
  padding-top: 1.15rem;
  border-top: 1px dashed var(--line-soft);
}

.post-preview img,
.post-preview video {
  max-width: 100%;
  height: auto;
  border-radius: 0.6rem;
  margin: 0.45rem 0;
}

.post-preview p {
  margin: 0.35rem 0;
}

.post-date {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.32rem;
}

h2 {
  font-family: "Playfair Display", serif;
  font-size: 1.32rem;
  margin-bottom: 0.38rem;
}

.section-title {
  margin-top: 1rem;
}

.btn {
  display: inline-block;
  margin-top: 0.68rem;
  border-radius: 999px;
  padding: 0.42rem 0.84rem;
  text-decoration: none;
  color: #fff;
  background: var(--accent);
  font-weight: 600;
  border: 1px solid transparent;
  font: inherit;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.btn:hover,
.btn:focus-visible {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.btn-small {
  margin-top: 0;
  padding: 0.3rem 0.7rem;
  font-size: 0.84rem;
}

.btn-light {
  background: #8aa094;
}

.btn-light:hover,
.btn-light:focus-visible {
  background: #6f8579;
}

.btn-danger {
  background: #b84f3d;
}

.btn-danger:hover,
.btn-danger:focus-visible {
  background: #943726;
}

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

.btn-ghost:hover,
.btn-ghost:focus-visible {
  background: var(--paper-soft);
  color: var(--text);
}

footer {
  margin: auto auto 0;
  padding: 1.2rem 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.last-updated {
  text-align: left;
  justify-self: start;
}

.footer-copy {
  text-align: center;
  justify-self: center;
}

.visitor-stats {
  text-align: right;
  white-space: nowrap;
  justify-self: end;
}

.visitor-stats small {
  color: var(--subtle-text);
}

.empty-hint {
  margin-top: 1rem;
  color: var(--muted);
  font-weight: 600;
}

.contact-section {
  width: min(1040px, 92%);
  margin: 0 auto 1.7rem;
}

.contact-intro {
  color: var(--muted);
  margin-bottom: 0.9rem;
}

.contact-form {
  display: grid;
  gap: 0.55rem;
}

.contact-form label {
  font-weight: 600;
}

.contact-form input,
.contact-form textarea,
.inbox-item select,
.inbox-item textarea,
input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--input-bg);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font: inherit;
}

.inbox-item select,
.inbox-item textarea {
  border-radius: 0.6rem;
  padding: 0.45rem 0.6rem;
}

.contact-form textarea {
  resize: vertical;
}

.contact-form input:focus,
.contact-form textarea:focus,
.inbox-item select:focus,
.inbox-item textarea:focus,
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(204, 111, 47, 0.32);
  outline-offset: 1px;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--paper-soft);
}

.editor-toolbar select,
.editor-toolbar input[type="color"],
.editor-toolbar input[type="file"] {
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--input-bg);
  color: var(--text);
  padding: 0.4rem 0.55rem;
  font: inherit;
}

.editor-toolbar input[type="color"] {
  padding: 0.2rem;
  width: 2.2rem;
  min-height: 2.1rem;
}

.rich-editor {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--input-bg);
  color: var(--text);
  padding: 0.65rem 0.75rem;
  overflow-wrap: anywhere;
}

.rich-editor:focus {
  outline: 2px solid rgba(204, 111, 47, 0.32);
  outline-offset: 1px;
}

.rich-editor img,
.rich-editor video {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 0.35rem 0;
}

.contact-form .btn {
  justify-self: start;
}

.contact-status {
  margin-top: 0.8rem;
  color: var(--success);
  font-weight: 700;
}

.dashboard-layout {
  margin-bottom: 2rem;
  gap: 1rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
  margin-top: 0.8rem;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: var(--paper-soft);
  padding: 0.8rem;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.stat-card strong {
  display: block;
  margin-top: 0.22rem;
  font-size: 1.4rem;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.inline-actions.space-between {
  justify-content: space-between;
  align-items: center;
}

.inline-actions.space-between h2 {
  margin-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.7rem;
}

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

.table-actions {
  white-space: nowrap;
}

.inbox-list {
  display: grid;
  gap: 0.8rem;
  margin-top: 0.7rem;
}

.inbox-item {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--paper-soft);
  padding: 0.8rem;
  display: grid;
  gap: 0.4rem;
}

.inbox-item h3 {
  font-family: "Playfair Display", serif;
  font-size: 1.12rem;
}

.inbox-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.auth-wrap {
  width: min(1040px, 92%);
  margin: 1rem auto 2rem;
}

.auth-card {
  max-width: 520px;
  margin: 0 auto;
}

@media (max-width: 1100px) {
  .top-bar,
  .hero,
  .content,
  footer,
  .contact-section,
  .auth-wrap {
    width: min(1040px, 94%);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  body {
    line-height: 1.6;
  }

  .top-bar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "brand nav theme"
      "search search search";
    align-items: center;
  }

  .top-bar .brand {
    grid-area: brand;
  }

  .top-bar nav {
    grid-area: nav;
  }

  .top-bar .theme-toggle {
    grid-area: theme;
  }

  .top-bar .top-search {
    grid-area: search;
  }

  body[data-page="blog"] .top-bar nav {
    justify-self: end;
    margin-right: 0.25rem;
    max-width: 100%;
  }

  .content {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .top-bar {
    margin-top: 1.1rem;
    padding: 0.85rem 0.95rem;
    gap: 0.75rem;
  }

  nav {
    gap: 0.55rem;
    justify-self: start;
    width: auto;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  nav a {
    padding: 0.15rem 0;
    font-size: 0.92rem;
  }

  .top-search {
    width: calc(100% - 0.45rem);
    justify-self: center;
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .top-search > input {
    width: 98%;
    justify-self: center;
    padding: 0.5rem 0.82rem;
  }

  .hero {
    margin-top: 0.55rem;
    margin-bottom: 1.05rem;
    padding: 1.15rem;
  }

  .panel {
    padding: 0.95rem;
  }

  .btn {
    min-height: 2.35rem;
  }

  .btn-small {
    min-height: 2rem;
  }

  .inline-actions {
    gap: 0.45rem;
  }

  .theme-toggle {
    justify-self: end;
  }

  footer {
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: 0.3rem;
  }

  .footer-copy {
    text-align: left;
    justify-self: start;
  }

  .visitor-stats {
    text-align: left;
    white-space: normal;
    justify-self: start;
  }
}

@media (max-width: 700px) {
  .brand {
    font-size: clamp(1.2rem, 5.6vw, 1.5rem);
  }

  nav {
    gap: 0.45rem;
  }

  nav a {
    font-size: 0.86rem;
  }

  .hero h1 {
    font-size: clamp(1.45rem, 8vw, 2rem);
    line-height: 1.2;
  }

  h2 {
    font-size: 1.14rem;
  }

  .status-note {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .contact-form,
  .contact-form input,
  .contact-form textarea {
    width: 100%;
  }

  .editor-toolbar {
    gap: 0.35rem;
  }

  .editor-toolbar .btn,
  .editor-toolbar select,
  .editor-toolbar input[type="file"] {
    flex: 1 1 140px;
  }

  .editor-toolbar input[type="color"] {
    flex: 0 0 2.2rem;
  }

  .inline-actions {
    width: 100%;
  }

  .inline-actions .btn {
    flex: 1 1 100%;
    text-align: center;
  }

  .dashboard-table thead {
    display: none;
  }

  .dashboard-table,
  .dashboard-table tbody,
  .dashboard-table tr,
  .dashboard-table td {
    display: block;
    width: 100%;
  }

  .dashboard-table tr {
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: var(--paper-soft);
    padding: 0.35rem 0.5rem;
    margin-top: 0.6rem;
  }

  .dashboard-table tr:first-child {
    margin-top: 0;
  }

  .dashboard-table td {
    border-bottom: 1px dashed var(--line-soft);
    padding: 0.5rem 0.35rem;
  }

  .dashboard-table td:last-child {
    border-bottom: none;
  }

  .dashboard-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 0.1rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .dashboard-table td.table-actions {
    white-space: normal;
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    border-bottom: none;
    padding-top: 0.6rem;
  }

  .dashboard-table td.table-actions::before {
    width: 100%;
  }

  .dashboard-table td.table-actions .btn {
    flex: 1 1 140px;
    margin-top: 0;
  }
}

#footer-fox-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 0.55rem;
}

#page-fox,
#page-fox-right {
  width: 96px;
  cursor: pointer;
  user-select: none;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.16));
  transition: transform 0.25s ease, filter 0.25s ease;
}

#page-fox:hover,
#page-fox-right:hover {
  transform: scale(1.02);
  filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.2));
}

#page-fox .fox-image,
#page-fox-right .fox-image {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

@media (max-width: 520px) {
  .top-bar,
  .hero,
  .content,
  footer,
  .contact-section,
  .auth-wrap {
    width: 94%;
  }

  .top-bar {
    border-radius: 0.8rem;
  }

  nav {
    gap: 0.4rem;
  }

  .top-search {
    width: calc(100% - 0.65rem);
  }

  .top-search > input {
    width: 97%;
  }

  .theme-toggle {
    width: 2rem;
    height: 2rem;
  }

  .panel {
    padding: 0.85rem;
    border-radius: 0.8rem;
  }

  .hero {
    border-radius: 0.8rem;
  }

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

  .stat-card strong {
    font-size: 1.2rem;
  }

  #footer-fox-row {
    margin-top: 0.45rem;
  }

  #page-fox,
  #page-fox-right {
    width: 74px;
  }
}

@media (max-width: 390px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .brand {
    letter-spacing: 0.01em;
  }

  nav a {
    font-size: 0.88rem;
  }
}
