/* KompNK Cloud — дизайн-система пользовательских страниц.
   Тема: авто (prefers-color-scheme) или ручная через <html data-theme="light|dark">. */

:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f1f3f9;
    --border: #e4e7ef;
    --text: #151a2d;
    --text-2: #5b6380;
    --text-3: #8a91ab;
    --accent: #5b5bf0;
    --accent-hover: #4a4adb;
    --accent-soft: #eceeff;
    --accent-text: #ffffff;
    --danger: #e5484d;
    --danger-soft: #fdecec;
    --success: #1f9d61;
    --success-soft: #e4f6ec;
    --warning: #d98a0b;
    --warning-soft: #fff4de;
    --shadow-sm: 0 1px 2px rgba(20, 26, 50, .06);
    --shadow: 0 6px 24px rgba(20, 26, 50, .08);
    --shadow-lg: 0 18px 50px rgba(20, 26, 50, .18);
    --radius: 14px;
    --radius-sm: 9px;
    --sidebar-w: 268px;

    --c-images: #7c6cf0;
    --c-video: #ef6b8a;
    --c-audio: #f0a23c;
    --c-documents: #3aa6e8;
    --c-archives: #38b98a;
    --c-other: #98a0b8;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0f1220;
    --surface: #171b2e;
    --surface-2: #1e2339;
    --border: #2a3050;
    --text: #eceffc;
    --text-2: #a6aecb;
    --text-3: #7a82a3;
    --accent: #7b7bff;
    --accent-hover: #9393ff;
    --accent-soft: #232853;
    --accent-text: #0f1220;
    --danger: #ff6b70;
    --danger-soft: #3a1d26;
    --success: #43c887;
    --success-soft: #16332a;
    --warning: #f0b03d;
    --warning-soft: #3a2f16;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 6px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f1220;
        --surface: #171b2e;
        --surface-2: #1e2339;
        --border: #2a3050;
        --text: #eceffc;
        --text-2: #a6aecb;
        --text-3: #7a82a3;
        --accent: #7b7bff;
        --accent-hover: #9393ff;
        --accent-soft: #232853;
        --accent-text: #0f1220;
        --danger: #ff6b70;
        --danger-soft: #3a1d26;
        --success: #43c887;
        --success-soft: #16332a;
        --warning: #f0b03d;
        --warning-soft: #3a2f16;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow: 0 6px 24px rgba(0, 0, 0, .35);
        --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
        color-scheme: dark;
    }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 28px; height: 28px; }
.icon.fill { fill: currentColor; }

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font-weight: 500; font-size: 14px; transition: background .15s, border-color .15s, transform .05s;
    white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(.92); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }

.icon-btn {
    width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px;
    border: none; background: transparent; color: var(--text-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.star-on { color: #f0b03d; }

/* ---------- Поля ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, .select {
    width: 100%; height: 42px; padding: 0 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.select { padding-right: 10px; }

/* ---------- Авторизация ---------- */
.auth-page {
    min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr;
}
.auth-hero {
    position: relative; overflow: hidden; color: #fff; padding: 56px;
    background: radial-gradient(1200px 600px at 0% 0%, #7b7bff 0%, transparent 60%),
                radial-gradient(900px 500px at 100% 100%, #c05bf0 0%, transparent 55%),
                linear-gradient(135deg, #4a3fe0, #6b3fc9);
    display: flex; flex-direction: column; justify-content: space-between;
}
.auth-hero .brand { color: #fff; }
.auth-hero h2 { font-size: 40px; line-height: 1.1; letter-spacing: -.02em; max-width: 440px; }
.auth-hero p { margin-top: 14px; font-size: 17px; opacity: .85; max-width: 420px; }
.auth-features { list-style: none; display: grid; gap: 12px; margin-top: 30px; }
.auth-features li { display: flex; gap: 12px; align-items: center; font-size: 15px; opacity: .95; }
.auth-features .dot { width: 30px; height: 30px; border-radius: 9px; background: rgba(255,255,255,.18); display: grid; place-items: center; }
.auth-hero small { opacity: .7; }
.auth-panel { display: grid; place-items: center; padding: 32px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card > .brand { display: none; }
.auth-card h1 { font-size: 28px; letter-spacing: -.01em; margin-bottom: 6px; }
.auth-card .sub { color: var(--text-2); margin-bottom: 28px; }
.auth-card .switch { text-align: center; margin-top: 22px; color: var(--text-2); font-size: 14px; }
.divider { display: flex; align-items: center; gap: 14px; color: var(--text-3); font-size: 13px; margin: 20px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.pw-wrap { position: relative; }
.pw-wrap .icon-btn { position: absolute; right: 3px; top: 2px; }
.notice { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; color: var(--text-2); font-size: 14px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; color: var(--text); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #6a6af5, #a35bf0); box-shadow: 0 4px 14px rgba(106, 106, 245, .45); }
.auth-hero .brand-mark { background: rgba(255,255,255,.2); box-shadow: none; }

@media (max-width: 900px) {
    .auth-page { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .auth-card > .brand { display: flex; }
}

/* ---------- Каркас приложения ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--border);
    padding: 20px 16px; display: flex; flex-direction: column; gap: 18px;
}
.sidebar .brand { padding: 4px 8px; }
.side-actions { display: grid; gap: 8px; }

.nav { display: grid; gap: 2px; }
.nav-item {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
    padding: 10px 12px; border: none; border-radius: 10px; background: transparent;
    color: var(--text-2); font-weight: 500; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--text-3); background: var(--surface-2); padding: 1px 8px; border-radius: 99px; }
.nav-item.active .count { background: var(--surface); color: var(--accent); }

.storage-card { margin-top: auto; background: var(--surface-2); border-radius: var(--radius); padding: 16px; }
.storage-card h4 { font-size: 13px; color: var(--text-2); font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; }
.storage-card .big { margin: 8px 0 10px; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.storage-card .big span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.seg-bar { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; display: flex; }
.seg-bar i { display: block; height: 100%; transition: width .4s; }
.seg-bar.warn { box-shadow: 0 0 0 2px var(--warning-soft); }
.seg-bar.crit { box-shadow: 0 0 0 2px var(--danger-soft); }
.legend { display: grid; gap: 6px; margin-top: 14px; font-size: 12.5px; color: var(--text-2); }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend b { margin-left: auto; font-weight: 500; color: var(--text); }
.legend .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.storage-note { margin-top: 12px; font-size: 12.5px; padding: 8px 10px; border-radius: 8px; background: var(--warning-soft); color: var(--warning); }
.storage-note.crit { background: var(--danger-soft); color: var(--danger); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
    padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 560px; }
.search .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search input { width: 100%; height: 42px; padding: 0 44px 0 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.search kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 12px/1 inherit; color: var(--text-3); border: 1px solid var(--border); border-radius: 6px; padding: 3px 7px; background: var(--surface-2); }
.top-spacer { flex: 1; }

.user-menu { position: relative; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: none; color: #fff; font-weight: 700; font-size: 14px; background: linear-gradient(135deg, #6a6af5, #a35bf0); display: grid; place-items: center; }

.content { padding: 24px 28px 120px; width: 100%; max-width: 1280px; margin: 0 auto; }

.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 22px; font-weight: 700; letter-spacing: -.01em; min-width: 0; margin-left: -8px; }
.crumb { padding: 4px 8px; border-radius: 8px; border: none; background: none; color: var(--text-2); font: inherit; font-weight: 600; }
.crumb:hover { background: var(--surface-2); color: var(--text); }
.crumb.current { color: var(--text); cursor: default; }
.crumb.current:hover { background: none; }
.crumb.drop-target, .folder-card.drop-target { background: var(--accent-soft); outline: 2px dashed var(--accent); }
.crumb-sep { color: var(--text-3); }
.page-sub { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.head-spacer { flex: 1; }

.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 13px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--text-2); }
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.seg-ctl { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg-ctl button { width: 36px; height: 34px; border: none; background: transparent; color: var(--text-3); display: grid; place-items: center; }
.seg-ctl button.active { background: var(--accent-soft); color: var(--accent); }
.select.compact { height: 34px; width: auto; border-radius: 10px; font-size: 13px; }

/* Панель массовых действий */
.bulk {
    position: sticky; top: 74px; z-index: 15; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    padding: 8px 10px 8px 16px; margin-bottom: 14px; border-radius: 12px;
    background: var(--accent); color: var(--accent-text); box-shadow: var(--shadow);
    animation: pop .18s ease-out;
}
.bulk .bulk-count { font-weight: 600; margin-right: auto; }
.bulk .btn { background: rgba(255,255,255,.16); border-color: transparent; color: inherit; height: 34px; }
:root[data-theme="dark"] .bulk .btn { background: rgba(0,0,0,.18); }
.bulk .btn:hover { background: rgba(255,255,255,.28); }
.bulk .btn.danger:hover { background: var(--danger); color: #fff; }
@keyframes pop { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 700; margin: 22px 0 10px; }

/* ---------- Папки ---------- */
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.folder-card {
    display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    transition: box-shadow .15s, transform .15s, border-color .15s; cursor: pointer; user-select: none;
}
.folder-card:hover { box-shadow: var(--shadow); border-color: transparent; transform: translateY(-1px); }
.folder-ico { width: 40px; height: 40px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.folder-body { flex: 1; min-width: 0; }
.folder-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-meta { font-size: 12.5px; color: var(--text-3); }

/* ---------- Файлы: список ---------- */
.files-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.files-head, .file-row {
    display: grid; grid-template-columns: 34px minmax(0, 1fr) 110px 150px 120px; gap: 12px; align-items: center; padding: 0 16px;
}
.files-head { height: 42px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 700; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.files-head .sortable { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; border: none; background: none; text-transform: inherit; letter-spacing: inherit; font: inherit; color: inherit; font-weight: 700; padding: 0; }
.files-head .sortable:hover { color: var(--text); }
.files-head .sortable.active { color: var(--accent); }
.file-row { min-height: 60px; border-bottom: 1px solid var(--border); transition: background .12s; position: relative; }
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--surface-2); }
.file-row.selected { background: var(--accent-soft); }
.file-row.dragging, .file-card.dragging { opacity: .45; }

.check { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.file-main { display: flex; align-items: center; gap: 12px; min-width: 0; cursor: pointer; }
.thumb { width: 40px; height: 40px; border-radius: 10px; flex: none; display: grid; place-items: center; overflow: hidden; background: var(--surface-2); color: #fff; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.t-images { background: var(--c-images); } .thumb.t-video { background: var(--c-video); }
.thumb.t-audio { background: var(--c-audio); } .thumb.t-documents { background: var(--c-documents); }
.thumb.t-archives { background: var(--c-archives); } .thumb.t-other { background: var(--c-other); }
.thumb.has-img { background: var(--surface-2); }
.file-text { min-width: 0; }
.file-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.file-name .star { color: #f0b03d; flex: none; }
.file-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-muted { color: var(--text-2); font-size: 13.5px; white-space: nowrap; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; opacity: 0; transition: opacity .12s; }
.file-row:hover .row-actions, .file-row:focus-within .row-actions, .file-row.selected .row-actions { opacity: 1; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.badge.warn { background: var(--warning-soft); color: var(--warning); }

/* ---------- Файлы: сетка ---------- */
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.file-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: box-shadow .15s, transform .15s, border-color .15s; }
.file-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: transparent; }
.file-card.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.card-preview { height: 130px; display: grid; place-items: center; background: var(--surface-2); cursor: pointer; overflow: hidden; color: #fff; }
.card-preview img { width: 100%; height: 100%; object-fit: cover; }
.card-preview.t-images { background: var(--c-images); } .card-preview.t-video { background: var(--c-video); }
.card-preview.t-audio { background: var(--c-audio); } .card-preview.t-documents { background: var(--c-documents); }
.card-preview.t-archives { background: var(--c-archives); } .card-preview.t-other { background: var(--c-other); }
.card-preview .icon { width: 44px; height: 44px; opacity: .92; }
.card-preview .ext { position: absolute; left: 10px; bottom: 112px; }
.card-body { padding: 10px 12px 12px; }
.card-check { position: absolute; left: 10px; top: 10px; opacity: 0; transition: opacity .12s; background: var(--surface); border-radius: 6px; padding: 3px; display: grid; }
.file-card:hover .card-check, .file-card.selected .card-check { opacity: 1; }
.card-more { position: absolute; right: 6px; top: 6px; opacity: 0; transition: opacity .12s; background: var(--surface); box-shadow: var(--shadow-sm); width: 32px; height: 32px; }
.file-card:hover .card-more { opacity: 1; }

/* ---------- Пустые состояния ---------- */
.empty { text-align: center; padding: 70px 20px; color: var(--text-2); }
.empty .em-ico { width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 18px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty .em-ico .icon { width: 34px; height: 34px; }
.empty h3 { color: var(--text); font-size: 18px; margin-bottom: 6px; }
.empty .btn { margin-top: 18px; }

.skeleton { height: 60px; border-bottom: 1px solid var(--border); background: linear-gradient(90deg, transparent, var(--surface-2), transparent); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Ссылки (доступ) ---------- */
.share-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.4fr) 100px 120px auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.share-row:last-child { border-bottom: none; }
.share-url { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Оверлей перетаскивания ---------- */
.drop-overlay {
    position: fixed; inset: 0; z-index: 200; display: none; place-items: center; text-align: center;
    background: color-mix(in srgb, var(--accent) 16%, transparent); backdrop-filter: blur(3px);
    border: 3px dashed var(--accent); margin: 12px; border-radius: 22px; pointer-events: none;
}
.drop-overlay.show { display: grid; }
.drop-overlay .box { background: var(--surface); padding: 30px 44px; border-radius: 20px; box-shadow: var(--shadow-lg); }
.drop-overlay h3 { font-size: 20px; margin-top: 10px; }
.drop-overlay p { color: var(--text-2); }

/* ---------- Загрузки ---------- */
.uploads { position: fixed; right: 20px; bottom: 20px; width: 360px; max-width: calc(100vw - 32px); z-index: 120; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
.uploads-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; font-weight: 600; background: var(--surface-2); }
.uploads-head span { flex: 1; }
.uploads-list { max-height: 280px; overflow-y: auto; }
.up-item { padding: 10px 14px; border-top: 1px solid var(--border); }
.up-row { display: flex; gap: 10px; font-size: 13.5px; align-items: center; }
.up-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-state { color: var(--text-3); font-size: 12.5px; }
.up-state.err { color: var(--danger); }
.up-state.ok { color: var(--success); }
.bar { height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 7px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.bar i.ok { background: var(--success); } .bar i.err { background: var(--danger); }

/* ---------- Меню и попапы ---------- */
.menu {
    position: fixed; z-index: 300; min-width: 210px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop .12s ease-out;
}
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 12px; padding: 9px 12px; border: none; background: none; border-radius: 8px; color: var(--text); text-align: left; font-size: 14px; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu .danger { color: var(--danger); }
.menu .sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu .menu-head { padding: 8px 12px 6px; font-size: 12.5px; color: var(--text-3); }

/* ---------- Модальные окна ---------- */
.overlay { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: 16px; background: rgba(10, 12, 24, .5); backdrop-filter: blur(2px); animation: fade .15s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.dialog { width: 100%; max-width: 460px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
@keyframes rise { from { transform: translateY(14px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.dialog-head { display: flex; align-items: center; padding: 18px 20px 0; }
.dialog-head h3 { flex: 1; font-size: 18px; }
.dialog-body { padding: 14px 20px 6px; color: var(--text-2); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 20px; }
.copy-box { display: flex; gap: 8px; }
.copy-box .input { font-size: 13px; }
.hint { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }

/* ---------- Просмотр ---------- */
.viewer { position: fixed; inset: 0; z-index: 500; background: rgba(8, 10, 20, .94); display: flex; flex-direction: column; animation: fade .15s; }
.viewer-top { display: flex; align-items: center; gap: 12px; padding: 12px 18px; color: #fff; }
.viewer-top .title { flex: 1; min-width: 0; }
.viewer-top .title b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-top .title span { font-size: 12.5px; opacity: .65; }
.viewer .icon-btn { color: #fff; }
.viewer .icon-btn:hover { background: rgba(255,255,255,.14); }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 70px 24px; position: relative; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; border-radius: 10px; object-fit: contain; }
.viewer-stage iframe { width: min(1000px, 100%); height: 100%; border: none; border-radius: 10px; background: #fff; }
.viewer-stage pre { width: min(900px, 100%); max-height: 100%; overflow: auto; background: var(--surface); color: var(--text); padding: 20px; border-radius: 12px; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.viewer-stage audio { width: min(520px, 100%); }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: none; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; }
.viewer-nav:hover { background: rgba(255,255,255,.26); }
.viewer-nav.prev { left: 12px; } .viewer-nav.next { right: 12px; }
.viewer-fallback { color: #fff; text-align: center; }
.viewer-fallback .em-ico { width: 80px; height: 80px; border-radius: 24px; background: rgba(255,255,255,.12); margin: 0 auto 16px; display: grid; place-items: center; }

/* ---------- Уведомления ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 700; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 12px; background: #1b2035; color: #fff; box-shadow: var(--shadow-lg); font-size: 14px; animation: rise .2s ease-out; pointer-events: auto; max-width: min(520px, 92vw); }
.toast.success .icon { color: #5ee0a0; } .toast.error .icon { color: #ff8a8f; }
.toast button { background: none; border: none; color: #9fa8ff; font-weight: 600; margin-left: 6px; }

/* ---------- Профиль ---------- */
.page-narrow { max-width: 760px; margin: 0 auto; padding: 28px 20px 80px; }
.page-top { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.page-top h1 { font-size: 26px; letter-spacing: -.01em; flex: 1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 18px; }
.card h2 { font-size: 17px; margin-bottom: 4px; }
.card .desc { color: var(--text-2); font-size: 14px; margin-bottom: 18px; }
.profile-id { display: flex; align-items: center; gap: 16px; }
.profile-id .avatar { width: 64px; height: 64px; font-size: 22px; }
.profile-id h2 { font-size: 20px; margin: 0; }
.profile-id p { color: var(--text-2); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 20px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font-size: 20px; letter-spacing: -.01em; }
.stat span { font-size: 13px; color: var(--text-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; padding: 4px 11px; border-radius: 99px; }
.status-pill.on { background: var(--success-soft); color: var(--success); }
.status-pill.off { background: var(--surface-2); color: var(--text-2); }
.form-message { margin-top: 14px; padding: 11px 14px; border-radius: 10px; font-size: 14px; display: none; }
.form-message.success { display: block; background: var(--success-soft); color: var(--success); }
.form-message.error { display: block; background: var(--danger-soft); color: var(--danger); }
.pw-meter { height: 4px; border-radius: 99px; background: var(--border); margin-top: 8px; overflow: hidden; }
.pw-meter i { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }

/* ---------- Публичная страница ссылки ---------- */
.share-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(900px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.share-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 34px 30px 28px; text-align: center; box-shadow: var(--shadow); }
.share-card .brand { justify-content: center; margin-bottom: 26px; }
.share-ico { width: 84px; height: 84px; border-radius: 24px; margin: 0 auto 18px; display: grid; place-items: center; color: #fff; overflow: hidden; background: var(--c-other); }
.share-ico .icon { width: 38px; height: 38px; }
.share-ico img { width: 100%; height: 100%; object-fit: cover; }
.share-ico.t-images { background: var(--c-images); } .share-ico.t-video { background: var(--c-video); } .share-ico.t-audio { background: var(--c-audio); }
.share-ico.t-documents { background: var(--c-documents); } .share-ico.t-archives { background: var(--c-archives); }
.share-card h1 { font-size: 20px; word-break: break-word; margin-bottom: 6px; }
.share-card .meta { color: var(--text-2); font-size: 14px; margin-bottom: 24px; }
.share-card .msg-err { color: var(--danger); font-size: 14px; margin: -8px 0 14px; }
.share-card .foot { margin-top: 22px; font-size: 12.5px; color: var(--text-3); }

/* ---------- Адаптив ---------- */
.scrim { display: none; }
@media (max-width: 960px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 250; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .22s, box-shadow .22s; }
    .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    .top-spacer { display: none; }
    .search { max-width: none; }
    .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 240; background: rgba(10, 12, 24, .45); }
    .menu-btn { display: inline-grid; }
    .topbar { padding: 12px 16px; }
    .content { padding: 18px 16px 120px; }
    .search kbd { display: none; }
}
@media (max-width: 720px) {
    .files-head { display: none; }
    .file-row { grid-template-columns: 30px minmax(0, 1fr) auto; padding: 8px 12px; }
    .file-row .col-size, .file-row .col-date { display: none; }
    .row-actions { opacity: 1; }
    .row-actions .hide-sm { display: none; }
    .file-name .star { display: none; }
    .crumbs { font-size: 19px; }
    .share-row { grid-template-columns: 1fr auto; }
    .share-row .col-hide { display: none; }
    .viewer-stage { padding: 0 12px 16px; }
    .viewer-nav { display: none; }
    .uploads { right: 8px; bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* ---------- Редактор документов ---------- */
.editor { position: fixed; inset: 0; z-index: 350; display: flex; flex-direction: column; background: var(--bg); animation: fade .15s; }
.ed-top { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.ed-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ed-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.ed-status { font-size: 12.5px; color: var(--text-3); }
.ed-status.dirty { color: var(--warning); }
.ed-toolbar { display: flex; flex-direction: column; padding: 4px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.tb-row { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; padding: 2px 0; }
.tb-row[hidden] { display: none; }
.tb { min-width: 34px; height: 34px; padding: 0 7px; border: none; border-radius: 8px; background: transparent; color: var(--text-2); display: inline-grid; place-items: center; cursor: pointer; position: relative; }
.tb:hover { background: var(--surface-2); color: var(--text); }
.tb.on { background: var(--accent-soft); color: var(--accent); }
.tb .glyph { font-weight: 600; font-size: 15px; font-family: Georgia, "Times New Roman", serif; }
.tb .glyph.b { font-weight: 800; } .tb .glyph.i { font-style: italic; } .tb .glyph.u { text-decoration: underline; } .tb .glyph.s { text-decoration: line-through; }
.tb.color { cursor: pointer; }
.tb.color i { position: absolute; left: 9px; right: 9px; bottom: 5px; height: 3px; border-radius: 2px; background: #c0392b; }
.tb.color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.tb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }
.tb-select { height: 34px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 0 8px; font-size: 13.5px; }
.ed-notice { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--accent-soft); color: var(--accent); font-size: 13px; }
.ed-notice span { flex: 1; }
.editor { --ed-bg: color-mix(in srgb, var(--bg) 70%, var(--border)); }
.ed-scroll { flex: 1; min-width: 0; min-height: 0; overflow: auto; padding: 28px 16px 60px; background: var(--ed-bg); }
.ed-loading { text-align: center; color: var(--text-3); padding: 60px; }
.ed-page { width: 100%; min-height: 1056px; margin: 0; padding: 72px 76px; background: #fff; color: #1d1d1f; border-radius: 4px; box-shadow: var(--shadow); outline: none;
    font: 15px/1.6 Calibri, Carlito, "Segoe UI", Arial, sans-serif; word-wrap: break-word; }
.ed-page h1 { font-size: 28px; line-height: 1.25; margin: 22px 0 8px; color: #1f3864; }
.ed-page h2 { font-size: 22px; line-height: 1.3; margin: 18px 0 6px; color: #1f3864; }
.ed-page h3 { font-size: 18px; margin: 14px 0 6px; color: #1f3864; }
.ed-page h4, .ed-page h5, .ed-page h6 { font-size: 15px; margin: 12px 0 4px; }
.ed-page p { margin: 0 0 10px; min-height: 1.6em; }
.ed-page ul, .ed-page ol { margin: 0 0 10px; padding-left: 28px; }
.ed-page a { color: #0563c1; text-decoration: underline; }
.ed-page table { border-collapse: collapse; width: 100%; margin: 6px 0 12px; table-layout: fixed; }
.ed-page td, .ed-page th { border: 1px solid #9aa0ad; padding: 6px 8px; vertical-align: top; min-width: 30px; }
.ed-page td p, .ed-page th p { margin: 0; }
.ed-page img { max-width: 100%; height: auto; cursor: default; }
.ed-page img:hover { outline: 2px solid #5b5bf0; }
.ed-page hr, .ed-page hr.pb { border: none; border-top: 2px dashed #b4b9c6; margin: 22px 0; overflow: visible; position: relative; }
.ed-page hr::after { content: "разрыв страницы"; position: absolute; left: 50%; top: -9px; transform: translateX(-50%); background: #fff; padding: 0 8px; font-size: 11px; color: #8a91ab; }
.ed-text { display: block; width: min(960px, 100%); min-height: 100%; height: calc(100% - 4px); margin: 0 auto; padding: 24px 28px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
    font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: none; outline: none; tab-size: 4; }
.ed-text:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ed-foot { display: flex; justify-content: space-between; padding: 7px 18px; font-size: 12.5px; color: var(--text-3); background: var(--surface); border-top: 1px solid var(--border); }
.version-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.version-row:last-child { border-bottom: none; }
.version-row .vi { flex: 1; min-width: 0; color: var(--text); }
.version-row .vi small { display: block; color: var(--text-3); font-size: 12.5px; }
.version-row.current .vi b { color: var(--accent); }
@media (max-width: 720px) {
    .ed-page { padding: 28px 20px; min-height: 80vh; }
    .ed-scroll { padding: 12px 8px 60px; }
    .ed-top .hide-sm { display: none; }
    .ed-foot .hide-sm { display: none; }
}

.ed-body { flex: 1; min-height: 0; display: flex; position: relative; }
.ed-outline { width: 250px; flex: none; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: 14px 10px; }
.ed-outline[hidden] { display: none; }
.ed-outline-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 700; padding: 0 8px 8px; }
.ed-outline .ol { display: block; width: 100%; text-align: left; border: none; background: none; padding: 6px 8px; border-radius: 8px; color: var(--text-2); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.ed-outline .ol:hover { background: var(--surface-2); color: var(--text); }
.ed-outline .ol.l1 { font-weight: 700; color: var(--text); } .ed-outline .ol.l2 { padding-left: 20px; } .ed-outline .ol.l3 { padding-left: 34px; font-size: 13px; }
.ed-outline-empty { font-size: 13px; color: var(--text-3); padding: 4px 8px; }
.tb-spacer { flex: 1; }
.tb-label { font-size: 12.5px; font-weight: 600; color: var(--text-3); padding: 0 6px; }
.tb-text { height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 12.5px; color: var(--text-2); cursor: pointer; margin-right: 2px; }
.tb-text:hover { background: var(--surface-2); color: var(--text); }
.tb-text.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tb-row.tb-table { background: var(--accent-soft); margin: 2px -14px -4px; padding: 5px 14px; }
.tb-select + .tb-select { margin-left: 2px; }
.ed-notice.draft { background: var(--warning-soft); color: var(--warning); }
.ed-find { position: absolute; top: 12px; right: 26px; z-index: 5; width: 360px; max-width: calc(100% - 32px); padding: 10px; display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
.ed-find[hidden] { display: none; }
.ed-find-row { display: flex; align-items: center; gap: 4px; }
.ed-find-row .input { height: 34px; flex: 1; min-width: 0; font-size: 13.5px; }
.ed-find-count { font-size: 12px; color: var(--text-3); white-space: nowrap; padding: 0 4px; }
.img-pop { position: fixed; z-index: 380; display: flex; align-items: center; gap: 2px; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); }
.img-pop[hidden] { display: none; }
.img-pop button { min-width: 32px; height: 30px; padding: 0 8px; border: none; border-radius: 8px; background: none; color: var(--text-2); font-size: 12.5px; font-weight: 600; cursor: pointer; display: grid; place-items: center; }
.img-pop button:hover { background: var(--surface-2); color: var(--text); }
.img-pop button.danger:hover { background: var(--danger-soft); color: var(--danger); }
.ed-page img { outline-offset: 2px; }
::highlight(find-all) { background-color: #ffe58a; color: #000; }
::highlight(find-cur) { background-color: #ff9f43; color: #000; }
@media (max-width: 960px) { .ed-outline { position: absolute; z-index: 6; top: 0; bottom: 0; left: 0; box-shadow: var(--shadow-lg); } }
@media (max-width: 720px) { .ed-page { padding: 28px 20px !important; min-height: 80vh !important; } .ed-find { right: 8px; } }

@media print {
    body > *:not(.editor) { display: none !important; }
    body { overflow: visible !important; background: #fff !important; }
    .editor { position: static !important; display: block !important; background: #fff !important; animation: none !important; }
    .ed-top, .ed-toolbar, .ed-notice, .ed-foot, .ed-outline, .ed-find, .img-pop { display: none !important; }
    .ed-body, .ed-scroll { display: block !important; overflow: visible !important; padding: 0 !important; background: #fff !important; }
    .ed-page { width: auto !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; box-shadow: none !important; zoom: 1 !important; border-radius: 0 !important; }
    .ed-page hr { border: 0 !important; height: 0 !important; margin: 0 !important; break-after: page; }
    .ed-page hr::after { display: none !important; }
    .ed-page table, .ed-page img { break-inside: avoid; }
}

/* ---------- Листы: страницы, зазоры, колонтитулы ---------- */
.ed-sheet { position: relative; width: min(var(--pw, 816px), 100%); margin: 0 auto; }
.pg-layer { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: visible; }
.pg-gap { position: absolute; left: -44px; right: -44px; display: flex; align-items: center; justify-content: center; background: var(--ed-bg);
    box-shadow: inset 0 7px 6px -6px rgba(0, 0, 0, .3), inset 0 -7px 6px -6px rgba(0, 0, 0, .3); }
.pg-gap span { font: 600 11px/1 Inter, "Segoe UI", system-ui, sans-serif; color: var(--text-3); letter-spacing: .03em; }
.pg-cross { position: absolute; left: 0; right: 0; border-top: 1px dashed #c3c8d4; }
.pg-cross span { position: absolute; right: 6px; top: -9px; padding: 0 6px; background: #fff; font: 600 10.5px/1 Inter, system-ui, sans-serif; color: #98a0b3; }
.hf { position: absolute; font: 11px/1.3 Calibri, Carlito, "Segoe UI", Arial, sans-serif; color: #8d93a3; overflow: hidden; }
.hf-row { display: flex; gap: 12px; }
.hf-row > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.paged .ed-page hr { border: 0; height: 0; margin: 0; overflow: visible; }
.paged .ed-page hr::after { display: none; }
.ed-foot { gap: 16px; }
.ed-pageind { font-weight: 700; color: var(--text-2); }
.ed-count { margin-right: auto; }
@media (max-width: 960px) { .pg-gap { left: 0; right: 0; } }
@media print {
    .ed-sheet { width: auto !important; zoom: 1 !important; }
    .pg-layer { display: none !important; }
    [data-pgs] { padding-top: 0 !important; }
    tr[data-pgs] td, tr[data-pgs] th { padding-top: 6px !important; }
}
