:root {
  --bg: #f8faf6;
  --panel: #ffffff;
  --ink: #2b3a2e;
  --muted: #6b7a6e;
  --line: #e3eadf;
  --green: #5b8c5a;
  --green-d: #4a7649;
  --warm: #e8c07a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(40, 60, 45, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30; flex-wrap: wrap;
}
.brand { font-size: 18px; font-weight: 600; color: var(--green-d); white-space: nowrap; }
.topbar-center { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.user-area { display: flex; align-items: center; gap: 10px; }
.user-area .email { color: var(--muted); font-size: 13px; }
.user-area .role {
  font-size: 11px; padding: 1px 6px; border-radius: 6px;
  background: var(--warm); color: #5a4413;
}

/* ---------- dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: 100%; left: 0; margin-top: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 28px rgba(40, 60, 45, 0.14);
  min-width: 190px; z-index: 40; padding: 6px;
}
.dropdown-menu.hidden { display: none; }
.dropdown-item { padding: 8px 10px; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--ink); }
.dropdown-item:hover { background: #eef5ec; }
.dropdown-item.active { color: var(--green-d); font-weight: 600; }
.dropdown-item.add { color: var(--green); border-top: 1px solid var(--line); margin-top: 4px; }
.dropdown-sep { height: 1px; background: var(--line); margin: 4px 0; }
.resume-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.resume-row:hover { background: #eef5ec; }
.resume-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume-row .del { color: #c0533f; cursor: pointer; font-size: 12px; margin-left: 8px; }
.resume-empty { padding: 10px; color: var(--muted); font-size: 12px; }

/* ---------- layout: 2 columns ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(320px, 38%) 1fr;
  gap: 14px; padding: 14px; align-items: start;
  max-width: 1500px; margin: 0 auto;
}

/* ---------- editor pane (left) ---------- */
.editor-pane {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column;
  height: calc(100vh - 96px); overflow: hidden;
}
.section-tabs {
  display: flex; gap: 2px; padding: 10px 10px 0;
  overflow-x: auto; border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.section-tabs::-webkit-scrollbar { height: 4px; }
.section-tabs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.tab {
  padding: 9px 13px; font-size: 13px; color: var(--muted);
  cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--green-d); }
.tab.active { color: var(--green-d); font-weight: 600; border-bottom-color: var(--green); }
.editor-scroll { overflow: auto; padding: 14px; flex: 1; }

/* ---------- preview pane (right) ---------- */
.preview-wrap {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column;
  height: calc(100vh - 96px); overflow: hidden;
}
.preview-toolbar {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.preview-toolbar .spacer { flex: 1; }
.btn.icon { padding: 4px 11px; font-size: 16px; line-height: 1; }
.zoom-label { font-size: 12px; color: var(--muted); min-width: 40px; text-align: center; }
.preview-scroll { overflow: auto; flex: 1; padding: 18px; background: #eef2ea; }
.preview-canvas { margin: 0 auto; position: relative; }
.preview { transform-origin: top left; background: #fff; }
.preview .page { margin: 0; }

/* ---------- form / fields ---------- */
.form { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field textarea, .field select {
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px;
  font: inherit; background: #fff; color: var(--ink);
}
.field textarea { resize: vertical; min-height: 56px; }
.group {
  border: 1px dashed var(--line); border-radius: 8px; padding: 10px;
  display: flex; flex-direction: column; gap: 8px; background: #fbfdfa;
}
.group-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; color: var(--green-d); }
.group-head .add { font-size: 12px; color: var(--green); cursor: pointer; }
.item-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.item-remove { font-size: 12px; color: #c0533f; cursor: pointer; text-align: right; }
.group-item { border-style: solid; }
.item-move-row { display: flex; gap: 6px; justify-content: flex-end; }
.item-move {
  cursor: pointer; font-size: 13px; line-height: 1; color: var(--green-d);
  background: #eef5ec; border: 1px solid var(--line); border-radius: 5px;
  width: 24px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  user-select: none;
}
.item-move:hover { background: var(--green); color: #fff; border-color: var(--green); }
.item-move.disabled { color: #c5cdc6; background: #f4f6f4; border-color: #ececec; cursor: default; }
.item-move.disabled:hover { color: #c5cdc6; background: #f4f6f4; }
.tpl-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--green); }
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn.primary:hover { background: var(--green-d); }
.btn.block { width: 100%; margin-bottom: 8px; }

/* ---------- modal / toast ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(30, 40, 32, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal.hidden, .toast.hidden, .dropdown-menu.hidden { display: none; }
.modal-card {
  background: #fff; border-radius: 12px; padding: 22px; width: 320px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal-card h3 { margin: 0 0 14px; color: var(--green-d); }
.modal-card .field { margin-bottom: 10px; }
.modal-card .row { display: flex; gap: 8px; margin-top: 8px; }
.modal-card .switch { font-size: 12px; color: var(--muted); margin-top: 10px; cursor: pointer; text-align: center; }
.modal-card .err { color: #c0533f; font-size: 12px; min-height: 16px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 8px;
  font-size: 13px; z-index: 60;
}

/* ---------- mobile view switch ---------- */
.mobile-switch { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding-bottom: 70px; }
  .editor-pane, .preview-wrap { height: auto; max-height: none; }
  .mobile-switch {
    display: flex; position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
    background: #fff; border: 1px solid var(--line); border-radius: 999px;
    box-shadow: 0 6px 20px rgba(0,0,0,.14); overflow: hidden; z-index: 50;
  }
  .mobile-switch button {
    border: none; background: transparent; padding: 11px 26px;
    font-size: 14px; color: var(--muted); cursor: pointer;
  }
  .mobile-switch button.active { background: var(--green); color: #fff; }
  .layout.view-preview .editor-pane { display: none; }
  .layout.view-edit .preview-wrap { display: none; }
}
