/* Resume Editor — A4 预览纸张（白底单栏人事实习） */
:root {
  --ink: #1a1a1a;
  --muted: #5a5a5a;
  --line: #222;
  --icon: #1a1a1a;
  --sheet: #fff;
  --page-bg: #e8e8e8;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif;
  --a4-w: 210mm;
  --a4-h: 297mm;
  /* 可由样式面板覆盖 */
  --pad-top: 10mm;
  --pad-right: 15mm;
  --pad-bottom: 9mm;
  --pad-left: 15mm;
  --base-font: 11px;
  --line-height: 1.45;
  --name-size: 32px;
  --title-size: 13.5px;
  --meta-size: 16px;
  --photo-w: 28mm;
  --photo-h: 36mm;
  --sidebar-w: 360px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--page-bg);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }

/* —— 工作区布局（铺满工具栏以下区域） —— */
.app-layout {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  min-height: 0;
  height: 100%;
  padding: 0;
  overflow: hidden;
}

body.is-editing .app-layout {
  justify-content: flex-start;
}

.preview-pane {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: auto;
  padding: 16px;
  background: var(--page-bg);
}

body.is-editing .preview-pane {
  justify-content: center;
  padding: 16px;
}

.preview-scale {
  width: calc(var(--a4-w) * var(--preview-zoom, 1));
  height: calc(var(--a4-h) * var(--preview-zoom, 1));
  flex-shrink: 0;
  overflow: hidden;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.12));
}

.preview-scale > .sheet {
  transform: scale(var(--preview-zoom, 1));
  transform-origin: top left;
}

/* —— A4 纸张 —— */
.sheet {
  width: var(--a4-w);
  height: var(--a4-h);
  padding: var(--pad-top) var(--pad-right) var(--pad-bottom) var(--pad-left);
  overflow: hidden;
  background: var(--sheet);
  color: var(--ink);
  font-size: var(--base-font);
  line-height: var(--line-height);
  box-shadow: none;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
  /* 预览禁止选中编辑感 */
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

.sheet * {
  user-select: none;
  -webkit-user-select: none;
}

/* —— 页眉 —— */
.resume-header {
  display: table;
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  padding-bottom: 10px;
}

.photo-wrap,
.identity {
  display: table-cell;
  vertical-align: top;
}

.photo-wrap {
  width: calc(var(--photo-w) + 4mm);
  height: var(--photo-h);
  padding-right: 12px;
}

.photo {
  display: block;
  width: var(--photo-w);
  height: var(--photo-h);
  object-fit: cover;
  object-position: center 18%;
  background: #f3f3f3;
}

.identity { height: var(--photo-h); }

.id-box {
  width: 100%;
  height: var(--photo-h);
  border-collapse: collapse;
}

.id-top td,
.id-bot td { padding: 0; }

.id-top td { vertical-align: top; }
.id-bot td { vertical-align: bottom; }

.name {
  margin: 0;
  font-size: var(--name-size);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.meta-line {
  margin: 0;
  color: #333;
  font-size: var(--meta-size);
  line-height: 1.45;
  text-align: left;
}

.meta-line + .meta-line { margin-top: 3px; }
.meta-line span + span { margin-left: 22px; }

/* —— 分区 —— */
.block { margin-top: 6px; }
.block.is-hidden { display: none; }

.section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
  font-size: var(--title-size);
  font-weight: 700;
  color: var(--ink);
}

.section-title svg {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  color: var(--icon) !important;
  stroke: currentColor !important;
  fill: none !important;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.section-title svg * {
  stroke: currentColor !important;
  fill: none !important;
}

.intent,
.eval {
  margin: 0;
  font-size: calc(var(--base-font) + 1px);
  color: var(--ink);
}

.eval { color: #222; }

/* —— 条目 —— */
.entry {
  margin-bottom: 7px;
  min-width: 0;
}

.entry:last-child { margin-bottom: 0; }

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.entry-name {
  font-weight: 700;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.entry-name .entry-role { font-weight: 600; }

.entry-date {
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.entry-sub {
  margin: 2px 0 0;
  color: #444;
}

.bullets,
.skill-list {
  margin: 3px 0 0;
  padding-left: 18px;
}

.bullets li,
.skill-list li {
  margin: 1px 0;
  color: var(--ink);
}

.bullets li::marker,
.skill-list li::marker {
  color: #333;
}

.sheet-empty {
  margin: 24px 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* —— 导出 / 打印 —— */
body.is-exporting .toolbar,
body.is-exporting .sidebar,
body.is-exporting .preview-scale {
  /* keep scale reset via JS class */
}

body.is-exporting .toolbar,
body.is-exporting .sidebar,
body.is-exporting .mobile-panel-tabs,
body.is-exporting .mobile-sheet-chrome,
body.is-exporting .mobile-sheet-toggle,
body.is-exporting .mobile-sheet-rail,
body.is-exporting .editor-footer {
  display: none !important;
}

body.is-exporting {
  background: #fff;
}

body.is-exporting .app-layout {
  padding: 0;
  min-height: 0;
  justify-content: flex-start;
}

body.is-exporting .preview-pane {
  padding: 0;
  overflow: visible;
}

body.is-exporting .preview-scale {
  transform: none !important;
  width: var(--a4-w) !important;
  height: var(--a4-h) !important;
  overflow: visible !important;
  filter: none !important;
}

body.is-exporting .preview-scale > .sheet,
body.is-exporting .sheet {
  transform: none !important;
  box-shadow: none;
  margin: 0;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html, body {
    width: 210mm;
    height: auto !important;
    min-height: 0 !important;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #fff !important;
  }

  .toolbar,
  .sidebar,
  .mobile-panel-tabs,
  .mobile-sheet-chrome,
  .mobile-sheet-toggle,
  .mobile-sheet-rail,
  .editor-footer {
    display: none !important;
  }

  .app-layout {
    padding: 0 !important;
    min-height: 0 !important;
  }

  .preview-pane { padding: 0 !important; overflow: visible; }
  .preview-scale {
    transform: none !important;
    width: 210mm !important;
    height: auto !important;
    overflow: visible !important;
    filter: none !important;
  }
  .preview-scale > .sheet { transform: none !important; }

  .sheet {
    position: relative;
    width: 210mm;
    height: 296mm;
    margin: 0;
    padding: var(--pad-top) var(--pad-right) var(--pad-bottom) var(--pad-left);
    box-shadow: none !important;
    overflow: hidden;
    background: var(--sheet);
    page-break-after: avoid !important;
    break-after: avoid-page !important;
    max-height: 296mm !important;
  }

  .resume-header {
    display: table;
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
  }

  .photo-wrap,
  .identity {
    display: table-cell;
    vertical-align: top;
  }

  * {
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
  }
}

/* 平板：单侧栏 + 顶部 tabs */
@media screen and (max-width: 1199px) {
  body.is-editing .app-layout {
    justify-content: flex-start;
  }

  body.is-editing .preview-pane {
    flex: 1 1 auto;
    min-width: 0;
  }
}

@media screen and (min-width: 821px) and (max-width: 1199px) {
  body.is-editing .app-layout {
    display: grid;
    grid-template-columns: minmax(280px, var(--sidebar-w, 360px)) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "tabs tabs"
      "side preview";
  }

  body.is-editing .mobile-sheet-chrome {
    display: contents;
  }

  body.is-editing .mobile-panel-tabs {
    grid-area: tabs;
    width: 100%;
  }

  body.is-editing .sidebar-left,
  body.is-editing .sidebar-right {
    grid-area: side;
    width: 100%;
    max-width: none;
    flex: 1 1 auto;
    height: auto;
  }

  body.is-editing .preview-pane {
    grid-area: preview;
    width: 100%;
  }
}

@media screen and (max-width: 820px) {
  html,
  body {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--page-bg);
  }

  .app-layout {
    flex-direction: column;
    padding: 0;
  }

  .preview-pane {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px 12px;
    -webkit-overflow-scrolling: touch;
  }

  body:not(.is-editing) .preview-pane {
    align-items: center;
    justify-content: center;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  body.is-editing .app-layout {
    flex-direction: column;
    padding: 0;
  }

  body.is-editing .preview-pane {
    flex: 1 1 auto;
    min-height: 120px;
    height: auto;
    max-height: none;
    overflow: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    order: 1;
    padding: 6px 0 0;
    align-items: flex-start;
    justify-content: center;
  }

  body.is-editing .mobile-sheet-chrome {
    display: block;
    position: relative;
    order: 2;
    flex: 0 0 auto;
    z-index: 180;
    overflow: visible;
    width: 100%;
    margin: 0;
    background: #fff;
    box-shadow: 0 -1px 0 #ececec;
  }

  body.is-editing .mobile-panel-tabs {
    order: 3;
    width: 100%;
    padding-top: 0;
  }

  body.is-editing .sidebar {
    flex: 0 0 var(--mobile-sheet-h, 42dvh);
    width: 100%;
    max-width: none;
    height: var(--mobile-sheet-h, 42dvh);
    max-height: none;
    min-height: 0;
    margin: 0;
    order: 4;
  }

  body.is-editing.sheet-collapsed .preview-pane {
    flex: 1 1 auto;
    min-height: 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  body.is-editing.sheet-collapsed .mobile-sheet-chrome {
    background: transparent;
    box-shadow: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  body.is-editing.sheet-collapsed .mobile-panel-tabs,
  body.is-editing.sheet-collapsed .sidebar {
    display: none !important;
  }

  .sheet {
    box-shadow: none;
  }

  .entry-head { flex-wrap: wrap; }

  body.is-editing .sheet .block[data-section] {
    cursor: default;
  }
}

@media screen and (max-width: 820px) and (max-height: 500px) {
  body.is-editing:not(.sheet-collapsed) .sidebar {
    flex-basis: var(--mobile-sheet-h, 36dvh);
    height: var(--mobile-sheet-h, 36dvh);
  }
}

/* —— 预览区画布拖拽（仅编辑模式） —— */
body.is-editing .sheet .block[data-section] {
  cursor: grab;
  position: relative;
}

@media (pointer: coarse) {
  body.is-editing .sheet .block[data-section] {
    cursor: default;
  }
}
body.is-editing .sheet .block[data-section].is-dragging {
  cursor: grabbing;
  outline: 1.5px solid #FF6700;
  outline-offset: 0;
  opacity: 0.4;
  background: rgba(255, 103, 0, 0.06);
}
body.is-editing .sheet .block[data-section].is-dnd-shift {
  will-change: transform;
  position: relative;
  z-index: 1;
}
body.is-editing .sheet .block[data-section].dnd-drop-before {
  box-shadow: inset 0 2.5px 0 0 #FF6700;
}
body.is-editing .sheet .block[data-section].dnd-drop-after {
  box-shadow: inset 0 -2.5px 0 0 #FF6700;
}

/* —— 画布分区选中（仅编辑模式） —— */
.sheet .block[data-section] {
  position: relative;
}

.canvas-sec-actions {
  display: none;
  position: absolute;
  /* 底边贴齐选中框上边线，右上角外侧 */
  top: 0;
  right: -1.5px;
  z-index: 6;
  transform: translateY(-100%);
  gap: 0;
  align-items: stretch;
  pointer-events: auto;
  background: #FF6700;
  border: none;
  border-radius: 0; /* 与选中框直角一致 */
  overflow: hidden;
  box-shadow: none;
}

body.is-editing .sheet .block[data-section].is-selected {
  border: 1.5px solid #FF6700;
  border-radius: 0;
  padding: 6px 8px 4px;
  margin-left: -8px;
  margin-right: -8px;
  box-sizing: border-box;
}

body.is-editing .sheet .block[data-section].is-selected .canvas-sec-actions {
  display: inline-flex;
}

.canvas-sec-btn {
  appearance: none;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 5px 10px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: none;
}

.canvas-sec-btn + .canvas-sec-btn {
  border-left: 1px solid rgba(255, 255, 255, 0.35);
}

.canvas-sec-btn:hover {
  background: rgba(0, 0, 0, 0.12);
  color: #fff;
}

.canvas-sec-btn-danger:hover {
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
}

@media print {
  .canvas-sec-actions {
    display: none !important;
  }
  .sheet .block.is-selected {
    border: none !important;
    padding: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

body.is-exporting .canvas-sec-actions {
  display: none !important;
}
body.is-exporting .sheet .block.is-selected {
  border: none !important;
  padding: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}
