/* CVCraftHub tool UI: resume builder, cover letter builder, ATS checker and job matcher.
   Loaded after site.css. No inline styles: dynamic sizes are CSS variables set through CSSOM. */

/* ---- App shell (full-height builder layouts) ----
   The toolbar and workspace fill the first screen; the short "About this builder" section sits below it and
   is reached by scrolling the page. The editor and preview scroll on their own and never chain to the page.
   svh keeps the shell height steady while mobile browser bars show and hide. */
.app-body { background: #fff; }
.app-shell { display: flex; flex-direction: column; height: 100vh; height: 100svh; min-height: 0; overflow: hidden; }
.app-bar {
  flex: none; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 14px;
  border-bottom: 1px solid var(--line); background: #fff; z-index: 20;
}
.app-bar-start { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.app-bar .logo { flex: none; font-size: 1.08rem; }
.app-bar .logo-mark { width: 30px; height: 30px; }
.app-doc { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; max-width: 340px; }
.app-doc-name {
  min-width: 0; width: 100%; padding: 2px 8px; margin-left: -8px; border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--ink); font-weight: 650; font-size: 0.98rem; line-height: 1.4; text-overflow: ellipsis;
}
.app-doc-name:hover { border-color: var(--line-strong); }
.app-doc-name:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); background: #fff; }
.save-status { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 0.8rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.save-status[data-state="saved"] .save-dot { background: #16a34a; }
.save-status[data-state="saving"] .save-dot { background: #d97706; }
.save-status[data-state="error"] { color: var(--danger); font-weight: 600; }
.save-status[data-state="error"] .save-dot { background: var(--danger); }
.app-bar-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.tb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; min-width: 40px; padding: 0 11px;
  border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--ink); font-weight: 600; font-size: 0.92rem; white-space: nowrap;
}
.tb-btn:hover:not([disabled]) { background: var(--soft); border-color: var(--line); }
.tb-btn[aria-pressed="true"], .tb-btn[aria-expanded="true"] { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
.tb-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.tb-btn .icon { width: 19px; height: 19px; }
.tb-icon { padding: 0; width: 40px; }
.tb-download { margin-left: 4px; }
.tb-sep { width: 1px; height: 24px; margin: 0 4px; background: var(--line); }

@media (max-width: 1239.98px) { .app-bar .logo-text { display: none; } }
/* The label stays in the accessibility tree when only the icon is shown, so the button keeps its name. */
@media (max-width: 1099.98px) {
  .tb-label { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  .tb-btn:not(.tb-icon) { position: relative; padding: 0; width: 40px; }
}
@media (max-width: 959.98px) { .tb-preview { display: none; } }
@media (max-width: 639.98px) {
  .app-bar { flex-wrap: wrap; gap: 6px 8px; padding: 8px 10px; }
  .app-bar-start { flex-basis: 100%; }
  .app-doc { max-width: none; }
  .app-bar-actions { flex-basis: 100%; justify-content: space-between; gap: 2px; }
  .tb-btn.tb-icon, .tb-btn:not(.tb-icon) { width: 38px; min-width: 38px; }
  .tb-download { margin-left: auto; }
}
@media (max-width: 359.98px) {
  .app-bar-actions { gap: 0; }
  .tb-btn.tb-icon, .tb-btn:not(.tb-icon) { width: 35px; min-width: 35px; }
  .tb-download { padding-left: 10px; padding-right: 10px; gap: 5px; }
}

.app-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; outline: none; }
.app-main > .no-js-message { flex: none; }
.app-view-toggle { display: none; }
.app-workspace { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(360px, 520px) minmax(0, 1fr); }
@media (min-width: 1400px) { .app-workspace { grid-template-columns: 580px minmax(0, 1fr); } }
.app-workspace[data-focus="preview"] { grid-template-columns: minmax(0, 1fr); }
.app-workspace[data-focus="preview"] .app-editor { display: none; }
.app-editor { position: relative; min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-right: 1px solid var(--line); background: #fff; container-type: inline-size; container-name: editor; scroll-padding-top: 108px; }
.app-preview { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #e9edf3; }
.privacy-note { flex: none; display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; padding: 7px 14px; border-top: 1px solid var(--line); background: var(--soft); color: var(--ink); font-size: 0.82rem; line-height: 1.4; text-align: left; }
.privacy-note .icon { flex: none; width: 17px; height: 17px; color: var(--success); }
.privacy-note a { white-space: nowrap; }

/* "About this builder": plain page content below the workspace. */
.app-about { padding: clamp(36px, 5vw, 56px) 0; border-top: 1px solid var(--line); background: var(--soft); }
.app-about .card-list { margin: 20px 0; }
.app-about .card h3 { font-size: 1.05rem; }
.app-about .container > p:last-child { margin-bottom: 0; }

@media (max-width: 959.98px) {
  .app-view-toggle { flex: none; display: flex; gap: 4px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: #fff; }
  .view-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; color: var(--ink); font-weight: 650; font-size: 0.95rem; }
  .view-btn .icon { width: 18px; height: 18px; }
  .view-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
  .app-workspace, .app-workspace[data-focus="preview"] { grid-template-columns: minmax(0, 1fr); }
  .app-workspace[data-view="edit"] .app-preview { display: none; }
  .app-workspace[data-view="preview"] .app-editor { display: none; }
  .app-workspace[data-view="edit"] .app-editor { display: block; }
  .app-editor { border-right: 0; }
  .privacy-note { font-size: 0.78rem; padding: 6px 10px; justify-content: flex-start; }
}

.editor-loading { display: grid; place-items: center; min-height: 240px; color: var(--muted); }
.editor-loading p { margin: 0; }

/* ---- Preview ---- */
.preview-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; border-bottom: 1px solid #d9dee7; background: #f3f5f9; }
.preview-info { margin: 0; color: var(--muted); font-size: 0.85rem; line-height: 1.3; min-width: 0; }
.preview-info strong { color: var(--ink); font-weight: 650; }
.preview-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.select-sm, .input-sm { min-height: 34px; padding: 4px 10px; font-size: 0.88rem; border-radius: 8px; }
.select.select-sm { padding-right: 30px; background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; }
.preview-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 22px 18px 40px; outline: none; }
.preview-scroll:focus-visible { box-shadow: inset 0 0 0 3px var(--brand); }
.preview-pages { display: flex; flex-direction: column; align-items: center; gap: 22px; min-width: min-content; }
.pv-page { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pv-frame {
  position: relative; width: var(--pv-w, 408px); height: var(--pv-h, 528px); overflow: hidden; background: #fff;
  box-shadow: 0 0 0 1px #cfd6e1, 0 2px 10px rgb(15 31 61 / 10%);
}
.pv-frame > .rs-page { position: absolute; left: 0; top: 0; transform-origin: 0 0; transform: scale(var(--pv-scale, 0.5)); }
.pv-frame [data-sec] { cursor: pointer; }
.pv-frame [data-sec]:hover { outline: 1px dashed #7aa2ea; outline-offset: 2px; }
.pv-label { margin: 0; color: var(--muted); font-size: 0.78rem; }
.pv-warn { max-width: 560px; margin: 0 auto; }
.preview-pages.is-updating .pv-frame { opacity: 0.94; }

/* ---- Editor structure ---- */
.ed-top { position: sticky; top: 0; z-index: 5; background: #fff; border-bottom: 1px solid var(--line); }
.ed-tabs { display: flex; gap: 2px; padding: 8px 14px 0; }
.ed-tab { position: relative; display: inline-flex; align-items: center; gap: 7px; min-height: 42px; padding: 0 14px; border: 0; background: transparent; color: var(--muted); font-weight: 650; font-size: 0.95rem; }
.ed-tab .icon { width: 18px; height: 18px; }
.ed-tab:hover { color: var(--ink); }
.ed-tab[aria-selected="true"] { color: var(--brand-700); }
.ed-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand); }
.ed-jump { display: flex; gap: 6px; padding: 8px 14px 10px; overflow-x: auto; scrollbar-width: thin; }
.ed-jump a, .ed-jump button {
  flex: none; display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 4px 11px; border: 1px solid var(--line-strong); border-radius: 99px;
  background: #fff; color: var(--ink); font-weight: 600; font-size: 0.83rem; text-decoration: none; white-space: nowrap;
}
.ed-jump a:hover, .ed-jump button:hover { border-color: var(--brand); color: var(--brand-600); background: var(--brand-50); }
.ed-jump a.is-hidden { color: var(--muted); border-style: dashed; }
.ed-jump .icon { width: 15px; height: 15px; }
.ed-jump .jump-action { border-color: transparent; background: var(--soft); }
.ed-panel { padding: 16px 16px 72px; }
.ed-panel[hidden] { display: none; }
.ed-panel > .notice { margin-bottom: 14px; }
.ed-intro { margin: 0 0 14px; color: var(--muted); font-size: 0.9rem; }

.ed-card { margin: 0 0 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; scroll-margin-top: 112px; }
.ed-card:focus-within { border-color: #b9cbef; }
.ed-card.is-flash { animation: ed-flash 1.1s ease-out; }
@keyframes ed-flash { from { box-shadow: 0 0 0 4px var(--brand-100); border-color: var(--brand); } to { box-shadow: 0 0 0 0 transparent; } }
.ed-card-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 6px; }
.ed-card-h, .ed-item-h { flex: 1 1 auto; min-width: 0; display: flex; margin: 0; font-size: inherit; font-weight: inherit; line-height: inherit; letter-spacing: normal; }
.ed-card-toggle {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); text-align: left;
}
.ed-card-toggle:hover { background: var(--soft); }
.ed-card-toggle .chev { flex: none; width: 18px; height: 18px; color: var(--muted); transition: transform 0.15s; }
.ed-card-toggle[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.ed-card-title { margin: 0; font-size: 1.02rem; font-weight: 700; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-card-sub { flex: none; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.ed-badge { flex: none; display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--soft); border: 1px solid var(--line); color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; }
.ed-badge-warn { background: var(--warn-50); border-color: #f6d9a8; color: var(--warn); }
.ed-card-actions { flex: none; display: flex; align-items: center; gap: 2px; }
.ed-card-body { padding: 4px 16px 16px; }
.ed-card-body[hidden] { display: none; }
.ed-card.is-section-hidden .ed-card-title { color: var(--muted); }

.ed-icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--muted);
}
.ed-icon-btn:hover:not([disabled]) { background: var(--soft); border-color: var(--line); color: var(--ink); }
.ed-icon-btn[disabled] { opacity: 0.35; cursor: not-allowed; }
.ed-icon-btn .icon { width: 18px; height: 18px; }
.ed-icon-btn.is-danger:hover:not([disabled]) { color: var(--danger); background: var(--danger-50); border-color: #f2c4bf; }
.ed-icon-btn[aria-pressed="true"] { color: var(--warn); }

/* ---- Editor fields ---- */
.app-editor .field, .tool-form .field { margin: 0 0 12px; gap: 5px; }
.app-editor .input, .app-editor .select, .app-editor .textarea { min-height: 40px; padding: 7px 11px; font-size: 0.95rem; }
.app-editor .select { padding-right: 34px; }
.app-editor .textarea { min-height: 88px; }
.app-editor .field > label, .app-editor .label { font-size: 0.87rem; }
.app-editor .hint { font-size: 0.82rem; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.fgrid > .span-2 { grid-column: 1 / -1; }
.fgrid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@container editor (max-width: 459.98px) {
  .fgrid, .fgrid-3 { grid-template-columns: minmax(0, 1fr); }
}
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.field-head label { color: var(--ink); font-weight: 620; font-size: 0.87rem; }
.field-opt { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.vis-btn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 1px 7px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--muted); font-size: 0.76rem; font-weight: 650;
}
.vis-btn .icon { width: 15px; height: 15px; }
.vis-btn:hover { background: var(--soft); border-color: var(--line); color: var(--ink); }
.vis-btn[aria-pressed="true"] { color: var(--warn); background: var(--warn-50); border-color: #f6d9a8; }
.field.is-field-hidden .input { color: var(--muted); background: var(--soft); border-style: dashed; }
.field .error-text:empty { display: none; }
.field .warn-text { color: var(--warn); font-size: 0.86rem; font-weight: 560; margin: 4px 0 0; }
.field .warn-text:empty { display: none; }
.field-row { display: flex; align-items: center; gap: 8px; }
.field-row > .input, .field-row > .select { flex: 1 1 auto; min-width: 0; }

.date-grp { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 6px; }
.date-grp .select, .date-grp .input { min-width: 0; }
.date-grp.is-disabled { opacity: 0.55; }
.check-sm { font-size: 0.87rem; font-weight: 560; margin: 2px 0 12px; }
.check-sm input { width: 17px; height: 17px; }
.check-group { display: grid; justify-items: start; gap: 10px; margin: 0 0 14px; }
.ed-subhead { margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--ink); font-size: 0.92rem; font-weight: 700; }
.ed-subhead:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.ed-more-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 12px; padding: 4px 0; border: 0; background: none; color: var(--brand); font-weight: 650; font-size: 0.88rem; }
.ed-more-toggle .icon { width: 16px; height: 16px; transition: transform 0.15s; }
.ed-more-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }
.ed-guidance { margin: 0 0 12px; color: var(--muted); font-size: 0.84rem; line-height: 1.5; }
.ed-note { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 12px; padding: 9px 11px; border-radius: 8px; background: var(--soft); color: var(--text); font-size: 0.84rem; line-height: 1.5; }
.ed-note .icon { flex: none; width: 17px; height: 17px; margin-top: 1px; color: var(--brand); }
.ed-note p { margin: 0; }
.ed-note-warn { background: var(--warn-50); }
.ed-note-warn .icon { color: var(--warn); }

/* ---- Items (experience, education ...) ---- */
.ed-items { display: grid; gap: 10px; margin: 0 0 12px; }
.ed-item { border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.ed-item.is-open { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.ed-item.is-item-hidden .ed-item-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.ed-item-head { display: flex; align-items: center; gap: 2px; padding: 4px 6px 4px 4px; }
.ed-item-toggle {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); text-align: left;
}
.ed-item-toggle:hover { background: var(--soft); }
.ed-item-toggle .chev { flex: none; width: 17px; height: 17px; color: var(--muted); transition: transform 0.15s; }
.ed-item-toggle[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.ed-item-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.ed-item-title { font-weight: 650; font-size: 0.93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-item-sub { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-item-actions { flex: none; display: flex; align-items: center; gap: 0; }
.ed-item-body { padding: 8px 12px 4px; border-top: 1px solid var(--line); }
.ed-item-body[hidden] { display: none; }
@container editor (max-width: 419.98px) {
  .ed-item-head { flex-wrap: wrap; }
  .ed-item-h { flex-basis: 100%; }
  .ed-item-actions { margin-left: auto; }
}
.ed-empty { margin: 0 0 12px; padding: 16px; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--soft); color: var(--muted); font-size: 0.9rem; text-align: center; }
.ed-empty p { margin: 0; }
.add-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; padding: 8px 14px; border: 1.5px dashed #a9bde6; border-radius: 10px;
  background: #fff; color: var(--brand-600); font-weight: 650; font-size: 0.93rem;
}
.add-btn:hover { background: var(--brand-50); border-color: var(--brand); }
.add-btn .icon { width: 18px; height: 18px; }
.ed-add-section { margin-top: 18px; }

/* Bullet list editor */
.bl-list { display: grid; gap: 6px; margin: 0 0 8px; padding: 0; list-style: none; }
.bl-row { display: flex; align-items: flex-start; gap: 4px; }
.bl-mark { flex: none; width: 14px; padding-top: 9px; color: var(--muted); font-weight: 700; text-align: center; }
.bl-row .textarea { flex: 1 1 auto; min-width: 0; min-height: 40px; height: auto; padding: 8px 10px; resize: none; overflow: hidden; line-height: 1.45; field-sizing: content; }
.bl-actions { flex: none; display: flex; align-items: center; }
.bl-actions .ed-icon-btn { width: 30px; height: 40px; }
@container editor (max-width: 379.98px) {
  .bl-row { flex-wrap: wrap; }
  .bl-row .textarea { flex-basis: calc(100% - 18px); }
  .bl-actions { margin-left: auto; }
}
.link-add { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; margin: 0 0 12px; padding: 4px 2px; border: 0; background: none; color: var(--brand); font-weight: 650; font-size: 0.88rem; }
.link-add .icon { width: 16px; height: 16px; }
.link-add:hover { color: var(--brand-700); text-decoration: underline; }

/* Rich text editor */
.rte { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; transition: border-color 0.15s, box-shadow 0.15s; }
.rte:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px 4px; border-bottom: 1px solid var(--line); background: var(--soft); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.rte-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 30px; padding: 0 7px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink); font-weight: 700; font-size: 0.9rem; }
.rte-btn:hover { background: #fff; border-color: var(--line); }
.rte-btn[aria-pressed="true"] { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
.rte-btn .icon { width: 17px; height: 17px; }
.rte-btn i { font-family: Georgia, "Times New Roman", serif; font-size: 1rem; }
.rte-area { min-height: 92px; max-height: 420px; overflow-y: auto; padding: 9px 12px; color: var(--ink); font-size: 0.95rem; line-height: 1.55; outline: none; overflow-wrap: anywhere; }
.rte-area p { margin: 0 0 0.45em; }
.rte-area p:last-child { margin-bottom: 0; }
.rte-area ul { margin: 0 0 0.45em; padding-left: 1.3em; }
.rte-area li { margin: 0 0 0.2em; }
.rte-area a { color: var(--brand); text-decoration: underline; }
.rte-area strong { font-weight: 700; }
.rte.is-empty .rte-area { position: relative; }
.rte.is-empty .rte-area::before { content: attr(data-placeholder); position: absolute; left: 12px; top: 9px; right: 12px; color: #8a97ab; pointer-events: none; }
.ed-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin: 5px 0 0; color: var(--muted); font-size: 0.8rem; }
.ed-meta .is-warn { color: var(--warn); font-weight: 600; }

/* Skills */
.sk-groups { display: grid; gap: 12px; margin: 0 0 12px; }
.sk-group { padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.sk-group-head { display: flex; align-items: flex-end; gap: 6px; margin-bottom: 10px; }
.sk-group-head .field { flex: 1 1 auto; margin: 0; min-width: 0; }
.sk-list { display: grid; gap: 6px; margin: 0 0 8px; padding: 0; list-style: none; }
.sk-row { display: flex; align-items: center; gap: 4px; }
.sk-row .input { flex: 1 1 auto; min-width: 0; }
.sk-row .select { flex: 0 0 132px; }
.sk-row .ed-icon-btn { width: 30px; }
@container editor (max-width: 399.98px) {
  .sk-row { flex-wrap: wrap; }
  .sk-row .select { flex: 1 1 auto; }
}
.sk-add { display: flex; gap: 6px; }
.sk-add .input { flex: 1 1 auto; min-width: 0; }
.sk-add .btn { flex: none; min-height: 40px; }

/* Photo */
.photo-field { display: flex; align-items: center; gap: 14px; margin: 0 0 12px; }
.photo-thumb { flex: none; display: grid; place-items: center; width: 72px; height: 72px; overflow: hidden; border-radius: 50%; border: 1px solid var(--line); background: var(--soft); color: var(--muted); }
.photo-thumb .icon { width: 30px; height: 30px; }
.photo-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-thumb.ps-rounded { border-radius: 14px; }
.photo-thumb.ps-square { border-radius: 2px; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ph-editor { display: grid; gap: 14px; justify-items: center; }
.ph-stage { position: relative; width: min(100%, 320px); aspect-ratio: 1; overflow: hidden; border-radius: 10px; background: #1e293b; touch-action: none; cursor: grab; user-select: none; }
.ph-stage:active { cursor: grabbing; }
.ph-stage:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
.ph-stage canvas { display: block; width: 100%; height: 100%; }
.ph-mask { position: absolute; inset: 8%; border-radius: 50%; box-shadow: 0 0 0 999px rgb(15 23 42 / 55%); border: 2px solid rgb(255 255 255 / 85%); pointer-events: none; }
.ph-mask.ps-rounded { border-radius: 16%; }
.ph-mask.ps-square, .ph-mask.ps-none { border-radius: 0; }
.ph-controls { display: grid; gap: 12px; width: 100%; max-width: 420px; }
.ph-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.ph-zoom { display: flex; align-items: center; gap: 10px; }
.ph-zoom input { flex: 1; accent-color: var(--brand); }
.ph-nudge { display: grid; grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(2, 36px); gap: 4px; }
.ph-nudge .ed-icon-btn { width: 40px; height: 36px; border-color: var(--line); }
.ph-nudge [data-nudge="up"] { grid-column: 2; grid-row: 1; }
.ph-nudge [data-nudge="left"] { grid-column: 1; grid-row: 2; }
.ph-nudge [data-nudge="down"] { grid-column: 2; grid-row: 2; }
.ph-nudge [data-nudge="right"] { grid-column: 3; grid-row: 2; }
.ph-hint { margin: 0; color: var(--muted); font-size: 0.84rem; text-align: center; }

/* Segmented radio groups */
.seg { display: inline-flex; flex-wrap: wrap; gap: 0; padding: 3px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--soft); }
.seg label { position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 4px 12px; border-radius: 7px; color: var(--ink); font-weight: 600; font-size: 0.87rem; cursor: pointer; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg label:has(input:checked) { background: #fff; color: var(--brand-700); box-shadow: 0 0 0 1px var(--brand-100), var(--shadow-sm); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--brand); outline-offset: 1px; }
.seg-block { display: flex; }
.seg-block label { flex: 1 1 auto; }

/* Design controls */
.ds-group { margin: 0 0 14px; padding: 14px 16px 4px; border: 1px solid var(--line); border-radius: 12px; }
.ds-group > h2, .ds-group > legend { float: left; width: 100%; margin: 0 0 12px; font-size: 1rem; font-weight: 700; color: var(--ink); }
.ds-group > legend + * { clear: both; }
.ds-tpl { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; }
.ds-tpl-thumb { flex: none; width: 76px; }
.ds-tpl-info { min-width: 0; flex: 1; }
.ds-tpl-info p { margin: 0 0 6px; color: var(--muted); font-size: 0.84rem; line-height: 1.45; }
.ds-tpl-name { display: block; color: var(--ink); font-weight: 700; }
.range-field { margin: 0 0 12px; }
.range-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.range-head label { flex: 1; color: var(--ink); font-weight: 620; font-size: 0.87rem; }
.range-head output { color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.range-field input[type="range"] { width: 100%; height: 28px; margin: 0; accent-color: var(--brand); }
.reset-btn { display: inline-flex; align-items: center; gap: 3px; min-height: 26px; padding: 0 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--brand); font-size: 0.76rem; font-weight: 650; }
.reset-btn:hover { background: var(--brand-50); }
.reset-btn[hidden] { display: none; }
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type="color"] { flex: none; width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; cursor: pointer; }
.color-row .input { flex: 1 1 auto; min-width: 0; font-family: var(--mono); font-size: 0.88rem; text-transform: lowercase; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-strong); background: var(--sw, #1f5fd6); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.ds-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 20px; }
.ds-group > h2 + * { clear: both; }
.ds-group .field { margin-bottom: 14px; }
.ds-group .hint.is-warn { color: var(--warn); font-weight: 560; }
.ds-group .hint:empty { display: none; }
.ds-tpl-info .btn .icon, .ds-actions .btn .icon { width: 16px; height: 16px; }

/* ---- Menus ---- */
.menu {
  position: fixed; left: var(--menu-x, 0); top: var(--menu-y, 0); z-index: 1100; min-width: 220px; max-width: min(320px, calc(100vw - 16px));
  max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; margin: 0; padding: 6px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow-lg); list-style: none;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 7px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); font-size: 0.92rem; font-weight: 560; text-align: left; text-decoration: none; white-space: nowrap;
}
.menu-item .icon { flex: none; width: 18px; height: 18px; color: var(--muted); }
.menu-item:hover, .menu-item:focus { outline: none; background: var(--brand-50); color: var(--brand-700); }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--brand); }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger .icon { color: var(--danger); }
.menu-item.is-danger:hover, .menu-item.is-danger:focus { background: var(--danger-50); color: var(--danger); }
.menu-item[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line); }
.menu-label { margin: 6px 10px 4px; color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

/* ---- Dialog content ---- */
.start-options { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
@media (min-width: 700px) { .start-options { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.start-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; width: 100%; height: 100%; padding: 18px; border: 1px solid var(--line-strong); border-radius: 12px;
  background: #fff; color: var(--text); text-align: left; font-size: 0.9rem; line-height: 1.5;
}
.start-opt:hover { border-color: var(--brand); background: var(--brand-50); }
.start-opt strong { color: var(--ink); font-size: 1.02rem; }
.start-opt .start-ic { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: var(--brand-50); color: var(--brand); }
.start-opt .start-ic .icon { width: 22px; height: 22px; }
.start-foot { margin: 16px 0 0; color: var(--muted); font-size: 0.86rem; }

.tpl-pick-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); margin: 0; padding: 0; list-style: none; }
.tpl-pick {
  display: flex; flex-direction: column; gap: 8px; width: 100%; padding: 10px; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink); text-align: left;
}
.tpl-pick:hover { border-color: var(--brand); }
.tpl-pick[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.tpl-pick .rs-thumb { border-radius: 5px; box-shadow: 0 0 0 1px var(--line); }
.tpl-pick-name { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-weight: 700; font-size: 0.92rem; }
.tpl-pick-name .icon { width: 18px; height: 18px; color: var(--brand); }
.tpl-pick .tag-list { gap: 4px; }
.tpl-pick .tag { font-size: 0.7rem; padding: 1px 7px; }
.tpl-note { margin: 0 0 14px; color: var(--muted); font-size: 0.88rem; }

.res-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.res-row { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border: 1px solid var(--line); border-radius: 10px; }
.res-row.is-current { border-color: var(--brand); background: var(--brand-50); }
.res-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.res-name { color: var(--ink); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-meta { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-actions { flex: none; display: flex; align-items: center; gap: 2px; }
@media (max-width: 479.98px) { .res-row { flex-wrap: wrap; } .res-info { flex-basis: 100%; } .res-actions { margin-left: auto; } }

.dl-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.dl-opt {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px;
  background: #fff; color: var(--text); text-align: left; font-size: 0.87rem; line-height: 1.45;
}
.dl-opt:hover { border-color: var(--brand); background: var(--brand-50); }
.dl-opt strong { display: block; color: var(--ink); font-size: 0.98rem; }
.dl-opt .dl-ic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--soft); color: var(--ink); font-weight: 800; font-size: 0.72rem; letter-spacing: 0.03em; }
.dl-opt.is-primary { border-color: var(--brand); }
.dl-opt.is-primary .dl-ic { background: var(--brand); color: #fff; }
.dl-opt[aria-busy="true"] { opacity: 0.6; cursor: progress; }
.dl-meta { margin: 0 0 14px; color: var(--muted); font-size: 0.86rem; }
.dl-meta strong { color: var(--ink); }

.chk-score { display: flex; align-items: center; gap: 16px; margin: 0 0 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.chk-ring { flex: none; display: grid; place-items: center; width: 74px; height: 74px; border-radius: 50%; background: conic-gradient(var(--ring-c, var(--brand)) calc(var(--pct, 0) * 1%), var(--line) 0); }
.chk-ring span { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: #fff; color: var(--ink); font-weight: 800; font-size: 1.15rem; }
.chk-score p { margin: 0; font-size: 0.9rem; }
.chk-score strong { display: block; color: var(--ink); font-size: 1.05rem; }
.chk-list { display: grid; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; }
.chk-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 0.9rem; line-height: 1.5; }
.chk-item .icon { flex: none; width: 19px; height: 19px; margin-top: 1px; }
.chk-item.is-ok .icon { color: var(--success); }
.chk-item.is-warn { background: var(--warn-50); border-color: #f6d9a8; }
.chk-item.is-warn .icon { color: var(--warn); }
.chk-item.is-info .icon { color: var(--brand); }
.chk-item strong { display: block; color: var(--ink); font-weight: 650; }
.chk-item p { margin: 0; }
.chk-item .link-btn { font-size: 0.86rem; font-weight: 600; }
.ats-text {
  max-height: 420px; overflow: auto; margin: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft);
  color: var(--ink); font-family: var(--mono); font-size: 0.82rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere;
}
.tabs-lite { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.tabs-lite button { position: relative; min-height: 40px; padding: 0 12px; border: 0; background: none; color: var(--muted); font-weight: 650; font-size: 0.92rem; }
.tabs-lite button[aria-selected="true"] { color: var(--brand-700); }
.tabs-lite button[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand); }

.sec-list { display: grid; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; }
.sec-row { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 4px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.sec-row.is-dragging { opacity: 0.5; }
.sec-row.is-drop-before { box-shadow: 0 -3px 0 var(--brand); }
.sec-row.is-drop-after { box-shadow: 0 3px 0 var(--brand); }
.sec-row.is-hidden-row .sec-name { color: var(--muted); }
.sec-grip { flex: none; display: grid; place-items: center; width: 28px; height: 36px; color: var(--muted); cursor: grab; touch-action: none; user-select: none; }
.sec-grip:active { cursor: grabbing; }
.sec-grip .icon { width: 18px; height: 18px; }
.sec-fixed { flex: none; width: 28px; }
.sec-name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.sec-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.93rem; }
.sec-name span { color: var(--muted); font-size: 0.78rem; }
.sec-actions { flex: none; display: flex; align-items: center; gap: 0; }
@media (max-width: 479.98px) { .sec-row { flex-wrap: wrap; } .sec-name { flex-basis: calc(100% - 40px); } .sec-actions { margin-left: auto; } }
.add-sec-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); margin: 0; padding: 0; list-style: none; }
.add-sec-grid .btn { width: 100%; justify-content: flex-start; white-space: normal; text-align: left; }
.add-sec-note { margin-top: 16px; }

.imp-drop { display: grid; place-items: center; gap: 10px; padding: 28px 18px; border: 2px dashed #a9bde6; border-radius: 14px; background: var(--brand-50); text-align: center; }
.imp-drop.is-over { border-color: var(--brand); background: var(--brand-100); }
.imp-drop p { margin: 0; }
.imp-drop .icon { width: 30px; height: 30px; color: var(--brand); }
.imp-review .ed-subhead { margin-top: 16px; }
.imp-review .field { margin-bottom: 10px; }
.imp-item { padding: 10px 12px; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 10px; }
.imp-item .check { font-weight: 600; }
.imp-raw { max-height: 220px; }
.imp-alert { margin: 0 0 12px; }
.imp-names { margin: 12px 0 0; padding-left: 20px; font-size: 0.92rem; }
.imp-details { margin: 12px 0 0; }
.imp-details summary { cursor: pointer; color: var(--brand-700); font-weight: 600; font-size: 0.9rem; }
.imp-details .ats-text { margin-top: 8px; }
.chk-suggest { margin: 0 0 16px; padding-left: 20px; font-size: 0.92rem; }
.chk-suggest li { margin: 0 0 4px; }
.dl-opt > span:last-child { min-width: 0; }
.dl-opt > span:last-child > span { display: block; color: var(--text); font-size: 0.86rem; line-height: 1.45; }

.progress { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.9rem; }
.spinner { flex: none; width: 18px; height: 18px; border: 2.5px solid var(--brand-100); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: #fff; color: var(--ink); font-family: var(--mono); font-size: 0.78rem; }

/* ---- Tool pages (ATS checker, job matcher, cover letter) ---- */
.tool-shell { padding: 8px 0 64px; }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
@media (min-width: 1000px) { .tool-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } }
.tool-card { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-sm); }
@media (max-width: 479.98px) {
  .tool-card { padding: 16px; }
  .tool-card .tabs-lite { flex-wrap: wrap; }
  .tool-card .chk-score { flex-direction: column; align-items: flex-start; }
  .tool-card .fgrid { grid-template-columns: minmax(0, 1fr); }
}
.tool-card > h2 { font-size: 1.25rem; margin-bottom: 12px; }
.tool-card > h2:not(:first-child) { margin-top: 22px; }
.tool-steps { display: grid; gap: 8px; margin: 0 0 18px; padding: 0; list-style: none; counter-reset: step; }
.tool-steps li { display: flex; gap: 10px; align-items: flex-start; font-size: 0.93rem; color: var(--ink); counter-increment: step; }
.tool-steps li::before { content: counter(step); flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--brand-50); color: var(--brand-700); font-weight: 750; font-size: 0.8rem; }
.tool-empty { padding: 28px 18px; border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--soft); color: var(--muted); text-align: center; }
.tool-empty p { margin: 0 0 12px; }
.tool-empty p:last-child { margin-bottom: 0; }
.tool-results[hidden] { display: none; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }
.tool-actions .btn { max-width: 100%; white-space: normal; text-align: center; }
.kw-group { margin: 0 0 18px; }
.kw-group h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 1rem; }
.kw-group h3 .count { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.kw-group > p { margin: 0 0 8px; color: var(--muted); font-size: 0.88rem; }
.chip-list .chip { max-width: 100%; font-weight: 600; overflow-wrap: anywhere; }
.tool-form .textarea { min-height: 220px; }

/* Cover letter builder layout (full-height like the resume builder) */
.letter-editor .ed-panel { padding-top: 16px; }
.letter-preview .pv-frame > .lt-page { position: absolute; left: 0; top: 0; transform-origin: 0 0; transform: scale(var(--pv-scale, 0.5)); }

@media print {
  .app-bar, .app-view-toggle, .privacy-note, .app-about, .toast-region, .menu { display: none !important; }
}
