* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  font-family: "Segoe UI Variable", "Segoe UI", sans-serif;
  background: #05090c;
  color: #f4f1ea;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(circle at 50% 0, #10242b, transparent 35rem), #05090c;
}

button,
input,
textarea,
select {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #d8b66f;
  outline-offset: 2px;
}

.auth-card {
  width: min(32rem, calc(100% - 2rem));
  margin: clamp(3rem, 12vh, 8rem) auto;
  padding: clamp(1.5rem, 5vw, 3rem);
  border: 1px solid #27353c;
  border-radius: 1.2rem;
  background: #0b1318;
  box-shadow: 0 2rem 8rem rgb(0 0 0 / 45%);
}

.admin-mark {
  width: 2.5rem;
  aspect-ratio: 1;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d8b66f;
  border-radius: 50%;
  color: #d8b66f;
  font: 1.4rem Georgia, serif;
}

.eyebrow {
  margin: 1.2rem 0 0.4rem;
  color: #d8b66f;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.auth-card h1 {
  margin: 0;
  font: 500 clamp(2rem, 6vw, 3.2rem) Georgia, serif;
}

.auth-card > p:not(.eyebrow) {
  color: #aab5bb;
  line-height: 1.6;
}

.auth-card label,
.field {
  display: grid;
  gap: 0.35rem;
  color: #c5cdd1;
  font-size: 0.78rem;
  font-weight: 700;
}

.auth-card label {
  margin: 0.8rem 0;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #34444d;
  border-radius: 0.55rem;
  background: #071015;
  color: #f4f1ea;
  padding: 0.7rem 0.75rem;
  font-weight: 400;
}

textarea {
  min-height: 7rem;
  resize: vertical;
  line-height: 1.5;
}

input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
}

input[type="color"] {
  min-height: 2.7rem;
  padding: 0.25rem;
}

button,
.cms-header a,
.auth-card button {
  border: 1px solid #41515a;
  border-radius: 0.55rem;
  background: #101c23;
  color: #f4f1ea;
  padding: 0.58rem 0.8rem;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.cms-header a:hover {
  border-color: #d8b66f;
}

button.primary,
.auth-card button {
  border-color: #d8b66f;
  background: #d8b66f;
  color: #181109;
  font-weight: 900;
}

.auth-card form > button {
  width: 100%;
  margin-top: 0.5rem;
}

.auth-card > a {
  display: inline-block;
  margin-top: 1rem;
  color: #b9c5ca;
}

.form-status {
  min-height: 1.25rem;
  color: #edb1a7;
  font-size: 0.8rem;
}

.cms {
  min-height: 100dvh;
}

.cms-header {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 4.3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #27353c;
  background: rgb(5 9 12 / 92%);
  backdrop-filter: blur(16px);
}

.cms-header > div {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.cms-header strong,
.cms-header small {
  display: block;
}

.cms-header small {
  margin-top: 0.15rem;
  color: #9eabb2;
}

.cms-header nav {
  display: flex;
  gap: 0.45rem;
}

.cms-layout {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  min-height: calc(100dvh - 4.3rem);
}

.cms-nav {
  position: sticky;
  top: 4.3rem;
  align-self: start;
  height: calc(100dvh - 4.3rem);
  display: grid;
  align-content: start;
  gap: 0.25rem;
  padding: 1rem 0.7rem;
  border-right: 1px solid #27353c;
  background: #070d11;
}

.cms-nav button {
  border-color: transparent;
  background: transparent;
  color: #aab5bb;
  text-align: left;
}

.cms-nav button.active {
  background: #132129;
  color: #fff;
  box-shadow: inset 3px 0 #d8b66f;
}

.cms-content {
  width: min(100%, 92rem);
  padding: clamp(1rem, 3vw, 2.2rem);
}

.section-heading {
  margin-bottom: 1.25rem;
}

.section-heading h1 {
  margin: 0;
  font: 500 clamp(1.8rem, 4vw, 3rem) Georgia, serif;
}

.section-heading p {
  max-width: 70ch;
  color: #9eabb2;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.editor-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

.editor-card {
  margin-bottom: 0.9rem;
  padding: 1rem;
  border: 1px solid #28373f;
  border-radius: 0.8rem;
  background: #0b1318;
}

.editor-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.editor-card h2,
.editor-card h3 {
  margin: 0;
}

.editor-card h2 {
  font: 500 1.35rem Georgia, serif;
}

.editor-card h3 {
  font-size: 0.9rem;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.card-actions button {
  padding: 0.38rem 0.55rem;
  font-size: 0.7rem;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: #c5cdd1;
  font-size: 0.78rem;
  font-weight: 700;
}

.subcards {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.subcard {
  padding: 0.75rem;
  border: 1px solid #26343b;
  border-radius: 0.65rem;
  background: #070e12;
}

.rich-toolbar {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.35rem;
}

.rich-toolbar button {
  min-width: 2rem;
  padding: 0.3rem;
  font-size: 0.7rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.metric {
  padding: 1rem;
  border: 1px solid #2c3a42;
  border-radius: 0.8rem;
  background: #0b1318;
}

.metric strong {
  display: block;
  color: #d8b66f;
  font-size: 1.6rem;
}

.metric span {
  color: #9eabb2;
  font-size: 0.75rem;
}

.preview-tools {
  display: flex;
  gap: 0.4rem;
  margin: 1rem 0 0.5rem;
}

.preview-wrap {
  width: 100%;
  height: 34rem;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 1rem;
  border: 1px solid #28373f;
  border-radius: 0.8rem;
  background: #020405;
}

.preview-wrap iframe {
  width: 100%;
  height: 100%;
  border: 1px solid #4a5961;
  background: #fff;
  transition: width 0.2s ease;
}

.preview-wrap[data-size="tablet"] iframe {
  width: 768px;
}

.preview-wrap[data-size="mobile"] iframe {
  width: 390px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.75rem;
}

.media-item {
  overflow: hidden;
  border: 1px solid #2c3a42;
  border-radius: 0.7rem;
  background: #091116;
}

.media-preview {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #020405;
  color: #9eabb2;
}

.media-preview img,
.media-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-item > div:last-child {
  padding: 0.6rem;
}

.media-item strong,
.media-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-item small {
  color: #91a0a7;
}

.media-item .card-actions {
  margin-top: 0.5rem;
}

.history-list,
.audit-list {
  display: grid;
  gap: 0.4rem;
}

.history-row,
.audit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.65rem;
  border: 1px solid #26343b;
  border-radius: 0.55rem;
  background: #080f13;
  font-size: 0.78rem;
}

.save-state {
  position: fixed;
  z-index: 30;
  right: 1rem;
  bottom: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #34444d;
  border-radius: 999px;
  background: #0b1318;
  color: #9eabb2;
  font-size: 0.72rem;
  box-shadow: 0 0.8rem 2rem rgb(0 0 0 / 35%);
}

.save-state.dirty {
  color: #d8b66f;
}

.save-state.error {
  color: #ffb7ac;
}

@media (max-width: 850px) {
  .cms-header {
    align-items: flex-start;
  }

  .cms-header nav {
    overflow-x: auto;
  }

  .cms-layout {
    display: block;
  }

  .cms-nav {
    position: sticky;
    z-index: 15;
    top: 4.3rem;
    width: 100%;
    height: auto;
    display: flex;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid #27353c;
  }

  .cms-nav button {
    white-space: nowrap;
  }

  .editor-grid,
  .editor-grid.three,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
