:root {
    --window-size: min(88vw, 420px);
    --page-max: 1180px;
    --stone-dark: #2f302d;
    --stone-mid: #817d72;
    --stone-light: #c8c1b1;
    --slot-bg: #ece5d5;
    --slot-border: #5a554b;
    --amethyst: #8758c7;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: #161713;
    color: #f7f2e8;
    font-family: Arial, Helvetica, sans-serif;
}

button {
    font: inherit;
}

.site-frame {
    min-height: 100svh;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.site-header,
.site-footer {
    width: min(100%, var(--page-max));
    margin: 0 auto;
}

.site-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 0;
}

.brand-mark {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 9px;
    align-self: center;
    color: #f7f2e8;
    text-decoration: none;
}

.brand-logo {
    width: clamp(34px, 8vw, 46px);
    height: clamp(34px, 8vw, 46px);
    object-fit: contain;
    image-rendering: pixelated;
}

.brand-name {
    overflow: hidden;
    font-size: clamp(17px, 5vw, 24px);
    font-weight: 700;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-controls {
    display: grid;
    justify-items: end;
    gap: 8px;
}

.control-window {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    max-width: min(100%, 720px);
    padding: 6px;
    background: #24251f;
    border: 3px solid var(--stone-dark);
    box-shadow: inset 0 0 0 2px #3c3c34;
}

.control-button-form {
    margin: 0;
}

.control-button {
    display: inline-grid;
    min-width: 42px;
    min-height: 34px;
    place-items: center;
    padding: 7px 9px;
    cursor: pointer;
    color: #f7f2e8;
    text-decoration: none;
    background: #262821;
    border: 2px solid #5c5f52;
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
}

.control-button:hover,
.control-button:focus-visible,
.control-button.is-active {
    outline: none;
    border-color: var(--amethyst);
}

.travel-window {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
}

.house-window {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    justify-content: end;
}

.house-window .control-button-form,
.travel-window .control-button-form {
    display: contents;
}

.house-window .control-button,
.travel-window .control-button {
    width: 100%;
}

.site-body {
    display: flex;
    justify-content: center;
}

.page-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: clamp(16px, 3vh, 28px);
    width: min(100%, var(--page-max));
    min-height: 100%;
    padding: 28px 16px;
}

.body-signpost {
    display: flex;
    width: 100%;
    justify-content: center;
    margin-top: auto;
}

.body-signpost .signpost-window {
    flex-wrap: nowrap;
    justify-content: center;
}

@media (max-width: 520px) {
    .brand-mark {
        flex-direction: column;
        justify-content: center;
        gap: 4px;
    }

    .brand-logo {
        width: 32px;
        height: 32px;
    }

    .brand-name {
        max-width: 74px;
        font-size: 12px;
        line-height: 1.1;
        text-align: center;
        white-space: normal;
    }

    .control-button {
        min-width: 0;
        min-height: 32px;
        padding: 6px 7px;
        font-size: 12px;
    }
}

.crafting-window,
.placeholder-menu-window {
    width: var(--window-size);
    aspect-ratio: 1 / 1;
}

.crafting-window {
    padding: clamp(10px, 2.4vw, 18px);
    background: var(--stone-light);
    border: 4px solid var(--stone-dark);
    box-shadow:
        inset 0 0 0 4px var(--stone-mid),
        0 18px 40px rgb(0 0 0 / 35%);
}

.crafting-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: clamp(6px, 1.8vw, 12px);
    width: 100%;
    height: 100%;
}

.crafting-slot {
    min-width: 0;
    min-height: 0;
    margin: 0;
}

.slot-button {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    background: var(--slot-bg);
    border: 3px solid var(--slot-border);
    color: #3b372f;
}

.slot-button:hover,
.slot-button:focus-visible,
.slot-button.is-active {
    outline: none;
    border-color: var(--amethyst);
    box-shadow: inset 0 0 0 3px rgb(135 88 199 / 35%);
}

.slot-label {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    text-align: center;
    font-size: clamp(10px, 2.4vw, 13px);
    line-height: 1.15;
}

.slot-image {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.placeholder-menu-window {
    display: grid;
    place-items: center;
    padding: clamp(18px, 4vw, 34px);
    background: #24251f;
    border: 4px solid var(--stone-dark);
    box-shadow:
        inset 0 0 0 4px #3c3c34,
        0 18px 40px rgb(0 0 0 / 28%);
}

.placeholder-menu-window h2 {
    margin: 0;
    text-align: center;
}

.service-content-panel {
    width: min(100%, var(--page-max));
    min-height: clamp(220px, 34vh, 360px);
    padding: clamp(22px, 5vw, 46px) 0;
}

.service-content-panel h1 {
    margin: 0 0 12px;
    font-size: clamp(28px, 7vw, 52px);
    line-height: 1.05;
}

.service-content-panel p {
    margin: 0;
    max-width: 62ch;
    color: #ddd5c8;
    font-size: clamp(16px, 3.4vw, 20px);
    line-height: 1.5;
}

.service-content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 26px;
}

.service-content-grid article {
    padding-top: 14px;
    border-top: 2px solid #3c3c34;
}

.service-content-grid h2 {
    margin: 0 0 6px;
    font-size: 18px;
    line-height: 1.2;
}

.service-content-grid p {
    font-size: 15px;
}

.site-footer {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 12px 18px;
}

.footer-panel {
    min-height: 96px;
    padding: 14px;
    background: #24251f;
    border: 3px solid var(--stone-dark);
    box-shadow: inset 0 0 0 3px #3c3c34;
}

.footer-panel h2 {
    margin: 0 0 8px;
    font-size: 17px;
    line-height: 1.15;
}

.footer-panel p {
    margin: 0;
    color: #ddd5c8;
    font-size: 14px;
    line-height: 1.4;
}

.utility-page {
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
}

.public-program-page {
    min-height: 100svh;
    padding: 24px 16px;
}

.public-program-shell {
    display: grid;
    gap: 18px;
    width: min(100%, 860px);
    margin: 0 auto;
}

.program-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.program-panel {
    padding: clamp(18px, 5vw, 36px);
    background: #24251f;
    border: 4px solid var(--stone-dark);
    box-shadow:
        inset 0 0 0 4px #3c3c34,
        0 18px 40px rgb(0 0 0 / 28%);
}

.program-panel h1,
.program-panel h2 {
    margin: 0 0 12px;
    line-height: 1.1;
}

.program-panel p {
    margin: 0 0 12px;
    color: #ddd5c8;
    line-height: 1.5;
}

.program-eyebrow {
    color: #f7f2e8;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.justyou-space-document,
.justyou-space-page {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #102617;
}

.justyou-space-page {
    min-height: 100svh;
}

.justyou-space-grid {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: #102617;
    cursor: default;
    touch-action: none;
    user-select: none;
}

.justyou-space-grid::before {
    position: fixed;
    inset: 0;
    content: "";
    pointer-events: none;
    background:
        linear-gradient(rgb(255 255 255 / 2%), transparent 46%),
        radial-gradient(circle at 50% 50%, rgb(0 0 0 / 0%), rgb(0 0 0 / 18%));
}

.justyou-space-grid.is-panning {
    cursor: grabbing;
}

.justyou-tile {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    margin: 0;
    padding: 0;
    overflow: hidden;
    cursor: zoom-in;
    background: #18381f;
    border: 0;
    outline: 0;
    transform: translate(var(--justyou-pan-x, 0), var(--justyou-pan-y, 0));
    transform-origin: 0 0;
    will-change: transform;
}

.justyou-tile img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    -webkit-user-drag: none;
}

.justyou-photo-modal[hidden] {
    display: none;
}

.justyou-photo-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgb(0 0 0 / 82%);
}

.justyou-photo-modal__image {
    display: block;
    max-width: min(96vw, 1480px);
    max-height: 92svh;
    object-fit: contain;
    box-shadow: 0 20px 70px rgb(0 0 0 / 55%);
}

.justyou-photo-modal__close {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 21;
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    cursor: pointer;
    color: #f7f2e8;
    background: rgb(22 23 19 / 86%);
    border: 2px solid #5c5f52;
    font-size: 30px;
    line-height: 1;
}

.justyou-photo-modal__close:hover,
.justyou-photo-modal__close:focus-visible {
    outline: none;
    border-color: var(--amethyst);
}

.upload-form {
    display: grid;
    gap: 12px;
}

.upload-form label {
    display: grid;
    gap: 8px;
    color: #ddd5c8;
    font-size: 14px;
}

.upload-form input[type="file"] {
    width: 100%;
    padding: 10px;
    color: #f7f2e8;
    background: #161713;
    border: 2px solid #5c5f52;
}

.upload-message {
    padding: 10px 12px;
    border: 2px solid #5c5f52;
}

.upload-message--success {
    color: #ddffd8;
    border-color: #5b8f5b;
}

.upload-message--error {
    color: #ffd1d1;
    border-color: #9a5b5b;
}

.simple-page {
    font-size: 24px;
}

.admin-shell {
    width: min(100%, 760px);
}

.admin-language-form {
    display: flex;
    justify-content: flex-end;
    margin: 0;
}

.admin-panel {
    width: min(100%, 420px);
    margin: 0 auto;
    padding: 22px;
    background: #24251f;
    border: 4px solid var(--stone-dark);
    box-shadow:
        inset 0 0 0 4px #3c3c34,
        0 18px 40px rgb(0 0 0 / 28%);
}

.admin-panel--wide {
    width: min(100%, 760px);
}

.admin-panel h1,
.admin-panel h2 {
    margin: 0 0 12px;
    line-height: 1.1;
}

.admin-note,
.role-list p {
    margin: 0 0 18px;
    color: #ddd5c8;
    line-height: 1.5;
}

.form-error {
    margin: 0 0 14px;
    color: #ffd1d1;
}

.login-form,
.editor-block {
    display: grid;
    gap: 12px;
}

.login-form label,
.editor-block {
    color: #ddd5c8;
    font-size: 14px;
}

.login-form input[type="text"],
.login-form input[type="password"],
.editor-block textarea {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    color: #f7f2e8;
    background: #161713;
    border: 2px solid #5c5f52;
}

.editor-block textarea {
    resize: vertical;
}

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

.check-row input {
    margin: 0;
}

.primary-button,
.secondary-button {
    display: inline-grid;
    place-items: center;
    min-height: 40px;
    padding: 9px 14px;
    cursor: pointer;
    color: #f7f2e8;
    text-decoration: none;
    background: #262821;
    border: 2px solid #5c5f52;
}

.primary-button:hover,
.primary-button:focus-visible,
.secondary-button:hover,
.secondary-button:focus-visible {
    outline: none;
    border-color: var(--amethyst);
}

.admin-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.storage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.storage-grid a {
    display: grid;
    min-height: 64px;
    place-items: center;
    color: #3b372f;
    text-decoration: none;
    background: var(--slot-bg);
    border: 3px solid var(--slot-border);
}

.storage-grid a:hover,
.storage-grid a:focus-visible {
    outline: none;
    border-color: var(--amethyst);
}

.role-list {
    margin-top: 18px;
}

.admin-page-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.admin-page-nav--chest {
    width: min(100%, 760px);
    margin: 0 auto 10px;
}

.inline-action {
    width: fit-content;
}

.picture-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.laboratory-page {
    place-items: start center;
}

.laboratory-shell {
    width: min(100%, var(--page-max));
    display: grid;
    gap: 28px;
}

.laboratory-intro h1,
.laboratory-section h2 {
    margin: 0 0 10px;
}

.laboratory-intro p {
    margin: 0;
    color: #ddd5c8;
    line-height: 1.5;
}

.laboratory-section {
    display: grid;
    gap: 14px;
}

.laboratory-control-row,
.laboratory-window-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.laboratory-item {
    display: grid;
    justify-items: center;
    gap: 8px;
    width: min(100%, var(--page-max));
}

.code-label,
.code-list p {
    margin: 0;
    color: #ddd5c8;
    font-size: 13px;
    line-height: 1.4;
}

.code-label code,
.code-list code,
.note-list code {
    color: #f7f2e8;
}

.code-list {
    display: grid;
    gap: 8px;
}

.code-list p {
    display: grid;
    gap: 3px;
    padding: 8px 0;
    border-bottom: 1px solid #3c3c34;
}

.laboratory-footer-preview {
    width: 100%;
    padding: 0;
}

.note-list {
    display: grid;
    gap: 12px;
}

.note-list article {
    padding-top: 12px;
    border-top: 2px solid #3c3c34;
}

.note-list h3 {
    margin: 0 0 6px;
    font-size: 15px;
    line-height: 1.25;
}

.note-list p {
    margin: 0;
    color: #ddd5c8;
    font-size: 14px;
    line-height: 1.45;
}

.keyword-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.keyword-grid p {
    display: grid;
    gap: 3px;
    margin: 0;
    padding: 10px;
    background: #161713;
    border: 2px solid #3c3c34;
}

.keyword-grid span {
    color: #ddd5c8;
    font-size: 13px;
}

.keyword-grid strong {
    font-size: 15px;
}

.media-review-toolbar,
.media-review-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.media-review-toolbar p {
    margin: 0;
    color: #ddd5c8;
}

.media-review-frame {
    display: grid;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin: 14px 0;
    place-items: center;
    overflow: hidden;
    background: #161713;
    border: 3px solid #3c3c34;
}

.media-review-frame img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: auto;
}

.media-review-actions {
    justify-content: flex-end;
}

.media-review-frame--cover img {
    object-fit: cover;
}

.media-review-status {
    margin: 10px 0 0;
    color: #ddd5c8;
    font-size: 14px;
    line-height: 1.4;
}

.media-review-status strong {
    color: #f7f2e8;
}

.media-metadata {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.media-metadata h2 {
    margin: 0;
}

.media-metadata p {
    display: grid;
    gap: 3px;
    margin: 0;
    padding-top: 8px;
    color: #ddd5c8;
    border-top: 1px solid #3c3c34;
}

.media-metadata strong,
.media-metadata code {
    color: #f7f2e8;
    font-weight: 700;
}

@media (min-width: 900px) {
    :root {
        --window-size: min(40vw, 520px);
    }

    .page-shell {
        padding-top: 36px;
        padding-bottom: 36px;
    }

    .slot-label {
        font-size: 13px;
    }

    .site-header {
        padding: 12px 0;
    }

    .site-footer {
        grid-template-columns: repeat(3, 1fr);
        padding: 18px;
    }

    .service-content-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .laboratory-control-row {
        align-items: flex-start;
    }
}
