:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --ink: #171b1e;
  --muted: #687178;
  --line: #dfe4df;
  --green: #176b54;
  --green-dark: #10533f;
  --green-soft: #e8f2ed;
  --blue: #315f88;
  --blue-soft: #eaf0f7;
  --coral: #a84d3d;
  --coral-soft: #fbefec;
  --warning: #7d5a20;
  --warning-soft: #fff7e6;
  --shadow: 0 16px 44px rgba(31, 45, 38, 0.08);
  --radius: 8px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; letter-spacing: 0; }
button { border: 0; }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible, [contenteditable]:focus-visible {
  outline: 3px solid rgba(49, 95, 136, 0.2);
  outline-offset: 2px;
}

.product-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }

.product-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(223, 228, 223, 0.9);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.header-inner {
  width: min(1120px, calc(100% - 40px));
  min-height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand { display: inline-flex; align-items: center; gap: 11px; padding: 0; color: var(--ink); background: transparent; cursor: pointer; text-align: left; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--ink); font-size: 18px; font-weight: 850; }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 18px; line-height: 1.1; }
.brand-copy small { color: var(--muted); font-size: 11px; }

.header-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.header-status > span { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

.product-main { width: 100%; }

.optimizer {
  width: min(900px, calc(100% - 40px));
  margin: 0 auto;
  padding: 64px 0 72px;
}

.optimizer-intro { max-width: 720px; margin-bottom: 28px; }
.product-label { margin: 0 0 10px; color: var(--green); font-size: 13px; font-weight: 800; }
.optimizer-intro h1, .result-toolbar h1, .loading-view h1 { margin: 0; font-size: 34px; line-height: 1.28; letter-spacing: 0; }
.optimizer-intro > p:last-child, .result-toolbar > div > p:last-child, .loading-view > p { margin: 12px 0 0; color: var(--muted); font-size: 16px; line-height: 1.75; }

.optimizer-form {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-error, .fact-alert, .upload-message { border-radius: 6px; line-height: 1.6; }
.form-error { margin-bottom: 22px; padding: 12px 14px; color: var(--coral); background: var(--coral-soft); }

.field-block + .field-block { margin-top: 26px; }
.field-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.field-heading label { font-size: 15px; font-weight: 800; }
.field-heading span { color: var(--muted); font-size: 12px; }

.upload-zone {
  min-height: 142px;
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 24px;
  border: 1px dashed #9aaba2;
  border-radius: var(--radius);
  background: var(--surface-soft);
  transition: border-color .16s ease, background .16s ease;
}

.upload-zone.is-dragging, .upload-zone.is-loading { border-color: var(--green); background: var(--green-soft); }
.upload-zone.is-success { border-style: solid; border-color: #8ab5a6; background: #f5faf7; }
.upload-zone.is-error { border-color: #d9a59a; background: #fffaf8; }
.upload-symbol { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 8px; color: var(--green); background: var(--green-soft); font-size: 25px; font-weight: 800; }
.upload-text { min-width: 0; display: grid; gap: 5px; }
.upload-text strong { overflow: hidden; color: var(--ink); font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.upload-text span { color: var(--muted); font-size: 13px; }

.primary-button, .secondary-button {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .14s ease, background .14s ease, border-color .14s ease;
}
.primary-button { color: #fff; background: var(--green); }
.primary-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.primary-button:disabled { cursor: not-allowed; color: #9fa8a3; background: #e4e8e5; transform: none; }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: var(--surface); }
.secondary-button:hover { border-color: #9aaba2; background: var(--surface-soft); }

.upload-message { margin-top: 8px; padding: 10px 12px; font-size: 13px; }
.upload-message.info { color: var(--green); background: var(--green-soft); }
.upload-message.error { color: var(--coral); background: var(--coral-soft); }
.upload-message.warning { color: var(--warning); background: var(--warning-soft); }

.source-preview, .paste-fallback { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.source-preview summary, .paste-fallback summary { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 14px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 700; }
.source-preview summary small { color: var(--green); }
.source-preview textarea, .paste-fallback textarea { width: calc(100% - 28px); min-height: 220px; margin: 0 14px 10px; padding: 14px; resize: vertical; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fbfcfb; line-height: 1.7; }
.source-preview > p { margin: 0; padding: 0 14px 12px; color: var(--muted); font-size: 12px; }

.role-field input { width: 100%; min-height: 54px; padding: 12px 15px; border: 1px solid #b9c2bc; border-radius: 7px; color: var(--ink); background: #fff; font-size: 16px; }
.role-field input::placeholder { color: #9aa29e; }

.submit-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--line); }
.submit-row p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.submit-row p strong { color: var(--ink); }
.submit-row .primary-button { min-width: 178px; }

.privacy-line { display: flex; gap: 10px; margin-top: 16px; padding: 0 4px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.privacy-line strong { flex: 0 0 auto; color: var(--green); }

.loading-view { width: min(720px, calc(100% - 40px)); min-height: calc(100vh - 124px); margin: 0 auto; display: grid; place-items: center; align-content: center; padding: 60px 0; text-align: center; }
.loading-mark { width: 54px; height: 54px; margin-bottom: 24px; display: grid; place-items: center; border: 1px solid #a9b7af; border-radius: 50%; }
.loading-mark span { width: 18px; height: 18px; border: 3px solid var(--green-soft); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-view > p { max-width: 580px; }
.loading-steps { width: min(620px, 100%); margin: 34px 0 18px; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.loading-steps > div { position: relative; display: grid; justify-items: center; gap: 10px; padding-top: 18px; color: #9aa29e; font-size: 13px; }
.loading-steps span { position: absolute; top: -13px; width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: var(--bg); font-size: 11px; }
.loading-steps .is-active, .loading-steps .is-done { color: var(--ink); }
.loading-steps .is-active span, .loading-steps .is-done span { border-color: var(--green); color: #fff; background: var(--green); }
.loading-view > small { color: var(--muted); }

.result-view { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 72px; }
.result-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 24px; }
.result-toolbar > div:first-child { max-width: 700px; }
.toolbar-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.toolbar-actions .primary-button { min-width: 132px; }

.fact-alert { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; padding: 12px 14px; color: var(--warning); background: var(--warning-soft); font-size: 13px; }
.fact-alert strong { flex: 0 0 auto; }

.result-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.resume-document { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.document-bar { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.document-bar > div { display: grid; gap: 2px; }
.document-bar strong { font-size: 14px; }
.document-bar span { color: var(--muted); font-size: 11px; }
.document-bar button { padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--blue); background: var(--blue-soft); font-size: 12px; font-weight: 800; }
.resume-editor { min-height: 780px; max-height: 1100px; overflow: auto; padding: 48px 54px; white-space: pre-wrap; color: #202428; background: #fff; font-family: "Songti SC", SimSun, "STSong", serif; font-size: 15px; line-height: 1.9; }

.result-insights { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.result-insights section { padding: 20px; }
.result-insights section + section { border-top: 1px solid var(--line); }
.insight-label { margin: 0 0 14px; color: var(--ink); font-size: 14px; font-weight: 850; }
.rewrite-item { display: grid; grid-template-columns: 28px 1fr; gap: 9px; }
.rewrite-item + .rewrite-item { margin-top: 15px; padding-top: 15px; border-top: 1px solid #edf0ed; }
.rewrite-item > span { color: var(--green); font-size: 11px; font-weight: 850; }
.rewrite-item strong { display: block; margin-bottom: 5px; font-size: 13px; line-height: 1.45; }
.rewrite-item p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.question-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.question-list li + li { margin-top: 7px; }
.keyword-row { display: flex; flex-wrap: wrap; gap: 7px; }
.keyword-row span { padding: 5px 8px; border-radius: 5px; color: var(--green-dark); background: var(--green-soft); font-size: 12px; }
.keyword-row small, .empty-copy { color: var(--muted); font-size: 12px; line-height: 1.6; }

.result-feedback { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted); background: rgba(255,255,255,.72); font-size: 13px; }
.result-feedback > div { display: flex; gap: 6px; }
.result-feedback button { min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; color: var(--muted); background: #fff; }
.result-feedback button:hover, .result-feedback button.is-selected { border-color: var(--green); color: var(--green); background: var(--green-soft); }

.product-footer { min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 20px; padding: 14px 20px; border-top: 1px solid var(--line); color: var(--muted); background: rgba(255,255,255,.6); font-size: 12px; }
.product-footer a { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; }
.product-footer a:hover { color: var(--green); }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 50; padding: 10px 14px; border-radius: 7px; color: #fff; background: var(--ink); box-shadow: var(--shadow); font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: opacity .18s ease, transform .18s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .result-toolbar { align-items: flex-start; flex-direction: column; }
  .result-grid { grid-template-columns: 1fr; }
  .result-insights { display: grid; grid-template-columns: repeat(2, 1fr); }
  .result-insights section + section { border-top: 0; border-left: 1px solid var(--line); }
  .resume-editor { min-height: 680px; }
}

@media (max-width: 640px) {
  .header-inner, .optimizer, .loading-view, .result-view { width: min(100% - 32px, 1180px); }
  .header-inner { min-height: 62px; }
  .brand-copy small, .header-status { display: none; }
  .optimizer { padding: 34px 0 46px; }
  .optimizer-intro { margin-bottom: 20px; }
  .optimizer-intro h1, .result-toolbar h1, .loading-view h1 { font-size: 25px; line-height: 1.35; }
  .optimizer-intro > p:last-child, .result-toolbar > div > p:last-child, .loading-view > p { font-size: 14px; line-height: 1.65; }
  .optimizer-form { padding: 18px; }
  .field-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .upload-zone { grid-template-columns: 42px minmax(0, 1fr); min-height: 0; padding: 18px; }
  .upload-symbol { width: 42px; height: 42px; }
  .upload-text strong { font-size: 15px; }
  .upload-zone .secondary-button { grid-column: 1 / -1; width: 100%; }
  .source-preview textarea, .paste-fallback textarea { min-height: 180px; }
  .submit-row { align-items: stretch; flex-direction: column; gap: 15px; }
  .submit-row .primary-button { width: 100%; }
  .privacy-line { align-items: flex-start; flex-direction: column; gap: 3px; }
  .loading-steps { grid-template-columns: 1fr; gap: 12px; border-top: 0; }
  .loading-steps > div { grid-template-columns: 28px 1fr; justify-items: start; align-items: center; padding: 0; }
  .loading-steps span { position: static; }
  .result-view { padding: 32px 0 48px; }
  .toolbar-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar-actions .primary-button { grid-column: 1 / -1; grid-row: 1; }
  .resume-editor { min-height: 640px; max-height: none; padding: 28px 22px; font-size: 14px; line-height: 1.85; }
  .result-insights { display: block; }
  .result-insights section + section { border-top: 1px solid var(--line); border-left: 0; }
  .result-feedback { align-items: flex-start; flex-direction: column; }
  .result-feedback > div { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .product-footer { align-items: center; flex-direction: column; gap: 6px; }
}

@media print {
  .product-header, .result-toolbar, .fact-alert, .document-bar, .result-insights, .result-feedback, .product-footer, .toast { display: none !important; }
  body, .product-shell, .product-main, .result-view, .result-grid, .resume-document { background: #fff; }
  .result-view { width: 100%; padding: 0; }
  .result-grid { display: block; }
  .resume-document { border: 0; box-shadow: none; }
  .resume-editor { min-height: 0; max-height: none; overflow: visible; padding: 0; }
}
