:root {
  --canvas: #f2f4f1;
  --surface: #ffffff;
  --surface-soft: #e8ece8;
  --ink: #17201c;
  --muted: #65716b;
  --quiet: #929c96;
  --line: #d8ded9;
  --line-strong: #bdc7c0;
  --forest: #285f4d;
  --forest-dark: #1f493c;
  --clay: #c65d3b;
  --clay-dark: #a9492d;
  --blue: #356b87;
  --danger: #b33f32;
  --success: #247153;
  --radius: 8px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { min-width: 320px; background: var(--canvas); }
body {
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  line-height: 1.55;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--forest); text-decoration: none; }
a:hover { color: var(--clay); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--clay);
  outline-offset: 3px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.hidden { display: none !important; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
.text-sm { color: var(--muted); font-size: 12px; }
.flex { display: flex; align-items: center; gap: 8px; }
.gap-8 { gap: 8px; }

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease;
}
.btn:hover { border-color: var(--forest); color: var(--forest); }
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: wait; opacity: .58; transform: none; }
.btn-primary { border-color: var(--clay); background: var(--clay); color: #fff; }
.btn-primary:hover { border-color: var(--clay-dark); background: var(--clay-dark); color: #fff; }
.btn-secondary { border-color: #aebec6; background: #f2f7f9; color: var(--blue); }
.btn-secondary:hover { border-color: var(--blue); background: #e8f1f4; color: var(--blue); }
.btn-danger { border-color: #dfb8b2; background: #fff6f4; color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-ai { border-color: var(--forest); background: var(--forest); color: #fff; }
.btn-ai:hover { border-color: var(--forest-dark); background: var(--forest-dark); color: #fff; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
}
.nav-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 750; white-space: nowrap; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 5px;
  background: var(--forest);
  color: #fff;
  font-family: Georgia, serif;
  font-size: 12px;
  font-style: italic;
}
.brand-name { font-size: 15px; }
.nav-links { min-width: 0; margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: 5px;
  padding: 7px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.nav-link:hover, .nav-link.active { background: var(--surface-soft); color: var(--ink); }
.nav-user { min-width: 0; display: flex; align-items: center; gap: 4px; border-left: 1px solid var(--line); padding-left: 8px; color: var(--ink); font-size: 12px; }
#navUsername { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page { display: none; }
.page.active { display: block; }
.workspace-page { width: min(1040px, 100%); margin: 0 auto; padding: 42px 28px 72px; }
.workspace-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line-strong);
  margin-bottom: 18px;
}
.page-index { display: block; margin-bottom: 9px; color: var(--clay); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.workspace-header h1, .editor-toolbar h1 {
  font-family: Georgia, "Songti SC", serif;
  font-size: 32px;
  font-weight: 500;
  line-height: 1.15;
}
.workspace-header p { margin-top: 8px; color: var(--muted); font-size: 13px; }

.auth-page { min-height: 100vh; grid-template-columns: minmax(340px, .92fr) minmax(500px, 1.08fr); }
.auth-page.active { display: grid; }
.auth-context {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 72px clamp(38px, 6vw, 92px);
  background: var(--forest);
  color: #fff;
}
.auth-context::after {
  content: "";
  position: absolute;
  width: 58%;
  height: 42%;
  right: -12%;
  top: 8%;
  border: 1px solid rgba(255,255,255,.13);
  pointer-events: none;
}
.auth-kicker { position: relative; z-index: 1; color: #cfe0d9; font-size: 10px; font-weight: 750; }
.auth-context h1 {
  position: relative;
  z-index: 1;
  margin-top: 20px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 46px;
  font-weight: 400;
  line-height: 1.28;
}
.resume-sheet {
  position: relative;
  z-index: 1;
  width: min(330px, 86%);
  aspect-ratio: 1 / 1.22;
  margin-top: 50px;
  padding: 42px 36px;
  border: 1px solid rgba(255,255,255,.45);
  background: #f9faf7;
  box-shadow: 18px 18px 0 rgba(15,46,37,.46);
}
.sheet-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 36px; }
.sheet-heading span:first-child { width: 42%; height: 12px; background: var(--ink); }
.sheet-heading span:last-child { width: 22%; height: 7px; background: #a9b1ac; }
.sheet-row { width: 72%; height: 6px; margin-bottom: 14px; background: #c4cbc7; }
.sheet-row.long { width: 100%; }
.sheet-row.short { width: 48%; }
.sheet-rule { height: 2px; margin: 30px 0 24px; background: var(--clay); }
.sheet-accent { position: absolute; right: 26px; bottom: 19px; color: var(--clay); font: italic 34px Georgia, serif; }
.auth-panel { min-height: 100vh; display: grid; place-items: center; padding: 52px; background: var(--surface); }
.auth-box { width: min(420px, 100%); }
.auth-title-row { display: flex; align-items: center; gap: 14px; margin-bottom: 34px; }
.auth-title-row h2 { font-family: Georgia, "Songti SC", serif; font-size: 28px; font-weight: 500; }
.auth-title-row p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.sso-status { min-height: 36px; margin: 0 0 20px; padding: 9px 11px; border-left: 3px solid var(--blue); background: #f2f7f9; color: var(--muted); font-size: 12px; }
.auth-account-link { margin-top: 16px; color: var(--muted); text-align: center; font-size: 12px; }
.auth-account-link a { font-weight: 650; }

.alert { display: none; margin-bottom: 14px; padding: 10px 12px; border: 1px solid transparent; border-radius: 5px; font-size: 12px; }
.alert-error { display: block; border-color: #e7bbb4; background: #fff4f2; color: #8e3025; }
.alert-success { display: block; border-color: #afd1c3; background: #eff8f4; color: var(--success); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
.form-group input, .form-group textarea, .form-group select, .input, .search-box input,
#skillList input, #skillList select, #langList input, #langList select, #certList input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.form-group textarea { min-height: 92px; resize: vertical; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus, .input:focus, .search-box input:focus,
#skillList input:focus, #skillList select:focus, #langList input:focus, #langList select:focus, #certList input:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(40,95,77,.1);
  outline: none;
}
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

#resumeList { min-height: 230px; }
.loading { display: grid; place-items: center; min-height: 260px; color: var(--muted); font-size: 13px; }
.spinner { width: 28px; height: 28px; border: 2px solid var(--line); border-top-color: var(--clay); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state {
  min-height: 390px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  text-align: center;
}
.empty-document { width: 54px; height: 70px; margin-bottom: 20px; border: 1px solid var(--line-strong); border-top: 5px solid var(--forest); background: var(--surface); box-shadow: 7px 7px 0 var(--surface-soft); }
.empty-state h2 { font-family: Georgia, "Songti SC", serif; font-size: 23px; font-weight: 500; }
.empty-state p { max-width: 380px; margin: 8px 0 20px; color: var(--muted); font-size: 13px; }
.resume-list { border-top: 1px solid var(--line); }
.resume-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px; padding: 18px 8px; border-bottom: 1px solid var(--line); }
.resume-open { min-width: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.resume-open:hover .resume-card-title { color: var(--clay); }
.resume-card-title { overflow: hidden; color: var(--ink); font-size: 15px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.resume-card-meta { margin-top: 5px; color: var(--muted); font-size: 11px; }
.resume-card-actions { display: flex; align-items: center; gap: 8px; }

.editor-toolbar {
  position: sticky;
  top: 60px;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: -42px -28px 20px;
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(242,244,241,.96);
  backdrop-filter: blur(10px);
}
.editor-toolbar h1 { margin-top: 5px; font-size: 24px; }
.back-button { border: 0; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.back-button:hover { color: var(--clay); }
.editor-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.save-status { min-width: 62px; color: var(--success); font-size: 11px; text-align: right; }
.save-status.dirty { color: var(--clay); }
.editor-sections { display: grid; gap: 14px; }
.card { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card-header, .section-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.card-title, .section-header h3 { font-size: 14px; font-weight: 750; }
.section-index { margin-right: 9px; color: var(--clay); font-family: Georgia, serif; font-size: 11px; font-style: italic; font-weight: 400; }
.entry-item { position: relative; margin-bottom: 12px; padding: 18px 42px 4px 18px; border-left: 3px solid var(--line-strong); background: #f8faf8; }
.entry-item .remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--quiet);
  font-size: 18px;
  cursor: pointer;
}
.entry-item .remove-btn:hover { background: #fff0ed; color: var(--danger); }
.add-btn { width: 100%; min-height: 42px; border: 1px dashed var(--line-strong); border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.add-btn:hover { border-color: var(--forest); color: var(--forest); background: #f4f8f6; }
#skillList .flex, #langList .flex { display: grid; grid-template-columns: minmax(0, 1fr) 110px 40px; gap: 8px; }
#certList .flex { display: grid; grid-template-columns: minmax(0, 1fr) 150px 40px; gap: 8px; }
#skillList select, #langList select, #skillList button, #langList button, #certList input, #certList button { margin: 0 !important; }
.editor-footer-actions { display: flex; justify-content: center; gap: 10px; padding: 24px 0 0; }

.preview-page { width: min(210mm, 100%); min-height: 297mm; margin: 0 auto; background: #fff; color: #202624; font-size: 12px; line-height: 1.5; }
.preview-header { padding: 28px 34px 18px; border-bottom: 2px solid var(--forest); }
.preview-name { font-size: 26px; font-weight: 800; }
.preview-title { margin-top: 4px; color: var(--muted); font-size: 14px; }
.preview-contact { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 9px; color: var(--muted); font-size: 11px; }
.preview-section { padding: 12px 34px; }
.preview-section-title { margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); color: var(--forest); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.preview-item { margin-bottom: 9px; }
.preview-item-header { display: flex; justify-content: space-between; gap: 20px; font-weight: 700; }
.preview-item-sub { margin-bottom: 2px; color: var(--muted); font-size: 11px; }
.preview-item-desc { margin-top: 2px; color: #3f4944; white-space: pre-wrap; }
.preview-skills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.preview-skill { padding: 2px 9px; border-radius: 4px; background: #e8f0ec; color: var(--forest); font-size: 10px; }

.search-box { margin-bottom: 14px; }
.admin-user-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.admin-user-item:last-child { border-bottom: 0; }
.badge { display: inline-block; margin-left: 5px; padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; }
.badge-admin { background: #fff1dd; color: #8a4b17; }

.modal-overlay { display: none; position: fixed; inset: 0; z-index: 200; align-items: center; justify-content: center; padding: 20px; background: rgba(23,32,28,.42); }
.modal-overlay.show { display: flex; }
.modal { width: min(480px, 100%); max-height: 80vh; overflow-y: auto; padding: 24px; border-radius: var(--radius); background: var(--surface); }
.modal h3 { margin-bottom: 12px; font-size: 16px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 300;
  display: none;
  max-width: min(440px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 11px 18px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(23,32,28,.2);
}

@media (max-width: 760px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-context { min-height: 230px; justify-content: flex-start; padding: 34px 24px; }
  .auth-context h1 { margin-top: 12px; font-size: 31px; line-height: 1.3; }
  .resume-sheet { position: absolute; width: 145px; right: 22px; bottom: -68px; margin: 0; padding: 18px; box-shadow: 8px 8px 0 rgba(15,46,37,.4); }
  .sheet-heading { margin-bottom: 16px; }
  .sheet-row { height: 3px; margin-bottom: 7px; }
  .sheet-rule { margin: 12px 0 9px; }
  .sheet-accent { right: 10px; bottom: 8px; font-size: 18px; }
  .auth-panel { min-height: calc(100vh - 230px); place-items: start stretch; padding: 34px 24px 52px; }
  .auth-box { margin: 0 auto; }
  .auth-title-row { margin-bottom: 26px; }
  .nav { min-height: 58px; gap: 8px; padding: 0 10px; }
  .brand-name { display: none; }
  .nav-links { gap: 1px; }
  .nav-link { min-height: 36px; padding: 7px 7px; font-size: 11px; }
  #navUsername { display: none; }
  .nav-user { border-left: 0; padding-left: 0; }
  .workspace-page { padding: 28px 16px 60px; }
  .workspace-header { align-items: flex-start; gap: 16px; }
  .workspace-header h1 { font-size: 28px; }
  .workspace-header .btn { flex: 0 0 auto; padding-left: 13px; padding-right: 13px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 0; }
  .card { padding: 17px; }
  .entry-item { padding: 16px 38px 2px 14px; }
  .editor-toolbar { top: 58px; align-items: flex-start; flex-direction: column; margin: -28px -16px 16px; padding: 14px 16px; }
  .editor-actions { width: 100%; justify-content: flex-start; }
  .save-status { margin-left: auto; order: 2; }
  .resume-card { gap: 10px; padding: 16px 2px; }
  .resume-card-actions .btn-secondary { display: none; }
  #skillList .flex, #langList .flex { grid-template-columns: minmax(0, 1fr) 92px 36px; }
  #certList .flex { grid-template-columns: minmax(0, 1fr) 112px 36px; }
  .preview-header, .preview-section { padding-left: 18px; padding-right: 18px; }
  .preview-item-header { align-items: flex-start; flex-direction: column; gap: 1px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  body { background: #fff; }
  .nav, .page:not(#preview-page), #preview-page > div:first-child { display: none !important; }
  #preview-page { display: block !important; }
  .preview-page { min-height: auto; box-shadow: none; }
}
