:root {
  --ink: #1c1d1b;
  --bg: #f4f4f1;
  --card: #fff;
  --line: #d9d9d3;
  --green: #5fa35a;
  --muted: #7a7a72;
  --err: #c82f2f;
  --radius: 10px;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  font-family:
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 8px 14px;
}
button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #10240f;
  font-weight: 600;
}
button.secondary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
button.ghost {
  background: transparent;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* login */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 {
  margin: 0;
  font-size: 24px;
}
.login-card input {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
.login-card button {
  background: var(--green);
  border-color: var(--green);
  color: #10240f;
  font-weight: 600;
  padding: 11px;
}
.err {
  color: var(--err);
  font-size: 13px;
  min-height: 16px;
}

/* bar */
.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.bar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.dirty {
  color: var(--err);
  font-size: 12px;
  margin-left: 10px;
}

/* editor */
.editor {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
details.section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
details.section > summary {
  padding: 14px 18px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
details.section > summary::-webkit-details-marker {
  display: none;
}
details.section > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--muted);
  transition: transform 0.15s;
}
details.section[open] > summary::before {
  transform: rotate(90deg);
}
.section-body {
  padding: 4px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field > label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.field input[type="text"],
.field input[type="number"],
.field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  resize: vertical;
}
.field textarea {
  min-height: 40px;
  line-height: 1.4;
}
.group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafaf8;
}
.group > .group-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* arrays */
.arr-item {
  position: relative;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px 12px 12px;
  background: #fff;
}
.arr-item > .arr-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  border: none;
  background: transparent;
  color: var(--err);
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
}
.arr-add {
  align-self: flex-start;
  font-size: 13px;
  padding: 6px 12px;
}
.arr-index {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

/* image */
.img-field {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.img-preview {
  width: 120px;
  height: 78px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: #eee;
}
.img-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.img-right .row {
  display: flex;
  gap: 8px;
}
.upload-btn {
  font-size: 13px;
  padding: 7px 12px;
  white-space: nowrap;
}

/* modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  z-index: 50;
}
.modal-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  width: min(680px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-card h2 {
  margin: 0;
  font-size: 18px;
}
.log {
  background: #10120f;
  color: #d6e6cf;
  border-radius: 8px;
  padding: 14px;
  overflow: auto;
  font-size: 12.5px;
  line-height: 1.45;
  max-height: 52vh;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}
.modal-actions .ghost {
  text-decoration: none;
  color: var(--ink);
}

/* toast */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 8px;
  z-index: 60;
  font-size: 14px;
}
.toast.err {
  background: var(--err);
}
