.tool-shell { margin: auto; padding-bottom: 40px; }
.tool-heading { padding: 24px 0; }
.tool-heading h1 { font: 400 clamp(2rem, 4vw, 3.3rem)/1.15 var(--freeify-serif); margin: 10px 0; }
.tool-heading p { color: var(--freeify-muted); max-width: 800px; }
.tool-panel, .result-card { background: var(--freeify-panel); border: 1px solid var(--freeify-line); border-radius: 6px; padding: 20px; margin-bottom: 20px; min-width: 0; }
.tool-panel h2, .result-card h2 { font: 400 1.5rem var(--freeify-serif); margin: 0 0 16px; overflow-wrap: anywhere; }
.tool-fields { display: flex; flex-wrap: wrap; align-items: end; gap: 16px; }
.tool-fields label { display: grid; gap: 6px; color: var(--freeify-muted); font-size: .875rem; min-width: 0; }
.tool-shell :is(input:not([type=checkbox]):not([type=range]):not([type=file]),select,button,.download-link) { min-height: 44px; border: 1px solid #596780; border-radius: 4px; padding: 9px 12px; font: 500 .875rem/1.4 system-ui,sans-serif; background: var(--freeify-raised); color: var(--freeify-text); max-width: 100%; }
.tool-shell input[type=number] { width: 125px; }
.tool-shell input[type=color] { width: 90px; padding: 4px !important; }
.tool-shell input[type=file] { display: block; max-width: 100%; margin: 10px 0; color: var(--freeify-muted); font: inherit; }
.tool-shell input[type=file]::file-selector-button { background: #d4af37; color: #111321; padding: 12px 16px; border: 0; border-radius: 4px; margin-right: 12px; cursor: pointer; }
.tool-shell button, .download-link { cursor: pointer; text-decoration: none; }
.tool-shell button.primary { background: var(--freeify-gold); color: #101321; border-color: var(--freeify-gold); }
.tool-shell button:disabled { opacity: .5; cursor: not-allowed; }
.tool-shell button:hover:not(:disabled), .download-link:hover { border-color: var(--freeify-gold); }
.tool-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.tool-note { color: var(--freeify-muted); font-size: .875rem; }
.tool-status { color: #e0c577; min-height: 26px; }
.tool-error { color: #ffb8b8; overflow-wrap: anywhere; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 20px; }
.result-card { margin: 0; }
.image-preview { width: 100%; height: 210px; object-fit: contain; background: repeating-conic-gradient(#d0d4da 0% 25%,#fff 0% 50%) 0/20px 20px; border: 1px solid var(--freeify-line); }
.settings-label { color: #e0c577; font-size: .875rem; }
.file-info { color: var(--freeify-muted); font-size: .875rem; overflow-wrap: anywhere; }
.tool-shell fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.tool-shell legend { margin-bottom: 10px; }
.tool-shell [hidden] { display: none !important; }
.tool-shell progress { width: min(100%, 400px); accent-color: var(--freeify-gold); }
.empty-results { padding: 32px 20px; border: 1px dashed var(--freeify-line); color: var(--freeify-muted); }
@media(max-width:700px) { .results-grid { grid-template-columns: 1fr; } .tool-panel,.result-card { padding: 16px; } .tool-fields { gap: 12px; } .tool-shell .freeify-header { padding: 18px 0; } }

.crop-preview { position: relative; width: 100%; max-width: 640px; margin: 14px auto; overflow: hidden; background: #ddd; touch-action: none; }
.crop-preview > img { display: block; width: 100%; height: 100%; }
.crop-box { position: absolute; border: 2px solid #ffe58d; box-shadow: 0 0 0 1500px #0009; cursor: move; touch-action: none; }
.crop-handle { position: absolute; right: -2px; bottom: -2px; width: 28px; height: 28px; display: grid; place-items: center; color: #111; background: #ffe58d; cursor: nwse-resize; font-size: 22px; }
.crop-editor .tool-fields { margin-top: 14px; }
[data-studio="image-resize"] .results-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr)); }

.tool-shell #convert.primary { background: var(--freeify-gold); color: #101321; border-color: var(--freeify-gold); }

.pdf-selection-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(170px,1fr)); gap: 16px; margin-bottom: 24px; }
.page-choice { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 12px; border: 1px solid var(--freeify-line); border-radius: 4px; background: var(--freeify-panel); cursor: pointer; }
.page-choice.selected { border-color: var(--freeify-gold); }
.thumbnail { grid-column: 1/-1; min-height: 220px; display: grid; place-items: center; background: #20293a; font-size: .875rem; color: #d5dce8; }
.thumbnail img { max-width: 100%; max-height: 220px; }
.tool-shell input[type=text] { width: min(100%,360px); }
.page-choice:focus-within { outline: 3px solid #f1d978; outline-offset: 3px; }
@media(max-width:390px) { .pdf-selection-grid { grid-template-columns: 1fr; } }

.page-choice > .file-info { grid-column: 1 / -1; }

.tool-panel > p { max-width: 90ch; }
