/* Unicorn PDF. The app around the pages follows the theme; the PDF pages stay as they are (white paper). */
html, body { height: 100%; overflow: hidden; }
body { display: grid; grid-template-rows: auto auto 1fr auto; }
body.empty .need-doc { display: none; }
body.empty .need-doc-bar { visibility: hidden; }
body.empty .thumbs { display: none; }
.top { display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.top .home { border: 0; background: none; padding: 2px; border-radius: 10px; }
.top .home:hover { background: var(--surface-2); }
.doc-name { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.doc-name input { font: 600 18px 'Fredoka', sans-serif; border: 1px solid transparent; background: none; color: var(--text); padding: 2px 6px; border-radius: 8px; max-width: 460px; }
.doc-name input:hover, .doc-name input:focus { border-color: var(--line); background: var(--surface-2); outline: none; }
.doc-name span { font-size: 12px; padding-left: 7px; }
.early { background: linear-gradient(135deg, #fef3c7, #fce7f3); color: #9a3412; border-color: #fcd34d; }
[data-theme="galaxy"] .early, [data-theme="midnight"] .early { background: #3b2a12; color: #fde68a; border-color: #92400e; }
.file-btns { display: flex; gap: 6px; align-items: center; }
.u-btn.sm { padding: 6px 12px; font-size: 13.5px; border-radius: 10px; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 30; min-width: 270px; display: grid; }
.menu button { text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 10px; font-weight: 700; color: var(--text); }
.menu button:hover { background: var(--surface-2); }

.toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); align-items: center; }
.grp { display: flex; gap: 2px; align-items: center; padding-right: 8px; border-right: 1px solid var(--line); }
.grp:last-child { border-right: 0; }
.toolbar button { min-width: 32px; height: 34px; border: 1px solid transparent; background: none; border-radius: 9px; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; color: var(--text); padding: 0 7px; }
.toolbar button span { font: 800 12.5px 'Nunito', sans-serif; }
.toolbar button:hover { background: var(--surface); border-color: var(--line); }
.toolbar button.on { background: var(--glow); border-color: var(--accent); }
.toolbar select { height: 32px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; font: 700 13px 'Nunito', sans-serif; padding: 0 6px; margin-left: 6px; }
.swatches { display: flex; gap: 3px; }
.swatches button { min-width: 0; width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.swatches button.on { box-shadow: 0 0 0 2px var(--accent); border-color: var(--surface); }
.search { margin-left: auto; }
.search input { height: 32px; width: 190px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; padding: 0 10px; font: 700 13px 'Nunito', sans-serif; }
.search span { font-size: 12px; font-weight: 800; min-width: 50px; text-align: center; }
@media (max-width: 1250px) { .toolbar button span { display: none; } }

.main { display: grid; grid-template-columns: 170px 1fr; min-height: 0; }
body.empty .main { grid-template-columns: 1fr; }
.thumbs { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.thumbs-head { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px 6px; font-size: 13px; }
.thumbs-head span { font-size: 11px; font-weight: 700; }
.thumb-list { overflow: auto; padding: 4px 12px 30px; display: grid; gap: 12px; align-content: start; }
.thumb { border: 2px solid transparent; border-radius: 10px; padding: 5px; background: none; cursor: pointer; display: grid; justify-items: center; gap: 4px; position: relative; }
.thumb:hover { background: var(--surface-2); }
.thumb.cur { border-color: var(--line); }
.thumb.sel { border-color: var(--accent); background: var(--glow); }
.thumb canvas, .thumb .ph { background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); max-width: 120px; display: block; }
.thumb b { font-size: 11.5px; color: var(--muted); }
.thumb.drop-before::before, .thumb.drop-after::after { content: ''; position: absolute; left: 0; right: 0; height: 4px; border-radius: 4px; background: var(--accent-2); }
.thumb.drop-before::before { top: -8px; } .thumb.drop-after::after { bottom: -8px; }
.thumb.dragging { opacity: .4; }

.desk { overflow: auto; background: radial-gradient(900px 400px at 50% 0%, var(--glow), transparent 70%), var(--bg-2); position: relative; }
.pages { display: grid; justify-content: center; gap: 22px; padding: 26px 20px 80px; }
.pg { position: relative; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .06), 0 18px 40px rgba(60, 30, 120, .14); }
.pg canvas.art { position: absolute; inset: 0; width: 100%; height: 100%; }
.pg .num { position: absolute; right: -8px; top: 0; transform: translateX(100%); font: 800 11px 'Nunito', sans-serif; color: var(--muted); }
.ov { position: absolute; transform-origin: center center; }
body:not(.tool-select) .ov { cursor: crosshair; }
body.tool-text .ov { cursor: text; }

/* marks (annotations) */
.an { position: absolute; }
.an.hl { mix-blend-mode: multiply; opacity: .4; }
.an.cover { background: #fff; }
.an.box { background: transparent; }
.an.text { white-space: pre-wrap; word-wrap: break-word; font-family: Helvetica, Arial, sans-serif; line-height: 1.25; outline: none; min-width: 20px; min-height: 1em; }
.an.text:empty::before { content: 'Type here…'; color: #a59cc2; }
.an.note { background: #fef08a; border: 1px solid #eab308; box-shadow: 0 3px 8px rgba(0, 0, 0, .15); padding: 6px; font: 10px/1.3 Helvetica, Arial, sans-serif; color: #3f3a1e; white-space: pre-wrap; word-wrap: break-word; outline: none; overflow: hidden; }
.an.note:empty::before { content: 'Write a note…'; color: #a18a26; }
.an.img { user-select: none; }
.an.img img { width: 100%; height: 100%; display: block; pointer-events: none; }
.an.draw { overflow: visible; pointer-events: none; }
.an.draw path { pointer-events: stroke; }
body.tool-select .an { cursor: move; }
body.tool-select .an.text[contenteditable="true"], body.tool-select .an.note[contenteditable="true"] { cursor: text; }
body:not(.tool-select):not(.tool-text):not(.tool-note) .an { pointer-events: none; }
body:not(.tool-select):not(.tool-text):not(.tool-note) .an.draw path { pointer-events: none; }
.an.picked { outline: 2px dashed #8b5cf6; outline-offset: 2px; }
.an .grip { position: absolute; right: -7px; bottom: -7px; width: 12px; height: 12px; border-radius: 3px; background: #8b5cf6; border: 2px solid #fff; cursor: nwse-resize; }
.an .x { position: absolute; right: -10px; top: -22px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: #ef4444; color: #fff; font: 900 11px/20px 'Nunito', sans-serif; padding: 0; cursor: pointer; }
.hit { position: absolute; background: rgba(6, 182, 212, .35); outline: 1px solid rgba(6, 182, 212, .8); pointer-events: none; border-radius: 2px; }
.hit.now { background: rgba(236, 72, 153, .45); outline-color: #ec4899; }
.temp { position: absolute; border: 1.5px dashed #8b5cf6; pointer-events: none; }

/* form fields */
.fld { position: absolute; border: 1px solid rgba(139, 92, 246, .45); background: rgba(219, 234, 254, .55); color: #111; font-family: Helvetica, Arial, sans-serif; padding: 0 2px; border-radius: 2px; outline: none; }
.fld:focus { background: #fff; border-color: #8b5cf6; box-shadow: 0 0 0 2px rgba(139, 92, 246, .3); }
textarea.fld { resize: none; padding: 2px; }
input.fld[type=checkbox], input.fld[type=radio] { margin: 0; accent-color: #8b5cf6; background: none; border: 0; }
.fld[readonly], .fld:disabled { background: transparent; border-color: transparent; }
body:not(.tool-select) .fld { pointer-events: none; }

.welcome { display: grid; place-items: center; min-height: 100%; padding: 30px; }
body:not(.empty) .welcome { display: none; }
.w-card { background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 34px 40px; text-align: center; box-shadow: var(--shadow); max-width: 480px; }
.w-emoji { font-size: 64px; line-height: 1; margin-bottom: 8px; }
.w-card h1 { font-size: 30px; }
.w-card .u-btn { margin-top: 14px; font-size: 16px; padding: 12px 22px; }
.drop-hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.w-list { text-align: left; list-style: none; padding: 16px 0 0; margin: 18px 0 0; border-top: 1px solid var(--line); display: grid; gap: 6px; font-weight: 700; }
.dropping { position: fixed; inset: 0; z-index: 70; background: rgba(139, 92, 246, .18); display: grid; place-items: center; pointer-events: none; }
.dropping div { background: var(--surface); border: 3px dashed var(--accent); border-radius: 24px; padding: 30px 50px; font: 600 24px 'Fredoka', sans-serif; }

.status { display: flex; gap: 16px; align-items: center; padding: 6px 16px; background: var(--surface); border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); font-weight: 700; }
.status .grow { flex: 1; }
.modal { position: fixed; inset: 0; background: rgba(10, 5, 30, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-box { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 22px 24px; width: min(640px, 100%); box-shadow: var(--shadow); max-height: 88vh; overflow: auto; }
.modal-box h2 { margin-bottom: 8px; }
.modal-box input:not([type=color]), .modal-box select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.sig-tabs { display: flex; gap: 6px; margin: 6px 0 10px; }
.sig-tabs button.on { border-color: var(--accent); background: var(--glow); }
.sig-pad { width: 100%; height: 190px; background: #fff; border: 2px dashed var(--line); border-radius: 14px; touch-action: none; cursor: crosshair; display: block; }
.sig-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.sig-row .ink { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); padding: 0; }
.sig-row .ink.on { box-shadow: 0 0 0 2px var(--accent); }
.sig-saved { display: flex; gap: 10px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; margin-bottom: 10px; }
.sig-saved img { height: 46px; background: #fff; border-radius: 8px; padding: 2px 8px; }
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.info-grid b { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%) translateY(140px); background: var(--sidebar); color: var(--sidebar-text); padding: 10px 18px; border-radius: 14px; font-weight: 800; transition: transform .25s; z-index: 80; max-width: 80vw; }
.toast.show { transform: translateX(-50%) translateY(0); }
.print-area { display: none; }
@media print {
  @page { margin: 0; }
  body { display: block; overflow: visible; background: #fff; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block; }
  .print-area img { display: block; width: 100%; break-after: page; }
}
