:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-ring: rgba(79, 70, 229, 0.25);
    
    --coffee: #d97706;
    --coffee-hover: #b45309;
    --coffee-bg: #fffbeb;
    --coffee-border: #fde68a;
    
    --bg-main: #f8fafc;
    --surface: #ffffff;
    --surface-alt: #f1f5f9;
    --border: #e2e8f0;
    --border-focus: #cbd5e1;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header & Nav */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(8px);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-text span {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    display: block;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Language selector */
.lang-dropdown {
    position: relative;
}

.lang-select {
    padding: 8px 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.lang-select:hover, .lang-select:focus {
    border-color: var(--primary);
}

.header-coffee-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--coffee-bg);
    color: var(--coffee-hover);
    border: 1px solid var(--coffee-border);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.header-coffee-btn:hover {
    background: #fef3c7;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Main Container */
.main-wrapper {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
}

/* Hero Section */
.hero {
    text-align: center;
    margin-bottom: 32px;
}

.badge-privacy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    border-radius: 9999px;
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 16px;
}

.hero h2 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.hero p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto;
}

/* Upload Area */
.dropzone {
    background: var(--surface);
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-xl);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-bottom: 32px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: #fbfcfe;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.dropzone-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: transform 0.2s;
}

.dropzone:hover .dropzone-icon {
    transform: scale(1.08);
}

.dropzone-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.dropzone-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.format-tags {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.format-tag {
    padding: 4px 10px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.btn-upload {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-upload:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

#fileInput {
    display: none;
}

/* File Loaded Bar */
.file-status-bar {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    margin-bottom: 24px;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 12px;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon {
    font-size: 24px;
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all;
}

.pdf-controls {
    display: none;
    align-items: center;
    gap: 8px;
}

.btn-page {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-page:hover:not(:disabled) {
    background: #e2e8f0;
}

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

/* Workspace Grid */
.workspace-grid {
    display: none;
    grid-template-columns: 360px 1fr;
    gap: 24px;
    align-items: start;
}

/* Controls Panel */
.controls-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.control-group {
    margin-bottom: 20px;
}

.control-label-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.control-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.control-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 9999px;
}

.control-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.35;
}

/* Sliders */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
    transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Color Mode Select */
.radio-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.radio-label input {
    accent-color: var(--primary);
}

/* Action Buttons */
.btn-secondary {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.btn-secondary:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.btn-download-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
    transition: all 0.2s ease;
}

.btn-download-primary:hover {
    background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.45);
}

/* Preview Panel */
.preview-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.preview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.preview-tabs {
    display: inline-flex;
    background: var(--surface-alt);
    padding: 4px;
    border-radius: var(--radius-md);
    gap: 4px;
}

.tab-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.preview-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Canvas Container */
.canvas-container {
    width: 100%;
    min-height: 420px;
    max-height: 600px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    /* Transparent checkerboard */
    background-image: 
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0px;
    background-color: #f8fafc;
}

.canvas-container.bg-white {
    background: #ffffff !important;
}

.canvas-container.bg-dark {
    background: #0f172a !important;
}

canvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    display: block;
}

/* Donation Bottom Card */
.donation-footer-banner {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fde68a;
    border-radius: var(--radius-xl);
    padding: 32px 28px;
    margin-top: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.donation-content {
    display: flex;
    align-items: center;
    gap: 20px;
    max-width: 720px;
}

.coffee-illustration {
    font-size: 48px;
    line-height: 1;
    filter: drop-shadow(0 4px 6px rgba(217, 119, 6, 0.2));
}

.donation-text h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #92400e;
    margin-bottom: 4px;
}

.donation-text p {
    font-size: 0.95rem;
    color: #b45309;
}

.btn-coffee-large {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #d97706;
    color: white;
    padding: 14px 28px;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(217, 119, 6, 0.35);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-coffee-large:hover {
    background: #b45309;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(217, 119, 6, 0.45);
}

/* Footer info */
.footer-bar {
    text-align: center;
    padding: 24px;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 40px;
    background: var(--surface);
}

/* Modal Popup */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    max-width: 500px;
    width: 100%;
    padding: 32px;
    box-shadow: var(--shadow-xl);
    text-align: center;
    position: relative;
    animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--surface-alt);
}

.modal-badge {
    display: inline-block;
    padding: 6px 14px;
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
    border-radius: 9999px;
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.modal-emoji {
    font-size: 54px;
    margin-bottom: 12px;
    display: inline-block;
    animation: bounce 2s infinite ease-in-out;
}

.modal-card h3 {
    font-size: 1.45rem;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.modal-card p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 14px;
}

.modal-card p strong {
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.modal-btn-coffee {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    color: white;
    font-weight: 700;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-size: 1rem;
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.35);
    transition: all 0.2s;
}

.modal-btn-coffee:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(217, 119, 6, 0.45);
}

.modal-btn-download {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn-download:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.modal-checkbox-row {
    margin-top: 14px;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* Responsive */
@media (max-width: 960px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
    
    .donation-footer-banner {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .btn-coffee-large {
        width: 100%;
        justify-content: center;
    }
}

