:root {
    --bg: #0f1115;
    --panel: #151922;
    --panel2: #1b2130;
    --text: #e6ebf2;
    --muted: #a7b0be;
    --accent: #ef4444;
    --accent-2: #dc2626;
    --border: #263041;
    --fs-12: 12px;
    --fs-14: 14px;
    --fs-16: 16px;
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%
}

html {
    -webkit-text-size-adjust: 100%
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent
}

.wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right))
}

header.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap
}

header .right {
    display: flex;
    align-items: center;
    gap: 12px
}

.lang {
    display: flex;
    gap: 6px
}

.lang button {
    border: 1px solid var(--border);
    background: #0d121a;
    color: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    min-height: 40px
}

.lang button.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, .25) inset
}

.gh {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 10px
}

.gh img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    opacity: .85
}

.gh a {
    color: #fff;
    text-decoration: none;
    font-weight: 600
}

.gh small {
    color: var(--muted);
    display: block;
    margin-top: -2px;
    font-size: 11px
}

.hint {
    color: var(--muted);
    font-size: var(--fs-12);
    margin: 2px 0 0
}

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    margin-top: 14px
}

@media (max-width:900px) {
    .grid {
        grid-template-columns: 1fr
    }
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px
}

.row2 {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 1fr
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px
}

label {
    font-size: var(--fs-12);
    color: var(--muted)
}

input[type="text"],
input[type="number"],
select,
input[type="file"] {
    background: #0d1017;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    padding: 10px;
    min-height: 44px;
    font-size: var(--fs-16)
}

input[type="color"] {
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #0d1017
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px
}

.btn {
    background: var(--accent);
    color: #fff;
    border: 0;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    min-height: 44px
}

.btn:hover {
    background: var(--accent-2)
}

.btn.ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text)
}

.btn:disabled {
    opacity: .6;
    cursor: not-allowed
}

.preview {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel2)
}

.qr-mount {
    width: min(100%, 720px);
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d1017;
    border: 1px dashed var(--border);
    border-radius: 12px;
    overflow: hidden;
    max-width: 450px
}

/* --- Builder grid --- */
.builder {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 10px;
    margin: 10px 0 6px
}

@media(max-width:1000px) {
    .builder {
        grid-template-columns: repeat(4, 1fr)
    }
}

@media(max-width:800px) {
    .builder {
        grid-template-columns: repeat(3, 1fr)
    }
}

@media(max-width:600px) {
    .builder {
        grid-template-columns: repeat(2, 1fr)
    }
}

@media(max-width:380px) {
    .builder {
        grid-template-columns: 1fr
    }
}

.bcard {
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    transition: transform .12s ease, border-color .12s ease
}

.bcard:hover {
    transform: translateY(-2px);
    border-color: #334155
}

.bcard.active {
    outline: 2px solid rgba(239, 68, 68, .35)
}

.btitle {
    font-weight: 800
}

.bdesc {
    color: var(--muted);
    font-size: 12px
}

/* Toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(20px);
    background: #1f2937;
    color: #e6ebf2;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
    z-index: 9999;
    font-size: 14px
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
}

@media(max-width:600px) {
    .wrap {
        padding: 16px
    }

    header.top {
        align-items: flex-start;
        gap: 10px
    }

    header .right {
        width: 100%;
        justify-content: space-between;
        gap: 10px
    }

    .gh small {
        display: none
    }

    .lang button {
        padding: 8px 12px
    }

    .panel {
        padding: 14px
    }

    .row2 {
        grid-template-columns: 1fr
    }

    .btn,
    .btn.ghost {
        flex: 1 1 auto
    }

    label {
        font-size: var(--fs-14)
    }

    input[type="text"],
    input[type="number"],
    select,
    input[type="file"] {
        padding: 12px
    }

    .qr-mount {
        width: 100%;
        max-width: min(100%, 450px);
        border-radius: 10px
    }
}

@media(max-width:380px) {
    .wrap {
        padding: 12px
    }

    header .right {
        flex-direction: column;
        align-items: stretch
    }

    .gh {
        width: 100%;
        justify-content: space-between
    }

    .lang {
        width: 100%;
        justify-content: space-between
    }

    .lang button {
        flex: 1 1 50%
    }
}

@media (prefers-reduced-motion:reduce) {
    .toast {
        transition: none
    }
}