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

* {
    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: var(--text);
}

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-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;
    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: 3px;
    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;
}

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

/* Кнопка "запомнить сессию" со строчной буквы */
.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-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);
}

.auth-exit-btn {
    width: 100%;
    height: 24px;
    min-height: 24px;
    border: 1px solid var(--line);
    font-size: 11px;
    color: var(--dim);
    margin-top: 4px;
    text-transform: lowercase;
}

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

#quota-wrap {
    height: 2px;
    background: var(--field);
    border-radius: var(--r);
    margin: 6px 0 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-y: auto;
    box-sizing: border-box;
    padding-bottom: 90px;
}

/* ── СЕТКА ПАПОК: 2-3 ПАПКИ В РЯД ДАЖЕ НА ТЕЛЕФОНЕ ── */
#grid {
    flex: 1;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(calc(70px * var(--file-scale)), 1fr));
    gap: calc(8px * var(--file-scale));
    align-content: start;
}

.item {
    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: var(--field);
    outline: 1px solid var(--dim);
}

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

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

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

/* ── ФИКСИРОВАННЫЕ ДЕЙСТВИЯ TELEPORT ── */
#action-bar {
    position: fixed;
    right: 8px;
    top: calc(50% - 34px);
    z-index: 140;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 5px;
    background: rgba(16, 16, 16, 0.94);
    border: 1px solid var(--line);
    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: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--r);
    cursor: pointer;
    user-select: none;
}

.act-btn:hover {
    background: var(--tab);
    border-color: var(--accent);
}

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

/* Компактный индикатор передачи по центру над масштабом */
#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;
}

/* Пустой нижний блок для будущих ссылок автора: на всю ширину */
#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.98);
    border-top: 1px solid var(--line);
    color: var(--dim);
    font-size: 11px;
}

#ui-scale {
    flex: 1;
    min-width: 80px;
    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: 72px;
    min-width: 72px;
    padding: 0 4px;
    font-size: 11px;
}

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

.scale-value:hover .scale-label-word,
.scale-value:focus .scale-label-word {
    display: none;
}

.scale-value:hover .scale-label-value,
.scale-value:focus .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;
    }

    #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: var(--r);
    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; }

/* ── СКРОЛЛБАР ── */
::-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 {
        gap: 6px;
        padding: 0 10px;
    }

    .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 {
        position: relative;
        width: 240px;
        flex-basis: 240px;
        padding-right: 12px;
    }

    #search-box {
        max-width: 240px;
        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;
        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,
    .auth-exit-btn {
        height: 32px;
        min-height: 32px;
        font-size: 13px;
    }

    #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-value {
        width: 84px;
        min-width: 84px;
        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;
    }
}
