
.tool-card,.tool-box{
  background:#fff;border:1px solid var(--line);border-radius:20px;box-shadow:var(--shadow);
  padding:24px;margin:18px 0 24px
}
.tool-card[data-tool-id]{display:block;min-height:0;height:auto}
.tool-card label,.tool-box label{display:block;font-weight:800;margin:10px 0 6px}
.tool-card input[type="text"],.tool-card input[type="url"],.tool-card input[type="number"],.tool-card input[type="search"],
.tool-card input[type="file"],.tool-card textarea,.tool-card select,
.tool-box input[type="text"],.tool-box input[type="url"],.tool-box input[type="number"],.tool-box input[type="search"],
.tool-box input[type="file"],.tool-box textarea,.tool-box select{
 width:100%;max-width:100%;border:1px solid #d6dde8;border-radius:12px;padding:12px 14px;
 font:inherit;background:#fff;color:var(--text);margin:4px 0 12px;outline:none
}
.tool-card input:focus,.tool-card textarea:focus,.tool-card select:focus,
.tool-box input:focus,.tool-box textarea:focus,.tool-box select:focus{
 border-color:#7ba6ff;box-shadow:0 0 0 3px rgba(37,99,235,.12)
}
.tool-card input[type="checkbox"],.tool-card input[type="range"],
.tool-box input[type="checkbox"],.tool-box input[type="range"]{width:auto}
.tool-card button,.tool-box button,.button{
 appearance:none;border:0;border-radius:12px;padding:11px 16px;min-height:44px;
 font:inherit;font-weight:800;cursor:pointer;background:var(--primary);color:#fff;text-decoration:none;
 display:inline-flex;align-items:center;justify-content:center;margin:6px 6px 6px 0;
 min-width:8rem;white-space:normal;word-break:keep-all;
 transition:background .15s ease,transform .15s ease
}
.tool-card button:hover,.tool-box button:hover,.button:hover{background:var(--primary-2);text-decoration:none}
.tool-card button:active,.tool-box button:active,.button:active{transform:translateY(1px)}
.tool-card button.secondary,.tool-box button.secondary{background:#e9eef6;color:#2f3b51}
.tool-card #status,.tool-card .status,.tool-box #status,.tool-box .status{margin-top:12px;color:var(--muted);font-weight:700}
.tool-card table,.tool-box table{width:100%;border-collapse:collapse;margin-top:14px}
.tool-card th,.tool-card td,.tool-box th,.tool-box td{border:1px solid var(--line);padding:10px;text-align:left;vertical-align:top}
.tool-card img,.tool-box img{border-radius:12px;border:1px solid var(--line)}
.drop-zone{
 border:2px dashed #cbd5e1;border-radius:16px;padding:22px;text-align:center;background:#fafcff;margin-bottom:14px
}
.result-box,#result:not(:empty){
 margin-top:16px;padding:16px;border:1px solid var(--line);border-radius:14px;background:#fbfdff
}
.download-grid{display:flex;flex-wrap:wrap;gap:12px;align-items:stretch}
.download-grid .button{width:auto;margin:0}
.download-item{display:flex;flex-direction:column;gap:10px;width:min(220px,100%);padding:12px;border:1px solid var(--line);border-radius:14px;background:#fff}
.download-item img{display:block;width:100%;height:auto;aspect-ratio:3/4;object-fit:contain;background:#f1f5f9}
.download-item .button{width:100%}
.crop-editor{margin:16px 0}
.crop-stage{position:relative;display:inline-block;max-width:100%;line-height:0;overflow:hidden;border-radius:14px;background:#e2e8f0;touch-action:none;user-select:none}
.crop-stage canvas{display:block;max-width:100%;max-height:62vh;width:auto;height:auto;border:0;border-radius:0}
.crop-selection{position:absolute;box-sizing:border-box;border:3px solid #2563eb;background:rgba(37,99,235,.12);box-shadow:0 0 0 9999px rgba(15,23,42,.48);cursor:move;touch-action:none}
.crop-selection:focus-visible{outline:3px solid #fbbf24;outline-offset:2px}
.crop-handle{position:absolute;width:18px;height:18px;border:3px solid #fff;border-radius:50%;background:#2563eb;box-shadow:0 1px 4px rgba(15,23,42,.35)}
.crop-handle.nw{left:-11px;top:-11px;cursor:nwse-resize}.crop-handle.ne{right:-11px;top:-11px;cursor:nesw-resize}
.crop-handle.sw{left:-11px;bottom:-11px;cursor:nesw-resize}.crop-handle.se{right:-11px;bottom:-11px;cursor:nwse-resize}
@media(max-width:700px){
 .tool-card,.tool-box{padding:16px}
 .tool-card button,.tool-box button,.button{width:100%;margin-right:0}
 .download-grid{display:grid;grid-template-columns:1fr}
 .download-item{width:100%;box-sizing:border-box}
}

/* v4 unified tool UI */
:root{
  --tool-primary:#2563eb;--tool-primary-hover:#1d4ed8;--tool-accent:#0f766e;
  --tool-accent-hover:#115e59;--tool-neutral:#eef2f7;--tool-neutral-hover:#e2e8f0;
  --tool-danger:#dc2626;--tool-danger-hover:#b91c1c;--tool-success:#15803d;--tool-error:#b91c1c;
  --tool-focus:rgba(37,99,235,.18)
}
.tool-page{overflow-x:hidden}
.tool-page .tool-box{font-size:16px}
.tool-page .field>label,.tool-page label{font-size:14px;line-height:1.5}
.tool-page input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
.tool-page select,.tool-page textarea{
  box-sizing:border-box;width:100%;max-width:100%;min-height:46px;border:1px solid #cbd5e1;border-radius:12px;
  padding:11px 13px;background:#fff;color:var(--text);font:inherit;line-height:1.5;transition:border-color .15s,box-shadow .15s,background .15s
}
.tool-page textarea{min-height:120px;resize:vertical}
.tool-page input:hover,.tool-page select:hover,.tool-page textarea:hover{border-color:#94a3b8}
.tool-page input:focus-visible,.tool-page select:focus-visible,.tool-page textarea:focus-visible,
.tool-page button:focus-visible,.tool-page .drop-zone:focus-visible{
  outline:3px solid var(--tool-focus);outline-offset:2px;border-color:#60a5fa
}
.tool-page button,.tool-page .btn,.tool-page .button{
  box-sizing:border-box;min-height:46px;border:1px solid transparent;border-radius:12px;padding:11px 16px;
  display:inline-flex;align-items:center;justify-content:center;gap:.45em;font:inherit;font-weight:800;line-height:1.25;
  text-align:center;text-decoration:none;white-space:nowrap;word-break:keep-all;overflow-wrap:normal;cursor:pointer;
  transition:background .15s,border-color .15s,color .15s,box-shadow .15s,transform .05s;vertical-align:middle
}
.tool-page button.action-primary,.tool-page .btn.primary,.tool-page button:not(.action-secondary):not(.action-reset):not(.action-danger){background:var(--tool-primary);color:#fff}
.tool-page button.action-primary:hover,.tool-page .btn.primary:hover,.tool-page button:not(.action-secondary):not(.action-reset):not(.action-danger):hover{background:var(--tool-primary-hover)}
.tool-page button.action-secondary{background:#ecfdf5;color:#065f46;border-color:#a7f3d0}
.tool-page button.action-secondary:hover{background:#d1fae5;border-color:#6ee7b7}
.tool-page button.action-reset{background:var(--tool-neutral);color:#334155;border-color:#dbe3ed}
.tool-page button.action-reset:hover{background:var(--tool-neutral-hover)}
.tool-page button.action-danger{background:var(--tool-danger);color:#fff}
.tool-page button.action-danger:hover{background:var(--tool-danger-hover)}
.tool-page button:disabled,.tool-page .btn:disabled{opacity:.5;cursor:not-allowed;transform:none;filter:saturate(.45)}
.tool-page button[aria-busy="true"],.tool-page .is-loading{cursor:progress;opacity:.78}
.tool-page .actions{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin-top:14px}
.tool-page .actions button{margin:0;min-width:0}
.tool-page .drop-zone{
  box-sizing:border-box;width:100%;border:2px dashed #94a3b8;border-radius:16px;padding:24px 18px;text-align:center;
  background:#f8fbff;transition:border-color .15s,background .15s,box-shadow .15s
}
.tool-page .drop-zone:hover,.tool-page .drop-zone.dragover{border-color:#2563eb;background:#eff6ff;box-shadow:0 0 0 4px rgba(37,99,235,.08)}
.tool-page .result-box,.tool-page [data-result-box]{box-sizing:border-box;max-width:100%;overflow-wrap:anywhere;background:#f8fafc;border:1px solid #dbe3ed;border-radius:14px;padding:16px}
.tool-page .notice.ok,.tool-page .state-success{border-color:#86efac;background:#f0fdf4;color:#166534}
.tool-page .notice.err,.tool-page .state-error{border-color:#fecaca;background:#fef2f2;color:#991b1b}
.tool-page .notice.warn,.tool-page .state-warning{border-color:#fde68a;background:#fffbeb;color:#92400e}
.tool-page .tool-row{align-items:start}
.tool-page .tool-row>*{min-width:0}
.tool-page img,.tool-page canvas{max-width:100%;height:auto}
.tool-page input[type="color"]{width:54px;height:46px;padding:4px;border:1px solid #cbd5e1;border-radius:10px;background:#fff;cursor:pointer}
.tool-page input[type="range"]{width:100%}

/* QR designer */
.qr-presets{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0 18px}
.qr-presets button{background:#f8fafc!important;color:#334155!important;border:1px solid #cbd5e1!important;min-height:40px!important;padding:8px 12px!important}
.qr-presets button[aria-pressed="true"]{background:#dbeafe!important;color:#1d4ed8!important;border-color:#93c5fd!important;box-shadow:inset 0 0 0 1px #93c5fd}
.qr-settings-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.qr-color-pair{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.qr-color-field{display:grid;grid-template-columns:54px 1fr;gap:8px;align-items:end}
.qr-color-field input[type="text"]{margin:0!important}
.qr-preview{min-height:320px;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:12px;padding:18px;border:1px solid #dbe3ed;border-radius:18px;background:linear-gradient(180deg,#fff,#f8fafc)}
.qr-preview canvas{background:#fff;border:0;border-radius:12px;box-shadow:0 10px 24px rgba(15,23,42,.08)}
.qr-help{font-size:13px;color:#64748b;line-height:1.65}
.qr-mark-upload{display:none}
.qr-status-stack{display:grid;gap:8px;margin-top:12px}
.qr-inline{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.qr-range-value{font-weight:800;min-width:3.5em;text-align:right}
@media(max-width:700px){
  .tool-page .actions{display:grid;grid-template-columns:1fr;width:100%}
  .tool-page .actions button,.tool-page .actions .btn,.tool-page .actions .button{width:100%;white-space:normal}
  .qr-settings-grid,.qr-color-pair{grid-template-columns:1fr}
  .qr-preview{min-height:280px;padding:12px}
  .qr-presets{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
  .qr-presets button{width:100%;white-space:normal}
}

/* v5 privacy / selected-file guidance */
.local-processing-note{display:flex;gap:12px;align-items:flex-start;margin:12px 0 16px;padding:13px 14px;border:1px solid #bfdbfe;border-radius:14px;background:#eff6ff;color:#1e3a5f;line-height:1.55}
.local-processing-note strong{display:block;font-size:14px;margin-bottom:2px}.local-processing-note span:not(.local-processing-icon){display:block;font-size:13px;color:#475569}.local-processing-icon{font-size:20px;line-height:1.3}
.selected-file-info{margin:6px 0 10px;font-size:13px;color:#475569;overflow-wrap:anywhere}.selected-file-info.is-warning{padding:9px 10px;border-radius:10px;background:#fffbeb;color:#92400e;border:1px solid #fde68a}
@media(max-width:700px){.local-processing-note{padding:12px}.local-processing-note strong{font-size:14px}}

/* v6: QR center-image drag & drop */
.qr-mark-dropzone{padding:16px;min-height:132px;margin-top:6px}
.qr-mark-dropzone input[type="file"]{margin:8px 0 4px}
