:root {
  --ink: #111;
  --paper: #fff;
  --line: #d8d8d8;
  --soft: #f5f5f5;
  --accent: #2563eb;
  --red: #c62828;
}

body { background: #fff; color: #111; font-family: Arial, Helvetica, sans-serif; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; background: #111; color: #fff; border-radius: 6px; }
.skip-link:focus { top: 12px; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #60a5fa; outline-offset: 2px; }
button:disabled { opacity: .45; cursor: not-allowed; }
header { height: 56px; padding: 0 20px; border-bottom: 1px solid #ddd; background: #fff; }
.brand { font-size: 16px; font-weight: 700; letter-spacing: 0; }
.theme-toggle { margin-left: 8px; padding: 6px 9px; border: 1px solid #ccc; border-radius: 5px; background: #fff; color: #111; font-size: 12px; cursor: pointer; }
.promise { gap: 16px; color: #666; font-size: 12px; letter-spacing: 0; text-transform: none; }
.promise b, .promise span { background: none; padding: 0; border-radius: 0; }

.welcome { min-height: calc(100vh - 56px); padding: 32px 20px; }
.welcome h1 { margin: 0; font: 700 clamp(34px, 5vw, 48px)/1.15 Arial, sans-serif; letter-spacing: -1.5px; }
.welcome h1 em { color: inherit; font-style: normal; }
.eyebrow { display: none; }
.lede { max-width: 520px; margin: 14px auto 28px; color: #555; font-size: 16px; line-height: 1.5; }
.upload { width: min(460px, 100%); padding: 28px; border: 1px solid #bbb; border-radius: 8px; box-shadow: none; }
.upload:hover, .upload.drag { border-color: #111; transform: none; box-shadow: none; }
.upload-icon { width: 36px; height: 36px; border-radius: 6px; background: #eee; font-size: 24px; }
.upload strong { font-size: 16px; }
.upload small { color: #777; }
.upload-status { color: #555; }
.fineprint { margin-top: 4px; color: #777; font-size: 12px; letter-spacing: 0; text-transform: none; }
.privacy-note { max-width: 560px; margin: 16px auto 0; color: #555; font-size: 13px; line-height: 1.5; }

.editor { height: calc(100vh - 56px); }
.toolbar { min-height: 64px; height: auto; padding: 10px 16px; gap: 12px; background: #fff; border-bottom: 1px solid #ddd; }
.file-info { width: 200px; }
.file-info strong { font-size: 14px; }
.file-info small { font-size: 12px; }
.tools { gap: 6px; }
.extra-tools { display: flex; gap: 4px; }
.more-tools { display: flex; flex-wrap: wrap; gap: 4px; }
.more-tools button { padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; background: #fff; color: #111; cursor: pointer; font-size: 12px; }
.extra-tools input { width: 120px; padding: 8px; border: 1px solid #ccc; border-radius: 6px; }
.extra-tools button { padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; background: #fff; cursor: pointer; }
.pdf-text-item.search-hit { outline: 2px solid #f59e0b !important; background: rgba(250, 204, 21, .32) !important; }
.selection-box { position: absolute; z-index: 12; border: 1px solid #2563eb; background: rgba(37,99,235,.12); pointer-events: none; }
.pdf-text-item.multi-selected, .added-text.multi-selected, .pdf-line-item.multi-selected { outline: 2px solid #2563eb !important; outline-offset: 2px; background-color: rgba(37,99,235,.12) !important; }
.added-text { pointer-events: auto; cursor: move; }
.pdf-line-item { position: absolute; z-index: 4; pointer-events: auto; cursor: move; border: 1px solid transparent; transform-origin: left center; }
.pdf-line-item:hover { border-color: #2563eb; background: rgba(37,99,235,.1); }
.tools button, .page-nav button { border: 1px solid #ccc; border-radius: 6px; padding: 9px 11px; background: #fff; color: #111; }
.tools button:hover { background: #f5f5f5; }
.tools button.active { border-color: #111; background: #111; color: #fff; }
.download { padding: 10px 14px; border: 0; border-radius: 6px; background: #2563eb; color: #fff; }
.save-link { color: #fff; }
.workspace { height: calc(100% - 64px); background: #eee; }
aside { width: 130px; padding: 16px 12px; background: #fafafa; border-right: 1px solid #ddd; }
.thumb canvas { border: 2px solid transparent; box-shadow: 0 1px 4px #0002; }
.thumb.active canvas { border-color: #2563eb; }
.stage { padding: 24px 12px; }
.canvas-wrap { box-shadow: 0 2px 12px #0002; }
.page-nav { border-radius: 6px; background: #fff; color: #111; border: 1px solid #ccc; }
.text-card { border-radius: 8px; }
#toast { border-radius: 6px; background: #111; }
.busy-status { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; gap: 12px; background: rgba(255,255,255,.82); color: #111; font-weight: 700; backdrop-filter: blur(2px); }
.busy-status[hidden] { display: none; }
.spinner { width: 24px; height: 24px; border: 3px solid #bbb; border-top-color: #2563eb; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  header { padding: 0 14px; }
  .promise { display: none; }
  .editor { height: auto; min-height: calc(100vh - 56px); }
  .toolbar { position: sticky; top: 0; z-index: 10; padding: 8px; align-items: stretch; flex-direction: column; }
  .file-info { width: 100%; }
  .tools, .more-tools { width: 100%; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding-bottom: 4px; }
  .tools button, .more-tools button { flex: 0 0 auto; min-height: 44px; }
  .extra-tools { width: 100%; }
  .extra-tools input { width: 100%; min-height: 44px; }
  .download { width: 100%; min-height: 46px; }
  .workspace { height: auto; min-height: 65vh; }
  .stage { width: 100%; padding: 14px 8px; overflow: auto; }
  .canvas-wrap { max-width: none; }
}

body.night { background: #18181b; color: #f4f4f5; }
body.night header, body.night .toolbar { background: #18181b; border-color: #3f3f46; }

.crop-box,.shape-preview{position:absolute;border:2px solid #2563eb;background:#2563eb14;pointer-events:none;z-index:8}
.crop-box::before{content:"Crop area";position:absolute;left:-2px;top:-24px;background:#2563eb;color:#fff;padding:3px 7px;border-radius:4px;font:12px/1.2 Arial,sans-serif}
.shape-item{position:absolute;pointer-events:auto;z-index:6;cursor:move}
.shape-item.rectangle{border:3px solid #e1452f;background:transparent}
.shape-item.arrow{height:3px;background:#e1452f;transform-origin:left center}
.shape-item.arrow::after{content:"";position:absolute;right:-2px;top:-5px;border-left:10px solid #e1452f;border-top:6px solid transparent;border-bottom:6px solid transparent}
.toolbar button.mode-on{background:#111;color:#fff}
.canvas-wrap.snap-grid::after{content:"";position:absolute;inset:0;z-index:5;pointer-events:none;background-image:linear-gradient(to right,#2563eb30 1px,transparent 1px),linear-gradient(to bottom,#2563eb30 1px,transparent 1px);background-size:10px 10px}
body.night .brand, body.night .file-info strong, body.night .tools button, body.night .page-nav, body.night .text-card { color: #f4f4f5; }
body.night .promise, body.night .lede, body.night .fineprint, body.night .file-info small, body.night .upload-status { color: #b4b4bc; }
body.night .theme-toggle, body.night .tools button, body.night .page-nav button, body.night .text-card button { background: #27272a; border-color: #52525b; color: #f4f4f5; }
body.night .extra-tools input, body.night .extra-tools button { background: #27272a; border-color: #52525b; color: #f4f4f5; }
body.night .more-tools button { background: #27272a; border-color: #52525b; color: #f4f4f5; }
body.night .tools button:hover { background: #3f3f46; }
body.night .tools button.active { background: #f4f4f5; border-color: #f4f4f5; color: #18181b; }
body.night .welcome, body.night .upload, body.night .text-card, body.night .page-nav { background: #18181b; }
body.night .upload { border-color: #71717a; }
body.night .upload-icon { background: #3f3f46; }
body.night .workspace { background: #27272a; }
body.night aside { background: #202023; border-color: #3f3f46; }
body.night .canvas-wrap { box-shadow: 0 2px 12px #0008; }
body.night .download { background: #3b82f6; color: white; }
body.night .save-link { color: white; }
body.night .privacy-note { color: #b4b4bc; }
body.night .busy-status { background: rgba(24,24,27,.86); color: #f4f4f5; }
