#template {
    display: grid;
    gap: 1rem;
    overflow-y: auto;
    max-height: 100%;
}

@media (max-width: 1023px) {
#template {
        grid-template-areas: 
            "template-switch"
            "template-files"
            "template-manual";
        grid-template-rows: auto auto auto;
        padding: 1rem 0.4rem 1rem 0.4rem;
        display: flex; /*Samsung Browser - padding-bottom*/
        flex-direction: column; /*Samsung Browser - padding-bottom*/
    }
}

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

#template form {
    grid-area: template-switch;
    display: grid;
    row-gap: 1rem;
    box-shadow: 0 2px 3px 0 #00000033;
    background-color: var(--windows);
    border-radius: 0.3rem;
}

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

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

#template form select {
    border-radius: 4px;
    font-size: 0.875rem;
    padding: 0 0.54rem;
    min-height: 35px;
    width: 100%;
    color: var(--template-form-select-font);
    background-color: var(--template-form-select);
    border: 1px solid var(--template-form-select-border);
    background-image: var(--select-icon);
    appearance: none;
    background-repeat: no-repeat;
    background-position: right .37rem center;
    background-size: 16px 12px;
}

#template form input {
    border-radius: 4px;
    font-size: 0.875rem;
    padding: 0 0.54rem;
    min-height: 35px;
    width: 100%;
    color: var(--template-form-input-font);
    background-color: var(--template-form-input);
    border: 1px solid var(--template-form-input-border);
}
#template input[type="submit"] {
    cursor: pointer;
}

#template .template-manual {
    grid-area: template-manual;
    display: grid;
    grid-auto-rows: max-content;
    gap: 1rem;
    border-radius: 0.3rem;
    box-shadow: 0 2px 3px 0 #00000033;
    background-color: var(--template-template-manual);
}
#template .template-manual div {
    color: var(--template-template-manual-div);
}
#template .template-manual p {
    font-size: 1rem;
    color: var(--template-template-manual-font);
}
#template .template-manual p a {
    color: var(--template-template-manual-p-a);
}

@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(--template-template-files);
    box-shadow: 0 2px 3px 0 #00000033;
    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(--template-files-title);
    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);
}


/* Start Secion */
#counters {
    overflow-y: auto;
    max-height: 100%;
}
#counters form {
    display: grid;
    row-gap: 1rem;
    background-color: var(--windows);
    border-radius: 0.3rem;
    box-shadow: 0 2px 3px 0 #00000033;
}
@media (max-width: 1023px) {
    #counters form {
        padding: 1rem 0.7rem 1rem 0.7rem;
        display: flex; /*Samsung Browser - padding-bottom*/
        flex-direction: column; /*Samsung Browser - padding-bottom*/
    }
}
@media (min-width: 1024px) {
    #counters form {
        padding: 1rem;
    }
}
#counters form > div {
    color: var(--counters-form-div);
}
@media (max-width: 1023px) {
    #counters {
        padding: 1rem 0.4rem 1rem 0.4rem;
    }
}
@media (min-width: 1024px) {
    #counters {
        padding: 1rem;
    }
}

#counters textarea {
    line-height: 1.3;
    resize: vertical;
    width: 100%;
    background-color: var(--counters-textarea);
    border: 1px solid var(--counters-textarea-border);
    border-radius: 0.3rem;
    font-size: 1.1rem;
    font-family: var(--monospace);
    color: var(--counters-textarea-font);
    padding: 0 8px;
}

#counters input[type="submit"] {
    cursor: pointer;
}
#counters form input {
    border-radius: 4px;
    font-size: 0.875rem;
    padding: 0 0.54rem;
    min-height: 35px;
    width: 100px;
    color: var(--counters-input-font);
    background-color: var(--counters-input);
    border: 1px solid var(--counters-input-border);
}



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

#template .template-editor-bg {
    position:fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9;
    background-color: var(--page-editor-bg);
}
#template .template-editor-bg.hidden {
    display: none;
}

#template .template-editor-grid {
    position: fixed;
    background-color: var(--page-editor-grid);
    display: grid;
    grid-template-rows: auto 1fr 1rem;
    grid-template-areas: 
        "template-editor-header"
        "template-editor" 
        "bottom";
}
@media (max-width: 1023px) {
    #template .template-editor-grid {
        top: 3rem;
        bottom: 0;
        left: 0;
        right: 0;
    }
}
@media (min-width: 1024px) {
    #template .template-editor-grid {
        top: 2.7rem;
        bottom: 0.7rem;
        left: 0.7rem;
        right: 0.7rem;
        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 {
    cursor: pointer;
    width: 2rem;
    height: 2rem;
}
@media (max-width: 1023px) {
    .close-template-button {
        grid-area: close;
    }
}
.close-template-button svg .a, .close-template-button svg .b {
    fill: none;
}
.close-template-button svg .b {
    stroke-linecap: round;
    stroke-miterlimit: 10;
    stroke-width: 35px;
}
.close-template-button svg .b {
    stroke: var(--close-page-button-svg-b);
}
.close-template-button:hover svg .b {
    stroke: var(--close-page-button-hover-svg-b);
}

.save-template-button {
    cursor: pointer;
    width: 2rem;
    height: 2rem;
}
@media (max-width: 1023px) {
    .save-template-button {
        grid-area: save;
        justify-self: right;
    }
}
.save-template-button svg .a, .save-template-button svg .b {
    fill: none;
}
.save-template-button svg .a {
    stroke-miterlimit: 10;
    stroke-width: 30px;
}
.save-template-button svg .a {
    stroke: var(--save-page-button-svg-a);
}
.save-template-button:hover svg .a {
    stroke: var(--save-page-button-hover-svg-a);
}

@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;
    padding: 5px 0 0 0;
}
.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%;
}

@media (min-width: 1024px) {
    .cm-s-dark .CodeMirror-vscrollbar::-webkit-scrollbar {width: 7px; height: 0;}
    .cm-s-dark .CodeMirror-vscrollbar::-webkit-scrollbar-button {width: 7px; height: 0;}
    .cm-s-dark .CodeMirror-vscrollbar::-webkit-scrollbar-thumb {background: #ffffff; border: none;}
    .cm-s-dark .CodeMirror-vscrollbar::-webkit-scrollbar-track {background: #343232; border: none;}
    .cm-s-dark .CodeMirror-vscrollbar::-webkit-scrollbar-corner {background: transparent;}
}

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