:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --ink: #18212b;
  --muted: #66717e;
  --line: #d9dfe6;
  --primary: #1463d6;
  --primary-dark: #0d48a1;
  --success: #08785e;
  --warning: #8a5200;
  --danger: #b42318;
  --radius: 6px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.48; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(20, 99, 214, 0.2);
  outline-offset: 1px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: 30px; line-height: 1.25; }
h2 { margin-bottom: 8px; font-size: 20px; line-height: 1.35; }
h3 { margin-bottom: 8px; font-size: 15px; }

.app-shell { min-height: 100vh; }

.top-menu {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 10px max(20px, calc((100vw - 1280px) / 2));
  backdrop-filter: blur(10px);
}

.brand-button {
  display: grid;
  gap: 1px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 4px 0;
  text-align: left;
}

.brand-button strong { font-size: 20px; }
.brand-button span { color: var(--muted); font-size: 12px; }

.top-menu nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 4px;
}

.menu-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #3c4652;
  padding: 8px 13px;
  font-weight: 700;
}

.menu-button:hover { background: var(--surface-soft); }
.menu-button.active { background: #e9f1fc; color: var(--primary-dark); }

.workspace { padding: 24px 18px 48px; }
.view { width: min(100%, 1280px); margin: 0 auto; }

.panel, .preview-shell, .next-action-panel, .home-lower, .package-banner {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel { padding: 18px; }

.eyebrow {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

.lead { color: #4b5663; font-size: 16px; line-height: 1.7; }
.muted { color: var(--muted); line-height: 1.6; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.primary-button, .secondary-button, .text-button, .template-card {
  min-height: 42px;
  border-radius: var(--radius);
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
}

.primary-button:hover { border-color: var(--primary-dark); background: var(--primary-dark); }

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 13px;
}

.secondary-button:hover { border-color: #aeb8c4; background: var(--surface-soft); }
.text-button { border: 0; background: transparent; padding: 8px; }
.full { width: 100%; }
.danger { color: var(--danger); }

label { display: grid; gap: 6px; margin-bottom: 12px; }
label > span { color: #394451; font-size: 13px; font-weight: 700; }

input, textarea, select {
  width: 100%;
  border: 1px solid #cbd3dd;
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}

textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); outline: none; }

.panel-header, .page-heading, .preview-toolbar, .action-row, .item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-heading { margin-bottom: 16px; }
.page-heading h1 { margin-bottom: 0; font-size: 26px; }

.status-pill {
  flex: 0 0 auto;
  border: 1px solid #b9d1ef;
  border-radius: 999px;
  background: #edf4fd;
  color: var(--primary-dark);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 750;
}

.notice {
  border: 1px solid #b9d1ef;
  border-radius: var(--radius);
  background: #edf4fd;
  color: var(--primary-dark);
  margin: 12px 0;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
}

.notice.error, .import-draft.error { border-color: #f3b7b2; background: #fff3f2; color: var(--danger); }

.empty-state {
  border: 1px dashed #bfc8d3;
  border-radius: var(--radius);
  background: #fafbfc;
  color: var(--muted);
  padding: 14px;
  line-height: 1.6;
}

.empty-state.spacious { padding: 40px 20px; text-align: center; }

/* Invite */
.invite-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: #eef2f5;
  padding: 24px 16px;
}

.invite-panel {
  width: min(100%, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 32px;
}

.invite-panel h1 { font-size: 32px; }

.benefit-list {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 22px 0;
  padding: 16px 0;
}

.benefit-list span::before { content: "✓"; color: var(--success); margin-right: 8px; font-weight: 800; }
.privacy-note { margin: 14px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.invite-code-entry { margin-top: 18px; }
.invite-code-entry summary { margin-bottom: 12px; cursor: pointer; color: var(--muted); font-size: 13px; }

/* Home */
.home-view { display: grid; gap: 16px; }
.next-action-panel { padding: 32px; }
.next-action-panel h1 { max-width: 720px; font-size: 36px; }
.next-action-panel .lead { max-width: 680px; }
.next-button { min-height: 50px; margin-top: 8px; padding-inline: 24px; }

.step-badge {
  display: inline-block;
  border-radius: 999px;
  background: #e5f6f1;
  color: var(--success);
  margin-bottom: 14px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.progress-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.progress-strip span {
  border-right: 1px solid var(--line);
  color: var(--muted);
  padding: 13px;
  text-align: center;
  font-size: 13px;
}

.progress-strip span:last-child { border-right: 0; }
.progress-strip .current { background: #e9f1fc; color: var(--primary-dark); font-weight: 800; }
.progress-strip .done { color: var(--success); font-weight: 700; }

.home-lower { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px; padding: 20px; }
.mini-metrics { display: grid; grid-template-columns: repeat(3, minmax(80px, 1fr)); gap: 8px; }
.mini-metrics span { color: var(--muted); font-size: 12px; text-align: center; }
.mini-metrics strong { display: block; color: var(--ink); font-size: 22px; }

/* Jobs */
.jobs-layout { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }
.jobs-sidebar { display: grid; gap: 12px; }
.job-list { display: grid; gap: 7px; }
.job-card {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 12px;
  text-align: left;
}
.job-card span { color: var(--muted); font-size: 12px; }
.job-card.active { border-color: var(--primary); box-shadow: inset 3px 0 var(--primary); }
.job-detail { min-height: 520px; }
.job-meta-grid, .profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; margin-top: 16px; }
.next-inline { margin-top: 16px; }

.match-report { display: grid; gap: 12px; margin-top: 16px; }
.score-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.score-row > div { border: 1px solid var(--line); border-radius: var(--radius); padding: 13px; }
.score-row span { display: block; color: var(--muted); font-size: 12px; }
.score-row strong { display: block; margin-top: 4px; color: var(--primary-dark); font-size: 26px; }
.score-row .suggestion strong { color: var(--success); font-size: 17px; }
.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.report-grid > div { border-top: 2px solid #c7d0db; background: var(--surface-soft); padding: 13px; }
.report-grid ul, .question-card ul { margin: 0; padding-left: 18px; color: #3d4854; line-height: 1.55; }

.interview-section { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 20px; }
.question-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.question-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.question-card strong { display: block; margin: 12px 0 6px; }

/* Materials */
.package-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-left: 4px solid var(--success);
  padding: 14px 16px;
}
.package-banner strong, .package-banner span { display: block; }
.package-banner span { margin-top: 3px; color: var(--muted); font-size: 13px; }
.package-banner.state-payment-required { border-left-color: var(--warning); }
.package-banner .beta-note { color: var(--warning); font-weight: 700; }
.package-banner > button { flex: 0 0 auto; }

.material-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  margin: 14px 0;
  border-bottom: 1px solid var(--line);
}
.material-tabs button { min-height: 44px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-weight: 700; }
.material-tabs button.active { border-bottom-color: var(--primary); color: var(--primary-dark); }

.centered-empty { padding: 48px 20px; text-align: center; }
.centered-empty p { color: var(--muted); }
.material-editor-single { display: grid; gap: 12px; }
.material-editor-single textarea { min-height: 300px; }

.resume-workspace { display: grid; grid-template-columns: minmax(300px, 390px) minmax(0, 1fr); gap: 16px; align-items: start; }
.resume-editor-panel { max-height: calc(100vh - 180px); overflow: auto; }
.preview-shell { min-width: 0; overflow: auto; padding: 18px; }
.preview-toolbar { margin-bottom: 14px; }
.compact-actions { justify-content: flex-end; }

/* Account and editors */
.account-layout { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }
.package-counter { display: flex; align-items: baseline; gap: 7px; color: var(--muted); }
.package-counter strong { color: var(--success); font-size: 28px; }
.editor-group { margin-top: 12px; }
.section-editor-list { display: grid; gap: 10px; margin: 12px 0; }
.section-editor { border-top: 1px solid var(--line); padding-top: 10px; }
.section-editor summary { cursor: pointer; font-weight: 800; }
.item-editor { border-left: 3px solid #dfe5ec; margin-top: 10px; padding-left: 12px; }

.import-draft { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); margin-top: 12px; padding: 12px; }
.import-summary { display: grid; gap: 3px; margin-bottom: 8px; }
.import-summary span { color: var(--success); font-size: 12px; }
.import-draft pre { max-height: 130px; overflow: auto; border: 1px solid var(--line); background: #fff; padding: 9px; white-space: pre-wrap; font: 12px/1.55 ui-monospace, monospace; }

.style-inline { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); margin-bottom: 14px; padding: 12px; }
.style-inline summary { cursor: pointer; font-weight: 800; }
.template-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.template-card { display: grid; gap: 3px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px; text-align: left; }
.template-card span { color: var(--muted); font-size: 11px; }
.template-card.active { border-color: var(--primary); background: #edf4fd; }

/* Resume preview */
.resume-page {
  --page-width: min(100%, 794px);
  width: var(--page-width);
  min-height: calc(var(--page-width) * 1.4142);
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 12px 36px rgba(24, 33, 43, 0.16);
  color: #111827;
  font-size: calc(14px * var(--font-scale));
  line-height: calc(1.48 * var(--spacing-scale));
  padding: calc(46px * var(--spacing-scale));
}
.resume-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; border-bottom: 3px solid var(--accent); padding-bottom: 18px; }
.resume-header h2 { color: #111827; font-size: calc(34px * var(--font-scale)); line-height: 1.1; }
.resume-title { color: var(--accent); font-weight: 750; margin: 7px 0 4px; }
.contacts { color: #4b5563; font-size: calc(12px * var(--font-scale)); margin-bottom: 0; overflow-wrap: anywhere; }
.avatar { display: grid; flex: 0 0 auto; width: 72px; height: 72px; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 30px; font-weight: 800; }
.profile-summary { color: #374151; margin: 18px 0; }
.resume-sections { display: grid; gap: calc(16px * var(--spacing-scale)); }
.resume-section h3 { color: #111827; font-size: calc(15px * var(--font-scale)); }
.section-line .resume-section h3 { border-bottom: 1px solid var(--accent); padding-bottom: 5px; }
.resume-items { display: grid; gap: calc(10px * var(--spacing-scale)); }
.resume-item p, .text-item { margin-bottom: 0; overflow-wrap: anywhere; }
.organization { color: var(--accent); font-weight: 700; margin-bottom: 3px; }
.item-head span { color: #6b7280; font-size: 12px; }
.skill-list { display: flex; flex-wrap: wrap; gap: 7px; }
.skill-list span { border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, white); padding: 4px 9px; }
.template-sidebar { display: grid; grid-template-columns: 180px 1fr; gap: 22px; }
.template-sidebar .resume-header { grid-column: 1 / -1; }
.template-sidebar .resume-sections { display: contents; }
.template-sidebar .resume-section:nth-child(1), .template-sidebar .resume-section:nth-child(5) { grid-column: 1; }
.template-sidebar .resume-section { grid-column: 2; }
.template-compact { padding: 32px; line-height: 1.35; }

@media (max-width: 900px) {
  body { background: #fff; }
  input, textarea, select, button { font-size: 16px; }
  .top-menu {
    position: static;
    min-height: 58px;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    backdrop-filter: none;
  }
  .brand-button span { display: none; }
  .top-menu nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.97);
    padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
    backdrop-filter: blur(10px);
  }
  .menu-button { min-width: 0; min-height: 48px; padding: 7px 2px; font-size: 13px; }
  .workspace { padding: 14px 10px calc(78px + env(safe-area-inset-bottom)); }
  .jobs-layout, .account-layout, .resume-workspace { grid-template-columns: 1fr; }
  .jobs-sidebar { order: 0; }
  .job-detail { min-height: auto; }
  .resume-editor-panel { max-height: none; }
  .report-grid, .question-grid { grid-template-columns: 1fr; }
  .preview-shell { border: 0; padding: 10px 0; }
  .resume-page { --page-width: min(100%, 440px); padding: calc(24px * var(--spacing-scale)); box-shadow: 0 8px 24px rgba(24, 33, 43, 0.14); }
  .template-sidebar { grid-template-columns: 1fr; }
  .template-sidebar .resume-header, .template-sidebar .resume-section, .template-sidebar .resume-section:nth-child(1), .template-sidebar .resume-section:nth-child(5) { grid-column: auto; }
  .template-sidebar .resume-sections { display: grid; }
}

@media (max-width: 560px) {
  h1 { font-size: 25px; }
  .invite-panel { padding: 24px 18px; }
  .invite-panel h1 { font-size: 28px; }
  .next-action-panel { padding: 22px 18px; }
  .next-action-panel h1 { font-size: 29px; }
  .progress-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .progress-strip span { padding: 10px 3px; font-size: 11px; overflow-wrap: anywhere; }
  .home-lower { grid-template-columns: 1fr; }
  .mini-metrics { width: 100%; }
  .page-heading, .panel-header, .preview-toolbar { align-items: flex-start; }
  .job-meta-grid, .profile-grid, .score-row { grid-template-columns: 1fr; }
  .material-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; }
  .material-tabs button { padding-inline: 2px; font-size: 14px; }
  .package-banner { align-items: flex-start; flex-direction: column; }
  .preview-toolbar { display: grid; }
  .compact-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .template-grid { grid-template-columns: repeat(2, 1fr); }
  .resume-header { gap: 12px; }
  .resume-header h2 { font-size: calc(26px * var(--font-scale)); }
  .avatar { width: 50px; height: 50px; font-size: 21px; }
  .item-head { align-items: flex-start; flex-direction: column; gap: 2px; }
}

@media print {
  body { background: #fff; }
  body * { visibility: hidden; }
  #resume-page, #resume-page * { visibility: visible; }
  #resume-page { position: absolute; top: 0; left: 0; width: 210mm; min-height: 297mm; margin: 0; box-shadow: none; }
  @page { size: A4; margin: 0; }
}
