/* Toolshed — app styles on top of the kit design system (core.css).
   Tokens only. Dynamic colours (page-crop overlays) go through CSSOM. */

:root { --mark-bg: var(--ochre); }

/* ── shared tool scaffolding ── */
.ts-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ts-bar .grow { flex: 1; }
.ts-note { font-size: 12.5px; color: var(--ink-3); }
.ts-files { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: thin; }
.ts-file { position: relative; flex: none; width: 96px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); overflow: hidden; cursor: pointer; }
.ts-file img, .ts-file .ph { display: block; width: 100%; height: 68px; object-fit: cover; background: var(--paper-2); }
.ts-file .ph { display: grid; place-items: center; color: var(--ink-3); }
.ts-file[aria-current="true"] { border-color: var(--ochre); box-shadow: 0 0 0 2px var(--ochre-soft); }
.ts-file .x { position: absolute; top: 3px; inset-inline-end: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; }
.ts-file .x .icon { width: 12px; height: 12px; }
.ts-file figcaption { font-size: 11px; color: var(--ink-3); padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── scan workspace ── */
.ts-stage { position: relative; border: 1px solid var(--line); border-radius: 16px; background: var(--paper-2); overflow: hidden; min-height: 300px; display: grid; place-items: center; }
.ts-stage canvas { max-width: 100%; display: block; }
.ts-stage .empty { padding: 48px 20px; text-align: center; color: var(--ink-3); }
.ts-crop { position: absolute; inset: 0; touch-action: none; }
.ts-crop:focus-visible { outline: 2px solid var(--ochre); outline-offset: -2px; }
.ts-hint { position: absolute; top: 10px; inset-inline-start: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 12px; color: var(--ink-2); box-shadow: var(--shadow-sm); pointer-events: none; }
.ts-status { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.ts-status .icon { width: 14px; height: 14px; }
.ts-status.busy .icon { animation: spin 1s linear infinite; }
.ts-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 14px; align-items: center; }
.ts-check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); cursor: pointer; }

/* camera drawer */
.ts-cam { display: grid; gap: 10px; }
.ts-cam video { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 4 / 3; object-fit: cover; } /* frontend-ok: video letterbox */

/* ── converter ── */
.ts-drop { border: 1.5px dashed var(--line-2); border-radius: 16px; padding: 26px 18px; text-align: center; color: var(--ink-3); cursor: pointer; }
.ts-drop:hover, .ts-drop.over { border-color: var(--ochre); color: var(--ink-2); background: var(--ochre-soft); }
.ts-conv { display: grid; gap: 8px; }
.ts-job { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); flex-wrap: wrap; }
.ts-job .nm { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }
.ts-job .meta { font-size: 12px; color: var(--ink-3); }
.ts-job .grow { flex: 1; min-width: 120px; }
.ts-job.ok { border-color: var(--moss-line); }
.ts-job.err { border-color: var(--rust-line); }

/* ── notebook ── */
.ts-nb-out { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); min-height: 320px; overflow: auto; }
.ts-paper { padding: 34px 38px 60px; max-width: 800px; margin: 0 auto; background: var(--surface); }
.ts-paper .page-title { font-size: 26px; }
.ts-paper .cell { margin-bottom: 18px; }
.ts-paper .cell-src { border-inline-start: 3px solid var(--ochre-line); padding: 2px 12px; margin-bottom: 8px; }
.ts-paper .cell-out { border-inline-start: 3px solid var(--line-2); padding: 2px 12px; }
.ts-paper pre { overflow-x: auto; font-size: 12.5px; line-height: 1.55; }
.ts-paper code, .ts-paper pre { font-family: var(--font-mono); }
.ts-err { border: 1px solid var(--rust-line); background: var(--rust-soft); color: var(--rust); border-radius: 10px; padding: 8px 12px; font-size: 12.5px; overflow-x: auto; }
.tok-kw { color: var(--clay); font-weight: 600; }
.tok-str { color: var(--moss); }
.tok-com { color: var(--ink-3); font-style: italic; }
.tok-num { color: var(--ochre-ink); }
.tok-dec { color: var(--slate); }

/* print: only the paper */
@media print { /* frontend-ok: paper is white and black whatever the theme */
  .ts-paper {
    color-scheme: light; --ink: #1c201a; --ink-2: #4b5147; --ink-3: #72776b; --line: #e1dbcd; --line-2: #cfc7b5; --surface: #fbfaf6; --code-bg: #efeadf;
    --moss: #3d5a3f; --clay: #b35f3a; --ochre: #9a6f18; --ochre-line: #e0cd98; --slate: #4a6271; --rust: #a13f2d; --rust-soft: #f5dcd5; --rust-line: #e7b7aa;
  }
  body { background: #fff; }
  .view, .site-nav, .site-footer, .toasts, .grain, .splash, .skip, .sidebar, .sb-top, .scrim, .top { display: none !important; }
  .ts-nb-out { border: 0; overflow: visible; }
  .ts-paper { max-width: none; padding: 0; background: #fff; color: #000; }
  #view-app { display: block !important; }
  .main { overflow: visible !important; }
}

/* ── transfer ── */
.ts-xfer { display: grid; gap: 14px; }
.ts-room { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.ts-code { font-size: 30px; letter-spacing: 0.14em; font-weight: 700; font-variant-numeric: tabular-nums; }
.ts-qr { width: 148px; height: 148px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; } /* frontend-ok: a QR code needs a white quiet zone */
.ts-qr canvas, .ts-qr img { width: 132px; height: 132px; image-rendering: pixelated; }
.ts-peer { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; }
.ts-peer .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); }
.ts-peer.on .dot { background: var(--moss); }
.ts-peer.me { border-color: var(--ochre-line); color: var(--ochre-ink); }
.ts-queue { display: grid; gap: 8px; }
.ts-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.ts-item .nm { font-weight: 600; font-size: 13.5px; word-break: break-all; }
.ts-item .meta { font-size: 12px; color: var(--ink-3); }
.ts-item .grow { flex: 1; min-width: 140px; }
.ts-item .progress { margin-top: 5px; }
.ts-item .progress > i { transition-duration: 0.25s; }
.ts-textlog { display: grid; gap: 6px; max-height: 180px; overflow: auto; }
.ts-textmsg { padding: 7px 11px; border-radius: 12px; background: var(--paper-2); font-size: 13px; word-break: break-word; }
.ts-textmsg.me { background: var(--ochre-soft); margin-inline-start: 12%; }
.ts-sendrow { display: flex; gap: 8px; }
.ts-sendrow input { flex: 1; }

/* ── collate (images → PDFs) ── */
.ts-comp { --col-w: 340px; --thumb-h: 210px; }
.ts-comp.sz-s { --col-w: 224px; --thumb-h: 148px; }
.ts-comp.sz-l { --col-w: 480px; --thumb-h: 300px; }
.ts-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.ts-hintline { margin: 0; }
.ts-comp .ts-cols { display: flex; align-items: flex-start; gap: 12px; overflow-x: auto; padding: 2px 2px 14px; min-height: 320px; }
.ts-col { flex: none; width: var(--col-w); border: 1px solid var(--line); border-radius: 16px; background: var(--paper-2); transition: border-color 0.15s var(--ease), background 0.15s var(--ease); }
.ts-col.ts-active { border-color: var(--ochre); }
.ts-col.ts-target { border-color: var(--ochre); background: var(--ochre-soft); }
.ts-colhead { display: flex; align-items: center; gap: 2px; padding: 7px 7px 7px 8px; border-bottom: 1px solid var(--line); }
.ts-colhead .icon-btn { opacity: 0.75; }
.ts-colname { font-weight: 600; font-size: 13.5px; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 6px; border-radius: 8px; }
.ts-colname:hover { background: var(--ochre-soft); }
.ts-colcount { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-inline-start: 2px; }
.ts-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px; min-height: 64px; }
.ts-card { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: grab; user-select: none; -webkit-user-select: none; touch-action: pan-y; transition: box-shadow 0.15s var(--ease), border-color 0.15s var(--ease); }
.ts-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.ts-card.sel { border-color: var(--ochre); box-shadow: 0 0 0 2px var(--ochre-soft); }
.ts-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.ts-thumb { position: relative; height: var(--thumb-h); border-bottom: 1px solid var(--line); background: var(--paper-2); border-radius: 11px 11px 0 0; overflow: hidden; display: grid; place-items: center; }
.ts-thumb img { max-width: calc(100% - 12px); max-height: calc(100% - 12px); transition: transform 0.15s var(--ease); }
.ts-card.bad .ts-thumb img { opacity: 0.3; }
.ts-idx { position: absolute; top: 5px; inset-inline-start: 5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); font-size: 11px; font-variant-numeric: tabular-nums; display: grid; place-items: center; color: var(--ink-3); }
.ts-bad { position: absolute; bottom: 6px; inset-inline-start: 6px; font-size: 11px; color: var(--rust); background: var(--rust-soft); padding: 2px 8px; border-radius: 999px; }
.ts-acts { position: absolute; top: 4px; inset-inline-end: 4px; display: none; gap: 2px; }
.ts-card:hover .ts-acts, .ts-card:focus-within .ts-acts { display: flex; }
.ts-acts .icon-btn { background: var(--surface); }
.ts-cap { padding: 6px 10px 8px; min-width: 0; }
.ts-nm { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-meta { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-colhint { margin: 0 10px 10px; display: flex; align-items: center; justify-content: center; gap: 6px; border: 1.5px dashed var(--line-2); border-radius: 12px; padding: 16px 8px; color: var(--ink-3); font-size: 12.5px; }
.ts-colhint:hover { border-color: var(--ochre); color: var(--ink-2); background: var(--ochre-soft); }
.ts-colhint .icon { width: 14px; height: 14px; }
.ts-board-empty { min-height: 280px; display: grid; place-content: center; gap: 6px; }
.ts-board-empty .icon { width: 30px; height: 30px; color: var(--ink-3); margin: 0 auto; }
.ts-ph { border: 1.5px dashed var(--ochre); border-radius: 12px; background: var(--ochre-soft); animation: ts-pulse 1.1s var(--ease) infinite alternate; }
@keyframes ts-pulse { from { opacity: 0.55; } to { opacity: 1; } }
.ts-hidesrc { display: none; }
.ts-ghost { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--ochre-line); background: var(--surface); box-shadow: var(--shadow-md); font-size: 12.5px; font-weight: 600; }
.ts-ghost img { width: 44px; height: 32px; object-fit: cover; border-radius: 6px; }
.ts-ghost .icon { width: 16px; height: 16px; color: var(--ink-3); }
.ts-selbar { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-md); }
.ts-cols-pick { display: grid; gap: 6px; margin-top: 4px; }
.ts-veil { position: fixed; inset: 10px; z-index: 50; display: none; place-items: center; border: 2px dashed var(--ochre); border-radius: 20px; background: var(--ochre-soft); color: var(--ink-2); font-weight: 600; pointer-events: none; }
.ts-veil.on { display: grid; }
.ts-flip { transform: scaleX(-1); }
body.ts-dragging, body.ts-dragging .ts-card { cursor: grabbing; }
.ts-undo { align-items: center; }
.ts-undo .grow { flex: 1; text-align: start; }
.ts-undo .btn { margin-inline-start: 12px; flex: none; }
@media (hover: none) {
  .ts-acts { display: flex; }
  .ts-colhead .icon-btn { opacity: 1; }
}

/* ── preview lightbox ── */
.modal-card.ts-pv-modal { width: min(1080px, 94vw); }
.ts-pv-stage { position: relative; height: min(64vh, 620px); display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); overflow: hidden; }
.ts-pv-stage img { box-shadow: var(--shadow-md); }
.ts-pv-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.ts-pv-nav.prev { inset-inline-start: 12px; }
.ts-pv-nav.next { inset-inline-end: 12px; }
.ts-pv-bar { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* narrow screens */
@media (max-width: 720px) {
  .ts-paper { padding: 20px 16px 40px; }
  .ts-code { font-size: 24px; }
  .ts-qr { width: 124px; height: 124px; }
  .ts-col { width: min(var(--col-w), 66vw); }
}

.icon.spin, .icon-sm.spin { animation: spin 0.9s linear infinite; }
