:root {
  --bg: #e9ecf1;
  --panel: #ffffff;
  --ink: #1b1f27;
  --muted: #6b7280;
  --line: #dde1e8;
  --accent: #c8372d;
  --accent-hover: #a92c24;
  --accent-soft: #fbe9e7;
  --danger: #c62828;
  --ok: #157a3e;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
body { display: flex; flex-direction: column; }
button, select, input { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ---- top bar ---- */
.topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--accent); margin-right: 8px; }
.brand .by { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: -2px; align-self: flex-end; padding-bottom: 3px; }
.tools-group { display: flex; align-items: center; gap: 4px; }
.sep { width: 1px; height: 26px; background: var(--line); margin: 0 6px; }
.sel-info { color: var(--muted); font-size: 13px; margin-left: 6px; white-space: nowrap; }
.spacer { flex: 1; }
.btn { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn svg { width: 18px; height: 18px; }
.btn:hover:not(:disabled) { background: #f4f6fa; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.big { height: 46px; padding: 0 22px; font-size: 16px; }
.btn.ghost { border-color: transparent; background: none; }
.btn.add { width: 100%; justify-content: center; border-style: dashed; color: var(--accent); }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid transparent; background: none; border-radius: 8px; cursor: pointer; color: inherit; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover:not(:disabled) { background: #f0f2f6; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger:hover:not(:disabled) { background: #fdecec; color: var(--danger); }
.select, .text-in { height: 36px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 0 8px; }
.select { cursor: pointer; }
.text-in { width: 130px; outline: none; }
.text-in.wide { width: 100%; margin-top: 6px; }
.select:focus, .text-in:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.pro-tag { font-size: 10px; font-weight: 700; letter-spacing: .05em; padding: 2px 6px; border-radius: 5px; background: var(--accent); color: #fff; vertical-align: 2px; margin-left: 4px; }

/* ---- main ---- */
main { flex: 1; min-height: 0; position: relative; }
.empty { height: 100%; overflow-y: auto; }
.empty > * { max-width: 920px; margin-left: auto; margin-right: auto; }
.empty { padding: 34px 24px 40px; }
.drop-zone { width: 100%; min-height: 230px; border: 2px dashed #c9b8b6; border-radius: 18px; background: var(--panel); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer; padding: 24px; }
.drop-zone:hover { border-color: var(--accent); background: #fffdfd; }
.drop-zone strong { font-size: 21px; }
.drop-zone span { color: var(--muted); }
.drop-icon { width: 56px; height: 56px; color: var(--accent); stroke-width: 2.2; margin-bottom: 4px; }
.quick-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px auto 10px; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.quick-card { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 14px 16px; cursor: pointer; display: grid; grid-template-columns: 40px 1fr; column-gap: 12px; row-gap: 2px; align-items: center; }
.quick-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.quick-card .qi { grid-row: span 2; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.quick-card .qi svg { width: 22px; height: 22px; }
.quick-card > span:last-child { color: var(--muted); font-size: 13px; }
.opt-h { display: flex; align-items: center; height: 16px; }

.work { display: flex; height: 100%; }
.files { width: 250px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 6px 14px 20px; overflow-y: auto; }
.files h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 8px; }
.file-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.file { display: grid; grid-template-columns: 10px minmax(0, 1fr) 28px; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 7px 4px 7px 9px; }
.file .dot { width: 10px; height: 10px; border-radius: 3px; }
.file .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file .mt { color: var(--muted); font-size: 12px; }
.file .err { color: var(--danger); font-size: 12px; }
.file .x { width: 26px; height: 26px; border: 0; background: none; border-radius: 6px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.file .x:hover { background: #fdecec; color: var(--danger); }
.file .x svg { width: 14px; height: 14px; }
.hint-text { color: var(--muted); font-size: 12px; line-height: 1.5; }

.grid { flex: 1; overflow-y: auto; padding: 20px 22px 40px; display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 18px 16px; align-content: start; outline: none; }
.pg { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 8px 6px; border-radius: 12px; border: 2px solid transparent; cursor: pointer; user-select: none; }
.pg:hover { background: rgba(255,255,255,.6); }
.pg.sel { border-color: var(--accent); background: #fff6f5; }
.pg.dragging { opacity: .35; }
.pg .box { width: 150px; height: 190px; display: grid; place-items: center; }
.pg .sheet { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18); position: relative; display: grid; place-items: center; transition: transform .18s ease; }
.pg .sheet img { display: block; max-width: 100%; max-height: 100%; }
.pg .sheet.loading { width: 120px; height: 160px; background: linear-gradient(110deg, #f3f4f6 30%, #fafafa 50%, #f3f4f6 70%) 0 0 / 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.pg .label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; max-width: 150px; }
.pg .label b { color: var(--ink); font-weight: 600; }
.pg .label .dot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.pg .acts { position: absolute; top: 4px; right: 4px; display: none; gap: 2px; background: rgba(27,31,39,.85); border-radius: 8px; padding: 2px; }
.pg:hover .acts { display: flex; }
.pg .acts button { width: 28px; height: 28px; border: 0; background: none; color: #fff; border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.pg .acts button:hover { background: rgba(255,255,255,.18); }
.pg .acts svg { width: 16px; height: 16px; }
.pg.drop-before::before, .pg.drop-after::after { content: ''; position: absolute; top: 10px; bottom: 30px; width: 4px; border-radius: 2px; background: var(--accent); }
.pg.drop-before::before { left: -10px; }
.pg.drop-after::after { right: -10px; }

.drop-overlay { position: fixed; inset: 56px 0 0 0; background: rgba(200,55,45,.08); border: 3px dashed var(--accent); display: grid; place-items: center; z-index: 40; pointer-events: none; }
.drop-overlay div { background: var(--accent); color: #fff; padding: 14px 26px; border-radius: 12px; font-size: 18px; font-weight: 600; }

/* ---- bottom bar ---- */
.bottom { flex: none; display: flex; align-items: flex-end; gap: 10px; padding: 10px 18px 12px; background: var(--panel); border-top: 1px solid var(--line); }
.opts { display: flex; gap: 14px; flex-wrap: wrap; }
.opt { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.check-opt .switch { height: 36px; display: flex; align-items: center; }
.switch input { display: none; }
.switch i { width: 40px; height: 22px; border-radius: 11px; background: #cfd5df; position: relative; cursor: pointer; transition: background .15s; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.summary { color: var(--muted); font-size: 13px; text-align: right; align-self: center; }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 60; background: #1b1f27; color: #fff; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.25); padding: 12px 16px; display: flex; gap: 14px; align-items: center; max-width: 80vw; }
.toast button { background: none; border: 0; color: #ffaaa2; cursor: pointer; font-weight: 600; }
.busy { position: fixed; inset: 0; background: rgba(233,236,241,.78); display: grid; place-content: center; justify-items: center; gap: 12px; z-index: 50; font-weight: 600; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid #ecc9c5; border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy-bar { width: 260px; height: 6px; border-radius: 3px; background: #dfe3ea; overflow: hidden; }
.busy-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* ---- dialogs ---- */
.dlg { border: 0; border-radius: 16px; padding: 0; width: min(560px, 94vw); box-shadow: 0 24px 60px rgba(0,0,0,.3); color: var(--ink); }
.dlg.small { width: min(500px, 94vw); }
.dlg::backdrop { background: rgba(20,24,33,.45); }
.dlg-head { padding: 18px 22px 0; display: flex; align-items: center; gap: 16px; }
.dlg-head h2 { font-size: 18px; margin: 0; }
.dlg-body { padding: 14px 22px; }
.dlg-foot { padding: 12px 22px 18px; display: flex; align-items: center; gap: 10px; }
.radio { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.radio > input { margin-top: 4px; accent-color: var(--accent); }
.radio > span { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.radio small { color: var(--muted); }
.radio.disabled { opacity: .5; pointer-events: none; }
.num-in { width: 58px; height: 30px; border: 1px solid var(--line); border-radius: 7px; padding: 0 6px; margin: 0 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2 .select { width: 100%; }
.about-brand { display: flex; gap: 14px; align-items: center; }
.about-brand h2 { margin: 0; font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.6; }
.small a { color: var(--accent); }
code { background: #f2f3f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.lic-badge { height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid #f0c36a; background: #fff6e0; color: #7a5200; font-size: 13px; font-weight: 600; cursor: pointer; }
.lic-badge.expired { border-color: #f1a7a1; background: #fdecec; color: var(--danger); }
.lic-badge.basic { border-color: #efb8b2; background: var(--accent-soft); color: var(--accent); }
.lic-state { padding: 12px 14px; border-radius: 10px; background: #f4f6fa; margin-bottom: 14px; line-height: 1.5; }
.lic-state.ok { background: #e8f6ee; color: #145c32; }
.lic-state.warn { background: #fff6e0; color: #7a5200; }
.lic-state.bad { background: #fdecec; color: var(--danger); }
.lic-notice { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); color: #8a241d; font-weight: 600; margin-bottom: 10px; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.text-input { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 10px; outline: none; }
.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.key-input { height: 84px; padding: 10px 12px; font: 13px/1.4 Consolas, monospace; resize: none; word-break: break-all; }
.lic-error { color: var(--danger); font-size: 13px; margin-top: 8px; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.plan { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; }
.plan.pro { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.plan-name { font-weight: 700; font-size: 15px; display: flex; justify-content: space-between; }
.plan .price { color: var(--accent); }
.plan ul { margin: 8px 0 12px; padding-left: 18px; font-size: 12.5px; line-height: 1.6; color: var(--muted); flex: 1; }
.plan .btn { justify-content: center; }
.plans-note { grid-column: 1 / -1; margin: 0; text-align: center; }
.plan[hidden] + .plan.pro { grid-column: 1 / -1; }

@media (max-width: 1100px) {
  .quick { grid-template-columns: repeat(2, 1fr); }
  .files { width: 210px; }
}

/* HirePDF web: extra styles on top of src/styles.css (phones and tablets). */
html, body { height: 100dvh; }
#hpOptToggle { display: none; }

/* "Ready to share" box and the install tip */
#hpShare { position: fixed; inset: 0; z-index: 80; background: rgba(20,24,33,.45); display: grid; place-items: end center; padding: 16px 12px calc(16px + env(safe-area-inset-bottom)); }
#hpShare[hidden] { display: none; }
.hp-share-card { background: #fff; border-radius: 16px; padding: 18px; width: min(440px, 100%); display: flex; flex-direction: column; gap: 6px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.hp-share-card strong { font-size: 16px; word-break: break-word; }
.hp-share-card span { color: var(--muted); font-size: 14px; }
.hp-share-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }
.hp-share-row .btn { height: 44px; padding: 0 18px; }
#hpInstall {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 70;
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100vw - 24px);
  background: #1b1f27; color: #fff; padding: 10px 10px 10px 16px; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.3); font-size: 14px; line-height: 1.4;
}
#hpInstall[hidden] { display: none; }
#hpInstall .icon-btn { color: #fff; width: 32px; height: 32px; flex: none; }
#hpInstall .btn { height: 34px; flex: none; }
#hpInstall .btn[hidden] { display: none; }

/* Touch: page buttons show on the selected page (there's no hover), and are bigger. */
body.hp-touch .pg:hover { background: none; }
body.hp-touch .pg.sel { background: #fff6f5; }
body.hp-touch .pg:hover .acts { display: none; }
body.hp-touch .pg.sel .acts { display: flex; }
body.hp-touch .pg .acts button { width: 34px; height: 34px; }
body.hp-touch .pg .acts svg { width: 18px; height: 18px; }
body.hp-touch .file .x { width: 34px; height: 34px; }

@media (max-width: 760px) {
  .topbar { height: 52px; gap: 4px; padding: 0 8px; }
  .brand span, .brand .by, .sep, .sel-info, .lic-badge { display: none !important; }
  .brand { margin-right: 2px; }
  .topbar:has(#pageTools:not([hidden])) .brand { display: none; }
  #btnAdd { font-size: 0; gap: 0; padding: 0 10px; }
  #btnAdd svg { width: 20px; height: 20px; }
  #btnSelAll { font-size: 0; padding: 0 10px; }
  #btnSelAll::after { content: 'All'; font-size: 15px; }
  .topbar .icon-btn { width: 36px; height: 38px; }
  .tools-group { gap: 2px; }

  .empty { padding: 16px 14px 30px; }
  .drop-zone { min-height: 170px; }
  .drop-zone strong { font-size: 19px; }
  .drop-zone span { text-align: center; }
  .quick { grid-template-columns: 1fr; gap: 8px; }
  .quick-title { margin-top: 20px; }

  /* Files become a strip across the top; pages two to a row. */
  .work { flex-direction: column; }
  .files { width: auto; display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); flex: none; }
  .files h3, .hint-text { display: none; }
  .file-list { flex-direction: row; margin: 0; flex: none; }
  .file { width: 190px; }
  .btn.add { width: auto; flex: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 8px; padding: 12px 10px 24px; justify-items: center; }
  .pg { padding: 6px 4px 4px; }
  .pg .acts { right: auto; left: 50%; transform: translateX(-50%); }
  body.hp-touch .pg .acts button { width: 30px; }

  /* Bottom bar: big Save button; options fold away behind "Options". */
  .bottom { flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .bottom > .spacer, .summary { display: none; }
  #hpOptToggle { display: inline-flex; }
  .opts { display: none; order: -1; width: 100%; grid-template-columns: 1fr 1fr; gap: 10px; padding-bottom: 4px; }
  body.hp-opts-open .opts { display: grid; }
  .opt .select, .opt .text-in { width: 100%; }
  #hpOptToggle, #btnImages, #btnSplit { flex: 1; justify-content: center; padding: 0 8px; }
  #btnSave { flex: 1 1 100%; justify-content: center; }

  .toast { top: 60px; bottom: auto; max-width: calc(100vw - 24px); width: max-content; flex-wrap: wrap; }
  #hpInstall { bottom: calc(150px + env(safe-area-inset-bottom)); }
  body:has(#bottom[hidden]) #hpInstall { bottom: calc(16px + env(safe-area-inset-bottom)); }

  /* Dialogs slide up from the bottom. */
  .dlg, .dlg.small { width: 100vw; max-width: 100vw; max-height: 92dvh; border-radius: 16px 16px 0 0; margin: auto 0 0; }
  .dlg-head { padding: 16px 16px 0; }
  .dlg-body { padding: 12px 16px; }
  .dlg-foot { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .dlg-foot .muted { width: 100%; }
  .plans { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .busy-bar { width: 70vw; }
}
