:root {
    /* Modern Indigo Palette - Tech, Fresh & Premium */
    --primary-color: #4f46e5;
    /* Indigo 600 - Deep & Vibrant */
    --primary-hover: #4338ca;
    /* Indigo 700 */
    --success-color: #059669;
    /* Emerald 600 - Richer green */

    --bg-color: #f8fafc;
    /* Slate 50 - Clean cool background */
    --card-bg: #ffffff;

    --text-main: #0f172a;
    /* Slate 900 - Sharp & High Contrast */
    --text-muted: #64748b;
    /* Slate 500 */
    --border-color: #cbd5e1;
    /* Slate 300 - Slightly more definition */

    --radius: 12px;
    --shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    /* Elevated Shadow */
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    overflow-x: hidden;
    /* Prevent horizontal scroll globally */
    width: 100%;
}

html {
    height: 100%;
}

body {
    font-family: 'Geist Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: 100%;
    /* Responsive Text Handling */
    overflow-wrap: break-word;
    word-break: break-word;
    /* Prevent long words from breaking layout */
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    /* Ensure main takes full width */
}

.container {
    width: 100%;
    max-width: 1111px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.main-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 3.5px 0;
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.datetime-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.2;
}

#current-time {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    /* Ensures numbers have same width to prevent jitter */
}

#current-date {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* Logo Styling */
.logo-link {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-image {
    height: 50px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    display: block;
}

.logo-text {
    background-color: var(--primary-color);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.85rem;
    letter-spacing: 1px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.logo-text-inner {
    font-size: 0.85rem;
}

.site-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    transition: color 0.2s;
}

.logo-link:hover .site-title {
    color: var(--primary-color);
}

/* Mobile Toggle */
.mobile-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

.mobile-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--text-main);
    border-radius: 2px;
    transition: all 0.3s;
}

/* Responsive Menu Logic */
@media (max-width: 768px) {
    .mobile-toggle {
        display: flex;
    }

    .top-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background-color: #ffffff;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
        padding: 5rem 2rem;
        transition: right 0.3s ease;
        z-index: 1000;
    }

    .top-nav.active {
        right: 0;
    }

    .top-nav ul {
        flex-direction: column;
        gap: 2rem;
        align-items: flex-start;
    }

    .top-nav a {
        font-size: 1.1rem;
    }

    /* Hamburger to X animation */
    #menu-toggle.active span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    #menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    #menu-toggle.active span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }
}

/* Top Navigation (Desktop & Base) */
.top-nav {
    display: block;
    /* Ensure visibility on desktop */
}

.top-nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
    padding: 0;
    margin: 0;
}

.top-nav a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.top-nav a:hover {
    color: var(--primary-color);
}

/* Intro Title & Paragraph */
.tool-intro {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 0.5rem 0;
}

.main-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: #1e40af;
    margin-bottom: 1rem;
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.lead {
    font-size: 1.2rem;
    color: #475569;
    max-width: 700px;
    margin: 0 auto 2rem;
    line-height: 1.6;
}

/* Tabs */
/* Tabs (Segmented Control Style) */
.tabs {
    display: inline-flex;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 2rem;
    background: #e2e8f0;
    /* Light gray background for the track */
    padding: 0.35rem;
    border-radius: 999px;
    /* Pill shape */
    position: relative;
    /* Center the container horizontally */
    left: 50%;
    transform: translateX(-50%);
}

.tab-btn {
    padding: 0.5rem 1.5rem;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 999px;
    /* Pill shape */
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--primary-color);
    background: white;
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

/* Tool Container (Min-Height Fix) */
/* Assuming the tabs are inside or siblings to the tool wrapper. 
Let's target the main article or create a wrapper class if needed. 
Looking at HTML, the tabs are inside <article class="tool-container"> which contains sections. */

/* Main Content - Fixed Height to Minimise Shifts */
.tool-container {
    min-height: 700px;
    /* Fixed height approach again */
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 2rem;
}

.tab-content {
    /* Standard display toggling controlled by JS */
    width: 100%;
}

/* Active State handled by JS normally */

/* Converter Options - RESTORED */
.converter-options {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0;
    background: white;
    padding: 1rem 1.5rem;
    width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.converter-controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0;
    min-height: 0;
    justify-content: space-between;
}

.converter-controls-wrapper>div {
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex-shrink: 1;
}

.converter-settings {
    background: white !important;
    padding: 1rem 1.5rem;
    width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* Match compressor height to converter */
#compressor-controls .converter-settings {
    padding-top: 2.5rem;
    padding-bottom: 1rem;
}

.format-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.radio-btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

/* Steps Container */
.steps-container {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: stretch;
}

.steps-container>* {
    flex: 1;
    min-width: 0;
}

/* Drop Zone */
.drop-zone {
    background: var(--card-bg);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 0;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary-color);
    background-color: #eff6ff;
}

.drop-zone__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.upload-icon {
    color: var(--primary-color);
}

.drop-zone.step-done {
    border-color: #22c55e;
    background-color: #f0fdf4;
}

.drop-zone.step-done .upload-icon {
    color: #22c55e;
}

.drop-zone.step-done p {
    color: #15803d;
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s;
    font-size: 1rem;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #16a34a;
}

.btn-outline {
    background-color: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background-color: #e2e8f0;
    color: var(--text-main);
}

.btn-secondary {
    background-color: #64748b;
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-danger {
    background-color: transparent;
    color: #ef4444;
    border: 1px solid #fee2e2;
    margin-top: 0.5rem;
}

.btn-danger:hover {
    background-color: #fef2f2;
    border-color: #fecaca;
}

/* Disabled Buttons */
.btn:disabled {
    opacity: 0.85;
    cursor: not-allowed;
    pointer-events: none;
}

.btn:disabled:hover {
    background-color: inherit;
    color: inherit;
}

/* Specific disabled styles for better visibility */
.btn-outline:disabled {
    background-color: #f1f5f9;
    color: #64748b;
    border-color: #cbd5e1;
    opacity: 0.9;
}

.btn-secondary:disabled {
    background-color: #94a3b8;
    color: white;
    opacity: 0.9;
}

/* Global Actions */
.global-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    justify-content: flex-start;
    margin-top: 0.5rem;
    margin-bottom: 0;
    width: 100%;
    flex-shrink: 1;
}

#global-actions-resize {
    flex-direction: row;
}

#global-actions-resize .btn {
    flex: 1;
}

.global-actions .btn {
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Converter buttons in row */
#global-actions-convert {
    flex-direction: row;
    gap: 0.75rem;
}

#global-actions-convert .btn {
    flex: 1;
    width: auto;
}

.hidden {
    display: none !important;
}

/* Image List - Grid Layout */
.image-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
    margin-bottom: 2rem;
}

.image-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    height: 100%;
    overflow: hidden;
}

.image-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.image-preview {
    width: 100%;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
    background-color: #f1f5f9;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border-color);
    position: relative;
}

/* Card Overlay Actions */
.card-overlay-actions {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.image-item:hover .card-overlay-actions {
    opacity: 1;
}

.card-badges {
    position: absolute;
    bottom: 5px;
    left: 5px;
}

.icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    padding: 0;
}

.icon-btn.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.icon-btn.btn-danger {
    background-color: rgba(239, 68, 68, 0.9);
    color: white;
}

.icon-btn:hover {
    transform: scale(1.1);
}

.icon-btn.disabled {
    opacity: 0.7;
    pointer-events: none;
}

.image-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
    overflow: hidden;
}

.image-details h3 {
    font-size: 0.6rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1;
}

.stats {
    font-size: 0.55rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
    align-items: center;
}

.badge-success {
    background: #dcfce7 !important;
    color: #166534 !important;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-weight: 700;
    font-size: 0.55rem;
}

.badge-warning {
    background: #fed7aa !important;
    color: #c2410c !important;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-weight: 700;
    font-size: 0.55rem;
}

.badge-danger {
    background: #fee2e2 !important;
    color: #dc2626 !important;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-weight: 700;
    font-size: 0.55rem;
}

.image-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
}

.quality-control {
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.6rem;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.quality-control label {
    display: none;
    /* Hide label to save space */
}

.quality-slider-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

input[type="range"] {
    accent-color: var(--primary-color);
    flex: 1;
    height: 2px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    /* Thinner */
}

.quality-value {
    font-weight: 700;
    min-width: 20px;
    font-size: 0.55rem;
    text-align: right;
}

.image-controls a.btn {
    min-width: auto;
    justify-content: center;
    box-shadow: none;
}

.image-controls a.btn:hover {
    transform: none;
    box-shadow: none;
}

.main-footer {
    background-color: #ffffff;
    border-top: 1px solid var(--border-color);
    padding: 1rem 0;
    margin-top: auto;
    width: 100%;
    flex-shrink: 0;
    box-sizing: border-box;
}

.footer-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.footer-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}

.footer-brand {
    font-weight: 700;
    color: #1e40af;
    font-size: 0.95rem;
}

.footer-separator {
    color: var(--border-color);
}

.footer-copyright {
    color: var(--text-muted);
}

.footer-tagline {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
    opacity: 0.8;
}

/* Step Labels - Highlighted */
.step-label {
    color: var(--primary-color) !important;
    font-weight: 700 !important;
    font-size: 1.05em;
}

/* Informative Content Section */
.info-content {
    max-width: 1111px;
    margin: 3rem auto;
    padding: 0 1.5rem;
    line-height: 1.7;
}

.info-content h2 {
    font-size: 20px;
    font-weight: 600;
    color: #64748b;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

.info-content h2:first-child {
    margin-top: 0;
}

.info-content h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-top: 1.5rem;
}

.info-content p {
    margin-bottom: 1.25rem;
    color: #334155;
    /* Soft readable gray for body */
    font-size: 1.05rem;
}

.info-content strong {
    color: var(--primary-color);
    font-weight: 600;
}

.info-content dl {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.info-content dt {
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
}

.info-content dt:first-child {
    margin-top: 0;
}

.info-content dd {
    color: var(--text-muted);
    margin-left: 1.5rem;
    margin-bottom: 1rem;
    line-height: 1.7;
}

/* Responsive: Steps Container */
/* Attention Animation */
@keyframes attention-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 2px var(--primary-color), 0 0 20px rgba(59, 130, 246, 0.4);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    }
}

.controls-flash .converter-options,
.controls-flash .converter-settings {
    animation: attention-pulse 0.5s ease-in-out 2;
}

@media (max-width: 768px) {
    .steps-container {
        flex-direction: column;
    }

    .drop-zone {
        margin-bottom: 1.5rem;
    }

    .converter-controls-wrapper {
        margin-bottom: 2rem;
    }

    #global-actions-convert {
        flex-direction: column;
    }

    #global-actions-convert .btn {
        width: 100%;
    }

    .info-content {
        margin: 2rem auto;
        padding: 0 1rem;
    }

    .info-content h2 {
        font-size: 1.25rem;
        margin-top: 2rem;
    }

    .datetime-display {
        /* font-size removed here as child elements have specific sizes */
        order: 3;
        width: 100%;
        justify-content: flex-end;
        /* Align to right */
        align-items: center;
        /* Center vertically */
        padding-right: 1rem;
        margin-top: 0.5rem;
        flex-direction: row;
        /* Side by side on mobile */
        gap: 0.5rem;
    }

    .datetime-display #current-time {
        font-size: 0.75rem;
    }

    .datetime-display #current-date {
        font-size: 0.75rem;
        display: inline;
        /* Show date on mobile */
    }

    .header-content {
        flex-wrap: wrap;
    }

    .mobile-toggle {
        order: 2;
    }
}


/* Header (Ensure it's white) */
.main-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0.2rem 0;
    /* Minimal padding */
    margin-bottom: 2rem;
}

/* Footer (Ensure it's white) */
.main-footer {
    border-top: 1px solid var(--border-color);
    padding: 0.5rem 0;
    /* Minimal padding */
    margin-top: auto;
    background-color: #ffffff;
    /* Explicitly White */
    color: var(--text-muted);
    font-size: 0.8rem;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

/* Table Comparison Styles (JGB Table) */
.jgbtablecss {
    width: 100%;
    max-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #ffffff;
    /* Card BG */
    color: var(--text-main);
    font-family: inherit;
    /* Use site font */
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin: 2rem 0;
}

.jgbtablecss th,
.jgbtablecss td {
    text-align: left;
    vertical-align: middle;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.5;
}

.jgbtablecss thead th {
    background: #e0e7ff;
    /* Indigo 100 to match theme */
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    font-size: 0.85rem;
    border-right: 1px solid rgba(79, 70, 229, 0.1);
    padding: 1rem;
}

.jgbtablecss thead th:last-child {
    border-right: none;
}

.jgbtablecss thead {
    border-bottom: 2px solid var(--primary-color);
}

.jgbtablecss tbody td {
    border-top: 1px solid var(--border-color);
    border-right: 1px solid #f1f5f9;
    padding: 1rem;
}

.jgbtablecss tbody td:last-child {
    border-right: none;
}

.jgbtablecss p {
    margin: 0;
    padding: 0;
}

.jgbtablecss tbody tr:nth-child(even) {
    background: var(--bg-color);
}

.jgbtablecss tbody tr:hover {
    background: #eef2ff;
    /* Very light indigo hover */
    box-shadow: inset 4px 0 0 0 var(--primary-color);
}

.jgbtablecss tbody td:first-child {
    font-weight: 600;
    color: var(--primary-color);
}

.jgbtablecss caption {
    caption-side: top;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--primary-color);
    line-height: 1.2;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 0 0.5rem;
        /* Reduced from 1rem to 0.5rem */
    }

    /* Header adjustments */
    .header-content {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .datetime-display {
        display: flex;
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
        gap: 0.5rem;
        font-size: 0.8rem;

        /* New Mobile Style */
        background-color: #f1f5f9;
        padding: 0.5rem;
        border-radius: 8px;
        margin-bottom: 0.5rem;
    }

    /* Tabs: 2 per row grid as requested, safer with text wrap */
    .tabs {
        width: 100%;
        left: auto;
        transform: none;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        padding: 0;
        background: transparent;
        gap: 0.5rem;
        border-radius: 0;
        margin-bottom: 2rem;
    }

    .tab-btn {
        flex: 1 1 calc(50% - 0.5rem);
        /* 2 per row */
        text-align: center;
        background: #e2e8f0;
        border-radius: 8px;
        padding: 0.75rem 0.25rem;
        /* More vertical padding */
        font-size: 0.85rem;
        white-space: normal;
        /* Allow wrap */
        line-height: 1.2;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 48px;
        /* Touch target size */
    }

    .tab-btn.active {
        background: var(--primary-color);
        color: white;
        box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
    }

    /* Stack the main tool areas */
    .steps-container {
        flex-direction: column;
        gap: 1rem;
    }

    .drop-zone {
        padding: 1.5rem 1rem;
    }

    /* Converter/Compressor controls stack */
    #compressor-controls .converter-settings {
        padding-top: 1rem;
    }

    /* Input groups stack */
    .dimensions-group {
        width: 100%;
        flex-wrap: wrap;
    }

    .input-group {
        width: 100%;
    }

    /* Global actions */
    .global-actions,
    #global-actions-compress,
    #global-actions-convert,
    #global-actions-resize {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .global-actions .btn,
    .btn {
        width: 100%;
        margin: 0;
    }

    /* Image Grid Adjustments */
    .image-list {
        grid-template-columns: repeat(2, 1fr);
    }

    .image-preview {
        height: 120px;
    }

    #image-list-exif {
        grid-template-columns: 1fr !important;
    }

    .info-content {
        padding: 0 0.5rem !important;
        /* Reduced padding for text blocks */
    }

    /* Info Content headers */
    .info-content h1 {
        font-size: 1.7rem;
        line-height: 1.25;
    }

    /* Tool Intro Adjustments */
    .tool-intro {
        margin-bottom: 1.5rem;
    }

    .main-title {
        font-size: 1.75rem;
        /* Smaller font for mobile */
        margin-bottom: 0.75rem;
    }

    .lead {
        font-size: 1rem;
        padding: 0 0.5rem;
        margin-bottom: 1.5rem;
    }

    /* Table Responsive: Compact 3-Column View */
    .jgbtablecss {
        display: table;
        width: 100%;
        table-layout: fixed;
        font-size: 13px !important;
        /* Force 13px */
    }

    .jgbtablecss thead {
        display: table-header-group;
    }

    .jgbtablecss tbody {
        display: table-row-group;
    }

    .jgbtablecss tr {
        display: table-row;
        margin-bottom: 0;
        box-shadow: none;
        border: none;
        background: transparent;
    }

    .jgbtablecss th,
    .jgbtablecss td {
        display: table-cell;
        padding: 0.25rem 0.1rem;
        /* Reduced from 0.5rem 0.2rem */
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        vertical-align: top;
        text-align: left;
        font-size: 13px !important;
        /* Force 13px */
    }

    .jgbtablecss p {
        font-size: 13px !important;
        /* Force 13px on paragraphs too */
        margin: 0;
    }

    .jgbtablecss td::before {
        display: none;
    }

    .jgbtablecss td {
        padding-left: 0.1rem;
        /* Reduced padding */
        min-height: auto;
        border-bottom: 1px solid var(--border-color);
    }

    .jgbtablecss th {
        font-size: 13px !important;
        /* Force 13px */
        padding: 0.25rem 0.1rem;
        /* Reduced padding */
        font-weight: 700;
    }

    /* Adjust specific column widths if needed to fit 3 cols */
    .jgbtablecss th:nth-child(1),
    .jgbtablecss td:nth-child(1) {
        width: 25%;
        /* Slightly smaller first col */
    }

    .jgbtablecss th:nth-child(2),
    .jgbtablecss td:nth-child(2) {
        width: 45%;
        /* Larger middle col for text */
    }

    .jgbtablecss th:nth-child(3),
    .jgbtablecss td:nth-child(3) {
        width: 30%;
        /* Rest for formats */
    }

    .jgbtablecss td p {
        text-align: left;
        margin: 0;
    }
}

/* Main Comparison Viewer Container */
.comparison-viewer-wrapper {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    animation: slide-down 0.3s ease-out;
    overflow: hidden;
}

.comparison-viewer-wrapper.hidden {
    display: none;
}

@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.viewer-header h4 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.viewer-header h4 span {
    color: var(--text-main);
    font-weight: 700;
}

/* Reusing .comparison-view but specific to big viewer */
.comparison-view.big-viewer {
    width: 100%;
    /* Fixed aspect or max height? Let's use max-height so it doesn't take entire screen */
    height: 400px;
    /* Reduced from 500px */
    max-height: 50vh;
    /* Reduced from 60vh */
    background-color: #eee;
    /* Checkerboard pattern */
    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-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;

    position: relative;
    overflow: hidden;
    cursor: col-resize;
    user-select: none;
    touch-action: pan-y;
}

.viewer-label {
    position: absolute;
    top: 10px;
    z-index: 20;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.viewer-label.original {
    left: 10px;
}

.viewer-label.result {
    right: 10px;
    background: rgba(37, 99, 235, 0.85);
    /* Primary color hint */
}


.comp-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    pointer-events: none;
    /* Main viewer uses CONTAIN to show full image */
    background-size: contain;
    background-position: center;
}

.comp-layer.after {
    z-index: 1;
    transform-origin: center center;
}

.comp-layer.before {
    width: 50%;
    border-right: 2px solid #fff;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    z-index: 2;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.01);
    /* catch clicks if needed, though pointer events none */
    will-change: width;
}

/* Smooth transition for images to reduce flicker */
.comp-layer,
.comp-layer.after,
.comp-layer-inner {
    transition: background-image 0.2s ease-in-out;
}



/* Custom Range Slider Styling */
/* Toggle Switch specific */
.switch input {
    display: none;
}

.slider.round:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.switch input:checked+.slider {
    background-color: var(--primary-color) !important;
}

.switch input:checked+.slider:before {
    transform: translateX(14px);
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    transition: background 0.3s;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

/* Inner layer for before image to keep alignment */
.comp-layer-inner {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    display: block;
    transform-origin: center center;
}

/* Icon Buttons XS in viewer */
.icon-btn.xs {
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comp-handle-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid var(--primary-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    color: var(--primary-color);
}

.comp-handle-icon {
    width: 16px;
    height: 16px;
}

.viewer-footer {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Adjust mobile height */
@media (max-width: 768px) {
    .comparison-view.big-viewer {
        height: 300px;
    }
}

/* Update image-preview to allow free layering */
.image-preview {
    padding: 0;
    position: relative;
    /* Remove default bg if we use layers here, usually overridden by inline style, we will handle in JS */
}