:root {
  --paper: #f6f1e6;
  --panel: #fffaf0;
  --ink: #15110d;
  --muted: rgba(21, 17, 13, .62);
  --line: rgba(21, 17, 13, .14);
  --line-strong: rgba(21, 17, 13, .28);
  --black: #11100e;
  --red: #bd3d26;
  --gold: #caa35a;
  --blue: #235d74;
  --green: #376b49;
  --shadow: 0 18px 44px rgba(0, 0, 0, .12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(189, 61, 38, .08), transparent 34%),
    linear-gradient(280deg, rgba(35, 93, 116, .10), transparent 38%),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

body.is-locked {
  overflow: hidden;
}

body.is-locked .adminTop,
body.is-locked .adminShell,
body.is-locked .mediaDrawer {
  display: none;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.adminGate {
  display: none;
}

body.is-locked .adminGate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
}

.adminGate__card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, .88);
  box-shadow: var(--shadow);
  padding: 22px;
}

.adminGate__back {
  display: inline-flex;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.adminGate__back:hover {
  color: var(--ink);
}

.adminGate__mark {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  background: var(--black);
  color: var(--paper);
  font-weight: 900;
  letter-spacing: .05em;
}

.adminGate h1 {
  margin-bottom: 18px;
}

.adminGate label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 900;
}

.adminGate input {
  width: 100%;
  border: 1px solid rgba(21, 17, 13, .24);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  font-weight: 800;
}

.adminGate input:focus {
  outline: 2px solid rgba(202, 163, 90, .34);
  border-color: var(--gold);
}

.adminGate .btn {
  width: 100%;
  margin-top: 12px;
}

.adminGate__error {
  min-height: 18px;
  margin: 12px 0 0;
  color: #8e2819;
  font-size: 13px;
  font-weight: 900;
}

.adminTop {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 241, 230, .93);
  backdrop-filter: blur(12px);
}

.adminBrand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
}

.adminBrand__mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--paper);
  background: var(--black);
  border-radius: var(--radius);
  font-weight: 900;
  letter-spacing: .04em;
}

.adminBrand strong,
.adminBrand small {
  display: block;
  line-height: 1.1;
}

.adminBrand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.adminActions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.statusPill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .58);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.statusPill.is-dirty {
  color: #7a3419;
  border-color: rgba(189, 61, 38, .35);
  background: rgba(189, 61, 38, .10);
}

.statusPill.is-saved {
  color: var(--green);
  border-color: rgba(55, 107, 73, .32);
  background: rgba(55, 107, 73, .10);
}

.btn,
.iconBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .72);
  color: var(--ink);
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.btn:hover,
.iconBtn:hover {
  transform: translateY(-1px);
  border-color: rgba(21, 17, 13, .48);
  background: #fff;
}

.btn--dark {
  color: var(--paper);
  background: var(--black);
  border-color: var(--black);
}

.btn--dark:hover {
  background: #26211b;
}

.btn--danger {
  color: #8e2819;
  border-color: rgba(189, 61, 38, .35);
  background: rgba(189, 61, 38, .08);
}

.btn--full {
  width: 100%;
}

.iconBtn {
  width: 34px;
  padding: 0;
}

.adminShell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: calc(100vh - 63px);
}

.sidebar {
  position: sticky;
  top: 63px;
  align-self: start;
  height: calc(100vh - 63px);
  overflow: auto;
  padding: 16px;
  border-right: 1px solid var(--line);
}

.sideBlock {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .45);
}

.sideBlock + .sideBlock {
  margin-top: 12px;
}

.sideTitle {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.sideNote {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.sectionNav {
  display: grid;
  gap: 6px;
}

.sectionNav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  padding: 9px 10px;
  color: var(--ink);
  text-align: left;
  font-weight: 900;
}

.sectionNav button span {
  color: var(--muted);
  font-size: 11px;
}

.sectionNav button:hover,
.sectionNav button.is-active {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, .75);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 38vw);
  gap: 16px;
  padding: 16px;
}

.editorPanel,
.previewPanel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, .78);
  box-shadow: var(--shadow);
}

.editorPanel {
  overflow: hidden;
}

.previewPanel {
  position: sticky;
  top: 79px;
  align-self: start;
  height: calc(100vh - 95px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panelHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panelHead--compact {
  align-items: center;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--red);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .10em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(26px, 4vw, 44px);
}

h2 {
  font-size: 20px;
}

.panelMeta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.editorRoot {
  padding: 16px;
}

.objectBlock,
.arrayBlock,
.field {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .56);
}

.objectBlock + .objectBlock,
.objectBlock + .arrayBlock,
.objectBlock + .field,
.arrayBlock + .objectBlock,
.arrayBlock + .arrayBlock,
.arrayBlock + .field,
.field + .objectBlock,
.field + .arrayBlock,
.field + .field {
  margin-top: 10px;
}

.objectBlock[open],
.arrayBlock[open] {
  background: rgba(255, 255, 255, .70);
}

.blockSummary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  list-style: none;
  cursor: pointer;
}

.blockSummary::-webkit-details-marker {
  display: none;
}

.summaryTitle {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  font-weight: 900;
}

.summaryTitle span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summaryMeta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.objectBody,
.arrayBody {
  padding: 0 12px 12px;
}

.rootObject {
  display: grid;
  gap: 10px;
}

.field {
  padding: 12px;
}

.fieldTop,
.itemTools,
.addRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fieldTop {
  margin-bottom: 7px;
}

.field label,
.manualPath label {
  color: rgba(21, 17, 13, .84);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .01em;
}

.field input[type="text"],
.field input[type="number"],
.field textarea,
.field select,
.manualPath input,
.addRow input,
.addRow select {
  width: 100%;
  border: 1px solid rgba(21, 17, 13, .22);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  font-weight: 700;
}

.field textarea {
  min-height: 94px;
  line-height: 1.45;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.manualPath input:focus,
.addRow input:focus,
.addRow select:focus {
  outline: 2px solid rgba(202, 163, 90, .34);
  border-color: var(--gold);
}

.checkLine {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  font-weight: 900;
}

.checkLine input {
  width: 18px;
  height: 18px;
  accent-color: var(--black);
}

.fieldActions,
.arrayActions,
.nodeActions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tinyBtn {
  min-height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .72);
  padding: 6px 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.tinyBtn:hover {
  background: #fff;
}

.tinyBtn--danger {
  color: #8e2819;
  border-color: rgba(189, 61, 38, .35);
}

.arrayItem {
  border: 1px dashed rgba(21, 17, 13, .23);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(246, 241, 230, .48);
}

.arrayItem + .arrayItem {
  margin-top: 10px;
}

.itemTools {
  margin-bottom: 8px;
}

.itemIndex {
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.addRow {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-strong);
}

.addRow input {
  max-width: 220px;
}

.addRow select {
  max-width: 150px;
}

.mediaField {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.mediaPreview {
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #14110e;
}

.mediaPreview img,
.mediaPreview video {
  display: block;
  width: 100%;
  max-height: 210px;
  object-fit: cover;
}

.jsonTools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.jsonEditor {
  width: 100%;
  min-height: 68vh;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 14px;
  background: #11100e;
  color: #f8f0df;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
}

.previewFrame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  flex: 1;
}

.mediaDrawer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: stretch end;
  background: rgba(17, 16, 14, .38);
}

.mediaDrawer[hidden] {
  display: none;
}

.mediaDrawer__panel {
  width: min(560px, 100vw);
  height: 100vh;
  overflow: auto;
  padding: 16px;
  background: var(--paper);
  box-shadow: -18px 0 50px rgba(0, 0, 0, .22);
}

.mediaDrawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.manualPath {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .58);
}

.manualPath div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 7px;
}

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

.assetTile {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .68);
  text-align: left;
  padding: 0;
}

.assetTile:hover {
  border-color: var(--gold);
}

.assetThumb {
  display: grid;
  place-items: center;
  height: 116px;
  background: #14110e;
  color: var(--paper);
  font-size: 12px;
  font-weight: 900;
}

.assetThumb img,
.assetThumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.assetName {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 9px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .previewPanel {
    position: static;
    height: 70vh;
  }
}

@media (max-width: 840px) {
  .adminTop,
  .adminShell,
  .workspace,
  .mediaField,
  .manualPath div {
    display: block;
  }

  .adminActions {
    justify-content: flex-start;
    margin-top: 10px;
  }

  .adminBrand {
    min-width: 0;
  }

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

  .workspace {
    padding: 12px;
  }

  .previewPanel {
    margin-top: 12px;
  }

  .mediaField .btn,
  .manualPath .btn {
    width: 100%;
    margin-top: 8px;
  }

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