        :root {
            --bg: #0f1115;
            --panel: #171a21;
            --text: #f3f4f6;
            --muted: #9aa4b2;
            --accent: #6ee7ff;
            --border: #2a2f3a;
        }

        * {
            box-sizing: border-box;
        }

        html,
        body {
            height: 100%;
        }

        body {
            margin: 0;
            font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
            background: var(--bg);
            color: var(--text);
        }

        .prefs-checker {
            position: fixed;
            top: 0;
            left: 0;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: 0;
            overflow: hidden;
            white-space: nowrap;
            border: 0;
            opacity: 0.01;
            pointer-events: none;
            z-index: -1;
        }

        header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 16px;
            border-bottom: 1px solid var(--border);
            background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, 0));
            background: rgba(23, 26, 33, 0.75);
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
            position: sticky;
            top: 0;
            z-index: 1100;
        }

        header h1 {
            margin: 0;
            font-size: 16px;
            font-weight: 600;
            letter-spacing: .2px;
            display: flex;
            align-items: baseline;
            gap: 8px;
        }

        header .file-tag {
            font-size: 12px;
            color: var(--muted);
            font-weight: 500;
        }

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

        button,
        select,
        label.btn {
            background: #1f2430;
            color: var(--text);
            border: 1px solid var(--border);
            padding: 8px 10px;
            border-radius: 10px;
            font-size: 13px;
            cursor: pointer;
        }

        button:hover,
        label.btn:hover {
            background: #232a37;
        }

        button.secondary {
            background: #171a21;
        }

        button.danger {
            background: #3a1f1f;
            border-color: #523030;
        }

        input[type="file"] {
            display: none;
        }

        main {
            display: grid;
            grid-template-columns: 316px 1fr;
            gap: 16px;
            padding: 16px;
            padding: 16px 16px 48px;
        }

        .left {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 14px;
            padding: 12px;
            display: flex;
            flex-direction: column;
            height: fit-content;
            gap: 12px;
        }

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

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

        .canvas-wrap {
            position: relative;
            display: inline-block;
            border: 1px solid var(--border);
            border-radius: 12px;
            overflow: auto;
            max-width: 100%;
        }

        canvas#glyph {
            display: block;
            background: repeating-conic-gradient(#111 0 25%, #0f0f12 0 50%) 50% / 16px 16px;
            image-rendering: pixelated;
        }

        .palette {
            display: flex;
            gap: 8px;
        }

        .swatch {
            width: 28px;
            height: 28px;
            border-radius: 8px;
            border: 1px solid var(--border);
            cursor: pointer;
            position: relative;
        }

        .swatch[data-v="0"] {
            background: #000;
        }

        .swatch[data-v="1"] {
            background: repeating-conic-gradient(#333 0 25%, #444 0 50%) 50% / 8px 8px;
        }

        .swatch[data-v="2"] {
            background: #fff;
        }

        .swatch.active {
            outline: 2px solid var(--accent);
        }

        .right {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 14px;
            padding: 12px;
            display: flex;
            flex-direction: column;
            min-height: 400px;
        }

        .grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
            gap: 2px;
        }

        .cell {
            background: #12151c;
            /* border: 1px solid var(--border); */
            border-radius: 3px;
            padding: 1px;
            text-align: center;
            cursor: pointer;
            position: relative;
        }

        .cell canvas {
            image-rendering: pixelated;
            width: 100%;
            height: auto;
            display: block;
            background: repeating-conic-gradient(#515151 0 25%, #2a2a2a 0 50%) 50% / 6px 6px;
            border-radius: 2px;
        }

        .cell .idx {
            position: absolute;
            top: 4px;
            left: 6px;
            font-size: 10px;
            color: #ffffff;
            opacity: .9;
            text-shadow: #000 1px 1px 1px;
        }

        .cell.active {
            outline: 2px solid var(--accent);
        }

        .cell.selected {
            outline: 2px dashed var(--accent);
        }

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

        .toolbar button {
            flex: 1;
            text-align: center;
        }

        .grow {
            flex: 1;
        }

        .mono {
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
        }

        footer {
            padding: 4px 16px;
            border-top: 1px solid var(--border);
            font-size: 10px;
            color: var(--muted);
            display: flex;
            justify-content: center;
            gap: 12px;
            flex-wrap: wrap;
            position: fixed;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(23, 26, 33, 0.75);
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
            z-index: 1000;
        }

        a {
            color: #9ae6ff;
            text-decoration: none;
        }

        /* lightweight modal for example picker */
        .modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, .45);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 2000;
        }

        .modal {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 16px;
            width: 240px;
            max-width: calc(100vw - 32px);
            box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
        }

        .modal h3 {
            margin: 0 0 12px;
            font-size: 14px;
        }

        .example-list {
            display: grid;
            grid-template-columns: 1fr;
            gap: 8px;
            max-height: 75vh;
            overflow: auto;
        }

        .example-list button {
            text-align: center;
        }

        .modal-overlay[hidden] {
            display: none !important;
        }

        .logo-panel {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 12px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            align-items: flex-start;
            gap: 16px;
        }

        #logoPreview {
            background: repeating-conic-gradient(#515151 0 25%, #2a2a2a 0 50%) 50% / 6px 6px;
            border: 1px solid var(--border);
            border-radius: 2px;
            display: block;
        }

        .logo-buttons {
            display: flex;
            flex-direction: row;
            align-items: flex-end;
            gap: 8px;
            flex-shrink: 0;
        }

        .multi-panel {
            margin-top: 12px;
            padding: 10px;
            border: 1px solid var(--border);
            border-radius: 12px;
            background: rgba(12, 14, 18, 0.6);
            display: none;
            flex-direction: column;
            gap: 8px;
        }

        .multi-panel.is-active {
            display: flex;
        }

        .multi-panel .multi-list {
            font-size: 12px;
            word-break: break-word;
        }

        .multi-panel input[type="number"] {
            width: 72px;
            background: #1a1e28;
            border: 1px solid var(--border);
            color: var(--text);
            padding: 6px 8px;
            border-radius: 8px;
        }

        .multi-panel .multi-hint {
            font-size: 11px;
            color: var(--muted);
        }

        #overlayOpacity {
            width: 100%;
        }


        .toast {
            position: fixed;
            top: 40px;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: #4CAF50;
            color: white;
            padding: 12px;
            border-radius: 16px;
            z-index: 9999;
            opacity: 0;
            animation: toastFadeInOut 3s ease forwards;
            font-size: 14px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        .toast-error {
            background-color: #d32f2f;
        }

        @keyframes toastFadeInOut {
            0% {
                opacity: 0;
                transform: translate(-50%, -70%);
            }

            10% {
                opacity: 1;
                transform: translate(-50%, -50%);
            }

            90% {
                opacity: 1;
                transform: translate(-50%, -50%);
            }

            100% {
                opacity: 0;
                transform: translate(-50%, -30%);
            }
        }