:root {
    --bg: #f4f4f4;
    --panel: #fff;
    --border: #000;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
    background: var(--bg);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Header --- */
header {
    background: var(--panel);
    border-bottom: 3px solid var(--border);
    padding: 15px 30px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    z-index: 100;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    height: auto;
    box-sizing: border-box;
}

.header-brand {
    justify-self: start;
    text-align: left;
    white-space: nowrap;
}

.header-brand .logo-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1.1;
}

.header-brand p {
    margin: 2px 0 0 0;
    font-size: 0.8rem;
    color: #666;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.main-nav a {
    text-decoration: none;
    color: #000;
    font-weight: bold;
    font-size: 1rem;
    padding: 8px 15px;
    border: 2px solid transparent;
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.main-nav a:hover,
.dropdown:hover .dropbtn {
    border-color: #000;
    background: #eee;
    transform: translateY(-2px);
}

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

.dropbtn {
    text-decoration: none;
    color: #000;
    font-weight: bold;
    font-size: 1rem;
    padding: 8px 15px;
    border: 2px solid transparent;
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--panel);
    min-width: 250px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.1);
    z-index: 200;
    border: 2px solid #000;
    border-radius: 8px;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 5px;
    overflow: hidden;
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    border: none;
    border-bottom: 1px solid #eee;
    border-radius: 0;
    white-space: normal;
    font-size: 0.95rem;
}

.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {
    background-color: #f8f8f8;
    transform: none;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* --- Main Scroll Area --- */
#main-scroll-area {
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* --- Page Intro --- */
.page-intro {
    text-align: center;
    padding: 20px 20px 10px;
    max-width: 800px;
    margin: 0 auto;
}

.page-intro h1 {
    margin: 0 0 10px 0;
    font-size: 1.5rem;
    color: #111;
}

.page-intro p {
    margin: 0;
    font-size: 0.95rem;
    color: #555;
    line-height: 1.5;
}

/* --- App Container --- */
#app-container {
    display: flex;
    height: auto;
    min-height: 680px;
    max-width: 1200px;
    margin: 20px auto;
    border: 3px solid var(--border);
    border-radius: 12px;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    background: #fff;
}

/* --- Sidebar --- */
.sidebar {
    width: 400px;
    background: var(--panel);
    padding: 15px;
    border-right: 3px solid var(--border);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-content: start;
    overflow-y: auto;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.sidebar h2 {
    grid-column: 1 / -1;
    margin: 0 0 5px 0;
    text-align: center;
    border-bottom: 3px solid #000;
    padding-bottom: 5px;
    font-size: 1.4rem;
}

.sidebar>.group:first-of-type {
    grid-column: 1 / -1;
}

.sidebar>.row {
    grid-column: 1 / -1;
}

.sidebar>button {
    grid-column: 1 / -1;
}

.sidebar>.btn-row {
    grid-column: 1 / -1;
}

.group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: #fafafa;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #eee;
}

.row {
    display: flex;
    gap: 10px;
    align-items: center;
}

label {
    font-weight: bold;
    font-size: 0.75rem;
    display: flex;
    justify-content: space-between;
    color: #333;
}

.val {
    font-weight: normal;
    font-size: 0.7rem;
    color: #666;
}

select,
input[type=range] {
    padding: 2px;
    border: 2px solid #000;
    border-radius: 4px;
    font-family: inherit;
    flex: 1;
    height: 28px;
}

input[type=color] {
    border: 2px solid #000;
    width: 35px;
    height: 28px;
    padding: 0;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
}

.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

button {
    flex: 1;
    background: #000;
    color: #fff;
    border: none;
    padding: 20px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: 0.1s;
}

button:hover {
    background: #444;
    transform: scale(1.02);
}

button.sec {
    background: #fff;
    color: #000;
    border: 3px solid #000;
}

#canvas-box {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: radial-gradient(#ccc 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: hidden;
}

#canvas {
    background: white;
    border: 4px solid #000;
    box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.2);
    transition: all 0.1s;
    max-width: 90%;
    max-height: 90%;
    width: auto;
    height: auto;
    aspect-ratio: 1/1;
    display: flex;
}

#canvas svg {
    width: 100%;
    height: 100%;
}

optgroup {
    font-weight: bold;
    color: #444;
}

/* --- Showcase --- */
.showcase-section {
    padding: 60px 20px;
    background: #fff8e1;
    border-bottom: 3px solid var(--border);
}

.showcase-inner {
    max-width: 1000px;
    margin: 0 auto;
}

.showcase-header {
    text-align: center;
    margin-bottom: 30px;
}

.showcase-header h2 {
    border-bottom: none;
    font-size: 2rem;
}

.showcase-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.show-card {
    background: #fff;
    border: 3px solid #000;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
}

.show-card:hover {
    transform: translateY(-5px);
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.2);
}

.show-img {
    height: 200px;
    border-bottom: 3px solid #000;
    background: radial-gradient(#eee 1px, transparent 1px);
    background-size: 10px 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.show-img svg {
    width: 100%;
    height: 100%;
    max-width: 180px;
}

.show-content {
    padding: 15px;
    text-align: center;
    background: #fff;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.show-name {
    font-weight: bold;
    font-size: 1.1rem;
    display: block;
    margin-bottom: 5px;
}

.show-desc {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.4;
}

/* --- Special Link --- */
.highlight-link {
    background: #ffea00;
    color: #111 !important;
    border: 2px solid #000 !important;
    box-shadow: 3px 3px 0px #000;
    transform: translateY(-2px);
    animation: pulse-wiggle 3s infinite;
}

.highlight-link:hover {
    background: #ffcc00 !important;
    box-shadow: 5px 5px 0px #000 !important;
    transform: translateY(-4px) !important;
    animation: none;
}

@keyframes pulse-wiggle {

    0%,
    10% {
        transform: translateY(-2px) rotate(0);
    }

    15% {
        transform: translateY(-2px) rotate(-6deg);
    }

    20% {
        transform: translateY(-2px) rotate(4deg);
    }

    25% {
        transform: translateY(-2px) rotate(-4deg);
    }

    30% {
        transform: translateY(-2px) rotate(2deg);
    }

    35%,
    100% {
        transform: translateY(-2px) rotate(0);
    }
}

/* --- Ad Units (placed only between content sections, never in tool canvas) --- */
.ad-unit-wrapper {
    background: #fafafa;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    padding: 12px 20px;
    text-align: center;
    min-height: 90px;
}

/* --- SEO & Footer --- */
.seo-section {
    background: var(--bg);
    padding: 60px 20px;
    display: flex;
    justify-content: center;
}

.seo-container {
    background: var(--panel);
    border: 3px solid var(--border);
    border-radius: 8px;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.1);
    max-width: 900px;
    width: 100%;
    padding: 30px;
    box-sizing: border-box;
}

.seo-container img,
.seo-container svg {
    max-width: 100%;
    height: auto;
}

.qa-item {
    margin-bottom: 20px;
    border-bottom: 1px dashed #ccc;
    padding-bottom: 20px;
}

.qa-item:last-child {
    border-bottom: none;
}

.qa-question {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.qa-question::before {
    content: "Q:";
    background: #000;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 10px;
    font-size: 0.9rem;
}

.qa-answer {
    color: #444;
    line-height: 1.6;
    padding-left: 35px;
}

.tag-cloud {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.tag {
    background: #eee;
    padding: 5px 10px;
    border: 1px solid #000;
    border-radius: 20px;
    font-size: 0.8rem;
    color: #333;
}

footer {
    background: #222;
    color: #fff;
    padding: 30px 20px;
    text-align: center;
    border-top: 4px solid #000;
}

.footer-content p {
    margin: 5px 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

@media (max-width: 900px) {
    header {
        display: flex;
        flex-direction: column;
        text-align: center;
        padding: 15px;
        gap: 15px;
        height: auto;
    }

    .header-brand {
        justify-self: center;
        text-align: center;
    }

    .seo-container {
        padding: 15px;
        border-width: 2px;
        box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.1);
    }

    .main-nav {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }

    #app-container {
        flex-direction: column;
        min-height: auto;
        height: auto;
        overflow: visible;
    }

    .sidebar {
        width: auto;
        border-right: none;
        border-bottom: 3px solid var(--border);
        display: flex;
        flex-direction: column;
    }

    #canvas-box {
        padding: 40px 0;
        min-height: 350px;
    }
}