:root {
    --bg: #101010;
    --tab: #181818;
    --field: #151515;
    --window: #101010;
    --line: #2b2b2b;
    --text: #c4c4c4;
    --dim: #858585;
    --accent: #ff3e3e;
    --r: 4px;
    --file-scale: 1;
    --file-card-side: 86px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100dvh;
    font-family: "Segoe UI", -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#scaled-app {
    flex: 1 1 auto;
    width: 100%;
    height: calc(100dvh - 38px);
    min-height: 0;
    display: flex;
    flex-direction: column;
}

input {
    outline: none;
    color: #c4c4c4;
}

input:not([type="checkbox"]),
select,
textarea {
    background: rgba(196, 196, 196, 0.08);
    border: 1px solid rgba(196, 196, 196, 0.28);
    border-radius: 7px;
    color: #c4c4c4;
}

input:not([type="checkbox"]):focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(255, 62, 62, 0.12);
}

button {
    cursor: pointer;
    border: none;
    color: var(--text);
    font-size: 12px;
}

/* ── ВКЛАДКИ ── */
#tabs {
    display: flex;
    align-items: flex-end;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 6px 8px 0;
    background: var(--window);
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
}

.tab {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--dim);
    background: transparent;
    border-radius: var(--r) var(--r) 0 0;
    cursor: pointer;
    user-select: none;
}

.tab.active {
    color: var(--text);
    background: var(--tab);
}

.tab .tclose {
    color: var(--dim);
    margin-left: 6px;
    font-size: 11px;
}

.tab .tclose:hover,
#tab-add:hover {
    color: var(--text);
}

#tab-add {
    flex: 0 0 auto;
    background: none;
    color: var(--dim);
    font-size: 18px;
    padding: 4px 8px;
    margin-bottom: 2px;
}

/* ── НАВБАР ── */
#navbar {
    display: flex;
    align-items: center;
    background: var(--tab);
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    height: 38px;
}

#nav-left {
    width: 148px;
    min-width: 148px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 6px;
    flex-shrink: 0;
    border-right: 1px solid var(--line);
}

.nav-btn {
    height: 26px;
    min-width: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    background: transparent;
    border: none;
    color: var(--dim);
    font-size: 14px;
    border-radius: var(--r);
}

.nav-btn:hover {
    color: var(--text);
    background: var(--field);
}

/* Тонкая подстройка пиксельных символов навигации */
#btn-up {
    transform: translateY(1px);
}

#btn-refresh {
    transform: translateY(2px);
}

#path-bar {
    flex: 1;
    height: 26px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 12px;
    font-size: 13px;
    color: var(--dim);
    background: var(--field);
    border-radius: var(--r);
    margin: 0 8px;
    min-width: 100px;
    overflow: hidden;
}
#path-crumbs { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow: auto; scrollbar-width: none; white-space: nowrap; }
#path-bar #btn-refresh { flex: 0 0 auto; margin-left: 8px; transform: none; }

#path-bar span {
    cursor: pointer;
}

#path-bar span:hover {
    color: var(--text);
    text-decoration: underline;
}

#path-bar .sep {
    color: var(--dim);
}


#nav-right {
    position: relative;
    display: flex;
    align-items: center;
    width: 180px;
    min-width: 0;
    flex: 0 1 180px;
    padding-right: 8px;
    flex-shrink: 1;
}

#search-box {
    width: 100%;
    max-width: 180px;
    height: 26px;
    padding: 0 10px;
    font-size: 12px;
    background: var(--field);
    border-radius: var(--r);
    border: none;
}

.search-panel {
    position: absolute;
    top: calc(100% + 14px);
    right: 8px;
    z-index: 130;
    width: min(360px, calc(100vw - 24px));
    max-height: min(440px, calc(100dvh - 90px));
    overflow-y: auto;
    display: none;
    padding: 8px;
    background: var(--tab);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.search-panel.open { display: block; }

.search-scopes {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.search-scopes button {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--r);
    color: var(--dim);
    font-size: 11px;
}

.search-scopes button.active {
    color: var(--text);
    border-color: var(--accent);
}

.search-result {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 6px;
    border-radius: var(--r);
    cursor: pointer;
}

.search-result:hover {
    background: var(--field);
}

.search-result.selected {
    background: rgba(255, 62, 62, 0.16);
    outline: 1px solid var(--accent);
}

.search-result-icon { flex: 0 0 auto; }
.search-result-text { min-width: 0; display: flex; flex-direction: column; }
.search-result-text strong,
.search-result-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-result-text strong { color: var(--text); font-size: 12px; }
.search-result-text small { color: var(--dim); font-size: 10px; }

/* ── РАБОЧЕЕ ПРОСТРАНСТВО ── */
#workspace {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    overflow: hidden;
    background: var(--bg);
}

/* ── СУЖЕННЫЙ САЙДБАР И НАВБАР ── */
#sidebar {
    width: 148px;
    min-width: 148px;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: var(--bg);
    flex-shrink: 0;
    position: relative;
}

#tree-wrap {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    box-sizing: border-box;
    padding: 10px 4px 140px 6px;
    user-select: none;
    -webkit-user-select: none;
}

/* ── КОМПАКТНЫЙ ПРОФИЛЬ / ВХОД В ОДНУ ЛИНИЮ С АВАТАРОМ ── */
#profile {
    box-sizing: border-box;
    position: fixed;
    left: 0;
    bottom: 38px;
    z-index: 111;
    width: 148px;
    max-height: calc(100dvh - 110px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding: 8px;
    border: 1px solid var(--line);
    border-bottom: 0;
    background: var(--window);
}

#auth-compact-row {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 48px;
}

/* Аватарка встает ровно слева на высоту двух полей */
#avatar {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
    border-radius: var(--r);
    background: var(--field);
    object-fit: cover;
    margin: 0;
    flex-shrink: 0;
}

/* Поля ввода справа от аватарки */
#login-fields {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

#login-fields input {
    width: 100%;
    height: 21px;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 2px 6px;
    font-size: 11px;
    color: var(--text);
    text-align: right;
}

#login-fields input::placeholder {
    text-align: right;
    color: var(--dim);
}

/* Блок инфо юзера вместо полей (когда авторизован) */
#user-info-fields {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
}

#p-name {
    text-align: right;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.15;
}

#quota-txt {
    text-align: right;
    font-size: 10px;
    color: var(--dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.15;
}

/* Кнопка "запомнить сессию" со строчной буквы */
.custom-remember {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 5px 0 4px;
    cursor: pointer;
    user-select: none;
}

.chk-text {
    font-size: 10px;
    color: var(--dim);
}

/* Кнопки профиля имеют ту же высоту, что и кнопки файлов */
#auth-btns {
    display: flex;
    gap: 4px;
}

#auth-status {
    display: none;
    margin-top: 4px;
    color: var(--dim);
    font-size: 9px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.auth-btn {
    flex: 1;
    height: 24px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1;
    font-size: 11px;
    color: var(--dim);
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 0 2px;
    cursor: pointer;
    user-select: none;
}

.auth-btn:hover {
    color: var(--text);
    background: var(--tab);
}



#user-controls {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
    max-width: 100%;
    margin-top: 6px;
}

.profile-actions-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
}


.auth-exit-btn {
    width: 62px;
    min-width: 62px;
    max-width: 62px;
    height: 23px;
    min-height: 23px;
    border: 1px solid var(--line);
    font-size: 10px;
    color: var(--dim);
    margin-top: 0;
    padding: 0 3px;
    text-transform: lowercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.auth-exit-btn:hover {
    color: var(--text);
    background: var(--tab);
}

.system-stats-window {
    left: auto;
    top: auto;
    right: 18px;
    bottom: 86px;
    width: 190px;
    height: auto;
    min-width: 170px;
    max-width: calc(100vw - 24px);
    min-height: 0;
    max-height: none;
    transform: none;
    resize: none;
    background: rgba(18, 18, 18, 0.42) !important;
    background-image: none !important;
    backdrop-filter: blur(18px) saturate(135%);
    -webkit-backdrop-filter: blur(18px) saturate(135%);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28) !important;
}

.system-stats-window::after {
    display: none;
}

.system-stats-window.system-stats-expanded {
    width: min(560px, calc(100vw - 24px)) !important;
    height: auto !important;
    max-height: min(760px, calc(100vh - 100px)) !important;
}

.system-stats-window.system-stats-expanded .system-stats-body {
    overflow-y: auto;
}

.system-stats-body {
    padding: 9px 11px 10px;
    color: var(--dim);
    font-size: 11px;
}

.system-stat-row {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    line-height: 1.5;
    white-space: nowrap;
}

.system-stat-row strong {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-weight: 500;
    text-overflow: ellipsis;
}

.system-stats-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    margin-left: auto;
}

.system-stats-toggle,
.system-stats-reboot {
    width: auto;
    min-width: 62px;
    height: 24px;
    padding: 0 7px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--field);
    color: var(--dim);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

.system-stats-toggle:hover,
.system-stats-reboot:hover {
    color: var(--text);
    border-color: var(--accent);
}

.system-stats-reboot.armed {
    border-color: var(--accent);
    color: var(--accent);
}

.system-stats-reboot:disabled {
    opacity: .65;
    cursor: wait;
}

.system-stats-admin {
    margin-top: 9px;
    padding-top: 9px;
    border-top: 1px solid var(--line);
}

.system-stats-admin .admin-panel {
    margin: 0;
}

.system-stats-admin .admin-panel h1 {
    display: none;
}

.system-stats-admin .admin-user-card-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.system-stats-admin .admin-user-danger {
    display: flex;
}

.system-stats-time {
    margin-top: 4px;
    color: var(--dim);
    font-size: 9px;
    opacity: 0.8;
}

#admin-view {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    margin-bottom: 76px;
    box-sizing: border-box;
    border-radius: 12px;
    scrollbar-gutter: stable;
}

.admin-panel {
    max-width: 1000px;
    margin: 0 auto;
}

.admin-panel h1,
.admin-panel h2 {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 500;
}

.admin-section {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: rgba(20, 20, 20, 0.68);
    backdrop-filter: blur(14px) saturate(120%);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    overflow: hidden;
}

.admin-section > summary {
    padding: 11px 12px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}

.admin-section > summary:hover {
    background: rgba(255, 255, 255, 0.04);
}

.admin-section-body {
    padding: 10px;
}

.admin-section-body > :last-child {
    margin-bottom: 0;
}

.admin-settings,
.admin-user-card {
    padding: 12px;
    background: rgba(20, 20, 20, 0.68);
    backdrop-filter: blur(14px) saturate(120%);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: var(--r);
}

.admin-settings-grid,
.admin-user-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.admin-user-card {
    display: block;
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
}

.admin-user-summary {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    list-style: none;
}

.admin-user-summary::-webkit-details-marker {
    display: none;
}

.admin-user-summary::before {
    content: "›";
    color: var(--dim);
    font-size: 16px;
    transition: transform 0.15s ease;
}

.admin-user-card[open] .admin-user-summary::before {
    transform: rotate(90deg);
}

.admin-user-summary:hover {
    background: rgba(255, 255, 255, 0.04);
}

.admin-user-card-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 8px 10px 10px;
    align-items: start;
}

.admin-user-card .admin-user-editor {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 7px;
    min-width: 0;
}

.admin-user-editor > .admin-user-tags {
    grid-column: 1 / -1;
}

.admin-user-editor > .admin-input,
.admin-user-editor > .btn-vpn {
    width: 100%;
}

.admin-user-danger {
    align-self: stretch;
    width: 100%;
}

.admin-user-name {
    display: block;
    margin: 0;
    min-width: 0;
    text-align: left;
    overflow-wrap: anywhere;
}

.admin-user-name.admin-role {
    color: #f87171;
}

.admin-user-editor,
.admin-user-controls,
.admin-user-danger {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.admin-user-controls {
    min-width: 0;
    align-content: flex-start;
}

.admin-user-controls label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1 1 100%;
    color: var(--dim);
    font-size: 10px;
}

.admin-user-controls select {
    width: 100%;
}

.admin-user-controls select[multiple] {
    min-height: 64px;
    padding: 4px;
}

.admin-user-danger {
    justify-content: stretch;
}

.admin-user-danger .btn-vpn {
    flex: 1 1 0;
}

.admin-user-tags {
    flex: 1 1 100%;
    min-width: 0;
}

.admin-user-card select,
.admin-user-card input {
    min-width: 0;
}

.admin-user-meta {
    margin-left: auto;
    min-width: 0;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--dim);
    font-size: 11px;
}

.admin-user-actions input,
.admin-settings input,
.admin-user-editor input,
.admin-user-editor select {
    width: 100px;
    min-width: 0;
    box-sizing: border-box;
}

.admin-user-editor .admin-user-tags {
    width: 100%;
}

.admin-user-editor select {
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 4px 6px;
}

.admin-user-danger .btn-vpn {
    min-height: 26px;
    padding: 5px;
    font-size: 10px;
    overflow-wrap: anywhere;
}

.admin-panel .admin-input {
    height: 26px;
    padding: 4px 7px;
    font-family: inherit;
    font-size: 10px;
    line-height: 16px;
    border-radius: 5px;
    background: rgba(196, 196, 196, 0.08);
    border: 1px solid rgba(196, 196, 196, 0.24);
    color: #c4c4c4;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.admin-settings-grid > .admin-input {
    flex: 1 1 110px;
    width: 110px;
}

.admin-panel .admin-input::placeholder {
    color: #858585;
}

.admin-panel .admin-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(255, 62, 62, 0.12);
    outline: none;
}

.admin-tag-picker {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 6px;
}

.admin-tag-picker > summary {
    cursor: pointer;
    color: var(--dim);
    font-size: 10px;
}

.admin-tag-picker .admin-input {
    height: 70px;
    margin-top: 6px;
}

@media (min-width: 900px) {
    #admin-view {
        margin-bottom: 96px;
    }
}

.admin-danger {
    color: #f87171 !important;
}

#quota-wrap {
    width: 100%;
    height: 2px;
    background: var(--field);
    border-radius: var(--r);
    margin-top: 2px;
}

#quota-fill {
    height: 2px;
    background: var(--accent);
    width: 0%;
}

/* ── ИДЕАЛЬНО ВЫРОВНЕННОЕ ДЕРЕВО WINDOWS ── */
.win-node {
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
}

.win-row {
    display: flex;
    align-items: center;
    height: 24px;
    padding-right: 8px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    font-size: 12px;
    color: var(--text);
    border-radius: var(--r);
}

.win-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

.win-row.selected {
    background: rgba(196, 196, 196, 0.14);
    color: var(--text);
}

/* Слот для шеврона: ВСЕГДА 16px, чтобы иконки стояли ровно */
.win-chevron {
    width: 16px;
    height: 16px;
    min-width: 16px;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.win-chevron.empty {
    visibility: hidden; /* Место зарезервировано, но шеврон пустой */
}

/* Сам шеврон Windows */
.win-arrow {
    display: block;
    width: 9px !important;
    height: 9px !important;
    max-width: 9px;
    max-height: 9px;
    color: var(--dim);
    transition: transform 0.15s ease;
}

.win-chevron:hover .win-arrow {
    color: var(--text);
}

/* Поворот стрелки при раскрытии (без смещений по высоте!) */
.win-arrow.open {
    transform: rotate(90deg);
}

.win-icon {
    margin-right: 6px;
    font-size: 14px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.win-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    -webkit-user-select: none;
}

.win-sub {
    padding-left: 16px; /* Ровный шаг вложенности для подпапок */
}

.auth-btn.err {
    background: var(--accent);
    color: var(--bg);
}

/* Кастомный чекбокс */
.custom-remember input {
    display: none;
}

.custom-chk-box {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--line);
    background: var(--field);
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-remember input:checked + .custom-chk-box {
    background: var(--accent);
    border-color: var(--accent);
}

.custom-remember input:checked + .custom-chk-box::after {
    content: "✓";
    font-size: 10px;
    color: var(--bg);
    font-weight: bold;
}


/* ── ЦЕНТРАЛЬНАЯ ЧАСТЬ И СЕТКА ── */
#center-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: auto;
    box-sizing: border-box;
    padding-bottom: 90px;
}

/* ── СЕТКА ПАПОК И ФАЙЛОВ ── */
#grid {
    position: relative;
    flex: 1;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(calc(70px * var(--file-scale)), 1fr));
    grid-auto-flow: dense;
    grid-auto-rows: calc(86px * var(--file-scale));
    gap: calc(8px * var(--file-scale));
    align-content: start;
    transition: background-image .25s ease;
}

#grid.canvas-mode {
    position: relative;
    display: block;
    flex: 0 0 auto;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    padding: 0;
    overflow: visible;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

#main.canvas-host { overflow: hidden; position: relative; padding-bottom: 0; touch-action: none; }
#grid.canvas-bounded { outline: 1px dashed rgba(255,255,255,.24); outline-offset: -1px; }
#grid.canvas-mode:active { cursor: grabbing; }
#grid.canvas-mode .canvas-item {
    position: absolute;
    width: calc(130px * var(--file-scale));
    height: calc(120px * var(--file-scale));
    min-height: 60px;
    box-sizing: border-box;
    overflow: visible;
    transition: box-shadow .15s ease;
    cursor: grab;
    user-select: none;
}
#grid.canvas-mode .canvas-item:active { cursor: grabbing; }
#grid.canvas-mode .canvas-item:hover { box-shadow: 0 8px 24px rgba(0,0,0,.35); }
#grid.canvas-mode .canvas-item.selected { outline: none; background: transparent; }
.canvas-transform-frame { --frame-blue: #5099ff; position: absolute; inset: 0; z-index: 5; border: calc(1px * var(--canvas-control-scale, 1)) solid var(--frame-blue); border-radius: 0; opacity: 0; visibility: hidden; transform: scale(.97); pointer-events: none; transition: opacity .18s ease, transform .18s ease, visibility .18s; }
.canvas-item.selected .canvas-transform-frame { opacity: 1; visibility: visible; transform: scale(1); }
.canvas-transform-handle { position: absolute; z-index: 2; width: calc(18px * var(--canvas-control-scale, 1)); height: calc(18px * var(--canvas-control-scale, 1)); transform: translate(-50%, -50%); touch-action: none; pointer-events: none; }
.canvas-transform-handle::after { content: ""; position: absolute; left: 50%; top: 50%; width: calc(8px * var(--canvas-control-scale, 1)); height: calc(8px * var(--canvas-control-scale, 1)); box-sizing: border-box; border: calc(1px * var(--canvas-control-scale, 1)) solid var(--frame-blue); background: #fff; transform: translate(-50%, -50%); }
.canvas-item.selected .canvas-transform-handle, .canvas-item.selected .canvas-rotate-zone { pointer-events: auto; }
.handle-nw { left: 0; top: 0; cursor: nwse-resize; }
.handle-n { left: 50%; top: 0; cursor: ns-resize; }
.handle-ne { left: 100%; top: 0; cursor: nesw-resize; }
.handle-e { left: 100%; top: 50%; cursor: ew-resize; }
.handle-se { left: 100%; top: 100%; cursor: nwse-resize; }
.handle-s { left: 50%; top: 100%; cursor: ns-resize; }
.handle-sw { left: 0; top: 100%; cursor: nesw-resize; }
.handle-w { left: 0; top: 50%; cursor: ew-resize; }
.canvas-rotate-zone { position: absolute; z-index: 1; touch-action: none; pointer-events: none; cursor: crosshair; }
.rotate-n, .rotate-s { left: 0; right: 0; height: calc(18px * var(--canvas-control-scale, 1)); }
.rotate-n { bottom: calc(100% + 8px * var(--canvas-control-scale, 1)); }
.rotate-s { top: calc(100% + 8px * var(--canvas-control-scale, 1)); }
.rotate-e, .rotate-w { top: 0; bottom: 0; width: calc(18px * var(--canvas-control-scale, 1)); }
.rotate-e { left: calc(100% + 8px * var(--canvas-control-scale, 1)); }
.rotate-w { right: calc(100% + 8px * var(--canvas-control-scale, 1)); }
.rotate-nw, .rotate-ne, .rotate-sw, .rotate-se { width: calc(26px * var(--canvas-control-scale, 1)); height: calc(26px * var(--canvas-control-scale, 1)); }
.rotate-nw, .rotate-ne { bottom: 100%; }
.rotate-sw, .rotate-se { top: 100%; }
.rotate-nw, .rotate-sw { right: 100%; }
.rotate-ne, .rotate-se { left: 100%; }
@media (prefers-reduced-motion: reduce) { .canvas-transform-frame { transition: none; } }
#grid.canvas-mode .canvas-item .name,
#grid.canvas-mode .canvas-item .size { position: absolute; top: 100%; left: 0; width: 100%; margin-top: 4px; opacity: 0; transition: opacity .16s ease; pointer-events: none; text-align: center; }
#grid.canvas-mode .canvas-item .size { margin-top: calc(8px + 2.8em); }
#grid.canvas-mode .canvas-item:hover .name, #grid.canvas-mode .canvas-item.selected .name,
#grid.canvas-mode .canvas-item:hover .size, #grid.canvas-mode .canvas-item.selected .size { opacity: 1; }
#marafet-toggle[aria-pressed="true"] { color: var(--accent); }
#marafet-layers.marafet-layers { left: auto; top: 110px; right: 20px; width: min(270px, calc(100vw - 24px)); height: min(380px, calc(100dvh - 210px)); min-width: 180px; transform: none; background: rgba(24,24,24,.94); }
#marafet-layer-list { flex: 1; overflow: auto; padding: 6px; }
.marafet-layer { display: block; width: 100%; padding: 8px; border: 0; border-radius: 4px; background: transparent; color: var(--text); font: inherit; font-size: 12px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: grab; }
.marafet-layer:hover { background: #ffffff0d; }
.marafet-layer.selected { background: #ffffff18; box-shadow: inset 2px 0 var(--accent); }
#grid.marafet-mode .item { cursor: grab; }
#grid.marafet-mode .marafet-dragging { opacity: .4; }
#grid.canvas-mode .selection-marquee { z-index: 2147483647; }
#grid.canvas-mode .asset-sticker { overflow: visible; background: transparent !important; border: 0 !important; box-shadow: none; }
#grid.canvas-mode .canvas-item .icon.preview { height: calc(100% - 16px); }
#grid.canvas-mode .asset-sticker .icon.preview { height: calc(100% - 16px); background: transparent; overflow: visible; }
#grid.canvas-mode .asset-sticker .icon.preview img { object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0,0,0,.45)); }
#grid.canvas-mode .canvas-item.folder-large { width: calc(260px * var(--file-scale)); height: calc(240px * var(--file-scale)); }
.item.tile-1-1 { grid-column: span 1; grid-row: span 1; }
.item[class*="tile-"] { height: 100%; min-height: 0; box-sizing: border-box; }
.item.tile-2-1 { grid-column: span 2; grid-row: span 1; }
.item.tile-1-2 { grid-column: span 1; grid-row: span 2; }
.item.tile-2-2 { grid-column: span 2; grid-row: span 2; }
.item.tile-3-1 { grid-column: span 3; grid-row: span 1; }
.item.tile-3-2 { grid-column: span 3; grid-row: span 2; }
.item.tile-1-3 { grid-column: span 1; grid-row: span 3; }
.item.tile-2-3 { grid-column: span 2; grid-row: span 3; }
.item.tile-3-3 { grid-column: span 3; grid-row: span 3; }
.tile-shape-grid:not(.canvas-mode) { grid-auto-flow: row dense; grid-auto-columns: calc(var(--file-card-side) * var(--file-scale)); }
.item.tile-shape-managed[class*="tile-"] { min-height: 0; }
#grid:not(.canvas-mode) > .item.tile-shape-irregular { padding: 0; }
#grid:not(.canvas-mode) > .item.tile-shape-irregular > .tile-shape-content {
    position: absolute;
    left: var(--tile-content-x, 0px);
    top: var(--tile-content-y, 0px);
    width: var(--tile-content-width, 100%);
    height: var(--tile-content-height, 100%);
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
    padding: calc(6px * var(--file-scale)) 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
#grid:not(.canvas-mode) .tile-shape-content > .icon:not(.preview) {
    width: 100%;
    font-size: min(calc(38px * var(--file-scale)), calc(var(--tile-content-height, 86px) * .45));
}
#grid:not(.canvas-mode) .tile-shape-content > .name { flex-shrink: 0; }
.item.folder-large { grid-column: span 2; grid-row: span 2; min-height: calc(174px * var(--file-scale)); }
.item.folder-stealth { opacity: 0; background: transparent !important; outline: none !important; }
.item.folder-stealth:hover { opacity: .12; cursor: pointer; }

.item {
    position: relative;
    width: 100%;
    height: calc(86px * var(--file-scale));
    min-width: 0;
    min-height: calc(86px * var(--file-scale));
    padding: calc(6px * var(--file-scale)) 2px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    border-radius: var(--r);
    overflow: hidden;
}

.item:hover {
    background: var(--tab);
}

.item.selected {
    background: rgba(255, 62, 62, .18);
    outline: 1px solid var(--accent);
}

.selection-marquee {
    position: absolute;
    z-index: 20;
    border: 1px solid rgba(112, 118, 128, .9);
    background: rgba(42, 45, 51, .62);
    border-radius: 2px;
    pointer-events: none;
}

#grid.marquee-active,
#grid.multi-select-mode {
    user-select: none;
    -webkit-user-select: none;
}

#grid.marquee-active { cursor: crosshair; }
#grid.multi-select-mode { cursor: copy; }
#grid.marquee-active .item { transition: none; }

.item.cut-item {
    opacity: 0.42;
}

.bg-set-button {
    position: absolute;
    left: 50%;
    bottom: 3px;
    z-index: 2;
    transform: translateX(-50%);
    height: 18px;
    min-height: 18px;
    padding: 0 6px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: rgba(16, 16, 16, .82);
    color: var(--text);
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
    touch-action: manipulation;
}

.bg-set-button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.item .icon {
    font-size: calc(38px * var(--file-scale));
    line-height: 1;
}

.item .icon.preview {
    width: 100%;
    height: calc(42px * var(--file-scale));
    margin: 0 auto;
    overflow: hidden;
    border-radius: var(--r);
    background: #0a0a0a;
}
.item.asset-sticker { background: transparent; border-color: transparent; box-shadow: none; }
.item.asset-sticker:hover, .item.asset-sticker.selected { background: transparent; }
.item.asset-sticker .icon.preview { background: transparent; overflow: visible; }
.item.asset-sticker .icon.preview img { object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0,0,0,.45)); }
.item.asset-sticker .name, .item.asset-sticker .size { display: none; }
.item.transparent-art-card,
.item.transparent-art-card:hover,
.item.transparent-art-card.selected { background: transparent; border-color: transparent; box-shadow: none; }
.item.transparent-art-card .icon.preview { background: transparent; overflow: visible; }
.item.transparent-art-card .icon.preview img { object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .45)); }

.item .icon.preview img,
.item .icon.preview video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.item .name {
    font-size: calc(11px * var(--file-scale));
    line-height: 1.15;
    margin-top: 4px;
    color: var(--dim);
    word-break: break-all;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

.item .size {
    margin-top: 2px;
    color: var(--dim);
    font-size: calc(9px * var(--file-scale));
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#grid.dragover {
    outline: 2px dashed var(--accent);
    background: var(--field);
}

#grid:not(.canvas-mode) {
    grid-template-columns: repeat(auto-fill, calc(var(--file-card-side) * var(--file-scale)));
    grid-auto-rows: calc(var(--file-card-side) * var(--file-scale));
}

#grid:not(.canvas-mode) .item {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: calc(var(--r) + 2px);
}

#grid:not(.canvas-mode) .item .icon:not(.preview) {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#grid:not(.canvas-mode) .item .name,
#grid:not(.canvas-mode) .item .size {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    width: 100%;
    margin-top: 0;
    text-align: center;
}

#grid:not(.canvas-mode) .item .name {
    order: 2;
}

#grid:not(.canvas-mode) .item .size {
    order: 1;
    margin-bottom: calc(2px * var(--file-scale));
}

#grid:not(.canvas-mode) .item .icon.preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    border-radius: inherit;
}

#grid:not(.canvas-mode) .item .icon.preview img,
#grid:not(.canvas-mode) .item .icon.preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: none;
}

#grid:not(.canvas-mode) .media-card {
    justify-content: flex-end;
    isolation: isolate;
}

#grid:not(.canvas-mode) .media-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
    background: linear-gradient(to top, rgba(0, 0, 0, .48), transparent 60%);
    pointer-events: none;
}

#grid:not(.canvas-mode) .media-card .name,
#grid:not(.canvas-mode) .media-card .size {
    color: #f0f0f0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .65);
}

#grid:not(.canvas-mode) .media-card .name {
    display: -webkit-box;
}

#grid:not(.canvas-mode) .media-card .size {
    display: block;
}

#grid:not(.canvas-mode) .item:hover {
    outline: 1px solid var(--dim);
    outline-offset: 0;
}

#grid:not(.canvas-mode) .item.selected {
    outline: 2px solid var(--accent);
    outline-offset: 0;
}

@media (max-width: 899px) {
    :root {
        --file-card-side: 70px;
    }

    #grid:not(.canvas-mode) {
        padding: 6px;
        gap: calc(5px * var(--file-scale));
    }
}

/* ── ФИКСИРОВАННЫЕ ДЕЙСТВИЯ TELEPORT ── */
#action-bar {
    position: fixed;
    right: 8px;
    top: 51%;
    transform: translateY(-50%);
    z-index: 140;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 5px;
    background: rgba(16, 16, 16, 0.34);
    backdrop-filter: blur(8px) saturate(125%);
    -webkit-backdrop-filter: blur(8px) saturate(125%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.act-btn {
    width: 32px;
    height: 30px;
    min-width: 32px;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 16px;
    line-height: 1;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r);
    cursor: pointer;
    user-select: none;
}

.act-btn { font-family: system-ui, "Segoe UI Symbol", sans-serif; font-variant-emoji: text; }
.act-btn[aria-label="Удалить"] { color: var(--text); }
.act-btn[aria-label="Копировать"], .act-btn[aria-label="Вставить"] { font-size: 14px; font-weight: 500; }

.act-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: transparent;
}

.act-btn.danger:hover {
    background: rgba(255, 62, 62, 0.14);
    border-color: transparent;
    color: var(--accent);
}

.act-btn:focus-visible {
    outline: 1px solid rgba(255, 255, 255, 0.42);
    outline-offset: -2px;
}

/* Компактный индикатор передачи по центру над масштабом */
#transfer-bar {
    position: fixed;
    left: 50%;
    bottom: 82px;
    z-index: 119;
    width: min(420px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 9px 10px;
    background: rgba(16, 16, 16, 0.97);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    color: var(--dim);
    font-size: 11px;
    visibility: hidden;
    opacity: 0;
    transform: translate(-50%, 8px);
    pointer-events: none;
    transition: opacity 0.9s ease, transform 0.9s ease, visibility 0s linear 0.9s;
}

#transfer-bar.visible {
    visibility: visible;
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

#transfer-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

#transfer-status {
    flex: 0 0 auto;
    min-width: 58px;
    white-space: nowrap;
}

#transfer-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
    color: var(--dim);
    font-size: 10px;
}

#transfer-pause,
#transfer-cancel {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--field);
    color: var(--text);
    font-size: 14px;
    line-height: 19px;
    cursor: pointer;
}

#transfer-cancel {
    border-color: rgba(255, 62, 62, 0.7);
    background: rgba(255, 62, 62, 0.16);
    color: var(--accent);
    font-size: 17px;
}

#transfer-pause:hover:not(:disabled),
#transfer-cancel:hover:not(:disabled) {
    background: var(--tab);
    border-color: var(--accent);
    color: var(--text);
}

#transfer-cancel:hover:not(:disabled) {
    background: var(--accent);
    color: var(--bg);
}

#transfer-pause:disabled,
#transfer-cancel:disabled {
    opacity: 0.35;
    cursor: default;
}

#transfer-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-size: 10px;
}

.transfer-track {
    width: 100%;
    height: 4px;
    overflow: hidden;
    background: var(--field);
    border-radius: var(--r);
}

#transfer-fill {
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width 0.12s ease;
}

#transfer-percent {
    width: 100%;
    min-width: 0;
    text-align: right;
    font-size: 10px;
}

#transfer-time {
    min-height: 12px;
    color: var(--dim);
    font-size: 10px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── FOLDER STYLER ── */
.folder-styler-modal { --styler-square: clamp(24px, calc((100vw - 140px) / 3), 144px); position: fixed; left: 50%; top: 50%; z-index: 300; transform: translate(-50%, -50%); width: min(600px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; background: #151515; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 48px #000b; font-family: system-ui, "Segoe UI", sans-serif; }
#folder-styler-overlay.qr-overlay { position: static; display: contents; background: transparent; backdrop-filter: none; pointer-events: none; }
#folder-styler-overlay.open { display: contents; }
#folder-styler-overlay #folder-styler-modal { display: none; pointer-events: auto; }
#folder-styler-overlay.open #folder-styler-modal { display: flex; flex-direction: column; }

.folder-styler-modal .qr-modal-header { font-size: 14px; }
.folder-styler-modal button, .folder-styler-modal input, .folder-styler-modal select { font-family: inherit; }
.folder-styler-modal .qr-modal-header, .folder-styler-body label, .styler-section-title, .styler-stealth-toggle, .styler-apply { text-transform: none; letter-spacing: normal; }
.folder-styler-modal .qr-modal-header > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transform: translateY(-1px); }
.styler-header-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.styler-header-actions #folder-style-reset.nav-btn { width: auto; min-width: 30px; height: 30px; margin: 0; padding: 0 8px; border: 1px solid var(--line); background: var(--field); font-size: 12px; }
.folder-styler-body { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; }
.folder-styler-body *, .folder-styler-body *::before, .folder-styler-body *::after { box-sizing: border-box; }
.folder-styler-body [hidden] { display: none !important; }
.styler-text-controls { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.styler-text-controls > label, .styler-text-color-control { min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 7px; color: var(--dim); font-size: 11px; }
.styler-text-controls > label > span, .styler-text-color-control > label { text-align: center; }
.styler-text-color-inline { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 6px; }
.styler-text-color-inline.custom { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
#folder-style-text-custom-row { display: flex; justify-content: center; min-width: 0; }
.styler-text-color-inline input[type="color"] { width: 32px; height: 32px; aspect-ratio: 1; padding: 0; border: 0; border-radius: 4px; }
.styler-text-color-inline input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.styler-text-color-inline input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 4px; }
.styler-text-color-inline input[type="color"]::-moz-color-swatch { border: 0; border-radius: 4px; }
.styler-text-controls input, .styler-text-controls select { display: block; width: 100%; min-width: 0; height: 32px; margin: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--field); color: var(--text); font: inherit; font-size: 12px; }
.styler-text-controls .qr-ctrl-row input[type="text"] { padding: 6px 8px; }
.styler-text-controls input[type="color"] { padding: 3px; cursor: pointer; }
.styler-text-controls input:focus-visible, .styler-text-controls select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.styler-effects-block { display: flex; flex-direction: column; gap: 8px; }
.styler-effect-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: end; gap: 12px; }
.styler-effect-row > .styler-effect-toggle input { transform: translateX(5px); }
.styler-effect-row > .styler-effect-toggle span { margin-left: 5px; }
.styler-gradient-toggle-row { align-self: flex-start; }
.styler-effect-toggle { display: flex; align-items: center; gap: 7px; min-height: 14px; color: var(--text); font-size: 11px; text-transform: none; }
.styler-effect-toggle input { flex: 0 0 auto; width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.styler-effect-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.styler-range { min-width: 0; display: flex; flex-direction: column; gap: 3px; color: var(--dim); font-size: 10px; }
.styler-range b { font-weight: 400; color: var(--text); }
.styler-range input { width: 100%; min-width: 0; height: 14px; margin: 0; accent-color: var(--accent); }
.styler-range input:disabled { opacity: .35; }
.styler-gradient-block { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.styler-gradient-column { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }

.styler-color-picker { display: grid; grid-template-columns: var(--styler-square) 18px; align-items: stretch; gap: 6px; height: var(--styler-square); }
.gradient-sv-picker { position: relative; width: var(--styler-square); height: var(--styler-square); overflow: hidden; border: 0; border-radius: 7px; touch-action: none; cursor: crosshair; background-image: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent); }
.gradient-picker-marker { position: absolute; width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #0008; transform: translate(-50%, -50%); pointer-events: none; }
.gradient-hue { appearance: none; writing-mode: vertical-lr; direction: rtl; width: 18px; height: var(--styler-square); min-width: 0; margin: 0; padding: 0; background: transparent; cursor: pointer; touch-action: none; }
.gradient-hue::-webkit-slider-runnable-track { width: 8px; height: 100%; border-radius: 999px; background: linear-gradient(to top, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.gradient-hue::-moz-range-track { width: 8px; height: 100%; border-radius: 999px; background: linear-gradient(to top, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.gradient-hue::-webkit-slider-thumb { appearance: none; width: 16px; height: 8px; margin-left: -4px; border: 2px solid #fff; border-radius: 4px; background: #333; box-shadow: 0 1px 3px #0008; }
.gradient-hue::-moz-range-thumb { width: 12px; height: 4px; border: 2px solid #fff; border-radius: 4px; background: #333; }
.gradient-preview-large { position: relative; width: calc(var(--styler-square) * 1.1); height: calc(var(--styler-square) * 1.1); border: 0; border-radius: 7px; background: #2b2b2b; }
.gradient-point { position: absolute; width: 16px; height: 16px; padding: 0; border: 2px solid #fff; border-radius: 50%; transform: translate(-50%, -50%); cursor: grab; touch-action: none; }
.gradient-point:active { cursor: grabbing; }
.gradient-point:focus-visible, .gradient-sv-picker:focus-visible, .gradient-hue:focus-visible, .styler-tile-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.gradient-point-a { left: 6%; top: 6%; }
.gradient-point-b { left: 94%; top: 94%; }

.styler-bottom-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 10px; padding-top: 4px; }
.folder-live-preview { min-width: 0; display: grid; grid-template-rows: 158.4px; align-content: start; justify-items: center; }
.styler-bottom-row .styler-tile-size { min-width: 0; display: grid; grid-template-rows: 140px auto; align-content: start; justify-items: center; gap: 4px; position: relative; }
.styler-shape-controls { width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: end; gap: 8px; }
.styler-shape-controls .ctx-tile-buttons { width: min(100%, 116px); }
.styler-section-title { position: absolute; top: 0; display: flex; align-items: center; justify-content: center; min-width: 0; color: var(--dim); font-size: 11px; line-height: 1.3; font-weight: 400; text-align: center; overflow-wrap: anywhere; }
.styler-stealth-toggle { transform: translateY(-1px); flex: 0 0 auto; justify-self: center; display: inline-flex; align-items: center; justify-content: center; gap: 5px; max-width: 100%; min-height: 30px; margin: 0; padding: 5px 8px; border: 0; border-radius: 6px; background: var(--field); color: var(--dim); font: inherit; font-size: 12px; text-align: center; cursor: pointer; }
.styler-stealth-toggle:hover, .styler-stealth-toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--text); }
.styler-stealth-toggle:focus-visible, .styler-apply:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.styler-card-stage, .styler-grid-stage { width: 100%; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; }
.folder-live-card { --styler-preview-fit: 1; flex: 0 0 auto; width: calc(var(--file-card-side) * var(--file-scale)); height: calc(var(--file-card-side) * var(--file-scale)); min-height: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 6px; border: 0; border-radius: 10px; background: #2b2b2b; color: var(--text); box-shadow: 0 6px 18px #0004; transition: background .18s ease, color .18s ease, backdrop-filter .18s ease; }
#folder-style-live-icon { font-size: calc(38px * var(--file-scale) * var(--styler-preview-fit)); line-height: 1; }
#folder-style-live-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: calc(11px * var(--file-scale) * var(--styler-preview-fit)); }
.styler-tile-grid { width: min(100%, 64px); aspect-ratio: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 4px; }
.styler-tile-cell { min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 4px; background: #343434; cursor: pointer; transition: background .15s ease; }
.styler-tile-cell.active { background: var(--accent); }
.styler-tile-cell:hover { background: #555; }
.styler-tile-cell.active:hover { background: var(--accent); filter: brightness(1.15); }
.styler-bottom-row .btn-vpn.primary.styler-apply { justify-self: center; width: auto; max-width: 100%; min-height: 30px; margin: 0; padding: 5px 12px; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: #fff; font: inherit; font-size: 12px; text-align: center; white-space: normal; cursor: pointer; }
#folder-styler-status:empty { display: none; }
@media (max-width: 460px) {
    .folder-styler-body { gap: 10px; padding: 12px; }
    .styler-gradient-block, .styler-bottom-row { gap: 8px; }
    .styler-effect-row { grid-template-columns: 88px minmax(0, 1fr); gap: 6px; }
    .styler-effect-controls { gap: 8px; }
    .styler-bottom-row { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 8px; }
    .styler-bottom-row .styler-text-controls { grid-column: 1 / -1; }
}
@media (max-width: 300px) {
    .folder-styler-modal .qr-modal-header { gap: 4px; padding: 0 8px; }
    .styler-header-actions { gap: 2px; }
    .styler-header-actions #folder-style-reset.nav-btn { padding: 0 4px; }
    .styler-effect-row, .styler-effect-controls, .styler-bottom-row { grid-template-columns: minmax(0, 1fr); }
}

/* ── ПЛАВАЮЩИЙ МЕДИА-ПЛЕЕР ── */
.player-window {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 180;
    width: min(680px, calc(100vw - 32px));
    height: min(460px, calc(100vh - 80px));
    min-width: 240px;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
    transform: translate(-50%, -50%);
    backdrop-filter: blur(18px) saturate(135%);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

#media-player.player-window {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.player-window.maximized {
    inset: 10px;
    left: 10px !important;
    top: 10px !important;
    right: 10px !important;
    bottom: 10px !important;
    width: auto !important;
    height: auto !important;
    transform: none;
    resize: none;
}

.player-window:fullscreen,
.player-window:-webkit-full-screen {
    inset: 0;
    left: 0 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border: none;
    border-radius: 0;
    transform: none;
    resize: none;
}

/* Нативный resize работает за правый нижний угол; делаем его заметным. */
.player-window:not(.maximized):not(:fullscreen)::after {
    content: "";
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 14px;
    height: 14px;
    pointer-events: none;
    background: linear-gradient(135deg, transparent 45%, var(--dim) 46%, var(--dim) 55%, transparent 56%) 0 0 / 7px 7px;
    opacity: 0.8;
}

.player-header {
    flex: 0 0 34px;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 8px 0 12px;
    background: rgba(35, 35, 35, 0.48);
    backdrop-filter: blur(14px) saturate(125%);
    -webkit-backdrop-filter: blur(14px) saturate(125%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    cursor: move;
    user-select: none;
}

.player-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-size: 12px;
}

.player-controls {
    display: flex;
    gap: 4px;
}

.player-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--field);
    color: var(--text);
}

.player-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.player-btn.danger:hover {
    background: var(--accent);
    color: var(--bg);
}

.player-body {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(180, 190, 205, .08) !important;
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, .15);
}

.player-body img,
.player-body video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.player-body audio {
    width: calc(100% - 24px);
}

/* Пустой нижний блок для будущих ссылок автора: на всю ширину */
#footer-links {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 109;
    height: 38px;
    background: var(--window);
    border: 1px solid var(--line);
}

/* Нижний островок масштаба на всю ширину */
#scale-bar {
    position: fixed;
    left: 148px;
    right: 0;
    bottom: 38px;
    z-index: 110;
    height: 38px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    background: rgba(16, 16, 16, 0.34);
    backdrop-filter: blur(8px) saturate(125%);
    -webkit-backdrop-filter: blur(8px) saturate(125%);
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    color: var(--dim);
    font-size: 11px;
}

#ui-scale {
    flex: 1 1 80px;
    min-width: 40px;
    height: 4px;
    appearance: none;
    background: var(--line);
    border-radius: 999px;
    accent-color: var(--accent);
}

#ui-scale::-webkit-slider-runnable-track {
    height: 4px;
    background: var(--line);
    border-radius: 999px;
}

#ui-scale::-webkit-slider-thumb {
    width: 12px;
    height: 12px;
    margin-top: -4px;
    appearance: none;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
}

#ui-scale::-moz-range-track {
    height: 4px;
    background: var(--line);
    border-radius: 999px;
}

#ui-scale::-moz-range-progress {
    height: 4px;
    background: var(--accent);
    border-radius: 999px;
}

#ui-scale::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
}

.scale-btn,
.scale-value {
    height: 24px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--field);
    color: var(--text);
    cursor: pointer;
}

.scale-btn {
    width: 24px;
    min-width: 24px;
    padding: 0;
    font-size: 16px;
    line-height: 1;
}

.scale-value {
    width: 78px;
    min-width: 78px;
    padding: 0 5px;
    font-size: 11px;
    box-sizing: border-box;
}

#scale-readout {
    width: 52px;
    min-width: 52px;
    flex: 0 0 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden-files-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    line-height: 0;
    outline: none;
    box-shadow: none;
}

.hidden-files-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.hidden-files-toggle svg {
    display: block;
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hidden-files-toggle.showing-hidden {
    border-color: var(--accent);
    color: var(--accent);
}

.hidden-files-toggle.showing-hidden .hidden-eye-slash {
    display: none;
}

.space-mode-toggle {
    width: 78px;
    min-width: 78px;
    flex: 0 0 78px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    box-sizing: border-box;
    transition: border-color .15s ease;
}

.space-mode-toggle.canvas-mode-active {
    border-color: var(--accent);
    color: var(--text);
}

#space-mode-toggle[hidden] {
    display: none !important;
}

.scale-label-value {
    display: inline;
}

.scale-btn:hover,
.scale-value:hover {
    border-color: var(--accent);
    color: var(--accent);
}

@keyframes tp-content-fade {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

.content-enter {
    animation: tp-content-fade 0.24s ease both;
}

@media (max-width: 520px) {
    #vpn-view {
        padding-left: 12px;
        padding-right: 12px;
    }

    .vpn-card {
        padding: 14px;
    }

    #nav-right {
        width: 120px;
        flex: 0 1 120px;
        padding-right: 6px;
    }

    #search-box {
        max-width: none;
    }

    #path-bar {
        min-width: 0;
    }

    #scale-bar {
        left: 148px;
        gap: 2px;
        padding: 0 4px;
    }

    #scale-bar .scale-btn {
        width: 20px;
        min-width: 20px;
    }

    #scale-readout {
        width: 40px;
        min-width: 40px;
        flex-basis: 40px;
    }

    .hidden-files-toggle svg {
        width: 14px;
        height: 14px;
    }

    .space-mode-toggle {
        width: 62px;
        min-width: 62px;
        flex-basis: 62px;
    }

    #ui-scale {
        min-width: 0;
    }

    #transfer-bar {
        left: 156px;
        right: 6px;
        bottom: 82px;
        width: auto;
        transform: translateY(8px);
    }

    #transfer-bar.visible {
        transform: translateY(0);
    }

    #action-bar {
        right: 6px;
    }
}

.item.dragging {
    opacity: 0.45;
}

.item.drop-target,
.win-row.drop-target {
    outline: 1px dashed var(--accent);
    background: rgba(255, 62, 62, 0.14);
}

/* ── СТИЛИ ЛИЧНОГО КАБИНЕТА VPN ── */
#vpn-view {
    display: none;
    flex: 1;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 24px 24px 110px;
    background: var(--bg);
}

.vpn-empty-msg {
    color: var(--dim);
    font-size: 13px;
    padding: 60px;
    text-align: center;
}

.vpn-card {
    width: 100%;
    max-width: 820px;
    background: var(--window);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.vpn-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.vpn-selector-label {
    color: var(--dim);
    font-size: 11px;
    margin: 8px 0 6px;
    text-transform: lowercase;
}

.vpn-proto-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.proto-btn {
    padding: 6px 14px;
    font-size: 12px;
    background: var(--tab);
    border-radius: var(--r);
    color: var(--dim);
    cursor: pointer;
}

.proto-btn.active {
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
}

.vpn-keybox {
    background: #0a0a0a;
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 10px;
    font-family: monospace;
    font-size: 11px;
    word-break: break-all;
    max-height: 60px;
    overflow-y: auto;
    scrollbar-width: thin;
    color: #a3e635;
    margin-bottom: 12px;
    user-select: all;
}

.vpn-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
    margin-bottom: 14px;
}

.btn-vpn {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    padding: 6px 12px;
    border-radius: var(--r);
    background: var(--tab);
    color: var(--text);
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-vpn.primary {
    background: var(--accent);
    color: var(--bg);
}

.btn-vpn.copy-btn {
    background: #3a3a3a;
    color: #eeeeee;
    border: 1px solid #555555;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.btn-vpn.copy-btn:hover {
    background: #4a4a4a;
    border-color: #777777;
}

.btn-vpn.copy-btn.copy-success {
    background: #4ade80;
    border-color: #4ade80;
    color: #101010;
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.35);
}

.btn-vpn.copy-btn.copy-error {
    background: #ef4444;
    border-color: #ef4444;
    color: #101010;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

.vpn-qr-wrap {
    display: flex;
    background: #ffffff;
    padding: 8px;
    border-radius: 6px;
    width: fit-content;
}

.vpn-qr-wrap img {
    width: 160px;
    height: 160px;
}

.vpn-downloads {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.vpn-downloads .btn-vpn {
    cursor: pointer;
    border: 0;
}

.vpn-admin-card {
    border-color: var(--accent);
}

.vpn-admin-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vpn-admin-form input,
.vpn-admin-form textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--field);
    border: 0;
    border-radius: var(--r);
    color: var(--text);
    padding: 8px;
    font: inherit;
    font-size: 12px;
}

.vpn-admin-form textarea {
    min-height: 60px;
    resize: vertical;
    font-family: monospace;
}

.vpn-ok {
    color: #4ade80;
    font-size: 11px;
}

.vpn-error {
    color: #f87171;
    font-size: 11px;
}

.guide-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 10px 0;
}

.guide-content p,
.guide-content h1,
.guide-content h2,
.guide-content h3 {
    margin: 8px 0;
}

.guide-accordion details {
    background: var(--tab);
    margin-bottom: 6px;
    border-radius: var(--r);
    border: 1px solid var(--line);
}

.guide-accordion summary {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
}

.guide-content {
    box-sizing: border-box;
    max-width: 100%;
    overflow-wrap: anywhere;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--dim);
    border-top: 1px solid var(--line);
}

.guide-content img,
#vpn-guide-body img {
    display: block;
    max-width: 100%;
    height: auto;
}

#vpn-guide-body {
    max-width: 100%;
    overflow-wrap: anywhere;
}

/* ── МОДАЛЬНЫЕ ОКНА ── */
#ui-modal-overlay, #lock-overlay, #editor-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    z-index: 200;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease, visibility 0s linear 0.28s;
}

#ui-modal-overlay.open, #lock-overlay.open, #editor-overlay.open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.28s ease;
}

#ui-modal-box, #lock-box {
    background: var(--window);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 20px;
    width: 320px;
    max-width: 90vw;
    transform: translateY(6px) scale(0.98);
    transition: transform 0.28s ease;
}

#ui-modal-overlay.open > #ui-modal-box,
#lock-overlay.open > #lock-box,
#editor-overlay.open > #editor-box {
    transform: translateY(0) scale(1);
}

#ui-modal-title, #lock-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

#ui-modal-input, #lock-input {
    width: 100%;
    padding: 8px;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--r);
    font-size: 12px;
    color: var(--text);
    margin-bottom: 12px;
}

.ui-modal-btns {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.ui-modal-btns button, #lock-box button {
    padding: 6px 14px;
    border-radius: var(--r);
    font-size: 12px;
}

.btn-sub { background: var(--tab); color: var(--dim); }
.btn-act { background: var(--accent); color: var(--bg); }
.btn-act.danger { background: var(--accent); color: var(--bg); }

#lock-close {
    position: absolute;
    top: 8px;
    right: 10px;
    cursor: pointer;
}

#editor-box {
    width: 860px;
    max-width: 96vw;
    height: 82vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r);
}

#editor-head {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--tab);
    border-bottom: 1px solid var(--line);
}

#editor-ta {
    flex: 1;
    padding: 12px;
    font-family: monospace;
    font-size: 12px;
    background: var(--bg);
    color: var(--text);
    border: none;
    resize: none;
}

/* ── КОНТЕКСТНОЕ МЕНЮ ── */
.ctx {
    display: block;
    position: fixed;
    min-width: 160px;
    padding: 4px 0;
    background: var(--tab);
    border: 1px solid var(--line);
    border-radius: calc(var(--r) + 2px);
    z-index: 100;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

.ctx.open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.ctx div { padding: 6px 12px; font-size: 12px; cursor: pointer; color: var(--dim); }
.ctx div:hover { background: var(--field); color: var(--text); }
.ctx hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }
.ctx .ctx-tile-section { padding: 7px 10px; cursor: default; color: var(--dim); font-size: 11px; }
.ctx .ctx-tile-section:hover { background: transparent; color: var(--dim); }
.ctx-tile-buttons { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; margin: 0; }
.ctx .ctx-tile-buttons { padding: 0; background: transparent; cursor: default; }
.ctx-tile-buttons button { grid-column: span 2; display: flex; align-items: center; justify-content: center; min-width: 0; aspect-ratio: 1; height: auto; padding: 3px; border: 0; border-radius: 4px; background: var(--field); color: var(--dim); cursor: pointer; }
.ctx-tile-buttons button:nth-child(5) { grid-column: 2 / span 2; }
.ctx-tile-buttons button:hover { background: var(--tab); color: var(--text); }
.ctx-tile-buttons button[aria-pressed="true"] { background: rgba(255,62,62,.12); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(255,62,62,.45); }
#ctx { min-width: 0; width: 140px; }
#ctx > div:not(.ctx-tile-section) { text-align: left; text-transform: lowercase; padding: 6px 10px; }
#ctx [aria-disabled="true"], #ctx [aria-disabled="true"]:hover { opacity: .38; cursor: default; background: transparent; color: var(--dim); }
#ctx .ctx-tile-section { padding: 6px 10px; }
#ctx .ctx-tile-buttons { width: 116px; margin: 0 auto; }
.ctx-tile-buttons button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile-preset-icon { display: grid; grid-template: repeat(2, 7px) / repeat(2, 7px); gap: 2px; pointer-events: none; }
.tile-preset-icon > span { border-radius: 1px; }
.tile-preset-icon > .filled { background: currentColor; }
.styler-tile-size { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 11px; }
.styler-tile-size .ctx-tile-buttons { margin-top: 0; }
.bundle-pocket { position: fixed; z-index: 260; width: min(340px, calc(100vw - 20px)); max-height: min(360px, calc(100dvh - 20px)); overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--window); box-shadow: 0 18px 50px #000a; color: var(--text); }
.bundle-pocket[hidden] { display: none; }
.bundle-pocket-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--line); background: var(--tab); font-size: 12px; }
.bundle-pocket-head > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bundle-pocket-head > div { display: flex; gap: 4px; }
.bundle-pocket-head button { width: 28px; height: 28px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; }
.bundle-pocket-head button:hover { border-color: var(--line); background: var(--field); }
.bundle-pocket-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; max-height: 310px; overflow: auto; padding: 10px; font-size: 11px; color: var(--dim); }
.bundle-pocket-grid.dragover { outline: 1px dashed var(--accent); outline-offset: -3px; }
.bundle-pocket-entry { min-width: 0; padding: 9px 7px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--field); color: var(--text); text-overflow: ellipsis; white-space: nowrap; cursor: grab; }
.bundle-pocket-entry:hover { border-color: var(--accent); }

/* ── СКРОЛЛБАР ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #333; border-radius: var(--r); }
* { scrollbar-width: thin; scrollbar-color: #333 var(--bg); }

/* ── ПРОСТОРНЫЙ DESKTOP-РЕЖИМ ──
   Увеличивает каркас интерфейса, а не масштабирует весь DOM. */
@media (min-width: 900px) {
    #scaled-app {
        height: calc(100dvh - 48px);
    }

    #tabs {
        padding: 10px 12px 0;
        gap: 4px;
    }

    .tab {
        gap: 8px;
        padding: 9px 18px;
        font-size: 15px;
    }

    #tab-add {
        padding: 6px 12px;
        font-size: 22px;
    }

    #navbar {
        height: 48px;
    }

    #nav-left,
    #sidebar {
        width: 220px;
        min-width: 220px;
    }



    #nav-left {
        box-sizing: border-box;
        flex: 0 0 220px;
        gap: 6px;
        padding: 0 10px;
    }
    #nav-left .nav-btn { flex: 1; min-width: 0; height: 42px; }

    .nav-btn {
        height: 34px;
        min-width: 36px;
        padding: 0 8px;
        font-size: 17px;
    }

    #path-bar {
        height: 34px;
        margin: 0 12px;
        padding: 0 14px;
        font-size: 15px;
    }

    #nav-right {
        box-sizing: border-box;
        width: 220px;
        min-width: 220px;
        flex: 0 0 220px;
        padding: 0 12px;
    }

    #search-box {
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        height: 34px;
        padding: 0 12px;
        font-size: 14px;
    }

    .win-row {
        height: 34px;
        padding-right: 10px;
        font-size: 14px;
    }

    .win-chevron {
        width: 22px;
        height: 22px;
        min-width: 22px;
        margin-right: 6px;
    }

    .win-arrow {
        width: 11px !important;
        height: 11px !important;
        max-width: 11px;
        max-height: 11px;
    }

    .win-icon {
        margin-right: 8px;
        font-size: 18px;
    }

    .win-sub {
        padding-left: 22px;
    }

    /* Профиль остаётся на своём месте над нижней полосой. */
    #profile {
        position: fixed;
        left: 0;
        bottom: 48px;
        width: 220px;
        max-height: calc(100dvh - 150px);
        padding: 12px;
        border-bottom: 0;
    }

    /* Высоту дерева задаёт JS по верхней границе профиля. */
    #tree-wrap {
        flex: 0 0 auto;
        overflow-y: auto;
        padding: 16px 8px 8px 10px;
    }

    #auth-compact-row {
        gap: 10px;
        height: 60px;
    }

    #avatar {
        width: 56px;
        height: 56px;
        min-width: 56px;
        min-height: 56px;
    }

    #login-fields {
        gap: 6px;
    }

    #login-fields input {
        height: 27px;
        padding: 3px 8px;
        font-size: 13px;
    }

    #p-name {
        font-size: 14px;
    }

    #quota-txt,
    .chk-text {
        font-size: 12px;
    }

    .custom-remember {
        gap: 7px;
        margin: 8px 0 7px;
    }

    .custom-chk-box {
        width: 17px;
        height: 17px;
    }

    #auth-btns {
        gap: 6px;
    }

    .auth-btn {
        height: 32px;
        min-height: 32px;
        font-size: 13px;
    }

    #user-controls {
        gap: 6px;
        margin-top: 8px;
    }

    .profile-actions-column {
        gap: 6px;
    }


    .auth-exit-btn {
        width: 72px;
        min-width: 72px;
        max-width: 72px;
        height: 30px;
        min-height: 30px;
        font-size: 12px;
        margin-top: 0;
    }

    #footer-links {
        height: 48px;
    }

    #scale-bar {
        left: 220px;
        bottom: 48px;
        height: 48px;
        gap: 10px;
        padding: 0 14px;
        font-size: 13px;
    }

    .scale-btn,
    .scale-value {
        height: 32px;
    }

    .scale-btn {
        width: 32px;
        min-width: 32px;
        font-size: 20px;
    }

    #scale-readout {
        width: 52px;
        min-width: 52px;
        flex: 0 0 52px;
    }

    .space-mode-toggle {
        width: 78px;
        min-width: 78px;
        flex: 0 0 78px;
    }

    .scale-value {
        height: 32px;
        font-size: 13px;
    }

    #action-bar {
        right: 14px;
        gap: 6px;
        padding: 7px;
    }

    .act-btn {
        width: 40px;
        height: 38px;
        min-width: 40px;
        min-height: 38px;
        font-size: 19px;
    }
}

/* Равные боковые колонки удерживают ползунок на оси экрана. */
#scale-bar { left: 0; display: grid; grid-template-columns: 272px minmax(0, 1fr) 272px; column-gap: 10px; box-sizing: border-box; }
.scale-left, .scale-right, .scale-center { display: flex; align-items: center; gap: 8px; min-width: 0; }
.scale-left { justify-content: flex-end; }
.scale-right { justify-content: flex-end; width: 100%; }
.scale-center { position: static; transform: none; width: 100%; }
.scale-center .scale-btn { flex: 0 0 auto; }
#ui-scale { flex: 1 1 0; width: 0; min-width: 0; margin: 0; }
#scale-readout { width: 52px; min-width: 52px; flex: 0 0 52px; }
#scale-readout .scale-label-value { display: inline; }
#marafet-toggle { width: 78px; min-width: 78px; flex: 0 0 78px; }
#space-mode-toggle { width: 77px; min-width: 77px; flex: 0 0 77px; }
#hidden-files-toggle { transform: translateX(-3px); }
#hidden-files-toggle { flex: 0 0 auto; }
#scale-bar #alphabet-sort { flex: 1 1 37px; width: auto; min-width: 24px; padding: 0 3px; font-size: inherit; }
#marafet-toggle:disabled, #space-mode-toggle:disabled { opacity: .4; cursor: default; color: var(--dim); }
#marafet-toggle:disabled:hover, #space-mode-toggle:disabled:hover { background: var(--field); border-color: var(--line); }
#scale-bar [hidden] { display: none !important; }
.my-folder-compact { display: none; }
#profile { --profile-avatar-side: 52px; --profile-button-height: 30px; --profile-trash-side: 36px; }
#auth-compact-row { height: var(--profile-avatar-side); }
#avatar { width: var(--profile-avatar-side); height: var(--profile-avatar-side); min-width: var(--profile-avatar-side); min-height: var(--profile-avatar-side); border-radius: 10px; }
#quota-wrap { width: 100%; align-self: stretch; }
.profile-actions-column { width: 100%; display: grid; grid-template-columns: var(--profile-avatar-side) minmax(0, 1fr) var(--profile-trash-side); grid-template-rows: repeat(2, var(--profile-button-height)); gap: 4px; }
.profile-actions-row { display: contents; }
#profile .auth-exit-btn { width: 100%; min-width: 0; max-width: none; height: var(--profile-button-height); min-height: var(--profile-button-height); margin: 0; padding: 0 3px; font-size: 10px; white-space: nowrap; }
#btn-public-page { grid-column: 1; grid-row: 1; transform: translateX(-1px); }
#btn-my-folder { grid-column: 2; grid-row: 1; transform: translateX(1px); }
#btn-logout { grid-column: 1; grid-row: 2; transform: translate(-1px, 2px); border: 1px solid rgba(255,62,62,.45); color: var(--text); background: var(--field); }
#btn-profile-trash { grid-column: 3; grid-row: 1 / span 2; transform: translateX(2px); width: 100%; height: 100%; min-width: 0; padding: 5px; border: 1px solid rgba(255,62,62,.45); background: var(--field); color: var(--dim); border-radius: var(--r); cursor: not-allowed; }
#btn-profile-trash svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 900px) {
    #profile { --profile-avatar-side: 64px; --profile-button-height: 30px; --profile-trash-side: 40px; padding-bottom: 24px; }
    #profile .auth-exit-btn { font-size: 11px; }
    #btn-profile-trash { height: 72px; }
}
#btn-logout:hover { background: rgba(255,62,62,.08); }
#navbar > #btn-refresh { flex: 0 0 34px; min-width: 34px; margin-right: 4px; transform: none; }
@media (max-width: 899px) {
    #navbar { display: grid; grid-template-columns: minmax(96px, .8fr) 30px minmax(0, 1fr); grid-template-rows: 36px 30px; gap: 0 4px; height: auto; padding: 0 6px; box-sizing: border-box; }
    #nav-left { grid-column: 1; grid-row: 1; width: 100%; min-width: 0; padding: 0; gap: 2px; box-sizing: border-box; }
    #nav-left .nav-btn { flex: 1; min-width: 0; height: 30px; padding: 0 4px; }
    #navbar > #btn-refresh { grid-column: 2; grid-row: 1; width: 30px; min-width: 0; height: 30px; margin: 0; padding: 0; }
    #nav-right { grid-column: 3; grid-row: 1; width: 100%; min-width: 0; padding: 0; margin: 0; box-sizing: border-box; }
    #search-box { width: 100%; max-width: 100%; min-width: 0; padding: 0 6px; box-sizing: border-box; }
    #path-bar { grid-column: 1 / -1; grid-row: 2; width: auto; min-width: 0; margin: 0; height: 26px; padding: 0 6px; }
    #scale-bar { height: 72px; grid-template-columns: 52px minmax(0, 1fr); grid-template-rows: 26px 26px; gap: 6px 4px; padding: 6px; align-items: center; }
    .scale-left { grid-column: 1; grid-row: 1; }
    .scale-right { grid-column: 2; grid-row: 1; gap: 4px; }
    .scale-center { grid-column: 1 / -1; grid-row: 2; gap: 8px; }
    #marafet-toggle { width: 68px; min-width: 68px; flex-basis: 68px; }
    #space-mode-toggle { width: 67px; min-width: 67px; flex-basis: 67px; }
    #hidden-files-toggle { transform: translateX(-3px); }
    #profile { bottom: 110px; }
    #main { padding-bottom: 124px; }
    .my-folder-wide { display: none; }
    .my-folder-compact { display: inline; }
}
@media (max-width: 360px) {
    #profile { --profile-avatar-side: 46px; --profile-trash-side: 32px; }
}
@media (max-width: 899px) {
    #btn-profile-trash { min-height: 68px; }
}
@media (max-width: 360px) {
    #btn-profile-trash { min-height: 68px; }
    #profile .auth-exit-btn { font-size: 9px; }
}

/* Перекрываем базовые размеры .player-window для компактного окна метрик. */
#system-stats-window.system-stats-window {
    width: 190px !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    left: auto;
    top: auto;
    right: 18px;
    bottom: 86px;
    transform: none !important;
    resize: none !important;
    background: rgba(18, 18, 18, 0.52) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28) !important;
}

#system-stats-window.system-stats-window.system-stats-expanded {
    width: min(560px, calc(100vw - 24px)) !important;
    max-height: min(760px, calc(100vh - 100px)) !important;
}

@media (max-width: 520px) {
    #system-stats-window.system-stats-window {
        width: 150px !important;
        max-width: calc(100vw - 16px) !important;
        right: 8px;
        bottom: 74px;
    }

    #system-stats-window .player-header {
        flex-basis: 28px;
        min-height: 28px;
        padding: 0 5px 0 7px;
        gap: 4px;
    }

    #system-stats-window .player-title {
        font-size: 10px;
    }

    #system-stats-window .system-stats-actions {
        gap: 4px;
    }

    #system-stats-window .system-stats-toggle,
    #system-stats-window .system-stats-reboot {
        min-width: 42px;
        height: 20px;
        padding: 0 4px;
        font-size: 9px;
    }

    #system-stats-window .system-stats-body {
        padding: 5px 7px 6px;
        font-size: 9px;
    }

    #system-stats-window .system-stat-row {
        line-height: 1.3;
    }
}

/* ── QR GENERATOR MODAL ── */
.qr-overlay {
    position: fixed;
    inset: 0;
    z-index: 240;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: rgba(0, 0, 0, 0.76);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.qr-overlay.open {
    display: flex;
}

#qr-modal-box {
    width: min(780px, calc(100vw - 24px));
    max-height: min(900px, calc(100dvh - 24px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #141416;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.72);
}

.qr-modal-header {
    flex: 0 0 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 12px 0 16px;
    background: #1a1a1d;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    font-size: 13px;
}

.cl-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid transparent;
    background: transparent;
    color: var(--dim);
    font-size: 17px;
    cursor: pointer;
}

.cl-btn:hover {
    border-color: var(--line);
    color: var(--text);
}

.qr-modal-body {
    min-height: 0;
    display: flex;
    gap: 14px;
    padding: 14px;
    overflow-y: auto;
}

.qr-preview-pane {
    flex: 0 1 340px;
    min-width: 0;
    align-self: flex-start;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background-color: #111;
    background-image: conic-gradient(#1e1e1e 25%, #111 0 50%, #1e1e1e 0 75%, #111 0);
    background-size: 20px 20px;
}

#qr-composite-canvas {
    display: block;
    width: 100%;
    max-width: 340px;
    height: auto;
}

.qr-controls-pane {
    flex: 1 1 300px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.qr-ctrl-row {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: var(--dim);
    font-size: 11px;
}

.qr-ctrl-row[hidden] {
    display: none !important;
}

.qr-ctrl-row input[type="text"] {
    width: 100%;
    min-width: 0;
    padding: 7px 9px;
    font-size: 12px;
}

.qr-ctrl-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.qr-ctrl-grid input[type="color"] {
    width: 100%;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--field);
    cursor: pointer;
}

.qr-size-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.qr-size-grid .qr-ctrl-row > span {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.qr-size-grid input[type="range"],
#qr-card-radius {
    width: 100%;
    accent-color: var(--accent);
}

.qr-toggles-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 12px;
}

.qr-toggles-row .custom-remember {
    margin: 0;
}

.qr-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 3px;
}

.qr-actions-row .btn-vpn {
    flex: 1 1 auto;
}

#qr-status-msg {
    min-height: 15px;
    margin-top: 2px;
    color: var(--dim);
    font-size: 11px;
}

@media (max-width: 680px) {
    .qr-overlay {
        padding: 8px;
    }

    #qr-modal-box {
        width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
    }

    .qr-modal-body {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }

    .qr-preview-pane {
        flex: 0 0 auto;
        width: min(100%, 300px);
        align-self: center;
    }

    #qr-composite-canvas {
        max-width: 280px;
    }

    .qr-controls-pane {
        flex: 0 0 auto;
        width: 100%;
    }
}
