/* BitFlow Tools – tool interface styles (theme-agnostic, uses theme tokens with fallbacks) */
.bf-tool-ui { --_p: var(--bf-purple, #5B21E8); --_n: var(--bf-navy, #101B4D); --_m: var(--bf-muted, #5F6788); --_b: var(--bf-border, #E7E9F3); --_soft: var(--bf-bg-soft, #F6F7FC); --_r: var(--bf-radius, 16px); background: #fff; border: 1px solid var(--_b); border-radius: calc(var(--_r) + 8px); box-shadow: var(--bf-shadow-lg, 0 16px 48px rgba(16,27,77,.12)); padding: 28px; }
@media (max-width: 560px) { .bf-tool-ui { padding: 18px; } }

/* Drop zone */
.bf-dropzone { border: 2px dashed #CFC6FF; border-radius: var(--_r); padding: 44px 24px; text-align: center; background: linear-gradient(180deg, #FBFAFF, #F6F3FF); cursor: pointer; transition: all .2s; outline: none; }
.bf-dropzone:hover, .bf-dropzone:focus-visible, .bf-dropzone.is-dragover { border-color: var(--_p); background: #F3EEFF; box-shadow: 0 0 0 4px rgba(91,33,232,.12); }
.bf-dropzone .bf-icon-box { margin: 0 auto 14px; background: var(--_p); color: #fff; }
.bf-dropzone-title { font-size: 1.25rem; margin: 0 0 4px; color: var(--_n); }
.bf-dropzone-text { margin: 0; color: var(--_m); }
.bf-dropzone-link { color: var(--_p); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.bf-dropzone-meta { margin: 12px 0 0; font-size: .8rem; color: #8A90AD; }
.bf-dropzone.is-hidden { display: none; }

/* File list */
.bf-file-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.bf-file-list:empty { display: none; }
.bf-file-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--_b); border-radius: 12px; background: var(--_soft); }
.bf-file-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #fff; border: 1px solid var(--_b); flex: none; display: flex; align-items: center; justify-content: center; color: var(--_p); }
.bf-file-thumb svg { width: 20px; height: 20px; }
.bf-file-name { flex: 1; min-width: 0; font-weight: 600; font-size: .9rem; color: var(--_n); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bf-file-size { font-size: .78rem; color: var(--_m); }
.bf-file-remove { border: 0; background: transparent; color: #8A90AD; width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.bf-file-remove:hover { background: #FEE7E7; color: #EF4444; }
.bf-file-remove svg { width: 14px; height: 14px; }
.bf-file-add { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 700; color: var(--_p); background: none; border: 0; cursor: pointer; padding: 6px 0; }

/* Options */
.bf-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-top: 18px; padding: 18px; border-radius: 12px; background: var(--_soft); }
.bf-option label { display: block; font-weight: 600; font-size: .85rem; color: var(--_n); margin-bottom: 6px; }
.bf-option output { float: right; color: var(--_p); }
.bf-option input[type="number"], .bf-option select { width: 100%; padding: 9px 12px; border: 1.5px solid var(--_b); border-radius: 10px; background: #fff; font-size: .92rem; }
.bf-option input[type="number"]:focus, .bf-option select:focus { border-color: var(--_p); outline: none; }
.bf-option input[type="range"] { width: 100%; accent-color: var(--_p); }
.bf-option--range { grid-column: 1 / -1; }
.bf-option--checkbox label { display: flex; align-items: center; gap: 8px; margin-top: 24px; }
.bf-option--checkbox input { accent-color: var(--_p); width: 18px; height: 18px; }

/* Actions & progress */
.bf-tool-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.bf-progress { margin-top: 16px; }
.bf-progress-bar { height: 10px; border-radius: 6px; background: #ECE8FF; overflow: hidden; }
.bf-progress-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--_p), #D946EF, #FF8A00); border-radius: 6px; transition: width .2s; }
.bf-progress-bar.is-indeterminate span { width: 40%; animation: bfSlide 1.2s ease-in-out infinite; }
@keyframes bfSlide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.bf-progress-text { margin: 8px 0 0; font-size: .88rem; color: var(--_m); }
.bf-tool-error { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; background: #FEE7E7; color: #B91C1C; font-size: .9rem; border: 1px solid #FECACA; }
.bf-tool-privacy { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; font-size: .8rem; color: #8A90AD; }
.bf-tool-privacy svg { width: 16px; height: 16px; color: #10B981; flex: none; }

/* Results */
.bf-results { margin-top: 18px; padding: 18px; border-radius: 14px; background: #ECFDF5; border: 1px solid #A7F3D0; }
.bf-results h3 { margin: 0 0 12px; font-size: 1.05rem; color: #065F46; display: flex; align-items: center; gap: 8px; }
.bf-results h3 svg { width: 20px; height: 20px; }
.bf-result-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: #fff; border-radius: 10px; border: 1px solid #D1FAE5; margin-bottom: 8px; flex-wrap: wrap; }
.bf-result-item .bf-file-name { flex: 1 1 200px; }
.bf-result-saved { font-size: .78rem; font-weight: 700; color: #059669; background: #D1FAE5; padding: 3px 10px; border-radius: 999px; }
.bf-result-item .btn { padding: 8px 16px; font-size: .85rem; }
.bf-results-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; font-size: .8rem; color: #047857; }
.bf-result-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid #D1FAE5; }

/* Coming soon */
.bf-tool-soon { text-align: center; padding: 30px 10px; }
.bf-tool-soon .bf-icon-box { margin: 0 auto 14px; background: #FFF3E0; color: #FF8A00; }
.bf-tool-soon h2 { font-size: 1.4rem; margin: 0 0 8px; }
.bf-tool-soon p { color: var(--_m); max-width: 520px; margin: 0 auto 10px; }
.bf-tool-soon-meta { font-size: .85rem; color: #8A90AD !important; margin-bottom: 20px !important; }

/* Crop stage */
.bf-crop-stage { margin-top: 16px; }
.bf-crop-wrap { position: relative; display: inline-block; max-width: 100%; user-select: none; touch-action: none; background: repeating-conic-gradient(#EEE 0 25%, #fff 0 50%) 0 0 / 16px 16px; border-radius: 10px; overflow: hidden; }
.bf-crop-img { display: block; max-width: 100%; max-height: 480px; width: auto; height: auto; pointer-events: none; }
.bf-crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(16,27,77,.5); cursor: move; box-sizing: border-box; }
.bf-crop-box::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to right, transparent 33.3%, rgba(255,255,255,.35) 33.3%, rgba(255,255,255,.35) calc(33.3% + 1px), transparent calc(33.3% + 1px), transparent 66.6%, rgba(255,255,255,.35) 66.6%, rgba(255,255,255,.35) calc(66.6% + 1px), transparent calc(66.6% + 1px)), linear-gradient(to bottom, transparent 33.3%, rgba(255,255,255,.35) 33.3%, rgba(255,255,255,.35) calc(33.3% + 1px), transparent calc(33.3% + 1px), transparent 66.6%, rgba(255,255,255,.35) 66.6%, rgba(255,255,255,.35) calc(66.6% + 1px), transparent calc(66.6% + 1px)); pointer-events: none; }
.bf-crop-handle { position: absolute; right: -8px; bottom: -8px; width: 18px; height: 18px; border-radius: 50%; background: var(--_p); border: 2px solid #fff; cursor: nwse-resize; }
.bf-crop-hint { font-size: .82rem; color: var(--_m); margin: 8px 0 0; }

/* Client-side tools */
.bf-client-tool { display: grid; gap: 16px; }
.bf-client-tool textarea, .bf-client-tool input[type="text"], .bf-client-tool input[type="number"], .bf-client-tool input[type="url"], .bf-client-tool select { width: 100%; padding: 12px 14px; border: 1.5px solid var(--_b); border-radius: 12px; font-size: .95rem; background: #fff; font-family: inherit; }
.bf-client-tool textarea { min-height: 180px; resize: vertical; }
.bf-client-tool textarea:focus, .bf-client-tool input:focus, .bf-client-tool select:focus { border-color: var(--_p); outline: none; box-shadow: 0 0 0 4px rgba(91,33,232,.12); }
.bf-client-tool label { font-weight: 600; font-size: .86rem; color: var(--_n); display: block; margin-bottom: 6px; }
.bf-client-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: end; }
.bf-client-row .bf-swap { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--_b); background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--_p); margin-bottom: 2px; }
.bf-client-row .bf-swap svg { width: 18px; height: 18px; }
@media (max-width: 560px) { .bf-client-row { grid-template-columns: 1fr; } .bf-client-row .bf-swap { justify-self: center; } }
.bf-client-result { padding: 18px; border-radius: 14px; background: linear-gradient(135deg, #F3EEFF, #FFF3E0); font-size: 1.4rem; font-weight: 800; color: var(--_n); word-break: break-word; }
.bf-client-result small { display: block; font-size: .8rem; font-weight: 500; color: var(--_m); margin-top: 4px; }
.bf-client-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.bf-client-buttons .bf-chip { cursor: pointer; }
.bf-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.bf-stat-box { padding: 14px; border-radius: 12px; background: var(--_soft); text-align: center; }
.bf-stat-box strong { display: block; font-size: 1.5rem; color: var(--_p); line-height: 1.1; }
.bf-stat-box span { font-size: .75rem; color: var(--_m); text-transform: uppercase; letter-spacing: .06em; }
.bf-keywords { display: flex; flex-wrap: wrap; gap: 6px; }
.bf-keywords span { font-size: .78rem; padding: 4px 10px; border-radius: 999px; background: var(--_soft); color: var(--_n); }
.bf-qr-layout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 700px) { .bf-qr-layout { grid-template-columns: 1fr; } }
.bf-qr-preview { text-align: center; padding: 20px; border-radius: 14px; background: var(--_soft); }
.bf-qr-preview canvas, .bf-qr-preview img, .bf-qr-preview svg { max-width: 100%; height: auto; margin: 0 auto; background: #fff; border-radius: 10px; }
.bf-qr-colors { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bf-qr-colors input[type="color"] { width: 100%; height: 42px; border: 1.5px solid var(--_b); border-radius: 10px; padding: 3px; background: #fff; }
.bf-client-tool .btn.is-copied { background: #10B981; box-shadow: none; }
