:root {
  --ink: #12262f;
  --sea: #0d2c36;
  --foam: #e7f3ee;
  --paper: #f7f3ea;
  --sand: #c4a36c;
  --coral: #c45c4a;
  --line: #d9d1c3;
  --display: "Fraunces", Georgia, serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: #07161d;
}

a { color: #1a6c7c; }
button, input, select, textarea { font: inherit; }

.bar {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr) auto;
  gap: 10px 18px;
  align-items: center;
  padding: 10px clamp(14px, 2vw, 28px);
  background: var(--sea);
  color: var(--foam);
  position: sticky;
  top: 0;
  z-index: 5;
}
.bar-brand, .bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bar b {
  font-family: var(--display);
  font-weight: 550;
  white-space: nowrap;
}
.bar-actions { justify-content: flex-end; flex-wrap: wrap; }

.btn {
  border: 1px solid rgba(255,255,255,0.16);
  background: transparent;
  color: var(--foam);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.bar .btn {
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0 14px;
  justify-content: center;
  font-size: 0.95rem;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
}
.bar label.btn { cursor: pointer; }
.btn:hover { background: rgba(255,255,255,0.08); }
.btn-accent {
  background: var(--sand);
  color: #1b1408;
  border-color: transparent;
  font-weight: 650;
}
.btn-danger { border-color: #e7a39a; color: #ffd4ce; }

.work {
  display: grid;
  grid-template-columns: 280px minmax(340px, 1fr) minmax(280px, 0.9fr);
  height: calc(100vh - 54px);
}
.work[hidden] { display: none; }
.editor-access {
  max-width: 680px;
  margin: 56px auto;
  padding: 24px;
  border-radius: 14px;
  background: var(--paper);
}
.editor-access h1 { margin-top: 0; }
.editor-access .btn {
  background: var(--sea);
  color: var(--foam);
}

.col {
  overflow: auto;
  min-width: 0;
}
.tree-col { background: #102832; color: var(--foam); padding: 12px; }
.form-col { background: var(--paper); padding: 16px 18px 40px; }
.preview-col { background: #efe7d6; padding: 16px; border-left: 1px solid var(--line); }

.tree-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tree-tools .btn { padding: 5px 9px; font-size: 0.85rem; }
.tree-col > .hint { color: rgba(231, 243, 238, 0.76); line-height: 1.45; margin: 8px 2px 14px; }

.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 0; padding-left: 14px; }
.tree button.n {
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
  border: 0;
  border-radius: 8px;
  padding: 5px 8px;
  cursor: pointer;
}
.tree button.n:hover, .tree button.n.sel { background: rgba(255,255,255,0.1); }
.tree button.n.sel { color: var(--sand); }

label { display: block; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: #5b6e75; margin: 12px 0 4px; }
label.check-label { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 0.95rem; }
label.check-label input { width: auto; }
input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}
textarea { min-height: 88px; resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 0.85rem; color: #5b6e75; margin: 4px 0 0; }
.asset-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.asset-preview { object-fit: cover; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.asset-preview[hidden] { display: none; }
.flag-preview { width: 54px; height: 36px; }
.cover-preview { width: 100px; height: 58px; }
.map-preview { width: 120px; height: 72px; }
.advanced { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 14px; }
.advanced summary { cursor: pointer; font-weight: 700; color: #245c68; }
.advanced[open] summary { margin-bottom: 8px; }
.advanced h2 { margin-top: 24px; }
.editor-cover {
  display: block;
  width: var(--image-scale, 100%);
  max-width: 100%;
  max-height: 180px;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  margin: 12px auto;
}
.empty { color: #5b6e75; }
.form-col input:focus, .form-col select:focus, .form-col textarea:focus { outline: 2px solid rgba(26, 108, 124, 0.25); border-color: #1a6c7c; }

.block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin: 10px 0;
  background: #fff;
}
.block-top {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.block-top select { width: auto; }
.mini { padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: #f6f1e6; cursor: pointer; }

h2 { font-family: var(--display); font-weight: 550; margin: 8px 0 12px; }
.preview-frame {
  display: block;
  width: 100%;
  height: calc(100vh - 126px);
  min-height: 520px;
  border: 0;
  border-radius: 12px;
  background: #f6f1e6;
}
.muted { opacity: 0.7; font-size: 0.9rem; }

.status { font-size: 0.85rem; line-height: 1.3; color: #b7cfc8; }

@media (max-width: 700px) {
  .bar { grid-template-columns: 1fr; }
  .bar-actions { justify-content: flex-start; }
  .row-2 { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 1100px) {
  .work { grid-template-columns: 1fr; height: auto; }
  .preview-col { border-left: 0; border-top: 1px solid var(--line); }
  .preview-frame { height: 75vh; min-height: 500px; }
}
