/* Mahato Net Cafe — Smart Scanner desktop UI */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e3e8f0;
  --line-2: #cfd7e3;
  --text: #111827;
  --muted: #5b6474;
  --blue: #1d6fe8;
  --blue-d: color-mix(in srgb, var(--blue) 80%, #000);
  --blue-soft: color-mix(in srgb, var(--blue) 11%, #fff);
  --blue-line: color-mix(in srgb, var(--blue) 40%, #fff);
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --well: #eef1f6;
  --label: #374151;
  --soft-bg: #fbfcfe;
  --green: #16a34a;
  --green-d: #12823c;
  --green-soft: #e7f6ec;
  --orange: #b45309;
  --orange-soft: #fdf1dc;
  --red: #dc2626;
  --red-soft: #fdecec;
  --brand-a: var(--blue);
  --brand-b: #141414;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 18px rgba(15, 23, 42, .05);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; display: flex; flex-direction: column; overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; flex: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ── Title bar ──────────────────────────────────────────── */
.titlebar {
  height: 64px; flex: none; display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line);
  -webkit-app-region: drag; user-select: none;
  /* leave room for the Windows caption buttons drawn over the page */
  padding-right: calc(100vw - env(titlebar-area-width, 100vw) + 20px);
}
.brand-logo { width: 52px; height: 52px; object-fit: contain; }
.brand-name { font-size: 30px; font-weight: 800; letter-spacing: -.3px; white-space: nowrap; }
.brand-a { color: var(--brand-a); }
.brand-b { color: var(--brand-b); }

.shell { flex: 1; display: flex; min-height: 0; }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: 250px; flex: none; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 12px;
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 16px;
  border: 0; background: transparent; border-radius: 10px; cursor: pointer;
  font-size: 16px; text-align: left; color: var(--text);
}
.nav-item svg { width: 24px; height: 24px; color: var(--label); }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--blue); color: #fff; font-weight: 600; }
.nav-item.active svg { color: #fff; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.conn {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); flex: none; }
.ver { color: var(--muted); font-size: 12.5px; padding-left: 6px; }

/* ── Work area grid ─────────────────────────────────────── */
.work {
  flex: 1; min-width: 0; min-height: 0; padding: 18px; overflow: auto;
  display: grid; gap: 16px;
  /* the crop editor gets the whole right side (as tall as upload + files) */
  grid-template-columns: minmax(640px, 1.25fr) minmax(440px, 1fr);
  grid-template-rows: auto minmax(360px, 1fr) auto;
  grid-template-areas: "upload crop" "files crop" "settings save";
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 19px; margin: 0; font-weight: 700; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin-right: auto; }

/* upload */
.upload {
  grid-area: upload; border: 2px dashed var(--line-2); box-shadow: none; background: var(--soft-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 12px 16px; text-align: center; gap: 4px; transition: background .15s, border-color .15s;
}
.upload.hover { border-color: var(--blue); background: var(--blue-soft); }
.up-cloud { width: 46px; height: 46px; color: var(--blue); }
.upload h2 { font-size: 19px; }
.upload p { margin: 0; color: var(--muted); }
.upload .btn { min-width: 190px; justify-content: center; margin: 4px 0; }
.up-note { font-size: 13px; }

/* how it works */
.how { display: none; grid-area: how; padding: 14px 16px; background: var(--blue-soft); border-color: var(--line); }
.steps { list-style: none; margin: 12px 0 0; padding: 0; display: flex; align-items: flex-start; justify-content: space-between; }
.steps li { display: flex; flex-direction: column; align-items: center; text-align: center; font-size: 13px; min-width: 88px; position: relative; }
.steps li b { margin-top: 6px; font-size: 14.5px; }
.steps li span:last-child { color: var(--label); }
.step-arrow { min-width: 0 !important; padding-top: 28px; font-size: 22px; color: var(--label); }
.step-n { position: absolute; left: 0; top: -4px; width: 28px; height: 28px; border-radius: 50%; color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.n1 { background: var(--green); } .n2 { background: var(--blue); } .n3 { background: #6d3fd8; }
.step-i { width: 38px; height: 38px; color: #0f9d8a; }
.steps li:nth-child(3) .step-i { color: var(--blue); }
.step-pdf { color: #6d3fd8 !important; }

/* ── Files table ────────────────────────────────────────── */
.files { grid-area: files; display: flex; flex-direction: column; min-height: 0; }
.head-actions { display: flex; gap: 8px; }
.status-line { padding: 8px 16px 0; color: var(--muted); font-size: 12.5px; min-height: 26px; }
.table-wrap { flex: 1; overflow: auto; min-height: 0; position: relative; }
.ftable { width: 100%; border-collapse: collapse; }
.ftable th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-size: 13px;
  font-weight: 700; padding: 9px 6px; border-bottom: 1px solid var(--line);
}
.ftable td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ftable tr { cursor: pointer; }
.ftable tbody tr:hover { background: var(--soft-bg); }
.ftable tr.sel { background: var(--blue-soft); }
.ftable tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
.c-chk { width: 36px; text-align: center !important; }
.c-num { width: 26px; }
.c-name { min-width: 96px; }
.c-prev, .c-back { width: 90px; }
.c-stat { width: 96px; }
.c-adj { width: 150px; }
.adj { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.adj + .adj { margin-top: 4px; }
.adj-g { width: 14px; text-align: center; font-size: 14px; color: var(--muted); }
.adj input[type=range] { width: 64px; accent-color: var(--blue); cursor: pointer; }
.adj-v { width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.c-act { width: 118px; }
.ftable input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--blue); cursor: pointer; }
.fname { font-size: 13.5px; word-break: break-all; line-height: 1.3; }
.doc-sel {
  margin-top: 6px; width: 100%; min-width: 150px; max-width: 240px; font: inherit; font-size: 12px; padding: 4px 6px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--label); cursor: pointer;
}
.doc-sel:focus { outline: 2px solid var(--blue-line); outline-offset: 1px; }
.fnote { font-size: 11.5px; color: var(--orange); margin-top: 3px; }
.fnote.err { color: var(--red); }

.thumb {
  width: 80px; height: 54px; border-radius: 6px; border: 1px solid var(--line); background: var(--well);
  display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; padding: 0;
}
.thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.thumb img.rot-90 { transform: rotate(90deg); max-width: 54px; max-height: 80px; }
.thumb img.rot-180 { transform: rotate(180deg); }
.thumb img.rot-270 { transform: rotate(270deg); max-width: 54px; max-height: 80px; }
button.thumb { cursor: pointer; }
button.thumb:hover { border-color: var(--blue); }
.thumb.working img { opacity: .4; }
.thumb-spin, .spinner {
  position: absolute; width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, .12); border-top-color: var(--blue); animation: spin .9s linear infinite;
}
.spinner { position: static; width: 36px; height: 36px; border-width: 4px; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.add-back {
  width: 80px; height: 54px; border: 1px solid var(--blue-line); background: var(--blue-soft); color: var(--blue);
  border-radius: 8px; cursor: pointer; font-size: 12px; line-height: 1.25; font-weight: 600; padding: 0 2px;
}
.add-back:hover, .add-back.drop-hover { background: var(--blue-soft); border-color: var(--blue); }

.pill { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.p-new { background: var(--orange-soft); color: var(--orange); }
.p-work { background: var(--blue-soft); color: var(--blue); }
.p-ok { background: var(--green-soft); color: var(--green); }
.p-warn { background: var(--red-soft); color: var(--red); }
.p-err { background: var(--red-soft); color: var(--red); }

.act { display: flex; align-items: center; gap: 4px; }
.btn-fix {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 10px; min-width: 74px; justify-content: center;
  border: 1px solid var(--blue-line); background: var(--surface); color: var(--blue); border-radius: 8px; font-weight: 700; cursor: pointer;
  white-space: nowrap;
}
.btn-fix svg { width: 16px; height: 16px; }
.btn-fix:hover:not(:disabled) { background: var(--blue-soft); }
.btn-fix.done { border-color: #b6e0c3; color: var(--green); background: var(--green-soft); }
.btn-fix:disabled { cursor: default; opacity: .75; }
.btn-dots { width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.btn-dots:hover { background: var(--well); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 9px;
  padding: 9px 16px; font-weight: 600; cursor: pointer; white-space: nowrap; line-height: 1.2;
}
.btn svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover:not(:disabled) { background: var(--blue-d); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover:not(:disabled) { background: var(--green-d); }
.btn-green.stop { background: #7c2d12; }
.btn-danger-outline { background: var(--surface); color: var(--red); border-color: #f1a8a8; }
.btn-danger-outline:hover:not(:disabled) { background: var(--red-soft); }
.btn-outline { background: var(--surface); border-color: var(--line-2); }
.btn-outline:hover:not(:disabled) { border-color: #6b7280; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--well); color: var(--text); }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid rgba(29, 111, 232, .35); outline-offset: 2px;
}

/* ── Crop & Adjust ──────────────────────────────────────── */
.crop { grid-area: crop; display: flex; flex-direction: column; min-height: 0; }
.side-tabs { display: flex; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.tab { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.tab.active { background: var(--surface); color: var(--blue); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.pager { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.btn-page { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-size: 20px; line-height: 1; }
.btn-page:disabled { opacity: .4; cursor: default; }
.crop-body { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 12px; }
.crop-stage { flex: 1; min-width: 0; position: relative; background: #2c2f36; border-radius: 10px; overflow: hidden; }
.crop-stage.crop-bad { box-shadow: inset 0 0 0 2px var(--red); }
.crop-canvas { position: absolute; inset: 0; touch-action: none; }
.crop-loupe {
  position: absolute; left: 0; top: 0; display: none; pointer-events: none; z-index: 2;
  border-radius: 50%; border: 3px solid #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .55);
}
.crop-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #aab3c0; padding: 16px; text-align: center; }
.crop-tools { width: 92px; display: flex; flex-direction: column; gap: 6px; flex: none; overflow-y: auto; }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; flex: none;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; cursor: pointer; font-size: 12.5px; color: var(--label);
}
.tool svg { width: 22px; height: 22px; }
.tool:hover:not(:disabled) { border-color: var(--blue-line); background: var(--blue-soft); }
.tool.primary { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue-d); }
.tool:disabled { opacity: .45; cursor: default; }
.crop-foot { display: flex; align-items: center; gap: 8px; padding: 0 12px 12px; }
.crop-msg { margin-right: auto; font-size: 12px; color: var(--muted); flex: 1; min-width: 0; line-height: 1.3; }
.crop-msg.bad { color: var(--red); font-weight: 600; }
#btnApply.pending { box-shadow: 0 0 0 3px rgba(29, 111, 232, .3); }

/* expanded crop view */
.crop.expanded { position: fixed; inset: 12px; z-index: 90; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
body.crop-open::after { content: ""; position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 89; }

/* ── Output settings / save ─────────────────────────────── */
.settings { grid-area: settings; padding: 14px 18px; }
.settings h2 { font-size: 16px; margin-bottom: 10px; }
.set-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.set { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; }
.set svg { grid-row: 1 / 3; width: 22px; height: 22px; color: var(--muted); }
.set-t { font-size: 12.5px; color: var(--muted); }
.set select { height: 32px; min-width: 92px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); }
.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--blue); }
.save-wrap { grid-area: save; display: flex; gap: 12px; }
.save-big.save-print { flex: 0 0 34%; background: var(--blue); box-shadow: 0 8px 20px color-mix(in srgb, var(--blue) 25%, transparent); }
.save-big.save-print:disabled { background: color-mix(in srgb, var(--blue) 45%, #fff); box-shadow: none; cursor: not-allowed; }
.save-big {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 18px; min-height: 88px;
  border: 0; border-radius: var(--radius); background: var(--green); color: #fff; cursor: pointer;
  box-shadow: 0 8px 20px rgba(22, 163, 74, .25);
}
.save-big:hover:not(:disabled) { background: var(--green-d); }
.save-big:disabled { background: #7fbf95; box-shadow: none; cursor: not-allowed; }
.save-big svg { width: 46px; height: 46px; }
.save-t { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.save-t b { font-size: 21px; }
.save-t span { font-size: 14.5px; opacity: .95; }

/* ── PDF Tools view ─────────────────────────────────────── */
.work-pdf {
  flex: 1; min-width: 0; min-height: 0; padding: 18px; overflow: auto;
  display: grid; gap: 16px; grid-template-rows: auto minmax(260px, 1fr) auto;
}
.work-pdf .upload { min-height: 170px; grid-area: auto; }
.pfiles { display: flex; flex-direction: column; min-height: 0; }
.head-note { color: var(--muted); font-size: 12.5px; margin-right: 8px; }
.plist-wrap { flex: 1; overflow: auto; min-height: 0; }
.plist { list-style: none; margin: 0; padding: 4px 8px 8px; }
.prow {
  display: grid; grid-template-columns: 28px 64px minmax(0, 1fr) auto auto; gap: 12px; align-items: center;
  padding: 8px; border-bottom: 1px solid var(--line);
}
.prow-n { color: var(--muted); text-align: center; font-weight: 600; }
.prow-thumb {
  width: 64px; height: 64px; border: 1px solid var(--line); border-radius: 6px; background: var(--well);
  display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative;
}
.prow-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; }
.prow-ext { font-size: 11px; font-weight: 700; color: var(--muted); }
.prow-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.prow-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow-detail { font-size: 12.5px; color: var(--muted); }
.prow-detail.err { color: var(--red); }
.prow-error { background: var(--red-soft); }
.prow-act { display: flex; gap: 4px; }
.btn-icon {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-size: 15px;
}
.btn-icon:hover:not(:disabled) { border-color: #6b7280; }
.btn-icon.danger:hover:not(:disabled) { color: var(--red); border-color: var(--red); }
.btn-icon:disabled { opacity: .35; cursor: default; }
.pdf-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.save-blue { background: var(--blue); box-shadow: 0 8px 20px rgba(29, 111, 232, .25); }
.save-blue:hover:not(:disabled) { background: var(--blue-d); }
.save-blue:disabled { background: #8fb3ee; }
.compress-card { display: flex; flex-direction: column; gap: 8px; }
.compress-card .save-big { min-height: 72px; }
.target { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--label); }
.target input { width: 110px; height: 34px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 8px; font-weight: 700; }

/* ── Resume Maker view ──────────────────────────────────── */
.work-resume {
  flex: 1; min-width: 0; min-height: 0; padding: 18px; overflow: hidden;
  display: grid; gap: 16px; grid-template-columns: minmax(520px, 1fr) minmax(420px, 0.95fr);
}
.rform, .rprev { display: flex; flex-direction: column; min-height: 0; }
.rform-scroll { flex: 1; overflow: auto; padding: 4px 16px 20px; }
.rsec { padding: 14px 0 16px; border-bottom: 1px solid var(--line); }
.rsec:last-child { border-bottom: 0; }
.rsec h3 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 10px; }
.rn { width: 24px; height: 24px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 12.5px;
      display: inline-flex; align-items: center; justify-content: center; flex: none; }
.rgrid { display: grid; gap: 10px 12px; margin-bottom: 10px; }
.g1 { grid-template-columns: 1fr; } .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.rf { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-width: 0; }
.rgrid .rf { margin-bottom: 0; }
.rf > span { font-size: 12px; font-weight: 600; color: var(--label); }
.rf input, .rf select, .rf textarea, .list-row input {
  height: 36px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; background: var(--surface); min-width: 0; width: 100%;
}
.rf textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.rf input:focus, .rf select:focus, .rf textarea:focus, .list-row input:focus { border-color: var(--blue); outline: 2px solid rgba(29, 111, 232, .2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); background: var(--surface); border-radius: 99px; padding: 5px 11px; cursor: pointer; font-size: 12.5px; }
.chip:hover { border-color: var(--blue); }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.edu-cols { display: grid; grid-template-columns: 1fr; gap: 10px; }
.edu-block { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--soft-bg); margin-bottom: 10px; }
.edu-title { font-weight: 700; font-size: 13px; margin-bottom: 8px; color: var(--text); }
.add-btn { border: 1px dashed var(--blue-line); background: var(--blue-soft); color: var(--blue); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 600; }
.add-btn:hover { background: var(--blue-soft); }
.list-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.extra-row input:nth-child(1) { flex: 2.2; } .extra-row input:nth-child(2) { flex: 2; }
.extra-row input:nth-child(3), .extra-row input:nth-child(4), .extra-row input:nth-child(5) { flex: .8; }
.list-row .num { width: 20px; font-weight: 700; color: var(--blue); flex: none; }
.list-row .rm { width: 30px; height: 30px; border-radius: 7px; border: 0; background: var(--red-soft); color: var(--red); cursor: pointer; flex: none; }
.exp-line { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; line-height: 1.45; }
.photo-row { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 12px; }
.photo-box { width: 105px; height: 135px; border: 1px dashed var(--line-2); border-radius: 8px; background: var(--well);
             display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none; font-size: 12px; }
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-act { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.photo-act p { flex-basis: 100%; margin: 2px 0 0; }
.tpl-strip { display: flex; gap: 10px; padding: 10px 14px; overflow-x: auto; border-bottom: 1px solid var(--line); flex: none; }
.tpl-thumb { flex: none; border: 2px solid var(--line); border-radius: 8px; background: var(--surface); padding: 4px; cursor: pointer;
             display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tpl-thumb:hover { border-color: var(--blue-line); }
.tpl-thumb.sel { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 111, 232, .18); }
.tpl-mini { width: 76px; height: 107.5px; overflow: hidden; position: relative; border: 1px solid var(--line); }
.tpl-lbl { font-size: 11px; font-weight: 600; color: var(--label); max-width: 84px; text-align: center; line-height: 1.2; }
.paper-wrap { flex: 1; min-height: 0; overflow: auto; background: var(--well); display: flex; justify-content: center; align-items: flex-start; padding: 12px; }
.paper { width: 210mm; height: 297mm; flex: none; transform-origin: top left; box-shadow: 0 6px 24px rgba(15, 23, 42, .18); background: #fff; }
.rprev-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.rprev-foot .muted { margin-right: auto; }
#rFitNote.bad { color: var(--red); font-weight: 600; }
.photo-card { background: var(--surface); border-radius: 16px; width: min(1000px, 96vw); height: min(760px, 92vh); display: flex; flex-direction: column;
              box-shadow: 0 20px 60px rgba(0, 0, 0, .35); overflow: hidden; }
.photo-card .crop-body { padding: 12px; }
.ph-foot { display: flex; align-items: center; gap: 14px; padding: 10px 14px 14px; flex-wrap: wrap; }
.ph-foot .crop-msg { flex: 1; }

/* ── Photo Print view ───────────────────────────────────── */
.work-photo {
  flex: 1; min-width: 0; min-height: 0; padding: 18px; overflow: hidden;
  display: grid; gap: 16px; grid-template-columns: 320px minmax(360px, 1fr) minmax(330px, 400px);
}
.ptools, .pcrop, .presult { display: flex; flex-direction: column; min-height: 0; }
.ptools-scroll { flex: 1; overflow: auto; padding: 12px 14px 16px; }
.mini-up { min-height: 0; padding: 12px; gap: 6px; }
.mini-up .up-cloud { width: 34px; height: 34px; }
.mini-up b { font-size: 14px; }
.pgroup { border-top: 1px solid var(--line); padding: 12px 0 6px; margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.pg-t { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge-ai { font-size: 11px; font-weight: 600; color: var(--green); background: var(--green-soft); border-radius: 99px; padding: 2px 8px; }
.count-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cnt { border: 1.5px solid var(--line-2); background: var(--surface); border-radius: 10px; padding: 7px 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.cnt b { font-size: 17px; } .cnt span { font-size: 10px; color: var(--muted); }
.cnt.sel { border-color: var(--blue); background: var(--blue-soft); }
.bg-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-left: 26px; }
.bg-row.off { opacity: .5; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-2); cursor: pointer; padding: 0; }
.sw.sel { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 111, 232, .25); }
.sw[data-bg="#ffffff"] { background: #ffffff; } .sw[data-bg="#f3f3f0"] { background: #f3f3f0; }
.sw[data-bg="#d9e9f9"] { background: #d9e9f9; } .sw[data-bg="#8cc4f0"] { background: #8cc4f0; } .sw[data-bg="#c62828"] { background: #c62828; }
.sw-clear { background: repeating-conic-gradient(#cfd4dc 0 25%, #fff 0 50%) 50% / 10px 10px; }
.sw-custom { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; border: 2px dashed var(--line-2); display: inline-flex; }
.sw-custom input { width: 40px; height: 40px; margin: -6px; border: 0; padding: 0; cursor: pointer; }
.small-rf { margin: 0; } .small-rf select { height: 32px; }
.small-btn { padding: 5px 10px; font-size: 12.5px; align-self: flex-start; }
.straight, .adj2 { display: grid; grid-template-columns: 82px 1fr 38px auto; align-items: center; gap: 8px; font-size: 12.5px; }
.adj2 { grid-template-columns: 82px 1fr 34px; }
.adj2 input, .straight input { width: 100%; accent-color: var(--blue); }
.adj2-l { color: var(--label); font-weight: 600; } .adj2-v { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.blur-line { font-size: 12.5px; font-weight: 600; min-height: 16px; }
.blur-line.sharp { color: var(--green); } .blur-line.soft { color: var(--orange); } .blur-line.blurry { color: var(--red); }
.res-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 14px; background: var(--well); }
.res-photo { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.res-photo canvas { width: 140px; height: auto; box-shadow: 0 2px 10px rgba(0, 0, 0, .15); background: #fff; }
.res-sheet canvas { max-width: 100%; max-height: 380px; width: auto; height: auto; box-shadow: 0 4px 18px rgba(0, 0, 0, .18); background: #fff; }
.res-foot { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.wheel-box { padding-left: 26px; }
.cw { display: flex; gap: 12px; align-items: center; }
.cw-wheel { width: 120px; height: 120px; cursor: crosshair; touch-action: none; border-radius: 50%; }
.cw-side { display: flex; flex-direction: column; gap: 6px; }
.cw-swatch { width: 44px; height: 30px; border-radius: 6px; border: 1px solid var(--line-2); }
.cw-hex { width: 84px; height: 30px; border: 1px solid var(--line-2); border-radius: 6px; padding: 0 6px; font-family: Consolas, monospace; }
.cw-rgb { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cw-val { width: 100%; margin-top: 6px; accent-color: var(--blue); }
.out-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; }
.out-t { font-weight: 700; font-size: 12.5px; color: var(--label); }
.copies { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.copies input { width: 56px; height: 32px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 6px; font-weight: 700; }

/* ── Mini Print view ────────────────────────────────────── */
.work-mini {
  flex: 1; min-width: 0; min-height: 0; padding: 18px; overflow: hidden;
  display: grid; gap: 16px; grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
}
.mini-left, .mini-right { display: flex; flex-direction: column; min-height: 0; }
.mini-left .upload { margin: 12px; }
.mini-opts { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.mini-grid2 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.mopt { border: 1.5px solid var(--line-2); background: var(--surface); border-radius: 10px; padding: 7px 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.mopt b { font-size: 18px; } .mopt span { font-size: 10.5px; color: var(--muted); }
.mopt.sel { border-color: #6d3fd8; background: #f6f2ff; } .mopt.sel b { color: #6d3fd8; }
.mini-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; }
.seg-b { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg-b.sel { background: var(--surface); color: var(--blue); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.mini-prev { flex: 1; min-height: 0; overflow: auto; background: var(--well); display: flex; justify-content: center; align-items: flex-start; padding: 14px; }
.mini-prev canvas { max-width: 100%; max-height: 100%; width: auto; height: auto; box-shadow: 0 4px 18px rgba(0, 0, 0, .18); background: #fff; }
.res-foot .pager { margin-right: auto; }

/* ── Row menu ───────────────────────────────────────────── */
.menu {
  position: fixed; z-index: 100; min-width: 210px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(15, 23, 42, .18); padding: 6px;
}
.menu button {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px;
  border: 0; background: transparent; padding: 8px 10px; border-radius: 7px; cursor: pointer; text-align: left;
}
.menu button:hover:not(:disabled), .menu button:focus-visible { background: var(--surface-2); outline: none; }
.menu button:disabled { opacity: .4; cursor: default; }
.menu button.danger { color: var(--red); }
.menu .sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu .lbl { font-size: 11.5px; color: var(--muted); padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: .4px; }
.menu .tick { color: var(--blue); font-weight: 700; }

/* ── Overlays ───────────────────────────────────────────── */
.drag-veil {
  position: fixed; inset: 0; z-index: 110; display: none; pointer-events: none;
  background: rgba(29, 111, 232, .08); border: 4px dashed var(--blue); align-items: center; justify-content: center;
}
.drag-veil.on { display: flex; }
.drag-veil div { background: var(--blue); color: #fff; font-weight: 700; font-size: 18px; padding: 14px 26px; border-radius: 12px; }
.modal, .progress {
  position: fixed; inset: 0; z-index: 120; background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card, .progress-card {
  background: var(--surface); border-radius: 16px; padding: 24px; max-width: 480px; width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3); text-align: center;
}
.modal-card h2 { margin: 0 0 8px; font-size: 20px; }
.modal-card p { color: var(--muted); margin: 0 0 18px; word-break: break-word; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.progress-card { max-width: 340px; font-weight: 600; }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 130;
  background: #111827; color: #fff; padding: 11px 18px; border-radius: 10px; font-weight: 600;
  max-width: min(640px, calc(100vw - 32px)); box-shadow: var(--shadow);
}

@media (max-width: 1600px) {
  .sidebar { width: 208px; }
  .nav-item { font-size: 14.5px; padding: 10px 12px; }
  .brand-name { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { .thumb-spin, .spinner { animation: none; } }
#pdfTargetLbl { font-size: inherit; opacity: 1; }


/* Photo result: Print and Download as two full-width rows */
.presult .res-foot { flex-direction: column; align-items: stretch; }
.presult .out-opt { justify-content: flex-end; flex-wrap: wrap; }
.presult .out-t { margin-right: auto; }
/* Mini Print list rows have no thumbnail column */
.prow.nothumb { grid-template-columns: 28px minmax(0, 1fr) auto auto; }

/* 4 / 8 / 16 point crop switch (top-left of every crop stage) */
.pts-mode { position: absolute; left: 8px; top: 8px; z-index: 3; display: flex; background: rgba(15, 23, 42, .72); border-radius: 8px; padding: 3px; gap: 2px; }
.pts-b { border: 0; background: transparent; color: #cbd5e1; padding: 4px 9px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 700; }
.pts-b.sel { background: var(--blue); color: #fff; }
.crop-editb {
  position: absolute; right: 8px; top: 8px; z-index: 3; border: 0; border-radius: 8px; cursor: pointer;
  background: rgba(15, 23, 42, .78); color: #fff; font-size: 12.5px; font-weight: 700; padding: 6px 12px;
}
.crop-editb:hover { background: var(--blue); }
.crop-result canvas.crop-canvas { cursor: default; }

/* ── ID Card Tools view ─────────────────────────────────── */
.work-idc {
  flex: 1; min-width: 0; min-height: 0; padding: 18px; overflow: hidden;
  display: grid; gap: 16px; grid-template-columns: minmax(280px, 330px) minmax(380px, 1fr) minmax(320px, 390px);
}
.idc-left { display: flex; flex-direction: column; min-height: 0; }
.idc-left .upload { margin: 12px; }
.idc-left .prow { grid-template-columns: 24px 76px minmax(0, 1fr) auto; gap: 10px; cursor: pointer; border-radius: 8px; }
.idc-left .prow.cur { background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--blue); }
.idc-left .prow-thumb { width: 76px; height: 52px; }
.idc-prev { max-width: 100%; max-height: 300px; width: auto; height: auto; box-shadow: 0 4px 18px rgba(0, 0, 0, .18); background: var(--surface); }
.idc-opts { padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; border-top: 1px solid var(--line); }
.idc-custom { display: flex; align-items: center; gap: 6px; }
.idc-custom input { width: 84px; height: 32px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 8px; font-weight: 700; }
.work-idc .crop-foot .pager { display: flex; align-items: center; gap: 8px; }
.work-idc .res-foot .btn { flex: 1 1 auto; }
.idc-left .prow-name, .idc-left .prow-detail { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#idcCropTitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ── QR Generator view ──────────────────────────────────── */
.work-qr {
  flex: 1; min-width: 0; min-height: 0; padding: 18px; overflow: hidden;
  display: grid; gap: 16px; grid-template-columns: minmax(340px, 440px) minmax(360px, 1fr);
}
.qr-left, .qr-right { display: flex; flex-direction: column; min-height: 0; }
.qr-scroll { flex: 1; overflow: auto; padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.qr-tabs { align-self: stretch; } .qr-tabs .seg-b { flex: 1; }
.qr-pane textarea, .qr-pane input, .qr-sel {
  width: 100%; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font: inherit; background: var(--surface);
}
.qr-pane textarea { resize: vertical; min-height: 120px; }
.qr-pane textarea:focus, .qr-pane input:focus, .qr-sel:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.qr-note { font-size: 12.5px; color: var(--muted); margin: 8px 2px 0; line-height: 1.45; }
.qr-count { font-size: 12px; color: var(--muted); text-align: right; min-height: 15px; }
.qr-count.err { color: var(--red); font-weight: 600; text-align: left; }
.qr-sizes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.qr-custom { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.qr-custom input { width: 70px; height: 32px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 6px; font-weight: 700; }
.qr-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--well); position: relative; padding: 18px; }
.qr-stage canvas { max-width: 100%; max-height: 100%; image-rendering: pixelated; box-shadow: 0 4px 18px rgba(0, 0, 0, .15); background: #fff; }
.qr-stage canvas.off { visibility: hidden; }
.qr-empty { position: absolute; color: var(--muted); font-size: 14px; }
.qr-right .res-foot { justify-content: space-between; }

/* ── PDF Editor view ────────────────────────────────────── */
.work-pe { flex: 1; min-width: 0; min-height: 0; padding: 18px; overflow: hidden; display: flex; }
.pe-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.pe-top { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pe-name { font-weight: 700; flex: 1; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 92px minmax(0, 1fr) 270px; }
.pe-rail { display: flex; flex-direction: column; gap: 4px; padding: 10px 8px; border-right: 1px solid var(--line); overflow: auto; }
.pe-tool { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 1.5px solid transparent; border-radius: 10px;
  background: transparent; cursor: pointer; font-size: 11.5px; font-weight: 600; color: var(--label); }
.pe-tool b { font-size: 18px; line-height: 1.1; }
.pe-tool:hover { background: var(--surface-2); }
.pe-tool.sel { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.pe-stage { overflow: auto; background: var(--well); position: relative; padding: 18px; display: flex; justify-content: center; align-items: flex-start; }
.pe-drop { margin: auto; width: min(460px, 90%); }
.pe-page { position: relative; box-shadow: 0 4px 20px rgba(0, 0, 0, .18); background: #fff; flex: none; }
.pe-page canvas { display: block; }
.pe-layer { position: absolute; inset: 0; }
.pe-layer.t-edit .pe-line { cursor: text; }
.pe-layer.t-text, .pe-layer.t-image { cursor: copy; }
.pe-layer.t-draw, .pe-layer.t-highlight, .pe-layer.t-cover, .pe-layer.t-box, .pe-layer.t-edit { cursor: crosshair; }
.pe-line { position: absolute; border-radius: 2px; }
.pe-layer.t-edit .pe-line:hover { outline: 1.5px solid rgba(29, 111, 232, .75); background: rgba(29, 111, 232, .07); }
.pe-layer.t-edit .pe-line.no:hover { outline-color: rgba(220, 38, 38, .6); background: rgba(220, 38, 38, .05); }
.pe-layer:not(.t-edit) .pe-line { pointer-events: none; }
.pe-edit { position: absolute; white-space: pre; outline: 2px solid var(--blue); outline-offset: 1px; line-height: 1; padding: 0; margin: 0; min-width: 8px;
  z-index: 5; cursor: text; }
.pe-obj { position: absolute; box-sizing: border-box; }
.pe-obj.sel { outline: 1.5px dashed var(--blue); outline-offset: 2px; }
.pe-obj .pe-h { position: absolute; right: -7px; bottom: -7px; width: 12px; height: 12px; border-radius: 3px; background: var(--blue); border: 2px solid #fff; cursor: nwse-resize; display: none; }
.pe-obj.sel .pe-h { display: block; }
.pe-layer.t-select .pe-obj { cursor: move; }
.pe-obj-text { white-space: pre; line-height: 1.2; }
.pe-obj img, .pe-obj svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.pe-rubber { position: absolute; border: 1.5px dashed var(--blue); background: rgba(29, 111, 232, .08); pointer-events: none; }
.pe-props { border-left: 1px solid var(--line); padding: 14px; overflow: auto; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.pe-props h3 { margin: 0; font-size: 14px; }
.pe-props label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; color: var(--label); }
.pe-props input[type="number"], .pe-props select, .pe-props textarea { border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 8px; font: inherit; }
.pe-props textarea { min-height: 70px; resize: vertical; }
.pe-props input[type="color"] { width: 48px; height: 30px; border: 1px solid var(--line-2); border-radius: 6px; padding: 2px; }
.pe-props .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pe-props .note { color: var(--muted); font-weight: 400; line-height: 1.45; }
.pe-hint { padding: 8px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; min-height: 18px; }
.pe-props label.chk { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }

/* ── Photo Print: frame / transform tool ────────────────── */
.pc-mode { margin-left: auto; }
.pf-stage { outline: none; }
.pf-canvas { display: block; touch-action: none; outline: none; }
.pf-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--blue); }
.pf-foot { gap: 18px; flex-wrap: wrap; }
.pf-sl { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 180px; font-size: 12.5px; font-weight: 600; color: var(--label); }
.pf-sl input { flex: 1; accent-color: var(--blue); }
.pf-sl b { min-width: 44px; text-align: right; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.pf-hint { padding: 0 12px 12px; font-size: 12px; color: var(--muted); }

/* ── Print tool ─────────────────────────────────────────── */
.work-print { flex: 1; min-width: 0; min-height: 0; padding: 18px; display: flex; }
.pr-home { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.pr-drop { width: min(640px, 100%); min-height: 320px; gap: 10px; text-align: center; }
.pr-drop .up-cloud { width: 54px; height: 54px; color: var(--blue); }
.pr-drop b { font-size: 20px; }
.pr-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.pr-dlg { width: min(1280px, 100%); height: min(860px, 100%); background: var(--surface); border-radius: 14px; overflow: hidden; display: grid;
  grid-template-columns: minmax(0, 1fr) 360px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.pr-preview { background: var(--well); overflow: auto; padding: 22px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.pr-sheet { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pr-sheet canvas { background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); max-width: 100%; height: auto; }
.pr-sheet span { font-size: 12px; color: var(--muted); }
.pr-side { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); }
.pr-head { padding: 18px 20px 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.pr-head h2 { margin: 0; font-size: 22px; }
.pr-rows { flex: 1; overflow: auto; padding: 4px 20px 12px; display: flex; flex-direction: column; gap: 12px; }
.pr-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 10px; font-size: 13.5px; }
.pr-row > span:first-child { color: var(--label); font-weight: 600; }
.pr-row select, .pr-row input[type="number"], .pr-row input:not([type]) { height: 34px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 8px; font: inherit; background: var(--surface); min-width: 0; width: 100%; }
.pr-row input.bad { border-color: var(--red); box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15); }
.pr-copies { display: flex; align-items: center; gap: 10px; }
.pr-copies input[type="number"] { width: 72px; }
.pr-more summary { cursor: pointer; font-weight: 600; color: var(--blue); padding: 4px 0; }
.pr-more[open] summary { margin-bottom: 10px; }
.pr-more .pr-row { margin-bottom: 12px; }
.pr-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }

/* ── Themes (Settings) ──────────────────────────────────── */
:root[data-accent="green"]  { --blue: #16a34a; }
:root[data-accent="purple"] { --blue: #7c3aed; }
:root[data-accent="orange"] { --blue: #ea580c; }
:root[data-accent="rose"]   { --blue: #e11d48; }
:root[data-accent="teal"]   { --blue: #0d9488; }
:root[data-accent="pink"]   { --blue: #db2777; }
:root[data-accent="indigo"] { --blue: #4f46e5; }
:root[data-mode="dark"] {
  --bg: #0e131b; --card: #161d28; --surface: #161d28; --surface-2: #222b38; --well: #0b1017; --soft-bg: #121925;
  --line: #273140; --line-2: #384456; --text: #e7ecf3; --muted: #9ba7b9; --label: #cad3df;
  --blue-soft: color-mix(in srgb, var(--blue) 24%, #161d28);
  --blue-line: color-mix(in srgb, var(--blue) 55%, #161d28);
  --green-soft: #12301f; --red-soft: #3b1a1d; --orange-soft: #3a2a12;
  --brand-b: #f3f4f6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
:root[data-mode="dark"] .pr-modal, :root[data-mode="dark"] .modal { background: rgba(0, 0, 0, 0.6); }
:root[data-mode="dark"] .toast { background: #f3f4f6; color: #111827; }

/* ── Home ───────────────────────────────────────────────── */
.work-home { flex: 1; min-width: 0; min-height: 0; overflow: auto; padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.home-hero { display: flex; align-items: center; gap: 26px; padding: 26px 30px;
  background: linear-gradient(120deg, var(--blue-soft), var(--surface) 70%); }
.home-logo { width: 104px; height: 104px; object-fit: contain; flex: none; }
.home-hi h1 { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -0.3px; }
.home-hi h1 .brand-a { color: var(--brand-a); } .home-hi h1 .brand-b { color: var(--brand-b); }
.home-sub { margin: 6px 0 0; font-size: 18px; color: var(--label); font-weight: 600; }
.home-by { margin: 10px 0 0; font-size: 15px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.home-by b { color: var(--text); }
.heart { width: 20px; height: 20px; color: #e11d48; animation: beat 1.4s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.22); } 30% { transform: scale(1); } 45% { transform: scale(1.14); } }
@media (prefers-reduced-motion: reduce) { .heart { animation: none; } }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.home-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.home-tile:hover, .home-tile:focus-visible { border-color: var(--blue); transform: translateY(-2px); outline: none; }
.ht-ic { width: 42px; height: 42px; border-radius: 11px; background: var(--blue-soft); color: var(--blue); display: flex; align-items: center; justify-content: center; }
.ht-ic svg { width: 24px; height: 24px; }
.home-tile b { font-size: 15.5px; }
.ht-d { font-size: 12.5px; color: var(--muted); }
.info-list { margin: 0; padding: 8px 18px 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 24px; }
.info-list div { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.info-list dt { width: 90px; flex: none; color: var(--muted); font-weight: 600; }
.info-list dd { margin: 0; display: flex; align-items: center; gap: 6px; }
.ok-ic { width: 18px; height: 18px; color: var(--green); }

/* ── Settings ───────────────────────────────────────────── */
.work-settings { flex: 1; min-width: 0; min-height: 0; overflow: auto; padding: 22px; }
.set-card { max-width: 820px; }
.set-body { padding: 18px; display: flex; flex-direction: column; gap: 22px; }
.set-group { display: flex; flex-direction: column; gap: 10px; }
.mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 170px)); gap: 12px; }
.mode-b { border: 2px solid var(--line-2); border-radius: 12px; background: var(--surface); padding: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.mode-b.sel { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.mode-prev { height: 70px; border-radius: 8px; display: flex; gap: 6px; padding: 8px; }
.mode-prev i { display: block; border-radius: 4px; }
.mode-prev i:first-child { width: 28%; } .mode-prev i:last-child { flex: 1; }
.mode-prev.light { background: #f4f6fb; } .mode-prev.light i { background: #fff; border: 1px solid #e3e8f0; }
.mode-prev.dark { background: #0e131b; } .mode-prev.dark i { background: #161d28; border: 1px solid #273140; }
.mode-prev.auto { background: linear-gradient(90deg, #f4f6fb 50%, #0e131b 50%); } .mode-prev.auto i { background: linear-gradient(90deg, #fff 50%, #161d28 50%); }
.accent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.accent-b { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 2px solid var(--line-2); border-radius: 10px; background: var(--surface); cursor: pointer; font-weight: 600; }
.accent-b.sel { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.acc-dot { width: 20px; height: 20px; border-radius: 50%; flex: none; }

/* brightness / contrast under the crop editor (live in the editor) */
.crop-adj { display: flex; align-items: center; gap: 16px; padding: 0 12px 10px; flex-wrap: wrap; }
.crop-adj .adj2 { flex: 1; min-width: 200px; grid-template-columns: 104px 1fr 34px; white-space: nowrap; }

/* ══ PDFBuild web port ═══════════════════════════════════════════════
   The desktop app filled one fixed window; on the web the same screens
   have to work from a small laptop down to a phone. */
.titlebar { -webkit-app-region: no-drag; user-select: auto; padding-right: 20px; }
.back-home {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; min-height: 36px;
  border: 1px solid var(--line-2); border-radius: 99px; color: var(--label); text-decoration: none; font-weight: 600; font-size: 14px;
}
.back-home:hover { border-color: var(--blue); color: var(--blue); }
.back-home:focus-visible { outline: 3px solid rgba(29, 111, 232, .35); outline-offset: 2px; }

/* laptops: the per-row Adjust sliders duplicate the ones under the crop
   editor, so they give way before the Action column gets pushed out */
@media (max-width: 1500px) {
  .ftable .c-adj { display: none; }
  .work { grid-template-columns: minmax(0, 1.3fr) minmax(380px, 1fr); }
}

/* ── Phones and small tablets ─────────────────────────────────────────
   One column, the page scrolls (not each card), the menu becomes a
   sticky strip of tabs. Editors and previews get a fixed share of the
   screen height, because their canvases size themselves to the box. */
@media (max-width: 900px) {
  html, body { height: auto; }
  body { overflow: auto; min-height: 100%; }
  .titlebar { height: 56px; padding: 0 12px; gap: 8px; }
  .brand-logo { width: 38px; height: 38px; }
  .brand-name { font-size: 22px; }
  .back-home { padding: 6px 12px; font-size: 13px; }

  .shell { flex-direction: column; }
  .sidebar { width: auto; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
  .nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; gap: 4px; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { width: auto; flex: none; gap: 6px; padding: 8px 12px; min-height: 40px; font-size: 13.5px; white-space: nowrap; }
  .nav-item svg { width: 18px; height: 18px; }
  .side-foot { display: none; }

  .work, .work-pdf, .work-resume, .work-photo, .work-mini, .work-idc, .work-qr, .work-pe, .work-print, .work-home, .work-settings {
    flex: none; min-height: 0; padding: 10px; gap: 12px; overflow: visible;
  }
  .work, .work-resume, .work-photo, .work-mini, .work-idc, .work-qr {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-auto-rows: auto;
  }
  .work { grid-template-areas: "upload" "files" "crop" "settings" "save"; }
  .work-pdf { grid-template-rows: none; }

  /* inner scrollers give way to the page */
  .rform-scroll, .ptools-scroll, .qr-scroll, .plist-wrap, .res-body { flex: none; overflow: visible; }
  .table-wrap { flex: none; overflow-x: auto; }
  .files, .pfiles { min-height: 220px; }
  .plist-wrap { min-height: 90px; }

  /* crop editors: stage on top, tools as a row underneath */
  .crop-body { flex: none; flex-direction: column; }
  .crop-stage { flex: none; height: 60vh; min-height: 300px; }
  .crop-tools { width: auto; flex-direction: row; overflow-x: auto; }
  .tool { min-width: 76px; }
  .crop-foot { flex-wrap: wrap; }
  .crop.expanded { inset: 0; border-radius: 0; }

  /* previews */
  .paper-wrap { flex: none; height: 72vh; }
  .mini-prev { flex: none; height: 65vh; }
  .qr-stage { flex: none; height: 50vh; min-height: 260px; }
  .res-sheet canvas { max-height: none; }
  .rprev-foot { flex-wrap: wrap; }
  .rprev-foot .muted { flex-basis: 100%; }
  .rprev-foot .btn { flex: 1; justify-content: center; }

  /* form grids */
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-grid2 { grid-template-columns: repeat(4, 1fr); }
  .pdf-actions { grid-template-columns: 1fr; }
  .save-big { min-height: 72px; }
  .extra-row { flex-wrap: wrap; }
  .extra-row input { flex: 1 1 40% !important; }

  /* PDF editor: tools row, page, then properties */
  .pe-body { grid-template-columns: minmax(0, 1fr); }
  .pe-rail { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .pe-tool { flex: none; min-width: 66px; }
  .pe-stage { height: 65vh; }
  .pe-props { border-left: 0; border-top: 1px solid var(--line); }

  /* print dialog: preview above, settings below */
  .pr-modal { padding: 0; }
  .pr-dlg { height: 100%; border-radius: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: 38% minmax(0, 1fr); }
  .pr-preview { padding: 12px; }
  .pr-side { border-left: 0; border-top: 1px solid var(--line); }
  .pr-head { padding: 12px 16px 6px; }
  .pr-rows { padding: 4px 16px 12px; }
  .pr-row { grid-template-columns: 96px minmax(0, 1fr); }
  .pr-foot { padding: 10px 16px; }
  .pr-foot .btn { flex: 1; justify-content: center; }
  .pr-home { padding: 12px; }
  .pr-drop { min-height: 260px; }

  /* resume photo crop dialog */
  .modal { padding: 8px; }
  .photo-card { width: 100%; height: 100%; }
  .photo-card .crop-body { flex: 1; min-height: 0; }
  .photo-card .crop-stage { height: auto; flex: 1; min-height: 200px; }

  /* home / settings */
  .home-hero { gap: 14px; padding: 16px; }
  .home-logo { width: 60px; height: 60px; }
  .home-hi h1 { font-size: 26px; }
  .home-sub { font-size: 15px; }
  .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .mode-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .card-head, .head-actions { flex-wrap: wrap; }
  /* finger-sized targets */
  .pts-b { min-height: 32px; padding: 4px 12px; }
  .cw-hex { height: 36px; }
  .sw, .sw-custom { width: 36px; height: 36px; }
  .btn-icon { width: 38px; height: 38px; }
  .small-btn, .seg-b, .chip, .tab { min-height: 36px; }
  .btn-page { width: 38px; height: 38px; }
  .list-row .rm { width: 36px; height: 36px; }
  .doc-sel { min-height: 34px; }
  .crop-editb { min-height: 34px; }
  .pe-props input[type="color"] { height: 36px; }
}
