#template {
    display: grid;
    height: 100%;
}

#template > .settings {
    display: grid;
    gap: 1rem;
    overflow-y: auto;
    grid-column: 1/-1;
    grid-row: 1/-1;
}

@media (max-width: 1023px) {
#template > .settings {
        grid-template-areas: 
            "template-install"
            "template-switch"
            "template-files"
            "template-manual"
            "milk";
        grid-template-rows: auto auto auto 1fr;
        padding: 1rem 0.4rem 1rem 0.4rem;
        display: grid;
    }
}

@media (min-width: 1024px) {
    #template > .settings {
        grid-template-areas: 
            "template-install template-manual"
            "template-switch template-manual"
            "template-files template-files"
            "milk milk";
        grid-template-columns: 17rem 1fr;
        grid-template-rows: auto auto auto 1fr;
        padding: 1rem;
    }
}

#template .template {
    grid-area: template-switch;
    display: grid;
    row-gap: 1rem;
    box-shadow: var(--shadows);
    background-color: var(--windows);
    background-image: var(--noise);
    border-radius: 0.3rem;
}

#template .template label {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 0.5rem;
    cursor: pointer;
    line-height: 1.3;
    color: var(--windows-font);
    user-select: none;
}

#template .template form {
    display: grid;
    row-gap: 1rem;
}

@media (max-width: 1023px) {
    #template .template {
        padding: 1rem 0.7rem 1rem 0.7rem;
    }
}
@media (min-width: 1024px) {
    #template .template {
        padding: 1rem;
    }
}

#template form > div {
    position: relative;
    color: var(--windows-font);
}

#template .upload_dnd {
    position: relative;
    text-align: center;
}
#template .upload_dnd #template-upload {
	width: 100%;
	height: 100%;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
	opacity: 0;
	overflow: hidden;
	position: absolute;
	z-index: 7;
    cursor: pointer;
}

label[for=template-upload] {
	padding: 0.4rem 0.7rem 0.5rem 0.7rem;
	white-space: nowrap;
	cursor: pointer;
	border-radius: 0.3rem;
	color: var(--windows-font);
	background-color: var(--windows);
    font-size: 1rem;
    justify-content: center;
    display: block;
}

#template .template-manual {
    grid-area: template-manual;
    display: grid;
    grid-auto-rows: max-content;
    gap: 1rem;
    border-radius: 0.3rem;
    box-shadow: var(--shadows);
    background-color: var(--windows);
    background-image: var(--noise);
}
#template .template-manual div {
    color: var(--windows-font);
}
#template .template-manual p {
    font-size: 1rem;
    color: var(--text);
}
#template .template-manual p a {
    color: var(--link);
}

@media (max-width: 1023px) {
    #template .template-manual {
        padding: 1rem 0.7rem 1rem 0.7rem;
    }
}
@media (min-width: 1024px) {
    #template .template-manual {
        padding: 1rem;
    }
}

#template .template-files {
    grid-area: template-files;
    display: grid;
    row-gap: 1rem;
    background-color: var(--windows);
    background-image: var(--noise);
    box-shadow: var(--shadows);
    border-radius: 0.3rem;
}
@media (max-width: 1023px) {
    #template .template-files {
        padding: 1rem 0.7rem 1rem 0.7rem;
    }
}
@media (min-width: 1024px) {
    #template .template-files {
        padding: 1rem;
    }
}

.template-files .title {
    color: var(--windows-font);
    padding-bottom: 0.2rem;
}
.template-files .file {
    font-size: 1rem;
    font-family: var(--monospace);
    color: var(--template-files-file);
    width: fit-content;
    display: flex; /* Mobile Browser - fit-content inline */
    cursor: pointer;
}
.template-files .file:hover {
    color: var(--template-files-file-hover);
}
.template-files .no-files {
    font-size: 1rem;
    color: var(--text);
}



/* Проверить */

#template .template-editor-bg {
    display: grid;
    position: relative;
    grid-row: 1/-1;
    grid-column: 1/-1;
    z-index: 9;
    background-color: var(--bg-3);
    background-image: var(--noise);
}
@media (min-width: 1024px) {
    #template .template-editor-bg {
        padding: 1rem;
    }
}
#template .template-editor-bg.hidden {
    display: none;
}

#template .template-editor-grid {
    background-color: var(--bg-3);
    display: grid;
    position: relative;
    box-shadow: 0 0 3px 0 #00000096;
    grid-template-rows: auto 1fr 1rem;
    grid-template-areas: 
        "template-editor-header"
        "template-editor" 
        "bottom";
}
#template .template-editor-grid::before {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    z-index: 1;
    width: 7px;
    height: 7px;
    border-radius: 50%;
}
#template .template-editor-grid[data-changed="true"]::before {
    background-color: var(--changes);
}
@media (min-width: 1024px) {
    #template .template-editor-grid {
        border-radius: 5px;
    }
}

.template-editor-header {
    grid-area: template-editor-header;
    display: grid;
}
@media (max-width: 1023px) {
    .template-editor-header {
        grid-template-areas:
        "title title save close";
        grid-template-columns: auto 1fr auto auto;
        grid-column-gap: 1rem;
        grid-row-gap: 0.5rem;
        padding: 10px;
    }
}
@media (min-width: 1024px) {
    .template-editor-header {
        padding: 10px;
        grid-template-columns: max-content max-content 1fr;
        gap: 1rem;
    }
}

.close-template-button {
    position: relative;
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    border-radius: 3px;
    background-color: var(--bg-3);
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 40%;
    background-image: var(--icon-close);
}
.close-template-button:hover {
    background-color: var(--bg-4);
}
@media (max-width: 1023px) {
    .close-template-button {
        grid-area: close;
    }
}

.save-template-button {
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    position: relative;
    background-color: var(--bg-3);
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 55%;
    background-image: var(--icon-save);
    border-radius: 3px;
}
.save-template-button:hover {
    background-color: var(--bg-4);
}
.save-template-button.saved {
    background-color: var(--saved-bg);
}
@media (max-width: 1023px) {
    .save-template-button {
        grid-area: save;
        justify-self: right;
    }
}

@media (max-width: 1023px) {
    .template-editor-title {
        grid-area: title;
    }
}

.template-editor-title {
    font-family: var(--monospace);
    color: var(--template-files-file);
    width: fit-content;
    align-self: center;
}

.template-editor {
    grid-area: template-editor;
}
.template-editor .CodeMirror {
    min-height: 100%;
    max-height: 100%;
    height: 1rem;
    font-family: var(--monospace);
    font-weight: normal;
    font-size: 1.04rem;
}
.CodeMirror-dialog input {
    font-family: var(--monospace);
    font-size: 100%;
}

#template .CodeMirror-wrap pre.CodeMirror-line, #template .CodeMirror-wrap pre.CodeMirror-line-like {
    word-wrap: break-word;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Select */
#template .template-select-grid {
    text-align: left;
}
#template .field-select {
    height: 100%;
    cursor: pointer;
    color: var(--text);
    background-color: var(--menu-input-bg);
    border: 2px solid var(--menu-input-border);
    background-image: var(--select-icon);
    border-radius: 4px;
    user-select: none;
    background-repeat: no-repeat;
    background-position: right 0.37rem center;
    background-size: 16px 12px;
    padding: 0 0.57rem 0 0.44rem;
    line-height: 32px;
    font-size: 1rem;
}
#template .template-select-grid .field-options {
    display: grid;
    position: absolute;
    height: 0;
    overflow: hidden;
    width: 100%;
    border-radius: 0.25rem;
    box-shadow: 0 2px 3px 0 #00000033;
    max-height: 17rem;
    z-index: 7;
}
#template .template-select-grid .field-options.open {
    background-color: var(--bg-3);
    border: 2px solid var(--bg-4);
    color: var(--text);
    overflow: auto;
    height: auto;
    margin-top: 2px;
}
#template .template-select-grid .field-options .option {
    padding: 0.4rem 0.44rem;
    cursor: pointer;
    font-size: 0.94rem;
}
#template .template-select-grid .field-options .option:hover {
    background-color: var(--bg-2);
}