* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --background: #f3f5f7;
    --card: #ffffff;
    --text: #222;
    --border: #d8d8d8;
    --primary: #1976d2;
    --primaryHover: #1565c0;
    --muted: #667085;
    --selected: #e8f2ff;
}

body.dark {
    --background: #1e1f22;
    --card: #2b2d31;
    --text: #f5f5f5;
    --border: #555;
    --primary: #4d9fff;
    --primaryHover: #76b5ff;
    --muted: #b7bec8;
    --selected: #183652;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: var(--background);
    color: var(--text);
    transition: .25s;
}

.container {
    max-width: 1680px;
    margin: auto;
    padding: 22px 36px;
}

header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    gap: 18px;
    padding: 16px 0;
    background: var(--background);
}

header h1 {
    font-size: 32px;
}

main {
    display: grid;
    grid-template-columns: minmax(120px, 170px) 380px minmax(430px, 1fr) minmax(120px, 170px);
    gap: 16px;
    align-items: start;
}

.leftPanel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.adPanel {
    position: sticky;
    top: 104px;
}

.adSlot {
    min-height: 600px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    text-transform: uppercase;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
}

.card h2 {
    margin-bottom: 15px;
    font-size: 20px;
}

select,
input,
textarea {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: 15px;
    margin-bottom: 12px;
}

textarea {
    resize: vertical;
    min-height: 120px;
}

button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: var(--primary);
    color: white;
    font-size: 16px;
    transition: .2s;
    margin-bottom: 10px;
}

button:hover {
    background: var(--primaryHover);
}

#themeButton {
    width: auto;
    padding: 12px 22px;
    margin-bottom: 0;
    white-space: nowrap;
}

.optionGrid {
    display: grid;
    gap: 10px;
}

.typeGrid {
    grid-template-columns: repeat(4, 1fr);
}

.frameGrid {
    grid-template-columns: repeat(2, 1fr);
    margin-bottom: 14px;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
}

.sizeOptions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.sizeButton {
    min-height: 44px;
    margin: 0;
    padding: 10px 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: 14px;
}

.sizeButton:hover,
.sizeButton.active {
    border-color: var(--primary);
    background: var(--selected);
    color: var(--text);
}

.optionButton {
    min-height: 76px;
    margin: 0;
    padding: 10px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 13px;
}

.optionButton:hover,
.optionButton.active {
    border-color: var(--primary);
    background: var(--selected);
    color: var(--text);
}

.optionIcon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 16px;
    line-height: 1;
}

.optionButton.danger:hover,
.optionButton.danger.active {
    border-color: #d92d20;
    background: #fff1f0;
}

.optionButton.danger .optionIcon {
    background: #d92d20;
}

body.dark .optionButton.danger:hover,
body.dark .optionButton.danger.active {
    background: #3a1614;
}

.optionThumb {
    width: 54px;
    height: 64px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--border);
    overflow: hidden;
}

.optionThumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.frameContent {
    padding-top: 2px;
}

.toggleRow {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 14px;
}

.toggleRow input {
    width: auto;
    margin: 0;
}

.colorControl {
    display: grid;
    grid-template-columns: 52px 34px 1fr;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.colorControl input[type="color"] {
    width: 52px;
    height: 42px;
    padding: 4px;
    margin: 0;
}

.colorSwatch {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .5);
}

.colorValue {
    color: var(--muted);
    font-family: Consolas, monospace;
    font-size: 14px;
}

.rightPanel {
    position: sticky;
    top: 104px;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    overflow: visible;
}

#previewFrame {
    position: relative;
    overflow: hidden;
    width: 430px;
    height: 510px;
    min-height: 510px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .08);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 30px;
    color: #111;
}

#previewFrame > * {
    position: relative;
    z-index: 1;
}

#previewFrame.frame-scanme,
#previewFrame.frame-visit,
#previewFrame.frame-read,
#previewFrame.frame-note,
#previewFrame.frame-email,
#previewFrame.frame-contact,
#previewFrame.frame-wifi,
#previewFrame.frame-wifiCompact,
#previewFrame.frame-appBadge,
#previewFrame.frame-folderFrame,
#previewFrame.frame-custom {
    border: 6px solid #222;
}

#previewFrame.frame-svgAsset,
#previewFrame.frame-folderFrame {
    border-color: transparent;
    background: white;
}

#previewFrame .folderFrameImage {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#previewFrame .folderFrameImage svg,
#previewFrame .folderFrameImage img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

#previewFrame.frame-appBadge {
    border-color: #1b5bd8;
    background: #f6fbff;
    border-radius: 24px;
}

#previewFrame.frame-appBadge::before {
    content: "";
    position: absolute;
    inset: 24px;
    border: 3px solid #79b7ff;
    border-radius: 20px;
}

#frameTop {
    font-size: 34px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 30px;
}

#frameBottom {
    margin-top: 30px;
    text-align: center;
    font-size: 22px;
    white-space: pre-line;
}

#qrContainer {
    width: 205px;
    height: 205px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
}

#qrContainer img,
#qrContainer canvas,
#qrContainer svg {
    max-width: 100%;
    max-height: 100%;
}

#qrContainer.barcodeContainer {
    width: calc(100% + 48px);
    height: 260px;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    padding: 0;
}

#qrContainer .pdf417Canvas {
    width: 100%;
    height: auto;
    display: block;
    image-rendering: auto;
}

.frameTitle {
    font-size: 36px;
    font-weight: 800;
    text-align: center;
}

.wifiInfo {
    margin-top: 25px;
    text-align: center;
    font-size: 20px;
    line-height: 1.8;
}

.customText {
    white-space: pre-line;
    text-align: center;
    font-size: 22px;
}

.siteFooter {
    margin-top: 44px;
    padding: 26px 0 10px;
    border-top: 1px solid var(--border);
    color: var(--muted);
}

.footerIntro {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: baseline;
    margin-bottom: 18px;
}

.footerIntro strong {
    color: var(--text);
    font-size: 18px;
}

.footerLinks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-bottom: 22px;
}

.footerLinks a {
    color: var(--primary);
    font-size: 14px;
    text-decoration: none;
}

.footerLinks a:hover {
    color: var(--primaryHover);
    text-decoration: underline;
}

.footerGrid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}

.footerSection {
    min-width: 0;
}

.footerSection h2 {
    margin-bottom: 8px;
    color: var(--text);
    font-size: 15px;
}

.footerSection p {
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.45;
}

.footerMeta {
    margin-top: 20px;
    font-size: 12px;
}

@media(max-width: 1000px) {
    main {
        grid-template-columns: 1fr;
    }

    .adPanel {
        display: none;
    }

    .rightPanel {
        position: static;
        max-height: none;
        overflow: visible;
    }

    #previewFrame {
        width: 100%;
    }

    body.dark #previewFrame {
        background: white;
        color: black;
    }

    .footerGrid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media(max-width: 520px) {
    .typeGrid,
    .frameGrid {
        grid-template-columns: repeat(2, 1fr);
    }

    header {
        align-items: flex-start;
        flex-direction: column;
    }

    #previewFrame {
        min-height: auto;
        padding: 18px;
    }

    #qrContainer {
        width: 205px;
        max-width: 100%;
        height: 205px;
        aspect-ratio: 1;
    }

    .footerGrid {
        grid-template-columns: 1fr;
    }
}
