/* portal.css — раскладка страницы «Сессии» (client2/platform.html): полоса сверху, навигация слева («Сцены», «Модели» с
   деревом, «Сессии»), справа раздел — плитки и карточка выбранного (владелец 2026-10-05: «НАВИГАЦИЯ СЛЕВА, КАК В DROPBOX»;
   «ТОЛЬКО РАСКЛАДКА» — цвета, шрифты и кнопки прежние). Общий вид плиток и карточек — у сцен (scene-catalog-section.js),
   моделей (model-files-section.js) и сессий (sessions-section.js) один. Цвета — переменные :root страницы, кнопки и поля — её же стили. */

/* ── Каркас: полоса сверху, под ней навигация и раздел; прокручиваются каждый сам ─────────────────────────────────────── */
.app {
    height: 100vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(14, 10, 28, 0.85);
    backdrop-filter: blur(12px);
}
/* Логотип: знак и слово с градиентной заливкой и мягким свечением (владелец 2026-10-05: «ПОКРУПНЕЕ И ПОСИМПАТИЧНЕЕ»). */
.topbar__logo {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 11px;
    padding-right: 6px;
}
.topbar__mark {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px rgba(155, 109, 255, 0.45));
}
.topbar__word {
    font: 700 23px/1 Bahnschrift, "Segoe UI Variable", "Segoe UI", sans-serif;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    background: linear-gradient(100deg, #f4f0ff 0%, #d4c2ff 45%, #a47bff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 14px rgba(160, 100, 255, 0.40));
}
.topbar__status {
    flex: 1;
    min-width: 0;
    margin: 0;
    font: 500 12px/1.4 Consolas, monospace;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar__user { display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 320px; }
.topbar__name-row { display: flex; align-items: center; gap: 7px; min-width: 0; }
.admin-badge {
    font: 700 9px/1 Consolas, monospace;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(91, 200, 245, 0.15);
    color: #5bc8f5;
    white-space: nowrap;
}
.topbar .logout-btn { text-decoration: none; display: inline-flex; align-items: center; }

.workspace {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: 0;
}

/* ── Навигация слева ──────────────────────────────────────────────────────────────────────────────────────────────── */
.sidebar {
    overflow-y: auto;
    padding: 10px 8px 24px;
    border-right: 1px solid var(--line);
    background: rgba(18, 12, 38, 0.45);
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.sidebar__head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--muted);
    font: 700 11px/1.2 Consolas, monospace;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    text-align: left;
    cursor: pointer;
}
.sidebar__head:first-child { margin-top: 0; }
.sidebar__head:hover { color: var(--ink); }
.sidebar__head.is-active { color: var(--ink); background: var(--accent-glow); }
.sidebar__head .side-node__count { margin-left: auto; }

.side-tree { display: flex; flex-direction: column; gap: 1px; }
.side-node {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-left: 6px;
    border-radius: 6px;
    border: 1px solid transparent;
}
.side-node.is-current { background: var(--accent-glow); }
/* Текущее место подсвечено только у открытого раздела: у остальных разделов оно лишь запомнено. */
.sidebar__head:not(.is-active) + * .side-node.is-current { background: none; }
.side-node.is-drop-target { border-color: var(--accent); background: var(--accent-glow); }
.side-node__toggle {
    width: 16px;
    flex-shrink: 0;
    padding: 0;
    background: none;
    border: none;
    color: var(--accent-dim);
    cursor: pointer;
    font-size: 11px;
}
.side-node__toggle:disabled { cursor: default; }
.side-node__label {
    flex: 1;
    min-width: 0;
    padding: 5px 4px;
    background: none;
    border: none;
    color: var(--ink);
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.side-node__label:hover { color: #fff; }
.side-node__count { padding: 0 8px; color: var(--muted); font: 500 11px/1 Consolas, monospace; }

/* ── Раздел справа: заголовок, плитки, справа карточка выбранного ─────────────────────────────────────────────────── */
.content {
    min-width: 0;
    overflow-y: auto;
    padding: 16px 22px 40px;
}
.view { display: flex; flex-direction: column; gap: 12px; }
.view__head { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.view__title { margin: 0; font-size: 18px; font-weight: 600; color: var(--ink); }

.browser {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-areas: "head head" "tiles side";
    gap: 12px 18px;
    align-items: start;
    min-width: 0;
}
.browser > .view__head { grid-area: head; }
.browser > .tiles, .browser > .empty { grid-area: tiles; }
.browser > .inspector { grid-area: side; position: sticky; top: 0; }
.browser.is-drop-target { outline: 1px dashed var(--accent); outline-offset: 6px; border-radius: 10px; }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 17px; font-weight: 600; }
.crumb {
    padding: 2px 6px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
}
.crumb:hover { background: var(--accent-glow); }
.crumbs__sep { color: var(--muted); }
.crumbs__here { color: var(--ink); font-weight: 600; padding: 2px 6px; }

.toolbar, .actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.toolbar .invite-button, .toolbar .action-button,
.inspector .invite-button, .inspector .action-button {
    min-height: 32px;
    padding: 0 12px;
    font-size: 11px;
}

/* Плитки */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}
.tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-bg);
    cursor: pointer;
    user-select: none;
    min-width: 0;
    transition: border-color 120ms ease, background 120ms ease;
}
.tile:hover { border-color: var(--accent-dim); }
.tile.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: rgba(155, 109, 255, 0.08); }
.tile.is-drop-target { border-color: var(--accent); background: var(--accent-glow); }
.tile--child { border-style: dashed; }
.tile--trash { opacity: 0.75; }
.tile--importing { opacity: 0.6; cursor: progress; border-style: dashed; }

/* Картинка плитки: значок вида или миниатюра 256×160 (сцена — src/platform/scene-thumbnail.js) */
.tile__icon, .scene-thumb {
    position: relative;
    overflow: hidden;
    aspect-ratio: 256 / 160;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--accent-dim);
    font-size: 34px;
}
.tile__thumb img, .scene-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile__stale, .scene-thumb__stale {
    position: absolute;
    right: 4px;
    bottom: 4px;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 10px;
    background: rgba(240, 160, 60, 0.85);
    color: #1a1030;
}

.tile__title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tile__name { flex: 1; min-width: 0; color: var(--ink); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__meta { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__badge {
    flex-shrink: 0;
    padding: 2px 6px;
    border: 1px solid;
    border-radius: 8px;
    font-size: 9px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.tile__badge--public { background: rgba(80, 200, 140, 0.12); color: rgba(120, 255, 180, 0.95); border-color: rgba(80, 200, 140, 0.30); }
.tile__badge--readonly { background: rgba(240, 160, 60, 0.12); color: #f0c060; border-color: rgba(240, 160, 60, 0.30); }
.tile__badge--mine, .tile__badge--private { background: rgba(155, 109, 255, 0.10); color: rgba(200, 170, 255, 0.95); border-color: rgba(155, 109, 255, 0.32); }
.tile__badge--trash { background: rgba(240, 120, 90, 0.12); color: rgba(255, 180, 150, 0.95); border-color: rgba(240, 120, 90, 0.30); }

/* Карточка выбранного */
.inspector {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--accent-dim);
    border-radius: 10px;
    background: rgba(155, 109, 255, 0.05);
}
.inspector--empty { border-style: dashed; border-color: var(--line); background: none; color: var(--muted); font-size: 12px; }
.inspector__title { color: var(--ink); font-size: 14px; font-weight: 600; }
.inspector__meta { color: var(--muted); font: 500 11px/1.4 Consolas, monospace; word-break: break-all; }
.picker {
    min-width: 220px;
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--panel-bg);
    color: var(--ink);
}

/* Меню «Импорт ▾» */
.menu-anchor { position: relative; display: inline-flex; }
/* Кнопка стоит у правого края раздела — меню раскрывается влево, не за край страницы. */
.menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 30;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    padding: 4px;
    border: 1px solid var(--accent-dim);
    border-radius: 10px;
    background: rgba(20, 14, 40, 0.98);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
}
.menu__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--ink);
    font: 600 13px/1.2 Bahnschrift, "Segoe UI Variable", "Segoe UI", sans-serif;
    text-align: left;
    cursor: pointer;
}
.menu__item:hover { background: var(--accent-glow); }
.menu__hint { color: var(--muted); font: 500 11px/1 Consolas, monospace; }

.empty { margin: 0; padding: 8px 2px; color: rgba(236, 241, 247, 0.45); font-style: italic; }
/* Новое с прошлого чтения — плитка сессии, строка участника — вспыхивает один раз */
.tile.row-added-highlight, .member-line.row-added-highlight { animation: portal-card-added 1.4s ease-out; }

/* ── Карточка сессии: подзаголовки, QR, участники, приглашение ──────────────────────────────────────────────────── */
.inspector__section {
    padding-top: 10px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font: 700 10px/1.2 Consolas, monospace;
    letter-spacing: 0.10em;
    text-transform: uppercase;
}
.session-qr { display: flex; align-items: center; gap: 12px; }
.session-qr__image {
    width: 116px;
    height: 116px;
    flex-shrink: 0;
    padding: 6px;
    border-radius: 10px;
    background: rgba(235, 228, 255, 0.96);
}
.session-qr__label { color: var(--muted); font-size: 12px; line-height: 1.4; }

.member-lines { display: flex; flex-direction: column; gap: 4px; }
.member-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
}
.member-line__who { flex: 1 1 100%; display: flex; align-items: center; gap: 6px; min-width: 0; }
.member-line__user { flex: 1; min-width: 0; color: var(--ink); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-line__role {
    flex-shrink: 0;
    padding: 2px 6px;
    border: 1px solid rgba(155, 109, 255, 0.32);
    border-radius: 8px;
    background: rgba(155, 109, 255, 0.10);
    color: rgba(200, 170, 255, 0.95);
    font-size: 9px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.member-line__state { flex: 1; min-width: 0; color: var(--muted); font: 500 11px/1.3 Consolas, monospace; }
.member-line__tools { display: flex; flex-wrap: wrap; gap: 4px; }
.inspector .member-line__tools .invite-button { min-height: 24px; padding: 0 8px; border-radius: 8px; font-size: 10px; }

.invite-line { display: flex; flex-wrap: wrap; gap: 6px; }
.invite-line__user { flex: 1 1 100%; min-width: 0; }
.invite-line__role { flex: 1; min-width: 0; }
.invite-line input, .invite-line select {
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid rgba(140, 100, 255, 0.18);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--ink);
    font: 500 13px/1 Bahnschrift, "Segoe UI Variable", "Segoe UI", sans-serif;
    outline: none;
}
.invite-line input:focus, .invite-line select:focus { border-color: rgba(155, 109, 255, 0.55); }
.invite-line select option { background: #1a1030; }

/* ── Узко: навигация над разделом, карточка под плитками ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .browser { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "tiles" "side"; }
    .browser > .inspector { position: static; }
}
@media (max-width: 720px) {
    .app { height: auto; min-height: 100vh; }
    .topbar { flex-wrap: wrap; }
    .workspace { grid-template-columns: minmax(0, 1fr); align-content: start; }
    .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
    .content { overflow: visible; padding: 14px 16px 32px; }
    .topbar__status, .user-bar-email { display: none; }
}
