html {
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #f4f4f5;
    color: #18181b;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: #4338ca;
}

.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;
}

.skip {
    position: absolute;
    left: 1rem;
    top: 1rem;
    z-index: 60;
    transform: translateY(-150%);
    background: white;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: #18181b;
    text-decoration: none;
    box-shadow: 0 8px 24px rgb(9 9 11 / 0.12);
}

.skip:focus {
    transform: none;
}

h1 {
    margin: 0.35rem 0 0;
    font-size: 1.875rem;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.eyebrow {
    margin: 0;
    color: #4f46e5;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.lede {
    margin: 0.5rem 0 0;
    max-width: 40rem;
    color: #71717a;
    line-height: 1.6;
}

.hint {
    margin: 0.75rem 0 0;
    color: #71717a;
    font-size: 0.8125rem;
    line-height: 1.5;
}

.shell {
    min-height: 100vh;
}

.side {
    background: #09090b;
    color: #f4f4f5;
}

.brand-row {
    display: flex;
    align-items: center;
}

.brand {
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    color: inherit;
    text-decoration: none;
}

.brand-text {
    min-width: 0;
}

.brand-text strong,
.brand-text small {
    display: block;
}

.brand-text strong {
    font-size: 0.875rem;
    letter-spacing: -0.01em;
}

.brand-text small {
    color: #a1a1aa;
    font-size: 0.75rem;
}

.mark {
    display: grid;
    width: 2.25rem;
    height: 2.25rem;
    flex: none;
    place-items: center;
    border-radius: 0.75rem;
    background: #6366f1;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
}

.menu-button {
    display: grid;
    width: 2.5rem;
    height: 2.5rem;
    margin-right: 0.75rem;
    place-items: center;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: white;
    cursor: pointer;
}

.menu-button svg {
    width: 1.5rem;
    height: 1.5rem;
}

.menu-button:hover {
    background: rgb(255 255 255 / 0.1);
}

.user-chip {
    margin: 0 0.75rem 0.5rem;
    padding: 0.55rem 0.75rem;
    border-radius: 0.75rem;
    background: rgb(255 255 255 / 0.05);
}

.user-chip strong,
.user-chip small {
    display: block;
}

.user-chip strong {
    overflow: hidden;
    font-size: 0.875rem;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip small {
    color: #a1a1aa;
    font-size: 0.75rem;
}

.side-nav,
.side-foot {
    display: none;
}

.nav-link {
    display: block;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: #a1a1aa;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
    background: rgb(255 255 255 / 0.1);
    color: white;
}

.sign-out {
    width: 100%;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: #a1a1aa;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}

.sign-out:hover {
    background: rgb(255 255 255 / 0.05);
    color: white;
}

.user-chip .sign-out {
    width: auto;
    margin-top: 0.45rem;
    border: 1px solid rgb(255 255 255 / 0.2);
    padding: 0.3rem 0.7rem;
    color: white;
}

.main-col {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

main {
    width: min(100% - 2rem, 72rem);
    margin: 0 auto;
    flex: 1;
    padding: 1.5rem 0 2rem;
}

main.wide {
    width: min(100% - 2rem, 100%);
}

.foot {
    padding: 0 1rem 1.25rem;
    color: #71717a;
    font-size: 0.75rem;
}

.foot-inner {
    width: min(100%, 72rem);
    margin: 0 auto;
}

.shell:has(main.wide) .foot-inner {
    width: min(100%, 100%);
}

.menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    overflow: auto;
    background: #09090b;
    color: #f4f4f5;
}

.menu-sheet {
    display: flex;
    min-height: 100%;
    max-width: 28rem;
    margin: 0 auto;
    flex-direction: column;
    padding: 1rem;
}

.menu-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.menu-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.menu-sign-out {
    margin-top: auto;
}

.login {
    display: grid;
    min-height: 100vh;
    background: #f4f4f5;
}

.login-hero {
    position: relative;
    overflow: hidden;
    background: #09090b;
    color: white;
    padding: 2.5rem 1.5rem;
}

.login-hero::before,
.login-hero::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(48px);
}

.login-hero::before {
    top: 2rem;
    left: -4rem;
    width: 20rem;
    height: 20rem;
    background: rgb(99 102 241 / 0.3);
}

.login-hero::after {
    right: 0;
    bottom: 0;
    width: 18rem;
    height: 18rem;
    background: rgb(56 189 248 / 0.12);
}

.login-hero-inner {
    position: relative;
    z-index: 1;
}

.login-hero .brand {
    padding: 0;
}

.login-hero .eyebrow {
    margin-top: 3rem;
    color: #a5b4fc;
}

.login-hero h1 {
    max-width: 12ch;
    font-size: clamp(2.25rem, 5vw, 3rem);
}

.login-hero p {
    max-width: 28rem;
    color: #a1a1aa;
    line-height: 1.7;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
}

.login-card {
    width: min(100%, 28rem);
}

.page-head {
    margin-bottom: 0.5rem;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.tiles {
    display: grid;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.tile {
    display: block;
    padding: 1rem 1.1rem;
    border: 1px solid #e4e4e7;
    border-radius: 1rem;
    background: white;
    color: inherit;
    text-decoration: none;
    box-shadow: 0 1px 2px rgb(9 9 11 / 0.04);
}

.tile:hover {
    border-color: #c7d2fe;
}

.tile strong,
.tile span {
    display: block;
}

.tile span {
    margin-top: 0.25rem;
    color: #71717a;
    font-size: 0.875rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.5rem;
    margin: 1rem 0;
}

.toolbar .field {
    min-width: 12rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field > span,
.check > span {
    color: #3f3f46;
    font-size: 0.875rem;
    font-weight: 500;
}

input:not([type="checkbox"]):not([type="hidden"]),
select,
textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #e4e4e7;
    border-radius: 0.5rem;
    background: white;
    color: #18181b;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    box-shadow: 0 1px 2px rgb(9 9 11 / 0.04);
}

select {
    appearance: none;
    padding-right: 2.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20' stroke='%2371717a' stroke-width='1.6'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    background-size: 1rem;
}

textarea {
    min-height: 7rem;
    resize: vertical;
}

input[readonly] {
    background: #fafafa;
    color: #71717a;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #6366f1;
    outline: none;
    box-shadow: 0 0 0 4px rgb(99 102 241 / 0.15);
}

.check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.35rem 0 0.75rem;
}

.check input {
    width: 1rem;
    height: 1rem;
    accent-color: #4f46e5;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e4e4e7;
    border-radius: 0.5rem;
    background: white;
    color: #18181b;
    padding: 0.55rem 0.9rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

.button:hover {
    background: #fafafa;
}

.button.primary {
    border-color: #09090b;
    background: #09090b;
    color: white;
}

.button.primary:hover {
    background: #27272a;
}

.button.danger {
    border-color: #fecdd3;
    color: #be123c;
}

.button.danger:hover {
    background: #fff1f2;
}

.button.block {
    width: 100%;
}

.button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.button:focus-visible,
.nav-link:focus-visible,
.menu-button:focus-visible,
.sign-out:focus-visible,
.tile:focus-visible,
.terrain-row:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.banner {
    margin: 0 0 1rem;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
}

.banner.error {
    border: 1px solid #fecdd3;
    background: #fff1f2;
    color: #be123c;
}

.banner.info {
    border: 1px solid #c7d2fe;
    background: #eef2ff;
    color: #3730a3;
}

.banner.warn {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid #fde68a;
    background: #fffbeb;
    color: #92400e;
}

.editor {
    display: grid;
    grid-template-columns: 18rem minmax(0, 1fr);
    gap: 1rem;
    height: calc(100dvh - 16rem);
    min-height: 32rem;
}

.panel {
    display: flex;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e4e4e7;
    border-radius: 1rem;
    background: white;
}

.terrain-list,
.editor-form {
    min-height: 0;
    overflow: auto;
}

.editor-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
}

.terrain-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
    border: 0;
    border-bottom: 1px solid #f4f4f5;
    background: white;
    padding: 0.7rem 0.9rem;
    text-align: left;
    cursor: pointer;
}

.terrain-row.selected {
    background: #eef2ff;
}

.terrain-row .num {
    color: #4338ca;
    font-weight: 600;
}

.terrain-row .label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lock {
    color: #71717a;
    font-size: 0.7rem;
}

.empty {
    margin: 0;
    padding: 1rem;
    color: #71717a;
    font-size: 0.875rem;
}

#terrain-map {
    height: 100%;
    min-height: 28rem;
    overflow: hidden;
    border: 1px solid #e4e4e7;
    border-radius: 1rem;
    background: #e4e4e7;
}

.vertex-icon {
    border: 2px solid white;
    border-radius: 999px;
    background: #4f46e5;
    box-shadow: 0 0 0 1px #4f46e5;
}

#boot {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    background: #f4f4f5;
}

.boot-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#blazor-error-ui {
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 80;
    display: none;
    width: 100%;
    box-sizing: border-box;
    background: #fef3c7;
    padding: 0.7rem 2.5rem 0.7rem 1rem;
    box-shadow: 0 -1px 2px rgb(9 9 11 / 0.12);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 0.45rem;
    right: 0.75rem;
    cursor: pointer;
}

@media (min-width: 1024px) {
    .shell {
        display: grid;
        grid-template-columns: 17rem minmax(0, 1fr);
    }

    .side {
        position: sticky;
        top: 0;
        display: flex;
        height: 100vh;
        flex-direction: column;
    }

    .side-nav {
        display: flex;
        flex: 1;
        flex-direction: column;
        gap: 0.25rem;
        overflow: auto;
        padding: 0 0.75rem 0.75rem;
    }

    .side-foot {
        display: block;
        padding: 0 0.75rem 1rem;
    }

    .menu-button,
    .menu-overlay,
    .user-chip .mobile-only {
        display: none;
    }

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

    .login-hero {
        display: flex;
        flex-direction: column;
        padding: 4rem 3.5rem;
    }

    main,
    main.wide {
        width: min(100% - 4rem, 72rem);
        padding-top: 2rem;
    }

    main.wide {
        width: min(100% - 4rem, 100%);
    }

    .foot {
        padding-right: 2rem;
        padding-left: 2rem;
    }
}

@media (max-width: 860px) {
    .editor {
        grid-template-columns: 1fr;
        height: auto;
    }

    .panel {
        max-height: 22rem;
    }

    #terrain-map {
        height: 70vh;
    }
}
