@font-face {
    font-family: LayRunMono;
    src: url('/fonts/DejaVuSansMono.ttf') format('truetype');
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

:root {
    color-scheme: light;

    --bg: #f7f8fa;
    --surface: #ffffff;
    --surface-soft: #f3f5f8;
    --line: #e3e7ed;
    --line-strong: #cdd4df;
    --accent: #315bdb;
    --accent-hover: #2548b8;
    --accent-soft: #edf2ff;
    --text: #202632;
    --muted: #647083;
    --danger: #b42335;
    --danger-soft: #fff2f3;
    --success: #248165;
    --radius: 18px;
    --shadow: 0 4px 24px rgba(24, 39, 66, 0.035);

    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 280px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a,
input,
select,
summary {
    -webkit-tap-highlight-color: transparent;
}

button,
a,
input,
select,
textarea,
summary {
    transition:
        background-color 160ms ease,
        border-color 160ms ease,
        color 160ms ease,
        box-shadow 160ms ease;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    color: var(--accent);
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: wait;
    opacity: 0.6;
}

input:disabled,
select:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    background-color: var(--surface-soft);
}

:where(button, a, input, select, textarea, summary):focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

::selection {
    background: #dce6ff;
    color: #19284f;
}

[hidden] {
    display: none !important;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2,
h3 {
    color: var(--text);
}

h1 {
    margin-bottom: 16px;
    font-size: clamp(32px, 4vw, 48px);
    line-height: 1.15;
    letter-spacing: -1.8px;
    font-weight: 700;
}

h2 {
    font-size: 17px;
    line-height: 1.4;
    letter-spacing: -0.35px;
    font-weight: 650;
}

h3 {
    font-size: 13px;
    line-height: 1.5;
    font-weight: 650;
}

p {
    line-height: 1.65;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    transform: translateY(-180%);
    border-radius: 8px;
    padding: 12px 16px;
    color: #ffffff;
    background: var(--accent);
}

.skip-link:focus {
    transform: translateY(0);
    color: #ffffff;
}

.site-header {
    width: 100%;
    min-height: 80px;
    padding: 20px max(28px, calc((100vw - 1240px) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    color: var(--text);
    font-size: 23px;
    line-height: 1;
    font-weight: 750;
    letter-spacing: -0.9px;
}

.brand:hover {
    color: var(--text);
    text-decoration: none;
}

.brand img {
    display: block;
    flex-shrink: 0;
    border-radius: 8px;
}

.brand-tag {
    margin-left: 12px;
    padding-left: 22px;
    border-left: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1.5;
}

.header-note {
    color: var(--muted);
    font-size: 12px;
    text-align: right;
}

.studio {
    width: 100%;
    max-width: 1296px;
    margin: 0 auto;
    padding: 48px 28px 64px;
    flex: 1;
}

.intro {
    max-width: 780px;
    margin-bottom: 34px;
}

.eyebrow {
    margin-bottom: 13px;
    color: var(--accent);
    font-size: 10px;
    line-height: 1.5;
    font-weight: 750;
    letter-spacing: 1.8px;
}

.intro h1 span {
    color: var(--muted);
}

.intro > p:last-child {
    max-width: 620px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 15px;
}

.mobile-break {
    display: none;
}

.workspace {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.settings {
    min-width: 0;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 23px;
}

.section-heading h2 {
    margin: 0;
}

.text-button {
    min-height: 36px;
    padding: 7px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 550;
}

.text-button:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.setting-section + .setting-section {
    margin-top: 22px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.setting-section h3 {
    margin: 0 0 17px;
}

label {
    display: block;
    margin-bottom: 14px;
    color: #414b5b;
    font-size: 12px;
    font-weight: 550;
    line-height: 1.5;
}

.label-unit {
    margin-left: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 400;
}

input:not([type="range"], [type="checkbox"], [type="radio"], [type="color"]),
select,
textarea {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    margin-top: 7px;
    padding: 11px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(24, 39, 66, 0.025);
}

input:not([type="range"], [type="checkbox"], [type="radio"], [type="color"]):hover,
select:hover,
textarea:hover {
    border-color: #aeb8c7;
}

input:not([type="range"], [type="checkbox"], [type="radio"], [type="color"]):focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(49, 91, 219, 0.1);
}

input::placeholder,
textarea::placeholder {
    color: #7d8796;
    opacity: 1;
}

select {
    appearance: none;
    padding-right: 35px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23647083' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    background-size: 16px;
    cursor: pointer;
}

#type {
    margin-top: -7px;
}

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
}

.two-col > * {
    min-width: 0;
}

.hint {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 400;
    line-height: 1.65;
}

.field-help {
    margin-top: 9px;
    margin-bottom: 18px;
}

.setting-section > :last-child {
    margin-bottom: 0;
}

.color-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 46px;
    margin-top: 0;
    padding: 7px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: var(--surface);
}

.color-field:hover {
    border-color: #aeb8c7;
}

input[type="color"] {
    flex-shrink: 0;
    width: 42px;
    height: 30px;
    padding: 3px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: var(--surface);
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 0;
    border-radius: 4px;
}

input[type="color"]::-moz-color-swatch {
    border: 0;
    border-radius: 4px;
}

.check-field {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 36px;
    margin-bottom: 0;
    cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
    flex-shrink: 0;
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
}

.primary-button {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 2px 3px rgba(49, 91, 219, 0.1);
}

.primary-button:hover:not(:disabled) {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
    color: #ffffff;
    text-decoration: none;
}

.primary-button:active:not(:disabled) {
    box-shadow: none;
}

.secondary-button {
    border-color: var(--line-strong);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(24, 39, 66, 0.025);
}

.secondary-button:hover:not(:disabled) {
    border-color: #aeb8c7;
    background: var(--surface-soft);
    color: var(--text);
    text-decoration: none;
}

.export-actions {
    margin-top: 22px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

#export {
    width: 100%;
    min-height: 48px;
}

#export span {
    font-size: 18px;
    line-height: 1;
}

.export-hint {
    margin: 11px 0 0;
    text-align: center;
}

.form-status {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.form-status:empty {
    display: none;
}

.form-status.error {
    background: var(--danger-soft);
    color: var(--danger);
}

.preview-panel {
    position: sticky;
    top: 24px;
    min-width: 0;
}

.preview-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 70px;
    padding: 18px 22px;
}

.preview-header h2 {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
}

.dot {
    display: inline-block;
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
}

.canvas-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    height: clamp(300px, 34vw, 460px);
    min-width: 0;
    overflow: hidden;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

/* A neutral, darker preview keeps white transparent overlays visible. */
.checker {
    background-color: #707985;
    background-image:
        linear-gradient(45deg, #78818d 25%, transparent 25%),
        linear-gradient(-45deg, #78818d 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #78818d 75%),
        linear-gradient(-45deg, transparent 75%, #78818d 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.canvas-stage canvas {
    display: block;
    flex: 0 1 auto;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.transport {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 17px 22px;
}

.transport button {
    flex-shrink: 0;
    min-width: 72px;
    min-height: 40px;
    padding: 8px 13px;
    font-size: 12px;
}

.transport input[type="range"] {
    flex: 1;
    width: 100%;
    min-width: 0;
    height: 28px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.transport output {
    flex-shrink: 0;
    color: var(--muted);
    font-family: LayRunMono, monospace;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.preview-notes {
    padding: 16px 4px 0;
    color: var(--muted);
    font-size: 12px;
}

.preview-notes p {
    margin-bottom: 0;
}

.preview-help {
    margin-top: 15px;
    padding: 0 4px;
    color: var(--muted);
    font-size: 12px;
}

.preview-help summary {
    width: fit-content;
    padding: 6px 0;
    border-radius: 3px;
    color: #465267;
    font-weight: 550;
    cursor: pointer;
}

.preview-help summary:hover {
    color: var(--accent);
}

.preview-help > div {
    max-width: 620px;
    padding-top: 8px;
}

.preview-help p {
    margin-bottom: 9px;
}

.last-result {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    margin-top: 15px;
    padding: 7px 4px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 550;
}

.last-result:hover {
    color: var(--accent-hover);
    text-decoration: underline;
    text-underline-offset: 4px;
}

footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: calc(100% - 56px);
    max-width: 1240px;
    margin: auto auto 0;
    padding: 24px 0;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

footer nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
}

footer nav a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
}

footer nav a[aria-current="page"] {
    color: var(--text);
}

.error-box {
    margin-top: 20px;
    padding: 16px 18px;
    border: 1px solid #f0c8ce;
    border-radius: 10px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.error-box a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 1050px) {
    .workspace {
        grid-template-columns: 330px minmax(0, 1fr);
        gap: 20px;
    }

    .settings {
        padding: 21px;
    }

    .brand-tag {
        display: none;
    }

    .preview-header,
    .transport {
        padding-left: 17px;
        padding-right: 17px;
    }

    .transport {
        flex-wrap: wrap;
        gap: 12px;
    }

    .transport output {
        width: 100%;
        text-align: right;
    }
}

@media (max-width: 760px) {
    .site-header {
        min-height: 72px;
        padding: 18px 22px;
    }

    .studio {
        padding: 34px 22px 44px;
    }

    .intro {
        margin-bottom: 26px;
    }

    .intro h1 {
        font-size: clamp(30px, 6vw, 42px);
        letter-spacing: -1.2px;
    }

    .intro > p:last-child {
        max-width: 540px;
        font-size: 14px;
    }

    .workspace {
        grid-template-columns: minmax(0, 1fr);
        gap: 26px;
    }

    .preview-panel {
        position: static;
        grid-row: 1;
    }

    .canvas-stage {
        height: clamp(220px, 48vw, 360px);
    }

    .transport {
        flex-wrap: nowrap;
    }

    .transport output {
        width: auto;
    }

    .settings {
        padding: 24px;
    }

    input:not([type="range"], [type="checkbox"], [type="radio"], [type="color"]),
    select,
    textarea {
        font-size: 16px;
    }

    footer {
        width: calc(100% - 44px);
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .site-header {
        gap: 14px;
        padding: 16px;
    }

    .brand {
        font-size: 22px;
    }

    .header-note {
        max-width: 120px;
        font-size: 10px;
    }

    .studio {
        padding: 28px 16px 36px;
    }

    .mobile-break {
        display: block;
    }

    .eyebrow {
        font-size: 9px;
        letter-spacing: 1.5px;
    }

    .settings {
        padding: 20px;
        border-radius: 14px;
    }

    .preview-card {
        border-radius: 14px;
    }

    .preview-header {
        padding: 15px;
    }

    .preview-header h2 {
        font-size: 12px;
    }

    .pill {
        padding: 5px 7px;
        font-size: 9px;
    }

    .transport {
        flex-wrap: wrap;
        padding: 14px 15px;
        gap: 10px;
    }

    .transport output {
        width: 100%;
        text-align: right;
    }

    .two-col {
        gap: 10px;
    }

    .color-field {
        gap: 6px;
        padding-left: 10px;
        padding-right: 8px;
    }

    footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        width: calc(100% - 32px);
        padding: 20px 0;
    }
}

@media (max-width: 340px) {
    .two-col {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .header-note {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}