/* =========================================================
   ImageConverter — design system
   ========================================================= */

:root {
    --primary: #5b57f0;
    --primary-dark: #4a46d6;
    --primary-light: #eef0ff;
    --primary-contrast: #ffffff;
    --navy: #10132b;
    --navy-soft: #171a37;
    --bg-page: #f5f6fb;
    --bg-card: #ffffff;
    --border: #e6e8f0;
    --border-strong: #d7dae6;
    --text: #14162a;
    --text-muted: #6b7089;
    --text-faint: #9498ac;
    --success: #16a34a;
    --success-bg: #eafaf0;
    --danger: #dc2626;
    --danger-bg: #fdecec;
    --warning: #d97706;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(16, 19, 43, 0.06);
    --shadow-md: 0 8px 24px rgba(16, 19, 43, 0.08);
    --shadow-lg: 0 16px 40px rgba(16, 19, 43, 0.12);
    --topbar-h: 64px;
    --sidebar-w: 240px;
}

[data-theme="dark"] {
    --bg-page: #0d0f1f;
    --bg-card: #151830;
    --border: #262a4a;
    --border-strong: #33385f;
    --text: #f1f2fb;
    --text-muted: #a3a7c2;
    --text-faint: #767ba0;
    --primary-light: #24265a;
    --navy: #0a0c1c;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg-page);
    color: var(--text);
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    transition: background 0.2s ease, color 0.2s ease;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    background: var(--primary);
    color: #fff;
    padding: 8px 16px;
    z-index: 2000;
}

    .skip-link:focus {
        left: 8px;
        top: 8px;
    }

.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.icon-xs {
    width: 14px;
    height: 14px;
}

.icon-sm {
    width: 16px;
    height: 16px;
}

.icon-md {
    width: 28px;
    height: 28px;
}

.icon-lg {
    width: 32px;
    height: 32px;
}

.icon-xl {
    width: 44px;
    height: 44px;
}

/* ---------------------------------------------------------
   Top bar
   --------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-h);
    background: var(--navy);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.topbar-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    gap: 16px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #fff;
    padding: 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

    .sidebar-toggle:hover {
        background: rgba(255,255,255,0.08);
    }

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    color: #fff;
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--primary);
}

    .brand-icon .icon {
        color: #fff;
    }

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    padding-left: 20px;
}

.topbar-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255,255,255,0.75);
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    font-weight: 500;
    background: transparent;
    border: none;
    cursor: pointer;
}

    .topbar-link:hover {
        color: #fff;
        background: rgba(255,255,255,0.08);
    }

    .topbar-link.active {
        color: #fff;
    }

.topbar-dropdown {
    position: relative;
}

.dropdown-menu-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    z-index: 200;
}

    .dropdown-menu-panel.show {
        display: block;
    }

/* ---- Tools mega-menu (grid of icon cards) ---- */
.tools-mega-panel {
    width: 760px;
    max-width: calc(100vw - 40px);
    padding: 16px;
}

.tools-mega-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.tools-mega-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-md);
    color: var(--text);
}

    .tools-mega-item:hover {
        background: var(--bg-page);
    }

    .tools-mega-item.active {
        background: var(--primary-light);
    }

.tools-mega-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .tools-mega-icon .icon {
        width: 21px;
        height: 21px;
    }

.tools-mega-text h5 {
    margin: 0 0 2px;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text);
}

.tools-mega-text p {
    margin: 0;
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.35;
}

.tools-mega-icon.c1 {
    background: rgba(34, 197, 94, .15);
    color: #16a34a;
}

.tools-mega-icon.c2 {
    background: rgba(124, 58, 237, .15);
    color: #7c3aed;
}

.tools-mega-icon.c3 {
    background: rgba(249, 115, 22, .15);
    color: #ea580c;
}

.tools-mega-icon.c4 {
    background: rgba(59, 130, 246, .15);
    color: #2563eb;
}

.tools-mega-icon.c5 {
    background: rgba(236, 72, 153, .15);
    color: #db2777;
}

.tools-mega-icon.c6 {
    background: rgba(20, 184, 166, .15);
    color: #0d9488;
}

.tools-mega-icon.c7 {
    background: rgba(234, 179, 8, .15);
    color: #ca8a04;
}

.tools-mega-icon.c8 {
    background: rgba(99, 102, 241, .15);
    color: #4f46e5;
}

@media (max-width: 1080px) {
    .tools-mega-panel {
        width: 620px;
    }

    .tools-mega-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: rgba(255,255,255,0.06);
    color: #fff;
    cursor: pointer;
}

    .icon-btn:hover {
        background: rgba(255,255,255,0.14);
    }

    .icon-btn.danger {
        background: transparent;
        color: var(--danger);
        border: 1px solid var(--border);
    }

        .icon-btn.danger:hover {
            background: var(--danger-bg);
        }

/* Icon button used inside light cards (not the dark topbar) needs dark icon color */
.preview-card .icon-btn {
    color: var(--danger);
}

/* ---------------------------------------------------------
   Shell: sidebar + main content
   --------------------------------------------------------- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 18px 12px;
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14.5px;
    font-weight: 500;
}

    .sidebar-item .icon {
        color: var(--text-faint);
    }

    .sidebar-item:hover {
        background: var(--bg-page);
        color: var(--text);
    }

    .sidebar-item.active {
        background: var(--primary-light);
        color: var(--primary);
        font-weight: 700;
    }

        .sidebar-item.active .icon {
            color: var(--primary);
        }

.sidebar-brand-item {
    font-weight: 700;
    color: var(--text);
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 10px 4px 12px;
}

.sidebar-backdrop {
    display: none;
}

.main-content {
    padding: 28px 32px 60px;
    max-width: 1280px;
    width: 100%;
}

/* ---------------------------------------------------------
   Professional footer
   --------------------------------------------------------- */
.site-footer {
    background: linear-gradient(180deg, #0a0c1e 0%, #05060f 100%);
    color: #aeb2c9;
    margin-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.footer-top {
    max-width: 1280px;
    margin: 0 auto;
    padding: 56px 32px 32px;
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1.2fr;
    gap: 32px;
}

.footer-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 21px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 14px;
}

.footer-brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #7c6ff0, #5b57f0);
    color: #fff;
    flex-shrink: 0;
}

.footer-brand-text .accent,
.footer-bottom-brand .text-accent {
    background: linear-gradient(90deg, #8b7bf7, #c179e8);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.footer-tagline {
    font-size: 13.5px;
    line-height: 1.6;
    color: #8b8fac;
    margin: 0 0 20px;
    max-width: 320px;
}

.footer-badges {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: 340px;
}

.footer-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #c6c9de;
    line-height: 1.3;
}

.footer-badge-icon {
    color: #a89bfa;
    flex-shrink: 0;
    display: flex;
}

    .footer-badge-icon .icon {
        width: 18px;
        height: 18px;
    }

.footer-col h5 {
    color: #fff;
    font-size: 14.5px;
    font-weight: 700;
    margin: 0 0 16px;
    position: relative;
    padding-bottom: 10px;
}

    .footer-col h5::after {
        content: "";
        position: absolute;
        left: 0;
        bottom: 0;
        width: 34px;
        height: 2px;
        background: linear-gradient(90deg, #8b7bf7, #c179e8);
    }

.footer-col ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 11px;
}

    .footer-col ul a {
        font-size: 13.5px;
        color: #9a9dbb;
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

        .footer-col ul a:hover {
            color: #fff;
        }

        .footer-col ul a::before {
            content: "\203A";
            color: #6a6d94;
        }

.footer-col > p {
    font-size: 13px;
    color: #8b8fac;
    margin: 0 0 14px;
    line-height: 1.5;
}

.footer-newsletter {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

    .footer-newsletter input {
        flex: 1;
        min-width: 0;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 10px;
        padding: 0 12px;
        height: 42px;
        color: #fff;
        font-size: 13px;
    }

        .footer-newsletter input::placeholder {
            color: #767ba0;
        }

        .footer-newsletter input:focus {
            outline: none;
            border-color: #7c6ff0;
        }

    .footer-newsletter button {
        width: 42px;
        height: 42px;
        flex-shrink: 0;
        border: none;
        border-radius: 10px;
        cursor: pointer;
        background: linear-gradient(135deg, #7c6ff0, #5b57f0);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        .footer-newsletter button:hover {
            filter: brightness(1.1);
        }

    .footer-newsletter .icon {
        width: 17px;
        height: 17px;
    }

.footer-social {
    display: flex;
    gap: 10px;
}

    .footer-social a {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.06);
        display: flex;
        align-items: center;
        justify-content: center;
        color: #c6c9de;
    }

        .footer-social a:hover {
            background: linear-gradient(135deg, #7c6ff0, #5b57f0);
            color: #fff;
        }

    .footer-social .icon {
        width: 16px;
        height: 16px;
    }

.footer-stats {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 32px 32px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.footer-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 16px 18px;
}

.footer-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    background: rgba(124, 111, 240, 0.18);
    color: #a89bfa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer-stat b {
    display: block;
    font-size: 19px;
    color: #fff;
    line-height: 1.3;
}

.footer-stat span {
    font-size: 12px;
    color: #8b8fac;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}

.footer-bottom-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.footer-bottom-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #7c6ff0, #5b57f0);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

    .footer-bottom-icon .icon {
        width: 18px;
        height: 18px;
    }

.footer-bottom-brand b {
    color: #fff;
    font-size: 14px;
}

.footer-bottom-brand p {
    margin: 2px 0 0;
    font-size: 11.5px;
    color: #767ba0;
    display: flex;
    align-items: center;
    gap: 4px;
}

    .footer-bottom-brand p .icon {
        width: 12px;
        height: 12px;
        color: #e8639a;
        fill: #e8639a;
    }

.footer-bottom-links {
    display: flex;
    gap: 18px;
    font-size: 12.5px;
}

    .footer-bottom-links a {
        color: #9a9dbb;
    }

        .footer-bottom-links a:hover {
            color: #fff;
        }

.footer-bottom-copy {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #767ba0;
}

    .footer-bottom-copy .icon {
        width: 16px;
        height: 16px;
        color: #6a6d94;
    }

/* ---------------------------------------------------------
   Page header
   --------------------------------------------------------- */
.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 800;
    margin: 0 0 4px;
    color: var(--text);
}

.page-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 14.5px;
}

/* ---------------------------------------------------------
   Alerts (toasts)
   --------------------------------------------------------- */
.alert-stack {
    position: fixed;
    top: 84px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
}

.app-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    animation: slideIn 0.2s ease;
    border: 1px solid var(--border);
    background: var(--bg-card);
}

    .app-alert.success {
        border-color: var(--success);
        background: var(--success-bg);
        color: #0d5a2a;
    }

    .app-alert.error {
        border-color: var(--danger);
        background: var(--danger-bg);
        color: #8a1414;
    }

    .app-alert .icon {
        flex-shrink: 0;
        margin-top: 1px;
    }

.app-alert-close {
    margin-left: auto;
    background: transparent;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 2px;
}

    .app-alert-close:hover {
        opacity: 1;
    }

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------------------------------------------------------
   Converter grid
   --------------------------------------------------------- */
.converter-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 22px;
    align-items: start;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.upload-panel {
    min-height: 360px;
    display: flex;
    flex-direction: column;
}

/* Dropzone */
.dropzone {
    flex: 1;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-page);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

    .dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
        border-color: var(--primary);
        background: var(--primary-light);
        outline: none;
    }

.dropzone-icon {
    color: var(--primary);
    margin-bottom: 14px;
}

.dropzone h3 {
    margin: 0 0 10px;
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
}

.dropzone-or {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-faint);
    font-size: 13px;
    width: 160px;
    margin: 2px 0 14px;
}

    .dropzone-or span {
        flex: 1;
        height: 1px;
        background: var(--border-strong);
    }

.btn-choose {
    margin-bottom: 14px;
}

.dropzone-hint {
    margin: 0;
    color: var(--text-faint);
    font-size: 13px;
}

.visually-hidden-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* Preview card (selected file) */
.preview-card {
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    background: var(--bg-page);
}

.preview-thumb {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-faint);
}

    .preview-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.preview-meta {
    flex: 1;
    min-width: 0;
}

.preview-filename {
    font-weight: 600;
    font-size: 14.5px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-details {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 0 8px;
    color: var(--text-muted);
}

.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--border-strong);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.result-state {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.result-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.result-success-icon {
    color: var(--success);
}

.result-header h4 {
    margin: 0 0 2px;
    font-size: 16px;
}

.result-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13.5px;
}

.result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------------------------------------------------------
   Options panel
   --------------------------------------------------------- */
.options-panel {
    position: sticky;
    top: calc(var(--topbar-h) + 20px);
}

.options-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 18px;
    color: var(--text);
}

.option-group {
    margin-bottom: 18px;
}

    .option-group label {
        display: flex;
        justify-content: space-between;
        font-size: 13.5px;
        font-weight: 600;
        color: var(--text);
        margin-bottom: 8px;
    }

        .option-group label span {
            color: var(--primary);
            font-weight: 700;
        }

.form-select, .form-control {
    background: var(--bg-page);
    border: 1px solid var(--border-strong);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

    .form-select:focus, .form-control:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px var(--primary-light);
    }

.form-range {
    accent-color: var(--primary);
}

.custom-size-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

    .custom-size-row span {
        color: var(--text-faint);
    }

.form-check.form-switch {
    padding-left: 2.4em;
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-label {
    font-size: 13.5px;
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    padding: 11px 18px;
    font-weight: 600;
    font-size: 14.5px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: filter 0.15s ease, opacity 0.15s ease;
}

    .btn:disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
}

    .btn-primary:hover:not(:disabled) {
        filter: brightness(1.06);
    }

.btn-outline {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text);
}

    .btn-outline:hover {
        background: var(--bg-page);
    }

.btn-convert {
    width: 100%;
    margin-top: 4px;
    padding: 13px 18px;
}

/* ---------------------------------------------------------
   Feature row
   --------------------------------------------------------- */
.feature-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 24px;
}

.feature-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
}

.feature-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feature-card h4 {
    margin: 0 0 3px;
    font-size: 14.5px;
    font-weight: 700;
}

.feature-card p {
    margin: 0;
    font-size: 12.5px;
    color: var(--text-muted);
}

/* ---------------------------------------------------------
   Recent conversions
   --------------------------------------------------------- */
.recent-panel {
    margin-top: 22px;
}

.recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

    .recent-header h3 {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 16px;
        font-weight: 700;
        margin: 0;
    }

.recent-hint {
    font-size: 12px;
    color: var(--text-faint);
}

.recent-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

    .recent-table th {
        text-align: left;
        color: var(--text-faint);
        font-weight: 600;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        padding: 8px 10px;
        border-bottom: 1px solid var(--border);
    }

    .recent-table td {
        padding: 10px;
        border-bottom: 1px solid var(--border);
        color: var(--text);
        vertical-align: middle;
    }

    .recent-table tr:last-child td {
        border-bottom: none;
    }

.recent-file-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.recent-thumb {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-page);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.recent-actions {
    display: flex;
    gap: 12px;
}

    .recent-actions a, .recent-actions button {
        background: none;
        border: none;
        padding: 0;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        gap: 4px;
        font-size: 13px;
        font-weight: 600;
    }

    .recent-actions .download-link {
        color: var(--primary);
    }

    .recent-actions .remove-link {
        color: var(--danger);
    }

.recent-empty {
    text-align: center;
    padding: 26px 12px;
    color: var(--text-faint);
    font-size: 13.5px;
}

/* ---------------------------------------------------------
   Simple content pages (privacy/error)
   --------------------------------------------------------- */
.simple-page {
    max-width: 720px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
}

    .simple-page h1 {
        margin-top: 0;
    }

.error-page {
    text-align: center;
}

.error-icon {
    color: var(--warning);
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

/* ---------------------------------------------------------
   Utilities
   --------------------------------------------------------- */
.d-none {
    display: none !important;
}

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */
@media (max-width: 1100px) {
    .converter-grid {
        grid-template-columns: 1fr 300px;
    }
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: var(--topbar-h);
        width: 260px;
        height: calc(100vh - var(--topbar-h));
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 150;
        box-shadow: var(--shadow-lg);
    }

        .sidebar.open {
            transform: translateX(0);
        }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: var(--topbar-h) 0 0 0;
        background: rgba(10,12,28,0.4);
        z-index: 140;
    }

        .sidebar-backdrop.show {
            display: block;
        }

    .sidebar-toggle {
        display: inline-flex;
    }

    .topbar-nav {
        display: none;
    }

    .converter-grid {
        grid-template-columns: 1fr;
    }

    .options-panel {
        position: static;
    }

    .main-content {
        padding: 20px 18px 48px;
    }

    .feature-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-top {
        grid-template-columns: 1fr 1fr;
    }

    .footer-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 560px) {
    .brand-text {
        display: none;
    }

    .page-header {
        gap: 12px;
    }

        .page-header h1 {
            font-size: 21px;
        }

    .page-header-icon {
        width: 44px;
        height: 44px;
    }

    .panel {
        padding: 16px;
    }

    .dropzone {
        padding: 32px 14px;
    }

    .feature-row {
        grid-template-columns: 1fr;
    }

    .preview-card {
        flex-wrap: wrap;
    }

    .recent-table thead {
        display: none;
    }

    .recent-table, .recent-table tbody, .recent-table tr, .recent-table td {
        display: block;
        width: 100%;
    }

        .recent-table tr {
            border-bottom: 1px solid var(--border);
            padding: 10px 0;
        }

        .recent-table td {
            border-bottom: none;
            padding: 4px 0;
        }

            .recent-table td::before {
                content: attr(data-label);
                display: inline-block;
                width: 90px;
                color: var(--text-faint);
                font-size: 11px;
                text-transform: uppercase;
                font-weight: 600;
            }

    .footer-top {
        grid-template-columns: 1fr;
        padding: 40px 20px 24px;
        gap: 28px;
    }

    .footer-stats {
        grid-template-columns: 1fr;
        padding: 0 20px 24px;
    }

    .footer-bottom {
        padding: 18px 20px;
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 400px) {
    .result-actions .btn, .result-actions a {
        flex: 1;
    }
}
/* =========================================================
   Choose Files Source Dropdown
   ========================================================= */

.choose-file-wrapper {
    position: relative;
    display: inline-block;
    width: max-content;
    margin-bottom: 14px;
}

.choose-file-main {
    display: flex;
    height: 54px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 22px rgba(79, 70, 229, 0.22);
}

    .choose-file-main .btn-choose {
        height: 54px;
        min-width: 190px;
        margin: 0;
        border-radius: 0;
        border: 0;
        padding: 0 28px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 9px;
    }
.choose-source-item {
    font-size: 15px;
}
.choose-file-arrow {
    width: 58px;
    height: 54px;
    border: 0;
    border-left: 1px solid rgba(255,255,255,0.18);
    background: #6366f1;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease;
}

    .choose-file-arrow:hover {
        background: #4f46e5;
    }

.arrow-icon {
    display: inline-block;
    font-size: 20px;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform 0.2s ease;
    margin-top: 5px;
}

.choose-file-wrapper.open .arrow-icon {
    transform: rotate(180deg);
    margin-top: -4px;
}

.choose-source-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 0px);
    width: 100%;
    min-width: 0;
    max-width: 100%;
    background: #6366f1;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    box-shadow: 0 16px 35px rgba(30, 41, 59, 0.22);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.choose-file-wrapper.open .choose-source-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.choose-source-item {
    width: 100%;
    min-height: 62px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    gap: 28px;
    border: 0;
    border-bottom: 1px solid rgba(255,255,255,0.10);
    background: linear-gradient(45deg, #4a46d6, transparent);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, padding-left 0.15s ease;
}

    .choose-source-item:last-child {
        border-bottom: 0;
    }

    .choose-source-item:hover {
        background: rgba(255,255,255,0.10);
        padding-left: 34px;
    }

    .choose-source-item .icon {
        width: 23px;
        height: 23px;
        flex: 0 0 23px;
        color: #fff;
    }

@media (max-width: 600px) {

    .choose-file-wrapper {
        width: 100%;
    }

    .choose-file-main {
        width: 100%;
    }

        .choose-file-main .btn-choose {
            flex: 1;
        }

    .choose-source-menu {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .choose-source-item {
        font-size: 16px;
        min-height: 58px;
    }
}

.source-icon {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

    .source-icon svg {
        width: 26px;
        height: 26px;
        display: block;
    }

.device-icon {
    color: #ffffff;
}

.dropbox-icon {
    color: #ffffff;
}

.google-drive-icon {
    width: 28px;
    height: 28px;
}

    .google-drive-icon svg {
        width: 28px;
        height: 28px;
    }

.onedrive-icon {
    width: 27px;
    height: 27px;
}

    .onedrive-icon svg {
        width: 27px;
        height: 27px;
    }

.url-icon {
    color: #ffffff;
}
/* ==============================
   URL MODAL
   ============================== */

.url-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .url-modal.d-none {
        display: none !important;
    }

.url-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.url-modal-box {
    position: relative;
    z-index: 2;
    width: min(1175px, calc(100vw - 40px));
    min-height: 380px;
    padding: 70px 80px 80px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

    .url-modal-box h2 {
        margin: 0 0 30px;
        font-size: 27px;
        font-weight: 700;
        color: #111;
    }

.url-modal-close {
    position: absolute;
    top: 25px;
    right: 30px;
    border: 0;
    background: transparent;
    font-size: 38px;
    line-height: 1;
    color: #111;
    cursor: pointer;
}

.url-input {
    width: 100%;
    height: 70px;
    padding: 0 20px;
    border: 1px solid #6675ff;
    border-radius: 5px;
    background: #fff;
    font-size: 17px;
    color: #333;
    outline: none;
}

    .url-input:focus {
        border-color: #5365ff;
        box-shadow: 0 0 0 2px rgba(83, 101, 255, 0.12);
    }

.url-modal-buttons {
    display: flex;
    gap: 14px;
    margin-top: 35px;
}

.url-add-more,
.url-submit {
    height: 50px;
    padding: 0 24px;
    border: 0;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.url-add-more {
    background: #7d8ca8;
    color: #fff;
}

.url-submit {
    background: #6875f5;
    color: #fff;
}

    .url-add-more:hover,
    .url-submit:hover {
        opacity: 0.9;
    }

@media (max-width: 700px) {

    .url-modal-box {
        width: calc(100vw - 24px);
        min-height: auto;
        padding: 50px 20px 30px;
    }

        .url-modal-box h2 {
            font-size: 22px;
        }

    .url-input {
        height: 58px;
    }

    .url-modal-buttons {
        margin-top: 25px;
    }
}

.google-drive-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

    .google-drive-icon svg {
        width: 28px;
        height: 28px;
        display: block;
        overflow: visible;
    }

.url-input-row {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

    .url-input-row .url-input {
        width: 100%;
        padding-right: 55px;
    }

.url-remove-btn {
    position: absolute;
    right: 18px;
    width: 30px;
    height: 30px;
    border: 2px solid #7d8ca8;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-x {
    position: relative;
    width: 12px;
    height: 12px;
    display: block;
}

    .remove-x::before,
    .remove-x::after {
        content: "";
        position: absolute;
        left: 5px;
        top: 0;
        width: 2px;
        height: 12px;
        background: #7d8ca8;
    }

    .remove-x::before {
        transform: rotate(45deg);
    }

    .remove-x::after {
        transform: rotate(-45deg);
    }

.url-remove-btn:hover {
    background: #7d8ca8;
}

    .url-remove-btn:hover .remove-x::before,
    .url-remove-btn:hover .remove-x::after {
        background: #fff;
    }

.url-remove-btn:hover {
    background: #7d8ca8;
    color: #fff;
}
/* =========================================================
   Added for the new iloveimg-style tools (Rotate, Watermark,
   Meme Generator, Crop, Upscale, Remove Background, Blur)
   ========================================================= */

.option-hint {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-faint);
    margin-top: 2px;
}

.quick-rotate-row {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

    .quick-rotate-row .btn-sm {
        flex: 1;
        padding: 8px 10px;
        font-size: 13px;
    }

.position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 16px;
}

.position-btn {
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-page);
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

    .position-btn:hover {
        background: var(--primary-light);
        color: var(--primary);
    }

    .position-btn.active {
        background: var(--primary);
        border-color: var(--primary);
        color: var(--primary-contrast);
    }

.form-control-color {
    width: 100%;
    height: 42px;
    padding: 4px;
    cursor: pointer;
}

/* Crop / Blur interactive selection box.
   Preview thumb is enlarged (via .selection-mode) so the box is easy to use. */
.preview-thumb {
    position: relative;
}

.preview-card.selection-active {
    flex-wrap: wrap;
}

    .preview-card.selection-active .preview-thumb.selection-mode {
        flex: 1 1 100%;
        order: -1;
        margin-bottom: 12px;
    }

    .preview-card.selection-active .preview-meta {
        flex: 1 1 auto;
    }

.preview-thumb.selection-mode {
    width: 100%;
    height: auto;
    max-height: 440px;
    padding: 0;
}

    .preview-thumb.selection-mode img {
        width: auto;
        height: auto;
        max-width: 100%;
        max-height: 440px;
        object-fit: contain;
        display: block;
        margin: 0 auto;
        user-select: none;
        -webkit-user-drag: none;
    }

.selection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.selection-box {
    position: absolute;
    border: 2px dashed var(--primary);
    background: rgba(91, 87, 240, 0.18);
    box-shadow: 0 0 0 2000px rgba(16, 19, 43, 0.35);
    cursor: move;
    pointer-events: auto;
    touch-action: none;
}

.selection-handle {
    position: absolute;
    right: -7px;
    bottom: -7px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    cursor: nwse-resize;
    touch-action: none;
}
