/* ═══════════════════════════════════════════════════════════════════════
   Рабочая станция — каркас поверх существующего #app
   [рельс][список][чат][слот] + мобильная нижняя навигация
   ═══════════════════════════════════════════════════════════════════════ */

#app {
  display: flex;
  align-items: stretch;
}

/* ── Рельс ──────────────────────────────────────────────────────────────── */
.rail {
  width: var(--rail-w);
  min-width: var(--rail-w);
  height: var(--app-height, 100vh);
  background: var(--bg-rail, #0c0c0d);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 12px;
  flex-shrink: 0;
}
.rail__mark {
  width: 40px; height: 40px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); margin-bottom: 16px;
}
.rail__mark svg { width: 26px; height: 26px; }
.rail__spaces { display: flex; flex-direction: column; gap: 4px; flex: 1; width: 100%; align-items: center; }
.rail__item {
  position: relative; width: 52px; height: 50px; border-radius: 13px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: transparent; border: none; cursor: pointer; color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.rail__item svg { width: 21px; height: 21px; }
.rail__item:hover { background: var(--bg-glass); color: var(--text-secondary); }
.rail__item--active { background: var(--accent-muted); color: var(--accent); }
.rail__item--active::before {
  content: ''; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; background: var(--accent); border-radius: 0 3px 3px 0;
}
.rail__label { font-size: 9px; font-weight: var(--fw-medium); letter-spacing: 0.01em; }
.rail__count {
  position: absolute; top: 5px; right: 8px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--accent); color: #fff;
  font-family: var(--font-mono); font-size: 9px; font-weight: var(--fw-medium);
  display: flex; align-items: center; justify-content: center;
}
.rail__bottom { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rail__icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer; color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.rail__icon-btn svg { width: 20px; height: 20px; }
.rail__icon-btn:hover { background: var(--bg-glass); color: var(--text-primary); }
.rail__avatar {
  width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--fw-semibold); font-size: 13px; color: var(--text-primary);
  overflow: hidden;
}

/* ── Список: новая шапка ────────────────────────────────────────────────── */
.sidebar__titlebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 4px 12px;
}
.sidebar__space-title {
  font-size: var(--font-xl); font-weight: var(--fw-bold); letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* ── Слот (правая панель) ───────────────────────────────────────────────── */
.slot {
  width: 0; min-width: 0; overflow: hidden;
  height: var(--app-height, 100vh);
  background: var(--bg-sidebar);
  border-left: 1px solid transparent;
  display: flex; flex-direction: column;
  flex-shrink: 0;
  transition: width var(--t-base), min-width var(--t-base);
}
.slot[data-open="true"] {
  width: var(--slot-w); min-width: var(--slot-w);
  border-left-color: var(--border);
}
.slot__head {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-h); padding: 0 8px 0 18px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.slot__title { font-size: var(--font-lg); font-weight: var(--fw-semibold); }
.slot__tabs { display: flex; gap: 2px; padding: 8px 12px; border-bottom: 1px solid var(--border-subtle); }
.slot__tab {
  flex: 1; padding: 7px 8px; border-radius: 8px; background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); font-family: var(--font-family); font-size: var(--font-sm); font-weight: var(--fw-medium);
  transition: background var(--t-fast), color var(--t-fast);
}
.slot__tab:hover { background: var(--bg-glass); color: var(--text-secondary); }
.slot__tab--active { background: var(--bg-glass-hover); color: var(--text-primary); }
.slot__body { flex: 1; overflow-y: auto; }
.slot__loading, .slot__empty { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: var(--font-sm); }
.slot__empty svg { width: 30px; height: 30px; opacity: 0.5; margin-bottom: 10px; }
.slot__empty p { margin: 0; }
.slot__empty-hint { font-family: var(--font-mono); font-size: var(--font-xs); color: var(--text-muted); opacity: 0.7; }

.slot__prof { display: flex; flex-direction: column; align-items: center; padding: 26px 20px 18px; text-align: center; border-bottom: 1px solid var(--border-subtle); }
.slot__prof-avatar { width: 88px; height: 88px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: var(--fw-semibold); color: var(--text-primary); overflow: hidden; }
.slot__prof-name { font-size: var(--font-lg); font-weight: var(--fw-bold); letter-spacing: -0.01em; margin-top: 14px; }
.slot__prof-handle { font-family: var(--font-mono); font-size: var(--font-sm); color: var(--text-muted); margin-top: 3px; }
.slot__prof-bio { font-size: var(--font-sm); color: var(--text-secondary); margin-top: 12px; line-height: 1.5; }
.slot__prof-actions { display: flex; gap: 8px; margin-top: 18px; }
.slot__qbtn {
  display: flex; flex-direction: column; align-items: center; gap: 5px; width: 64px; padding: 10px 4px;
  border-radius: 11px; background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-secondary);
  cursor: pointer; font-family: var(--font-family); font-size: var(--font-xs);
  transition: background var(--t-fast), color var(--t-fast);
}
.slot__qbtn svg { width: 18px; height: 18px; }
.slot__qbtn:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.slot__qbtn--danger:hover { color: var(--danger); }

.slot__group { padding: 14px 18px; border-bottom: 1px solid var(--border-subtle); }
.slot__group-label { font-size: var(--font-xs); font-weight: var(--fw-semibold); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.slot__row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.slot__row-ic { color: var(--text-muted); display: flex; }
.slot__row-ic svg { width: 17px; height: 17px; }
.slot__row-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: var(--fw-semibold); color: var(--text-primary); overflow: hidden; flex-shrink: 0; }
.slot__row-main { flex: 1; min-width: 0; }
.slot__row-k { font-size: var(--font-sm); color: var(--text-primary); }
.slot__row-v { font-size: var(--font-xs); color: var(--text-muted); margin-top: 1px; }

.slot__mgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 12px; }
.slot__mtile { aspect-ratio: 1; border-radius: 8px; overflow: hidden; background-color: var(--bg-surface); background-size: cover; background-position: center; border: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.slot__mtile--video svg { width: 22px; height: 22px; }
.slot__mtile:hover { border-color: var(--border-accent); }
.slot__frow { display: flex; align-items: center; gap: 12px; padding: 9px 16px; cursor: pointer; }
.slot__frow:hover { background: var(--bg-glass); }
.slot__ficon { width: 38px; height: 38px; border-radius: 9px; background: var(--bg-surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--accent); flex-shrink: 0; }
.slot__ficon svg { width: 18px; height: 18px; }

.slot__thread { display: block; width: 100%; text-align: left; padding: 12px 16px; background: transparent; border: none; border-bottom: 1px solid var(--border-subtle); cursor: pointer; transition: background var(--t-fast); }
.slot__thread:hover { background: var(--bg-glass); }
.slot__thread-title { font-size: var(--font-sm); font-weight: var(--fw-medium); color: var(--text-primary); }
.slot__thread-meta { font-family: var(--font-mono); font-size: var(--font-xs); color: var(--text-muted); margin-top: 3px; }

.icon-btn--active { color: var(--accent) !important; background: var(--accent-muted) !important; }
.icon-btn--sm { width: 32px; height: 32px; }

/* ── Лента «Требует внимания» ───────────────────────────────────────────── */
.sidebar__activity { padding: 0 14px 10px; }
.activity {
  border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden;
  background: var(--bg-glass);
}
.activity__head { display: flex; align-items: center; gap: 7px; padding: 9px 12px 7px; }
.activity__head svg { width: 15px; height: 15px; color: var(--accent); }
.activity__head span {
  font-size: var(--font-xs); font-weight: var(--fw-semibold); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted);
}
.activity__item {
  display: flex; gap: 9px; align-items: flex-start; width: 100%; text-align: left;
  padding: 8px 12px; border: none; border-top: 1px solid var(--border-subtle);
  background: transparent; cursor: pointer; transition: background var(--t-fast);
}
.activity__item:hover { background: var(--bg-glass-hover); }
.activity__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex-shrink: 0; }
.activity__text {
  flex: 1; min-width: 0; font-size: var(--font-sm); color: var(--text-secondary); line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.activity__text b { color: var(--text-primary); font-weight: var(--fw-semibold); }
.activity__time { font-family: var(--font-mono); font-size: var(--font-xs); color: var(--text-muted); flex-shrink: 0; }

/* ── Бейдж треда под сообщением ─────────────────────────────────────────── */
.message__thread {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
  padding: 4px 10px; border-radius: 20px; cursor: pointer;
  background: var(--bg-glass); border: 1px solid var(--border-subtle);
  color: var(--accent); font-family: var(--font-family); font-size: var(--font-xs); font-weight: var(--fw-medium);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.message__thread:hover { background: var(--bg-glass-hover); border-color: var(--border-accent); }
.message__thread svg { width: 13px; height: 13px; }

/* ── Панель треда (оверлей поверх чата) ─────────────────────────────────── */
.thread-ov {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,0.45);
  display: flex; justify-content: flex-end;
  opacity: 0; transition: opacity var(--t-base);
}
.thread-ov--visible { opacity: 1; }
.thread-panel {
  width: 440px; max-width: 100%; height: 100%;
  background: var(--bg-sidebar); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transform: translateX(24px); transition: transform var(--t-base);
  box-shadow: -10px 0 40px rgba(0,0,0,0.4);
}
.thread-ov--visible .thread-panel { transform: translateX(0); }
.thread-panel__head {
  display: flex; align-items: center; gap: 10px;
  height: var(--header-h); padding: 0 14px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.thread-panel__titles { display: flex; flex-direction: column; line-height: 1.2; }
.thread-panel__title { display: flex; align-items: center; gap: 7px; font-size: var(--font-lg); font-weight: var(--fw-semibold); }
.thread-panel__title svg { width: 17px; height: 17px; color: var(--accent); }
.thread-panel__sub { font-family: var(--font-mono); font-size: var(--font-xs); color: var(--text-muted); margin-top: 2px; }
.thread-panel__body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.thread-panel__root {
  padding: 4px 6px 12px; margin-bottom: 4px;
  border-bottom: 1px dashed var(--border);
}
.thread-panel__sep {
  display: flex; align-items: center; gap: 12px; margin: 8px 2px 4px;
  color: var(--text-muted); font-size: var(--font-xs); text-transform: uppercase; letter-spacing: 0.06em;
}
.thread-panel__sep::before, .thread-panel__sep::after {
  content: ''; flex: 1; height: 1px; background: var(--border-subtle);
}
.thread-panel__composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; flex-shrink: 0;
  border-top: 1px solid var(--border); background: var(--bg-surface);
}
.thread-panel__input {
  flex: 1; resize: none; max-height: 120px; padding: 9px 12px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--bg-input, var(--bg-glass));
  color: var(--text-primary); font-family: var(--font-family); font-size: var(--font-sm); line-height: 1.4;
}
.thread-panel__input:focus { outline: none; border-color: var(--border-accent); }

@media (max-width: 768px) {
  .thread-panel { width: 100%; border-left: none; }
}

/* ── Мобильная нижняя навигация (скрыта на десктопе) ────────────────────── */
.mobnav { display: none; }

/* ═══ Адаптив ════════════════════════════════════════════════════════════ */

/* Слот уходит в оверлей на средних ширинах */
@media (max-width: 1180px) {
  .slot[data-open="true"] {
    position: fixed; right: 0; top: 0; bottom: 0;
    width: var(--slot-w); z-index: 60;
    box-shadow: -10px 0 40px rgba(0,0,0,0.4);
  }
}

@media (max-width: 768px) {
  .rail { display: none; }
  .slot[data-open="true"] { width: 100%; min-width: 100%; }

  /* Нижняя навигация по пространствам */
  .mobnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    height: 58px; padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
    background: var(--bg-rail, #0c0c0d); border-top: 1px solid var(--border);
  }
  .mobnav__item {
    flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; border: none; cursor: pointer; color: var(--text-muted); border-radius: 10px;
    font-size: 10px; font-weight: var(--fw-medium); transition: color var(--t-fast);
  }
  .mobnav__item svg { width: 20px; height: 20px; }
  .mobnav__item--active { color: var(--accent); }
  .mobnav__badge {
    position: absolute; top: 3px; right: 50%; margin-right: -20px;
    min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px;
    background: var(--accent); color: #fff; font-family: var(--font-mono); font-size: 9px;
    display: flex; align-items: center; justify-content: center;
  }
  /* Когда открыт чат — прячем нижнюю навигацию, чат на весь экран */
  #app[data-mobile="conv"] .mobnav { display: none; }
  /* Запас снизу под навигацию в списке */
  #app:not([data-mobile="conv"]) .sidebar__chats { padding-bottom: 64px; }
}
