:root {
    --bg: #f8fafc;
    --panel: #fff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #7c3aed;
    --accent2: #8b5cf6;
    --danger: #ef4444;
    --code: #0b1220;
    --codeText: #e2e8f0;
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
}

.layout {
    display: flex;
    flex-direction: row;
}

.assets-page .pageGrid {
    padding: 0px;
}

.assets-page header {
    height: 60px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: end;
    padding: 10px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 1000
}

.brand img {
    width: 45px;
    /* height: 28px; */
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    /* border: 1px solid rgba(15, 23, 42, .08) */
}

.btn {
    border: 1px solid var(--border);
    background: #fff;
    padding: 9px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 900;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    white-space: nowrap
}

.btn:hover {
    background: #f1f5f9
}

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff
}

.btn.primary:hover {
    background: #6d28d9
}

.btn.danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff
}

.btn.danger:hover {
    background: #dc2626
}

.asset-sidebar {
    width: 350px;
    min-width: 350px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 0 0 auto
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border)
}

.tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 10px;
    font-weight: 1000;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent
}

.tab.active {
    color: var(--accent);
    background: #fafafa;
    border-bottom-color: var(--accent)
}

.panel {
    height: 100vh;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: none
}

.panel.active {
    display: block
}

.section {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 16px;
    padding: 14px;
    margin: 14px
}

.section h3 {
    margin: 0 0 10px 0;
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted)
}

.hint {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.35
}

.label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 900;
    color: var(--muted);
    margin: 10px 0 6px 0;
    letter-spacing: .04em;
    text-transform: uppercase
}

.label span {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--text);
    font-weight: 800;
    text-transform: none;
    letter-spacing: 0
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent2)
}

input[type="color"].big {
    width: 100%;
    height: 38px;
    border: none;
    padding: 0;
    border-radius: 12px;
    cursor: pointer
}

.grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 8px
}

.grid3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px
}

.toggle {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 12px;
    padding: 10px 8px;
    font-weight: 1000;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    user-select: none
}

.toggle.active {
    background: var(--accent2);
    border-color: var(--accent2);
    color: #fff
}

/* code editor with line numbers */
.codeWrap {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0
}

.codeArea {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 54px 1fr;
    background: var(--code);
    border-top: 1px solid rgba(255, 255, 255, .06)
}

.lines {
    padding: 12px 0;
    color: #94a3b8;
    font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    text-align: right;
    border-right: 1px solid rgba(255, 255, 255, .06);
    user-select: none;
    overflow: hidden
}

.lines div {
    padding: 0 12px
}

textarea.code {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    resize: none;
    padding: 12px;
    background: transparent;
    color: var(--codeText);
    font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    overflow: auto
}

.footer {
    border-top: 1px solid var(--border);
    background: #f1f5f9;
    padding: 12px;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap
}

.footer .left {
    margin-right: auto;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap
}

.pill {
    font-size: 11px;
    font-weight: 1000;
    color: #4c1d95;
    background: #f3e8ff;
    border: 1px solid rgba(124, 40, 217, .25);
    padding: 6px 10px;
    border-radius: 999px
}

/* preview */
.preview {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    overflow: hidden
}

.previewFrame {
    width: 720px;
    max-width: 100%;
    height: 720px;
    max-height: 100%;
    border-radius: 18px;
    background: rgba(255, 255, 255, .65);
    border: 1px solid rgba(15, 23, 42, .08);
    box-shadow: 0 18px 60px rgba(2, 6, 23, .08);
    overflow: auto;
    display: grid;
    place-items: center;
    padding: 18px
}

.previewFrame svg {
    max-width: 640px;
    width: 100%;
    height: auto;
    display: block;
    overflow: visible
}

/* palettes */
.palList {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.palCard {
    border: 1px solid rgba(15, 23, 42, .10);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    cursor: pointer
}

.palCard.active {
    outline: 2px solid rgba(124, 40, 217, .22);
    background: #faf5ff
}

.palRow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    gap: 10px
}

.palTitle {
    font-size: 11px;
    font-weight: 1000;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted)
}

.palHex {
    font: 11px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--text);
    font-weight: 900
}

.palMini {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    height: 12px;
    border-top: 1px solid rgba(15, 23, 42, .06)
}

.palMini>div {
    height: 12px
}

.palPickRow {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(15, 23, 42, .06);
    background: #fff;
    overflow-x: auto;
}

.palPickRow::-webkit-scrollbar {
    height: 10px;
}

.palPickRow::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
}

.palPick {
    border: 1px solid rgba(15, 23, 42, .10);
    border-radius: 12px;
    padding: 8px
}

.palPick label {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 1000;
    color: var(--muted);
    letter-spacing: .06em;
    text-transform: uppercase;
    margin-bottom: 6px
}

.palPick input {
    width: 100%;
    height: 32px;
    border: none;
    padding: 0;
    border-radius: 10px;
    cursor: pointer
}

.miniActions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 10px
}

.miniActions .hint {
    margin-left: auto
}

/* layers */
.layers {
    padding: 14px
}

.layerToolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 10px
}

.layerSearch {
    flex: 1;
    min-width: 180px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 900;
    outline: none
}

.layerGroup {
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    margin-bottom: 12px
}

.layerHead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid rgba(15, 23, 42, .06)
}

.swatch {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, .08)
}

.layerTitle {
    font-size: 12px;
    font-weight: 1000;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted)
}

.layerItems {
    padding: 8px
}

.layerItem {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 12px;
    cursor: pointer
}

.layerItem:hover {
    background: #f1f5f9
}

.layerItem.active {
    background: #ede9fe;
    outline: 2px solid rgba(124, 40, 217, .18)
}

.liLeft {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0
}

.liTag {
    font-size: 11px;
    font-weight: 1000;
    color: var(--text);
    letter-spacing: .04em;
    text-transform: uppercase
}

.liId {
    font: 11px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 210px
}

.iconbtn {
    border: 1px solid rgba(15, 23, 42, .10);
    background: #fff;
    border-radius: 10px;
    padding: 7px 9px;
    font-weight: 1000;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    color: var(--text)
}

.iconbtn:hover {
    background: #f1f5f9
}

.iconbtn.del {
    color: var(--danger);
    border-color: rgba(239, 68, 68, .25)
}

.iconbtn.del:hover {
    background: #fee2e2
}

/* export drawer */
.asset-drawer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 280px;
    background: #0b1220;
    color: #e2e8f0;
    transform: translateY(100%);
    transition: transform .25s ease;
    z-index: 30;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -18px 50px rgba(0, 0, 0, .18)
}

.asset-drawer.open {
    transform: translateY(0)
}

.drawerHead {
    background: #050a14;
    border-top: 1px solid rgba(255, 255, 255, .06);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px
}

.drawerTabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap
}

.dt {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-weight: 1000;
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 2px solid transparent
}

.dt.active {
    color: #fff;
    border-bottom-color: var(--accent2)
}

pre.out {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 14px;
    overflow: auto;
    white-space: pre;
    font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace
}

.toast {
    position: fixed;
    top: 72px;
    right: 16px;
    background: #0f172a;
    color: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 900;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .18s ease, transform .18s ease;
    z-index: 50;
    max-width: min(360px, 92vw)
}

.toast.show {
    opacity: 1;
    transform: translateY(0)
}

.toast small {
    display: block;
    opacity: .7;
    font-weight: 800;
    margin-top: 4px
}

@media (max-width: 980px) {
    .layout {
        flex-direction: column
    }

    .asset-sidebar {
        width: 100%;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
        height: 56%
    }

    .preview {
        height: 44%
    }

    .previewFrame {
        height: 100%;
        width: 100%;
        border-radius: 0;
        box-shadow: none
    }
}

@media (max-width: 420px) {
    .palList {
        grid-template-columns: 1fr
    }

    .liId {
        max-width: 150px
    }
}


.preset-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 0.5px solid var(--border);
    background: var(--surface-1);
}

.preset-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.preset-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preset-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.preset-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.preset-del {
    padding: 0 8px;
    color: var(--text-muted);
}

.preset-del:hover {
    color: #e24b4a;
    border-color: #e24b4a;
}