:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --ok: #16a34a;
  --ok-light: #f0fdf4;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .06);
}

* { 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", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px;
}
.container.narrow { max-width: 460px; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand { font-size: 20px; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; color: var(--primary); }
.nav { display: flex; align-items: center; gap: 18px; }
.nav-form { margin: 0; }
.nav-link { color: var(--muted); font-size: 15px; }
.nav-link:hover { color: var(--primary); text-decoration: none; }
.btn-link {
  background: none; border: none; cursor: pointer;
  font: inherit; padding: 0;
}

/* ---------- 首页 ---------- */
.hero { text-align: center; padding: 64px 0 32px; }
.hero h1 { font-size: 42px; margin: 0 0 12px; }
.hero-sub { color: var(--muted); font-size: 17px; margin: 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  padding: 24px 0 64px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.card h2 { margin-top: 0; font-size: 20px; }

.lookup-form { display: flex; gap: 10px; margin-top: 12px; }
.lookup-form .input { flex: 1; }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 16px; font-size: 14px; color: var(--text); font-weight: 600; }
.field .input { margin-top: 6px; }
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--card);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}
textarea.input { resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-ghost { border-style: dashed; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-light); }
.btn-danger { color: var(--danger); border-color: #fecaca; background: var(--danger-light); }
.btn-danger:hover { background: #fee2e2; border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 4px; }

.muted { color: var(--muted); }
.center { text-align: center; }
.grow { flex: 1; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 15px;
}
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-ok { background: var(--ok-light); color: var(--ok); border: 1px solid #bbf7d0; }

/* ---------- 编辑器 ---------- */
.editor-wrap { padding-top: 32px; padding-bottom: 64px; }
.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.editor-head h1 { margin: 0 0 4px; font-size: 28px; }
.editor-actions { display: flex; gap: 10px; }

.editor-wrap .card { margin-bottom: 20px; }
.editor-wrap .card h2 {
  margin-top: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 18px;
}
.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 16px;
}

.list-section .items { display: flex; flex-direction: column; gap: 16px; margin-bottom: 14px; }
.item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: #fafbfc;
}
.item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.item-title { font-size: 14px; font-weight: 700; color: var(--muted); }
.item-inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.item-inline .field { margin-bottom: 0; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 15px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .3);
  z-index: 100;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

/* ---------- 简历展示 ---------- */
.resume-wrap { padding-top: 28px; padding-bottom: 64px; }
.resume-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.resume {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 44px 48px;
}
.resume-header {
  display: flex;
  gap: 24px;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--primary-light);
  margin-bottom: 24px;
}
.avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 36px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.resume-header h1 { margin: 0 0 4px; font-size: 32px; }
.resume-title { margin: 0 0 8px; color: var(--primary); font-size: 18px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
}
.chip a { color: inherit; }
.chip a:hover { text-decoration: underline; }

.resume-section { margin-bottom: 28px; }
.resume-section h2 {
  font-size: 18px;
  color: var(--primary-dark);
  margin: 0 0 12px;
  padding-left: 12px;
  border-left: 4px solid var(--primary);
}
.summary-text { margin: 0; white-space: pre-wrap; }

.timeline-item { margin-bottom: 16px; }
.timeline-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.tl-company { font-weight: 700; font-size: 16px; }
.tl-role { color: var(--text); }
.tl-period { color: var(--muted); font-size: 13px; margin-left: auto; }
.tl-desc { margin: 4px 0 0; color: #475569; white-space: pre-wrap; }

.skill-bars { display: flex; flex-direction: column; gap: 12px; }
.skill { display: flex; align-items: center; gap: 16px; }
.skill-name { width: 160px; font-weight: 600; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-track {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.skill-fill { height: 100%; background: var(--primary); border-radius: 999px; }

.resume-empty-tip { text-align: center; padding: 48px 0; color: var(--muted); font-size: 17px; }
.resume-empty-tip .btn { margin-top: 8px; }

/* ---------- 错误页 ---------- */
.err-code { font-size: 72px; margin: 0; color: var(--primary); line-height: 1; }

/* ---------- 页脚 ---------- */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--card);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 18px 0;
}
.footer p { margin: 0; }

@media (max-width: 640px) {
  .hero h1 { font-size: 32px; }
  .resume { padding: 24px 20px; }
  .hero { flex-direction: column; text-align: center; }
  .hero .chips { justify-content: center; }
  .resume-header { flex-direction: column; text-align: center; }
  .timeline-head { flex-direction: column; gap: 2px; }
  .tl-period { margin-left: 0; }
  .exp-period { margin-left: 0; }
}

/* ---------- 附件与链接 ---------- */
.attach-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.attach-row .attach-file { flex: 1; min-width: 180px; }
.attach-info { font-size: 13px; }
.tl-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.tl-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 6px;
  padding: 3px 10px;
}
.tl-link:hover { background: #dde3ff; text-decoration: none; }

/* ========== 经历呈现主页（区块化） ========== */
.hero {
  display: flex;
  gap: 28px;
  align-items: center;
  padding: 40px 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #9333ea 100%);
  color: #fff;
  margin-bottom: 28px;
}
.hero .avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  border: 3px solid rgba(255, 255, 255, .7);
  color: #fff;
  font-size: 40px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hero-info h1 { margin: 0 0 6px; font-size: 34px; color: #fff; }
.hero .resume-title { margin: 0 0 10px; color: #e9d5ff; font-size: 18px; font-weight: 600; }
.hero .chips { margin-bottom: 10px; }
.hero .chip { background: rgba(255, 255, 255, .18); color: #fff; }
.hero .chip a { color: #fff; }
.hero .summary-text { margin: 0; color: #f3e8ff; white-space: pre-wrap; }

.blocks { display: flex; flex-direction: column; gap: 22px; }
.block-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 26px 30px;
}
.block-card h2 { margin: 0 0 14px; font-size: 19px; color: var(--primary-dark); padding-left: 12px; border-left: 4px solid var(--primary); }
.block-card h3 { margin: 0; font-size: 17px; }
.block-body-text { white-space: pre-wrap; margin: 0; }

.badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  margin-right: 10px;
  flex-shrink: 0;
}
.exp-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.exp-role { color: var(--text); font-weight: 600; }
.exp-period { color: var(--muted); font-size: 13px; margin-left: auto; }
.exp-desc { white-space: pre-wrap; color: #475569; }

.block-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.block-media-item { min-width: 0; }
.media-img {
  width: 100%;
  border-radius: 10px;
  cursor: zoom-in;
  display: block;
  background: var(--bg);
}
.media-video, .media-audio { width: 100%; border-radius: 10px; display: block; }

.block-video video, .block-audio audio { width: 100%; margin-top: 6px; }

.link-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--primary-light);
  color: var(--primary-dark);
  text-decoration: none;
}
.link-card:hover { background: #dde3ff; text-decoration: none; }
.link-card .link-title { display: block; font-weight: 700; margin-bottom: 2px; }
.link-card .link-url { font-size: 13px; color: var(--muted); word-break: break-all; }

/* ---------- 图片集 ---------- */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.gallery-grid img { width: 100%; height: 180px; object-fit: cover; border-radius: 10px; cursor: zoom-in; background: var(--bg); }

.gallery-carousel { position: relative; overflow: hidden; border-radius: 12px; }
.gallery-track { display: flex; transition: transform .4s ease; }
.gallery-slide { flex: 0 0 100%; min-width: 0; }
.gallery-slide img { width: 100%; max-height: 520px; object-fit: contain; background: #0f172a; display: block; cursor: zoom-in; }
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, .55);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.gallery-nav:hover { background: rgba(15, 23, 42, .8); }
.gallery-prev { left: 12px; }
.gallery-next { right: 12px; }
.gallery-dots { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 8px; z-index: 2; }
.gallery-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, .5);
  cursor: pointer;
  padding: 0;
}
.gallery-dot.active { background: #fff; }

/* ---------- 灯箱 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .92);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  padding: 24px;
}
.lightbox-inner { max-width: 94vw; max-height: 94vh; }
.lightbox-inner img { max-width: 100%; max-height: 94vh; border-radius: 8px; }

/* ---------- 编辑器：区块画布 ---------- */
.blocks-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.blocks-head h2 { border: none; padding: 0; margin: 0; }
.add-block-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.blocks-canvas { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.block-card { position: relative; }
.block-card.dragging { opacity: .55; }
.block-card.drag-over { outline: 2px dashed var(--primary); }
.block-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -26px -30px 16px;
  padding: 10px 30px;
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  cursor: grab;
}
.block-head:active { cursor: grabbing; }
.drag-handle { color: var(--muted); font-size: 18px; user-select: none; }
.block-type-label { font-weight: 700; color: var(--primary-dark); }
.block-head-actions { margin-left: auto; display: flex; gap: 6px; }

.attach-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.attach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  background: #fafbfc;
}
.attach-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--bg); }
.attach-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.attach-item-type { font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 4px; padding: 2px 6px; }
.attach-item-size { font-size: 12px; color: var(--muted); }

.skill-rows { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.skill-row { display: flex; gap: 10px; align-items: center; }
.skill-row .input:first-child { flex: 1; }