:root {
  --theme-color: #2f5785;
  --tag-color: #8bc34a;
  --ink: #222;
  --muted: #666;
  --line: #e6e6e6;
  --bg: #f0f2f5;
  --card: #fff;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: #1f2733;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
  flex-wrap: wrap;
}
.tb-left .logo { font-weight: 700; font-size: 16px; }
.tb-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tb-field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #cfd6e0; }
.tb-field select {
  background: #2c3744; color: #fff; border: 1px solid #3c4856;
  border-radius: 6px; padding: 5px 8px; font-size: 13px;
}
.btn {
  background: #3b82f6; color: #fff; border: none; border-radius: 6px;
  padding: 7px 12px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.btn:hover { background: #2f6fd6; }
.btn.ghost { background: transparent; border: 1px solid #4b5566; color: #cfd6e0; }
.btn.ghost:hover { background: #2c3744; }
.save-hint { font-size: 12px; color: #8bc34a; opacity: .9; }

/* ---------- Layout ---------- */
.layout {
  display: flex;
  gap: 18px;
  padding: 18px;
  align-items: flex-start;
}
.editor {
  flex: 1 1 420px;
  max-width: 460px;
  max-height: calc(100vh - 90px);
  overflow: auto;
}
.preview-wrap { flex: 1 1 600px; display: flex; justify-content: center; }

/* ---------- Editor cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}
.card-h {
  margin: 0 0 10px; font-size: 15px; color: #1f2733;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 2px solid #eef1f5; padding-bottom: 8px;
}
.item {
  border: 1px dashed #d7dde5; border-radius: 8px;
  padding: 10px; margin-bottom: 10px; background: #fafbfc;
}
.item-h {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: #555; margin-bottom: 8px; font-weight: 600;
}
.f { margin-bottom: 9px; }
.f-label { display: block; font-size: 12px; color: #6b7280; margin-bottom: 4px; }
/* 基本信息卡片：标签与内容字段之间间距更紧凑 */
.card-profile .f { margin-bottom: 5px; }
.card-profile .f-label { margin-bottom: 2px; }
.card-profile .item { padding: 8px 10px; }
.f.row { display: flex; align-items: center; gap: 8px; }
.f input[type="text"], .f textarea, .f input[type="color"] {
  width: 100%; border: 1px solid #d7dde5; border-radius: 6px;
  padding: 7px 9px; font-size: 13px; font-family: inherit; color: #222;
}
.f input[type="color"] { height: 34px; padding: 2px; }
.f textarea { resize: vertical; line-height: 1.5; }
.f input:focus, .f textarea:focus { outline: none; border-color: #3b82f6; }
.range { display: flex; gap: 8px; }
.range input { flex: 1; }
.btn-mini {
  background: #eef2ff; color: #3b5bdb; border: 1px solid #dbe4ff;
  border-radius: 5px; padding: 3px 9px; font-size: 12px; cursor: pointer;
}
.btn-mini:hover { background: #e0e7ff; }
.btn-mini.danger { background: #fdecec; color: #d64545; border-color: #f6cccc; }
.btn-mini.danger:hover { background: #f9d5d5; }

/* ---------- Resume base ---------- */
.resume {
  background: #fff;
  width: 794px;
  min-height: 1123px;
  padding: 48px 56px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}
.r-avatar {
  width: 150px; height: 188px; border-radius: 16px;
  object-fit: cover; border: 3px solid var(--theme-color); background: #eef1f5;
  display: flex; align-items: center; justify-content: center;
  font-size: 62px; font-weight: 700; color: var(--theme-color);
  flex: 0 0 auto;
}
.r-avatar-ph { width: 150px; height: 188px; }
.r-name { font-size: 28px; font-weight: 700; color: var(--theme-color); }
.r-sec-title {
  font-size: 16px; color: var(--theme-color); font-weight: 700;
  margin: 18px 0 10px; padding-left: 10px;
  border-left: 4px solid var(--theme-color);
}
.r-section { margin-bottom: 6px; }
.r-list { list-style: none; margin: 0; padding: 0; }
.r-list li { margin-bottom: 12px; }
.r-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.r-strong { font-weight: 700; color: #1f2733; }
.r-dim { color: var(--muted); font-weight: 400; }
.r-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.r-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.r-desc { margin-top: 4px; color: #333; }
.r-about { color: #333; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  background: var(--tag-color); color: #fff; border-radius: 14px;
  padding: 3px 12px; font-size: 12px; font-weight: 600;
}
.r-link { color: var(--theme-color); word-break: break-all; }
.chip {
  background: #f1f4f8; color: #445; border-radius: 12px;
  padding: 2px 10px; font-size: 12px;
}

/* ---------- 模块管理 ---------- */
.card-sub {
  font-size: 12px; color: #8a94a3; font-weight: 400; margin-left: 8px;
}
.sec-manager { display: flex; flex-direction: column; gap: 10px; }
.sec-active { display: flex; flex-wrap: wrap; gap: 8px; }
.sec-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #eef2ff; color: #3b5bdb; border: 1px solid #dbe4ff;
  border-radius: 16px; padding: 4px 10px; font-size: 13px; font-weight: 600;
}
.sec-del {
  background: transparent; border: none; color: #d64545; font-size: 16px;
  line-height: 1; cursor: pointer; padding: 0 2px;
}
.sec-del:hover { color: #a51b1b; }
.sec-add-row { display: flex; gap: 8px; align-items: center; }
.sec-add-row select {
  background: #fff; border: 1px solid #d7dde5; border-radius: 6px;
  padding: 5px 8px; font-size: 13px; color: #222;
}
.sec-add-row input[type="text"] {
  flex: 1; min-width: 0; border: 1px solid #d7dde5; border-radius: 6px;
  padding: 6px 8px; font-size: 13px; font-family: inherit; color: #222;
}
.sec-add-row input[type="text"]:focus { outline: none; border-color: #3b82f6; }
.sec-group-title {
  font-size: 13px; font-weight: 700; color: #3b5bdb;
  margin: 6px 0 2px; padding-top: 6px; border-top: 1px dashed #e6eaf0;
}
.card-sub-edit { margin-bottom: 8px; }
.card-sub-edit input {
  width: 100%; border: 1px solid #d7dde5; border-radius: 6px;
  padding: 6px 8px; font-size: 13px; font-family: inherit; color: #222;
}
.card-sub-edit input:focus { outline: none; border-color: #3b82f6; }

/* ---------- 头像上传（编辑器） ---------- */
.av-edit { display: flex; gap: 14px; align-items: flex-start; }
.av-prev-wrap { flex: 0 0 auto; }
.av-prev {
  width: 84px; height: 104px; border-radius: 12px; object-fit: cover;
  border: 2px dashed #c4ccd6; background: #eef1f5; display: flex;
  align-items: center; justify-content: center; font-size: 34px;
  font-weight: 700; color: #8a94a3;
}
.av-prev.ph { border-style: dashed; }
.av-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.av-actions .f-label { margin: 4px 0 0; }

/* ---------- Template 1 (default) ---------- */
.tpl-1 .r-header {
  display: flex; align-items: center; gap: 22px;
  border-bottom: 3px solid var(--theme-color);
  padding-bottom: 16px; margin-bottom: 18px;
}
.tpl-1 .r-head-info { flex: 1; }
.tpl-1 .r-contact { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 10px; }
.tpl-1 .r-sec-title { display: block; }

/* ---------- Template 2 (simple) ---------- */
.tpl-2 { padding: 44px 52px; }
.tpl-2 .r-header {
  text-align: center; border-bottom: 1px solid var(--line);
  padding-bottom: 14px; margin-bottom: 16px;
}
.tpl-2 .r-avatar, .tpl-2 .r-avatar-ph {
  width: 116px; height: 145px; font-size: 48px; margin: 0 auto 10px; border-radius: 14px;
}
.tpl-2 .r-name { font-size: 24px; }
.tpl-2 .r-contact { justify-content: center; margin-top: 8px; }
.tpl-2 .r-sec-title {
  display: inline-block; color: #fff; background: var(--theme-color);
  border-left: none; border-radius: 4px; padding: 3px 14px;
  font-size: 14px; letter-spacing: 1px;
}
.tpl-2 .r-section { text-align: left; }

/* ---------- Template 3 (sidebar) ---------- */
.tpl-3 {
  /* A4 标准：794×1123px @96dpi（210×297mm），与打印尺寸一致 */
  display: flex; width: 794px; padding: 0; min-height: 1123px;
  color: var(--ink);
}
.tpl-3 .r-side {
  /* 与打印比例一致：70mm / 210mm = 1/3 页宽 */
  width: 265px; background: var(--theme-color); color: #fff;
  padding: 32px 20px; flex: 0 0 265px;
}
.tpl-3 .r-side .r-avatar, .tpl-3 .r-side .r-avatar-ph {
  width: 162px; height: 202px; font-size: 66px; border: 3px solid #fff; border-radius: 16px;
  margin: 0 auto 14px; color: #fff; background: rgba(255, 255, 255, .15);
}
.tpl-3 .r-side .side-name {
  text-align: center; font-size: 22px; color: #fff; margin-bottom: 6px;
}
.tpl-3 .side-contacts { margin: 6px 0 4px; }
.tpl-3 .side-contact {
  display: flex; gap: 8px; font-size: 12px; margin-bottom: 5px;
  word-break: break-all;
}
.tpl-3 .sc-k { color: rgba(255, 255, 255, .7); flex: 0 0 56px; }
.tpl-3 .sc-v { color: #fff; }
.tpl-3 .r-side .r-sec-title {
  color: #fff; border-left: none; border-bottom: 1px solid rgba(255, 255, 255, .35);
  padding: 0 0 4px; margin: 18px 0 10px; font-size: 14px;
}
.tpl-3 .r-side .tag { background: rgba(255, 255, 255, .2); color: #fff; }
.tpl-3 .r-main { flex: 1; padding: 36px 34px; }
.tpl-3 .r-main .r-sec-title {
  color: var(--theme-color); border-left: 4px solid var(--theme-color);
  padding-left: 10px; display: block;
}

/* ---------- 行内编辑（直接编辑预览） ---------- */
.btn.active { background: #16a34a; }
.btn.active:hover { background: #15803d; }
.resume.inline-on [contenteditable="true"] {
  cursor: text; border-radius: 3px; transition: background .12s;
}
.resume.inline-on [contenteditable="true"]:hover {
  background: rgba(59, 130, 246, .08);
}
.resume.inline-on [contenteditable="true"]:focus {
  outline: 2px dashed var(--theme-color); outline-offset: 2px;
  background: rgba(59, 130, 246, .12);
}

/* ---------- 通用 ---------- */
.hidden { display: none !important; }

/* ---------- 登录遮罩 ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1f2733 0%, #2c3a4f 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: #fff; border-radius: 14px; padding: 28px 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  text-align: center;
}
.login-logo { font-size: 30px; margin-bottom: 8px; }
.login-title { margin: 4px 0 6px; font-size: 20px; color: #1f2733; }
.login-sub { margin: 0 0 18px; font-size: 13px; color: #6b7280; line-height: 1.5; }
.login-field { margin-bottom: 12px; }
.login-field input {
  width: 100%; border: 1px solid #d7dde5; border-radius: 8px;
  padding: 11px 12px; font-size: 14px; font-family: inherit; color: #222;
}
.login-field input:focus { outline: none; border-color: #3b82f6; }
.login-error { color: #d64545; font-size: 12.5px; min-height: 18px; margin-bottom: 6px; }
.login-primary { width: 100%; margin-bottom: 10px; padding: 11px; font-size: 15px; }
.login-secondary { width: 100%; padding: 9px; }
.login-note { margin: 14px 0 0; font-size: 11.5px; color: #9aa3ad; line-height: 1.5; }

/* ---------- 用户区（工具栏） ---------- */
.user-area { display: inline-flex; align-items: center; gap: 8px; }
.user-label {
  font-size: 13px; color: #cfe3ff; background: #2c3744;
  border-radius: 14px; padding: 4px 12px; max-width: 140px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 赞助弹窗 ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 22, 33, .55); padding: 20px;
}
.modal-card {
  position: relative; width: 100%; max-width: 380px;
  background: #fff; border-radius: 16px; padding: 26px 24px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); text-align: center;
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close {
  position: absolute; top: 10px; right: 12px;
  background: transparent; border: none; font-size: 24px; line-height: 1;
  color: #9aa3ad; cursor: pointer;
}
.modal-close:hover { color: #445; }
.modal-title { margin: 2px 0 10px; font-size: 18px; color: #1f2733; }
.modal-text { margin: 0 0 16px; font-size: 13px; color: #6b7280; line-height: 1.6; }
.sponsor-qr {
  width: 200px; height: 200px; margin: 0 auto 12px;
  border: 1px solid #eef1f5; border-radius: 10px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; background: #fafbfc;
}
.sponsor-qr img { width: 100%; height: 100%; object-fit: contain; }
.modal-sub { margin: 0 0 16px; font-size: 12px; color: #9aa3ad; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ---------- Print ---------- */
@media print {
  @page { margin: 0; size: A4; }
  .toolbar, .editor { display: none !important; }
  .login-overlay, .modal-overlay { display: none !important; }
  html, body { background: #fff; margin: 0; padding: 0; }
  .layout { display: block; padding: 0; margin: 0; }
  .preview-wrap { display: block; padding: 0; margin: 0; }
  .resume {
    box-shadow: none; width: 210mm; min-height: 297mm;
    margin: 0; padding: 12mm;
    overflow: hidden;
    page-break-after: avoid;
  }
  .tpl-1, .tpl-2 { padding: 12mm; }
  .tpl-3 {
    width: 210mm; min-height: 297mm; padding: 0;
    display: flex;
  }
  .tpl-3 .r-side {
    width: 70mm; min-height: 297mm; padding: 12mm 8mm;
    flex: 0 0 70mm;
  }
  .tpl-3 .r-main {
    flex: 1; min-height: 297mm; padding: 12mm 10mm;
  }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- 分组技能编辑器 ---------- */
.item-sub {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.item-sub input[type="text"] {
  flex: 1; border: 1px solid #d7dde5; border-radius: 6px;
  padding: 6px 8px; font-size: 13px; font-family: inherit; color: #222;
}
.item-sub input[type="text"]:focus { outline: none; border-color: #3b82f6; }
.item-sub-list { margin-bottom: 6px; }
/* 分组名：行内小标签，与技能标签同处一个流式容器（一行放满再换行） */
.skill-g-label {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 600; color: #3b5bdb;
  padding: 0 8px; margin: 2px 0; align-self: center;
}
.skill-g-label::after { content: "："; font-weight: 600; }
.sec-add-row select {
  border: 1px solid #d7dde5; border-radius: 6px; padding: 5px 6px; font-size: 12px;
  background: #fff; color: #222; font-family: inherit;
}

/* 模块管理：长按拖动排序 */
.sec-chip {
  touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; cursor: grab;
}
.sec-chip.dragging { opacity: .55; cursor: grabbing; }
