  :root {
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --primary-light: #f3e8ff;
    --accent: #eab308;
    --accent-hover: #ca8a04;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --primary-light: #2e1065;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    width: 100%;
    transition: background-color 0.3s ease, color 0.3s ease;
}
/* Typography Helper */
h1, h2, h3, h4 {
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
}
/* Container */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}
/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}
.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}
.btn-accent {
    background-color: var(--accent);
    color: #0f172a;
    font-weight: 700;
}
.btn-accent:hover {
    background-color: var(--accent-hover);
}
.btn-outline {
    background-color: transparent;
    border-color: var(--border);
    color: var(--text-main);
}
.btn-outline:hover {
    background-color: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}
.btn-sm {
    min-height: 38px;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}
.btn-icon {
    min-width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius-sm);
}
/* Header */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
    transition: var(--transition);
}
.nav-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--primary);
    text-decoration: none;
    font-family: 'Poppins', sans-serif;
}
.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transform: rotate(-5deg);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4);
    flex-shrink: 0;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    list-style: none;
}
.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
}
.nav-links a:hover {
    color: var(--primary);
}
.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
/* Mobile Menu Drawer */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.4rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}
.mobile-drawer {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-card);
    z-index: 99;
    padding: 1.5rem;
    flex-direction: column;
    gap: 1rem;
    border-top: 1px solid var(--border);
    transform: translateY(-100%);
    transition: transform 0.3s ease-in-out;
}
.mobile-drawer.open {
    display: flex;
    transform: translateY(0);
}
.mobile-drawer a {
    text-decoration: none;
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}
/* Hero Section */
.hero {
    padding: 2.5rem 0 1.5rem;
    text-align: center;
    background: radial-gradient(circle at 50% 0%, var(--primary-light) 0%, transparent 70%);
}
.hero h1 {
    font-size: clamp(1.8rem, 5vw, 3.5rem);
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--text-main) 30%, var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero p {
    font-size: clamp(0.95rem, 2vw, 1.2rem);
    color: var(--text-muted);
    max-width: 650px;
    margin: 0 auto 1.5rem;
}
.hero-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.trust-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    flex-wrap: wrap;
}
.trust-badge span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}
/* Main Meme Editor App */
.editor-section {
    padding: 1rem 0 2.5rem;
    scroll-margin-top: 70px;
}
.editor-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    width: 100%;
}
/* Preview Area (Left / Top) */
.preview-area {
    background-color: #0b0f19;
    background-image: radial-gradient(#1e293b 1px, transparent 1px);
    background-size: 16px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    position: relative;
    min-height: 320px;
    user-select: none;
    width: 100%;
    overflow: hidden;
}
.canvas-wrapper {
    position: relative;
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
    border-radius: 4px;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    overflow: hidden;
}
#memeCanvas {
    max-width: 100%;
    height: auto !important;
    display: block;
}
.canvas-toolbar {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.4rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    padding: 0.35rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,255,255,0.15);
    z-index: 10;
}
.canvas-toolbar button {
    background: transparent;
    border: none;
    color: #ffffff;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.canvas-toolbar button:hover {
    background: rgba(255,255,255,0.2);
    color: var(--accent);
}
/* Controls Area (Right / Bottom) */
.controls-area {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--bg-card);
    height: 100%;
    max-height: 700px;
    width: 100%;
    min-width: 0;
}
/* Tabs Header */
.control-tabs {
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    background: var(--bg-main);
    scrollbar-width: none;
    width: 100%;
}
.control-tabs::-webkit-scrollbar {
    display: none;
}
.tab-btn {
    flex: 1;
    min-width: 64px;
    min-height: 48px;
    padding: 0.6rem 0.35rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    transition: var(--transition);
    white-space: nowrap;
}
.tab-btn i {
    font-size: 1rem;
}
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--bg-card);
}
/* Tab Content Panels */
.tab-content {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
    display: none;
    width: 100%;
}
.tab-content.active {
    display: block;
}
/* Control Form Elements */
.control-group {
    margin-bottom: 1.1rem;
    width: 100%;
}
.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}
.control-label span.val {
    color: var(--primary);
    font-weight: 700;
}
.input-text, .select-input {
    width: 100%;
    min-height: 44px;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}
.input-text:focus, .select-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    flex-wrap: wrap;
}
.color-picker {
    -webkit-appearance: none;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
    flex-shrink: 0;
}
.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}
.color-picker::-webkit-color-swatch {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.range-slider {
    width: 100%;
    height: 28px;
    accent-color: var(--primary);
}
.btn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    gap: 0.5rem;
    width: 100%;
}
.btn-grid-2 {
    grid-template-columns: 1fr 1fr;
}
.btn-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}
.btn-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}
.preset-btn {
    min-height: 42px;
    padding: 0.5rem 0.35rem;
    font-size: 0.82rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}
.preset-btn:hover, .preset-btn:active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
/* Upload Dropzone */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem 0.75rem;
    text-align: center;
    background: var(--bg-main);
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.dropzone i {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 0.35rem;
}
.dropzone p {
    font-size: 0.85rem;
    color: var(--text-muted);
}
/* Sticker/Emoji Grids */
.emoji-grid, .sticker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.4rem;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 0.25rem;
    width: 100%;
}
.emoji-item, .sticker-item {
    font-size: 1.5rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}
.emoji-item:hover, .emoji-item:active, .sticker-item:hover, .sticker-item:active {
    transform: scale(1.1);
    border-color: var(--primary);
    background: var(--primary-light);
}
.sticker-item img {
    width: 100%;
    height: 32px;
    object-fit: contain;
}
/* Action Drawer / Bottom Footer of Editor */
.editor-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    width: 100%;
}
.export-options {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}
.export-options select {
    width: 95px;
    flex-shrink: 0;
}
.privacy-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    justify-content: center;
    text-align: center;
}
/* Templates Section */
.templates-section {
    padding: 3rem 0;
    background: var(--bg-main);
    border-top: 1px solid var(--border);
}
.section-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}
.section-header h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 0.5rem;
}
.section-header p {
    color: var(--text-muted);
    font-size: clamp(0.88rem, 2vw, 1rem);
}
.template-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    width: 100%;
}
.categories-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
    width: 100%;
    max-width: 100%;
}
.categories-scroll::-webkit-scrollbar {
    display: none;
}
.cat-chip {
    min-height: 38px;
    padding: 0.4rem 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
}
.cat-chip.active, .cat-chip:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.search-box {
    position: relative;
    width: 100%;
}
.search-box i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.search-box input {
    padding-left: 2.5rem;
    width: 100%;
}
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    width: 100%;
}
.template-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    cursor: pointer;
    position: relative;
}
.template-card:hover, .template-card:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}
.template-img-wrapper {
    aspect-ratio: 1 / 1;
    width: 100%;
    background: #f1f5f9;
    overflow: hidden;
    position: relative;
}
.template-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.template-card:hover .template-img-wrapper img {
    transform: scale(1.05);
}
.template-info {
    padding: 0.65rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.template-name {
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
/* SEO & Info Section */
.info-section {
    padding: 3rem 0;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}
.seo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}
.seo-card {
    padding: 1.25rem;
    border-radius: var(--radius-md);
    background: var(--bg-main);
    border: 1px solid var(--border);
}
.seo-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.seo-card p {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.5;
}
/* FAQ Accordion */
.faq-section {
    padding: 2rem 0;
    max-width: 800px;
    margin: 0 auto;
}
.faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    background: var(--bg-main);
    overflow: hidden;
}
.faq-question {
    width: 100%;
    padding: 0.85rem 1rem;
    min-height: 48px;
    text-align: left;
    background: none;
    border: none;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.faq-answer {
    padding: 0 1rem 0.85rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    display: none;
    line-height: 1.5;
}
.faq-item.active .faq-answer {
    display: block;
}
.faq-item.active .faq-question i {
    transform: rotate(180deg);
    color: var(--primary);
}
/* Footer */
footer {
    background: #0f172a;
    color: #94a3b8;
    padding: 2.5rem 0 1.5rem;
    border-top: 1px solid #1e293b;
}
.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
    gap: 2rem;
}
.footer-brand .logo {
    color: #ffffff;
    margin-bottom: 0.75rem;
}
.footer-brand p {
    font-size: 0.85rem;
    max-width: 300px;
    line-height: 1.6;
}
.footer-col h4 {
    color: #ffffff;
    font-size: 0.9rem;
    margin-bottom: 0.85rem;
}
.footer-links {
    list-style: none;
}
.footer-links li {
    margin-bottom: 0.6rem;
}
.footer-links a {
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.85rem;
    transition: var(--transition);
    display: inline-block;
    padding: 0.2rem 0;
    background: none;
    border: none;
    cursor: pointer;
}
.footer-links a:hover {
    color: #ffffff;
}
.footer-bottom {
    text-align: center;
    padding-top: 1.5rem;
    margin-top: 2rem;
    border-top: 1px solid #1e293b;
    font-size: 0.8rem;
    color: #94a3b8;
}
/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-main);
    color: var(--bg-main);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    max-width: 90vw;
    white-space: nowrap;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* RESPONSIVE MOBILE OVERRIDES */
@media (max-width: 900px) {
    .editor-container {
        grid-template-columns: 1fr;
    }
    .preview-area {
        min-height: 280px;
        padding: 0.75rem;
    }
    .controls-area {
        max-height: none;
        border-left: none;
        border-top: 1px solid var(--border);
    }
    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    .mobile-menu-btn {
        display: flex;
    }
    .search-box {
        min-width: 100%;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 0.75rem;
    }
    .hero {
        padding: 1.75rem 0 1rem;
    }
    .hero h1 {
        font-size: 1.8rem;
    }
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    .template-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.65rem;
    }
    .emoji-grid, .sticker-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    .btn-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .btn-grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 360px) {
    .template-grid {
        grid-template-columns: 1fr;
    }
    .btn-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    .tab-btn {
        min-width: 54px;
        font-size: 0.72rem;
        padding: 0.5rem 0.2rem;
    }
}
/* ============ Legal Pages Styling ============ */
.legal-page {
    max-width: 800px;
    margin: 3rem auto;
    padding: 0 1.5rem 3rem;
}
.legal-page h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.legal-page .legal-updated {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}
.legal-page h2 {
    font-size: 1.3rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}
.legal-page p {
    color: var(--text-main);
    margin-bottom: 1rem;
    line-height: 1.7;
}
.legal-page ul {
    margin: 0 0 1rem 1.5rem;
    color: var(--text-main);
    line-height: 1.7;
}
.legal-page a {
    color: var(--primary);
    text-decoration: underline;
}