:root {
    --primary-color: #6366f1;
    --secondary-color: #4f46e5;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-light: #f8fafc;
    --text-dim: #94a3b8;
    --border-color: #334155;
    --success-color: #10b981;
}

body.light-mode {
    --primary-color: #4f46e5;
    --secondary-color: #4338ca;
    --bg-dark: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.85);
    --text-light: #0f172a;
    --text-dim: #475569;
    --border-color: #cbd5e1;
}

body.light-mode .main-content {
    background: radial-gradient(circle at top right, #e0e7ff, transparent 40%);
    background-color: var(--bg-dark);
}

body.light-mode .converter-box {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.mobile-only {
    display: none !important;
}

/* Custom Scrollbar Global */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    /* Firefox */
    scrollbar-color: var(--secondary-color) var(--bg-dark);
    /* Firefox */
}

::-webkit-scrollbar {
    width: 12px !important;
    height: 12px !important;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark) !important;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background-color: var(--secondary-color) !important;
    border-radius: 6px;
    border: 2px solid var(--bg-dark);
    /* Padding effect */
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-color) !important;
}

body,
html {
    overflow-x: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    display: flex;
    min-height: 100vh;
    height: auto;
    overflow-y: auto;
}

.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    /* Reserve space for the fixed header so content starts below it.
       The CSS var lets media queries override the value if the header
       changes height on mobile. */
    --nmorph-header-h: 60px;
    padding-top: var(--nmorph-header-h);
}

/* Sidebar -> Top Bar (sticky / glassmorphic).
   position: fixed instead of sticky because .main-content owns its own
   overflow:auto, which would swallow the scroll a sticky header listens
   for. Fixed + a content-side padding-top works in every layout. */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding: 0.6rem 1rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: nowrap;
    z-index: 100;
    /* Translucent surface + blur for the modern "frosted" look. The solid
       fallback applies on browsers that don't support backdrop-filter. */
    background-color: rgba(20, 22, 32, 0.72);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .sidebar { background-color: var(--bg-card); }
}

body.light-mode .sidebar {
    background-color: rgba(255, 255, 255, 0.72);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
    color: var(--text-light);
    flex-shrink: 0;
}

.logo svg {
    stroke: var(--primary-color);
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: row;
    gap: 0.25rem;
    flex-wrap: nowrap;
    align-items: center;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.7rem;
    border-radius: 0.5rem;
    color: var(--text-dim);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.nav-links li.active a {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.nav-links li a:hover:not(.disabled) {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
}

.nav-links li a.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.badge {
    font-size: 0.65rem;
    background-color: var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: auto;
    color: var(--text-dim);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: radial-gradient(circle at top right, #1e1b4b, transparent 40%);
    overflow-y: auto;
    width: 100%;
    background-color: var(--bg-dark);
    color: var(--text-light);
    min-height: calc(100vh - 60px);
    height: auto;
    position: relative;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-dim);
    font-size: 1.1rem;
}

/* Upload Area */
.converter-box {
    width: 100%;
    max-width: 600px;
    min-height: 350px;
    max-height: 70vh;
    /* Limits height so scrollbar appears if content is taller */
    background-color: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: 1rem;
    position: relative;
    transition: all 0.3s ease;
    overflow-x: hidden;
    overflow-y: auto !important;
    /* Forces scrollbar logic */
    display: block;
    padding: 1rem;
    padding-right: 0.5rem;
    /* Space for scrollbar */
    box-sizing: border-box;

    /* Firefox Scrollbar for this box */
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--bg-card);
}

.converter-box *,
.converter-box *::before,
.converter-box *::after {
    box-sizing: border-box;
}

/* Custom Scrollbar specifically for Converter Box to ensure visibility */
.converter-box::-webkit-scrollbar {
    width: 12px;
}

.converter-box::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin: 10px 0;
    /* Align with border radius */
}

.converter-box::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 8px;
    border: 2px solid var(--bg-card);
}

/* Center children */
.upload-area,
.file-preview {
    margin: 0 auto;
    width: 100%;
}

.converter-box:hover,
.converter-box.drag-over {
    border-color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.05);
}

.upload-area {
    padding: 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    flex: 1;
}

.browse-text {
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
}

.browse-text:hover {
    text-decoration: underline;
}

.icon-large {
    color: var(--text-dim);
    margin-bottom: 1rem;
    transition: color 0.3s ease;
}

.converter-box:hover .icon-large {
    color: var(--primary-color);
}

/* File Preview */
.file-preview {
    padding: 2rem;
    background-color: var(--bg-card);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    /* Remove absolute positioning which might be causing issues with height */
    /* position: absolute; */
    /* top: 0; */
    /* left: 0; */
    /* height: 100%; */
    /* Use relative flow instead */
    position: relative;
    height: auto;
    z-index: 10;
    display: none;
}

/* Ensure buttons are visible */
.file-preview .convert-btn {
    display: flex;
    /* Force flex display */
    width: 100%;
}

/* When active */
.file-preview.active {
    display: flex;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background-color: rgba(255, 255, 255, 0.03);
    padding: 0.85rem;
    border-radius: 0.5rem;
    position: relative;
    width: 100%;
    max-width: 100%;
}

.file-icon {
    font-size: 2rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
}

/* Standardize all inline preview thumbnails to a stable 56x56 square */
#img-thumbnail,
#format-thumbnail {
    width: 56px !important;
    height: 56px !important;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    display: block;
}

.file-details {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    color: var(--text-light);
    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.file-size {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.remove-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
    padding: 0 0.5rem;
}

.remove-btn:hover {
    color: #ef4444;
}

.convert-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background-color 0.2s;
    font-size: 1rem;
}

.convert-btn:hover {
    background-color: var(--secondary-color);
}

.convert-btn:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
}

/* Progress Bar */
.progress-bar-container {
    height: 6px;
    background-color: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.5rem;
    width: 100%;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.status-msg {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-dim);
    min-height: 1.2rem;
}

/* URL Input Styles */
.url-input-container {
    width: 100%;
    margin: 1rem 0;
}

#web-url-input {
    width: 100%;
    padding: 1rem;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-light);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
}

#web-url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(255, 255, 255, 0.1);
}

/* Floating Print Button */
.floating-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

.floating-btn:hover {
    transform: scale(1.1);
    background-color: var(--secondary-color);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* Image Tools Styles */
.settings-panel {
    margin-bottom: 0.5rem;
}

.input-group {
    min-width: 0;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.input-group input[type="number"] {
    width: 100%;
    min-width: 0;
    padding: 0.8rem;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-light);
    font-family: inherit;
    transition: all 0.2s;
}

/* Resize tab — width/height grid that stays stable on narrow screens */
.resize-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.1);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

@media (max-width: 420px) {
    .resize-grid {
        gap: 0.6rem;
        padding: 0.75rem;
    }
    .resize-grid .input-group label {
        font-size: 0.78rem;
    }
    .resize-grid .input-group input[type="number"] {
        padding: 0.65rem 0.55rem;
        font-size: 0.9rem;
    }
}

.input-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(255, 255, 255, 0.1);
}

.input-group input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
}

@media (max-width: 768px) {
    .app-container {
        --nmorph-header-h: 56px;
    }

    .sidebar {
        flex-wrap: nowrap;
        padding: 0.5rem;
        gap: 0.4rem;
        justify-content: space-between;
    }

    .logo img {
        width: 60px !important;
    }

    /* Hide top nav links on mobile — rail takes over */
    .sidebar .nav-links { display: none !important; }

    .theme-toggle-container span#theme-text {
        display: none;
    }

    .badge { display: none; }

    .main-content {
        padding: 1.5rem 1rem;
        min-height: calc(100vh - 120px);
    }

    header h1 {
        font-size: 1.4rem;
        word-wrap: break-word;
        padding: 0 0.5rem;
    }

    header p {
        font-size: 0.9rem;
        padding: 0 0.5rem;
    }

    .mobile-only {
        display: block !important;
    }

    .converter-box {
        height: auto;
        min-height: 300px;
        max-height: none;
    }

    .upload-area {
        padding: 1.5rem !important;
    }

    .file-info {
        flex-wrap: nowrap;
        gap: 0.7rem;
        padding: 0.7rem;
    }

    .file-preview {
        padding: 1rem !important;
    }

    .remove-btn {
        flex-shrink: 0;
    }
}

/* ============ MOBILE RAIL (≤768px) ============ */
.mobile-rail { display: none; }

@media (max-width: 768px) {
    .mobile-rail {
        display: flex;
        position: fixed;
        right: 0;
        top: calc(env(safe-area-inset-top, 0px) + 80px);
        z-index: 100;
        align-items: stretch;
        gap: 8px;
        padding: 8px 6px 8px 10px;
        pointer-events: auto;
        touch-action: none;
        background: rgba(20, 20, 28, 0.62);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        border: 1px solid rgba(255, 255, 255, 0.09);
        border-right: none;
        border-radius: 18px 0 0 18px;
        box-shadow: -6px 10px 28px rgba(0, 0, 0, 0.38);
        transition: padding 0.22s ease, gap 0.22s ease;
        --rail-active: 0;
        --rail-progress: 0;
    }

    .mobile-rail.active {
        gap: 12px;
        padding-left: 12px;
    }

    /* Groove-style strap — recessed track inside the rail housing */
    .rail-strap {
        position: relative;
        width: 10px;
        margin: 0;
        border-radius: 6px;
        background: linear-gradient(180deg,
            rgba(0, 0, 0, 0.45) 0%,
            rgba(0, 0, 0, 0.28) 50%,
            rgba(0, 0, 0, 0.45) 100%);
        box-shadow:
            inset 0 2px 4px rgba(0, 0, 0, 0.55),
            inset 0 -1px 0 rgba(255, 255, 255, 0.06),
            inset 1px 0 0 rgba(0, 0, 0, 0.35);
        pointer-events: auto;
        touch-action: none;
        opacity: 0.85;
        transition: opacity 0.25s ease, width 0.25s ease, background 0.25s ease;
        overflow: hidden;
        align-self: stretch;
    }

    .mobile-rail.active .rail-strap {
        opacity: 1;
        width: 14px;
        background: linear-gradient(180deg,
            rgba(99, 102, 241, 0.22) 0%,
            rgba(0, 0, 0, 0.35) 50%,
            rgba(99, 102, 241, 0.22) 100%);
    }

    /* Snap notches — 5 horizontal divots aligned with icons */
    .strap-notches {
        position: absolute;
        inset: 0;
        pointer-events: none;
    }
    .strap-notches span {
        position: absolute;
        left: 3px;
        right: 3px;
        height: 2px;
        background: rgba(0, 0, 0, 0.45);
        border-radius: 2px;
        box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15);
        opacity: 0.7;
    }

    /* Knob — slides along the strap */
    .rail-knob {
        position: absolute;
        left: 50%;
        top: 0;
        transform: translate(-50%, calc(var(--rail-progress, 0) * 1px));
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background: radial-gradient(circle at 35% 30%,
            #fafafa 0%,
            #c0c0c8 55%,
            #6b6b78 100%);
        box-shadow:
            0 2px 6px rgba(0, 0, 0, 0.5),
            inset 0 1px 1px rgba(255, 255, 255, 0.7),
            inset 0 -1px 1px rgba(0, 0, 0, 0.4);
        margin-left: 0;
        opacity: 0;
        transition: opacity 0.2s ease,
                    background 0.18s ease,
                    box-shadow 0.18s ease;
        pointer-events: none;
    }
    .mobile-rail.active .rail-knob { opacity: 1; }

    /* Knob locked-on-icon feedback */
    .rail-knob.on-target {
        background: radial-gradient(circle at 35% 30%,
            #c7c8ff 0%,
            var(--primary-color) 55%,
            #3f43c7 100%);
        box-shadow:
            0 0 0 3px rgba(99, 102, 241, 0.35),
            0 2px 8px rgba(99, 102, 241, 0.55),
            inset 0 1px 1px rgba(255, 255, 255, 0.5);
    }

    /* Icon column — lives inside the rail housing, no standalone chrome */
    .rail-icons-wrap {
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: stretch;
    }

    .rail-icons {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        gap: 6px;
        background: transparent;
        border: none;
        box-shadow: none;
        pointer-events: auto;
    }

    /* Collapse button — sits right under the icons inside the housing */
    .rail-collapse-btn {
        margin-top: 2px;
        width: 40px;
        height: 28px;
        border: 1px solid rgba(255, 255, 255, 0.12);
        background: rgba(255, 255, 255, 0.04);
        color: var(--text-dim);
        border-radius: 10px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.95rem;
        line-height: 1;
        transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
        pointer-events: auto;
        font-family: inherit;
    }
    .rail-collapse-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        color: var(--text-light);
    }
    body.light-theme .rail-collapse-btn {
        border-color: rgba(0, 0, 0, 0.08);
        background: rgba(0, 0, 0, 0.04);
    }

    /* Collapsed state: slide rail off-screen */
    body.rail-collapsed .mobile-rail {
        transform: translateX(calc(100% + 20px));
        transition: transform 0.28s cubic-bezier(.2, .8, .2, 1);
        pointer-events: none;
    }
    .mobile-rail {
        transition: transform 0.28s cubic-bezier(.2, .8, .2, 1),
                    padding 0.22s ease, gap 0.22s ease;
    }

    /* Reopen tab — a small edge handle visible only when collapsed */
    .rail-reopen-tab {
        position: fixed;
        right: 0;
        top: calc(env(safe-area-inset-top, 0px) + 100px);
        z-index: 101;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 52px;
        padding: 0;
        border-radius: 12px 0 0 12px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-right: none;
        background: rgba(20, 20, 28, 0.82);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        color: var(--text-light);
        cursor: pointer;
        font-size: 1.1rem;
        box-shadow: -4px 6px 18px rgba(0, 0, 0, 0.35);
        font-family: inherit;
    }
    body.light-theme .rail-reopen-tab {
        background: rgba(255, 255, 255, 0.92);
        border-color: rgba(0, 0, 0, 0.1);
        color: var(--text-light);
    }

    /* When collapsed: remove the reserved right padding so content spreads */
    body.rail-collapsed .main-content { padding-right: 1rem !important; }

    .rail-icons li {
        --scale: 1;
        position: relative;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.04);
        cursor: pointer;
        transition: transform 0.18s cubic-bezier(.2,.8,.2,1.1),
                    background-color 0.2s ease;
        transform-origin: right center;
        transform: scale(var(--scale));
        will-change: transform;
    }

    .rail-icons li.active {
        background: var(--primary-color);
        box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
    }

    .rail-ico {
        font-size: 20px;
        line-height: 1;
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
    }

    /* Title pill — appears to the LEFT of magnified icon */
    .rail-title {
        position: absolute;
        right: calc(100% + 10px);
        top: 50%;
        transform: translateY(-50%) scale(0.92);
        background: var(--bg-card, #1a1a24);
        color: var(--text-light, #fff);
        padding: 6px 12px;
        border-radius: 8px;
        font-size: 0.85rem;
        font-weight: 600;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        border: 1px solid rgba(255, 255, 255, 0.12);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
        transition: opacity 0.15s ease, transform 0.18s ease;
    }
    .rail-title::after {
        content: "";
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        border: 5px solid transparent;
        border-left-color: var(--bg-card, #1a1a24);
    }
    .rail-icons li.magnified .rail-title {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }

    /* Light theme adjustments */
    body.light-theme .mobile-rail {
        background: rgba(255, 255, 255, 0.85);
        border-color: rgba(0, 0, 0, 0.08);
        box-shadow: -6px 10px 24px rgba(0, 0, 0, 0.12);
    }
    body.light-theme .rail-icons li {
        background: rgba(0, 0, 0, 0.04);
    }
    body.light-theme .rail-strap {
        background: linear-gradient(180deg,
            rgba(0, 0, 0, 0.18) 0%,
            rgba(0, 0, 0, 0.08) 50%,
            rgba(0, 0, 0, 0.18) 100%);
        box-shadow:
            inset 0 2px 3px rgba(0, 0, 0, 0.25),
            inset 0 -1px 0 rgba(255, 255, 255, 0.5);
    }
    body.light-theme .mobile-rail.active .rail-strap {
        background: linear-gradient(180deg,
            rgba(99, 102, 241, 0.35) 0%,
            rgba(0, 0, 0, 0.1) 50%,
            rgba(99, 102, 241, 0.35) 100%);
    }

    /* Reserve right padding so content doesn't sit under rail */
    .main-content { padding-right: 88px !important; }
}

/* BG-remove quality selector — two-card radio group */
.bg-quality-select {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.bg-qual-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-align: left;
    padding: 0.7rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1.5px solid var(--border-color);
    border-radius: 0.6rem;
    color: var(--text-light);
    cursor: pointer;
    transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.12s ease;
    font-family: inherit;
    min-width: 0;
}

.bg-qual-btn:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.06);
}

.bg-qual-btn:active {
    transform: scale(0.98);
}

.bg-qual-btn.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.14);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.bg-qual-btn .q-badge {
    font-size: 1.2rem;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.15);
}

.bg-qual-btn .q-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.bg-qual-btn .q-title {
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.2;
}

.bg-qual-btn .q-meta {
    font-size: 0.72rem;
    color: var(--text-dim);
    line-height: 1.25;
    margin-top: 2px;
    white-space: normal;
    word-break: break-word;
}

@media (max-width: 480px) {
    .bg-quality-select {
        grid-template-columns: 1fr;
    }
}

body.light-theme .bg-qual-btn {
    background: rgba(0, 0, 0, 0.02);
}

body.light-theme .bg-qual-btn.active {
    background: rgba(99, 102, 241, 0.1);
}

/* =========== Object Selection Modal (SAM click-to-select) =========== */
.obj-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.obj-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.obj-modal-panel {
    position: relative;
    background: var(--bg-card);
    color: var(--text-light);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    width: min(92vw, 720px);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.1rem 1.1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.obj-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.obj-modal-header h3 { margin: 0; font-size: 1.05rem; }
.obj-modal-close {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.6rem;
    cursor: pointer;
    padding: 0 0.3rem;
    line-height: 1;
}
.obj-modal-close:hover { color: var(--text-light); }

.obj-modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.obj-modal-footer {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.obj-tools {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.obj-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-light);
    border-radius: 0.45rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}
.obj-tool-btn:hover { border-color: var(--primary-color); }
.obj-tool-btn.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary-color);
}

.obj-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}
.obj-dot-pos { background: #22c55e; }
.obj-dot-neg { background: #ef4444; }

.obj-help {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin: 0;
    line-height: 1.45;
}

.obj-canvas-wrap {
    position: relative;
    width: 100%;
    min-height: 220px;
    max-height: 55vh;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

#obj-canvas,
#obj-overlay {
    max-width: 100%;
    max-height: 55vh;
    display: block;
    touch-action: none;
}

#obj-canvas { cursor: crosshair; }

#obj-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* Mode tabs (points / box / lasso) */
.obj-mode-tabs {
    display: flex;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 0.1rem;
}
.obj-mode-tab {
    flex: 1;
    padding: 0.5rem 0.6rem;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border-color);
    color: var(--text-dim);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.15s ease, color 0.15s ease;
    font-family: inherit;
}
.obj-mode-tab:last-child { border-right: none; }
.obj-mode-tab.active {
    background: var(--primary-color);
    color: #fff;
}
.obj-mode-tab:hover:not(.active) { background: rgba(99, 102, 241, 0.08); color: var(--text-light); }

body.light-theme .obj-modal-panel {
    background: #fff;
}

@media (max-width: 480px) {
    .obj-modal-panel {
        width: 96vw;
        padding: 0.8rem;
    }
    .obj-tool-btn { font-size: 0.78rem; padding: 0.4rem 0.55rem; }
}

/* Pre-upload hints — let users see what the tool does before uploading */
.pre-upload-hint {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    justify-content: center;
    text-align: left;
    margin-top: 0.75rem;
    padding: 0.55rem 0.85rem;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 0.5rem;
    color: var(--text-light);
    font-size: 0.8rem;
    line-height: 1.35;
}

.pre-upload-hint .hint-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

/* Visibility Helpers */
.mobile-only { display: none !important; }
.desktop-only { display: block; }

@media (max-width: 768px) {
    .desktop-only { display: none !important; }
}
/* ==================== Cancel button (in-progress) ====================
   Inserted as a SIBLING after the progress bar — the bar itself is 6px tall
   with overflow:hidden, so a child cancel button would never render. */
.cancel-btn,
.nmorph-cancel-btn {
    display: block;
    margin: 0.7rem auto 0.2rem;
    padding: 0.55rem 1.4rem;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #ef4444;
    border-radius: 0.55rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 9rem;
    text-align: center;
}

.cancel-btn:hover:not(:disabled),
.nmorph-cancel-btn:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.22);
}

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

/* ==================== Download result card ==================== */
.download-card {
    margin-top: 0.85rem;
    padding: 1rem 1.1rem;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 0.65rem;
    color: var(--text-light);
    font-size: 0.88rem;
}

.download-card .dl-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.65rem;
}

.download-card .dl-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.55rem;
    flex-wrap: wrap;
}

.download-card .dl-label {
    color: var(--text-dim);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.download-card .dl-default-name {
    background: rgba(0, 0, 0, 0.18);
    padding: 0.2rem 0.5rem;
    border-radius: 0.35rem;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.78rem;
    word-break: break-all;
}

.download-card .dl-rename-input {
    flex: 1;
    min-width: 8rem;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--border-color);
    border-radius: 0.4rem;
    padding: 0.4rem 0.6rem;
    color: var(--text-light);
    font-size: 0.85rem;
}

.download-card .dl-rename-input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.7);
    background: rgba(0, 0, 0, 0.3);
}

.download-card .dl-ext {
    color: var(--text-dim);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.download-card .dl-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.6rem;
}

.download-card .dl-btn {
    flex: 1;
    min-width: 9rem;
    padding: 0.55rem 0.9rem;
    border-radius: 0.45rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.download-card .dl-btn-default {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-light);
}

.download-card .dl-btn-default:hover {
    background: rgba(255, 255, 255, 0.16);
}

.download-card .dl-btn-rename {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-color: transparent;
}

.download-card .dl-btn-rename:hover {
    filter: brightness(1.1);
}

body.light-mode .download-card .dl-default-name,
body.light-mode .download-card .dl-rename-input {
    background: rgba(0, 0, 0, 0.06);
}

/* ==================== Download card → compact banner ==================== */
.download-card.downloaded {
    padding: 0.6rem 0.85rem;
    background: rgba(34, 197, 94, 0.10);
    border-color: rgba(34, 197, 94, 0.35);
}

.download-card.downloaded .dl-banner-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.download-card.downloaded .dl-check {
    font-size: 1rem;
    flex-shrink: 0;
}

.download-card.downloaded .dl-banner-text {
    flex: 1;
    min-width: 8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.download-card.downloaded .dl-banner-label {
    color: var(--text-dim);
    font-size: 0.78rem;
}

.download-card.downloaded .dl-banner-name {
    background: rgba(0, 0, 0, 0.18);
    padding: 0.18rem 0.45rem;
    border-radius: 0.3rem;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.78rem;
    word-break: break-all;
}

.download-card.downloaded .dl-banner-redownload {
    background: rgba(34, 197, 94, 0.18);
    border: 1px solid rgba(34, 197, 94, 0.45);
    color: #22c55e;
    border-radius: 0.4rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.download-card.downloaded .dl-banner-redownload:hover {
    background: rgba(34, 197, 94, 0.28);
}

.download-card.downloaded .dl-banner-close {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.15rem 0.45rem;
    border-radius: 0.3rem;
    transition: all 0.15s ease;
}

.download-card.downloaded .dl-banner-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-light);
}

body.light-mode .download-card.downloaded .dl-banner-name {
    background: rgba(0, 0, 0, 0.06);
}

/* ---- Pro / rewarded-video unlock ---- */
/* Sticky bar pinned just below the fixed nav. On mobile it stops short of
   the right-hand rail (rail reserves 88px). Sticky position keeps it in the
   normal flow, so no padding-offset gymnastics. */
.pro-bar {
    position: sticky;
    top: var(--nmorph-header-h, 60px);
    z-index: 99;
    background: linear-gradient(90deg,
        rgba(99, 102, 241, 0.22) 0%,
        rgba(139, 92, 246, 0.20) 50%,
        rgba(168, 85, 247, 0.18) 100%);
    border-bottom: 1px solid rgba(139, 92, 246, 0.35);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    color: var(--text-light);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.10);
}

body.light-mode .pro-bar {
    background: linear-gradient(90deg,
        rgba(99, 102, 241, 0.12) 0%,
        rgba(168, 85, 247, 0.10) 100%);
    border-bottom-color: rgba(99, 102, 241, 0.25);
}

.pro-bar-inner {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.9rem;
    min-height: 56px;
}

/* Gift icon in a soft gradient disc — feels like a "reward chip". */
.pro-bar-gift {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%,
        rgba(255, 255, 255, 0.25),
        rgba(168, 85, 247, 0.35) 60%,
        rgba(99, 102, 241, 0.45));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18),
                0 2px 8px rgba(99, 102, 241, 0.25);
}

.pro-bar-check {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.22);
    color: #22c55e;
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.45);
}

.pro-bar-copy {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    overflow: hidden;
}

.pro-bar-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sub copy is the place where the i18n strings actually wrap — letting it
   take 2 lines (3 in very narrow viewports) avoids the previous "Video
   izle, gün sonun…" truncation. The bar grows in height to fit. */
.pro-bar-sub {
    font-size: 0.74rem;
    color: var(--text-dim);
    margin-top: 2px;
    line-height: 1.25;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pro-bar-expiry { color: #22c55e; font-weight: 500; }

/* The "Watch" pill — the affordance the eye should land on. Gradient,
   pulsing glow, prominent play glyph. */
.pro-bar-btn {
    flex-shrink: 0;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 0.45rem 0.9rem 0.45rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.55),
                0 4px 12px rgba(99, 102, 241, 0.45);
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.15s ease;
    animation: pro-bar-pulse 2.4s ease-in-out infinite;
}

@keyframes pro-bar-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.0),
                    0 4px 12px rgba(99, 102, 241, 0.45);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(168, 85, 247, 0.0),
                    0 4px 14px rgba(168, 85, 247, 0.6);
    }
}

.pro-bar-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.18),
                0 6px 16px rgba(168, 85, 247, 0.55);
}

.pro-bar-btn:disabled {
    opacity: 0.7;
    cursor: progress;
    transform: none;
    animation: none;
}

.pro-bar-play {
    display: block;
    margin-left: 1px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
}

.pro-bar-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.pro-bar-close:hover {
    background: rgba(255, 255, 255, 0.10);
    color: var(--text-light);
}

/* "Pro active" — calm, no CTA / close button. JS adds .is-pro-active when
   Pro is unlocked; avoids :has() so it works on older WebViews too. */
.pro-bar.is-pro-active {
    background: linear-gradient(90deg,
        rgba(34, 197, 94, 0.16) 0%,
        rgba(16, 185, 129, 0.12) 100%);
    border-bottom-color: rgba(34, 197, 94, 0.35);
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.08);
}

.pro-bar.is-pro-active .pro-bar-title { color: #22c55e; }

/* Mobile rail reserves 88px on the right side — keep the bar clear of it,
   otherwise the icon column sits ON TOP of the bar and the close button
   becomes unreachable. Match the rail's left-only collapse with body.rail-collapsed. */
@media (max-width: 768px) {
    .pro-bar {
        width: calc(100% - 88px);
        transition: width 0.28s cubic-bezier(.2, .8, .2, 1);
    }
    body.rail-collapsed .pro-bar {
        width: 100%;
    }
}

@media (max-width: 380px) {
    .pro-bar-inner {
        gap: 0.55rem;
        padding: 0.45rem 0.7rem;
    }
    .pro-bar-title { font-size: 0.86rem; }
    .pro-bar-sub { font-size: 0.7rem; }
    .pro-bar-btn { padding: 0.4rem 0.75rem 0.4rem 0.65rem; font-size: 0.8rem; }
}

/* PRO badge that sits on top of a gated button (Manuel Kes) */
.pro-badge {
    position: absolute;
    top: -8px;
    right: 10px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.45rem;
    border-radius: 0.35rem;
    line-height: 1.25;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
    pointer-events: none;
}

/* Pro unlock modal */
.pro-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.pro-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.pro-modal-panel {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem 1.4rem 1.25rem;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.pro-modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.65rem;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem 0.55rem;
    border-radius: 0.4rem;
}

.pro-modal-close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-light);
}

.pro-modal-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.pro-modal-panel h3 {
    margin: 0 0 0.6rem;
    font-size: 1.15rem;
    color: var(--text-light);
}

.pro-modal-panel > p {
    margin: 0 0 1.15rem;
    color: var(--text-dim);
    font-size: 0.9rem;
    line-height: 1.5;
}

.pro-modal-panel > p b {
    color: var(--text-light);
}

.pro-modal-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.pro-modal-secondary,
.pro-modal-primary {
    flex: 1;
    padding: 0.7rem 0.9rem;
    border-radius: 0.55rem;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.pro-modal-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-light);
}

.pro-modal-secondary:hover {
    background: rgba(255, 255, 255, 0.04);
}

.pro-modal-primary {
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    border: none;
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.pro-modal-primary:hover {
    transform: translateY(-1px);
}

.pro-modal-primary:disabled {
    opacity: 0.6;
    cursor: progress;
    transform: none;
    box-shadow: none;
}

/* Toast */
.pro-toast {
    position: fixed;
    left: 50%;
    bottom: 5rem;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    color: var(--text-light);
    border: 1px solid var(--border-color);
    border-radius: 0.65rem;
    padding: 0.7rem 1rem;
    font-size: 0.88rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 9998;
    max-width: 90vw;
    text-align: center;
}

.pro-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.pro-toast.success {
    border-color: rgba(34, 197, 94, 0.55);
}

.pro-toast.error {
    border-color: rgba(239, 68, 68, 0.55);
}

/* ============ Sticker view ============ */
#sticker-pack-tabs {
    scrollbar-width: thin;
}

.sticker-pack-tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.sticker-pack-tab .ico {
    font-size: 1rem;
    line-height: 1;
}

.sticker-pack-tab:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sticker-pack-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.sticker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.6rem;
}

.sticker-tile {
    aspect-ratio: 1 / 1;
    padding: 0.4rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 0.6rem;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sticker-tile:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.07);
}

.sticker-tile img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* ---- Sticker editor modal (reuses .obj-modal* shell) ---- */
/* The editor panel keeps the canvas pinned at the top so the live
   preview never scrolls out of view — only the controls below it
   scroll. Without this, mobile users open the keyboard, the body
   pushes up, and they lose sight of what they're typing. */
.sticker-editor-modal .obj-modal-panel {
    padding-top: 0.75rem;
}
.sticker-editor-modal .obj-modal-body {
    padding-top: 0.6rem;
}

.sticker-canvas-wrap {
    width: 100%;
    max-width: 320px;
    margin: 0 auto 0.5rem;
    background:
        linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%) 0 0/16px 16px,
        linear-gradient(-45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%) 0 8px/16px 16px,
        rgba(0, 0, 0, 0.25);
    border-radius: 0.6rem;
    border: 1px solid var(--border-color);
    overflow: hidden;
    flex: 0 0 auto;
}

.sticker-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: auto;
    touch-action: none;
}

/* Phones short on vertical real estate — shrink the canvas preview a bit
   more so the text input + action buttons fit without scrolling off. */
@media (max-height: 720px) {
    .sticker-canvas-wrap { max-width: 260px; }
}
@media (max-height: 600px) {
    .sticker-canvas-wrap { max-width: 220px; }
}

/* ---- "Stickerlarım" library header + tiles ---- */
.sticker-mine-header {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.65rem 0.75rem;
    margin: 0 0 0.6rem;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 0.5rem;
}
.sticker-mine-counter {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.sticker-mine-count {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--primary-color);
}
.sticker-mine-hint {
    color: var(--text-dim);
    font-size: 0.82rem;
}
.sticker-mine-enable {
    width: 100%;
    background: #25D366 !important;
    color: #fff !important;
    border: none;
    font-weight: 600;
}

/* User-saved sticker tiles get a small × delete badge in the top-right
   corner. The tile body itself remains the share button. */
.sticker-tile-mine {
    position: relative;
}
.sticker-tile-mine .sticker-tile-body {
    width: 100%;
    height: 100%;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 0.55rem;
    cursor: pointer;
    overflow: hidden;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sticker-tile-mine .sticker-tile-body img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.sticker-tile-mine .sticker-tile-del {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: #fff;
    border: none;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.sticker-tile-mine .sticker-tile-del:hover {
    background: rgba(220, 38, 38, 1);
}

.sticker-controls {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.sticker-control-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sticker-control-row > input[type="text"] {
    flex: 1 1 100%;
    padding: 0.55rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-light);
    font-size: 0.95rem;
}

.sticker-control-row > select,
.sticker-control-row > input[type="color"] {
    padding: 0.4rem 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-light);
    font-size: 0.85rem;
    cursor: pointer;
}

.sticker-control-row > select {
    flex: 1 1 auto;
    min-width: 0;
}

.sticker-control-row > input[type="color"] {
    width: 38px;
    height: 36px;
    padding: 0;
}

.sticker-slider-label {
    flex: 1 1 45%;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.78rem;
    color: var(--text-dim);
}

.sticker-slider-label input[type="range"] {
    width: 100%;
}

.sticker-action-row {
    margin: 0.5rem 0 0.25rem;
}

.sticker-pack-cta {
    margin: 0 0 0.85rem;
    padding: 0;
}

.sticker-icon-btn {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-light);
    cursor: pointer;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    transition: background 0.15s, border-color 0.15s;
}

.sticker-icon-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
}

.sticker-icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sticker-icon-btn-danger:hover:not(:disabled) {
    border-color: var(--error-color);
    color: var(--error-color);
}

.sticker-rotate-quick {
    display: inline-flex;
    gap: 0.3rem;
    flex: 0 0 auto;
}
