:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
}

/* Header & Navigation */
header {
    background: var(--card-bg);
    padding: 1rem 5%;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo span {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav {
    display: flex;
    gap: 2rem;
}

nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s ease;
}

nav a:hover, nav a.active {
    color: var(--primary);
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
}

/* Main Layout */
.container {
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 5%;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2.5rem;
}

/* Controls Sidebar */
.controls-panel {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    height: fit-content;
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
}

/* Custom scrollbar for controls panel */
.controls-panel::-webkit-scrollbar {
    width: 6px;
}
.controls-panel::-webkit-scrollbar-track {
    background: transparent;
}
.controls-panel::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

.controls-panel h2 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
}

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

textarea, select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
    background: #fdfdfd;
    transition: all 0.2s ease;
}

textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: #fff;
}

/* Custom Sliders */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    margin: 10px 0;
}

input[type="range"]:focus {
    outline: none;
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--border-color);
    border-radius: 3px;
    transition: background 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -7px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.1s ease;
}

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

input[type="range"]:focus::-webkit-slider-runnable-track {
    background: #cbd5e1;
}

input[type="range"]::-moz-range-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--border-color);
    border-radius: 3px;
}

input[type="range"]::-moz-range-thumb {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-sm);
}

/* Color Picker */
.color-options {
    display: flex;
    gap: 0.75rem;
}

.color-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: var(--shadow-sm);
}

.color-btn.active {
    border-color: var(--primary);
    transform: scale(1.15);
    box-shadow: var(--shadow-md);
}

/* Checkbox */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.checkbox-group input {
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-group label {
    margin-bottom: 0;
    font-weight: 500;
    cursor: pointer;
}

/* Buttons */
.export-actions {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.primary-btn {
    width: 100%;
    background: var(--gradient);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.secondary-actions {
    display: flex;
    gap: 0.75rem;
}

.secondary-btn {
    flex: 1;
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Preview Area */
.preview-area {
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1rem;
}

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

.canvas-wrapper {
    background: #e2e8f0;
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    overflow-x: auto;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
}

#pdf-content {
    display: block;
    width: 100%;
}

.page-canvas {
    background: white;
    box-shadow: var(--shadow-lg);
    width: 794px; /* A4 width */
    max-width: 100%;
    aspect-ratio: 794 / 1123;
    margin-bottom: 2rem;
    border-radius: 4px;
    display: inline-block;
}

/* Ad Spaces */
.ad-container {
    background: rgba(226, 232, 240, 0.5);
    min-height: 90px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    border: 1px dashed var(--border-color);
}
.mt-4 { margin-top: 1.5rem; }

/* SEO Content Section */
.seo-content {
    background: var(--card-bg);
    padding: 3rem 5%;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    margin: 3rem auto;
    max-width: 1000px;
}

.seo-article h1, .seo-article h2, .seo-article h3 {
    color: var(--text-main);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.seo-article h1 {
    font-size: 2.2rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.seo-article h2 {
    font-size: 1.6rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.seo-article p {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-bottom: 1.25rem;
    line-height: 1.8;
}

.seo-article ol {
    margin-left: 2rem;
    margin-bottom: 2rem;
    color: var(--text-muted);
}

.seo-article li {
    margin-bottom: 0.75rem;
    font-size: 1.05rem;
}

.seo-article strong {
    color: var(--text-main);
}

.faq-item {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.faq-item h3 {
    margin-top: 0;
    font-size: 1.2rem;
}

.faq-item p {
    margin-bottom: 0;
}

/* Footer */
#site-footer {
    background: #0f172a;
    color: #f1f5f9;
    padding: 3rem 5% 1rem;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h4 {
    margin-bottom: 1rem;
    color: #fff;
}

.footer-section p {
    color: #cbd5e1;
    font-size: 0.9rem;
}

.footer-section a {
    display: block;
    color: #cbd5e1;
    text-decoration: none;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.footer-section a:hover {
    color: var(--primary);
}

.footer-bottom {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    color: #94a3b8;
    font-size: 0.85rem;
}

/* Back to Top Button */
#backToTopBtn {
    display: none;
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99;
    border: none;
    outline: none;
    background-color: var(--primary);
    color: white;
    cursor: pointer;
    padding: 12px 16px;
    border-radius: 50%;
    font-size: 18px;
    box-shadow: var(--shadow-md);
    transition: background-color 0.3s, transform 0.3s;
}

#backToTopBtn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-3px);
}

/* Custom Font Dropdown */
.custom-dropdown {
    position: relative;
    width: 100%;
}
.dropdown-selected {
    padding: 0.75rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.dropdown-selected::after {
    content: "▼";
    font-size: 0.8rem;
    color: #64748b;
}
.dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 4px;
    padding: 0;
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: var(--shadow-lg);
}
.dropdown-options.show {
    display: block;
}
.dropdown-options li {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 1.4rem;
    border-bottom: 1px solid #f1f5f9;
}
.dropdown-options li:hover {
    background: #f8fafc;
    color: var(--primary-color);
}


/* Responsive Media Queries */
@media (max-width: 992px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    .controls-panel {
        position: static;
    }
}

@media (max-width: 768px) {
    header {
        flex-wrap: wrap;
    }

    .mobile-menu-toggle {
        display: block;
    }

    nav {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0;
        margin-top: 1rem;
        background: var(--bg-color);
        border-radius: 8px;
        overflow: hidden;
    }

    nav.show {
        display: flex;
    }

    nav a {
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
        margin: 0;
    }
    
    .canvas-wrapper {
        padding: 1rem;
    }
}
