/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; overflow-x: clip; overscroll-behavior: none; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    line-height: 1.5;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

/* === Header === */
.app-header {
    height: 52px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}
.logo-link { display: flex; align-items: center; text-decoration: none; }
.logo-img { height: 32px; width: auto; }
.header-right { display: flex; gap: 8px; align-items: center; }

/* Language switcher */
.lang-switcher { display: flex; gap: 2px; }
.lang-btn {
    padding: 4px 8px;
    border: 1px solid #94a3b8;
    background: #fff;
    color: #475569;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}
.lang-btn:first-child { border-radius: 6px 0 0 6px; }
.lang-btn:last-child { border-radius: 0 6px 6px 0; }
.lang-btn.active { background: #4f46e5; color: #fff; border-color: #4f46e5; }

/* === Buttons === */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: #6366f1; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #4f46e5; }
.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* === Layout === */
.app-container {
    display: flex;
    margin-top: 52px;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
    overflow: hidden;
}

/* === Sidebar === */
.sidebar {
    width: 300px;
    min-width: 300px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
}
.sidebar-section { margin-bottom: 20px; }
.sidebar-section h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    margin-bottom: 8px;
    font-weight: 700;
}
.sidebar-occasions {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}
.sidebar-occasions-title {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.sidebar-occasions-links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
}
.sidebar-occasions-links a {
    font-size: 0.7rem;
    color: #94a3b8;
    text-decoration: none;
    white-space: nowrap;
}
.sidebar-occasions-links a:hover { color: #6366f1; }
.sidebar-footer {
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 16px;
    justify-content: center;
}
.sidebar-footer a {
    font-size: 0.75rem;
    color: #94a3b8;
    text-decoration: none;
}
.sidebar-footer a:hover { color: #6366f1; }

/* Upload Zone */
.upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: #6366f1;
    background: #f5f3ff;
}
.upload-zone input { display: none; }
.upload-icon { font-size: 1.8rem; color: #6366f1; margin-bottom: 2px; font-weight: 300; }
.upload-zone p { font-size: 0.75rem; color: #94a3b8; }
.photo-count { font-size: 0.75rem; color: #64748b; margin-top: 6px; text-align: center; }

/* Photo strip */
.photo-strip { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; max-height: 120px; overflow-y: auto; }
.photo-thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; cursor: pointer; border: 2px solid transparent; transition: all 0.15s; }
.photo-thumb:hover { border-color: #6366f1; transform: scale(1.05); }
.photo-thumb-remove { position: absolute; top: -4px; right: -4px; width: 16px; height: 16px; border-radius: 50%; background: #ef4444; color: #fff; border: none; font-size: 10px; line-height: 16px; text-align: center; cursor: pointer; display: none; }
.photo-thumb-wrap { position: relative; display: inline-block; }
.photo-thumb-wrap:hover .photo-thumb-remove { display: block; }

/* Select */
select { width: 100%; padding: 7px 10px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 0.8rem; background: #fff; cursor: pointer; }
select:focus { outline: none; border-color: #6366f1; }

/* Orientation toggle */
.orientation-toggle { display: flex; gap: 4px; margin-top: 6px; }
.orientation-toggle .btn { flex: 1; }
.orientation-toggle .btn.active { background: #6366f1; color: #fff; }

/* Layout Grid */
.layout-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.layout-btn {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 3px 5px; border: 2px solid #e2e8f0; background: #fff;
    border-radius: 8px; cursor: pointer; transition: all 0.15s;
}
.layout-btn svg { width: 32px; height: 32px; fill: #64748b; }
.layout-btn span { font-size: 0.6rem; color: #94a3b8; font-weight: 600; }
.layout-btn:hover { border-color: #a5b4fc; background: #f5f3ff; }
.layout-btn:hover svg { fill: #6366f1; }
.layout-btn.active { border-color: #6366f1; background: #eef2ff; }
.layout-btn.active svg { fill: #6366f1; }
.layout-btn.active span { color: #6366f1; }

/* Mask Picker */
.mask-category { margin-bottom: 8px; }
.mask-category label { font-size: 0.7rem; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.04em; display: block; margin-bottom: 4px; }
.mask-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.mask-btn {
    aspect-ratio: 1; border: 2px solid #e2e8f0; background: #fff; border-radius: 6px;
    cursor: pointer; padding: 4px; transition: all 0.15s; display: flex; align-items: center; justify-content: center;
}
.mask-btn img { width: 100%; height: 100%; object-fit: contain; opacity: 0.5; transition: opacity 0.15s; }
.mask-btn:hover { border-color: #a5b4fc; background: #f5f3ff; }
.mask-btn:hover img { opacity: 0.8; }
.mask-btn.active { border-color: #6366f1; background: #eef2ff; }
.mask-btn.active img { opacity: 1; }
.mask-number-input {
    width: 100%; padding: 8px 10px; border: 2px solid #e2e8f0; border-radius: 8px;
    font-size: 0.9rem; font-family: inherit; outline: none; transition: border-color 0.15s;
}
.mask-number-input:focus { border-color: #6366f1; }
.mask-number-input::placeholder { color: #94a3b8; }

/* Alignment grid */
.align-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; max-width: 120px; }
.align-btn {
    width: 36px; height: 36px; border: 1px solid #e2e8f0; background: #fff;
    border-radius: 6px; cursor: pointer; font-size: 0.9rem; color: #94a3b8;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.align-btn:hover { border-color: #a5b4fc; background: #f5f3ff; color: #6366f1; }
.align-btn.active { border-color: #6366f1; background: #eef2ff; color: #6366f1; }

/* Settings */
.setting-hint { font-size: 0.65rem; color: #94a3b8; margin: 0 0 6px; line-height: 1.3; }
.setting-row { margin-bottom: 10px; }
.setting-row label { display: block; font-size: 0.75rem; color: #64748b; margin-bottom: 3px; font-weight: 500; }
.range-with-value { display: flex; align-items: center; gap: 8px; }
.range-with-value input[type="range"] { flex: 1; }
.range-with-value span { font-size: 0.7rem; color: #94a3b8; min-width: 36px; text-align: right; }
input[type="color"] { width: 100%; height: 32px; border: 1px solid #e2e8f0; border-radius: 8px; padding: 2px; cursor: pointer; }
input[type="range"] { -webkit-appearance: none; height: 4px; background: #e2e8f0; border-radius: 2px; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #6366f1; cursor: pointer; }

/* === Canvas Area === */
.canvas-area {
    flex: 1;
    display: grid;
    grid-template-areas:
        "top   top   top"
        "left  center right";
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto 1fr;
    gap: 0 8px;
    background: #e8eaed;
    position: relative;
    overflow: hidden;
    min-width: 0;
    touch-action: pan-x pan-y;
}
.canvas-scroll-container {
    grid-area: center;
    width: 100%;
    height: 100%;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
    min-height: 0;
}
.canvas-wrapper {
    box-shadow: 0 4px 24px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.08);
    position: relative;
    background: #fff;
    flex-shrink: 0;
    margin: auto;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
#collage-canvas { display: block; }
.canvas-scroll-container.empty-hidden { display: none; }

.canvas-empty {
    grid-area: center;
    z-index: 5;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.canvas-empty.hidden { display: none; }
.empty-icon { font-size: 3.5rem; margin-bottom: 12px; opacity: 0.3; }
.canvas-empty h1 { font-size: 1.1rem; color: #334155; font-weight: 600; text-align: center; padding: 0 20px; margin: 0; }
.canvas-empty p { font-size: 0.85rem; color: #475569; margin-top: 4px; text-align: center; padding: 0 20px; }

/* === Hint Bar === */
.hint-bar {
    grid-area: center;
    position: relative; align-self: end; justify-self: center;
    margin-bottom: 12px;
    background: rgba(30, 41, 59, 0.85); color: #e2e8f0;
    padding: 7px 16px; border-radius: 10px; font-size: 0.73rem; font-weight: 500;
    pointer-events: none; white-space: nowrap; backdrop-filter: blur(8px); z-index: 11;
}
.hint-bar.hint-crop { background: rgba(99, 102, 241, 0.9); color: #fff; }

/* === Zoom Controls === */
.zoom-controls {
    grid-area: center;
    position: relative; align-self: end; justify-self: center;
    margin-bottom: 12px;
    z-index: 10;
    display: none; align-items: center; gap: 2px;
    background: rgba(255,255,255,0.92); border-radius: 8px;
    padding: 3px 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    user-select: none; backdrop-filter: blur(4px);
}
.zoom-btn {
    width: 28px; height: 28px; border: none; background: transparent;
    border-radius: 6px; cursor: pointer; font-size: 16px; color: #555;
    display: flex; align-items: center; justify-content: center;
}
.zoom-btn:hover { background: #e8eaed; color: #1a1a2e; }
.zoom-level { font-size: 11px; color: #666; min-width: 38px; text-align: center; }

/* === Crop Mode === */
.canvas-wrapper.crop-mode { outline: 3px solid #6366f1; outline-offset: 2px; cursor: grab; }
.canvas-wrapper.crop-mode:active { cursor: grabbing; }

/* === Modal === */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff; border-radius: 16px; width: 420px; max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-export { width: 540px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid #e2e8f0; }
.modal-header h2 { font-size: 1.05rem; }
.modal-close { width: 32px; height: 32px; border: none; background: #f1f5f9; border-radius: 8px; font-size: 1.2rem; cursor: pointer; color: #64748b; }
.modal-close:hover { background: #e2e8f0; }
.modal-body { padding: 22px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: #475569; margin-bottom: 5px; }

/* Export Preview */
.export-preview {
    position: relative;
    background: #f1f5f9; border-radius: 10px;
    min-height: 120px; margin-bottom: 16px;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.export-preview img {
    max-width: 100%; max-height: 280px;
    border-radius: 8px; display: block;
    object-fit: contain;
}
.export-preview img[src=""] { display: none; }
.export-preview-loading {
    position: absolute; font-size: 0.8rem; color: #94a3b8; font-weight: 500;
}
.export-preview img:not([src=""]) ~ .export-preview-loading { display: none; }

/* Export Settings Row */
.export-settings {
    display: flex; gap: 12px; margin-bottom: 14px;
}
.export-settings .form-group { flex: 1; margin-bottom: 0; }

/* Share Section */
.share-section {
    margin-top: 18px; padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}
.share-label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
    color: #94a3b8; font-weight: 700; margin-bottom: 10px;
}
.share-bar {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.share-btn {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 8px 10px; border: 1px solid #e2e8f0; background: #fff;
    border-radius: 10px; cursor: pointer; transition: all 0.15s;
    min-width: 56px; color: #475569;
}
.share-btn svg { flex-shrink: 0; }
.share-btn span { font-size: 0.6rem; font-weight: 600; color: #94a3b8; }
.share-btn:hover { border-color: #a5b4fc; background: #f5f3ff; color: #6366f1; }
.share-btn:hover span { color: #6366f1; }
.share-btn.success { border-color: #86efac; background: #f0fdf4; }
.share-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.share-status {
    margin-top: 8px; padding: 6px 10px; border-radius: 8px;
    font-size: 0.75rem; font-weight: 500;
}
.share-status.loading { background: #f0f4ff; color: #4f46e5; }
.share-status.error { background: #fef2f2; color: #dc2626; }
.share-status.success { background: #f0fdf4; color: #16a34a; }

/* Export button loading state */
.btn-exporting {
    position: relative; pointer-events: none; opacity: 0.85;
}
.btn-exporting .btn-spinner {
    display: inline-block; width: 16px; height: 16px; margin-right: 6px;
    border: 2.5px solid rgba(255,255,255,0.35); border-top-color: #fff;
    border-radius: 50%; animation: url-spin 0.6s linear infinite; vertical-align: middle;
}

/* Export success view */
.export-success {
    text-align: center; padding: 24px 0 16px;
}
.export-success-icon { margin-bottom: 12px; }
.export-success h3 {
    font-size: 1.1rem; font-weight: 700; color: #1a1a2e; margin: 0 0 6px;
}
.export-success p {
    font-size: 0.85rem; color: #64748b; margin: 0;
}

/* Export modal ad slots */
.ad-slot-export.active {
    display: flex !important; align-items: center; justify-content: center;
    margin-top: 16px; padding-top: 14px; border-top: 1px solid #f1f5f9;
    max-height: 250px;
}
.ad-slot-export-success.active {
    display: flex !important; align-items: center; justify-content: center;
    margin: 20px 0 16px; max-height: 250px;
}

@media (max-width: 768px) {
    .modal-export { width: 95vw; }
    .export-preview img { max-height: 200px; }
    .share-bar { gap: 4px; }
    .share-btn { min-width: 48px; padding: 6px 8px; }
}

/* === Mobile === */
.mobile-toggle {
    display: none;
    position: fixed; bottom: 16px; right: 16px;
    width: 52px; height: 52px; border-radius: 50%;
    background: #6366f1; color: #fff; border: none;
    font-size: 1.4rem; cursor: pointer; z-index: 200;
    box-shadow: 0 4px 16px rgba(99,102,241,0.4);
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(99,102,241,0.3);
}
.mobile-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.4); z-index: 80;
}
.mobile-backdrop.active { display: block; }

@media (max-width: 768px) {
    .mobile-toggle { display: flex; align-items: center; justify-content: center; }
    .app-container { flex-direction: column; height: calc(100vh - 52px); height: calc(100dvh - 52px); }

    .sidebar {
        position: fixed; left: 0; top: 52px; bottom: 0; z-index: 85;
        width: min(320px, 85vw); min-width: 0;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: 1px solid #e2e8f0;
    }
    .sidebar.open { transform: translateX(0); }

    .canvas-area {
        width: 100%; height: calc(100vh - 52px); height: calc(100dvh - 52px);
        grid-template-areas: "center";
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
    }
    .canvas-scroll-container { padding: 4px; }

    .canvas-empty { cursor: pointer; }
    .canvas-empty h1 { font-size: 0.95rem; padding: 0 24px; }
    .canvas-empty p { font-size: 0.78rem; padding: 0 24px; }

    .hint-bar { font-size: 0.65rem; padding: 5px 10px; white-space: normal; text-align: center; max-width: 90vw; margin-bottom: 48px; }
    .zoom-controls { margin-bottom: 48px; }
    .logo-img { height: 26px; }

    /* When bottom ad is visible, shift controls up further */
    body.has-bottom-ad .zoom-controls { margin-bottom: 108px; }
    body.has-bottom-ad .hint-bar { margin-bottom: 72px; }
    body.has-bottom-ad .canvas-area { height: calc(100vh - 52px - 60px); height: calc(100dvh - 52px - 60px); }
    body.has-bottom-ad .mobile-toggle { bottom: 76px; }
}

/* === Logo Upload (compact) === */
.upload-zone-sm {
    padding: 10px 12px;
}
.upload-zone-sm .upload-icon { font-size: 1.2rem; margin-bottom: 0; }
.upload-zone-sm p { font-size: 0.7rem; }
.logo-preview-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.logo-preview {
    height: 40px;
    width: auto;
    max-width: 120px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    object-fit: contain;
}

/* === Text Overlay === */
#overlay-text {
    width: 100%;
    min-width: 0;
    padding: 7px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: inherit;
    background: #fff;
    color: #1a1a2e;
    resize: vertical;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1.5;
}
#overlay-text:focus { outline: none; border-color: #6366f1; }
.text-style-toolbar { display: flex; gap: 4px; }
.text-style-btn {
    width: 32px; height: 32px; border: 1px solid #e2e8f0; background: #fff;
    border-radius: 6px; cursor: pointer; font-size: 0.8rem; color: #64748b;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s;
    padding: 0; line-height: 1;
}
.text-style-btn:hover { border-color: #a5b4fc; background: #f5f3ff; color: #6366f1; }
.text-style-btn.active { border-color: #6366f1; background: #eef2ff; color: #6366f1; }
.color-with-toggle { display: flex; align-items: center; gap: 8px; }
.color-with-toggle input[type="color"] { flex: 1; }
.toggle-label {
    display: flex; align-items: center; gap: 4px;
    font-size: 0.7rem; color: #64748b; cursor: pointer; white-space: nowrap;
}
.toggle-label input[type="checkbox"] { accent-color: #6366f1; }
#text-font-family option { padding: 4px 8px; }
#text-font-family option[value="Roboto"] { font-family: 'Roboto', sans-serif; }
#text-font-family option[value="Open Sans"] { font-family: 'Open Sans', sans-serif; }
#text-font-family option[value="Lato"] { font-family: 'Lato', sans-serif; }
#text-font-family option[value="Montserrat"] { font-family: 'Montserrat', sans-serif; }
#text-font-family option[value="Raleway"] { font-family: 'Raleway', sans-serif; }
#text-font-family option[value="Oswald"] { font-family: 'Oswald', sans-serif; }
#text-font-family option[value="Playfair Display"] { font-family: 'Playfair Display', serif; }
#text-font-family option[value="Bebas Neue"] { font-family: 'Bebas Neue', sans-serif; }
#text-font-family option[value="Lobster"] { font-family: 'Lobster', cursive; }
#text-font-family option[value="Permanent Marker"] { font-family: 'Permanent Marker', cursive; }
#text-font-family option[value="Dancing Script"] { font-family: 'Dancing Script', cursive; }
#text-font-family option[value="Pacifico"] { font-family: 'Pacifico', cursive; }
#text-font-family option[value="Caveat"] { font-family: 'Caveat', cursive; }
#text-font-family option[value="Great Vibes"] { font-family: 'Great Vibes', cursive; }
#text-font-family option[value="Satisfy"] { font-family: 'Satisfy', cursive; }

/* === URL Import === */
.url-import-section { margin-top: 10px; padding-top: 10px; border-top: 1px solid #e2e8f0; }
.url-input-row { display: flex; gap: 6px; margin-bottom: 6px; }
.url-input-row input[type="url"] {
    flex: 1; min-width: 0; padding: 7px 10px;
    border: 1px solid #e2e8f0; border-radius: 8px;
    font-size: 0.8rem; font-family: inherit; background: #fff;
    color: #1a1a2e; -webkit-appearance: none; appearance: none;
}
.url-input-row input[type="url"]:focus { outline: none; border-color: #6366f1; }
.url-input-row .btn { white-space: nowrap; flex-shrink: 0; }
.url-status {
    padding: 6px 10px; border-radius: 8px; font-size: 0.75rem; font-weight: 500;
    margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.url-status.loading { background: #f0f4ff; color: #4f46e5; }
.url-status.error { background: #fef2f2; color: #dc2626; }
.url-status.success { background: #f0fdf4; color: #16a34a; }
.url-status .spinner {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid #a5b4fc; border-top-color: #4f46e5;
    border-radius: 50%; animation: url-spin 0.6s linear infinite; flex-shrink: 0;
}
@keyframes url-spin { to { transform: rotate(360deg); } }

/* === Upload Progress === */
.upload-progress {
    margin: 8px 0; padding: 8px 10px; border-radius: 10px;
    background: #f0f4ff; font-size: 0.75rem; color: #4f46e5;
}
.upload-progress-info {
    display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 5px;
}
.upload-progress-track {
    height: 6px; border-radius: 3px; background: #c7d2fe; overflow: hidden;
}
.upload-progress-bar {
    height: 100%; width: 0%; border-radius: 3px;
    background: linear-gradient(90deg, #6366f1, #818cf8);
    transition: width 0.2s ease;
}

/* === Debug Panel (localhost only) === */
.debug-panel {
    position: fixed; bottom: 12px; right: 12px; z-index: 9999;
    background: #1e1b4b; color: #e0e7ff; font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.7rem; line-height: 1.5; padding: 10px 14px; border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.3); max-width: 340px; pointer-events: auto;
    backdrop-filter: blur(8px); border: 1px solid rgba(99,102,241,0.3);
}
.debug-panel-title {
    font-weight: 700; font-size: 0.72rem; color: #a5b4fc; margin-bottom: 4px;
    display: flex; align-items: center; gap: 5px;
}
.debug-panel-title::before {
    content: ''; display: inline-block; width: 7px; height: 7px;
    background: #22c55e; border-radius: 50;
}
.debug-panel .dp-row {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 1px 0; border-bottom: 1px solid rgba(99,102,241,0.12);
}
.debug-panel .dp-row:last-child { border-bottom: none; }
.debug-panel .dp-label { color: #94a3b8; }
.debug-panel .dp-val { color: #c4b5fd; font-weight: 600; }
.debug-panel .dp-val.dp-green { color: #4ade80; }
.debug-panel .dp-close {
    position: absolute; top: 6px; right: 8px; background: none; border: none;
    color: #64748b; cursor: pointer; font-size: 0.85rem; line-height: 1;
}
.debug-panel .dp-close:hover { color: #e0e7ff; }

/* === Legal Pages === */
.legal-page {
    max-width: 700px;
    margin: 52px auto 0;
    padding: 40px 24px 80px;
    overflow-y: auto;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
}
.legal-page h1 { font-size: 1.6rem; margin-bottom: 24px; color: #1a1a2e; }
.legal-page h2 { font-size: 1.1rem; margin: 24px 0 8px; color: #334155; }
.legal-page h3 { font-size: 0.95rem; margin: 16px 0 6px; color: #475569; }
.legal-page p { margin-bottom: 10px; font-size: 0.9rem; color: #475569; line-height: 1.7; }
.legal-page ul { margin: 8px 0 16px 24px; font-size: 0.9rem; color: #475569; }
.legal-page li { margin-bottom: 4px; }
.legal-page a { color: #6366f1; }

/* === Ad Slots === */
.ad-slot { display: none !important; overflow: hidden; background: transparent; }
.ad-slot img { max-width: 100%; height: auto; display: block; }
.ad-slot a { display: block; line-height: 0; background: transparent; }

/* Sidebar ad: always visible when active */
.ad-slot-sidebar.active {
    display: flex !important; align-items: center; justify-content: center;
    width: 100%; max-height: 250px;
    margin: 12px 0; padding: 4px 0;
    flex-shrink: 0;
}
.ad-slot-sidebar a { display: block; line-height: 0; }
.ad-slot-sidebar img { max-width: 100%; height: auto; }

/* Top ad: inside canvas-area grid, visible ≥1024px */
.ad-slot-top {
    grid-area: top;
    max-height: 250px;
    justify-self: center;
    width: 100%; max-width: 900px;
    margin-bottom: 12px;
}
@media (min-width: 1024px) {
    .ad-slot-top.active { display: flex !important; align-items: center; justify-content: center; }
}

/* Side ads: inside canvas-area grid, visible ≥1400px */
.ad-slot-left {
    grid-area: left;
    max-width: 300px; max-height: 600px;
    align-self: center;
}
.ad-slot-right {
    grid-area: right;
    max-width: 300px; max-height: 600px;
    align-self: center;
}
@media (min-width: 1400px) {
    .ad-slot-left.active, .ad-slot-right.active { display: flex !important; align-items: center; justify-content: center; }
}

/* Mobile bottom ad: fixed, visible ≤768px */
.ad-slot-bottom-mobile {
    position: fixed; bottom: 0; left: 0; right: 0;
    max-width: 430px; max-height: 60px; margin: 0 auto;
    z-index: 70; background: #fff;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
@media (max-width: 768px) {
    .ad-slot-bottom-mobile.active { display: flex !important; align-items: center; justify-content: center; }
}
