:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e3e6eb;
  --text: #1d2330;
  --muted: #6b7280;
  --primary: #2f5bea;
  --primary-hover: #244bd0;
  --danger: #d64545;
  --ok: #1f9d55;
  --warn: #d98a00;
  --info: #4c6ef5;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 18px; background: #fff; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.badge { font-size: 11px; font-weight: 600; background: #e8eefc; color: var(--primary); padding: 2px 8px; border-radius: 999px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.btn {
  font: inherit; font-size: 13px; font-weight: 500; line-height: 1.2;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 7px 12px; border-radius: 8px; cursor: pointer;
}
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.ghost { border-style: dashed; background: transparent; color: var(--primary); }
.btn.ghost:hover { background: #f0f4ff; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-btn {
  flex: none; width: 26px; height: 26px; border: 0; border-radius: 6px; background: none;
  color: var(--muted); font-size: 14px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: #eef0f4; color: var(--text); }
.icon-btn.danger:hover { background: #fdecec; color: var(--danger); }

/* Layout */
.layout { flex: 1; display: grid; grid-template-columns: minmax(400px, 540px) 1fr; min-height: 0; }
.panel { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--bg); }
.tabs { display: flex; gap: 4px; padding: 6px 14px 0; background: #fff; border-bottom: 1px solid var(--border); }
.tabs button {
  font: inherit; font-weight: 500; color: var(--muted); background: none; cursor: pointer;
  border: 0; border-bottom: 2px solid transparent; padding: 9px 12px; display: flex; align-items: center; gap: 6px;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--primary); }
.score-badge { font-size: 11px; font-weight: 700; color: #fff; border-radius: 999px; padding: 1px 7px; background: var(--muted); }
.score-badge:empty { display: none; }
.panel-body { flex: 1; overflow: auto; padding: 14px; }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
.card-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-body { padding: 4px 14px 14px; }
.card.sec .card-head { padding: 7px 8px; }
.card.sec.open .card-head { border-bottom: 1px solid var(--border); }
.card.sec.open .card-body { padding-top: 12px; }
.card.hidden-sec { opacity: 0.6; }
.sec-title-input {
  flex: 1; min-width: 0; font: inherit; font-weight: 600; color: var(--text);
  border: 1px solid transparent; border-radius: 6px; padding: 5px 7px; background: transparent;
}
.sec-title-input:hover, .sec-title-input:focus { border-color: var(--border); background: #fff; outline: none; }
.tag { font-size: 11px; color: var(--muted); background: #f1f3f6; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.vis { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; margin: 0 2px; }

/* Forms */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.lbl { font-size: 12px; font-weight: 500; color: #4b5563; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 0; }
.lbl em, .lbl output { font-style: normal; font-weight: 400; color: #9ca3af; text-align: right; }
.lbl output { color: var(--text); font-weight: 600; }
input[type=text], input[type=email], textarea, select {
  font: inherit; font-size: 13.5px; color: var(--text); width: 100%;
  border: 1px solid #d6dae1; border-radius: 7px; padding: 7px 9px; background: #fff;
}
textarea { resize: vertical; line-height: 1.45; overflow: hidden; min-height: 35px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 91, 234, .12); }
input[type=range] { width: 100%; accent-color: var(--primary); }
input[type=color] { width: 34px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
.row { display: flex; gap: 6px; align-items: flex-start; margin-bottom: 6px; }
.row > input, .row > textarea { flex: 1; min-width: 0; }
.skill-row .w-label { flex: 0 0 34%; font-weight: 500; }
.swatches { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2px var(--primary); }

/* Entry items */
.item { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: #fafbfc; }
.item-head { display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; cursor: pointer; user-select: none; }
.item-head:hover { background: #f3f5f8; border-radius: 8px; }
.item.open .item-head:hover { border-radius: 8px 8px 0 0; }
.caret { color: var(--muted); width: 12px; flex: none; }
.item-title { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { font-size: 12px; color: var(--muted); white-space: nowrap; max-width: 38%; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; }
.item-body { padding: 12px; background: #fff; border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; }
.add-sec { display: flex; gap: 8px; margin: 6px 0 30px; }
.add-sec select { flex: 1; }

.muted { color: var(--muted); margin: 0 0 10px; font-size: 13px; }
.tips { margin: 0; padding-left: 18px; color: #4b5563; font-size: 13px; line-height: 1.55; }

/* ATS */
.score-card { display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; align-items: center; padding-top: 14px; }
.score-card p { margin: 2px 0 0; }
.score-ring {
  width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), #e5e7eb 0);
}
.score-ring span { width: 48px; height: 48px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 14px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; }
.chip i { font-style: normal; opacity: .65; font-size: 11px; }
.chip.hit { background: #e7f6ec; color: #17733d; }
.chip.miss { background: #fdeeee; color: #b23434; }
.check-group { margin-bottom: 10px; }
.group-title, .check-group summary { font-size: 12px; font-weight: 600; color: #4b5563; text-transform: uppercase; letter-spacing: .04em; margin: 4px 0; cursor: default; }
.check-group summary { cursor: pointer; }
.check { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid #f0f1f4; font-size: 13px; line-height: 1.45; }
.check small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; word-break: break-word; }
.check .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.check.err .dot { background: var(--danger); }
.check.warn .dot { background: var(--warn); }
.check.info .dot { background: var(--info); }
.check.ok .dot { background: var(--ok); }

/* Preview */
.preview-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #e6e9ef; }
.preview-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 16px; font-size: 12.5px; color: var(--muted); background: #eef0f4; border-bottom: 1px solid var(--border);
}
.preview-toolbar .hint { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zoom { display: flex; align-items: center; gap: 4px; }
#zoom-label { min-width: 40px; text-align: center; }
.preview-scroll { flex: 1; overflow: auto; padding: 24px; }
.sheet-wrap { position: relative; margin: 0 auto; }
.sheet {
  position: absolute; top: 0; left: 0; box-sizing: border-box;
  background: #fff; transform-origin: top left;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 10px 30px rgba(0, 0, 0, .08);
}
.page-guide { position: absolute; left: 0; right: 0; border-top: 1px dashed #ef8b8b; pointer-events: none; }
.page-guide span {
  position: absolute; right: 6px; top: -9px; background: #fff; color: #e06464; padding: 0 4px;
  font: 500 10px/16px 'Inter', 'Segoe UI', sans-serif;
}

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #1d2330; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; transition: .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Print: only the resume */
#print-root { display: none; }
@media print {
  html, body { height: auto; background: #fff; }
  #app, #toast { display: none !important; }
  #print-root { display: block; }
}

@media (max-width: 960px) {
  #app { height: auto; }
  .layout { grid-template-columns: 1fr; }
  .panel { border-right: 0; }
  .panel-body { overflow: visible; }
  .preview-scroll { height: 85vh; }
  .preview-toolbar .hint { display: none; }
}
@media (max-width: 520px) {
  .grid2 { grid-template-columns: 1fr; }
  .topbar { padding: 10px 12px; }
}
