/* Match the 16px gap between Reset and the purchase action. */
.options > .reset {
    margin-left: 12px;
}

:root {
    color-scheme: light;
    font-family: system-ui, sans-serif;
    color: #252537;
    background: #f4f4f7;
    --surface: #ffffff;
    --muted: #656573;
    --toolbar: #F9F9FC;
    --line: #e9e9ef;
    --selected: #ededf2;
    --focus: #656573;
    --accent: #c03800;
}

* {
    box-sizing: border-box;
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    overflow: hidden;
}

button,
select,
summary,
a {
    -webkit-tap-highlight-color: transparent;
}

button,
select {
    font: inherit;
    color: inherit;
}

button,
summary,
select {
    cursor: pointer;
}

button,
a,
select,
summary {
    touch-action: manipulation;
}

button:disabled,
select:disabled {
    cursor: wait;
    opacity: 0.45;
}

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

[hidden] {
    display: none !important;
}

.toolbar {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    align-items: center;
    gap: 16px;
    flex: 0 0 auto;
    min-height: 54px;
    padding: 8px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--toolbar);
}

.identity {
    display: flex;
    align-items: baseline;
    gap: 9px;
    white-space: nowrap;
}

.identity h1 {
    margin: 0;
    font-family: system-ui, sans-serif;
    font-size: 22px;
    font-weight: 450;
    letter-spacing: -0.5px;
    line-height: 1;
}

.identity__byline {
    color: var(--muted);
    font-size: 11px;
}

.devices {
    display: flex;
    gap: 2px;
}

.toolbar-toggle {
    margin-left: 6px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    text-decoration: none;
}

.icon-button:hover,
.icon-button[aria-pressed='true'] {
    background: #fff;
}

.icon-button[aria-pressed='true'] {
    box-shadow: inset 0 -1px #b6b6b6;
}

.icon-button img {
    width: 17px;
    height: 17px;
}

.toolbar-toggle img {
    width: 16px;
    height: 16px;
}

.options {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
}

.buy-theme {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 7px 13px;
    border: 1px solid #252537;
    border-radius: 6px;
    background: #252537;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
    text-decoration: none;
    white-space: nowrap;
}

.buy-theme img {
    flex-shrink: 0;
    filter: invert(1);
}

.buy-theme:hover {
    border-color: #41414f;
    background: #41414f;
}

.animation-control {
    position: relative;
    flex-shrink: 0;
}

.animation-control select {
    width: 126px;
    height: 34px;
    padding: 0 28px 0 9px;
    border: 1px solid #ddd;
    border-radius: 6px;
    appearance: none;
    background: #fff;
    font-size: 12px;
}

.animation-control select:hover {
    background: #fff;
}

.animation-control option {
    background: var(--surface);
}

.animation-control > img {
    position: absolute;
    top: 9px;
    right: 8px;
    pointer-events: none;
}

.divider {
    height: 18px;
    margin-inline: 5px;
    border-left: 1px solid var(--line);
}

.stage {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.frame-shell {
    position: absolute;
    top: 0;
    left: 50%;
    overflow: hidden;
    background: var(--surface);
    transform: translateX(-50%);
}

.stage:not([data-device='desktop']) .frame-shell {
    border-radius: 10px;
    box-shadow: 0 0 0 1px #dcdce2, 0 12px 40px rgb(37 37 55 / 8%);
}

iframe {
    display: block;
    border: 0;
    background: var(--surface);
    transform-origin: top left;
}

.loading {
    position: absolute;
    right: 18px;
    bottom: 18px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    font-size: 12px;
    pointer-events: none;
}

.preview-error {
    position: absolute;
    top: 20px;
    left: 50%;
    width: min(420px, calc(100% - 32px));
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 8px 30px rgb(37 37 55 / 12%);
    font-size: 13px;
    transform: translateX(-50%);
}

.preview-error p {
    margin: 0 0 14px;
}

.preview-error button {
    margin-right: 12px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--selected);
}

.preview-error a {
    color: inherit;
}

.show-toolbar {
    position: fixed;
    z-index: 3;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    box-shadow: 0 2px 12px rgb(37 37 55 / 8%);
    font-size: 12px;
}

.no-script {
    position: fixed;
    inset: 100px 16px auto;
    text-align: center;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.appearance {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    width: 76px;
    height: 34px;
    padding: 3px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #eeeef2;
    isolation: isolate;
}

.appearance::before {
    position: absolute;
    z-index: -1;
    top: 3px;
    left: 3px;
    width: 34px;
    height: 26px;
    border-radius: 3px;
    background: #fff;
    box-shadow: 0 1px 3px rgb(37 37 55 / 10%);
    content: '';
    transform: translateX(0);
    transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.appearance:has([data-appearance='dark'][aria-pressed='true'])::before {
    transform: translateX(34px);
}

.appearance__button {
    display: inline-flex;
    flex: 0 0 34px;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
}

.appearance__button img {
    width: 17px;
    height: 17px;
    opacity: 0.55;
    transition: opacity 180ms ease;
}

.appearance__button[aria-pressed='true'] img,
.appearance__button:hover img {
    opacity: 1;
}

.appearance__button:disabled {
    cursor: wait;
}

@media (prefers-reduced-motion: reduce) {
    .appearance::before,
    .appearance__button img {
        transition: none;
    }
}

.grid-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.grid-style-control select {
    width: 120px;
}

@media (max-width: 900px) {
    .toolbar {
        grid-template-columns: 1fr auto auto;
        gap: 6px 12px;
        padding: 8px 12px;
    }

    .identity {
        grid-column: 1;
        grid-row: 1;
    }

    .devices {
        grid-column: 2;
        grid-row: 1;
    }

    .buy-theme {
        grid-column: 3;
        grid-row: 1;
    }

    .options {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: flex-start;
    }

    .options > .reset {
        margin-left: auto;
    }
}

@media (max-width: 600px) {
    .toolbar {
        grid-template-columns: 1fr auto;
        padding: 8px 10px;
    }

    .buy-theme {
        grid-column: 2;
        grid-row: 1;
    }

    .devices {
        grid-column: 1;
        grid-row: 2;
    }

    .options {
        display: contents;
    }

    .appearance {
        grid-column: 2;
        grid-row: 2;
        justify-self: end;
    }

    .grid-controls {
        grid-column: 1 / -1;
        grid-row: 3;
    }

    .grid-controls .animation-control {
        flex: 1;
        min-width: 0;
    }

    .grid-controls select {
        width: 100%;
    }

    .options > .divider,
    .options > .reset {
        display: none;
    }

    .identity__byline {
        display: none;
    }
}

@media (max-width: 350px) {
    .toolbar {
        column-gap: 6px;
    }

    .devices .icon-button {
        flex-basis: 30px;
        width: 30px;
    }

    .toolbar-toggle {
        margin-left: 0;
    }

}

/* Collapse the toolbar's layout space together with its slide animation. */
.toolbar-shell {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-rows: 1fr;
    flex: 0 0 auto;
    transition: grid-template-rows 280ms ease;
}

.toolbar-clip {
    min-height: 0;
}

.toolbar-shell .toolbar {
    transition: transform 280ms ease, opacity 280ms ease;
}

.toolbar-shell.is-collapsed {
    grid-template-rows: 0fr;
}

.toolbar-shell.is-collapsed .toolbar-clip {
    overflow: hidden;
}

.toolbar-shell.is-collapsed .toolbar {
    transform: translateY(-100%);
    opacity: 0;
}

.toolbar-toggle img,
.show-toolbar img {
    width: 16px;
    height: 16px;
}

@media (prefers-reduced-motion: reduce) {
    .toolbar-shell,
    .toolbar-shell .toolbar {
        transition: none;
    }
}

.palette-picker {
    position: relative;
    font-size: 12px;
}

.palette-picker summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 110px;
    min-height: 34px;
    padding: 6px 9px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    list-style: none;
}

.palette-picker summary::-webkit-details-marker {
    display: none;
}

.palette-picker[open] summary,
.palette-picker summary:hover {
    background: #fff;
}

.chevron {
    margin-left: auto;
}

.swatch {
    display: inline-block;
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    border: 1px solid rgb(0 0 0 / 12%);
    border-radius: 50%;
    background: var(--swatch, var(--accent));
}

.palette-panel {
    position: absolute;
    inset: calc(100% + 12px) 0 auto auto;
    width: 308px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 12px 40px rgb(37 37 55 / 12%);
}

.palette-panel fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.palette-panel legend {
    margin-bottom: 14px;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
}

.palette-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
}

.palette-option {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 12px 4px 9px;
    border: 1px solid transparent;
    border-radius: 7px;
    font-size: 11px;
    cursor: pointer;
}

.palette-option:hover {
    background: #f7f7f9;
}

.palette-option:has(input:checked) {
    border-color: #a3a3af;
    background: #f7f7f9;
}

.palette-option:has(input:focus-visible) {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.palette-option .swatch {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
}

.palette-option .swatch img {
    visibility: hidden;
    filter: invert(1);
}

.palette-option input:checked + .swatch img {
    visibility: visible;
}


.version-control {
    width: fit-content;
}

.version-control select {
    width: 76px;
}

.version-note {
    color: #686874;
    font-size: 11px;
    white-space: nowrap;
}

.appearance.is-unavailable .appearance__button {
    cursor: default;
}

.appearance.is-unavailable [data-appearance='dark'] img {
    opacity: 0.25;
}

.palette-panel {
    z-index: 5;
    width: min(308px, calc(100vw - 20px));
}

@media (max-width: 600px) {
    .palette-picker {
        grid-column: 1 / -1;
        grid-row: 3;
        justify-self: end;
    }

    .version-control {
        grid-column: 1;
        grid-row: 3;
    }

    .version-note {
        grid-column: 2;
        grid-row: 3;
        justify-self: end;
    }

    .toolbar:not(:has(.appearance)) .palette-picker {
        grid-column: 2;
        grid-row: 2;
    }
}

@media (max-width: 600px) {
    .toolbar:has(.version-control) .appearance,
    .toolbar:has(.palette-picker):has(.appearance) .appearance {
        grid-column: 2;
        grid-row: 3;
    }

    .toolbar:has(.appearance) .palette-picker {
        grid-column: 1;
        grid-row: 3;
        justify-self: start;
    }

    .toolbar:has(.appearance) .palette-panel {
        right: auto;
        left: 0;
    }

    .version-note {
        grid-column: 1 / -1;
        grid-row: 4;
    }
}

/* Keep the name, device controls and store action together on small screens. */
@media (max-width: 600px) {
    .toolbar {
        grid-template-columns: auto 1fr auto;
        column-gap: 6px;
        padding: 8px 10px;
    }

    .toolbar .identity {
        grid-column: 1;
        grid-row: 1;
    }

    .toolbar .identity h1 {
        font-size: 20px;
    }

    .toolbar .devices {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }

    .toolbar .devices .icon-button {
        flex-basis: 30px;
        width: 30px;
    }

    .toolbar .toolbar-toggle {
        margin-left: 2px;
    }

    .toolbar .buy-theme {
        grid-column: 3;
        grid-row: 1;
        padding-inline: 9px;
    }

    .toolbar .options {
        display: flex;
        grid-column: 1 / -1;
        grid-row: 2;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }

    .toolbar .options .appearance {
        margin-left: auto;
    }

    .toolbar .grid-controls {
        flex: 1;
        margin-right: 0;
    }

    .toolbar .options .palette-picker {
        flex: 0 1 auto;
    }

    .toolbar .options .palette-panel {
        right: auto;
        left: 0;
    }

    .toolbar .options .reset {
        display: none;
    }
}

@media (max-width: 380px) {
    .toolbar .buy-theme {
        gap: 0;
        width: 34px;
        padding-inline: 0;
        justify-content: center;
    }

    .toolbar .buy-theme span {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

/* The longer Nordic Wall name needs the icon-only action a little earlier. */
@media (max-width: 440px) {
    .toolbar .buy-theme[href*='/nordicwall/'] {
        gap: 0;
        width: 34px;
        padding-inline: 0;
        justify-content: center;
    }

    .toolbar .buy-theme[href*='/nordicwall/'] span {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

.palette-option .swatch img {
    filter: none;
}

.palette-option .swatch--dark img {
    filter: invert(1);
}

.palette-picker summary {
    max-width: 198px;
}

#current-palette {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.palette-picker[aria-disabled='true'] summary {
    color: #777780;
    cursor: default;
}

.palette-picker[aria-disabled='true'] .swatch {
    opacity: 0.45;
}

.palette-panel {
    max-height: min(520px, calc(100dvh - 110px));
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Changelog's name needs the compact store action earlier. */
@media (max-width: 480px) {
    .buy-theme[href*='/changelog/'] {
        justify-content: center;
        width: 34px;
        padding-inline: 0;
        gap: 0;
    }

    .buy-theme[href*='/changelog/'] span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

@media (max-width: 380px) {
    .toolbar .options {
        gap: 6px;
    }

    .palette-picker summary {
        min-width: 100px;
    }

}


.layout-control {
    flex: 0 0 auto;
}

.layout-control select {
    width: 98px;
    min-height: 34px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #292933;
    font: inherit;
    font-size: 12px;
}

.layout-control select:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
}

@media (max-width: 600px) {
    .options:has(.layout-control) .palette-picker {
        flex: 1 1 0;
        min-width: 0;
        position: static;
    }

    .options:has(.layout-control) {
        position: relative;
    }

    .options:has(.layout-control) .palette-picker summary {
        min-width: 0;
    }

    .options:has(.layout-control) .appearance {
        flex: 0 0 76px;
    }
}


.palette-grid:has(> :nth-child(8)) {
    grid-template-columns: repeat(4, 1fr);
}

.grid-panel {
    width: min(280px, calc(100vw - 20px));
}

.grid-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.grid-choices label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 7px;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
}

.grid-choices label:has(input:checked) {
    background: #f7f7f9;
    border-color: #a3a3af;
}

.grid-choices input {
    margin: 0;
    accent-color: #55555f;
}

.columns-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
}

.columns-control select {
    width: 76px;
    min-height: 34px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
}

#columns-note {
    margin: 10px 0 0;
    color: #64646f;
    font-size: 11px;
    line-height: 1.5;
}

#current-grid {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.grid-picker summary[aria-disabled='true'] {
    opacity: 0.55;
    cursor: default;
}

@media (max-width: 600px) {
    #alignment {
        width: 92px;
    }
}


/* Quiet, consistent controls for Changelog's native layout options. */
#layout-picker {
    flex: 0 0 108px;
}

#layout-trigger {
    min-width: 108px;
    padding-inline: 12px;
    gap: 14px;
}

#layout-trigger .chevron {
    flex: 0 0 16px;
    opacity: 0.6;
}

.layout-panel {
    inset-inline: 0 auto;
    width: 168px;
    padding: 6px;
    border-color: #e2e2e8;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgb(30 30 45 / 3%), 0 12px 32px rgb(30 30 45 / 8%);
}

.layout-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 38px;
    padding: 9px 11px;
    border-radius: 6px;
    color: #454550;
    cursor: pointer;
}

.layout-option img {
    opacity: 0;
}

.layout-option:has(input:checked) {
    background: #f0f0f5;
    color: #292933;
}

.layout-option:has(input:checked) img {
    opacity: 0.65;
}

@media (hover: hover) {
    .layout-option:hover {
        background: #f6f6f9;
    }

    .layout-option:has(input:checked):hover {
        background: #ededf3;
    }
}

.toolbar:has(#layout-picker) .palette-picker summary:focus-visible,
.layout-option:has(input:focus-visible),
.toolbar:has(#layout-picker) .palette-option:has(input:focus-visible) {
    outline: 2px solid #7c8da6;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgb(136 164 207 / 12%);
}

.toolbar:has(#layout-picker) .palette-option {
    text-align: center;
    line-height: 1.4;
}

.toolbar:has(#layout-picker) .palette-option > span:last-child {
    width: 100%;
    text-align: center;
    text-wrap: balance;
}

.toolbar:has(#layout-picker) .palette-option:has(input:checked) {
    border-color: #d6d6df;
    background: #f4f4f8;
}

@media (max-width: 600px) {
    .options:has(#layout-picker) #layout-picker {
        flex: 0 0 100px;
    }

    #layout-trigger {
        min-width: 100px;
        gap: 8px;
    }
}
