:root {
    color-scheme: light;
    --ink: #15161a;
    --muted: #58606c;
    --paper: #f3f8fb;
    --surface: #ffffff;
    --soft: #eef6f4;
    --line: #cbd7df;
    --blue: #0078d4;
    --cyan: #00a8c6;
    --green: #008f68;
    --coral: #e5484d;
    --yellow: #f5c542;
    --lime: #8cc63f;
    --shadow: 0 20px 50px rgba(21, 22, 26, 0.14);
    --panel-shadow: 0 12px 30px rgba(21, 22, 26, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background:
        linear-gradient(135deg, rgba(0, 168, 198, 0.16) 0 18%, transparent 18% 100%),
        linear-gradient(315deg, rgba(229, 72, 77, 0.14) 0 15%, transparent 15% 100%),
        linear-gradient(90deg, rgba(0, 143, 104, 0.08) 1px, transparent 1px),
        linear-gradient(0deg, rgba(0, 120, 212, 0.07) 1px, transparent 1px),
        var(--paper);
    background-size: auto, auto, 46px 46px, 46px 46px;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    letter-spacing: 0;
}

button,
input,
select,
textarea {
    font: inherit;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

.page-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0 auto;
    padding: 16px;
}

.topbar {
    position: sticky;
    top: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
    padding: 10px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(16px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(90deg, var(--yellow) 0 24%, var(--green) 24% 44%, var(--cyan) 44% 64%, var(--coral) 64% 82%, var(--blue) 82% 100%) left bottom / 100% 8px no-repeat,
        #ffffff;
    font-weight: 900;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.42);
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 28px;
    min-width: 28px;
    height: 28px;
    border: 2px solid var(--ink);
    border-radius: 6px;
    background: var(--ink);
    color: #ffffff;
    font-size: 0.78rem;
    line-height: 1;
}

.home-page .brand {
    min-height: 52px;
    padding: 0 18px;
    background:
        linear-gradient(90deg, var(--yellow) 0 20%, var(--green) 20% 42%, var(--cyan) 42% 64%, var(--coral) 64% 84%, var(--blue) 84% 100%) left bottom / 100% 10px no-repeat,
        #ffffff;
    font-size: 1.24rem;
    box-shadow: 6px 6px 0 var(--ink);
}

.home-page .brand-mark {
    width: 34px;
    min-width: 34px;
    height: 34px;
    font-size: 0.9rem;
}

.topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
    font-weight: 700;
}

.topbar nav a {
    min-height: 36px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.topbar nav a:hover {
    border-color: var(--ink);
    background: #e2f5f2;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(360px, 0.72fr) minmax(360px, 1fr);
    grid-template-areas:
        "controls preview"
        "stage stage";
    gap: 22px;
}

.palette-page {
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    grid-template-areas:
        "controls stage"
        "preview stage";
    align-items: stretch;
}

.tool-directory,
.single-tool {
    display: grid;
    gap: 22px;
}

.directory-intro {
    max-width: none;
    padding: 34px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(0, 168, 198, 0.16), transparent 44%),
        var(--surface);
    box-shadow: var(--shadow);
}

.home-hero {
    position: relative;
    display: grid;
    align-content: end;
    min-height: clamp(430px, 52vh, 620px);
    overflow: hidden;
    padding: clamp(26px, 5vw, 64px);
    background:
        linear-gradient(90deg, rgba(243, 248, 251, 0.98) 0 30%, rgba(243, 248, 251, 0.78) 52%, rgba(243, 248, 251, 0.24) 100%),
        #f3f8fb;
}

.home-hero > div,
.home-material-generator {
    position: relative;
    z-index: 2;
}

.home-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background:
        linear-gradient(90deg, rgba(243, 248, 251, 0.95) 0 28%, rgba(243, 248, 251, 0.62) 42%, rgba(243, 248, 251, 0.16) 100%),
        linear-gradient(118deg, transparent 0 45%, rgba(245, 197, 66, 0.94) 45% 54%, transparent 54% 100%),
        linear-gradient(100deg, transparent 0 56%, rgba(229, 72, 77, 0.94) 56% 66%, transparent 66% 100%),
        linear-gradient(146deg, transparent 0 60%, rgba(0, 143, 104, 0.92) 60% 72%, transparent 72% 100%),
        linear-gradient(78deg, transparent 0 64%, rgba(0, 168, 198, 0.94) 64% 76%, transparent 76% 100%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(245, 197, 66, 0.22)),
        url("../img/workbench-preview.png") center / cover no-repeat;
    background-blend-mode: normal, multiply, multiply, multiply, multiply, color, normal;
}

.home-hero::after {
    content: "";
    position: absolute;
    right: clamp(18px, 4vw, 60px);
    bottom: clamp(18px, 4vw, 52px);
    z-index: 1;
    width: min(42vw, 620px);
    height: 18px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background:
        linear-gradient(90deg, var(--yellow) 0 18%, var(--green) 18% 38%, var(--cyan) 38% 58%, var(--coral) 58% 78%, var(--blue) 78% 100%);
    box-shadow: 8px 8px 0 var(--ink);
}

.home-hero .eyebrow {
    width: fit-content;
    padding: 7px 10px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
}

.home-hero::before,
.home-hero::after {
    pointer-events: none;
}

.home-hero::selection {
    background: var(--yellow);
}

.home-hero h1::after {
    content: "";
    display: block;
    width: min(560px, 54vw);
    height: 12px;
    margin-top: 12px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background:
        linear-gradient(90deg, var(--coral) 0 22%, var(--yellow) 22% 42%, var(--green) 42% 62%, var(--cyan) 62% 82%, var(--blue) 82% 100%);
}

.home-hero h1 {
    max-width: none;
    font-size: 6rem;
    letter-spacing: 0;
    text-transform: none;
    overflow-wrap: normal;
}

.home-hero p:not(.eyebrow) {
    max-width: 680px;
    margin: 18px 0 0;
    color: var(--ink);
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.45;
}

.home-actions {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 30px;
}

.home-actions a {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    padding: 0 18px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: var(--ink);
    color: #ffffff;
    font-weight: 900;
    box-shadow: 5px 5px 0 var(--yellow);
}

.home-actions a:nth-child(2) {
    background: #ffffff;
    color: var(--ink);
    box-shadow: 5px 5px 0 var(--cyan);
}

.home-material-generator {
    display: grid;
    width: min(780px, 100%);
    gap: 14px;
    margin-top: 28px;
    padding: clamp(16px, 2vw, 22px);
    border: 3px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(245, 197, 66, 0.96), rgba(255, 255, 255, 0.94) 42%, rgba(0, 168, 198, 0.2)),
        #ffffff;
    box-shadow: 8px 8px 0 var(--coral);
}

.home-material-generator label {
    display: block;
    margin-top: 8px;
    color: var(--ink);
    font-size: clamp(1.45rem, 2.2vw, 2.35rem);
    font-weight: 900;
    line-height: 1;
}

.home-hero .home-material-generator p:not(.eyebrow) {
    max-width: 660px;
    margin: 10px 0 0;
    color: var(--ink);
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.45;
}

.home-material-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, 0.32fr) minmax(96px, auto);
    gap: 10px;
}

.home-material-row input[type="text"],
.home-material-row select {
    min-height: 58px;
    min-width: 0;
    width: 100%;
    padding: 0 16px;
    border: 3px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
    font-size: 1.15rem;
    font-weight: 900;
}

.home-material-row select {
    appearance: none;
    background:
        linear-gradient(45deg, transparent 50%, var(--ink) 50%) calc(100% - 18px) 50% / 7px 7px no-repeat,
        linear-gradient(135deg, var(--ink) 50%, transparent 50%) calc(100% - 12px) 50% / 7px 7px no-repeat,
        #ffffff;
}

.home-material-row button {
    min-height: 58px;
    padding: 0 24px;
    border: 3px solid var(--ink);
    border-radius: 8px;
    background: var(--green);
    color: #ffffff;
    font: inherit;
    font-size: 1.35rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 5px 5px 0 var(--ink);
}

.home-material-row button:hover,
.home-material-row button:focus-visible {
    background: var(--coral);
}

.home-material-prompts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-weight: 900;
}

.home-material-prompts button {
    min-height: 34px;
    padding: 0 10px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 900;
    cursor: pointer;
}

.home-material-prompts button:hover,
.home-material-prompts button:focus-visible {
    background: var(--cyan);
}

.home-material-generator small {
    color: var(--ink);
    font-weight: 900;
}

.home-material-loader {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
}

.home-material-loader[hidden] {
    display: none;
}

.home-loader-track {
    height: 14px;
    overflow: hidden;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: #ffffff;
}

.home-loader-track span {
    display: block;
    width: var(--home-loader-progress, 12%);
    height: 100%;
    border-right: 2px solid var(--ink);
    background:
        linear-gradient(90deg, var(--yellow) 0 20%, var(--green) 20% 40%, var(--cyan) 40% 60%, var(--coral) 60% 80%, var(--blue) 80% 100%);
    transition: width 260ms ease;
}

.home-material-generator.is-waiting-texture .home-loader-track span {
    width: 38%;
    animation: home-loader-wait 1100ms ease-in-out infinite;
}

@keyframes home-loader-wait {
    0% {
        transform: translateX(-110%);
    }

    50% {
        transform: translateX(82%);
    }

    100% {
        transform: translateX(265%);
    }
}

.home-material-loader p {
    margin: 0;
    color: var(--ink);
    font-size: 1.08rem;
    font-weight: 900;
}

.home-material-loader ol {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.home-material-loader li {
    min-height: 38px;
    padding: 7px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f3f8fb;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 900;
}

.home-material-loader li.is-active {
    border-color: var(--ink);
    background: var(--yellow);
    color: var(--ink);
}

.home-material-loader li.is-complete {
    border-color: rgba(0, 136, 95, 0.42);
    background: #e2f5f2;
    color: var(--ink);
}

.home-material-generator.is-loading .home-material-row input,
.home-material-generator.is-loading .home-material-row select,
.home-material-generator.is-loading .home-material-row button {
    opacity: 0.72;
}

.home-flow,
.home-feature-grid {
    display: grid;
    gap: 18px;
    padding: 26px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.home-flow {
    grid-template-columns: minmax(260px, 0.7fr) minmax(0, 1.3fr);
    background:
        linear-gradient(90deg, rgba(245, 197, 66, 0.2), transparent 38%),
        linear-gradient(315deg, rgba(0, 168, 198, 0.14), transparent 42%),
        var(--surface);
}

.home-flow > div {
    display: grid;
    align-content: start;
    gap: 12px;
}

.home-flow h2 {
    font-size: clamp(2rem, 3.2rem, 3.2rem);
}

.home-flow p,
.home-feature-grid p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.home-flow ol {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.home-flow li,
.home-feature-grid > div {
    min-width: 0;
    min-height: 190px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
}

.home-flow li a,
.home-feature-grid > div {
    display: grid;
    gap: 12px;
}

.home-flow li a {
    min-height: 100%;
    padding: 18px;
    border-radius: 6px;
}

.home-flow li:hover,
.home-flow li:focus-within {
    transform: translateY(-2px);
    box-shadow: 5px 5px 0 var(--ink);
}

.home-flow li a:focus-visible {
    outline: 3px solid var(--cyan);
    outline-offset: -6px;
}

.home-feature-grid > div {
    padding: 18px;
    border: 2px solid var(--ink);
    border-radius: 8px;
}

.home-flow li:nth-child(1),
.home-feature-grid > div:nth-child(1) {
    background: linear-gradient(180deg, #ffffff 0 68%, #fff3cf 68% 100%);
}

.home-flow li:nth-child(2),
.home-feature-grid > div:nth-child(2) {
    background: linear-gradient(180deg, #ffffff 0 68%, #e2f5f2 68% 100%);
}

.home-flow li:nth-child(3),
.home-feature-grid > div:nth-child(3) {
    background: linear-gradient(180deg, #ffffff 0 68%, #ffe8e9 68% 100%);
}

.home-flow li span,
.home-feature-grid span {
    color: var(--coral);
    font-size: 0.82rem;
    font-weight: 900;
    text-transform: uppercase;
}

.home-flow li strong,
.home-feature-grid strong {
    font-size: 1.4rem;
    line-height: 1.05;
}

.home-feature-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    background:
        linear-gradient(90deg, rgba(0, 143, 104, 0.14), transparent 40%),
        linear-gradient(315deg, rgba(0, 120, 212, 0.12), transparent 46%),
        var(--surface);
}

.directory-intro p:not(.eyebrow) {
    color: var(--muted);
    line-height: 1.65;
}

.home-page .home-hero p:not(.eyebrow) {
    color: var(--ink);
}

.tool-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.tool-card {
    display: grid;
    align-content: space-between;
    min-height: 260px;
    gap: 16px;
    padding: 24px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(180deg, #ffffff 0 72%, #edf8f6 72% 100%);
    box-shadow: var(--shadow);
    transition: transform 140ms ease, box-shadow 140ms ease;
}

.tool-card:nth-child(2) {
    background:
        linear-gradient(180deg, #ffffff 0 72%, #fff3cf 72% 100%);
}

.tool-card:nth-child(3) {
    background:
        linear-gradient(180deg, #ffffff 0 72%, #ffe8e9 72% 100%);
}

.tool-card:nth-child(4) {
    background:
        linear-gradient(180deg, #ffffff 0 72%, #e9f2ff 72% 100%);
}

.tool-card:hover {
    transform: translateY(-2px);
}

.tool-card span {
    color: var(--coral);
    font-size: 0.84rem;
    font-weight: 800;
    text-transform: uppercase;
}

.tool-card strong {
    font-size: 2rem;
    line-height: 1.05;
    overflow-wrap: anywhere;
}

.tool-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.control-surface,
.preview-panel,
.palette-stage,
.noise-tool,
.texture-tool,
.normal-tool {
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.control-surface {
    grid-area: controls;
    display: grid;
    align-content: space-between;
    min-height: 470px;
    padding: 34px;
}

.intro {
    max-width: 640px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--green);
    font-size: 0.88rem;
    font-weight: 800;
    text-transform: uppercase;
}

h1,
h2,
p {
    overflow-wrap: anywhere;
}

h1 {
    max-width: 720px;
    margin: 0;
    font-size: clamp(2.4rem, 4.8rem, 4.8rem);
    line-height: 0.98;
}

h2 {
    margin: 0;
    font-size: 2rem;
    line-height: 1;
}

h3 {
    margin: 0;
    font-size: 1.45rem;
    line-height: 1.05;
}

.intro p:not(.eyebrow),
.stage-heading p {
    color: var(--muted);
    line-height: 1.65;
}

.tool-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, 190px) auto;
    align-items: end;
    gap: 12px;
    margin-top: 38px;
}

.tool-form label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.tool-form input,
.tool-form select,
.tool-form button {
    min-height: 52px;
    border: 2px solid var(--ink);
    border-radius: 8px;
}

.tool-form input,
.tool-form select {
    width: 100%;
    min-width: 0;
    background: #f7fbfd;
    padding: 0 14px;
    color: var(--ink);
}

.tool-form button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    background: var(--blue);
    color: #ffffff;
    padding: 0 18px;
    font-weight: 800;
}

.tool-form button:disabled {
    cursor: wait;
    opacity: 0.86;
}

.button-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.46);
    border-top-color: #ffffff;
    border-radius: 50%;
    flex: 0 0 auto;
}

.tool-form button.is-loading .button-spinner {
    display: inline-block;
    animation: button-spin 760ms linear infinite;
}

@keyframes button-spin {
    to {
        transform: rotate(360deg);
    }
}

.preview-panel {
    grid-area: preview;
    position: relative;
    min-height: 470px;
    overflow: hidden;
}

.preview-panel img {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 470px;
    object-fit: cover;
}

.preview-copy {
    position: absolute;
    right: 18px;
    bottom: 18px;
    left: 18px;
    display: grid;
    gap: 6px;
    padding: 16px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
}

.preview-copy span {
    color: var(--coral);
    font-size: 0.84rem;
    font-weight: 800;
    text-transform: uppercase;
}

.preview-copy strong {
    line-height: 1.25;
}

.palette-stage {
    grid-area: stage;
    padding: 26px;
}

.palette-page .control-surface {
    min-height: auto;
    align-content: start;
    gap: 28px;
    background:
        linear-gradient(180deg, rgba(245, 197, 66, 0.22), transparent 210px),
        var(--surface);
}

.palette-page .intro {
    max-width: 100%;
}

.palette-page .intro h1 {
    font-size: 3.6rem;
}

.palette-page .tool-form {
    grid-template-columns: 1fr;
    margin-top: 0;
}

.bias-panel {
    display: grid;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.tool-form .bias-panel label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
}

.bias-panel label {
    color: var(--ink);
    font-weight: 800;
}

.palette-prompt-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.palette-prompt-list span {
    min-height: 34px;
    cursor: pointer;
    padding: 7px 10px;
    border: 1px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 800;
}

.saved-biomes {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(0, 143, 104, 0.16), transparent 58%),
        linear-gradient(315deg, rgba(229, 72, 77, 0.12), transparent 46%),
        #ffffff;
}

.saved-biomes > div:first-child {
    display: grid;
    gap: 6px;
}

.saved-biomes h2 {
    margin: 0;
    font-size: 1.35rem;
}

.palette-biome-cta p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.saved-biomes a {
    width: fit-content;
    color: var(--blue);
    font-weight: 900;
}

.saved-biome-list {
    display: grid;
    gap: 8px;
    max-height: 280px;
    overflow: auto;
}

.saved-biome-card {
    display: grid;
    gap: 4px;
    width: 100%;
    min-height: 64px;
    cursor: pointer;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    padding: 10px 12px;
    text-align: left;
    font: inherit;
}

.saved-biome-card:hover,
.saved-biome-card:focus-visible {
    border-color: var(--ink);
    outline: 2px solid var(--yellow);
    outline-offset: 1px;
}

.saved-biome-card > span:first-child {
    font-weight: 900;
    overflow-wrap: anywhere;
}

.saved-biome-card small {
    color: var(--muted);
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.saved-biome-strip {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    min-height: 10px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.saved-biome-strip span {
    min-height: 10px;
}

.biome-library {
    display: grid;
    gap: 22px;
}

.texture-library {
    display: grid;
    gap: 22px;
}

[data-library-card][hidden] {
    display: none;
}

.library-search {
    display: grid;
    gap: 8px;
    padding: 18px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(245, 197, 66, 0.28), rgba(0, 168, 198, 0.16)),
        #ffffff;
    box-shadow: var(--panel-shadow);
}

.library-search label {
    color: var(--ink);
    font-size: 1.25rem;
    font-weight: 900;
}

.library-search input {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
    font-weight: 900;
}

.library-search p {
    margin: 0;
    color: var(--muted);
    font-weight: 800;
}

.library-popular-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
}

.library-popular-tags span {
    color: var(--ink);
    font-weight: 900;
}

.library-popular-tags button {
    min-height: 32px;
    padding: 4px 9px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 900;
}

.library-popular-tags button:hover,
.library-popular-tags button:focus-visible {
    background: var(--yellow);
}

.biome-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.texture-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 340px));
    gap: 16px;
    justify-content: start;
    align-items: start;
}

.biome-library-grid .saved-biome-card {
    min-height: 190px;
    align-content: start;
    border: 2px solid var(--ink);
    box-shadow: var(--panel-shadow);
}

.biome-library-grid .saved-biome-strip {
    min-height: 34px;
    margin-top: 8px;
}

.biome-library-grid .saved-biome-strip span {
    min-height: 34px;
}

.texture-library-card {
    display: grid;
    width: min(100%, 340px);
    min-width: 0;
    overflow: hidden;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(180deg, #ffffff 0 70%, #fff3cf 70% 100%);
    box-shadow: var(--panel-shadow);
}

.texture-library-preview {
    display: block;
    width: 100%;
    max-width: 340px;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-bottom: 2px solid var(--ink);
    background:
        linear-gradient(45deg, #d8dbe2 25%, transparent 25%),
        linear-gradient(-45deg, #d8dbe2 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d8dbe2 75%),
        linear-gradient(-45deg, transparent 75%, #d8dbe2 75%),
        #ffffff;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    background-size: 24px 24px;
}

.texture-library-preview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 180ms ease, opacity 180ms ease;
}

.texture-library-card:hover .texture-library-preview img,
.texture-library-card:focus-within .texture-library-preview img {
    transform: scale(1.025);
}

.texture-library-copy {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.texture-library-copy h2 {
    font-size: 1.35rem;
    line-height: 1.05;
}

.texture-library-copy dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
}

.texture-library-copy dl div {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.texture-library-copy dt,
.texture-library-copy dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.texture-library-copy dt {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
}

.texture-library-copy dd {
    font-weight: 900;
}

.texture-variation-tray {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.texture-variation-tray p {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 900;
}

.texture-variation-tray p:focus-visible {
    outline: 3px solid var(--yellow);
    outline-offset: 3px;
}

.texture-variation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
    gap: 8px;
    max-height: 0;
    overflow-y: hidden;
    opacity: 0;
    padding-right: 4px;
    scrollbar-gutter: stable;
    transform: translateY(-8px);
    transition:
        max-height 260ms ease,
        opacity 180ms ease,
        transform 220ms ease;
    pointer-events: none;
}

.texture-library-card:hover .texture-variation-grid,
.texture-variation-tray:focus-within .texture-variation-grid {
    max-height: 224px;
    overflow-y: auto;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

@media (hover: none) {
    .texture-variation-grid {
        max-height: 224px;
        overflow-y: auto;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }
}

.texture-variation-pick {
    display: grid;
    gap: 5px;
    min-width: 0;
    padding: 5px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #eef8ff;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 900;
    transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.texture-variation-pick.is-active {
    background: #fff3cf;
}

.texture-variation-pick:hover,
.texture-variation-pick:focus-visible {
    transform: translateY(-2px);
    box-shadow: 4px 4px 0 rgba(10, 15, 31, 0.18);
}

.texture-variation-pick img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 6px;
}

.texture-variation-pick span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.library-tags span,
.library-tags button {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--muted);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 900;
    cursor: pointer;
}

.library-tags span:hover,
.library-tags span:focus-visible,
.library-tags button:hover,
.library-tags button:focus-visible {
    border-color: var(--ink);
    background: #e2f5f2;
    color: var(--ink);
}

.texture-library-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.texture-library-actions a,
.texture-library-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 10px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: var(--blue);
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 900;
}

.texture-library-actions a:last-child,
.texture-library-actions button {
    background: var(--green);
}

.texture-library-actions a:first-of-type {
    background: var(--coral);
}

.texture-library-actions .texture-library-download {
    grid-column: 1 / -1;
}

.empty-library {
    display: grid;
    gap: 12px;
    padding: 24px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.empty-library[hidden] {
    display: none;
}

.empty-library p {
    margin: 0;
    color: var(--muted);
}

.empty-library a {
    width: fit-content;
    min-height: 40px;
    padding: 10px 12px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: var(--yellow);
    font-weight: 900;
}

.palette-page .preview-panel {
    min-height: 230px;
}

.palette-page .preview-panel img {
    min-height: 230px;
}

.palette-page .palette-stage {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: calc(100vh - 120px);
    background:
        linear-gradient(135deg, rgba(0, 120, 212, 0.1), transparent 34%),
        linear-gradient(315deg, rgba(229, 72, 77, 0.11), transparent 28%),
        var(--surface);
}

.palette-page #palette-board,
.palette-page .palette-group-stack {
    min-height: 0;
}

.palette-source-line {
    margin-bottom: 16px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--muted);
    font-weight: 800;
}

.palette-group-stack {
    display: grid;
    gap: 18px;
}

.palette-group {
    display: grid;
    gap: 12px;
}

.palette-group-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: end;
}

.biome-pack {
    display: grid;
    align-content: start;
    align-items: start;
    gap: 16px;
    margin-top: 22px;
    padding: 18px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(0, 143, 104, 0.12), transparent 46%),
        #ffffff;
}

.biome-pack-heading {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: end;
}

.biome-pack-heading p:not(.eyebrow) {
    max-width: 520px;
    margin: 0 0 10px;
    color: var(--muted);
    line-height: 1.5;
}

.biome-pack-heading > div:last-child {
    display: grid;
    justify-items: end;
}

.biome-export-button {
    min-height: 42px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: var(--coral) !important;
    color: #ffffff !important;
    cursor: pointer;
    font: inherit;
    font-weight: 900;
    padding: 0 12px;
}

.biome-layer-stack {
    display: grid;
    gap: 16px;
}

.biome-layer {
    display: grid;
    gap: 10px;
}

.biome-layer h4 {
    margin: 0;
    color: var(--green);
    font-size: 1rem;
    text-transform: uppercase;
}

.biome-material-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.biome-material {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 12px;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.biome-material-swatch {
    min-height: 100%;
    border: 2px solid var(--ink);
    border-radius: 8px;
}

.biome-material-copy {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.biome-material-copy > div:first-child {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
}

.biome-material-copy strong {
    overflow-wrap: anywhere;
}

.biome-material-copy p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.4;
}

.material-settings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
    gap: 6px;
    margin: 0;
}

.material-settings div {
    display: grid;
    gap: 2px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7fbfd;
}

.material-settings dt,
.material-settings dd {
    margin: 0;
}

.material-settings dt {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.material-settings dd {
    font-weight: 900;
}

.material-send-button {
    min-height: 40px;
    cursor: pointer;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: var(--blue);
    color: #ffffff;
    font: inherit;
    font-weight: 900;
}

.material-send-button-secondary {
    background: var(--green);
}

.material-preset-note {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff9e8;
    color: var(--ink);
    font-weight: 800;
    line-height: 1.35;
}

.pbr-source-summary {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(0, 168, 198, 0.16), rgba(245, 197, 66, 0.22)),
        #ffffff;
    box-shadow: 4px 4px 0 var(--ink);
}

.pbr-source-summary[hidden] {
    display: none;
}

.pbr-source-summary img {
    width: 92px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(45deg, #d8dbe2 25%, transparent 25%),
        linear-gradient(-45deg, #d8dbe2 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d8dbe2 75%),
        linear-gradient(-45deg, transparent 75%, #d8dbe2 75%),
        #ffffff;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-size: 20px 20px;
}

.pbr-source-summary h2 {
    font-size: 1.25rem;
}

.pbr-source-summary dl {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin: 10px 0 0;
}

.pbr-source-summary dl div {
    min-width: 0;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
}

.pbr-source-summary dt,
.pbr-source-summary dd,
.pbr-source-summary p {
    margin: 0;
}

.pbr-source-summary dt {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.pbr-source-summary dd {
    color: var(--ink);
    font-weight: 900;
    overflow-wrap: anywhere;
}

.pbr-source-summary div > p:not(.eyebrow) {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.35;
}

.noise-tool,
.texture-tool {
    grid-area: noise;
    padding: 26px;
}

.normal-tool {
    padding: 22px;
}

.single-tool .noise-tool,
.single-tool .texture-tool,
.single-tool .normal-tool {
    grid-area: auto;
}

.single-tool {
    min-height: calc(100vh - 96px);
}

.stage-heading {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: end;
    margin-bottom: 20px;
}

.stage-heading p {
    max-width: 420px;
    margin: 0;
}

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

.swatch-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
}

.swatch-fill {
    min-height: 190px;
}

.swatch-meta {
    display: grid;
    gap: 8px;
    padding: 14px;
}

.swatch-meta span {
    font-weight: 800;
}

.swatch-meta small {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.copy-chip {
    width: fit-content;
    max-width: 100%;
    min-height: 34px;
    cursor: pointer;
    border: 1px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    padding: 6px 10px;
    font-weight: 800;
}

.palette-page .swatch-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    height: auto;
}

.palette-page .swatch-card {
    display: grid;
    grid-template-rows: minmax(190px, 1fr) auto;
    border: 2px solid var(--ink);
    min-height: 360px;
}

.palette-page .swatch-fill {
    min-height: 190px;
}

.palette-page .swatch-meta {
    min-height: 150px;
    align-content: start;
    background: #ffffff;
}

.palette-page .swatch-meta span {
    font-size: 1.25rem;
}

.biome-stage #biome-board {
    display: grid;
    align-content: start;
    align-items: start;
    gap: 20px;
}

.biome-generator-page .biome-pack {
    margin-top: 0;
}

.biome-generator-page .palette-stage {
    min-height: calc(100vh - 120px);
}

.biome-generator-page .swatch-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.biome-generator-page .swatch-card {
    grid-template-rows: minmax(110px, 150px) auto;
    min-height: 250px;
}

.biome-generator-page .swatch-fill {
    min-height: 110px;
}

.biome-generator-page .swatch-meta {
    min-height: 128px;
}

.biome-generator-page .swatch-meta span {
    font-size: 1rem;
}

.noise-workbench {
    display: grid;
    grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
    gap: 18px;
    align-items: stretch;
}

.normal-workbench {
    display: grid;
    grid-template-columns: minmax(340px, 480px) minmax(0, 1fr);
    gap: 20px;
    align-items: stretch;
}

.texture-workbench {
    display: grid;
    grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
    gap: 18px;
    align-items: stretch;
}

.noise-controls,
.texture-controls,
.normal-controls {
    display: grid;
    align-content: start;
    gap: 14px;
    padding: 18px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(0, 168, 198, 0.1), transparent 160px),
        #ffffff;
    box-shadow: var(--panel-shadow);
}

.normal-controls {
    max-height: calc(100vh - 152px);
    overflow: auto;
}

.texture-controls textarea,
.texture-controls select {
    width: 100%;
    min-width: 0;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
}

.texture-controls textarea {
    min-height: 120px;
    padding: 12px;
    resize: vertical;
}

.texture-controls select {
    min-height: 44px;
    padding: 0 12px;
}

.control-row {
    display: grid;
    gap: 8px;
}

.control-row label,
.check-control {
    color: var(--ink);
    font-weight: 800;
}

.control-row label {
    display: flex;
    justify-content: space-between;
    gap: 14px;
}

.control-row output {
    color: var(--muted);
    font-weight: 800;
}

.seed-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.seed-row label {
    grid-column: 1 / -1;
}

.seed-row input {
    width: 100%;
    min-width: 0;
}

.noise-controls input[type="text"],
.texture-controls button,
.noise-controls button,
.normal-controls button {
    min-height: 44px;
    border: 2px solid var(--ink);
    border-radius: 8px;
}

.noise-controls input[type="text"] {
    padding: 0 12px;
    background: #ffffff;
    color: var(--ink);
}

.noise-refine-panel {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.ai-refine-panel {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.ai-refine-panel label {
    font-weight: 900;
}

.ai-refine-panel textarea {
    width: 100%;
    min-height: 82px;
    resize: vertical;
    border: 2px solid var(--ink);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ink);
    font: inherit;
}

.material-intelligence {
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #e2f5f2;
    color: var(--ink);
    font-weight: 900;
    line-height: 1.35;
}

.noise-refine-panel label {
    font-weight: 900;
}

.noise-refine-panel textarea {
    width: 100%;
    min-height: 82px;
    resize: vertical;
    border: 2px solid var(--ink);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ink);
    font: inherit;
}

.noise-refine-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.noise-refine-presets button {
    min-height: 34px;
    border-width: 1px;
    font-size: 0.88rem;
}

.noise-controls input[type="range"] {
    width: 100%;
    accent-color: var(--blue);
}

.normal-controls input[type="range"] {
    width: 100%;
    accent-color: var(--blue);
}

.noise-controls button,
.texture-controls button,
.normal-controls button {
    cursor: pointer;
    padding: 0 12px;
    background: #ffffff;
    color: var(--ink);
    font-weight: 800;
}

.texture-controls button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.texture-controls button:disabled {
    cursor: wait;
    opacity: 0.86;
}

.texture-controls button.is-loading .button-spinner {
    display: inline-block;
    animation: button-spin 760ms linear infinite;
}

.texture-action-grid,
.texture-output-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

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

.texture-action-panel {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff9e8;
}

.texture-action-panel-pbr {
    background: #e2f5f2;
}

.texture-action-panel p {
    margin: 0;
    color: var(--muted);
    line-height: 1.4;
}

.texture-action-panel p strong {
    color: var(--ink);
}

.texture-pbr-map-hint {
    padding: 8px 10px;
    border: 1px solid rgba(0, 136, 95, 0.26);
    border-radius: 8px;
    background: #ffffff;
    font-size: 0.92rem;
}

.texture-action-panel > div {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.texture-action-panel-pbr > div {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr);
    align-items: stretch;
}

.texture-prompt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.texture-prompt-chips button {
    min-height: 34px;
    border-width: 1px;
    background: #ffffff;
    color: var(--muted);
    font-size: 0.88rem;
}

.texture-status,
.texture-prompt-output,
.texture-seed-output {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.texture-prompt-output,
.texture-seed-output {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff9e8;
    color: var(--ink);
    font-weight: 800;
}

.texture-seed-output {
    background: #e2f5f2;
}

.texture-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 12px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    font-weight: 800;
}

.texture-variation-button,
.texture-tileable-button,
.texture-compare-button {
    background: var(--blue) !important;
}

.texture-send-pbr {
    border-color: var(--green) !important;
    background: #ffffff !important;
    color: var(--green) !important;
}

.texture-generate-pbr {
    background: var(--coral) !important;
    min-height: 52px;
    font-size: 1rem;
    box-shadow: 0 4px 0 var(--ink);
}

.file-control {
    display: grid;
    gap: 8px;
}

.file-control label {
    color: var(--ink);
    font-weight: 800;
}

.file-control input {
    width: 100%;
    min-width: 0;
    padding: 10px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
}

.tool-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.tool-tabs .tab-button:last-child {
    grid-column: 1 / -1;
}

.tab-button {
    min-width: 0;
    min-height: 44px;
    cursor: pointer;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font-weight: 800;
    overflow-wrap: anywhere;
    white-space: normal;
}

.tab-button.is-active {
    background: var(--blue);
    color: #ffffff;
}

.tab-panel {
    display: grid;
    gap: 14px;
}

.tab-panel[hidden] {
    display: none;
}

.mask-panel {
    display: grid;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.mask-slot {
    display: grid;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f3faf8;
}

.mask-helper {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0;
}

.color-pick-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 54px 36px;
    gap: 10px;
    align-items: center;
}

.color-pick-row label {
    color: var(--ink);
    font-weight: 800;
}

.color-pick-row span:first-child {
    color: var(--ink);
    font-weight: 800;
}

.color-pick-row input {
    width: 54px;
    height: 38px;
    min-width: 0;
    padding: 2px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
}

.mask-color-chip {
    width: 36px;
    height: 36px;
    border: 2px solid var(--ink);
    border-radius: 8px;
}

.slot-pick-button {
    min-height: 42px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
}

.slot-pick-button:hover {
    background: #e4f1f0;
}

.slot-pick-button.is-active {
    background: #bdeee8;
}

.toggle-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.check-control {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.check-control:hover {
    border-color: var(--cyan);
}

.check-control input {
    width: 18px;
    height: 18px;
    accent-color: var(--green);
}

.download-button {
    background: var(--green) !important;
    color: #ffffff !important;
}

.export-all-button {
    background: var(--coral) !important;
}

.export-panel {
    display: grid;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff9e8;
}

.export-panel .eyebrow {
    margin-bottom: 6px;
}

.packed-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.packed-button,
.export-packed-button {
    background: var(--blue) !important;
}

.packed-action-grid .packed-button:last-child,
.export-packed-button {
    grid-column: 1 / -1;
}

.noise-preview {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 520px;
    padding: 18px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(45deg, #d8dbe2 25%, transparent 25%),
        linear-gradient(-45deg, #d8dbe2 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d8dbe2 75%),
        linear-gradient(-45deg, transparent 75%, #d8dbe2 75%),
        #ffffff;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    background-size: 24px 24px;
}

.texture-preview-panel {
    display: grid;
    min-width: 0;
    min-height: 620px;
    padding: 18px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(245, 197, 66, 0.2), transparent 52%),
        linear-gradient(315deg, rgba(0, 168, 198, 0.18), transparent 48%),
        #ffffff;
}

.texture-preview-frame {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(45deg, #d8dbe2 25%, transparent 25%),
        linear-gradient(-45deg, #d8dbe2 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d8dbe2 75%),
        linear-gradient(-45deg, transparent 75%, #d8dbe2 75%),
        #ffffff;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    background-size: 24px 24px;
}

.texture-preview-frame img {
    display: block;
    width: min(100%, 820px);
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

.texture-preview-frame img[hidden] {
    display: none;
}

.texture-preview-frame p {
    max-width: 320px;
    margin: 0;
    padding: 18px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
    color: var(--muted);
    font-weight: 800;
    text-align: center;
}

#noise-canvas {
    display: block;
    width: min(100%, 620px);
    height: auto;
    aspect-ratio: 1 / 1;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #ffffff;
    image-rendering: pixelated;
}

.normal-preview-stack {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.pbr-preview {
    position: relative;
    min-width: 0;
    min-height: min(62vh, 760px);
    overflow: hidden;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #15161a;
}

.pbr-preview canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.preview-hint {
    position: absolute;
    right: 14px;
    bottom: 14px;
    left: 14px;
    z-index: 2;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 8px;
    background: rgba(21, 22, 26, 0.72);
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 800;
    pointer-events: none;
}

.normal-map-output {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
    padding: 16px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(245, 197, 66, 0.18), transparent 38%),
        #ffffff;
    box-shadow: var(--panel-shadow);
}

.map-canvas-panel {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.normal-map-output p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.normal-map-output canvas {
    display: block;
    width: min(100%, var(--map-size, 1024px));
    height: auto;
    aspect-ratio: 1 / 1;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: #8080ff;
}

#height-canvas {
    cursor: crosshair;
    background: #ffffff;
}

#mask-canvas {
    background: #000000;
}

#surface-canvas {
    background: #808080;
}

#metallic-canvas {
    background: #000000;
}

#ao-canvas {
    background: #ffffff;
}

#height-map-canvas {
    background: #808080;
}

@media (min-width: 901px) {
    .noise-controls,
    .texture-controls,
    .normal-controls {
        position: sticky;
        top: 92px;
    }
}

@media (max-width: 900px) {
    .workspace {
        grid-template-columns: 1fr;
        grid-template-areas:
            "controls"
            "preview"
            "stage";
    }

    .palette-page {
        grid-template-areas:
            "controls"
            "stage"
            "preview";
    }

    .control-surface,
    .preview-panel {
        min-height: auto;
    }

    .normal-controls {
        min-height: auto;
        max-height: none;
        overflow: visible;
    }

    .preview-panel img {
        min-height: 340px;
    }

    .tool-form,
    .swatch-grid,
    .noise-workbench,
    .texture-workbench,
    .normal-workbench,
    .home-flow,
    .home-flow ol,
    .home-feature-grid,
    .tool-list {
        grid-template-columns: 1fr;
    }

    .home-hero {
        min-height: 420px;
    }

    .home-hero h1 {
        font-size: 4.2rem;
    }

    .stage-heading {
        align-items: start;
        flex-direction: column;
    }

    .noise-preview {
        min-height: auto;
    }

    .texture-preview-panel {
        min-height: 480px;
    }

    .pbr-preview {
        min-height: 440px;
    }

    .normal-map-output {
        grid-template-columns: 1fr;
    }

    .palette-page .palette-stage {
        min-height: auto;
    }

    .palette-page .swatch-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        height: auto;
    }

    .palette-page .swatch-card {
        grid-template-rows: minmax(220px, auto) auto;
        min-height: auto;
    }

    .palette-page .swatch-fill {
        min-height: 220px;
    }

    .palette-page .swatch-card:last-child {
        grid-column: 1 / -1;
    }

    .biome-pack-heading {
        align-items: start;
        flex-direction: column;
    }

    .biome-pack-heading > div:last-child {
        justify-items: start;
    }

    .biome-material-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .page-shell {
        padding: 10px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding-bottom: 18px;
    }

    .home-page .brand {
        width: 100%;
        min-height: 48px;
        box-shadow: 4px 4px 0 var(--ink);
    }

    .home-hero {
        min-height: 380px;
        padding: 22px;
    }

    .home-hero h1 {
        font-size: 2.8rem;
    }

    .home-hero p:not(.eyebrow) {
        font-size: 1.04rem;
    }

    .home-hero::after {
        right: 22px;
        bottom: 16px;
        width: 180px;
    }

    .home-actions a {
        width: 100%;
        justify-content: center;
    }

    .home-material-generator {
        margin-top: 22px;
    }

    .home-material-row {
        grid-template-columns: 1fr;
    }

    .home-material-row button {
        width: 100%;
    }

    .home-material-loader ol {
        grid-template-columns: 1fr;
    }

    .home-flow,
    .home-feature-grid {
        padding: 18px;
    }

    .control-surface,
    .palette-stage,
    .noise-tool,
    .texture-tool,
    .normal-tool {
        padding: 18px;
    }

    .seed-row,
    .toggle-grid,
    .pbr-source-summary,
    .pbr-source-summary dl,
    .texture-action-grid,
    .texture-output-actions,
    .texture-action-panel > div,
    .texture-action-panel-pbr > div,
    .packed-action-grid {
        grid-template-columns: 1fr;
    }

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

    .normal-map-output,
    .color-pick-row,
    .texture-library-copy dl,
    .texture-library-actions,
    .palette-page .swatch-grid {
        grid-template-columns: 1fr;
    }

    .palette-page .intro h1 {
        font-size: 1.9rem;
        line-height: 1;
    }

    .palette-page {
        gap: 8px;
    }

    .palette-page .control-surface {
        gap: 16px;
        padding: 14px;
    }

    .palette-page .intro p:not(.eyebrow) {
        display: none;
    }

    .palette-page .tool-form {
        gap: 10px;
    }

    .palette-page .tool-form input,
    .palette-page .tool-form select,
    .palette-page .tool-form button {
        min-height: 44px;
    }

    .palette-page .bias-panel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        padding: 10px;
    }

    .palette-page .bias-panel .control-row {
        gap: 4px;
    }

    .palette-page .bias-panel label {
        display: grid;
        gap: 2px;
        font-size: 0.82rem;
        line-height: 1.15;
    }

    .palette-prompt-list {
        display: none;
    }

    .palette-page .palette-stage {
        padding: 14px;
    }

    .palette-page .stage-heading {
        gap: 8px;
        margin-bottom: 12px;
    }

    .palette-page .stage-heading > p {
        display: none;
    }

    .palette-page .swatch-card:last-child {
        grid-column: auto;
    }

    .palette-page .swatch-card {
        grid-template-rows: minmax(180px, auto) auto;
    }

    .palette-page .swatch-fill {
        min-height: 180px;
    }

    .biome-pack {
        padding: 12px;
    }

    .biome-material {
        grid-template-columns: 42px minmax(0, 1fr);
        padding: 10px;
    }

    .material-settings {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .pbr-preview {
        min-height: 360px;
    }

    h1 {
        font-size: 2.45rem;
    }

    h2 {
        font-size: 1.6rem;
    }
}
