:root {
    --bg-color: #f7f8fc;
    --card-bg: #ffffff;
    --border-color: #e8eaf3;
    --text-color: #333745;
    --text-secondary: #70768b;
    --accent-gradient: linear-gradient(90deg, #5A8BFF, #69D2E7);
    --accent-color-start: #5A8BFF;
    --shadow-color: rgba(90, 100, 120, 0.1);
}

[data-theme="dark"] {
    --bg-color: #101727;
    --card-bg: #1d283d;
    --border-color: #2c3a54;
    --text-color: #f0f4f9;
    --text-secondary: #94a3b8;
    --accent-gradient: linear-gradient(90deg, #9f7aea, #f06292);
    --accent-color-start: #9f7aea;
}

body.homepage-body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* --- HEADER FIX --- */
.page-header {
    padding: 20px;
    display: flex; /* Use flexbox */
    align-items: center; /* Vertically align all items */
}
.logo {
    margin: 0 auto; /* This is the key to perfect centering */
    line-height: 0;
}
.logo img {
    max-height: 50px;
    width: auto;
    display: block;
}
.theme-toggle {
    position: fixed; /* Keep toggle independent of header flow */
    top: 20px;
    right: 20px;
    cursor: pointer;
    z-index: 1000;
    width: 48px;
    height: 48px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px var(--shadow-color);
}
.theme-toggle svg { width: 24px; height: 24px; color: var(--text-secondary); }
.sun-icon { display: none; }
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 10px 20px 30px;
}
/* This selector targets the logo only in the hero section */
.hero-section .logo {
    margin-bottom: 1rem;
}
.hero-section h1 {
    font-size: 2.8rem;
    font-weight: 700;
    margin-bottom: 15px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}
.hero-section p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* Card Style */
.section-card {
    background-color: var(--card-bg);
    border-radius: 24px;
    padding: 25px;
    box-shadow: 0 10px 30px var(--shadow-color);
    margin-top: 30px;
    border: 1px solid var(--border-color);
}

/* Form Styles */
.shorten-form {
    display: flex;
    gap: 15px;
    background-color: var(--bg-color);
    padding: 8px;
    border-radius: 50px;
}
.input-wrapper {
    flex-grow: 1;
    display: flex;
    align-items: center;
}
.link-icon {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
    margin: 0 15px;
    flex-shrink: 0;
}
#long-url-input {
    width: 100%;
    border: none;
    background: transparent;
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    color: var(--text-color);
    min-width: 50px;
}
#long-url-input:focus { outline: none; }
#long-url-input::placeholder { color: var(--text-secondary); opacity: 0.7; }

.btn-gradient {
    padding: 16px 32px;
    border: none;
    border-radius: 50px;
    background: var(--accent-gradient);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-shrink: 0;
}
.btn-gradient:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px color-mix(in srgb, var(--accent-color-start) 40%, transparent);
}
.btn-gradient:disabled { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Result Area */
#result-area {
    margin-top: 25px;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
#result-area p { color: var(--text-secondary); margin-bottom: 10px; }
.result-box {
    display: flex;
    gap: 10px;
    background-color: var(--bg-color);
    border-radius: 12px;
    padding: 8px;
    align-items: center;
}
#short-url-output {
    flex-grow: 1;
    border: none;
    background: transparent;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-color);
    padding: 0 15px;
    text-align: left;
}
#copy-btn {
    padding: 10px 20px;
    background: var(--accent-color-start);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

/* Interstitial Page Styles */
.interstitial-container { max-width: 800px; }
.timer-card { text-align: center; }
.timer-card h2 { background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.progress-bar-container { width: 100%; height: 12px; background-color: var(--bg-color); border-radius: 12px; margin: 30px 0; overflow: hidden; border: 1px solid var(--border-color); }
.progress-bar { width: 100%; height: 100%; background: var(--accent-gradient); border-radius: 12px; }
.demo-ad-slot { background-color: var(--card-bg); border: 2px dashed var(--border-color); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; font-weight: 500; margin: 20px auto; }
.ad-leaderboard { width: 100%; max-width: 728px; height: 90px; }
.ad-rectangle { width: 100%; max-width: 300px; height: 250px; }
.content-card { text-align: left; }
.content-card h2, .content-card h3 { text-align: left; background: none; -webkit-background-clip: initial; -webkit-text-fill-color: initial; }
.content-card h2 { font-size: 1.8rem; color: var(--text-color); }
.content-card h3.content-h3 { font-size: 1.3rem; font-weight: 600; color: var(--text-color); margin-top: 30px; border-bottom: 2px solid var(--border-color); padding-bottom: 10px; }
.content-card p, .content-card li { color: var(--text-secondary); }
.content-card ul.content-list { list-style: none; padding: 0; }
.content-card ul.content-list li { display: flex; align-items: flex-start; gap: 15px; margin-bottom: 15px; }
.content-card ul.content-list svg { width: 24px; height: 24px; flex-shrink: 0; color: var(--accent-color-start); margin-top: 5px; }
.content-card strong { color: var(--text-color); }

/* Features Section */
.features-section { padding: 60px 20px; background-color: var(--card-bg); }
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; }
.feature-card { text-align: center; }
.feature-card .icon { width: 48px; height: 48px; color: var(--accent-color-start); margin-bottom: 15px; }
.feature-card h3 { font-size: 1.2rem; }
.feature-card p { font-size: 0.95rem; }

/* FAQ Section */
.faq-section { padding: 60px 20px; }
.faq-list { max-width: 700px; margin: 0 auto; }
.faq-item { border-bottom: 1px solid var(--border-color); padding-bottom: 15px; margin-bottom: 15px; }
.faq-question { cursor: pointer; position: relative; font-size: 1.1rem; }
.faq-question::after { content: '+'; position: absolute; right: 0; transition: transform 0.3s; color: var(--accent-color-start); }
.faq-answer { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; }
.faq-answer p { margin-top: 10px; }
.faq-item.active .faq-answer { max-height: 200px; }
.faq-item.active .faq-question::after { transform: rotate(45deg); }

/* --- FOOTER FIX --- */
.main-footer { padding: 60px 20px 20px; background-color: var(--bg-color); border-top: 1px solid var(--border-color); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 40px; margin-bottom: 40px; }
.footer-about {
    display: flex;
    flex-direction: column;
    align-items: center; /* Center items on mobile */
    text-align: center;
}
.footer-about .logo {
    position: static;
    transform: none;
    margin-bottom: 20px;
}
.footer-about p { font-size: 0.9rem; }
.footer-col { text-align: center; }
.footer-col h4 { font-size: 1rem; }
.footer-col ul { list-style: none; padding: 0; }
.footer-col li { margin-bottom: 10px; }
.footer-col a { text-decoration: none; }
.footer-bottom { text-align: center; padding-top: 20px; border-top: 1px solid var(--border-color); font-size: 0.9rem; }

@media (min-width: 769px) {
    /* Apply these styles only on desktop */
    .footer-grid {
        grid-template-columns: 2fr 1fr;
        text-align: left;
    }
    .footer-about {
        align-items: flex-start;
        text-align: left;
    }
    .footer-col {
        text-align: left;
    }
}

@media (max-width: 768px) {
    .hero-section h1 { font-size: 2.5rem; }
    .shorten-form {
        flex-direction: column;
        background: none;
        padding: 0;
        gap: 20px;
    }
    .input-wrapper {
        background-color: var(--bg-color);
        padding: 8px;
        border-radius: 50px;
    }
    .result-box {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    #short-url-output {
        text-align: center;
        padding: 10px;
    }
    #copy-btn {
        width: 100%;
        padding: 12px;
    }
    .features-grid, .footer-grid { grid-template-columns: 1fr; text-align: center; }
    .ad-leaderboard { width: 320px; height: 100px; }
}