:root {
    /* Colors - New "Premium Utility" Palette */
    --primary-color: #4F46E5;
    /* Indigo-600 */
    --primary-hover: #4338CA;
    /* Indigo-700 */
    --background-color: #f9fafb;
    /* Cool Gray 50 - Warmer than previous */
    --card-background: #ffffff;
    --text-main: #111827;
    /* Gray-900 */
    --text-muted: #6B7280;
    /* Gray-500 */
    --border-color: #E5E7EB;
    /* Gray-200 */
    --input-bg: #ffffff;
    --focus-ring: rgba(79, 70, 229, 0.15);
    /* Soft Indigo Glow */

    /* Spacing & Layout */
    --radius-lg: 16px;
    /* Slightly tighter for cleaner look */
    --radius-md: 10px;
    --radius-sm: 6px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --container-max-width: 1080px;

    /* Shadows */
    --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-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #818CF8;
        /* Indigo-400 - Brighter for dark mode */
        --primary-hover: #6366F1;
        /* Indigo-500 */
        --background-color: #111827;
        /* Gray-900 */
        --card-background: #1F2937;
        /* Gray-800 */
        --text-main: #F9FAFB;
        /* Gray-50 */
        --text-muted: #9CA3AF;
        /* Gray-400 */
        --border-color: #374151;
        /* Gray-700 */
        --input-bg: #111827;
        --focus-ring: rgba(129, 140, 248, 0.2);

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Header and Navigation */
header {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

@media (prefers-color-scheme: dark) {
    header {
        background-color: rgba(28, 28, 30, 0.8);
    }
}

nav {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: var(--spacing-lg);
}

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

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

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropbtn {
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dropbtn:hover {
    color: var(--primary-color);
}

.dropbtn::after {
    content: "▼";
    font-size: 0.6rem;
    opacity: 0.6;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--card-background);
    min-width: 200px;
    box-shadow: var(--shadow-hover);
    border-radius: var(--radius-md);
    /* padding-top creates an invisible bridge so cursor can travel from
       button to menu without leaving the hover zone */
    padding: 8px 0 8px 0;
    z-index: 1000;
    border: 1px solid var(--border-color);
    top: 100%;
    right: -10px;
    /* No margin-top — use pseudo-element bridge instead */
    margin-top: 0;
}

/* Invisible bridge fills the gap between button and panel */
.dropdown-content::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 12px;
}

.dropdown-content a {
    color: var(--text-main);
    padding: 10px 16px;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
    font-weight: 400;
    transition: background-color 0.1s ease;
}

.dropdown-content a:hover {
    background-color: var(--background-color);
    color: var(--primary-color);
}

/* Shown via JS toggle (.open class) OR hover */
.dropdown:hover .dropdown-content,
.dropdown.open .dropdown-content {
    display: block;
}

/* Main Content */
main {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 40px var(--spacing-lg);
    flex: 1;
    width: 100%;
}

.tool-section {
    max-width: 900px;
    margin: 0 auto;
}

/* Content Pages (Privacy, Terms, Contact) */
.content-block,
article {
    background-color: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 40px;
    border: 1px solid var(--border-color);
    margin-top: var(--spacing-lg);
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: var(--spacing-sm);
    text-align: center;
    letter-spacing: -0.015em;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-muted);
    margin-bottom: 40px;
    text-align: center;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Tool Container */
.tool-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    align-items: start;
}

/* Panels (Cards) */
.input-panel,
.preview-panel>.qr-preview {
    background-color: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 30px;
    border: 1px solid var(--border-color);
}

/* Input Panel Specifics */
.input-panel {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

label {
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.9rem;
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background-color: var(--input-bg);
    color: var(--text-main);
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

/* Select arrow fix */
select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 32px;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

textarea {
    resize: vertical;
    font-family: inherit;
    min-height: 100px;
}

/* Color Inputs */
input[type="color"] {
    width: 100%;
    height: 44px;
    padding: 4px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 400;
    color: var(--text-main);
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Preview Panel */
.preview-panel {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.qr-preview {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    /* QR codes look best on white even in dark mode */
    position: relative;
    overflow: hidden;
}

/* Force Light Mode inside QR preview for visibility */
@media (prefers-color-scheme: dark) {
    .qr-preview {
        border: 4px solid var(--card-background);
        /* Frame it */
    }
}

.qr-preview canvas,
.qr-preview img {
    max-width: 80%;
    height: auto;
    object-fit: contain;
}

.placeholder-text {
    color: #a1a1a6;
    /* Specific color for placeholder */
    text-align: center;
    padding: 2rem;
    font-size: 0.95rem;
}

/* Download Buttons */
.download-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    width: 100%;
}

.btn {
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    /* Matches Indigo */
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: rgba(118, 118, 128, 0.12);
    color: var(--primary-color);
}

.btn-secondary:hover {
    background-color: rgba(118, 118, 128, 0.2);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* SEO Section */
.seo-content {
    margin-top: 80px;
    padding-top: 40px;
    border-top: 1px solid var(--border-color);
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.seo-content h2 {
    font-size: 1.75rem;
    color: var(--text-main);
    margin-bottom: var(--spacing-lg);
    text-align: center;
}

.seo-content h3 {
    font-size: 1.25rem;
    color: var(--text-main);
    margin: 30px 0 15px;
}

.seo-content p,
.seo-content li {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.6;
}

.seo-content ul {
    margin-bottom: 20px;
    padding-left: 20px;
}

.faq-grid {
    display: grid;
    gap: var(--spacing-lg);
    margin-top: 30px;
}

.faq-item {
    padding: 0;
    background: none;
    border: none;
}

.faq-item h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

/* Footer */
footer {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 40px var(--spacing-lg);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    width: 100%;
}

.footer-links {
    margin-top: var(--spacing-md);
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
}

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

/* Mobile Responsiveness */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .tool-container {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .nav-links {
        display: none;
        /* Consider a hamburger menu or just simplified nav for extreme simplicity preference? 
                        Current implementation had them stack. Let's keep them accessible but cleaner. 
                     */
    }

    /* Simplified Mobile Nav */
    nav {
        justify-content: center;
    }

    .logo {
        font-size: 1.5rem;
    }

    /* Re-enable links if needed, but for "utility" focus, maybe bottom nav or just scroll? 
       Let's stick to the previous stacking behavior but improved.
    */
}

/* Better Mobile Link Handling */
@media (max-width: 768px) {
    nav {
        flex-direction: column;
        height: auto;
        padding: 15px;
        gap: 10px;
    }

    .nav-links {
        display: flex;
        gap: 15px;
        font-size: 0.85rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .input-panel,
    .preview-panel>.qr-preview {
        padding: 20px;
    }

    .qr-preview {
        min-height: 250px;
    }
}

@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .download-buttons {
        flex-direction: column;
    }

    main {
        padding: 20px 16px;
    }
}