* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #bcbcbc;
}
body.app-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}
header.app-header {
    height: 60px;
    background-color: #f1f3f4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    border-bottom: 1px solid #dadce0;
    gap: 20px;
    z-index: 100;
}

/* Logo styling */
.header-logo-link {
    display: flex;
    align-items: center;
    height: 100%;
    text-decoration: none;
}
.header-logo {
    height: 35px;
    width: auto;
    display: block;
}

@media (max-width: 768px) {
    .header-logo-link {
        display: flex;
        justify-content: center;
        width: 100%;
    }
}

.header-center {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    max-width: 1000px;
    margin: 0 20px;
}

.format-selector {
    padding: 10px 15px; border-radius: 6px; border: 1px solid #dadce0;
    background: #fff; font-size: 15px; color: #3c4043; cursor: pointer;
    outline: none; font-weight: 600; flex: 1; min-width: 150px; max-width: 200px;
}

.title-input {
    padding: 10px 15px; border-radius: 6px; border: 1px solid #dadce0;
    background: #fff; font-size: 15px; color: #3c4043; outline: none; flex: 1; min-width: 150px;
    transition: all 0.3s; max-width: 250px;
}
.title-input::placeholder { color: #888; }
.title-input.valid { background-color: #e6f4ea !important; border-color: #34a853; }
.title-input.error { background-color: #fce8e6 !important; border-color: #ea4335; }

.link-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #dae6ed;
    border: 1px solid #bcd1db;
    border-radius: 6px;
    padding: 0 5px 0 10px;
    flex: 1;
    min-width: 200px;
    max-width: 280px;
    height: 42px;
    transition: background-color 0.3s, border-color 0.3s;
    cursor: not-allowed;
}
.link-wrapper.has-title {
    cursor: pointer;
    background-color: #e6f4ea;
    border-color: #34a853;
}

.link-input {
    background: transparent; border: none; outline: none;
    font-size: 14px; color: #3c4043; width: 100%; 
    cursor: inherit;
    user-select: none;
    pointer-events: none;
    text-overflow: ellipsis;
}
.link-input::placeholder { color: #555555; }

.copy-btn {
    background: none; border: none; cursor: pointer; font-size: 16px; padding: 5px;
    opacity: 0.4; pointer-events: none; transition: opacity 0.2s;
}
.copy-btn.active { opacity: 1; pointer-events: auto; cursor: pointer; }

.link-wrapper .tooltip-box {
    visibility: hidden; background-color: #1a73e8; color: #fff; text-align: center; border-radius: 4px;
    padding: 5px 10px; position: absolute; z-index: 999; top: 115%; left: 50%; transform: translateX(-50%);
    white-space: nowrap; font-size: 12px; font-weight: 600; opacity: 0; transition: opacity 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2); pointer-events: none;
}
.link-wrapper .tooltip-box::after {
    content: ""; position: absolute; bottom: 100%; left: 50%; margin-left: -5px;
    border-width: 5px; border-style: solid; border-color: transparent transparent #1a73e8 transparent;
}
.link-wrapper.has-title:hover .tooltip-box { visibility: visible; opacity: 1; }
.link-wrapper.copied .tooltip-box { background-color: #34a853 !important; }
.link-wrapper.copied .tooltip-box::after { border-color: transparent transparent #34a853 transparent !important; }

.header-developer {
    font-size: 12px;
    color: #797979;
    white-space: nowrap;
    margin-left: auto;
    margin-right: auto;
}
.header-developer a { color: #797979; text-decoration: none; }
.header-developer a:hover { text-decoration: underline; }

.header-right {
    font-size: 12px; color: #797979; text-decoration: none;
    display: flex; align-items: center; gap: 10px; white-space: nowrap;
}

.main-container { display: flex; flex: 1; position: relative; overflow: hidden; }

.toolbar {
    width: 70px; background-color: #f1f3f4; border-right: 1px solid #dadce0;
    display: flex; flex-direction: column; align-items: center;
    padding: 15px 0; gap: 10px; z-index: 100;
}
.tool-btn {
    width: 44px; height: 44px; border-radius: 50%; border: none;
    background: #ffffff; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 18px; color: #3c4043; transition: all 0.2s;
    flex-shrink: 0;
}
.tool-btn:hover { background-color: #f8f9fa; }
.tool-btn.active { background-color: #000000; color: #ffffff; }

.tool-btn-pdf { background-color: #f72015 !important; color: #ffffff !important; }
.tool-btn-save { background-color: #377169 !important; color: #ffffff !important; }
.tool-btn-clear { background-color: #ff4444 !important; color: #ffffff !important; }

.separator { width: 30px; height: 1px; background-color: #dadce0; margin: 5px 0; }

.color-picker-wrapper {
    position: relative; width: 40px; height: 40px; border-radius: 50%;
    overflow: hidden; cursor: pointer; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    flex-shrink: 0;
}
.color-picker-wrapper input[type="color"] {
    position: absolute; right: -10px; bottom: -10px; width: 60px; height: 60px; border: none; cursor: pointer;
}

.workspace { flex: 1; display: flex; justify-content: center; align-items: center; position: relative; overflow: auto; background-color: #bcbcbc; padding: 20px; }

.canvas-container-wrapper { background-color: #ffffff; box-shadow: 0 4px 20px rgba(0,0,0,0.15); position: relative; width: 500px; height: 707px; flex-shrink: 0; max-width: 100%; max-height: 100%; aspect-ratio: 1 / 1.414; }
canvas { display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; touch-action: none; }

#toast-container { position: fixed; bottom: 30px; right: 30px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
    min-width: 250px; padding: 14px 20px; border-radius: 8px; color: #fff; font-size: 14px; font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 10px; pointer-events: auto;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
}
.toast.success { background-color: #34a853; }
.toast.error { background-color: #ea4335; }
@keyframes slideIn { from { transform: translateY(100px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-10px); } }

#inlineTextEditor { position: absolute; display: none; background: #ffffff; border: 2px solid #1a73e8; outline: none; font-family: sans-serif; text-align: center; z-index: 500; padding: 0; margin: 0; }

#downloadOverlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background-color: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px);
    z-index: 99999; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 20px; color: #ffffff;
    font-family: inherit; animation: fadeIn 0.2s ease;
}
.loader-box { background: #ffffff; padding: 30px 40px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); display: flex; flex-direction: column; align-items: center; gap: 15px; color: #202124; }
.spinner { width: 50px; height: 50px; border: 5px solid #f1f3f4; border-top: 5px solid #1a73e8; border-radius: 50%; animation: spin 1s linear infinite; }
.loader-text { font-size: 16px; font-weight: 600; color: #3c4043; letter-spacing: 0.3px; }

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sidebar-menu {
    position: fixed; top: 0; right: 0; width: 300px; height: 100vh;
    background: #ffffff; box-shadow: -4px 0 15px rgba(0,0,0,0.1);
    transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 2000; display: flex; flex-direction: column;
}
.sidebar-menu.open { transform: translateX(0); }
.sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); z-index: 1999; display: none; backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

.sidebar-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px; border-bottom: 1px solid #dadce0; background: #f8f9fa;
}
.sidebar-title { font-weight: 700; font-size: 18px; color: #202124; }
.sidebar-close {
    background: none; border: none; font-size: 28px; cursor: pointer; color: #5f6368;
    line-height: 1; transition: color 0.2s;
}
.sidebar-close:hover { color: #202124; }
.sidebar-nav { padding: 20px; list-style: none; display: flex; flex-direction: column; gap: 15px; }
.sidebar-nav a { text-decoration: none; color: #3c4043; font-weight: 500; font-size: 16px; transition: color 0.2s; display: block; }
.sidebar-nav a:hover { color: #1a73e8; }
.sidebar-nav a.active-page { color: #34a853 !important; font-weight: 700; }
.sidebar-nav .home-link { font-weight: 700; color: #1a73e8; border-bottom: 2px solid #f1f3f4; padding-bottom: 10px; margin-bottom: 10px; }
.sidebar-nav .home-link.active-page { color: #34a853 !important; }

.hamburger-btn {
    background: none; border: none; font-size: 26px; cursor: pointer;
    color: #3c4043; padding: 5px; border-radius: 4px; transition: background 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.hamburger-btn:hover { background: #e8eaed; }

body.seo-page {
    background-color: #fafafa;
    color: #202124;
    overflow-y: auto;
}
.seo-header {
    background: #ffffff; padding: 15px 30px; display: flex; justify-content: space-between;
    align-items: center; border-bottom: 1px solid #dadce0; position: sticky; top: 0; z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
.seo-header .logo { font-size: 24px; font-weight: 700; color: #202124; text-decoration: none; }
.seo-desktop-nav { display: flex; gap: 20px; align-items: center; }
.seo-desktop-nav a { text-decoration: none; color: #3c4043; font-weight: 500; transition: color 0.2s; }
.seo-desktop-nav a:hover { color: #1a73e8; }
.seo-desktop-nav .cta-btn {
    background: #1a73e8; color: #fff; padding: 8px 16px; border-radius: 6px; font-weight: 600;
}
.seo-desktop-nav .cta-btn:hover { background: #1557b0; color: #fff; }

.seo-main { max-width: 800px; margin: 60px auto; padding: 0 20px; line-height: 1.7; font-size: 18px; }
.seo-main h1 { font-size: 36px; margin-bottom: 20px; color: #34a853; line-height: 1.2; }
.seo-main h2 { font-size: 28px; margin-top: 40px; margin-bottom: 15px; }
.seo-main p { margin-bottom: 20px; color: #4a4a4a; }
.seo-main .hero-cta { display: inline-block; margin-top: 20px; background: #1a73e8; color: #fff; padding: 15px 30px; font-size: 18px; font-weight: 600; border-radius: 8px; text-decoration: none; transition: transform 0.2s; }
.seo-main .hero-cta:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3); }

.seo-hr {
    border: none;
    height: 2px;
    background: linear-gradient(to right, transparent, #dadce0, transparent);
    margin: 40px 0;
}

.seo-footer {
    background: #f1f3f4; padding: 40px 20px; text-align: center; border-top: 1px solid #dadce0; margin-top: 80px;
    color: #5f6368; font-size: 14px;
}
.seo-footer a { color: #1a73e8; text-decoration: none; }
.seo-footer a:hover { text-decoration: underline; }

.mobile-only { display: none; }
.mobile-save-text { display: none; font-size: 12px; font-weight: 600; color: #3c4043; }
.mobile-header-btn { display: none !important; }

@media (max-width: 768px) {
    header.app-header { height: auto; padding: 10px 15px; flex-direction: column; align-items: stretch; gap: 10px; }
    .header-logo { height: 30px; }
    .header-center { flex-direction: column; margin: 0; gap: 8px; max-width: none; }
    .format-selector, .title-input, .link-wrapper { width: 100%; min-width: 0; max-width: 100%; }
    .header-developer { display: none; }

    .header-right {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .mobile-save-text { display: inline-block; white-space: nowrap; }
    .mobile-header-btn { display: flex !important; width: 36px; height: 36px; font-size: 15px; }
    .desktop-only-btn { display: none !important; }
    
    .main-container { flex-direction: column-reverse; }
    .toolbar {
        width: 100%; height: auto; min-height: 70px; flex-direction: row; flex-wrap: wrap; overflow-x: visible;
        border-right: none; border-top: 1px solid #dadce0; padding: 10px; justify-content: center; gap: 8px;
    }
    .separator { display: none; }
    
    .workspace { padding: 10px; align-items: center; justify-content: center; overflow: hidden; }
    
    .canvas-container-wrapper {
        width: auto !important;
        height: 100% !important;
        max-width: 100%;
        max-height: 100%;
        aspect-ratio: 1 / 1.414;
        margin: auto;
    }

    .seo-desktop-nav { display: none; }
    .mobile-only { display: flex; }
    .seo-main h1 { font-size: 28px; }
}

@media screen and (max-width: 768px) {
    #bmc-wbtn, 
    iframe[src*="buymeacoffee.com"], 
    div[id*="bmc"], 
    img[src*="buymeacoffee"] {
        display: none !important;
    }
}