:root {
  --bg: #0f1420; --panel: #171e2e; --panel2: #1d2638; --line: #2a3550;
  --text: #e8edf6; --muted: #9aa7c2; --accent: #5b9dff; --accent2: #7c6cf0;
  --green: #4ade80; --amber: #fbbf24; --red: #f87171;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.brand { font-size: 1.25rem; font-weight: 800; letter-spacing: 0.02em; }
.brand .logo { color: var(--accent); }
.brand .sub { font-weight: 400; color: var(--muted); font-size: 0.85rem; margin-left: 8px; }
.top-actions { display: flex; gap: 8px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 0.85rem; font-weight: 600;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.big { width: 100%; padding: 12px; font-size: 1rem; margin-top: 6px; }
.btn.secondary { background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.link { background: none; border: none; color: var(--accent); padding: 4px 0; font-weight: 500; }
.btn.xs { padding: 5px 10px; font-size: 0.75rem; }
.presets { display: flex; gap: 6px; margin: 2px 0 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- split layout ---------- */
.split { display: flex; flex: 1; min-height: 0; }
.left {
  width: 380px; flex: 0 0 380px; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
  border-right: 1px solid var(--line); background: var(--bg);
}
.right { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #0b0f18; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px;
}
.panel h2 { margin: 0 0 10px; font-size: 0.95rem; font-weight: 700; }
.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 0.75rem; margin-right: 6px;
}
.field { display: block; margin: 8px 0; font-size: 0.82rem; color: var(--muted); }
.field input, .field select, .field textarea, textarea#jd-input, textarea#paste-area {
  width: 100%; margin-top: 4px; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
  font-size: 0.85rem; font-family: inherit; resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus,
textarea#jd-input:focus, textarea#paste-area:focus {
  outline: none; border-color: var(--accent);
}
.hint { font-size: 0.78rem; color: var(--muted); margin: 8px 0 0; line-height: 1.45; }
.hidden { display: none !important; }

.upload { display: block; margin: 4px 0; }
.upload-row { display: flex; gap: 8px; align-items: stretch; }
.upload-row .upload { flex: 1; margin: 0; }
.upload-row .btn { white-space: nowrap; align-self: center; }
.upload-cta {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 18px 10px; cursor: pointer; font-weight: 600; font-size: 0.9rem;
}
.upload-cta small { font-weight: 400; color: var(--muted); }
.upload-cta:hover { border-color: var(--accent); background: var(--panel2); }

/* ---------- ATS score ---------- */
.score-wrap { display: flex; gap: 14px; align-items: center; }
.ring { width: 110px; height: 110px; flex: 0 0 110px; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 10; }
.ring-fg {
  fill: none; stroke: var(--muted); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transform: rotate(-90deg); transform-origin: 60px 60px;
  transition: stroke-dashoffset 0.8s ease, stroke 0.8s ease;
}
.ring-num { font-size: 26px; font-weight: 800; fill: var(--text); }
.ring-sub { font-size: 11px; fill: var(--muted); letter-spacing: 0.1em; }
.breakdown { list-style: none; margin: 0; padding: 0; flex: 1; font-size: 0.75rem; }
.breakdown li { margin-bottom: 6px; }
.breakdown .blabel { display: flex; justify-content: space-between; color: var(--muted); margin-bottom: 2px; }
.breakdown .bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.breakdown .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.6s ease; }

/* ---------- keyword chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  background: #3a2b12; color: #ffd166; border: 1px solid #6b5320;
  font-size: 0.75rem; padding: 4px 10px; border-radius: 999px; cursor: pointer; font-weight: 600;
}
.chip:hover { background: #4a3a18; }
.chip small { opacity: 0.7; font-weight: 400; }
.chip.added { background: #1d3a26; color: var(--green); border-color: #2c5a38; cursor: default; }

details.ai summary { cursor: pointer; font-size: 0.95rem; font-weight: 700; }
details.ai .opt { font-size: 0.7rem; color: var(--muted); font-weight: 400; border: 1px solid var(--line); padding: 1px 8px; border-radius: 999px; margin-left: 6px; }

/* ---------- right: document ---------- */
.doc-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.doc-title { font-size: 0.85rem; color: var(--muted); }
.doc-tools { display: flex; gap: 6px; }
.doc-scroll { flex: 1; overflow-y: auto; padding: 26px; display: flex; justify-content: center; }

/* resume sheet — ATS-safe: single column, standard fonts, no graphics */
#resume-doc {
  background: #fff; color: #1a1a1a; width: 816px; min-height: 1056px;
  padding: 48px 54px; box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  font-family: Georgia, "Times New Roman", serif; font-size: 11pt; line-height: 1.45;
  flex: 0 0 auto; align-self: flex-start;
}
#resume-doc [contenteditable="true"] { outline: none; border-radius: 3px; }
#resume-doc [contenteditable="true"]:hover { background: #f0f6ff; }
#resume-doc [contenteditable="true"]:focus { background: #e4efff; box-shadow: 0 0 0 2px var(--accent); }
#resume-doc h1 { font-size: 22pt; margin: 0 0 2px; font-family: inherit; }
#resume-doc .r-contact { font-size: 9.5pt; color: #444; margin: 0 0 12px; font-family: Arial, Helvetica, sans-serif; }
#resume-doc h2.rsec {
  font-size: 11pt; text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1.5px solid #333; padding-bottom: 3px; margin: 16px 0 8px;
  font-family: Arial, Helvetica, sans-serif;
}
#resume-doc .r-entry { margin-bottom: 10px; position: relative; }
#resume-doc .r-entry-head { display: flex; justify-content: space-between; font-weight: bold; font-family: Arial, Helvetica, sans-serif; font-size: 10.5pt; }
#resume-doc .r-entry-sub { font-style: italic; color: #333; font-size: 10pt; margin-bottom: 2px; }
#resume-doc ul.r-bullets { margin: 4px 0 6px; padding-left: 18px; }
#resume-doc ul.r-bullets li { margin-bottom: 3px; }
#resume-doc .r-skills { margin: 2px 0 6px; }
#resume-doc .r-extra { font-size: 10.5pt; line-height: 1.5; white-space: pre-wrap; }
#resume-doc [contenteditable="true"]:empty::before {
  content: attr(data-ph); color: #999; font-style: italic;
}
.skill-chip {
  display: inline-block; background: #eef2f7; border: 1px solid #c8d3e3;
  color: #1a1a1a; font-size: 9.5pt; font-family: Arial, Helvetica, sans-serif;
  padding: 2px 6px 2px 10px; border-radius: 999px; margin: 0 6px 6px 0;
}
.skill-chip button {
  background: none; border: none; color: #888; cursor: pointer;
  font-size: 12px; margin-left: 4px; padding: 0 2px;
}
.skill-chip button:hover { color: var(--red); }
.skill-add input {
  border: 1px dashed #999; border-radius: 999px; padding: 3px 10px;
  font-size: 9.5pt; width: 130px; font-family: Arial, Helvetica, sans-serif;
}
.skill-add button {
  background: #1a1a1a; color: #fff; border: none; border-radius: 999px;
  padding: 4px 12px; font-size: 9.5pt; cursor: pointer; margin-left: 4px;
  font-family: Arial, Helvetica, sans-serif;
}
#resume-doc .entry-x {
  position: absolute; right: -8px; top: -6px; display: none;
  background: var(--red); color: #fff; border: none; border-radius: 50%;
  width: 20px; height: 20px; font-size: 12px; line-height: 1; cursor: pointer;
}
#resume-doc .r-entry:hover .entry-x { display: block; }
#resume-doc .add-bullet {
  display: none; background: none; border: 1px dashed #999; color: #666;
  font-size: 0.75rem; padding: 2px 10px; border-radius: 6px; cursor: pointer; margin: 2px 0 6px;
}
#resume-doc .r-entry:hover .add-bullet { display: inline-block; }

/* templates */
#resume-doc.tpl-classic h1 { font-family: Arial, Helvetica, sans-serif; }
#resume-doc.tpl-classic h2.rsec { border-bottom: 1px solid #999; color: #222; }
#resume-doc.tpl-compact { font-size: 10pt; padding: 36px 44px; line-height: 1.35; }
#resume-doc.tpl-compact h1 { font-size: 19pt; }
#resume-doc.tpl-compact h2.rsec { margin: 12px 0 6px; }
#resume-doc.tpl-compact .r-entry { margin-bottom: 7px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #222c44; border: 1px solid var(--accent); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 0.85rem; z-index: 99;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}

/* ---------- print: resume only, real selectable text ---------- */
#print-root { display: none; }
@media print {
  body { overflow: visible; background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  #print-root #resume-doc {
    box-shadow: none; width: auto; min-height: auto; margin: 0;
  }
  #print-root [contenteditable] { background: none !important; box-shadow: none !important; }
  #print-root .entry-x, #print-root .add-bullet { display: none !important; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .split { flex-direction: column; }
  .left { width: auto; flex: none; border-right: none; border-bottom: 1px solid var(--line); }
  #resume-doc { width: 100%; min-height: auto; }
}

/* accessible hiding: keeps the input focusable/exposed without visual display */
.visually-hidden{position:absolute!important;width:1px;height:1px;margin:-1px;padding:0;border:0;clip:rect(0 0 0 0);clip-path:inset(50%);overflow:hidden;white-space:nowrap}
.upload:focus-within{outline:2px solid var(--accent);outline-offset:2px}
