:root {
    color-scheme: dark;
    --bg: #0f1115;
    --panel: #161921;
    --panel-soft: rgba(20, 24, 32, 0.72);
    --surface: rgba(255, 255, 255, 0.04);
    --accent: #4cc38a;
    --accent-soft: rgba(76, 195, 138, 0.18);
    --text: #f5f7fa;
    --muted: #8891a7;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --shadow: rgba(0, 0, 0, 0.45);
    font-size: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at top, rgba(76, 195, 138, 0.08), transparent 60%), var(--bg);
    color: var(--text);
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    display: flex;
    flex-direction: column;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2.75rem;
}

.app-header {
    padding: 1.35rem 2rem;
    background: rgba(15, 17, 23, 0.9);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.brand h1 {
    margin: 0;
    font-size: clamp(1.75rem, 2.8vw, 2.7rem);
    letter-spacing: 0.01em;
}

.brand p {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.app-shell {
    flex: 1;
    width: 100%;
    max-width: 1380px;
    margin: 0 auto;
    padding: 1.75rem 2rem 2.5rem;
    display: grid;
    grid-template-columns: minmax(340px, 420px) minmax(0, 1fr) minmax(240px, 320px);
    gap: 1.75rem;
    align-items: start;
}

.seo-section {
    padding: 0 2rem 3rem;
}

.seo-container {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.seo-pretitle {
    margin: 0;
    font-size: 0.9rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.seo-container h2 {
    margin: 0;
    font-size: clamp(1.6rem, 2.4vw, 2.1rem);
    letter-spacing: 0.01em;
}

.seo-intro {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--muted);
}

.seo-feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.1rem;
}

.seo-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    padding: 1.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 28px 60px -48px var(--shadow);
}

.seo-card h3 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--text);
}

.seo-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.seo-steps,
.seo-faq {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 18px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.seo-steps h3,
.seo-faq h3 {
    margin: 0;
    font-size: 1.1rem;
}

.seo-steps ol {
    margin: 0;
    padding-left: 1.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    color: var(--muted);
    line-height: 1.6;
    list-style-position: outside;
}

.seo-steps li::marker {
    color: var(--accent);
    font-weight: 600;
}

.seo-faq dl {
    margin: 0;
    display: grid;
    gap: 1rem;
}

.seo-faq dl > div {
    padding: 1rem 1.15rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.seo-faq dt {
    font-weight: 600;
    color: var(--text);
}

.seo-faq dd {
    margin: 0.4rem 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.control-sidebar {
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.35rem;
    box-shadow: 0 32px 65px -48px var(--shadow);
    position: sticky;
    top: 112px;
    align-self: start;
    display: flex;
    flex-direction: column;
}

.control-scroll {
    overflow-y: auto;
    max-height: calc(100vh - 160px);
    padding-right: 0.35rem;
    margin-right: -0.35rem;
}

.control-stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.control-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 18px;
    padding: 1.25rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.section-title {
    margin: 0;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
}

.section-subtitle {
    margin: 0.4rem 0 0;
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.4;
}

.section-actions {
    display: flex;
    gap: 0.4rem;
}

.field,
.palette-favorites {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.field-label {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.1rem 1rem;
}

.control-toggle-stack {
    grid-column: 1 / -1;
    display: grid;
    gap: 0.75rem;
}

.control-toggle-stack .field-label {
    margin: 0;
}

.field--slider {
    padding: 0.75rem 0.85rem;
    background: rgba(15, 17, 23, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    gap: 0.65rem;
}

.field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.field--slider .field-label {
    margin: 0;
}

.chip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.6rem;
}

.chip-toggle {
    position: relative;
    display: inline-flex;
}

.chip-toggle input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.chip-toggle span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border-radius: 999px;
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
    border: 1px solid var(--border);
    background: rgba(22, 25, 33, 0.72);
    transition: border 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.chip-toggle:hover span {
    border-color: rgba(76, 195, 138, 0.6);
}

.chip-toggle input:checked + span {
    color: var(--accent);
    background: rgba(76, 195, 138, 0.16);
    border-color: rgba(76, 195, 138, 0.6);
    box-shadow: 0 12px 26px -18px rgba(76, 195, 138, 0.8);
}

[data-element-toggle].is-hidden {
    display: none;
}

.palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    gap: 0.9rem;
}

.palette-favorites + .palette-grid {
    margin-top: 1.1rem;
}

.palette-grid .palette-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
}

.palette-grid input[type="color"] {
    width: 100%;
    height: 52px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0;
    background: transparent;
    cursor: pointer;
    transition: border 0.2s ease, transform 0.2s ease;
}

.palette-grid input[type="color"]:hover {
    border-color: rgba(76, 195, 138, 0.6);
    transform: translateY(-1px);
}

.palette-grid .color-caption {
    font-size: 0.78rem;
    color: var(--muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.favorites-controls {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.55rem;
}

.favorites-controls button {
    min-width: 44px;
}

select,
button,
input[type="color"],
input[type="range"],
input[type="number"] {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.65rem 0.75rem;
    font: inherit;
    transition: border 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

button {
    cursor: pointer;
    width: auto;
}

button:hover,
select:hover,
input[type="color"]:hover {
    border-color: rgba(76, 195, 138, 0.6);
}

button:active {
    transform: translateY(1px);
}

button.primary {
    background: var(--accent);
    color: #0b1110;
    border: none;
}

button.ghost {
    background: var(--accent-soft);
    border: none;
    color: var(--accent);
}

.slider-value {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--accent);
    font-size: 0.82rem;
}

.slider-value-input {
    width: 4.5rem;
    padding: 0.35rem 0.55rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(76, 195, 138, 0.14);
    color: var(--text);
    font: inherit;
    text-align: right;
    transition: border 0.2s ease, background 0.2s ease;
}

.slider-value-input:focus {
    outline: none;
    border-color: rgba(76, 195, 138, 0.6);
    background: rgba(76, 195, 138, 0.25);
}

.slider-value-input::-webkit-outer-spin-button,
.slider-value-input::-webkit-inner-spin-button {
    appearance: none;
    margin: 0;
}

.slider-value-input {
    -moz-appearance: textfield;
}

.slider-value-suffix {
    color: var(--muted);
}

.slider-value-suffix:empty {
    display: none;
}

input[type="number"] {
    min-width: 0;
}

input[type="range"] {
    appearance: none;
    height: 6px;
    border-radius: 999px;
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    box-shadow: 0 0 0 3px rgba(76, 195, 138, 0.24);
    transition: transform 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.08);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
}

.field--toggle {
    position: relative;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(15, 17, 23, 0.32);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.95rem;
}

.field--toggle--disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.field--toggle input[type="checkbox"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.toggle {
    width: 50px;
    height: 26px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    position: relative;
    transition: background 0.2s ease;
}

.toggle::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.2s ease, background 0.2s ease;
}

.field--toggle input[type="checkbox"]:checked + .toggle {
    background: rgba(76, 195, 138, 0.32);
}

.field--toggle input[type="checkbox"]:checked + .toggle::after {
    transform: translateX(24px);
    background: var(--accent);
}

.workspace {
    background: rgba(16, 18, 24, 0.65);
    border: 1px solid var(--border);
    border-radius: 26px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
    box-shadow: inset 0 0 38px rgba(0, 0, 0, 0.35), 0 30px 70px -50px var(--shadow);
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.ad-sidebar {
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.4rem 1.25rem;
    display: none;
    flex-direction: column;
    gap: 1.25rem;
    position: sticky;
    top: 112px;
    align-self: start;
    box-shadow: 0 32px 65px -48px var(--shadow);
}

.ad-sidebar[data-ad-status="ready"] {
    display: flex;
}

.ad-sidebar__header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.ad-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: rgba(76, 195, 138, 0.18);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ad-sidebar__title {
    margin: 0;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.ad-stack {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.ad-card {
    background: rgba(15, 17, 23, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 18px;
    padding: 1.1rem 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.ad-card__title {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text);
}

.ad-card__subtitle {
    margin: 0;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.ad-mock {
    border-radius: 14px;
    border: 1px dashed rgba(255, 255, 255, 0.22);
    background: repeating-linear-gradient(135deg, rgba(76, 195, 138, 0.08), rgba(76, 195, 138, 0.08) 12px, transparent 12px, transparent 24px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.82rem;
    text-align: center;
    padding: 0.75rem;
}

.ad-mock--leaderboard {
    min-height: 110px;
}

.ad-mock--skyscraper {
    min-height: 420px;
}

.ad-sidebar__disclaimer {
    margin: 0;
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.5;
}

.workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.workspace-intro {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 240px;
}

.workspace-title {
    margin: 0;
    font-size: 1.25rem;
}

.workspace-subtitle {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}


.workspace-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.workspace-action-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    width: 100%;
}

.workspace-row-primary {
    justify-content: flex-start;
}

.workspace-row-export {
    justify-content: flex-start;
}

.workspace-actions button,
.workspace-actions select {
    padding-block: 0.35rem;
    min-height: 2.65rem;
}

.workspace-actions button {
    white-space: nowrap;
}

.workspace-resolution {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.4rem 0.75rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 17, 23, 0.35);
    flex: 1 1 240px;
    min-width: 0;
}

.workspace-resolution .field-label {
    margin: 0;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.workspace-resolution select {
    min-width: 0;
    flex: 1 1 auto;
}

.workspace-export-buttons {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex: 1 1 240px;
    margin-left: auto;
}

.workspace-regenerate {
    padding-inline: 1.35rem;
    box-shadow: 0 18px 40px -22px rgba(76, 195, 138, 0.85);
    font-weight: 600;
}

.preview-surface {
    position: relative;
    border-radius: 22px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.05);
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    width: 100%;
    max-width: 900px;
    margin-inline: auto;
}

.preview-surface--tiled {
    background-repeat: repeat;
}

.preview-surface--tiled canvas {
    opacity: 0;
    pointer-events: none;
}

canvas {
    width: min(100%, 900px);
    height: auto;
    display: block;
    aspect-ratio: 1 / 1;
}

.app-footer {
    padding: 1.25rem 2rem 2.25rem;
    display: flex;
    justify-content: center;
    border-top: 1px solid var(--border);
    background: rgba(15, 17, 23, 0.78);
}

.footer-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
    letter-spacing: 0.04em;
}

@media (max-width: 1200px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .control-sidebar {
        position: static;
    }

    .control-scroll {
        max-height: none;
        overflow: visible;
        padding-right: 0;
        margin-right: 0;
    }

    .workspace {
        min-height: 360px;
    }

    .ad-sidebar {
        position: static;
        width: 100%;
    }

    .seo-section {
        padding-inline: 1.5rem;
    }
}

@media (max-width: 960px) {
    :root {
        font-size: 15px;
    }

    .app-shell {
        padding: 1.5rem;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .workspace-row-primary,
    .workspace-row-export {
        flex-direction: column;
        align-items: stretch;
    }

    .workspace-preview-toggle {
        width: 100%;
        justify-content: space-between;
    }

    .workspace-resolution {
        width: 100%;
    }

    .workspace-export-buttons {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.65rem;
        margin-left: 0;
    }

    .workspace-export-buttons button {
        flex: 1 1 160px;
    }

    .workspace-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .workspace-regenerate {
        width: 100%;
    }

    .seo-container {
        gap: 1.5rem;
    }

    .seo-feature-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .app-header {
        padding: 1.1rem 1.35rem;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .app-shell {
        padding: 1.1rem 1.25rem 1.75rem;
        gap: 1.25rem;
    }

    .control-sidebar {
        padding: 1.1rem;
    }

    .workspace {
        padding: 1.25rem;
    }

    .workspace-resolution {
        padding: 0.6rem 0.75rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .seo-section {
        padding-inline: 1.25rem;
    }

}
