:root {
    --bg: #ece5d6;
    --panel: #f9f6ee;
    --ink: #26282c;
    --mute: #716d63;
    --field: #efe9da;
    --highlight: #e9c23b;
    --accent: #26282c;
    --accent-text: #f4efe3;
    --checker-a: #e4dccb;
    --checker-b: #f3eee2;
    --error: #b3321f;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #1d1e21;
        --panel: #2a2c30;
        --ink: #efe9da;
        --mute: #9a978e;
        --field: #222427;
        --accent: #efe9da;
        --accent-text: #26282c;
        --checker-a: #34373c;
        --checker-b: #2c2e32;
        --error: #ff8c78;

        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #1d1e21;
    --panel: #2a2c30;
    --ink: #efe9da;
    --mute: #9a978e;
    --field: #222427;
    --accent: #efe9da;
    --accent-text: #26282c;
    --checker-a: #34373c;
    --checker-b: #2c2e32;
    --error: #ff8c78;

    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-padding-top: env(safe-area-inset-top, 0px);
}

body {
    min-height: 100vh;
    margin: 0;
    padding:
        calc(28px + env(safe-area-inset-top, 0px))
        16px
        calc(48px + env(safe-area-inset-bottom, 0px));

    background: var(--bg);
    color: var(--ink);

    font-family:
        "Nunito",
        "Segoe UI",
        system-ui,
        -apple-system,
        sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: 0;
}

button:disabled {
    cursor: not-allowed;
}

:focus-visible {
    outline: 3px solid var(--highlight);
    outline-offset: 2px;
}

.container {
    width: min(100%, 896px);
    margin: 0 auto;
}

.page-title {
    margin: 0 0 6px;

    font-size: 36px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.page-description {
    margin: 0 0 24px;

    color: var(--mute);

    font-size: 15px;
}

.layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
}

.panel {
    padding: 20px;

    border-radius: 32px;

    background: var(--panel);
    box-shadow: 0 10px 30px rgb(0 0 0 / 5%);
}

.drop-zone {
    display: flex;

    min-height: 116px;
    margin-bottom: 12px;
    padding: 24px 16px;

    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;

    border: 2px dashed rgb(113 109 99 / 30%);
    border-radius: 24px;

    color: var(--mute);

    cursor: pointer;

    text-align: center;

    font-size: 15px;
    font-weight: 700;

    transition:
        border-color 150ms ease,
        background 150ms ease;
}

.drop-zone.active {
    border-color: var(--highlight);
    background: rgb(233 194 59 / 16%);
}

.drop-zone svg {
    width: 28px;
    height: 28px;
}

.code-input {
    display: block;

    width: 100%;
    min-height: 176px;
    padding: 14px 16px;

    border: 0;
    border-radius: 24px;

    outline: 0;
    resize: vertical;

    background: var(--field);
    color: var(--ink);

    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        monospace;

    font-size: 13px;
    line-height: 1.45;
}

.code-input::placeholder {
    color: var(--mute);
}

.settings {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.setting {
    display: flex;
    flex-direction: column;
    gap: 6px;

    color: var(--mute);

    font-size: 13px;
    font-weight: 700;
}

.number-input,
.hex-input {
    height: 44px;
    padding: 0 16px;

    border: 0;
    border-radius: 999px;

    outline: 0;

    background: var(--field);
    color: var(--ink);

    font-size: 16px;
    font-weight: 700;
}

.number-input {
    width: 128px;
    -moz-appearance: textfield;
}

.number-input::-webkit-inner-spin-button {
    display: none;
}

.hex-input {
    width: 112px;

    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        monospace;
}

.select {
    position: relative;
    min-width: 152px;
}

.select-button {
    display: flex;

    width: 100%;
    min-height: 44px;
    padding: 0 16px;

    align-items: center;
    gap: 8px;

    border-radius: 999px;

    background: var(--field);
    color: var(--ink);

    cursor: pointer;

    font-size: 16px;
    font-weight: 700;
    text-align: left;
}

.select-button .label {
    flex: 1;
}

.select-button .chevron {
    width: 16px;
    height: 16px;

    color: var(--mute);

    transition: transform 150ms ease;
}

.select-button[aria-expanded="true"] .chevron {
    transform: rotate(180deg);
}

.select-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 20;

    display: none;

    width: max-content;
    min-width: 100%;
    max-width: 80vw;
    padding: 8px;

    border-radius: 24px;

    background: var(--panel);

    box-shadow:
        0 16px 40px rgb(0 0 0 / 15%),
        0 0 0 1px rgb(0 0 0 / 8%);

    list-style: none;
}

.select-menu.open {
    display: block;
}

.select-option {
    display: flex;

    min-height: 40px;
    padding: 8px 12px;

    align-items: center;
    gap: 10px;

    border-radius: 999px;

    color: var(--ink);

    cursor: pointer;

    font-size: 15px;
    font-weight: 700;
}

.select-option:hover,
.select-option:focus {
    background: var(--field);
    outline: 0;
}

.option-label {
    flex: 1;
    white-space: nowrap;
}

.option-check {
    width: 16px;
    height: 16px;
}

.swatch {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;

    border-radius: 50%;

    box-shadow: 0 0 0 1px rgb(0 0 0 / 20%);
}

.checker {
    background:
        conic-gradient(
            var(--checker-a) 25%,
            var(--checker-b) 0 50%,
            var(--checker-a) 0 75%,
            var(--checker-b) 0
        ) 0 0 / 16px 16px;
}

.preview {
    display: flex;

    min-height: 240px;
    padding: 12px;

    align-items: center;
    justify-content: center;

    overflow: auto;

    border-radius: 24px;
}

.preview canvas {
    display: block;

    width: auto;
    max-width: 100%;
    height: auto;

    border-radius: 12px;
}

.info {
    min-height: 21px;
    margin: 12px 4px 6px;

    color: var(--mute);

    font-size: 14px;
    font-weight: 700;
}

.error {
    min-height: 21px;
    margin: 0 4px;

    color: var(--error);

    font-size: 14px;
    font-weight: 700;
}

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

.button {
    display: inline-flex;

    min-height: 48px;
    padding: 0 20px;

    align-items: center;
    justify-content: center;
    gap: 8px;

    border-radius: 999px;

    cursor: pointer;

    font-size: 15px;
    font-weight: 800;

    transition:
        transform 150ms ease,
        opacity 150ms ease;
}

.button:active {
    transform: scale(0.96);
}

.button:disabled {
    opacity: 0.4;
}

.button svg {
    width: 20px;
    height: 20px;
}

.button-primary {
    background: var(--accent);
    color: var(--accent-text);
}

.button-secondary {
    background: var(--field);
    color: var(--ink);
}

[hidden] {
    display: none !important;
}

@media (max-width: 700px) {
    body {
        padding-top:
            calc(20px + env(safe-area-inset-top, 0px));
    }

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

    .page-title {
        font-size: 32px;
    }
}

@media (max-width: 420px) {
    body {
        padding-right: 12px;
        padding-left: 12px;
    }

    .panel {
        padding: 16px;
        border-radius: 28px;
    }

    .settings {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .setting {
        min-width: 0;
    }

    .number-input,
    .select,
    .hex-input {
        width: 100%;
        min-width: 0;
    }

    .actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .button {
        width: 100%;
    }
}

.error-page {
    display: grid;
    min-height: 100vh;
    padding:
        env(safe-area-inset-top, 0px)
        24px
        env(safe-area-inset-bottom, 0px);

    place-items: center;
}

.error-content {
    width: min(100%, 640px);
    text-align: center;
}

.error-code {
    margin: 0;

    font-size: clamp(7rem, 28vw, 12rem);
    font-weight: 900;
    line-height: 0.8;
    letter-spacing: -0.08em;

    color: var(--ink);
}

.error-code span {
    color: var(--highlight);
}

.error-content h1 {
    margin: 48px 0 12px;

    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.03em;
}

.error-content p {
    max-width: 420px;
    margin: 0 auto;

    color: var(--mute);

    font-size: 1rem;
    line-height: 1.6;
}

.error-link {
    display: inline-flex;

    margin-top: 28px;
    padding: 13px 22px;

    align-items: center;
    justify-content: center;

    border-radius: 999px;

    background: var(--ink);
    color: var(--bg);

    font-weight: 800;
    text-decoration: none;

    transition:
        transform 150ms ease,
        opacity 150ms ease;
}

.error-link:hover {
    transform: translateY(-2px);
}

.error-link:active {
    transform: scale(0.97);
}

.error-link:focus-visible {
    outline: 3px solid var(--highlight);
    outline-offset: 3px;
}

.error-mark {
    position: fixed;
    left: 24px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));

    color: var(--mute);

    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.about-page {
    max-width: 820px;
}

.about-back {
    display: inline-flex;
    margin-bottom: 72px;
    color: var(--mute);
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    transition: color 150ms ease;
}

.about-back:hover {
    color: var(--ink);
}

.about-back:focus-visible {
    outline: 3px solid var(--highlight);
    outline-offset: 4px;
    border-radius: 4px;
}

.about-header {
    margin-bottom: 72px;
}

.about-label {
    margin: 0 0 14px;
    color: var(--highlight);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.about-header .page-title {
    margin-bottom: 18px;
}

.about-content {
    display: grid;
    gap: 0;
    border-top: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
}

.about-section {
    padding: 36px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
}

.about-section h2 {
    margin: 0 0 16px;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.about-section p {
    max-width: 680px;
    margin: 0 0 12px;
    color: var(--mute);
    font-size: 0.95rem;
    line-height: 1.7;
}

.about-section p:last-child {
    margin-bottom: 0;
}

.about-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    color: var(--mute);
    list-style: none;
    font-size: 0.95rem;
}

.about-list li {
    position: relative;
    padding-left: 20px;
    line-height: 1.5;
}

.about-list li::before {
    position: absolute;
    top: 0.65em;
    left: 0;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--highlight);
    content: "";
}

.about-footer {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-top: 48px;
    color: var(--mute);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

@media (max-width: 640px) {
    .about-page {
        padding-top: 32px;
        padding-bottom: 32px;
    }

    .about-back {
        margin-bottom: 52px;
    }

    .about-header {
        margin-bottom: 52px;
    }

    .about-section {
        padding: 28px 0;
    }

    .about-footer {
        flex-direction: column;
        gap: 8px;
        margin-top: 36px;
    }
}