:root {
  --bg: #e9ecf1;
  --panel: #ffffff;
  --ink: #1b1f27;
  --muted: #6b7280;
  --line: #dde1e8;
  --accent: #2455d6;
  --accent-soft: #e6edff;
  --danger: #c62828;
  --radius: 10px;
  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; }
button { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
kbd { font: 11px/1 inherit; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 4px; background: #fafafa; }

/* ---- top bar ---- */
.topbar {
  height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--accent); margin-right: 8px; }
.doc-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw; }
.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: #1d47b8; }
.btn.big { height: 46px; padding: 0 22px; font-size: 16px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid transparent; background: none; border-radius: 8px; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover:not(:disabled) { background: #f0f2f6; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.zoom { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; }
.zoom .icon-btn { border-radius: 0; }
.zoom-label { min-width: 62px; height: 38px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: none; cursor: pointer; font-variant-numeric: tabular-nums; }
.page-info { color: var(--muted); min-width: 90px; text-align: center; font-variant-numeric: tabular-nums; }
.save-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 44px; min-width: 250px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.14); padding: 6px; z-index: 20;
}
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 7px; cursor: pointer; }
.menu button:hover { background: var(--accent-soft); }
.menu small { display: block; color: var(--muted); }

/* ---- layout ---- */
.layout { display: flex; height: calc(100% - 56px); }
.sidebar {
  width: 272px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 8px 14px 20px;
}
.sidebar h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 8px; }
.btn.add { width: 100%; justify-content: center; border-style: dashed; color: var(--accent); }
.sig-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.sig-list.small { flex-direction: row; flex-wrap: wrap; }
.sig-item {
  position: relative; height: 68px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  display: grid; place-items: center; cursor: pointer; padding: 6px 28px 6px 8px; touch-action: manipulation;
}
.sig-list.small .sig-item { width: calc(50% - 4px); height: 56px; }
.sig-item img { max-width: 100%; max-height: 100%; pointer-events: none; }
.sig-item:hover { border-color: #b9c4dc; }
.sig-item.armed { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sig-item .del {
  position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; border-radius: 6px; border: 0;
  background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; opacity: .6;
}
.sig-item .del:hover { background: #fdecec; color: var(--danger); opacity: 1; }
.sig-item .del svg { width: 14px; height: 14px; }
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px 7px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 12px;
}
.tool svg { width: 20px; height: 20px; }
.tool:hover { background: #f5f7fb; }
.tool.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.swatches { display: flex; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; background: var(--c); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.range { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.range input { flex: 1; accent-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); cursor: pointer; margin-top: 8px; }
.check input { accent-color: var(--accent); margin-top: 2px; }
.hint-small { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 18px; }

/* ---- viewer ---- */
.viewer { flex: 1; overflow: auto; position: relative; }
.sizer { margin: 0 auto; position: relative; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; padding: 24px 0; }
.page { position: relative; margin: 0 auto 20px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 6px 20px rgba(0,0,0,.06); }
.page canvas.render { width: 100%; height: 100%; display: block; }
.overlay { position: absolute; inset: 0; z-index: 3; }
.armed .overlay, .tool-date .overlay, .tool-text .overlay, .tool-check .overlay, .tool-cross .overlay { cursor: copy; }
.inking .overlay { cursor: crosshair; touch-action: none; }
.inking.pen-only .overlay { touch-action: pan-x pan-y; }
canvas.ink { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* docx pages */
.stage .docx-wrapper { background: transparent !important; padding: 0 !important; }
.stage section.docx { position: relative; margin: 0 auto 20px !important; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 6px 20px rgba(0,0,0,.06) !important; }

/* placed items */
.item { position: absolute; touch-action: none; cursor: move; user-select: none; }
.item img { width: 100%; height: 100%; display: block; pointer-events: none; }
.item.sel { outline: 2px solid var(--accent); outline-offset: 2px; }
.item .h {
  position: absolute; right: -11px; bottom: -11px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent); cursor: nwse-resize; display: none;
}
.item .h::before { content: ""; position: absolute; inset: -10px; } /* larger touch target */
.item .x {
  position: absolute; right: -12px; top: -30px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--danger); color: #fff; border: 0; display: none; place-items: center; cursor: pointer;
}
.item .x svg { width: 14px; height: 14px; stroke-width: 2.4; }
.item.sel .h { display: block; }
.item.sel .x { display: grid; }
.inking .item { pointer-events: none; }

.empty { position: absolute; inset: 0; display: grid; place-items: center; }
.drop { text-align: center; padding: 48px 64px; border: 2px dashed #c3cad6; border-radius: 18px; background: rgba(255,255,255,.55); color: var(--muted); }
.drop svg { color: var(--accent); }
.drop h2 { color: var(--ink); margin: 12px 0 6px; }
.viewer.dragover .drop, .viewer.dragover .stage { outline: 3px dashed var(--accent); outline-offset: -8px; }

.hint, .ink-bar, .toast {
  position: fixed; left: 50%; transform: translateX(calc(-50% + 136px)); z-index: 30;
  background: #1b1f27; color: #fff; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.hint { top: 70px; padding: 10px 16px; font-size: 14px; pointer-events: none; }
.ink-bar { bottom: 22px; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; }
.ink-bar .btn:not(.primary) { background: #2c323d; border-color: #3a414e; color: #fff; }
.toast { bottom: 22px; padding: 12px 16px; display: flex; gap: 14px; align-items: center; }
.toast button { background: none; border: 0; color: #8fb0ff; cursor: pointer; font-weight: 600; }
.busy { position: fixed; inset: 0; background: rgba(233,236,241,.7); 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 #c9d3ea; border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- dialogs ---- */
.dlg { border: 0; border-radius: 16px; padding: 0; width: min(860px, 94vw); box-shadow: 0 24px 60px rgba(0,0,0,.3); color: var(--ink); }
.dlg.small { width: min(460px, 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; flex: 1; }
.dlg-body { padding: 16px 22px; }
.dlg-foot { padding: 12px 22px 18px; display: flex; align-items: center; gap: 10px; }
.dlg-foot .check { margin: 0; }
.tabs { display: flex; background: #f0f2f6; padding: 3px; border-radius: 9px; }
.tab { border: 0; background: none; padding: 7px 16px; border-radius: 7px; cursor: pointer; }
.tab.active { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.pad-wrap { position: relative; height: 280px; border: 1px solid var(--line); border-radius: 12px; background: #fcfcfd; overflow: hidden; touch-action: none; }
.pad-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; z-index: 2; touch-action: none; }
.pad-line { position: absolute; left: 36px; right: 36px; bottom: 70px; border-bottom: 1.5px solid #c9ced8; }
.pad-line span { position: absolute; left: -2px; bottom: 4px; color: #b1b8c5; font-size: 18px; }
.pad-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #aab1be; font-size: 17px; pointer-events: none; padding-bottom: 60px; }
.pad-tools { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.pad-tools .range { margin: 0; width: 220px; }
.text-input { width: 100%; height: 48px; font: inherit; font-size: 18px; padding: 0 14px; 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); }
.font-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; max-height: 300px; overflow-y: auto; }
.font-opt { height: 88px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-size: 34px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 12px; }
.font-opt.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.upload-box { display: flex; align-items: center; gap: 20px; }
.upload-box .range { flex: 1; margin: 0; }
.upload-preview { margin-top: 14px; height: 240px; border: 1px solid var(--line); border-radius: 12px; display: grid; place-items: center;
  background: repeating-conic-gradient(#f3f4f6 0% 25%, #fff 0% 50%) 50% / 20px 20px; }
.upload-preview img { max-width: 90%; max-height: 90%; }
.upload-preview img:not([src]), .upload-preview img[src=""] { display: none; }

/* ---- print (Word -> PDF export) ---- */
@media print {
  .topbar, .sidebar, .hint, .ink-bar, .toast, .busy, .empty, dialog { display: none !important; }
  html, body, .layout, .viewer { height: auto !important; overflow: visible !important; background: #fff !important; }
  .layout { display: block !important; }
  .sizer { width: auto !important; height: auto !important; }
  .stage { position: static !important; transform: none !important; padding: 0 !important; }
  .stage section.docx { margin: 0 !important; box-shadow: none !important; overflow: hidden !important; break-after: page; }
  .stage section.docx:last-of-type { break-after: auto; }
  .item.sel { outline: none !important; }
  .item .h, .item .x { display: none !important; }
}

/* ---- branding & licence ---- */
.brand .by { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: -2px; align-self: flex-end; padding-bottom: 3px; }
.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); }
.about-brand { display: flex; gap: 14px; align-items: center; }
.about-brand h2 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.6; }
.small a { 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); }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.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; }

/* ---- editions ---- */
.lic-badge.basic { border-color: #b9c8f5; background: var(--accent-soft); color: var(--accent); }
.lic-notice { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); color: #1d3d99; font-weight: 600; margin-bottom: 10px; }
.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; }
.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; }
.pro-tag.big { display: inline-block; font-size: 12px; margin: 0 0 8px; }
.locked { height: 280px; display: grid; place-content: center; justify-items: center; text-align: center; border: 1px dashed var(--line); border-radius: 12px; padding: 20px 60px; }
.locked h3 { margin: 0 0 6px; }
.locked p { max-width: 460px; margin: 0 0 14px; line-height: 1.5; }
.plan[hidden] + .plan.pro { grid-column: 1 / -1; }

/* HireSign web: extra styles on top of src/styles.css (phones and tablets). */
body.hs-web { height: 100dvh; }
body.hs-web .layout { height: calc(100dvh - 56px); }
#hsPanelToggle, #hsScrim { display: none; }
#hsInstall {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 60;
  display: flex; align-items: center; gap: 10px; 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;
}
#hsInstall[hidden] { display: none; }
#hsInstall .icon-btn { color: #fff; width: 32px; height: 32px; flex: none; }
#hsInstall .btn { height: 34px; flex: none; }
#hsInstall .btn[hidden] { display: none; }

/* Touch targets: bigger hit areas for fingers. */
@media (pointer: coarse) {
  .item .h { width: 28px; height: 28px; right: -15px; bottom: -15px; }
  .item .x { width: 32px; height: 32px; top: -38px; }
}

@media (max-width: 760px) {
  .topbar { height: 52px; gap: 6px; padding: 0 8px; }
  .brand span, .brand .by, .doc-name, .page-info, #btnUndo { display: none; }
  .brand { margin-right: 0; }
  .topbar .btn { padding: 0 10px; height: 36px; }
  .zoom .icon-btn { width: 32px; height: 36px; }
  .zoom-label { min-width: 46px; height: 36px; font-size: 13px; }
  /* Compact top bar: icon-only Open, short "Save", trial status lives under the (i) button. */
  .lic-badge { display: none !important; }
  #btnOpen { font-size: 0; gap: 0; padding: 0 9px; }
  #btnOpen svg { width: 20px; height: 20px; }
  #btnSave { font-size: 0; gap: 6px; padding: 0 12px; }
  #btnSave::after { content: 'Save'; font-size: 15px; }
  .topbar .spacer { min-width: 0; }
  body.hs-web .layout { height: calc(100dvh - 52px); }

  /* The sidebar becomes a panel that slides up from the bottom. */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; width: auto; max-height: 72dvh;
    border-right: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,.18); padding: 6px 16px calc(24px + env(safe-area-inset-bottom));
    transform: translateY(105%); transition: transform .25s ease;
  }
  .sidebar::before { content: ''; display: block; width: 44px; height: 5px; border-radius: 3px; background: #d0d5de; margin: 6px auto 4px; }
  body.hs-panel-open .sidebar { transform: none; }
  #hsScrim { display: block; position: fixed; inset: 0; background: rgba(20,24,33,.35); z-index: 39; opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.hs-panel-open #hsScrim { opacity: 1; pointer-events: auto; }
  #hsPanelToggle {
    display: inline-flex; position: fixed; z-index: 35; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom));
    height: 52px; padding: 0 22px; border-radius: 26px; font-size: 16px; box-shadow: 0 8px 24px rgba(36,85,214,.4);
  }
  body.armed #hsPanelToggle, body.inking #hsPanelToggle { display: none; }
  #hsInstall { bottom: calc(84px + env(safe-area-inset-bottom)); }

  .hint, .ink-bar, .toast { left: 50%; transform: translateX(-50%); max-width: calc(100vw - 24px); }
  .hint { top: 60px; font-size: 13px; text-align: center; }
  .menu { right: -6px; min-width: 230px; }
  .empty .drop { padding: 30px 22px; margin: 0 14px; }
  .dlg { width: 100vw; max-width: 100vw; max-height: 100dvh; border-radius: 16px 16px 0 0; margin: auto 0 0; }
  .dlg-head { flex-wrap: wrap; padding: 14px 16px 0; }
  .dlg-body { padding: 12px 16px; }
  .dlg-foot { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .pad-wrap { height: 230px; }
  .pad-tools { flex-wrap: wrap; gap: 10px; }
  .pad-tools .range { width: 100%; }
  .font-list { grid-template-columns: 1fr; max-height: 46dvh; }
  .plans { grid-template-columns: 1fr; }
  .hint-small { display: none; }          /* keyboard tips (Shift) don't apply on phones */
}
