        :root {
            --primary: #4f46e5;
            --primary-hover: #4338ca;
            --bg: #f9fafb;
            --text: #111827;
            --danger: #ef4444;
            --border: #e5e7eb;
        }

        body {
            font-family: 'Inter', system-ui, -apple-system, sans-serif;
            margin: 0;
            background: var(--bg);
            color: var(--text);
        }

        /* Header & Logo */
        header {
            background: white;
            padding: 0.75rem 2rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--border);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        }

        .brand {
            display: flex;
            align-items: center;
            gap: 10px;
            text-decoration: none;
        }

        .logo-mark {
            background: var(--primary);
            color: white;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            font-weight: 900;
            font-size: 1.2rem;
        }

        .logo-text {
            font-weight: 800;
            font-size: 1.2rem;
            color: #1f2937;
            letter-spacing: -0.5px;
        }

        .privacy-badge {
            font-size: 0.75rem;
            font-weight: 600;
            background: #ecfdf5;
            color: #065f46;
            padding: 6px 16px;
            border-radius: 20px;
            border: 1px solid #d1fae5;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        /* Intro strip above the tool (H1 + value prop). Compact on desktop, hero on mobile. */
        .intro {
            display: flex;
            align-items: baseline;
            gap: 0.75rem;
            padding: 0.6rem 2rem;
            background: white;
            border-bottom: 1px solid var(--border);
            height: 48px;
            box-sizing: border-box;
            overflow: hidden;
            white-space: nowrap;
        }

        .intro h1 {
            margin: 0;
            font-size: 1.05rem;
            font-weight: 800;
            letter-spacing: -0.3px;
        }

        .intro p {
            margin: 0;
            font-size: 0.9rem;
            color: #4b5563;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .btn-choose {
            display: none;
        }

        /* Tool fills the first screen; the content below scrolls */
        .main-container {
            display: flex;
            height: calc(100vh - 57px - 48px);
            min-height: 560px;
            overflow: hidden;
        }

        /* Content below the tool */
        .content {
            max-width: 820px;
            margin: 0 auto;
            padding: 3rem 1.5rem 2rem;
            line-height: 1.7;
            color: #374151;
        }

        .content>h2:first-child {
            margin-top: 0;
            font-size: 1.6rem;
            letter-spacing: -0.5px;
            line-height: 1.25;
        }

        .content h2 {
            font-size: 1.3rem;
            font-weight: 800;
            color: var(--text);
            margin: 2.5rem 0 0.75rem;
        }

        .content h3 {
            font-size: 1rem;
            font-weight: 700;
            color: var(--text);
            margin: 1.25rem 0 0.25rem;
        }

        .content p {
            margin: 0 0 1rem;
        }

        .content ol {
            padding-left: 1.25rem;
        }

        .content li {
            margin-bottom: 0.5rem;
        }

        .site-footer {
            border-top: 1px solid var(--border);
            background: white;
            padding: 1.5rem;
            text-align: center;
            font-size: 0.85rem;
            color: #6b7280;
        }

        .site-footer a {
            color: #4b5563;
            margin: 0 0.75rem;
            text-decoration: none;
        }

        .site-footer a:hover {
            color: var(--primary);
        }

        /* Sidebar */
        .sidebar {
            width: 350px;
            background: white;
            padding: 1.5rem;
            border-right: 1px solid var(--border);
            overflow-y: auto;
            display: flex;
            flex-direction: column;
        }

        .section-title {
            font-size: 0.7rem;
            font-weight: 800;
            text-transform: uppercase;
            color: #6b7280;
            margin: 1.5rem 0 0.5rem;
            display: block;
            letter-spacing: 0.8px;
        }

        .input-card {
            background: #fff;
            border: 1px solid var(--border);
            padding: 1rem;
            border-radius: 12px;
            margin-bottom: 1.2rem;
        }

        label {
            display: block;
            font-size: 0.85rem;
            font-weight: 600;
            margin-bottom: 0.6rem;
            color: #374151;
        }

        input,
        select {
            width: 100%;
            padding: 0.75rem;
            border: 1px solid #d1d5db;
            border-radius: 8px;
            box-sizing: border-box;
            font-size: 0.9rem;
            outline: none;
            transition: 0.2s;
        }

        input:focus {
            border-color: var(--primary);
        }

        :focus-visible {
            outline: 3px solid #a5b4fc;
            outline-offset: 2px;
        }

        input[type="range"] {
            accent-color: var(--primary);
            cursor: pointer;
        }

        .row {
            display: flex;
            gap: 8px;
        }

        .row input {
            min-width: 0;
        }

        .row select {
            width: auto;
            flex: 0 0 auto;
        }

        .field-title {
            display: block;
            font-size: 0.85rem;
            font-weight: 600;
            margin: 14px 0 0.6rem;
            color: #374151;
        }

        .result-box {
            font-size: 0.9rem;
            line-height: 1.4;
            padding: 12px;
            border-radius: 10px;
            margin-bottom: 0.5rem;
            border: 1px solid var(--border);
            background: #f9fafb;
        }

        .result-box.ok {
            background: #ecfdf5;
            border-color: #a7f3d0;
            color: #065f46;
        }

        .result-box.bad {
            background: #fef2f2;
            border-color: #fecaca;
            color: #991b1b;
        }

        .result-box small {
            display: block;
            margin-top: 2px;
            opacity: 0.85;
        }

        .btn-main:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none;
        }

        .combo {
            position: relative;
        }

        .combo-list {
            position: absolute;
            left: 0;
            right: 0;
            top: 100%;
            z-index: 30;
            max-height: 280px;
            overflow-y: auto;
            margin: 4px 0 0;
            padding: 4px 0;
            list-style: none;
            background: white;
            border: 1px solid #d1d5db;
            border-radius: 8px;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
        }

        .combo-list .grp {
            padding: 8px 12px 4px;
            font-size: 0.7rem;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 0.8px;
            color: #6b7280;
        }

        .combo-list [role="option"] {
            padding: 12px;
            min-height: 44px;
            box-sizing: border-box;
            font-size: 0.9rem;
            cursor: pointer;
        }

        .combo-list [role="option"].active,
        .combo-list [role="option"][aria-selected="true"] {
            background: #eef2ff;
        }

        .combo-list .none {
            padding: 12px;
            font-size: 0.9rem;
            color: #6b7280;
        }

        .spec-card {
            margin-top: 12px;
            font-size: 0.85rem;
            line-height: 1.5;
            color: #374151;
        }

        .spec-card .title {
            font-weight: 700;
            color: var(--text);
        }

        .spec-card a {
            color: var(--primary);
            font-weight: 600;
        }

        .spec-card .warn {
            color: #92400e;
            font-weight: 600;
        }

        .spec-card .hint {
            color: #6b7280;
            font-size: 0.8rem;
        }

        .btn-link {
            margin-top: 10px;
            min-height: 44px;
            padding: 0 14px;
            background: white;
            border: 1px solid #d1d5db;
            border-radius: 8px;
            font-size: 0.85rem;
            font-weight: 600;
            color: #374151;
            cursor: pointer;
        }

        .stats-container {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
            margin-bottom: 0.5rem;
        }

        .stat-box {
            background: #f9fafb;
            padding: 12px;
            border-radius: 10px;
            text-align: center;
            border: 1px solid var(--border);
        }

        .stat-val {
            display: block;
            font-weight: 700;
            font-size: 1rem;
            color: #111827;
        }

        .stat-lbl {
            font-size: 0.65rem;
            color: #6b7280;
            text-transform: uppercase;
            font-weight: 600;
        }

        /* Preview Pane */
        .preview-pane {
            flex: 1;
            background: #f3f4f6;
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 2rem;
            overflow: auto;
        }

        /* Improved File Upload Icon Thumbnail */
        .empty-state {
            text-align: center;
            cursor: pointer;
            padding: 4rem 2rem;
            border: 2px dashed #d1d5db;
            border-radius: 24px;
            transition: all 0.3s ease;
            max-width: 400px;
            width: 100%;
            background: white;
        }

        .empty-state:hover {
            border-color: var(--primary);
            background: #f5f3ff;
            transform: translateY(-2px);
        }

        .empty-state svg {
            width: 64px;
            height: 64px;
            fill: none;
            stroke: var(--primary);
            stroke-width: 1.5;
            margin-bottom: 20px;
        }

        .empty-state h2 {
            margin: 0;
            font-size: 1.3rem;
            color: #111827;
            font-weight: 800;
        }

        .empty-state p {
            color: #6b7280;
            font-size: 0.9rem;
            margin-top: 10px;
            line-height: 1.6;
        }

        .canvas-wrapper {
            background: white;
            padding: 12px;
            border-radius: 12px;
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
            display: none;
        }

        canvas {
            max-width: 100%;
            height: auto;
            display: block;
            border-radius: 6px;
        }

        /* Actions */
        .actions {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-top: auto;
            padding-top: 1.5rem;
        }

        .btn-main {
            background: var(--primary);
            color: white;
            border: none;
            width: 100%;
            padding: 1.1rem;
            border-radius: 12px;
            font-weight: 700;
            cursor: pointer;
            transition: 0.2s;
            font-size: 1rem;
        }

        .btn-main:hover {
            background: var(--primary-hover);
            transform: scale(1.02);
        }

        .btn-reset {
            background: transparent;
            color: #6b7280;
            border: 1px solid var(--border);
            width: 100%;
            padding: 0.8rem;
            border-radius: 12px;
            font-weight: 600;
            cursor: pointer;
        }

        .btn-reset:hover {
            background: #fee2e2;
            color: var(--danger);
            border-color: #fca5a5;
        }

        .hidden {
            display: none !important;
        }

        /* Tablet / small laptop: stack, no fixed heights */
        @media (max-width: 1023px) {
            .main-container {
                flex-direction: column;
                height: auto;
                min-height: 0;
                overflow: visible;
            }

            .sidebar {
                width: 100%;
                height: auto;
                box-sizing: border-box;
            }

            .preview-pane {
                min-height: 300px;
            }
        }

        /* Mobile-first single column: choose photo -> preview -> controls -> sticky download */
        @media (max-width: 768px) {
            header {
                padding: 0.5rem 1rem;
                gap: 0.5rem;
                flex-wrap: wrap;
            }

            .brand {
                min-height: 44px;
            }

            .privacy-badge {
                padding: 6px 10px;
            }

            .hide-sm {
                display: none;
            }

            .intro {
                display: block;
                height: auto;
                white-space: normal;
                padding: 1.25rem 1rem 1rem;
                background: var(--bg);
                border-bottom: 0;
            }

            .intro h1 {
                font-size: 1.6rem;
                line-height: 1.2;
            }

            .intro p {
                margin: 0.5rem 0 1rem;
                font-size: 1rem;
                line-height: 1.45;
            }

            .btn-choose {
                display: block;
                width: 100%;
                min-height: 56px;
                background: var(--primary);
                color: white;
                border: 0;
                border-radius: 14px;
                font-size: 1.1rem;
                font-weight: 700;
                cursor: pointer;
            }

            .btn-choose:active {
                background: var(--primary-hover);
            }

            /* The sidebar's children become flex items of .main-container so they can be re-ordered */
            .sidebar {
                display: contents;
            }

            .main-container {
                display: flex;
                padding: 0 1rem 0;
            }

            .preview-pane {
                order: 1;
                min-height: 0;
                padding: 0.75rem;
                border-radius: 14px;
                margin-bottom: 0.75rem;
            }

            .stats-container,
            .result-box {
                order: 2;
            }

            .sidebar>.section-title,
            .sidebar>.input-card {
                order: 3;
            }

            .actions {
                order: 4;
            }

            /* Nothing to preview until a photo is chosen */
            body:not(.has-image) .preview-pane,
            body:not(.has-image) .stats-container,
            body:not(.has-image) .actions {
                display: none;
            }

            .empty-state {
                display: none !important;
            }

            canvas {
                width: auto;
                max-height: 50vh;
                object-fit: contain;
            }

            .canvas-wrapper {
                padding: 8px;
                max-width: 100%;
                box-sizing: border-box;
            }

            input,
            select {
                font-size: 16px;
                min-height: 44px;
            }

            input[type="range"] {
                min-height: 44px;
                padding: 0;
            }

            .input-card {
                margin-bottom: 0.75rem;
            }

            .actions {
                position: sticky;
                bottom: 0;
                z-index: 10;
                flex-direction: row;
                align-items: stretch;
                margin: 0 -1rem;
                padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
                background: rgba(255, 255, 255, 0.97);
                border-top: 1px solid var(--border);
                box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
            }

            .btn-main {
                flex: 1;
                min-height: 52px;
                padding: 0.9rem;
            }

            .btn-main:hover {
                transform: none;
            }

            .btn-reset {
                flex: 0 0 auto;
                width: auto;
                min-width: 88px;
                min-height: 52px;
            }

            .content {
                padding: 2rem 1rem 1.5rem;
            }

            .site-footer a {
                display: inline-block;
                padding: 0.9rem 0.5rem;
                margin: 0;
            }
        }

/* Landing pages (spec 004) */
.crumbs {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0 0 1rem;
}

.crumbs a {
    color: #4b5563;
}

.spec-box {
    margin: 0 0 2rem;
}

.spec-box h2 {
    margin-top: 0;
}

.spec-box table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.spec-box caption {
    text-align: left;
    font-weight: 700;
    color: var(--text);
    padding: 0 0 0.4rem;
}

.spec-box th,
.spec-box td {
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.spec-box th {
    width: 32%;
    color: #4b5563;
    font-weight: 600;
}

.spec-box a {
    color: var(--primary);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.spec-note {
    font-size: 0.85rem;
    color: #6b7280;
}

.related ul,
.popular ul {
    padding-left: 1.25rem;
}

.related a,
.popular a,
.content a {
    color: var(--primary);
}

@media (max-width: 768px) {
    .related li,
    .popular li {
        margin-bottom: 0.25rem;
    }

    .related a,
    .popular a {
        display: inline-block;
        padding: 0.55rem 0;
    }

    .spec-box th {
        width: 38%;
    }
}

/* Crop editor (spec 005) */
.preview-pane {
    flex-direction: column;
    gap: 12px;
}

.crop-stage {
    position: relative;
    display: inline-block;
    line-height: 0;
    max-width: 100%;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.crop-stage.hidden {
    display: none !important;
}

#cropView {
    display: block;
    max-width: 100%;
    max-height: 60vh;
    width: auto;
    height: auto;
    border-radius: 6px;
}

.crop-box {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(17, 24, 39, 0.55), 0 0 0 1px var(--primary) inset;
    cursor: move;
    touch-action: none;
}

.crop-h {
    position: absolute;
    width: 22px;
    height: 22px;
    background: var(--primary);
    border: 2px solid #fff;
    border-radius: 50%;
    box-sizing: border-box;
    touch-action: none;
}

.crop-h::after {
    content: "";
    position: absolute;
    inset: -12px;
}

.crop-h.nw { left: -12px; top: -12px; cursor: nwse-resize; }
.crop-h.ne { right: -12px; top: -12px; cursor: nesw-resize; }
.crop-h.sw { left: -12px; bottom: -12px; cursor: nesw-resize; }
.crop-h.se { right: -12px; bottom: -12px; cursor: nwse-resize; }

.crop-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.crop-bar .btn-link {
    margin-top: 0;
}

.crop-bar.hidden {
    display: none !important;
}

label.check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin: 10px 0 0;
    font-weight: 600;
}

input[type="checkbox"] {
    width: 20px;
    min-height: 0 !important;
    height: 20px;
    padding: 0;
    flex: 0 0 auto;
    accent-color: var(--primary);
}

/* File messages + HEIC spinner (spec 006) */
.file-msg {
    margin-top: 0.75rem;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.4;
    background: #f3f4f6;
    color: #374151;
    white-space: normal;
}

.file-msg.bad {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.file-msg.busy {
    background: #eef2ff;
    color: #3730a3;
}

.file-msg.hidden {
    display: none;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    vertical-align: -2px;
    border: 2px solid #c7d2fe;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (min-width: 769px) {
    .intro .file-msg {
        margin: 0 0 0 auto;
        padding: 2px 10px;
        flex: 0 1 auto;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Install button (spec 007) */
.install-box {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 0.5rem;
}

.install-box.hidden {
    display: none;
}

.install-btn {
    min-height: 44px;
    padding: 0 14px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
}

.install-x {
    min-width: 44px;
    min-height: 44px;
    background: transparent;
    border: 0;
    font-size: 1.25rem;
    color: #6b7280;
    cursor: pointer;
}

/* Upload checklist (spec 013) */
.upload-set {
    max-width: 820px;
    margin: 0 auto;
    padding: 0.5rem 1rem 1rem;
}

.upload-set h2 {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #6b7280;
}

.upload-set ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.upload-set button {
    width: 100%;
    min-height: 56px;
    text-align: left;
    padding: 8px 12px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
}

.upload-set button .name {
    font-weight: 700;
    font-size: 0.9rem;
}

.upload-set button .limits {
    font-size: 0.75rem;
    color: #4b5563;
}

.upload-set button.current {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px #c7d2fe;
}

.upload-set button.done {
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.upload-set .tick {
    position: absolute;
    top: 8px;
    right: 10px;
    color: #047857;
    font-weight: 800;
}

.hint-text {
    margin: 10px 0 0;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #6b7280;
}

/* Batch mode (spec 011) */
.batch-panel {
    width: 100%;
    max-width: 760px;
    align-self: stretch;
}

.batch-panel.hidden {
    display: none !important;
}

.batch-note {
    margin: 0 0 10px;
    font-size: 0.85rem;
    color: #4b5563;
}

.batch-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
    font-weight: 600;
}

.batch-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.batch-actions .btn-link {
    margin-top: 0;
}

.batch-actions .btn-link:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.batch-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.batch-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    min-height: 56px;
}

.batch-list .thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    background: #e5e7eb;
    flex: 0 0 auto;
}

.batch-list .info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.batch-list .nm {
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.batch-list .meta {
    font-size: 0.8rem;
    color: #4b5563;
}

.batch-list .dl {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
}

body.batch-mode #dlBtn,
body.batch-mode .stats-container,
body.batch-mode .result-box,
body.batch-mode #cropBar {
    display: none !important;
}

/* a long result list must scroll from its top, not be centred and clipped */
body.batch-mode .preview-pane {
    justify-content: flex-start;
}

body.batch-mode .actions {
    display: none !important;
}

/* Language switch (Hindi pages discoverable from the header) */
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.lang-link,
.crumbs .lang-pill {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid #c7d2fe;
    border-radius: 22px;
    background: #eef2ff;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    box-sizing: border-box;
}

.crumbs .lang-pill {
    margin-left: 8px;
    min-height: 36px;
    font-size: 0.85rem;
}

.lang-link:hover,
.crumbs .lang-pill:hover {
    background: #e0e7ff;
}

.popular h3 {
    margin: 1.25rem 0 0.25rem;
    font-size: 1rem;
}
