/* ===================================
 * Juhetool Online Tools Engine Styles
 * Shared UI components for in-site tools
 * =================================== */

/* ===== Engine Container ===== */
.tool-engine-container {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.tool-engine-error,
.runtime-error {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-light);
    background: #fff;
    border: 1px dashed var(--color-border-dark);
    border-radius: var(--radius-md);
}
.runtime-error .btn { margin-top: 16px; }

/* ===== Tool Runtime Page ===== */
.tool-runtime-page { padding: 24px 0 48px; min-height: 70vh; }
.runtime-header {
    background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    margin-bottom: 24px;
}
.runtime-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.runtime-title {
    font-size: 1.625rem;
    font-weight: 800;
    color: var(--color-heading);
    margin: 0;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.runtime-actions { display: flex; gap: 8px; align-items: center; }
.runtime-subtitle {
    color: var(--color-text-light);
    margin-top: 8px;
    font-size: .9375rem;
}
.runtime-canvas {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: 0 4px 24px rgba(0,0,0,.04);
    min-height: 400px;
}

/* ===== Tool UI Form Elements ===== */
.tool-field { margin-bottom: 20px; }
.tool-field-label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}
.tool-field-hint {
    font-size: .75rem;
    color: var(--color-text-lighter);
    margin-top: 4px;
}
.tool-input,
.tool-textarea,
.tool-select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: .9375rem;
    font-family: var(--font-sans);
    background: #fff;
    color: var(--color-text);
    transition: var(--transition-fast);
}
.tool-input:focus,
.tool-textarea:focus,
.tool-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(79,70,229,.08);
}
.tool-textarea {
    font-family: var(--font-mono);
    min-height: 180px;
    resize: vertical;
    line-height: 1.5;
}
.tool-input-large { font-size: 1.125rem; padding: 14px 18px; }

/* ===== Tool Buttons ===== */
.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 1.5px solid transparent;
    background: var(--color-primary);
    color: #fff;
}
.tool-btn:hover { background: var(--color-primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79,70,229,.25); }
.tool-btn-secondary { background: #fff; color: var(--color-text); border-color: var(--color-border-dark); }
.tool-btn-secondary:hover { background: var(--color-bg-alt); border-color: var(--color-primary); color: var(--color-primary); box-shadow: none; }
.tool-btn-ghost { background: transparent; color: var(--color-text-light); }
.tool-btn-ghost:hover { background: var(--color-bg-alt); color: var(--color-text); box-shadow: none; transform: none; }
.tool-btn-danger { background: var(--color-danger); }
.tool-btn-danger:hover { background: #dc2626; }
.tool-btn-success { background: var(--color-success); }
.tool-btn-success:hover { background: #059669; }
.tool-btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.tool-btn-block { width: 100%; }

/* ===== Tool Output Area ===== */
.tool-output {
    margin-top: 24px;
    padding: 20px;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    min-height: 80px;
    position: relative;
}
.tool-output-label {
    font-size: .75rem;
    font-weight: 700;
    color: var(--color-text-lighter);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 8px;
}
.tool-output-content {
    font-family: var(--font-mono);
    font-size: .875rem;
    color: var(--color-text);
    word-break: break-all;
    white-space: pre-wrap;
    line-height: 1.6;
}
.tool-output-content.is-error { color: var(--color-danger); }
.tool-output-content.is-success { color: var(--color-success); }
.tool-output-empty { color: var(--color-text-lighter); font-style: italic; }

/* ===== Tool Layout Grid ===== */
.tool-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tool-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tool-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.tool-row-end { justify-content: flex-end; }
.tool-row-between { justify-content: space-between; }

/* ===== Tool Tabs ===== */
.tool-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 20px;
    overflow-x: auto;
}
.tool-tab {
    padding: 10px 18px;
    background: transparent;
    color: var(--color-text-light);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition-fast);
    white-space: nowrap;
}
.tool-tab:hover { color: var(--color-primary); }
.tool-tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tool-tab-panel { display: none; }
.tool-tab-panel.active { display: block; }

/* ===== Tool Stats Display ===== */
.tool-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 16px;
}
.tool-stat-card {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
}
.tool-stat-label { font-size: .75rem; color: var(--color-text-lighter); margin-bottom: 4px; }
.tool-stat-value { font-size: 1.25rem; font-weight: 700; color: var(--color-primary); }

/* ===== Tool Code Box ===== */
.tool-code-box {
    background: #0f172a;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: .8125rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
}
.tool-code-box .json-key { color: #93c5fd; }
.tool-code-box .json-string { color: #86efac; }
.tool-code-box .json-number { color: #fbbf24; }
.tool-code-box .json-bool { color: #f9a8d4; }
.tool-code-box .json-null { color: #94a3b8; }

/* ===== Tool Copy Button ===== */
.tool-copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 6px 12px;
    background: rgba(255,255,255,.9);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: .75rem;
    color: var(--color-text-light);
    cursor: pointer;
    transition: var(--transition-fast);
}
.tool-copy-btn:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.tool-copy-btn.copied { background: var(--color-success); color: #fff; border-color: var(--color-success); }

/* ===== Inline Tool Section (within single-tool.php) ===== */
.tool-inline-section {
    background: linear-gradient(135deg, #eef2ff 0%, #f0f9ff 100%);
    border: 1px solid #c7d2fe;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: 24px 0;
}
.tool-inline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}
.tool-inline-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}
.tool-inline-title::before { content: '⚡'; font-size: 1.25rem; }
.tool-inline-link {
    font-size: .8125rem;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.tool-inline-link:hover { color: var(--color-primary-dark); }
.tool-inline-body {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--color-border);
}

/* ===== JSON -> Table ===== */
.jt-table {
    border-collapse: collapse;
    width: 100%;
    font-size: .875rem;
    margin-top: 4px;
}
.jt-table th,
.jt-table td {
    border: 1px solid var(--color-border);
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
    word-break: break-word;
}
.jt-table th {
    background: var(--color-bg-alt);
    font-weight: 700;
    color: var(--color-heading);
}
.jt-table tbody tr:nth-child(even) { background: #fafbff; }

/* ===== Color Swatch (color picker) ===== */
.tool-color-swatch {
    width: 100%;
    height: 80px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    margin-top: 8px;
    transition: var(--transition);
}

/* ===== QR Code Canvas ===== */
.tool-qr-canvas {
    background: #fff;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    display: inline-block;
}
.tool-qr-canvas canvas,
.tool-qr-canvas img { display: block; image-rendering: pixelated; }

/* ===== Image Tool Dropzone ===== */
.tool-dropzone {
    border: 2px dashed var(--color-border-dark);
    border-radius: var(--radius-md);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--color-bg-alt);
}
.tool-dropzone:hover,
.tool-dropzone.dragover {
    border-color: var(--color-primary);
    background: #eef2ff;
}
.tool-dropzone-icon { font-size: 2.5rem; margin-bottom: 8px; }
.tool-dropzone-text { color: var(--color-text-light); font-size: .875rem; }
.tool-dropzone-text strong { color: var(--color-primary); }

.tool-image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    display: block;
    margin: 12px 0;
}

/* ===== Range Slider ===== */
.tool-range {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    outline: none;
    margin: 12px 0;
}
.tool-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.tool-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid #fff;
}

/* ===== Pomodoro / Timer ===== */
.tool-timer-display {
    font-size: 4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--color-primary);
    text-align: center;
    margin: 20px 0;
    font-family: var(--font-mono);
    letter-spacing: -.02em;
}
.tool-timer-display.is-break { color: var(--color-success); }
.tool-timer-progress {
    width: 100%;
    height: 8px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 20px;
}
.tool-timer-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: var(--radius-full);
    transition: width 1s linear;
}

/* ===== Decision Wheel ===== */
.tool-wheel-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.tool-wheel-canvas {
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
    cursor: pointer;
    transition: transform .2s;
}
.tool-wheel-canvas:hover { transform: scale(1.02); }
.tool-wheel-pointer {
    font-size: 2rem;
    color: var(--color-danger);
    margin-bottom: -16px;
    z-index: 2;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .tool-runtime-page { padding: 16px 0 32px; }
    .runtime-header { padding: 16px 18px; }
    .runtime-title { font-size: 1.25rem; }
    .runtime-canvas { padding: 16px; }
    .tool-engine-container { padding: 16px; }
    .tool-grid-2,
    .tool-grid-3 { grid-template-columns: 1fr; }
    .tool-timer-display { font-size: 3rem; }
}
@media (max-width: 480px) {
    .runtime-header-top { flex-direction: column; align-items: flex-start; }
    .runtime-actions { width: 100%; justify-content: flex-end; }
    .tool-btn { flex: 1; min-width: 0; }
}

/* ===== Password Generator ===== */
.pw-opts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 16px;
}
@media (max-width: 480px) { .pw-opts { grid-template-columns: 1fr; } }
.tool-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .875rem;
    color: var(--color-text);
    cursor: pointer;
    user-select: none;
}
.tool-check input { width: 16px; height: 16px; accent-color: var(--color-primary); cursor: pointer; }
.pw-strength {
    width: 100%;
    height: 8px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 6px;
}
.pw-strength-bar {
    height: 100%;
    width: 0%;
    border-radius: var(--radius-full);
    transition: width .25s ease, background-color .25s ease;
}
.pw-strength-label { font-size: .75rem; color: var(--color-text-light); margin-top: 4px; }
.pw-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--color-border);
    word-break: break-all;
}
.pw-line:last-child { border-bottom: none; }
.pw-line-copy {
    flex: none;
    font-size: .75rem;
    color: var(--color-primary);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    cursor: pointer;
}
.pw-line-copy:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ===== Audio Equalizer ===== */
.ae-bands {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px 16px;
    margin-top: 14px;
    padding: 14px;
    background: var(--color-bg-subtle, #f7f8fa);
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: var(--radius-md, .5rem);
}
@media (max-width: 640px) { .ae-bands { grid-template-columns: repeat(2, 1fr); } }

/* ===== Transparency checkerboard (bg-remove preview) ===== */
.jt-checker {
    background-image:
        linear-gradient(45deg, #cbd5e1 25%, transparent 25%),
        linear-gradient(-45deg, #cbd5e1 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #cbd5e1 75%),
        linear-gradient(-45deg, transparent 75%, #cbd5e1 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-color: #f1f5f9;
}

/* ===== Shared small utilities ===== */
.tool-divider { height: 1px; background: var(--color-border, #e5e7eb); border: 0; margin: 16px 0; }
.tool-input-sm { width: auto; padding: 6px 10px; font-size: .85rem; }
.tool-btn-sm { padding: 5px 12px; font-size: .8rem; }

/* ===== Image to GIF ===== */
.gif-thumb { display: flex; align-items: center; gap: 10px; background: var(--color-bg-alt, #f7f8fa); border: 1px solid var(--color-border, #e5e7eb); border-radius: 8px; padding: 8px; margin-bottom: 8px; }
.gif-thumb img { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; flex: none; }
.gif-thumb-meta { flex: 1; font-size: .8rem; color: var(--color-text-light, #64748b); }
.gif-thumb-ctrl { display: flex; gap: 4px; }
.gif-thumb-ctrl button { width: 28px; height: 28px; border: 1px solid var(--color-border, #e5e7eb); background: #fff; border-radius: 6px; cursor: pointer; font-size: .9rem; line-height: 1; }
.gif-thumb-ctrl button:hover { background: var(--color-primary, #4f46e5); color: #fff; border-color: var(--color-primary, #4f46e5); }

/* ===== Image Compress ===== */
.ic-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--color-bg-alt, #f7f8fa); border: 1px solid var(--color-border, #e5e7eb); border-radius: 8px; margin-bottom: 8px; }
.ic-row-err { color: #dc2626; justify-content: flex-start; }
.ic-info { font-size: .85rem; line-height: 1.4; }
.ic-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; margin-left: 6px; }
.ic-good { background: #dcfce7; color: #166534; }
.ic-bad { background: #fee2e2; color: #991b1b; }

/* ===== Image Crop ===== */
.crop-stage { position: relative; display: inline-block; max-width: 100%; line-height: 0; border: 1px solid var(--color-border, #e5e7eb); border-radius: 8px; overflow: hidden; background: #0f172a; }
.crop-stage.crop-empty { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 200px; background: var(--color-bg-alt, #f7f8fa); }
.crop-stage.crop-empty .crop-box { display: none; }
.crop-stage canvas { display: block; max-width: 100%; height: auto; touch-action: none; }
.crop-hint { position: absolute; color: var(--color-text-light, #64748b); font-size: .85rem; }
.crop-box { position: absolute; border: 1px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); cursor: move; box-sizing: border-box; }
.crop-handle { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; background: #fff; border: 2px solid var(--color-primary, #4f46e5); border-radius: 50%; cursor: nwse-resize; }

/* ===== Eyedropper ===== */
.ed-stage { position: relative; border: 1px solid var(--color-border, #e5e7eb); border-radius: 8px; overflow: auto; max-height: 420px; background: var(--color-bg-alt, #f7f8fa); }
.ed-stage.ed-empty { display: flex; align-items: center; justify-content: center; min-height: 160px; }
.ed-empty-hint { color: var(--color-text-light, #64748b); font-size: .85rem; padding: 20px; text-align: center; }
.ed-stage canvas { display: block; max-width: 100%; cursor: crosshair; }
.ed-current { display: flex; gap: 16px; align-items: center; margin-top: 6px; }
.ed-swatch { width: 72px; height: 72px; border-radius: 12px; border: 1px solid var(--color-border, #e5e7eb); flex: none; background: #000; }
.ed-values { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.ed-val { display: flex; align-items: center; gap: 8px; font-size: .8rem; }
.ed-val span { width: 34px; color: var(--color-text-light, #64748b); }
.ed-val code { flex: 1; background: var(--color-bg-alt, #f7f8fa); padding: 4px 8px; border-radius: 6px; font-size: .8rem; }
.ed-palette { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.ed-palette-empty { color: var(--color-text-light, #64748b); font-size: .85rem; }
.ed-pal-item { position: relative; width: 36px; height: 36px; border-radius: 8px; border: 1px solid rgba(0,0,0,.1); cursor: pointer; }
.ed-pal-rm { position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; line-height: 14px; text-align: center; background: #fff; border: 1px solid var(--color-border, #e5e7eb); border-radius: 50%; font-size: .7rem; color: #ef4444; }

/* ===== Video to GIF ===== */
.vtg-preview-wrap { margin: 12px 0; }
.vtg-video { width: 100%; max-height: 320px; border-radius: 12px; background: #000; }
.vtg-progress { height: 8px; background: var(--color-bg-alt, #f1f5f9); border-radius: 999px; overflow: hidden; margin: 12px 0; }
.vtg-progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #6366f1, #8b5cf6); transition: width .2s ease; }
.vtg-result { margin-top: 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.vtg-gif { max-width: 100%; border-radius: 12px; border: 1px solid var(--color-border, #e5e7eb); }

/* ===== Image Format Converter (Batch) ===== */
.ifp-list { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.ifp-item { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--color-border, #e5e7eb); border-radius: 12px; background: var(--color-bg, #fff); }
.ifp-item-err { border-color: #fecaca; background: #fef2f2; }
.ifp-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; }
.ifp-meta { flex: 1; min-width: 0; }
.ifp-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ifp-sizes { font-size: .82rem; color: var(--color-text-light, #64748b); margin: 4px 0 8px; }
.ifp-sizes strong { color: var(--color-text, #1f2937); }
.ifp-ratio { color: #16a34a; font-weight: 600; }
.ifp-item-err .ifp-sizes { color: #dc2626; }

/* ===== Base64 Image (Pro) ===== */
.ibp-list { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.ibp-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border: 1px solid var(--color-border, #e5e7eb); border-radius: 12px; background: var(--color-bg, #fff); }
.ibp-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; background: #f1f5f9; }
.ibp-meta { flex: 1; min-width: 0; }
.ibp-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ibp-ext { color: var(--color-text-light, #64748b); font-weight: 400; }
.ibp-sizes { font-size: .8rem; color: var(--color-text-light, #64748b); margin: 4px 0 8px; }
.ibp-copy { display: flex; flex-wrap: wrap; gap: 6px; }
.ibp-decode-out { margin-top: 12px; display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.ibp-decoded { max-width: 200px; max-height: 200px; border-radius: 10px; border: 1px solid var(--color-border, #e5e7eb); }

/* ===== PDF Page Number + Rotate ===== */
.tool-field-inline { display: flex; align-items: center; }
.tool-field-inline label { display: flex; align-items: center; gap: 8px; font-size: .92rem; cursor: pointer; }
.tool-field-inline input { width: auto; }

/* ===== PDF to Word ===== */
.ptw-wrap { max-width: 680px; }

/* Dropzone */
.ptw-dropzone { padding: 24px 20px; border-style: dashed; transition: var(--transition); }
.ptw-drop-ico {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; margin: 0 auto 8px;
    border-radius: 12px;
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
    color: var(--color-primary, #4f46e5);
}
.ptw-drop-ico svg { width: 22px; height: 22px; }
.ptw-dropzone.dragover .ptw-drop-ico { transform: scale(1.06); }
.ptw-drop-sub { margin: 8px 0 0; font-size: 12.5px; color: #94a3b8; }
.ptw-dropzone:focus-visible { outline: 2px solid var(--color-primary, #4f46e5); outline-offset: 3px; }

/* Selected file card */
.ptw-filecard {
    display: flex; align-items: center; gap: 12px;
    margin-top: 12px; padding: 12px 14px;
    background: #fff; border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 12px; box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
    animation: toolResultIn .22s ease both;
}
.ptw-filecard[hidden] { display: none; }
.ptw-filecard-ico { font-size: 1.6rem; line-height: 1; flex: none; }
.ptw-filecard-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ptw-filecard-name { font-weight: 600; font-size: .92rem; color: var(--color-heading, #1e293b); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptw-filecard-size { font-size: .8rem; color: #64748b; }
.ptw-filecard-rm {
    flex: none; width: 30px; height: 30px; border-radius: 8px;
    border: 1px solid var(--color-border, #e5e7eb); background: #fff;
    color: #94a3b8; cursor: pointer; font-size: .85rem; line-height: 1;
    transition: var(--transition-fast);
}
.ptw-filecard-rm:hover { background: #fee2e2; color: #dc2626; border-color: #fecaca; }

/* Format selection cards */
.ptw-fmt { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ptw-fmt-card {
    position: relative; display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; cursor: pointer;
    background: #fff; border: 1.5px solid var(--color-border, #e5e7eb);
    border-radius: 12px; transition: var(--transition-fast);
}
.ptw-fmt-card:hover { border-color: color-mix(in srgb, var(--color-primary, #4f46e5) 40%, #fff); background: #faf9ff; }
.ptw-fmt-card input { position: absolute; opacity: 0; pointer-events: none; }
.ptw-fmt-ico { font-size: 1.5rem; flex: none; }
.ptw-fmt-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ptw-fmt-title { font-weight: 700; font-size: .95rem; color: var(--color-heading, #1e293b); }
.ptw-fmt-desc { font-size: .78rem; color: #64748b; }
.ptw-fmt-card:has(input:checked) {
    border-color: var(--color-primary, #4f46e5);
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.ptw-fmt-card:has(input:checked) .ptw-fmt-title { color: var(--color-primary-dark, #4338ca); }

/* Progress */
.ptw-progress { height: 8px; background: var(--color-bg-alt, #f1f5f9); border-radius: 999px; overflow: hidden; margin: 14px 0; }
.ptw-progress[hidden] { display: none; }
.ptw-progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #6366f1, #8b5cf6); transition: width .15s ease; }

/* Output / result card */
.ptw-output { margin-top: 22px; }
.ptw-result { margin-top: 10px; display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.ptw-result:empty { display: none; }
.ptw-done {
    display: flex; align-items: center; gap: 14px;
    padding: 16px; border-radius: 14px;
    background: linear-gradient(135deg, #ecfdf5, #f0fdf4);
    border: 1px solid #a7f3d0;
    animation: toolResultIn .28s ease both;
}
.ptw-done-ico {
    flex: none; width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--color-success, #10b981); color: #fff; font-size: 1.2rem; font-weight: 800;
}
.ptw-done-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ptw-done-title { font-weight: 700; color: #065f46; font-size: .95rem; }
.ptw-done-sub { font-size: .8rem; color: #047857; }
.ptw-done .ptw-dl { flex: none; white-space: nowrap; }

@media (max-width: 560px) {
    .ptw-fmt { grid-template-columns: 1fr; }
    .ptw-done { flex-wrap: wrap; }
    .ptw-done .ptw-dl { width: 100%; }
}

/* ===== Shared helpers for new PDF tools ===== */
.tool-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.tool-dropzone-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.tool-progress { height: 8px; background: var(--color-bg-alt, #f1f5f9); border-radius: 999px; overflow: hidden; margin: 12px 0; }
.tool-progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #6366f1, #8b5cf6); transition: width .15s ease; }
.tool-hint { font-size: 12.5px; color: #64748b; margin: 6px 0 2px; line-height: 1.6; }

/* ===================================
 * Unified beauty upgrade — shared output components
 * The following classes are used by 78+ tools but had no styles,
 * leaving results/tables/fractions in browser-default look.
 * Now they get a consistent, polished light-theme treatment.
 * =================================== */

/* ===== Tool Result Panel ===== */
.tool-result {
    margin-top: 22px;
    padding: 20px 22px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--color-border, #e5e7eb);
    border-left: 4px solid var(--color-primary, #4f46e5);
    border-radius: var(--radius-md, .75rem);
    box-shadow: 0 4px 18px rgba(15, 23, 42, .05);
    animation: toolResultIn .28s ease both;
}
.tool-result > *:first-child { margin-top: 0; }
.tool-result > *:last-child { margin-bottom: 0; }
.tool-result p { margin: 0 0 10px; line-height: 1.7; }
.tool-result b,
.tool-result strong { color: var(--color-primary-dark, #4338ca); font-weight: 700; }
@keyframes toolResultIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

/* ===== Tool Result Table ===== */
.tool-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .9rem;
    margin: 4px 0 10px;
    overflow: hidden;
    border-radius: var(--radius-sm, .5rem);
    border: 1px solid var(--color-border, #e5e7eb);
}
.tool-table th,
.tool-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
    vertical-align: middle;
}
.tool-table thead th {
    background: linear-gradient(135deg, var(--color-primary, #4f46e5), var(--color-secondary, #7c3aed));
    color: #fff;
    font-weight: 600;
    letter-spacing: .3px;
    border-bottom: none;
}
.tool-table tbody tr { transition: background-color .15s ease; }
.tool-table tbody tr:nth-child(even) { background: #f8fafc; }
.tool-table tbody tr:hover { background: #eef2ff; }
.tool-table tbody tr:last-child td { border-bottom: none; }
.tool-table td:first-child,
.tool-table th:first-child { font-weight: 600; color: var(--color-heading, #1e293b); }

/* ===== Tool Error / Hint Messages ===== */
.tool-error {
    display: inline-block;
    padding: 6px 14px;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 999px;
    font-size: .875rem;
    font-weight: 600;
    margin: 4px 0;
}

/* ===== Fraction Input Component ===== */
.tool-fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: var(--color-bg-alt, #f7f8fa);
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: var(--radius-sm, .5rem);
}
.tool-fraction .tool-input { width: 72px; text-align: center; padding: 8px 6px; }
.tool-frac-line {
    width: 70%;
    height: 2px;
    border-radius: 2px;
    background: var(--color-border-dark, #cbd5e1);
}

/* ===== Section Subtitle ===== */
.tool-subtitle {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary-dark, #4338ca);
    margin: 22px 0 12px;
    padding-left: 12px;
    border-left: 4px solid var(--color-primary, #4f46e5);
    line-height: 1.3;
}

/* ===================================
 * Micro-interactions & number highlight
 * =================================== */

/* ===== Button Micro-interaction ===== */
.tool-btn,
.tool-btn-sm { position: relative; }
.tool-btn { overflow: hidden; }
.tool-btn::after {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    background: linear-gradient(120deg, transparent 35%, rgba(255, 255, 255, .28) 50%, transparent 65%);
    transform: translateX(-130%);
    transition: transform .55s ease;
}
.tool-btn:hover::after { transform: translateX(130%); }
.tool-btn:active,
.tool-btn-sm:active { transform: translateY(0) scale(.96); box-shadow: inset 0 1px 4px rgba(15, 23, 42, .22); }
.tool-btn:focus-visible,
.tool-btn-sm:focus-visible { outline: 2px solid var(--color-primary, #4f46e5); outline-offset: 2px; }

/* ===== Result Number Highlight ===== */
.tool-num {
    color: var(--color-primary-dark, #4338ca);
    font-weight: 700;
    background: rgba(79, 70, 229, .1);
    padding: 0 5px;
    border-radius: 5px;
    font-variant-numeric: tabular-nums;
}
.tool-result b,
.tool-result strong {
    background: rgba(79, 70, 229, .1);
    padding: 0 5px;
    border-radius: 5px;
}
.tool-table td { font-variant-numeric: tabular-nums; }

/* ===== OCR Image to Text ===== */
.ocr-wrap { }
.ocr-drop { padding: 32px 20px; }
.ocr-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; height: 56px; margin-bottom: 12px; border-radius: 16px;
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
    font-size: 1.9rem; line-height: 1;
}
.ocr-drop.dragover .ocr-ico { transform: scale(1.06); }

/* selected image preview */
.ocr-preview {
    position: relative; margin-top: 12px; padding: 10px;
    background: #fff; border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 12px; display: inline-block; max-width: 100%;
}
.ocr-preview[hidden] { display: none; }
.ocr-preview img { display: block; max-width: 100%; max-height: 240px; border-radius: 8px; }
.ocr-preview-rm {
    position: absolute; top: 6px; right: 6px; width: 28px; height: 28px;
    border-radius: 8px; border: 1px solid var(--color-border, #e5e7eb);
    background: rgba(255, 255, 255, .95); color: #94a3b8; cursor: pointer;
    font-size: .8rem; line-height: 1; transition: var(--transition-fast);
}
.ocr-preview-rm:hover { background: #fee2e2; color: #dc2626; border-color: #fecaca; }

/* language chips */
.ocr-langs { display: flex; flex-wrap: wrap; gap: 8px; }
.ocr-lang-card {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 13px; cursor: pointer; user-select: none;
    background: #fff; border: 1.5px solid var(--color-border, #e5e7eb);
    border-radius: 999px; font-size: .85rem; color: var(--color-text, #1e293b);
    transition: var(--transition-fast);
}
.ocr-lang-card:hover { border-color: color-mix(in srgb, var(--color-primary, #4f46e5) 40%, #fff); background: #faf9ff; }
.ocr-lang-card input { width: 15px; height: 15px; accent-color: var(--color-primary, #4f46e5); cursor: pointer; }
.ocr-lang-card:has(input:checked) {
    border-color: var(--color-primary, #4f46e5);
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
    color: var(--color-primary-dark, #4338ca); font-weight: 600;
}

/* progress */
.ocr-progress { margin: 14px 0 6px; }
.ocr-progress[hidden] { display: none; }
.ocr-progress-bar {
    height: 8px; width: 0; border-radius: 999px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    transition: width .15s ease;
}
.ocr-progress-text { margin: 8px 0 0; font-size: .82rem; color: #64748b; }

/* result */
.ocr-result-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    flex-wrap: wrap; margin-bottom: 10px;
}
.ocr-result-head[hidden] { display: none; }
.ocr-count { font-size: .8rem; color: #64748b; font-weight: 600; }
.ocr-result-actions { display: flex; gap: 8px; }
.ocr-textarea {
    width: 100%; min-height: 320px; line-height: 1.7; font-family: var(--font-mono);
    border: 1.5px solid var(--color-border, #e5e7eb); border-radius: 12px;
    padding: 14px; font-size: .9rem; color: var(--color-text, #1e293b); background: #fff;
    transition: var(--transition-fast); resize: vertical;
}
.ocr-textarea:focus { outline: none; border-color: var(--color-primary, #4f46e5); box-shadow: 0 0 0 4px rgba(79, 70, 229, .08); }
.ocr-status { margin: 10px 0 0; font-size: 12.5px; color: #64748b; line-height: 1.6; }
.ocr-status.is-ok { color: #047857; }
.ocr-status.is-err { color: #b91c1c; }

@media (max-width: 720px) {
    .ocr-wrap .tool-grid-2 { grid-template-columns: 1fr; }
}

/* ============================================================
 * Screenshot carousel — local CSS scroll-snap (no external Swiper)
 * Replaces the previous cdn.jsdelivr.net Swiper dependency so the
 * carousel works fully offline with zero console network errors.
 * ============================================================ */
.tool-screenshots { margin: 2rem 0; }

.tool-screenshot-slider {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: .75rem;
}

.tool-screenshot-slider::-webkit-scrollbar { height: 8px; }
.tool-screenshot-slider::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .18);
    border-radius: 8px;
}
.tool-screenshot-slider::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, .06);
    border-radius: 8px;
}

.tool-screenshot-slide {
    flex: 0 0 auto;
    width: min(82%, 720px);
    scroll-snap-align: center;
}

.tool-screenshot-slide .tool-screenshot {
    width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .08);
}

/* ============================================================
 * Unified Design Language upgrade layer (P2)
 * Applies to legacy tools whose render output drops plain
 * .tool-field / .tool-btn / .tool-result siblings directly inside
 * .tool-engine-container.
 *
 * Strategy: use :has() so ONLY the flat-form tools (fields +
 * buttons + result as direct children) get the two-column grid.
 * Wrapped tools (dev-wrap/mk-wrap/conv-wrap/...) keep their own
 * internal layouts untouched — the shared component classes below
 * (buttons / inputs / result card) upgrade every tool consistently.
 * ============================================================ */

/* ---- Two-column layout: at least two sibling .tool-field ---- */
.tool-engine-container:has(> .tool-field + .tool-field) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px 20px;
    align-items: start;
}
/* every non-field direct child (labels, buttons, result, notes) spans full width */
.tool-engine-container:has(> .tool-field + .tool-field) > :not(.tool-field) {
    grid-column: 1 / -1;
}
.tool-engine-container:has(> .tool-field + .tool-field) > .tool-field-inline {
    grid-column: 1 / -1;
}

/* ---- Gradient primary button (all tools, incl. wrapped) ---- */
.tool-engine-container .tool-btn:not(.tool-btn-secondary):not(.tool-btn-ghost):not(.tool-btn-danger):not(.tool-btn-success) {
    background: linear-gradient(135deg, var(--color-primary, #4f46e5), var(--color-secondary, #7c3aed));
    box-shadow: 0 6px 16px rgba(79, 70, 229, .22);
}
.tool-engine-container .tool-btn:not(.tool-btn-secondary):not(.tool-btn-ghost):not(.tool-btn-danger):not(.tool-btn-success):hover {
    background: linear-gradient(135deg, var(--color-primary-dark, #4338ca), var(--color-secondary-dark, #6d28d9));
    box-shadow: 0 8px 20px rgba(79, 70, 229, .3);
}

/* ---- Inputs: softer radius + subtle inner depth ---- */
.tool-engine-container .tool-input,
.tool-engine-container .tool-textarea,
.tool-engine-container .tool-select {
    border-radius: 10px;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, .04);
}
.tool-engine-container .tool-input:hover,
.tool-engine-container .tool-textarea:hover,
.tool-engine-container .tool-select:hover {
    border-color: color-mix(in srgb, var(--color-primary, #4f46e5) 45%, var(--color-border, #d8dee9));
}

/* ---- Labels: consistent weight + spacing ---- */
.tool-engine-container .tool-field-label {
    font-weight: 650;
    letter-spacing: .1px;
}

/* ---- Shared output panel: card treatment (covers .tool-output and friends) ---- */
.tool-engine-container .tool-output {
    margin-top: 24px;
    padding: 20px 22px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--color-border, #e5e7eb);
    border-left: 4px solid var(--color-primary, #4f46e5);
    border-radius: 14px;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .05);
    animation: toolResultIn .28s ease both;
}

/* ---- Mobile: collapse to single column ---- */
@media (max-width: 760px) {
    .tool-engine-container:has(> .tool-field + .tool-field) {
        grid-template-columns: 1fr;
    }
    .tool-engine-container .tool-btn:not(.tool-btn-secondary):not(.tool-btn-ghost):not(.tool-btn-danger):not(.tool-btn-success) {
        width: 100%;
    }
}
