:root {
  --admin-bg: var(--bg, #f4f2ed);
  --admin-panel: var(--white, #fdfcfa);
  --admin-line: var(--line, rgba(20, 20, 16, 0.1));
  --admin-ink: var(--ink, #141410);
  --admin-soft: var(--ink-soft, #4a4840);
  --admin-muted: var(--ink-muted, #9a9890);
  --admin-accent: var(--accent, #3a5226);
  --admin-gold: var(--gold, #a87c3e);
  --admin-danger: #8f4636;
  --admin-radius: 6px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--admin-bg);
  color: var(--admin-ink);
  font-family: 'DM Sans', sans-serif;
}

body.admin-shell {
  cursor: auto;
  overflow-x: auto;
}

a {
  color: inherit;
}

.admin-shell section {
  padding: 0;
  background: transparent;
}

.admin-shell a,
.admin-shell button {
  cursor: pointer !important;
}

.admin-shell input,
.admin-shell textarea,
.admin-shell select,
.admin-shell label {
  cursor: auto !important;
}

.admin-shell-login {
  min-height: 100vh;
  padding: clamp(1rem, 2vw, 2rem);
  background:
    radial-gradient(circle at top right, rgba(122, 156, 101, 0.14), transparent 28%),
    radial-gradient(circle at bottom left, rgba(168, 124, 62, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0));
}

.admin-login-shell {
  width: min(1240px, 100%);
  min-height: calc(100vh - clamp(2rem, 4vw, 4rem));
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.admin-shell .auth-stage {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, .82fr);
  gap: 0;
  min-height: min(650px, calc(100vh - clamp(2rem, 4vw, 4rem)));
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.12)),
    linear-gradient(180deg, rgba(244, 242, 237, 0.92), rgba(238, 236, 229, 0.86));
  border: 1px solid var(--admin-line);
  border-radius: calc(var(--admin-radius) * 3);
  box-shadow: 0 24px 80px rgba(20, 20, 16, 0.08);
}

.admin-shell .auth-stage::before,
.admin-shell .auth-stage::after {
  content: '';
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.admin-shell .auth-stage::before {
  top: -14%;
  right: -10%;
  width: 42rem;
  height: 42rem;
  border: 1px solid rgba(58, 82, 38, 0.14);
  box-shadow:
    0 0 0 6rem rgba(58, 82, 38, 0.03),
    0 0 0 12rem rgba(58, 82, 38, 0.02);
}

.admin-shell .auth-stage::after {
  bottom: -18%;
  left: -14%;
  width: 28rem;
  height: 28rem;
  background: radial-gradient(circle, rgba(168, 124, 62, 0.08), rgba(168, 124, 62, 0));
}

.admin-shell .auth-stage-copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  padding: clamp(4.5rem, 7vw, 6rem) clamp(3rem, 5vw, 4rem);
}

.admin-shell .auth-stage-copy .admin-kicker {
  margin: 0 0 1.5rem;
  letter-spacing: .2em;
  color: var(--accent, #3A5226);
}

.admin-page-head .admin-kicker {
  margin: 0 0 1.5em;
  letter-spacing: .2em;
  color: var(--accent, #3A5226);
}

.admin-shell .auth-stage-copy h1,
.admin-page-head h1 {
  font-family: 'Cormorant', serif;
  font-weight: 300;
  font-size: clamp(3rem, 5vw, 5.5rem);
  line-height: 1.05;
  letter-spacing: -.01em;
}

.admin-shell .auth-stage-copy h1 {
  max-width: 11ch;
}

.admin-shell .auth-stage-copy h1 {
  margin: 0 0 1.2rem;
}

.admin-page-head h1 {
  max-width: none;
  margin: 0 0 1.3em;
}

.admin-shell .auth-stage-lead {
  max-width: 380px;
  font-size: 1rem;
  color: var(--admin-soft);
  font-weight: 300;
  line-height: 1.6;
  margin: 0;
}

.admin-shell .auth-form-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2.25rem, 4vw, 3rem) clamp(2rem, 4vw, 4rem);
  background:
    linear-gradient(180deg, rgba(253, 252, 250, 0.94), rgba(253, 252, 250, 0.84));
  border-left: 1px solid rgba(20, 20, 16, 0.08);
  backdrop-filter: blur(16px);
}

.admin-shell .auth-form-kicker {
  margin: 0 0 1.5rem;
  font-family: 'DM Mono', monospace;
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--admin-accent);
}

.admin-shell .auth-form {
  gap: 1.2rem;
}

.admin-shell .auth-form .form-field label {
  color: var(--admin-soft);
}

.admin-shell .auth-form .form-field input {
  min-height: 3.3rem;
  border-color: rgba(20, 20, 16, 0.08);
  background: rgba(255, 255, 255, 0.92);
}

.admin-shell .auth-form .admin-button-primary {
  width: 100%;
  min-height: 3.45rem;
  margin-top: .25rem;
}

.admin-shell .auth-stage-copy p,
.admin-page-head p {
  color: var(--admin-soft);
  line-height: 1.7;
  margin: 0;
}

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

.admin-sidebar {
  padding: 2rem 1.25rem;
  border-right: 1px solid var(--admin-line);
  background: rgba(255, 255, 255, 0.5);
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
}

.admin-brand {
  display: grid;
  gap: .18em;
  margin-bottom: 2.4rem;
  font-family: 'Cormorant', serif;
  font-size: clamp(1.6rem, 2vw, 2rem);
  line-height: 1.08;
  text-decoration: none;
}

.admin-brand-lead,
.admin-brand-name {
  display: block;
}

.admin-brand-name {
  padding-left: .02em;
}

.admin-sidebar-group + .admin-sidebar-group {
  margin-top: 1.5rem;
}

.admin-sidebar-label,
.admin-kicker {
  font-family: 'DM Mono', monospace;
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--admin-accent);
}

.admin-nav-link {
  display: block;
  padding: .5rem 0;
  text-decoration: none;
  color: var(--admin-soft);
}

.admin-nav-link:hover {
  color: var(--admin-accent);
}

.admin-main {
  padding: 2rem;
}

.admin-main-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--admin-line);
}

.admin-credit {
  margin: 1.5rem 0 0;
  font-family: 'DM Mono', monospace;
  font-size: .64rem;
  letter-spacing: .08em;
  line-height: 1.8;
  text-transform: uppercase;
  color: var(--admin-muted);
  text-align: center;
}

.admin-credit a {
  color: var(--admin-accent);
  text-decoration: none;
}

.admin-credit a:hover {
  color: var(--admin-gold);
}

.admin-page-head {
  margin-bottom: 2rem;
}

.admin-page-head-inline {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.admin-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.admin-shell .admin-card,
.admin-shell .admin-panel-card {
  background: var(--admin-panel);
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius);
  padding: 1.25rem;
}

.admin-card strong {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--admin-muted);
}

.admin-card span {
  display: block;
  margin-top: .8rem;
  font-family: 'Cormorant', serif;
  font-size: 2.4rem;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

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

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

.form-field {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.form-field label {
  font-family: 'DM Mono', monospace;
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--admin-muted);
}

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: .85rem 1rem;
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius);
  background: white;
  color: var(--admin-ink);
  font: inherit;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: .7rem;
}

.checkbox-field input {
  width: auto;
}

.form-field-error input,
.form-field-error textarea,
.form-field-error select {
  border-color: var(--admin-danger);
}

.field-error {
  color: var(--admin-danger);
  font-size: .88rem;
}

.field-error-box {
  padding: .9rem 1rem;
  border-radius: var(--admin-radius);
  background: rgba(143, 70, 54, 0.08);
}

.field-help {
  color: var(--admin-muted);
  font-size: .9rem;
}

.form-actions,
.page-head-actions,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.form-actions-split {
  justify-content: space-between;
}

.admin-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .8rem 1rem;
  border-radius: var(--admin-radius);
  border: 1px solid var(--admin-line);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.admin-button-primary {
  background: var(--admin-accent);
  color: #fff;
  border-color: var(--admin-accent);
}

.admin-button-danger {
  border-color: rgba(143, 70, 54, 0.25);
  color: var(--admin-danger);
}

.admin-button-ghost {
  color: var(--admin-ink);
}

.admin-alert {
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: var(--admin-radius);
}

.admin-alert-success {
  background: rgba(58, 82, 38, 0.1);
  color: var(--admin-accent);
}

.admin-alert-error {
  background: rgba(143, 70, 54, 0.1);
  color: var(--admin-danger);
}

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

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

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

.admin-table th {
  font-family: 'DM Mono', monospace;
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--admin-muted);
}

.admin-logout-form {
  margin-top: 2rem;
}

.admin-logout-button {
  width: 100%;
  justify-content: flex-start;
  background: none;
}

.rich-editor {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.rich-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}

.rich-editor-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.9rem;
  padding: .7rem .85rem;
  border: 1px solid var(--admin-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--admin-ink);
  font-family: 'DM Mono', monospace;
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition:
    border-color .16s ease,
    background-color .16s ease,
    color .16s ease,
    box-shadow .16s ease;
}

.rich-editor-tool[data-active="true"] {
  border-color: rgba(58, 82, 38, 0.36);
  background: rgba(58, 82, 38, 0.12);
  color: var(--admin-accent);
  box-shadow: inset 0 0 0 1px rgba(58, 82, 38, 0.08);
}

.rich-editor-tool strong,
.rich-editor-tool em,
.rich-editor-tool u {
  font: inherit;
}

.rich-editor-tool strong {
  font-weight: 700;
}

.rich-editor-tool em {
  font-style: italic;
}

.rich-editor-surface {
  min-height: 26rem;
  padding: 1.15rem 1.2rem;
  border: 1px solid var(--admin-line);
  border-radius: calc(var(--admin-radius) * 2);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(253, 252, 250, 0.96));
  color: var(--admin-ink);
  font-size: 1rem;
  line-height: 1.8;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.rich-editor-surface:focus {
  border-color: rgba(58, 82, 38, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 0 0 3px rgba(58, 82, 38, 0.08);
}

.rich-editor-surface[data-empty="true"][data-focused="false"]::before {
  content: attr(data-placeholder);
  color: var(--admin-muted);
}

.rich-editor-surface > :first-child {
  margin-top: 0;
}

.rich-editor-surface > :last-child {
  margin-bottom: 0;
}

.rich-editor-surface p,
.rich-editor-surface ul,
.rich-editor-surface h1,
.rich-editor-surface h2,
.rich-editor-surface h3,
.rich-editor-surface figure {
  margin: 0 0 1rem;
}

.rich-editor-surface h1,
.rich-editor-surface h2,
.rich-editor-surface h3 {
  font-family: 'Cormorant', serif;
  line-height: 1.12;
  color: var(--admin-ink);
}

.rich-editor-surface h1 {
  font-size: 2rem;
}

.rich-editor-surface h2 {
  font-size: 1.7rem;
}

.rich-editor-surface h3 {
  font-size: 1.35rem;
}

.rich-editor-surface ul {
  padding-left: 1.25rem;
}

.rich-editor-surface a {
  color: var(--admin-accent);
  text-decoration-thickness: .08em;
  text-underline-offset: .14em;
}

.rich-editor-panels {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.rich-editor-panel {
  padding: .95rem 1rem;
  border: 1px solid var(--admin-line);
  border-radius: calc(var(--admin-radius) * 1.5);
  background: rgba(255, 255, 255, 0.78);
}

.rich-editor-panel-copy {
  margin-bottom: .7rem;
  color: var(--admin-soft);
  font-size: .92rem;
  line-height: 1.6;
}

.rich-editor-panel-row,
.rich-editor-panel-grid {
  display: grid;
  gap: .75rem;
}

.rich-editor-panel-row {
  grid-template-columns: minmax(0, 1fr);
}

.rich-editor-panel-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: .75rem;
}

.rich-editor-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
}

.rich-editor-panel input {
  width: 100%;
  padding: .8rem .95rem;
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius);
  background: #fff;
  color: var(--admin-ink);
  font: inherit;
}

.rich-editor-media {
  position: relative;
  overflow: hidden;
  margin: 1.25rem 0;
  border: 1px solid var(--admin-line);
  border-radius: calc(var(--admin-radius) * 2);
  background: #fff;
}

.rich-editor-media img {
  display: block;
  width: 100%;
  max-height: 20rem;
  object-fit: cover;
}

.rich-editor-media-caption {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding: .85rem 1rem 1rem;
}

.rich-editor-media-caption span {
  font-family: 'DM Mono', monospace;
  font-size: .62rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--admin-muted);
}

.rich-editor-media-caption strong {
  font-size: .95rem;
  line-height: 1.55;
  color: var(--admin-ink);
}

.rich-editor-media-actions {
  position: absolute;
  top: .75rem;
  right: .75rem;
  display: flex;
  gap: .5rem;
}

.rich-editor-media-action {
  padding: .45rem .7rem;
  border: 1px solid rgba(20, 20, 16, 0.14);
  border-radius: 999px;
  background: rgba(253, 252, 250, 0.92);
  color: var(--admin-ink);
  font-family: 'DM Mono', monospace;
  font-size: .64rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

  .admin-sidebar {
    position: static;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--admin-line);
  }

  .admin-card-grid,
  .form-grid-2,
  .form-grid-3,
  .admin-shell .auth-stage {
    grid-template-columns: 1fr;
  }

  .admin-page-head-inline,
  .form-actions-split {
    flex-direction: column;
    align-items: stretch;
  }

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

  .admin-shell .auth-stage {
    min-height: auto;
  }

  .admin-shell .auth-stage-copy,
  .admin-shell .auth-form-shell {
    padding: 1.5rem;
  }

  .admin-shell .auth-stage-copy h1 {
    max-width: none;
    font-size: clamp(2.7rem, 14vw, 4.2rem);
  }

  .admin-shell .auth-stage::before {
    width: 24rem;
    height: 24rem;
    right: -25%;
  }
}

@media (max-width: 900px) {
  .admin-shell .auth-stage-copy .admin-kicker {
    font-size: .62rem;
    letter-spacing: .16em;
    margin-bottom: 1rem;
  }

  .admin-shell .auth-stage-copy h1 {
    margin-bottom: 1rem;
  }
}
