#pages {
    display: grid;
    height: 100%;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        "main-header"
        "main-main"
        "main-footer";
}

#pages .main-header {
    grid-area: main-header;
    display: grid;
    gap: 1rem;
}

@media (max-width: 1023px) {
    #pages .main-header {
        padding: 1rem 0.7rem 1rem 0.4rem;
        grid-template-columns: 1fr auto auto auto;
    }
}
@media (min-width: 1024px) {
    #pages .main-header {
        padding: 1rem 2.4rem 1rem 1rem;
        grid-template-columns: 1fr auto 1fr auto;
    }
}

/* вернули скролл к стандартной ширине
@-moz-document url-prefix() {
    #pages .main-header {
        padding-right: 1.4rem;
    }
}
*/

#pages .search-wrapper {
    position: relative;
    min-width: 180px;
}
#pages .page-search {
    border-radius: 0.3rem;
    font-size: 0.875rem;
    padding: 0 4.7rem 0 0.54rem;
    height: 100%;
    width: 100%;
    background-color: var(--page-search);
    border: 2px solid var(--input-border);
    color: var(--text);
}
#pages .reset {
    position: absolute;
    top: 3px;
    bottom: 3px;
    right: 45px;
    cursor: pointer;
    border: none;
    border-radius: 50%;
    outline: none;
    width: 30px;
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 40%;
    background-image: var(--icon-clear);
}
@media (max-width: 1023px) {
    #pages .reset:active {
        background-color: var(--bg-4);
    }
}
@media (min-width: 1024px) {
    #pages .reset:hover {
        background-color: var(--bg-4);
    }
}

#pages .page-search-button {
    position: absolute; 
    top: 1px;
    bottom: 1px;
    right: 1px;
    border-radius: 3px;
    cursor: pointer; 
    border: none;
    outline: none;
    width: 42px;
    min-height: unset;
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 48%;
    background-image: var(--search-icon);
}


.add-page-btn {
    display: flex;
    width: 35px;
    border-radius: 0.3rem;
    cursor: pointer;
    background-color: var(--bg-3);
    position: relative;
}
.add-page-btn:hover {
    background-color: var(--add-page-btn-hover);
}
.add-page-btn .x1 {
    width: 2px;
    height: 16px;
    border-radius: 2px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: rotate(0deg) translate(-50%, -50%);
}
.add-page-btn .x2 {
    width: 16px;
    height: 2px;
    border-radius: 2px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: rotate(0deg) translate(-50%, -50%);
}
.add-page-btn .x1, .add-page-btn .x2 {
    background-color: var(--add-page-btn-svg-b-plus);
}

#pages .add-pages {
	display: grid;
	grid-auto-flow: column;
	column-gap: 1rem;
	align-content: center;
}

.del-pages-btn {
    display: flex;
    cursor: pointer;
    border-radius: 0.3rem;
    user-select: none;
}
@media (min-width: 1024px) {
    .del-pages-btn:hover {
        background-color: var(--bg-4);
    }
}
.del-pages-btn svg {
    width: 35px;
}
.del-pages-btn svg .a-trash, .del-pages-btn svg .b-trash {
    stroke: var(--del-pages-btn-svg);
}


#pages .main-main {
    grid-area: main-main;
    overflow-y: scroll;
}
@media (max-width: 1023px) {
    #pages .main-main {
        padding: 0 0.4rem 0.3rem 0.4rem;
    }
}
@media (min-width: 1024px) {
    #pages .main-main {
        padding: 0rem 1rem 0.3rem 1rem;
    }
}





.pages-grid {
    display: grid;
    row-gap: 0.3rem;
}

.pages-grid > div {
    border-radius: 0.3rem;
    display: grid;
    padding: 0.7rem;
    column-gap: 0.7rem;
    box-shadow: 0 2px 2px 0 #00000033;
    position: relative;
    row-gap: 0.5rem;
    background-color: var(--windows);
    background-image: var(--noise);
}
@media (max-width: 1023px) {
    .pages-grid > div {
        grid-template-areas:
        "page-name page-pin  page-del"
        "page-butt published page-del";
        grid-template-columns: 1fr auto 1.4rem;
    }
}
@media (min-width: 1024px) {
    .pages-grid > div {
        grid-template-areas:
        "page-name page-pin  page-date page-del"
        "page-butt published page-date page-del";
        grid-template-columns: 1fr auto 6rem 1.4rem;
    }
    .pages-grid > div:hover {
        background-color: var(--windows-hover)
    }
}
.pages-grid > div.open {
    background-color: var(--pages-grid-div-open);
    box-shadow: 0 0 0 2px var(--pages-grid-div-open-shadow) inset;
}

.pages-grid > div.home {
	box-shadow: 0 0 0 2px var(--pages-grid-div-open-shadow) inset;
}

@media (max-width: 1023px) {
    .pages-grid > div.open {
        grid-template-areas:
        "page-name page-pin  page-del "
        "page-butt published page-del "
        "page-prop page-prop page-prop";
    }
}
@media (min-width: 1024px) {
    .pages-grid > div.open {
        grid-template-areas:
        "page-name page-pin  page-date page-del "
        "page-butt published page-date page-del "
        "page-prop page-prop page-prop page-prop";
    }
}


.pages-grid > div.last-edited::before {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    z-index: 1;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--green-3);
}

#pages .pin {
    grid-area: page-pin;
    width: 15px;
    height: 15px;
    margin: -11px auto 0 auto;
    cursor: pointer;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 84%;
    background-image: var(--pages-pin-off);
}
#pages [data-pin="1"] .pin {
    background-image: var(--pages-pin-on);
}
@media (min-width: 1024px) {
    #pages .pages-grid > div .pin {
        display: none;
    }
    #pages .pages-grid > div[data-pin="1"] .pin {
        display: block;
    }
    #pages .pages-grid > div:hover .pin {
        display: block;
    }
}

#pages .pages-grid > div > .published {
    grid-area: published;
    width: 18px;
    height: 18px;
    cursor: pointer;
    background-size: 100%;
    background-repeat: no-repeat;
    background-image: var(--eye-icon);
    grid-row: 2/3;
    align-self: end;
}
#pages .pages-grid [data-published="0"] .published {
    background-position-y: 100%;
}
@media (min-width: 1024px) {
    #pages .pages-grid > div > .published {
        opacity: 0;
    }
    #pages .pages-grid > div:hover .published {
        opacity: 1;
    }
    #pages .pages-grid [data-published="0"] .published {
        opacity: 1;
    }
}


.page-buttons div {
    cursor: pointer;
    user-select: none;
    color: var(--buttons-font);
    position: relative;
}
.page-buttons .loading::after {
    content: "";
    display: block;
    width: 100%;
    height: 2px;
    position: absolute;
    left: 0;
    right: 0;
    bottom: -3px;
    border-radius: 2px;
    background-image: repeating-linear-gradient(90deg, var(--link) -0.2rem, var(--windows) 0rem, var(--link) 0.2rem);
    animation: barberpole 10s linear infinite;
    background-size: 300% 300%;
}
@keyframes barberpole {
    100% {
      background-position: 150% 150%;
    }
}


.page-buttons div:hover {
    color: var(--buttons-hover);
}
.pages-grid > div.open .page-prop-btn {
    color: var(--buttons-open);
}

.page-prop-save-btn {
    display: none;
}
.pages-grid > div.open .page-prop-save-btn {
    display: block;
}
.pages-grid > div.open .page-prop-save-btn.saved {
    color: var(--saved);
}

.pages-grid a.page-name {
    grid-area: page-name;
    width: fit-content;
    display: flex;
    margin-top: -5px;
    font-size: 1rem;
    min-height: 21px; /* for empty title */
    text-decoration: none;
    color: var(--link);
}
.pages-grid a.page-name:hover {
    color: var(--link-hover);
}


.page-buttons {
    grid-area: page-butt;
    display: flex;
    column-gap: 0.7rem;
    font-size: 0.9rem;
}
@media (max-width: 320px) {
    .page-buttons {
        font-size: 0.7rem;
        align-self: center;
    }
}
@media (min-width: 1024px) {
    .page-buttons {
        opacity: 0;
    }
    .pages-grid > div:hover .page-buttons {
        opacity: 1;
    }
    .pages-grid > div.open .page-buttons {
        opacity: 1;
    }
}
@media (max-width: 1023px) {
    .page-date {
        display: none;
    }
}
@media (min-width: 1024px) {
    .page-date {
        grid-area: page-date;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 0.8rem;
        color: var(--page-date);
    }
    .page-date.future {
        color: var(--page-date-planned);
    }
}

.page-prop {
    display: none;
    grid-area: page-prop;
}
@media (max-width: 1023px) {
    .pages-grid > div.open .page-prop {
        display: grid;
    }
}
@media (min-width: 1024px) {
    .page-prop {
        grid-template-areas:
        "cTitle vTitle cTemplate vTemplate"
        "cURL   vURL   cDate     vDate"
        "cSEO   vSEO   cTime     vTime"
        "cDesc  vDesc  cTags     vTags";
        grid-template-columns: 6em minmax(240px, 100%) 6em minmax(240px, 100%);
        row-gap: 0.75rem;
        column-gap: 0.7rem;
    }
    .pages-grid > div.open .page-prop {
        display: grid;
        padding: 0.5rem 0 0.3rem 0;
    }
}

.page-prop > div {
    font-size: 1rem;
    line-height: 27px;
    color: var(--names);
}


/* Select */
.page-prop .template-select-grid, .page-properties .template-select-grid {
    text-align: left;
    position: relative;
}
.page-prop .field-select, .page-properties .field-select {
	height: 100%;
	cursor: pointer;
    color: var(--text);
	background-color: var(--bg-4);
	border: 1px solid var(--bg-4);
    background-image: var(--select-icon);
	border-radius: 4px;
    user-select: none;
    background-repeat: no-repeat;
    background-position: right .37rem center;
    background-size: 16px 12px;
    padding: 0 0.57rem 0 0.44rem;
}
.page-prop .template-select-grid .field-options, .page-properties .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;
}
.page-prop .template-select-grid .field-options.open, .page-properties .template-select-grid .field-options.open {
    background-color: var(--bg-3);
    border: 2px solid var(--bg-4);
    margin-top: 2px;
    color: var(--text);
    overflow: auto;
    height: auto;
}
.page-prop .template-select-grid .field-options option, .page-properties .template-select-grid .field-options option {
    padding: 0.4rem 0.44rem;
    cursor: pointer;
    font-size: 0.94rem;
}
.page-prop .template-select-grid .field-options option:hover, .page-properties .template-select-grid .field-options option:hover {
    background-color: var(--bg-2);
}

@media (max-width: 1023px) {
    .page-prop > div:not(:first-child), .page-properties > div:not(:first-child) {
        padding-top: 0.75rem;
    }
}
@media (min-width: 1024px) {
    .page-prop > div, .page-properties > div {
        text-align: right;
    }
    .page-prop .page-title, .page-properties .page-title { grid-area: cTitle; }
    .page-prop input[name=title], .page-properties input[name=title] { grid-area: vTitle; }
    .page-prop .seo-title, .page-properties .seo-title { grid-area: cSEO; }
    .page-prop input[name=seo_title], .page-properties input[name=seo_title] { grid-area: vSEO; }
    .page-prop .url, .page-properties .url { grid-area: cURL; }
    .page-prop .url-input, .page-properties .url-input { grid-area: vURL; }
    .page-prop .template, .page-properties .template { grid-area: cTemplate; }
    .page-prop .template-select-grid, .page-properties .template-select-grid { grid-area: vTemplate; }
    .page-prop .description, .page-properties .description { grid-area: cDesc; }
    .page-prop textarea[name="description"], .page-properties textarea[name="description"] { grid-area: vDesc; }
    .page-prop .date, .page-properties .date { grid-area: cDate; }
    .page-prop input[name=date], .page-properties input[name=date] { grid-area: vDate; max-width: fit-content; }
    .page-prop .time, .page-properties .time { grid-area: cTime; }
    .page-prop input[name=time], .page-properties input[name=time] { grid-area: vTime; max-width: fit-content; }
    .page-prop .tags, .page-properties .tags { grid-area: cTags; }
    .page-prop textarea[name="tags"], .page-properties textarea[name="tags"] { grid-area: vTags; }
}


.page-prop .url-input {
    display: grid;
    grid-template-columns: 1fr 2.7rem;
}
.page-prop .url-input > input {
    width: 100%;
    grid-column: 1/-1;
    grid-row: 1/-1;
    padding-right: 3rem;
}
.page-prop .url-input .url-translit {
    display: grid;
    grid-column: 2/3;
    grid-row: 1/-1;
    cursor: pointer;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 54%;
    background-image: var(--icon-link);
}


.pages-grid > div > input[type="checkbox"] {
    grid-area: page-del;
}
@media (min-width: 1024px) {
    .pages-grid > div > input[type="checkbox"] {
        align-self: center;
    }
}

.page-prop input,
.page-prop textarea{
    border-radius: 4px;
    font-size: 0.94rem;
    padding: 0 0.54rem;
    min-height: 30px;
    height: 100%;
    background-color: var(--bg-4);
    border: 1px solid var(--bg-4);
    color: var(--text);
}

.page-prop textarea {
    font-family: var(--sans-serif);
    line-height: 1.3em;
    resize: vertical;
    display: block;
}

.page-prop select, .page-prop input[type=date], .page-prop input[type=time] {
    -moz-padding-start: 4px;
    -moz-padding-end: 4px;
}

#pages .main-footer {
    grid-area: main-footer;
    padding: 1rem;
    display: grid;
    column-gap: 1rem;
    grid-auto-flow: column;
    justify-content: space-between;
}

#pages .main-footer .pager::-webkit-scrollbar {
    height: 0;
}

#pages .main-footer .pager {
    scrollbar-width: none;
}

#pages .counters {
    display: grid;
    column-gap: 0.5rem;
    grid-auto-flow: column;
}
#pages .counters input {
    border-radius: 4px;
    font-size: 0.875rem;
    padding: 0 0.3rem;
    min-height: 30px;
    height: 100%;
    width: 3.2rem;
    text-align: center;
    background-color: var(--bg-4);
    border: 1px solid var(--bg-4);
    color: var(--text);
}
#pages .counters span {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text);
}


#pages .main-footer .pager {
    display: grid;
    grid-auto-flow: column;
    column-gap: 0.5rem;
    overflow-x: auto;
    padding: 4px;
}

#pages .main-footer .pager > div {
    color: var(--text);
    background-color: var(--bg-3);
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 32px;
    border-radius: 0.7rem;
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
}

#pages .main-footer .pager > div.active {
    color: var(--main-footer-pager-div-active-font);
    box-shadow: 0 0 0 0.25rem var(--pages-main-footer-pager-div-bg-active);
}

#pages .main-footer .pager > div:hover {
    color: var(--main-footer-pager-div-hover);
}

#pages .page-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) {
    #pages .page-editor-bg {
        padding: 1rem;
    } 
}
#pages .page-editor-bg.hidden {
    display: none;
}


#pages .page-editor-grid {
    position: relative;
    background-color: var(--bg-3);
    box-shadow: 0 0 3px 0 #00000096;
    min-height: 0; /*Scroll*/
    display: grid;
    grid-template-rows: auto auto auto auto 1fr 1rem;
    grid-template-areas: 
        "page-editor-header page-editor-header"
        "page-editor-buttons page-editor-buttons"
        "page-properties page-properties"
        "page-editor-panel page-editor-panel"
        "page-editor tags"
        "bottom bottom";
}

#pages .page-editor-grid::before {
	content: "";
	position: absolute;
	left: 3px;
	top: 3px;
	z-index: 1;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	
}

#pages .page-editor-grid[data-changed="true"]::before {
    background-color: var(--changes);
}










.page-properties {
    grid-area: page-properties;
    display: grid;
    padding: 0.5rem 0.5rem 1rem 0.5rem;
}

@media (max-width: 414px) {
    .page-properties {
        grid-row: 3/-1;
        z-index: 111;
        background-color: var(--bg-3);
        align-content: start;
        overflow-y: auto;
    }
}




.page-properties.hidden {
    display: none;
}
@media (min-width: 1024px) {
    .page-properties {
        grid-template-areas:
        "cTitle vTitle cTemplate vTemplate"
        "cURL   vURL   cDate     vDate"
        "cSEO   vSEO   cTime     vTime"
        "cDesc  vDesc  cTags     vTags";
        grid-template-columns: 6em minmax(240px, 100%) 6em minmax(240px, 100%);
        row-gap: 0.75rem;
        column-gap: 0.7rem;
    }
}

.page-properties > div {
    font-size: 1rem;
    line-height: 27px;
    color: var(--names);
}
/* Options */
.page-properties select {
    appearance: none;
    background-repeat: no-repeat;
    background-position: right .37rem center;
    background-size: 16px 12px;
}

.page-properties select {
    background-image: var(--select-icon);
}
@media (max-width: 1023px) {
    .page-properties > div:not(:first-child) {
        padding-top: 0.75rem;
    }
}
@media (min-width: 1024px) {
    .page-properties > div {
        text-align: right;
    }
    .page-properties .page-title { grid-area: cTitle; }
    .page-properties input[name=title] { grid-area: vTitle; }
    .page-properties .seo-title { grid-area: cSEO; }
    .page-properties input[name=seo_title] { grid-area: vSEO; }
    .page-properties .url { grid-area: cURL; }
    .page-properties .url-input { grid-area: vURL; }
    .page-properties .template { grid-area: cTemplate; }
    .page-properties select[name=template] { grid-area: vTemplate; }
    .page-properties .description { grid-area: cDesc; }
    .page-properties textarea { grid-area: vDesc; }
    .page-properties .date { grid-area: cDate; }
    .page-properties input[name=date] { grid-area: vDate; max-width: fit-content; }
    .page-properties .time { grid-area: cTime; }
    .page-properties input[name=time] { grid-area: vTime; max-width: fit-content; }
}

.page-properties .url-input {
    display: grid;
    grid-template-columns: 1fr 2.7rem;
}
.page-properties .url-input > input {
    width: 100%;
    grid-column: 1/-1;
    grid-row: 1/-1;
    padding-right: 3rem;
}
.page-properties .url-input .url-translit {
    display: grid;
    grid-column: 2/3;
    grid-row: 1/-1;
    cursor: pointer;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 54%;
    background-image: var(--icon-link);
}

.page-properties input,
.page-properties textarea {
    border-radius: 4px;
    font-size: 0.94rem;
    padding: 0 0.54rem;
    min-height: 30px;
    height: 100%;
    background-color: var(--bg-4);
    border: 1px solid var(--bg-4);
    color: var(--text);
}

.page-properties textarea {
    font-family: var(--sans-serif);
    font-size: 0.94rem;
    line-height: 1.3em;
    resize: vertical;
    min-height: 3.75rem;
}

.page-properties select, .page-properties input[type=date], .page-properties input[type=time] {
    -moz-padding-start: 4px;
    -moz-padding-end: 4px;
}




















@media (max-width: 1023px) {
    #pages .page-editor-grid {
        grid-template-columns: 1fr 0;
    }
    #pages .page-editor-grid.tags-opened {
        grid-template-columns: 1fr max-content;
    }
    #pages .tags {
        z-index: 3;
    }
}
@media (min-width: 1024px) {
    #pages .page-editor-grid {
        grid-template-columns: 1fr 0;
    }
    #pages .page-editor-grid.tags-opened {
        grid-template-columns: 1fr max-content;
    }
}
@media (min-width: 1024px) {
    #pages .page-editor-grid {
        border-radius: 5px;
    }
}

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

#pages .close-page-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);
}
#pages .close-page-button:hover {
    background-color: var(--bg-4);
}
@media (max-width: 1023px) {
    #pages .close-page-button {
        grid-area: close;
    }
}

#pages .save-page-button {
    cursor: pointer;
}

#pages .page-editor-buttons .save-page-button.saved {
    color: var(--saved);
}
#pages .page-editor-buttons .save-page-button.error {
    color: var(--error);
}


#pages .open-properties {
    cursor: pointer;
    user-select: none;
}
#pages .page-editor-grid.properties .open-properties {
    color: var(--buttons-open);
}

#pages .page-editor-header a {
    color: var(--link);
    text-decoration: none;
    width: fit-content;
    align-self: center;
}
#pages .page-editor-header a:hover {
    color: var(--link-hover);
    text-decoration: none;
}

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

#pages .page-editor-buttons {
    display: grid;
    grid-area: page-editor-buttons;
    grid-auto-flow: column;
    gap: 0.7em;
    justify-content: start;
    overflow-x: auto;
    overflow-y: hidden;
    font-size: 1rem;
    color: var(--buttons-font);
}
@media (max-width: 1023px) {
    #pages .page-editor-buttons {
        padding: 10px 10px;
    }
}
@media (min-width: 1024px) {
    #pages .page-editor-buttons {
        padding: 10px 14px;
    }
    #pages .page-editor-buttons > div:hover {
        color: var(--buttons-hover);
    }
}
#pages .page-editor-buttons.hidden {
	display: none;
}


#pages .open-mediateka {
    cursor: pointer;
    user-select: none;
}
#pages .page-editor-grid.mediateka .open-mediateka {
    color: var(--buttons-open);
}


#pages .tags-helper {
    cursor: pointer;
    user-select: none;
}
#pages .page-editor-grid.tags-opened .tags-helper {
    color: var(--buttons-open);
}


#pages .codemirror-replace {
    cursor: pointer;
    user-select: none;
}


#pages .page-editor-buttons a {
    color: var(--uni-editor);
    text-decoration: none;
}
@media (min-width: 1024px) {
    #pages .page-editor-buttons a:hover {
        color: var(--buttons-hover);
    }
}


#pages .page-editor-panel {
    display: grid;
    grid-area: page-editor-panel;
    padding:10px;
    position: relative;
    max-width: 100%;
}
#pages .page-editor-panel.hidden {
    display: none;
}

#pages .upload-progress {
    position: absolute;
    width: 0%;
    height: 3px;
    background-color: tomato;
}
@keyframes barberpole {
    100% {
        background-position: 100% 100%;
    }
}

#pages .mediateka-grid {
    display: grid;
    grid-template-rows: auto auto;
    grid-template-columns: 1fr;
    row-gap: 10px;
    grid-template-areas:
      "mediateka-files-hscroll"
      "mediateka-buttons";
}
#pages .mediateka-grid.hidden {
	display: none;
}

#pages .mediateka-files-hscroll {
    grid-area: mediateka-files-hscroll;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
}

#pages .mediateka-files-grid {
    display: grid;
    column-gap: 5px;
    grid-auto-columns: 130px;
    grid-auto-flow: column;
}

#pages .file-block {
    height: 130px;
    background-color: var(--bg-2);
    box-shadow: 0 2px 3px 0 #0000004d;
    border: 2px solid var(--br-3);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}
	
#pages .file-block:hover {
    border: 2px solid var(--br-active);
}
#pages .file-block.active-file {
    border: 2px solid var(--br-active);
}

#pages .file-block img {
    object-fit: contain;
    width: 100%;
    height: 100%;
    display: block;
}

#pages .file-block .media-name {
    width: 100%;
	font-size: 60%;
	position: absolute;
	padding: 0 2%;
	overflow: hidden;
    color: var(--text);
    word-break: break-all;
    background-color: #0005;
}

#pages .file-block input[type="checkbox"] {
    position: absolute;
    right: 3px;
    top: 5px;
    z-index: 1;
    width: 1rem;
    height: 1rem;
    display: none;
    border-color: var(--orange);
}

#pages .file-block:hover input[type="checkbox"] {
    display: block;
}

#pages .file-block input[type="checkbox"]:checked {
    display: block;
}

#pages .file-block .ext {
    position: absolute;
    z-index: 12;
    bottom: 3px;
    left: 3px;
    font-size: 12px; 
    padding: 1px 5px 1px 3px;
    border-radius: 3px;
    cursor: default;
    background-color: var(--bg-4);
    color: var(--ext);
}

#pages .mediateka-buttons {
    display: grid;
    grid-area: mediateka-buttons;
}
@media (max-width: 1023px) {
    #pages .mediateka-buttons {
        grid-template-rows: auto;
        grid-template-columns: 1fr 1fr;
        gap: 0.9rem;
        grid-template-areas:
            "upload-files del-uploaded-files"
            "link-file link-file";
    }
}
@media (min-width: 1024px) {
    #pages .mediateka-buttons {
        grid-template-columns: auto 1fr auto;
        column-gap:15px;
        grid-template-areas: "upload-files link-file del-uploaded-files";
    }
}
#pages .upload-files {
    grid-area: upload-files;
    min-height: 2.5rem;
    position: relative;
}
#pages .mediateka-buttons .inputfile {
    width: 100%;
    opacity: 0;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    overflow: hidden;
}
#pages .mediateka-buttons .inputfile + label {
    height: 100%;
    padding: 0 0.7rem;
    display: flex;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1;
    background-color: var(--bg-2);
    color: var(--buttons-font);
}

#pages .link-file {
    grid-area: link-file;
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 1rem;
    line-height: 2;
    min-height: 2.5rem;
    align-items: center;
    padding-left: 10px;
    padding-right: 4px;
    border-radius: 5px;
    font-size: 1rem;
    word-break: break-all;
    background-color: var(--bg-2);
    color: var(--buttons-font);
}
#pages .link-file a {
    color: var(--link);
}
#pages .link-file-tag {
    line-height: 1.4;
}
#pages .link-file-copy-btn {
    cursor: pointer;
    z-index: 1;
    font-size: 0.8rem;
    padding: 0 0.4rem;
    border-radius: 0.2rem;
    display: flex;
    min-height: 2rem;
    height: calc(100% - 8px);
    user-select: none;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-3);
}

#pages .del-uploaded-files {
    grid-area: del-uploaded-files;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-left: 10px;
    padding-right: 10px;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    background-color: var(--orange);
    color: var(--white);
}
#pages .del-uploaded-files:hover {
    box-shadow: 0 0 0 0.25rem var(--focus-orange);
}

#pages .del-uploaded-files.disabled {
    background-color: var(--bg-2);
    color: var(--font-bg);
    cursor: context-menu;
}
#pages .del-uploaded-files.disabled:hover {
    box-shadow: unset;
}

/* теги, в которые заворачивается html-код */
#pages .page-editor-grid > .tags {
    grid-area: tags;
    display: none;
    width: max-content;
    overflow-y: auto;
    background-color: var(--tags-bg);
    position: relative;
}
#pages .page-editor-grid.tags-opened > .tags {
    display: block;
}

#pages .tags-grid {
    display: grid;
    position: relative;
    padding: 0.3rem 0;
}

#pages .tags-grid > div {
    display: flex;
    padding: 7px 15px 7px 15px;
    color: var(--tags-font);
    font-size: 0.9rem;
    cursor: pointer;
    justify-content: space-between;
}

#pages .tags-grid > div .tag {
    color: var(--windows-font);
}
#pages .tags-grid > div:hover {
    background-color: var(--codemirror-bg);
}


#pages .page-editor {
    grid-area: page-editor;
}
@media (max-width: 1023px) {
    #pages .page-editor {
        grid-column: 1/-1;
    }
}
body .CodeMirror {
    min-height: 100%;
    max-height: 100%;
    height: 2rem;
    font-family: var(--monospace);
    font-weight: normal;
    font-size: 1.04rem;
}
body .CodeMirror-dialog input {
    font-family: var(--monospace);
    font-size: 100%;
}

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

/* Codemirror light theme Start */
.cm-s-default.CodeMirror {
    background-color: var(--codemirror-bg);
    color: var(--codemirror-text);
}
.cm-s-default .CodeMirror-gutters {
    background-color: var(--codemirror-bg);
    color: var(--codemirror-numbeslines);
    border: none;
}
/* Codemirror dark theme Start */
/*
Лишнее, дублирует по сути то что выше
.cm-s-dark.CodeMirror {
    background-color: var(--codemirror-bg);
    color: var(--codemirror-text);
}
.cm-s-dark .CodeMirror-gutters {
    background-color: var(--codemirror-bg);
    color: var(--codemirror-numbeslines);
    border: none;
}
*/
.dark .CodeMirror .CodeMirror-guttermarker,
.dark .CodeMirror .CodeMirror-guttermarker-subtle,
.dark .CodeMirror .CodeMirror-linenumber {
    color: var(--codemirror-numbeslines);
}
.dark .CodeMirror .CodeMirror-cursor {
    border-left: 1px solid #FFCC00;
}
.dark .CodeMirror div.CodeMirror-selected {
    background-color: #0663d2;
}
.dark .CodeMirror .cm-searching {
    background-color: rgb(112 112 100 / 30%);
}
.dark .CodeMirror-focused div.CodeMirror-selected {
    background-color: #0663d2;
}
.dark .CodeMirror .CodeMirror-line::selection,
.dark .CodeMirror .CodeMirror-line>span::selection,
.dark .CodeMirror .CodeMirror-line>span>span::selection {
    background-color: rgba(128, 203, 196, 0.2);
}
.dark .CodeMirror .CodeMirror-line::-moz-selection,
.dark .CodeMirror .CodeMirror-line>span::-moz-selection,
.dark .CodeMirror .CodeMirror-line>span>span::-moz-selection {
    background-color: rgba(128, 203, 196, 0.2);
}
.dark .CodeMirror .CodeMirror-activeline-background {
    background-color: #2c2929b5;
}
.dark .CodeMirror .cm-keyword {
    color: #C792EA;
}
.dark .CodeMirror .cm-operator {
    color: #89DDFF;
}
.dark .CodeMirror .cm-variable-2 {
    color: #EEFFFF;
}
.dark .CodeMirror .cm-variable-3,
.dark .CodeMirror .cm-type {
    color: #f07178;
}
.dark .CodeMirror .cm-builtin {
    color: #FFCB6B;
}
.dark .CodeMirror .cm-atom {
    color: #F78C6C;
}
.dark .CodeMirror .cm-number {
    color: #FF5370;
}
.dark .CodeMirror .cm-def {
    color: #82AAFF;
}
.dark .CodeMirror .cm-string {
    color: #94af6e;
}
.dark .CodeMirror .cm-string-2 {
    color: #f07178;
}
.dark .CodeMirror .cm-comment {
    color: #546E7A;
}
.dark .CodeMirror .cm-variable {
    color: #f07178;
}
.dark .CodeMirror .cm-tag {
    color: #FF5370;
}
.dark .CodeMirror .cm-meta {
    color: #FFCB6B;
}
.dark .CodeMirror .cm-attribute {
    color: #C792EA;
}
.dark .CodeMirror .cm-property {
    color: #C792EA;
}
.dark .CodeMirror .cm-qualifier {
    color: #DECB6B;
}
.dark .CodeMirror .cm-variable-3,
.dark .CodeMirror .cm-type {
    color: #DECB6B;
}
.dark .CodeMirror .cm-error {
    color: rgba(255, 255, 255, 1.0);
    background-color: #FF5370;
}
.dark .CodeMirror .CodeMirror-matchingbracket {
    text-decoration: underline;
    color: white !important;
}
/* Codemirror dark theme End. */


#lbox-window {
    position: fixed;
    z-index: 999;
    cursor: pointer;
    background-color: var(--lbox-window);
    display: grid;
    height: 100vh;
    width: 100vw;
    grid-template-areas: "lightbox";
}
#lbox-window img, #lbox-window video, #lbox-window audio {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 3px 7px 0 #0000004d;
    grid-area: lightbox;
    align-self: center;
    justify-self: center;
    overflow: hidden;
}

#lbox-window audio {
    width: 97%;
    height: 54px;
}