/* =========================================================
   styles.css  (editor UI, built on the tokens in wm-theme.css)
   Load order: wm-theme.css first, then this file.
========================================================= */
@font-face { font-family: 'Dancing Script'; src: url('dancing-script-latin-600-normal.woff2') format('woff2'); font-weight: 600; }
@font-face { font-family: 'Caveat'; src: url('caveat-latin-600-normal.woff2') format('woff2'); font-weight: 600; }

:root { --nav-h: 76px; --paper-grid: rgba(43,38,64,.045); }
[data-theme="dark"] { --paper-grid: rgba(255,255,255,.04); }
@media (max-width: 640px) { :root { --nav-h: 68px; } }

.hidden { display: none !important; }
input, select { font: inherit; color: inherit; }
i[data-icon] { display: inline-flex; width: 18px; height: 18px; flex: none; }
i[data-icon] svg { width: 100%; height: 100%; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }

/* ---------- app shell: sits between the site header and the site footer ---------- */
.app {
  height: calc(100dvh - var(--nav-h)); min-height: 620px;
  display: grid; grid-template-rows: auto minmax(0, 1fr) 40px;
  background: var(--canvas); color: var(--body-c); font-size: 14px;
}

/* ---------- app bar ---------- */
.appbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 20px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--hairline);
}
.file-actions, .right-actions { display: flex; align-items: center; gap: 8px; }
.right-actions { margin-left: auto; }
.modes { display: flex; background: var(--canvas-deep); border-radius: var(--radius-pill); padding: 4px; gap: 2px; box-shadow: var(--e-pressed); }
.mode {
  display: flex; align-items: center; gap: 7px; border: 0; background: transparent;
  padding: 8px 16px; border-radius: var(--radius-pill); font-weight: 600; color: var(--muted);
  transition: transform .2s ease, background .2s ease, color .2s ease, box-shadow .2s ease;
}
.mode.active { background: var(--primary); color: var(--on-primary); box-shadow: 3px 3px 8px var(--clay-dark); }
.mode:not(.active):hover { color: var(--primary); transform: translateY(-1px); }
.mode:active { transform: scale(.95); }

/* ---------- buttons (clay pills, same as the design file) ---------- */
.btn {
  position: relative; overflow: hidden; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border: 0; border-radius: var(--radius-pill);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; white-space: nowrap;
  box-shadow: var(--e-sm);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
}
.btn:hover:not(:disabled) { color: var(--primary); transform: translateY(-3px); }
.btn:active:not(:disabled) { transform: scale(.95); }
.btn:disabled { opacity: 1; background: var(--primary-soft); color: var(--muted); box-shadow: none; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--e-md); }
.btn.primary:hover:not(:disabled) { background: var(--primary-active); color: var(--on-primary); }
.btn.primary:not(:disabled)::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%; z-index: -1;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.5), transparent);
  transform: skewX(-20deg); animation: wmShine 4.2s ease-in-out 2s infinite;
}
.btn.danger { color: var(--error); }
.btn.danger:hover:not(:disabled) { color: var(--error); background: color-mix(in srgb, var(--error) 10%, var(--surface)); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { height: 32px; padding: 0 13px; font-size: 13px; }
.btn.big { height: 52px; padding: 0 26px; font-size: 15px; font-weight: 700; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; border: 0; background: var(--surface);
  border-radius: 13px; color: var(--ink); box-shadow: var(--e-sm);
  transition: transform .2s ease, color .2s ease, box-shadow .2s ease;
}
.icon-btn:hover:not(:disabled) { color: var(--primary); transform: translateY(-2px); }
.icon-btn:active:not(:disabled) { transform: scale(.92); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.zoom { display: flex; align-items: center; gap: 6px; padding-left: 12px; margin-left: 4px; border-left: 1px solid var(--hairline-strong); }
#zoomLabel { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }

/* ---------- edit view ---------- */
.mode-view { min-height: 0; }
#view-edit { display: grid; grid-template-columns: 84px 150px 1fr; min-height: 0; }
.toolrail {
  background: var(--surface); border-right: 1px solid var(--hairline); padding: 12px 8px;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 5px; border: 0; background: transparent;
  padding: 9px 2px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 600; color: var(--muted);
  transition: transform .2s ease, background .2s ease, color .2s ease;
}
.tool i[data-icon] { width: 22px; height: 22px; transition: transform .3s cubic-bezier(.34,1.56,.64,1); }
.tool:hover { background: var(--hover); color: var(--primary); }
.tool:hover i[data-icon] { transform: translateY(-2px) scale(1.12); }
.tool:active { transform: scale(.94); }
.tool.active { background: var(--primary-soft); color: var(--primary); box-shadow: var(--e-pressed); }
.rail-sep { height: 1px; background: var(--hairline-strong); margin: 6px 4px; }

.thumbs {
  border-right: 1px solid var(--hairline); overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 14px; align-items: center; background: var(--canvas-deep);
}
.thumb { cursor: pointer; text-align: center; font-size: 11px; color: var(--muted); }
.thumb canvas { display: block; max-width: 110px; background: #fff; box-shadow: var(--e-sm); border: 2px solid transparent; border-radius: 6px; transition: transform .2s ease; }
.thumb:hover canvas { transform: translateY(-2px); }
.thumb.current canvas { border-color: var(--primary); }
.thumb.current { color: var(--primary); font-weight: 700; }

.workspace { display: grid; grid-template-rows: auto 1fr; min-width: 0; min-height: 0; }
.propbar {
  display: flex; align-items: center; gap: 18px; padding: 8px 18px; min-height: 52px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--hairline);
}
.prop { display: none; align-items: center; gap: 8px; }
.prop.show { display: flex; animation: paneIn .25s ease both; }
@keyframes paneIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.prop label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.prop .hint { color: var(--muted); }
.prop select, .prop input[type=number], .crow select, #sigText, #splitRanges {
  height: 34px; border: 1px solid var(--hairline-strong); border-radius: 12px; padding: 0 10px;
  background: var(--field); color: var(--ink);
}
.prop input[type=number] { width: 68px; }
.prop input[type=color] { width: 34px; height: 34px; border: 1px solid var(--hairline-strong); border-radius: 12px; padding: 3px; background: var(--field); }
.prop input[type=range] { accent-color: var(--primary); }
.swatches { display: flex; gap: 6px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--hairline-strong); cursor: pointer; padding: 0; transition: transform .2s cubic-bezier(.34,1.56,.64,1); }
.swatch:hover { transform: scale(1.18); }
.swatch.active { box-shadow: 0 0 0 2px var(--primary); }
.toggle { height: 34px; min-width: 34px; padding: 0 10px; border: 0; background: var(--surface); color: var(--ink); border-radius: 12px; box-shadow: var(--e-sm); transition: transform .2s ease; }
.toggle:active { transform: scale(.93); }
.toggle.on { background: var(--primary); color: var(--on-primary); }
.check, .radio { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; color: var(--ink); }
.check input, .radio input { accent-color: var(--primary); width: 17px; height: 17px; }
.sel-actions { margin-left: auto; }

.pages-scroll { overflow: auto; position: relative; min-height: 0; background: var(--canvas);
  background-image: linear-gradient(var(--paper-grid) 1px, transparent 1px), linear-gradient(90deg, var(--paper-grid) 1px, transparent 1px);
  background-size: 30px 30px;
}
.pages { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 26px 30px 60px; width: max-content; min-width: 100%; }
.page {
  position: relative; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 10px 30px rgba(0,0,0,.12);
  flex: none; animation: wmRise .45s ease both;
}
.page > canvas.render { position: absolute; inset: 0; width: 100%; height: 100%; }
.page .page-num { position: absolute; left: -2px; top: -20px; font-size: 11px; color: var(--muted); font-weight: 600; }
.overlay { position: absolute; inset: 0; }
.overlay.tool-text, .overlay.tool-highlight, .overlay.tool-rect, .overlay.tool-whiteout,
.overlay.tool-image, .overlay.tool-sign { cursor: crosshair; }
.overlay.tool-draw { cursor: crosshair; }
.overlay svg.ink { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }

.ann { position: absolute; transform-origin: 0 0; }
.ann.sel { outline: 1.5px solid var(--primary); outline-offset: 2px; }
.overlay.tool-select .ann { cursor: move; }
.ann .handle { display: none; position: absolute; right: -7px; bottom: -7px; width: 12px; height: 12px; background: #fff; border: 2px solid var(--primary); border-radius: 4px; cursor: nwse-resize; }
.ann.sel .handle { display: block; }
.ann-text { white-space: pre; line-height: 1.15; padding: 0; outline: none; min-width: 4px; }
.ann-text[contenteditable=true] { outline: 1.5px dashed var(--primary); outline-offset: 2px; cursor: text; background: rgba(255,255,255,.6); }
.ann-image img { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; }
.ann-ink { pointer-events: none; }
.overlay.tool-select .ann-ink { pointer-events: auto; }
.ann-ink svg { width: 100%; height: 100%; overflow: visible; display: block; }

.textlayer { position: absolute; inset: 0; display: none; }
.overlay.tool-edittext + .textlayer, .page.edittext .textlayer { display: block; }
.tl-item { position: absolute; border-radius: 2px; cursor: text; }
.tl-item:hover { background: rgba(87,58,252,.12); outline: 1px solid rgba(87,58,252,.55); }
.tl-item.done { pointer-events: none; }

.formlayer { position: absolute; inset: 0; pointer-events: none; }
.page.forms .formlayer { pointer-events: auto; }
.ff { position: absolute; border: 0; background: rgba(87,58,252,.10); outline: 1px solid rgba(87,58,252,.4); font-family: Helvetica, Arial, sans-serif; padding: 0 3px; color: #1b1b1f; }
.ff:focus { background: rgba(255,255,255,.95); outline: 2px solid var(--primary); }
.ff.cb { appearance: none; -webkit-appearance: none; display: grid; place-items: center; cursor: pointer; padding: 0; margin: 0; }
/* check mark is an SVG mask, not a text glyph */
.ff.cb:checked::after {
  content: ''; width: 80%; height: 80%; background: #1b1b1f;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E") center / contain no-repeat;
}
.page:not(.forms) .ff { background: transparent; outline-color: transparent; }
textarea.ff { resize: none; padding: 2px 3px; }

.drag-rect { position: absolute; border: 1.5px dashed var(--primary); background: rgba(87,58,252,.07); pointer-events: none; }

/* ---------- empty state / drop card ---------- */
.empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; overflow: auto; }

/* ---------- pages view ---------- */
#view-pages { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; }
.org-bar { display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--hairline); flex-wrap: wrap; }
.org-left { display: flex; align-items: center; gap: 14px; }
.org-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.vsep { width: 1px; height: 24px; background: var(--hairline-strong); margin: 0 4px; }
.org-grid { overflow-y: auto; padding: 26px; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 26px 20px; align-content: start; }
.org-page { display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; user-select: none; position: relative; }
.org-page .frame { width: 150px; height: 190px; display: grid; place-items: center; border-radius: var(--radius-sm); border: 2px solid transparent; padding: 8px; transition: background .15s, transform .2s ease; }
.org-page:hover .frame { background: var(--hover); transform: translateY(-3px); }
.org-page.selected .frame { border-color: var(--primary); background: var(--primary-soft); }
.org-page canvas { max-width: 130px; max-height: 170px; background: #fff; box-shadow: var(--e-sm); transition: transform .2s; }
.org-page .lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.org-page.selected .lbl { color: var(--primary); }
.org-page .src { position: absolute; top: 6px; left: 12px; font-size: 10px; background: var(--ink); color: var(--canvas); padding: 1px 7px; border-radius: 8px; }
.org-page .tick { position: absolute; top: 4px; right: 10px; width: 24px; height: 24px; border-radius: 50%; background: var(--field); border: 2px solid var(--hairline-strong); display: grid; place-items: center; color: var(--on-primary); transition: transform .25s cubic-bezier(.34,1.56,.64,1); }
.org-page .tick svg { width: 14px; height: 14px; stroke-width: 3; opacity: 0; transition: opacity .15s; }
.org-page.selected .tick { background: var(--primary); border-color: var(--primary); transform: scale(1.1); }
.org-page.selected .tick svg { opacity: 1; }
.org-page.dragging { opacity: .35; }
.org-page.drop-before::before, .org-page.drop-after::after {
  content: ''; position: absolute; top: 10px; bottom: 30px; width: 4px; background: var(--primary); border-radius: 2px;
}
.org-page.drop-before::before { left: -12px; }
.org-page.drop-after::after { right: -12px; }
.org-hint { text-align: center; margin: 0; padding: 8px; font-size: 12px; }

/* ---------- convert view ---------- */
#view-convert { overflow-y: auto; }
.convert-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; padding: 28px; max-width: 1200px; margin: 0 auto; }
.ccard {
  background: var(--surface); border-radius: var(--radius-card); padding: 24px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--e-md); transition: transform .3s cubic-bezier(.2,.8,.2,1), box-shadow .3s ease;
  animation: wmRise .6s cubic-bezier(.2,.8,.2,1) both;
}
.ccard:nth-child(2) { animation-delay: .06s; } .ccard:nth-child(3) { animation-delay: .12s; }
.ccard:nth-child(4) { animation-delay: .18s; } .ccard:nth-child(5) { animation-delay: .24s; } .ccard:nth-child(6) { animation-delay: .3s; }
.ccard:hover { transform: translateY(-6px); box-shadow: var(--e-lg); }
.ccard h3 { margin: 4px 0 0; font-size: 18px; color: var(--ink); }
.ccard p { margin: 0; color: var(--body-c); line-height: 1.55; flex: 1; }
.ccard .btn { align-self: flex-start; margin-top: 6px; }
.crow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cicon { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; box-shadow: var(--e-sm); transition: transform .4s cubic-bezier(.34,1.56,.64,1); }
.ccard:hover .cicon { transform: rotate(-8deg) scale(1.1); }
.cicon i[data-icon] { width: 24px; height: 24px; }
.cicon.orange { background: var(--orange); color: var(--orange-ink); }
.cicon.blue   { background: var(--blue);   color: var(--blue-ink); }
.cicon.green  { background: var(--green);  color: var(--green-ink); }
.cicon.violet { background: var(--purple); color: var(--purple-ink); }
.cicon.pink   { background: var(--pink);   color: var(--pink-ink); }
.cicon.yellow { background: var(--yellow); color: var(--yellow-ink); }
code { background: var(--canvas-deep); color: var(--ink); padding: 1px 6px; border-radius: 6px; }

/* ---------- status bar ---------- */
.statusbar { display: flex; align-items: center; gap: 18px; padding: 0 20px; font-size: 12px; background: var(--surface); border-top: 1px solid var(--hairline); color: var(--muted); }
.statusbar .grow { flex: 1; }
.statusbar .privacy { display: inline-flex; align-items: center; gap: 6px; }
.statusbar .privacy i[data-icon] { width: 14px; height: 14px; color: var(--success); }
#docName { font-weight: 700; color: var(--ink); max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; z-index: 500; backdrop-filter: blur(4px); animation: fadeIn .2s ease both; }
@keyframes fadeIn { from { opacity: 0; } }
.modal-card { background: var(--surface); border-radius: var(--radius-card); padding: 22px 24px; width: min(780px, 94vw); box-shadow: var(--e-lg); display: flex; flex-direction: column; gap: 14px; animation: wmRise .35s cubic-bezier(.2,.8,.2,1) both; color: var(--body-c); }
.modal-card.small { width: min(460px, 94vw); }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 20px; color: var(--ink); }
.modal-foot { display: flex; align-items: center; justify-content: space-between; }
.sig-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--hairline-strong); }
.sig-tab { border: 0; background: transparent; padding: 9px 16px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .2s; }
.sig-tab:hover { color: var(--primary); }
.sig-tab.active { color: var(--primary); border-color: var(--primary); }
#sigPad, #sigUploadPrev { width: 100%; aspect-ratio: 3 / 1; background: #fff; border: 1px dashed var(--hairline-strong); border-radius: var(--radius-sm); touch-action: none; cursor: crosshair; }
#sigText { width: 100%; height: 44px; font-size: 16px; padding: 0 14px; }
.sig-preview { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.sig-opt { height: 90px; background: #fff; color: #1b1b1f; border: 2px solid var(--hairline-strong); border-radius: var(--radius-sm); display: grid; place-items: center; font-size: 40px; cursor: pointer; overflow: hidden; white-space: nowrap; transition: transform .2s ease, border-color .2s; }
.sig-opt:hover { transform: translateY(-2px); }
.sig-opt.active { border-color: var(--primary); }
.saved-sigs { display: flex; gap: 10px; flex-wrap: wrap; }
.saved-sigs:empty { display: none; }
.saved-sig { position: relative; width: 150px; height: 56px; background: #fff; border: 1px solid var(--hairline-strong); border-radius: 14px; cursor: pointer; padding: 4px; transition: transform .2s ease, border-color .2s; }
.saved-sig:hover { border-color: var(--primary); transform: translateY(-2px); }
.saved-sig img { width: 100%; height: 100%; object-fit: contain; }
.saved-sig button { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--ink); color: var(--canvas); display: none; place-items: center; padding: 0; }
.saved-sig button svg { width: 12px; height: 12px; }
.saved-sig:hover button { display: grid; }

.busy { position: fixed; inset: 0; background: color-mix(in srgb, var(--canvas) 80%, transparent); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; gap: 14px; z-index: 510; font-weight: 700; font-size: 15px; color: var(--ink); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 520; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: var(--canvas); padding: 11px 20px; border-radius: var(--radius-pill); box-shadow: var(--e-lg); max-width: min(520px, 92vw); display: flex; gap: 12px; align-items: center; font-size: 13px; font-weight: 600; animation: wmRise .3s cubic-bezier(.34,1.56,.64,1) both; }
.toast.err { background: var(--error); color: #fff; }
.toast a { color: var(--primary-soft); cursor: pointer; font-weight: 800; text-decoration: underline; }
[data-theme="dark"] .toast a { color: var(--primary-active); }

/* ---------- small screens ---------- */
@media (max-width: 1000px) {
  #view-edit { grid-template-columns: 76px 1fr; }
  .thumbs { display: none; }
}
@media (max-width: 720px) {
  .app { min-height: 560px; }
  .appbar { padding: 8px 12px; gap: 8px; }
  .mode { padding: 7px 11px; }
  .mode i[data-icon] { display: none; }
  #view-edit { grid-template-columns: 64px 1fr; }
  .tool span { font-size: 10px; }
  .empty .file-drop { padding: 30px 18px 26px; }
  .statusbar { padding: 0 12px; }
  .org-grid, .convert-grid { padding: 16px; }
}

/* ---------- ask() dialog + tool dialogs ---------- */
.ask-in { height: 42px; border: 1px solid var(--hairline-strong); border-radius: 14px; padding: 0 14px; background: var(--field); color: var(--ink); }
.ask-in:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn.primary.danger-fill { background: var(--error); }
.fd-card { width: min(520px, 94vw); max-height: 92dvh; overflow: visible; }
.fd-intro { margin: 0; line-height: 1.55; }
.fd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.fd { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fd.half { grid-column: auto; }
.fd[hidden] { display: none; }
.fd-l { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.fd input:not([type=checkbox]):not([type=range]):not([type=color]):not([type=file]) {
  height: 42px; border: 1px solid var(--hairline-strong); border-radius: 14px; padding: 0 14px; background: var(--field); color: var(--ink); width: 100%;
}
.fd input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.fd input[type=color] { width: 100%; height: 42px; padding: 4px; border: 1px solid var(--hairline-strong); border-radius: 14px; background: var(--field); }
.fd input[type=file] { color: var(--body-c); }
.fd input[type=file]::file-selector-button { border: 0; border-radius: 999px; padding: 8px 16px; margin-right: 10px; font-weight: 700; background: var(--primary-soft); color: var(--primary); cursor: pointer; }
.fd input[type=range] { width: 100%; accent-color: var(--primary); }
.fd-out { font-weight: 700; color: var(--ink); font-size: 13px; }
.fd-hint { line-height: 1.45; }
.fd-err { margin: 0; min-height: 0; color: var(--error); font-weight: 600; font-size: 13px; }
.fd-err:empty { display: none; }
.fd .ds-dd.sm { width: 100%; }
.fd .ds-dd.sm .ds-dd-btn { height: 42px; border-radius: 14px; }
.fd-x { width: 34px; height: 34px; }
.fd-x svg { width: 16px; height: 16px; }

/* ---------- SEO / how-to section (below the editor) ---------- */
.seo { padding: 84px 0 70px; background: var(--canvas); }
.seo-head { max-width: 760px; margin: 0 auto 48px; text-align: center; }
.seo-head h2 { font-size: clamp(28px, 4.4vw, 44px); line-height: 1.12; letter-spacing: -.02em; color: var(--ink); font-weight: 800; }
.seo-accent { color: var(--primary); }
.seo-head p { margin-top: 14px; font-size: 17px; line-height: 1.65; color: var(--body-c); }
.seo-h3 { font-size: 22px; color: var(--ink); font-weight: 800; margin: 54px 0 20px; letter-spacing: -.01em; }
.seo-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; counter-reset: s; }
.seo-steps li { background: var(--surface); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--e-md); transition: transform .3s cubic-bezier(.2,.8,.2,1), box-shadow .3s ease; }
.seo-steps li:hover { transform: translateY(-5px); box-shadow: var(--e-lg); }
.seo-n { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 14px; margin-bottom: 14px; font-weight: 800; background: var(--primary); color: var(--on-primary); box-shadow: var(--e-sm); }
.seo-steps h4 { font-size: 17px; color: var(--ink); margin: 0 0 6px; }
.seo-steps p { font-size: 14.5px; line-height: 1.6; color: var(--body-c); }
.seo-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.seo-grid li { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center; background: var(--surface); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--e-sm); transition: transform .25s ease; }
.seo-grid li:hover { transform: translateY(-3px); }
.seo-grid li i[data-icon] { grid-row: 1 / 3; width: 44px; height: 44px; padding: 10px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); }
.seo-grid b { color: var(--ink); font-size: 15px; align-self: end; }
.seo-grid span { font-size: 13px; color: var(--muted); line-height: 1.4; align-self: start; }
.seo-faq { display: grid; gap: 12px; max-width: 860px; }
.seo-q { background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--e-sm); transition: box-shadow .25s ease; }
.seo-q[open] { box-shadow: var(--e-md); }
.seo-q summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; font-weight: 700; color: var(--ink); font-size: 16px; }
.seo-q summary::-webkit-details-marker { display: none; }
.seo-q summary i[data-icon] { width: 32px; height: 32px; padding: 7px; border-radius: 11px; background: var(--primary-soft); color: var(--primary); transition: transform .3s cubic-bezier(.34,1.56,.64,1); }
.seo-q[open] summary i[data-icon] { transform: rotate(180deg); }
.seo-q p { padding: 0 20px 20px; line-height: 1.7; color: var(--body-c); animation: paneIn .3s ease both; }
@media (max-width: 640px) { .seo { padding: 56px 0 48px; } .seo-h3 { margin-top: 40px; } }

/* ---------- open dropdowns must sit above everything beside them ---------- */
.propbar { position: relative; z-index: 30; }
.ccard { position: relative; }
.ccard:has(.ds-dd.open) { z-index: 20; }
.org-bar { position: relative; z-index: 30; }

/* dialogs (password prompt etc.) must sit above the busy overlay */
.modal { z-index: 600; }


/* ---------- upload area (the design's file-drop component) ---------- */
.file-drop{position:relative;display:flex;flex-direction:column;align-items:center;gap:6px;padding:34px 20px 28px;text-align:center;border:2px dashed var(--hairline-strong);border-radius:var(--radius-lg);background:var(--canvas);color:var(--muted);box-shadow:inset 3px 3px 8px var(--clay-dark),inset -3px -3px 8px var(--clay-light);transition:border-color .2s ease,background .2s ease,transform .2s ease;-webkit-tap-highlight-color:transparent;cursor:pointer;user-select:none}
[data-theme="dark"] .file-drop{box-shadow:none;background:var(--canvas-deep)}
.file-drop:hover,.file-drop.dragover{border-color:var(--primary);background:var(--primary-soft)}
.file-drop.dragover{transform:scale(1.015)}
.file-drop:active{transform:scale(.99)}
.fd-icon{width:60px;height:60px;border-radius:50%;background:var(--primary-soft);color:var(--primary);display:flex;align-items:center;justify-content:center;margin-bottom:6px;transition:transform .25s ease,background .2s ease,color .2s ease}
.fd-icon svg{width:28px;height:28px}
.file-drop:hover .fd-icon,.file-drop.dragover .fd-icon{background:var(--primary);color:var(--on-primary);transform:translateY(-3px)}
.fd-title{font-size:17px;font-weight:700;color:var(--ink)}
.fd-sub{font-size:14px;color:var(--body-c)}
.fd-btn{margin-top:10px;display:inline-flex;align-items:center;gap:8px;padding:10px 22px;border-radius:var(--radius-pill);background:var(--primary);color:var(--on-primary);font-size:14px;font-weight:700;box-shadow:4px 4px 10px var(--clay-dark),-4px -4px 10px var(--clay-light)}
.fd-meta{font-size:12px;color:var(--muted);margin-top:4px}
.fname{margin-top:10px;padding:7px 14px;border-radius:var(--radius-pill);background:var(--surface);color:var(--ink);font-size:13px;font-weight:600;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;box-shadow:3px 3px 8px var(--clay-dark),-3px -3px 8px var(--clay-light)}
.fname:empty{display:none}
.fd-icon svg, .fd-icon i[data-icon] { width: 28px; height: 28px; }
.up-fd .fd-icon{position:relative;animation:fdBob 3.2s ease-in-out infinite}
.up-fd .fd-icon::before,.up-fd .fd-icon::after{content:"";position:absolute;inset:0;border-radius:50%;border:2px solid var(--primary);opacity:0;pointer-events:none}
.up-fd.dragover .fd-icon{animation:fdLift .6s var(--ease-out) infinite alternate}
.up-fd.dragover .fd-icon::before{animation:fdRing 1.1s ease-out infinite}
.up-fd.dragover .fd-icon::after{animation:fdRing 1.1s ease-out .45s infinite}
.up-fd.dragover{border-style:solid}
.up-fd .fd-btn{transition:transform .2s var(--ease-out),box-shadow .2s}
.up-fd:hover .fd-btn{transform:translateY(-2px)}
.up-fd:active .fd-btn{transform:scale(.95)}
.up-fd:focus-visible{outline:2px solid var(--primary);outline-offset:3px}
@keyframes fdBob{0%,100%{transform:translateY(0)}50%{transform:translateY(-4px)}}
@keyframes fdLift{from{transform:translateY(-2px) scale(1.04)}to{transform:translateY(-8px) scale(1.14)}}
@keyframes fdRing{0%{transform:scale(1);opacity:.55}100%{transform:scale(1.9);opacity:0}}
.empty .file-drop { width: min(560px, 100%); padding: 44px 28px 34px; animation: wmRise .7s cubic-bezier(.2,.8,.2,1) both; }
.empty h1.fd-title { font-size: 24px; margin: 0; letter-spacing: -.01em; }
.fd-sub { margin-bottom: 4px; }
.fd-meta { display: inline-flex; align-items: center; gap: 6px; }
.fd-meta i[data-icon] { width: 14px; height: 14px; color: var(--success); }
.drop-alt { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 22px; animation: wmRise .7s ease .25s both; }
.empty-wrap { display: flex; flex-direction: column; align-items: center; width: 100%; }
/* a file being dragged anywhere on the page lights up every upload area */
body.dragging .file-drop { border-color: var(--primary); border-style: solid; background: var(--primary-soft); transform: scale(1.015); }
body.dragging .file-drop .fd-icon { background: var(--primary); color: var(--on-primary); animation: fdLift .6s cubic-bezier(.2,.8,.2,1) infinite alternate; }
body.dragging .file-drop .fd-icon::before { animation: fdRing 1.1s ease-out infinite; }
body.dragging .file-drop .fd-icon::after { animation: fdRing 1.1s ease-out .45s infinite; }
/* when a document is open, dropping a new file shows one clear target over the workspace */
body.dragging.has-doc .pages-scroll::after {
  content: 'Drop your file here'; position: absolute; inset: 14px; z-index: 40; display: grid; place-items: center;
  border: 2px solid var(--primary); border-radius: var(--radius-lg); font-size: 20px; font-weight: 800; color: var(--primary);
  background: color-mix(in srgb, var(--primary-soft) 88%, transparent); backdrop-filter: blur(3px); pointer-events: none;
}

/* ---------- tool pages ---------- */
.tool-feature { padding: 28px 28px 0; max-width: 1200px; margin: 0 auto; }
.tool-feature .file-drop { padding: 40px 24px 32px; }
.tool-feature h1.fd-title { font-size: 26px; margin: 0; letter-spacing: -.01em; }
.tool-feature .fd-sub { max-width: 640px; line-height: 1.55; }
.tool-feature .fd-icon { animation: fdBob 3.2s ease-in-out infinite; }
body.has-doc .tool-feature { display: none; }
.more-tools-title { max-width: 1200px; margin: 0 auto; padding: 26px 28px 0; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
body[data-mode="convert"]:not(.has-doc) .more-tools-title { display: block; }
.ccard.featured { outline: 2px solid var(--primary); outline-offset: -2px; }
.ccard.featured::before { content: 'This tool'; position: absolute; top: 14px; right: 16px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); background: var(--primary-soft); padding: 3px 10px; border-radius: 999px; }
.ccard.pulse { animation: cardPulse 1.2s ease 2; }
@keyframes cardPulse { 50% { box-shadow: 0 0 0 6px var(--primary-soft), var(--e-lg); transform: translateY(-4px); } }

/* ---------- tool links in the info section ---------- */
.seo-grid a { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center; background: var(--surface); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--e-sm); transition: transform .25s ease, box-shadow .25s ease; }
.seo-grid a:hover { transform: translateY(-3px); box-shadow: var(--e-md); }
.seo-grid a i[data-icon] { grid-row: 1 / 3; width: 44px; height: 44px; padding: 10px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); }
.seo-grid a b { color: var(--ink); font-size: 15px; align-self: end; }
.seo-grid a span { font-size: 13px; color: var(--muted); line-height: 1.4; align-self: start; }
.seo-grid li.current a { outline: 2px solid var(--primary); outline-offset: -2px; }

.ask-msg { margin: 0; line-height: 1.55; }
.modal-btns { display: flex; gap: 8px; }

/* convert-style pages open straight onto the Convert view (no flash of the editor) */
body[data-boot="convert"] #view-edit { display: none !important; }
body[data-boot="convert"] #view-convert.hidden { display: block !important; }
