.image-tool-section {
    overflow: hidden;
}

/* auto-fit keeps every tab the same width no matter how many tools are added;
   new modules only need one more <a> in the markup, no CSS change. */
.image-tool-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.6rem;
    margin-bottom: 1rem;
    padding: 0.45rem;
    background: #e9edf3;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.image-tool-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 46px;
    padding: 0.65rem 1rem;
    color: var(--light-text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 11px;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.image-tool-tab:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.62);
}

.image-tool-tab.active {
    color: var(--primary-hover);
    background: #ffffff;
    border-color: var(--border-color);
    box-shadow: var(--box-shadow);
}

.image-tool-tab:focus-visible {
    outline: 3px solid rgba(239, 68, 68, 0.25);
    outline-offset: 2px;
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.section-heading h1 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.35rem;
    color: var(--text-color);
    font-size: 1.65rem;
    font-weight: 750;
    letter-spacing: -0.025em;
    line-height: 1.3;
}

.section-heading h1 i {
    color: var(--primary-color);
    font-size: 1.35rem;
}

.section-heading p {
    color: var(--light-text);
    font-size: 0.95rem;
}

.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex: 0 0 auto;
    padding: 0.45rem 0.75rem;
    color: #047857;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.gif-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
    padding: 0.9rem 1rem;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--border-radius);
}

.gif-notice > i {
    margin-top: 0.2rem;
    color: #d97706;
}

.gif-notice div {
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
}

.gif-notice strong {
    font-size: 0.9rem;
}

.gif-notice span {
    color: #a16207;
    font-size: 0.85rem;
    line-height: 1.5;
}

.upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    padding: 2.25rem 1.25rem;
    text-align: center;
    background: var(--surface-muted);
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.upload-zone:hover,
.upload-zone:focus-visible,
.upload-zone.is-dragging {
    background: var(--primary-soft);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-soft);
    outline: none;
}

.upload-icon {
    display: grid;
    place-items: center;
    width: 68px;
    height: 68px;
    margin-bottom: 1rem;
    color: var(--primary-color);
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--box-shadow);
}

.upload-icon i {
    font-size: 1.75rem;
}

.upload-zone h3 {
    margin-bottom: 0.35rem;
    font-size: 1.08rem;
}

.upload-zone > p {
    margin-bottom: 0.9rem;
    color: var(--light-text);
    font-size: 0.9rem;
}

.upload-note {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #047857;
    font-size: 0.82rem;
    font-weight: 600;
}

.converter-controls {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.quality-control {
    flex: 1 1 440px;
    max-width: 600px;
}

.quality-label,
.range-labels {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.quality-label {
    margin-bottom: 0.55rem;
}

.quality-label label {
    font-size: 0.9rem;
    font-weight: 700;
}

.quality-label output {
    min-width: 3.2rem;
    padding: 0.18rem 0.5rem;
    color: var(--primary-hover);
    background: var(--primary-soft);
    border-radius: 999px;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 700;
}

#qualityRange {
    width: 100%;
    padding: 0;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.range-labels {
    margin-top: 0.25rem;
    color: #94a3b8;
    font-size: 0.73rem;
}

.ico-controls {
    align-items: flex-end;
}

.size-control {
    flex: 1 1 680px;
    min-width: 0;
    padding: 0;
    border: 0;
}

.size-control legend {
    margin-bottom: 0.6rem;
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 700;
}

.size-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.size-options label {
    position: relative;
    cursor: pointer;
}

.size-options input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.size-options span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 0.45rem 0.65rem;
    color: var(--light-text);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.size-options input:checked + span {
    color: var(--primary-hover);
    background: var(--primary-soft);
    border-color: rgba(239, 68, 68, 0.4);
}

.size-options input:focus-visible + span {
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.size-options input:disabled + span {
    cursor: not-allowed;
    opacity: 0.55;
}

.size-control > p {
    margin-top: 0.55rem;
    color: var(--light-text);
    font-size: 0.76rem;
}

.action-buttons {
    display: flex;
    flex: 0 0 auto;
    gap: 0.65rem;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
    transform: none;
}

.file-panel {
    margin-top: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.file-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border-color);
}

.file-panel-header h3 {
    font-size: 1rem;
}

.file-panel-header h3 span {
    display: inline-grid;
    place-items: center;
    min-width: 1.6rem;
    height: 1.6rem;
    margin-left: 0.3rem;
    padding: 0 0.4rem;
    color: var(--light-text);
    background: #e2e8f0;
    border-radius: 999px;
    font-size: 0.75rem;
}

.file-panel-header p {
    margin-top: 0.15rem;
    color: var(--light-text);
    font-size: 0.82rem;
}

.image-list {
    display: flex;
    flex-direction: column;
}

.image-item {
    display: grid;
    grid-template-columns: 58px minmax(160px, 1.4fr) minmax(120px, 0.8fr) minmax(125px, auto);
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.image-item:last-child {
    border-bottom: none;
}

.image-preview {
    width: 58px;
    height: 58px;
    object-fit: cover;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.image-preview.checkerboard {
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-position: 0 0, 0 6px, 6px -6px, -6px 0;
    background-size: 12px 12px;
}

.file-details,
.conversion-details {
    min-width: 0;
}

.file-name {
    overflow: hidden;
    margin-bottom: 0.18rem;
    font-size: 0.9rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-meta,
.output-meta {
    color: var(--light-text);
    font-size: 0.78rem;
}

.gif-tag {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.08rem 0.35rem;
    color: #92400e;
    background: #fef3c7;
    border-radius: 5px;
    font-size: 0.68rem;
    font-weight: 700;
    vertical-align: 1px;
}

.status-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--light-text);
    font-size: 0.82rem;
    font-weight: 600;
}

.status-label.is-converting {
    color: #2563eb;
}

.status-label.is-complete {
    color: #059669;
}

.status-label.is-error {
    color: #dc2626;
}

.image-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.45rem;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: var(--light-text);
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 9px;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.icon-btn:hover {
    color: var(--primary-color);
    background: var(--primary-soft);
    border-color: var(--primary-color);
}

.icon-btn.download-item {
    width: auto;
    padding: 0 0.75rem;
    gap: 0.4rem;
    color: #047857;
    border-color: #a7f3d0;
}

.icon-btn.download-item:hover {
    color: #065f46;
    background: #ecfdf5;
    border-color: #34d399;
}

.ico-size-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
}

.ico-size-grid div {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 1rem 0.75rem;
    text-align: center;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.ico-size-grid strong {
    color: var(--text-color);
    font-size: 0.9rem;
}

.ico-size-grid span {
    color: var(--light-text);
    font-size: 0.73rem;
    line-height: 1.45;
}

@media (max-width: 768px) {
    .image-tool-tabs {
        display: flex;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .image-tool-tab {
        flex: 0 0 auto;
        min-width: 148px;
    }

    .section-heading,
    .converter-controls,
    .file-panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .privacy-badge {
        align-self: flex-start;
    }

    .quality-control {
        flex-basis: auto;
        max-width: none;
    }

    .size-control {
        flex-basis: auto;
    }

    .action-buttons,
    .action-buttons .btn,
    #downloadAll {
        width: 100%;
    }

    .image-item {
        grid-template-columns: 52px minmax(0, 1fr) auto;
        gap: 0.75rem;
        padding: 0.85rem;
    }

    .image-preview {
        width: 52px;
        height: 52px;
    }

    .conversion-details {
        grid-column: 2 / -1;
    }

    .image-actions {
        grid-column: 2 / -1;
        justify-content: flex-start;
    }

    .ico-size-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .upload-zone {
        min-height: 220px;
        padding: 1.5rem 0.85rem;
    }

    .action-buttons {
        flex-direction: column-reverse;
    }

    .image-item {
        grid-template-columns: 48px minmax(0, 1fr);
    }

    .image-preview {
        width: 48px;
        height: 48px;
    }

    .conversion-details,
    .image-actions {
        grid-column: 1 / -1;
    }

    .ico-size-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ========== QR code generator ========== */

.qr-workbench {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
    gap: 1.75rem;
    align-items: start;
}

.qr-controls {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.qr-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.qr-field > label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
}

.qr-field > label i {
    color: var(--primary-color);
}

.qr-optional {
    font-weight: 500;
    color: var(--light-text);
}

#qrText {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface);
    color: var(--text-color);
    font-family: var(--font-mono);
    font-size: 0.92rem;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#qrText:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.qr-field select {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface);
    color: var(--text-color);
    font-size: 0.92rem;
    cursor: pointer;
}

.qr-field select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.qr-hint {
    margin: 0;
    font-size: 0.82rem;
    color: var(--light-text);
}

.qr-advice {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: #b45309;
}

/* colour swatches */
.qr-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.qr-swatches.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.qr-swatch {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    background: var(--swatch);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.qr-swatch:hover {
    transform: scale(1.1);
}

.qr-swatch.is-active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.qr-color-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.85rem;
    color: var(--light-text);
}

.qr-color-row input[type="color"] {
    width: 44px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: none;
    cursor: pointer;
}

.qr-check {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.88rem;
    color: var(--text-color);
    cursor: pointer;
}

/* centre logo upload */
.qr-logo-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 96px;
    padding: 0.9rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-muted);
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.qr-logo-zone:hover,
.qr-logo-zone.is-dragging {
    border-color: var(--primary-color);
    background: var(--primary-soft);
}

.qr-logo-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    color: var(--light-text);
    font-size: 0.88rem;
    text-align: center;
}

.qr-logo-empty i {
    font-size: 1.4rem;
    color: var(--primary-color);
}

.qr-logo-loaded {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
}

.qr-logo-loaded img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #fff;
}

.qr-logo-meta {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.qr-logo-meta strong {
    font-size: 0.9rem;
    color: var(--text-color);
    word-break: break-all;
}

.qr-logo-remove {
    align-self: flex-start;
    padding: 0;
    border: none;
    background: none;
    color: var(--primary-color);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.qr-range-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--light-text);
}

.qr-range-row input[type="range"] {
    flex: 1;
    accent-color: var(--primary-color);
}

/* preview panel */
.qr-preview {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding: 1.25rem;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.qr-canvas-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    /* checkerboard so a transparent background is visible in the preview */
    background:
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%, transparent 75%, #e2e8f0 75%) 0 0 / 16px 16px,
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%, transparent 75%, #e2e8f0 75%) 8px 8px / 16px 16px,
        #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

#qrCanvas {
    width: 100%;
    max-width: 280px;
    height: auto;
    border-radius: 6px;
}

.qr-meta {
    margin: 0;
    font-size: 0.85rem;
    color: var(--light-text);
    text-align: center;
}

.qr-error {
    margin: 0;
    padding: 0.6rem 0.8rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--border-radius);
    background: rgba(239, 68, 68, 0.08);
    color: #b91c1c;
    font-size: 0.85rem;
}

.qr-preview .action-buttons {
    margin-bottom: 0;
}

.qr-preview .action-buttons .btn {
    flex: 1;
    justify-content: center;
}

@media (max-width: 900px) {
    .qr-workbench {
        grid-template-columns: 1fr;
    }
}

/* ===== Image to ICO: editor / crop / adjust ===== */
.editor-panel {
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.editor-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.editor-heading h3 {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.05rem;
}

.editor-filename {
    color: var(--light-text);
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(240px, 360px) minmax(260px, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.editor-canvas-wrap {
    position: relative;
    width: 100%;
    max-width: 360px;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    background: #fff;
}

.editor-canvas-wrap:active {
    cursor: grabbing;
}

.editor-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.editor-canvas.checkerboard {
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-size: 20px 20px;
}

.editor-hint {
    position: absolute;
    left: 50%;
    bottom: 0.6rem;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    color: #fff;
    background: rgba(15, 23, 42, 0.72);
    border-radius: 999px;
    font-size: 0.72rem;
    white-space: nowrap;
    pointer-events: none;
}

.editor-controls {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.editor-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.editor-btn-row .icon-btn {
    width: 42px;
    height: 42px;
    font-size: 1rem;
}

.editor-btn-row .icon-btn.is-active {
    color: var(--primary-color);
    background: var(--primary-soft);
    border-color: var(--primary-color);
}

.editor-slider {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.editor-slider input[type="range"] {
    width: 100%;
    padding: 0;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.editor-slider input[type="range"]:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.editor-apply {
    align-self: flex-start;
    margin-top: 0.25rem;
}

.editor-empty {
    color: var(--light-text);
    font-size: 0.88rem;
}

.image-item.is-selected {
    background: var(--primary-soft);
    box-shadow: inset 3px 0 0 var(--primary-color);
}

.image-item {
    cursor: pointer;
}

@media (max-width: 768px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }

    .editor-canvas-wrap {
        max-width: none;
        margin: 0 auto;
    }
}
