/* КЛАССИКА: только классический интерфейс (плоский вид, телефон, планшет, ПК, модалки классики). */


/* ----- навигационная панель (шапка) ----- */
html[data-pf="apple"] .topbar { background: rgba(249, 249, 251, .78); -webkit-backdrop-filter: saturate(1.8) blur(24px); backdrop-filter: saturate(1.8) blur(24px); border-bottom: .5px solid var(--line-strong); box-shadow: none; color: var(--text); }

html[data-pf="apple"] .topbar .brand { color: var(--text); }

html[data-pf="apple"] .topbar .brand-logo { filter: brightness(0) opacity(.86); }

html[data-pf="apple"] .topbar-title { color: var(--muted); border-left-color: var(--line-strong); }

html[data-pf="apple"] .topbar .btn-ghost,
html[data-pf="apple"] .topbar .nav-toggle { color: var(--ap); }

html[data-pf="apple"] .topbar .btn-ghost:hover { background: var(--primary-soft); color: var(--ap); }

html[data-pf="apple"] .login-card .brand-logo { filter: brightness(0) opacity(.86); }


/* ----- боковая панель macOS (source list) ----- */
html[data-pf="apple"] .sidebar { background: rgba(246, 246, 250, .8); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); border-right: .5px solid var(--line-strong); padding: 14px 10px 24px; }

html[data-pf="apple"] .nav-item { min-height: 32px; padding: 6px 10px; border-radius: 8px; color: var(--text); font-size: 14px; font-weight: 500; gap: 10px; }

html[data-pf="apple"] .nav-item .i { color: var(--ap); width: 18px; height: 18px; }

html[data-pf="apple"] .nav-item:hover { background: rgba(60, 60, 67, .07); }

html[data-pf="apple"] .nav-item.active,
html[data-pf="apple"] .nav-item[aria-current="page"] { background: var(--ap); color: #fff; font-weight: 600; }

html[data-pf="apple"] .nav-item.active .i,
html[data-pf="apple"] .nav-item[aria-current="page"] .i { color: #fff; }

html[data-pf="apple"] .nav-label { color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: .02em; text-transform: none; margin: 16px 0 4px; padding: 0 10px; }

html[data-pf="apple"] .nav-fold-head { border-radius: 8px; }

html[data-pf="apple"].is-embed:where(:not(.in-os)) .form-bar { background: rgba(249, 249, 251, .85); -webkit-backdrop-filter: saturate(1.8) blur(20px); backdrop-filter: saturate(1.8) blur(20px); border-top: .5px solid var(--line-strong); }

html[data-pf="apple"] .brand-mark { background: var(--ap); box-shadow: none; }


/* ----- нижняя панель вкладок iOS (только узкие экраны) ----- */
.tabbar { display: none; }

@media (max-width: 900px) {
  html[data-pf="apple"] .tabbar { display: flex; position: fixed; z-index: 57; left: 0; right: 0; bottom: 0; padding: 6px 4px calc(6px + var(--sab, 0px)); background: rgba(249, 249, 251, .86); -webkit-backdrop-filter: saturate(1.8) blur(24px); backdrop-filter: saturate(1.8) blur(24px); border-top: .5px solid var(--line-strong); }

  html[data-pf="apple"] .tabbar .tab { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; border: 0; background: none; color: var(--faint); font: inherit; font-size: 10.5px; font-weight: 600; cursor: pointer; }

  html[data-pf="apple"] .tabbar .tab .i { width: 24px; height: 24px; }

  html[data-pf="apple"] .tabbar .tab.active { color: var(--ap); }

  html[data-pf="apple"] .tabbar .chat-count { position: absolute; top: 0; left: 55%; }

html[data-pf="apple"] body:not(.has-bar) .app-layout { padding-bottom: calc(64px + var(--sab, 0px)); }

  html.nav-open[data-pf="apple"] .tabbar { display: none; }

  html[data-pf="apple"] .topbar .nav-toggle { display: none; }
}

html[data-pf="apple"] .dsk-bar .brand { color: #1c1c1e; }

.tabbar .tab .i { stroke: currentColor; }


html[data-pf="apple"].is-embed:where(:not(.in-os)),
html[data-pf="apple"].is-embed:where(:not(.in-os)) body { background: var(--bg); }

@media (min-width: 721px) {
  html:not(.is-embed)[data-pf="apple"] .page:has(> .set-tabs) { padding-right: 24px; border-radius: 14px; }

  html:not(.is-embed) .page:has(> .set-tabs) > form { min-height: 0; }

  html:not(.is-embed) .page:has(> .set-tabs) > .set-tabs { border-radius: 14px 0 0 14px; }

  html:not(.is-embed) .page:has(> .set-tabs) > form.toolbar,
html.is-embed:where(:not(.in-os)) .page:has(> .set-tabs) > form.toolbar { display: flex; flex-direction: row; flex-wrap: wrap; min-height: 0; }
}


/* заголовки крупных блоков бокового меню: TRS / TRS Forge */
.sidebar .nav-section { margin: 18px 10px 2px; padding: 8px 12px; border-radius: 10px; background: var(--ap-soft, var(--primary-soft)); color: var(--ap, var(--primary)); font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }

@media (max-width: 720px) {
  html:not(.is-embed) .page:has(> .set-tabs) > .set-tabs { flex-wrap: nowrap; overflow-x: auto; margin: 0 0 14px; padding: 2px 0 6px; width: 100%; contain: inline-size; }

  html:not(.is-embed) .page:has(> .set-tabs) > .set-tabs a { flex: none; white-space: nowrap; }

  html:not(.is-embed) .page:has(> .set-tabs) > .set-tabs .set-group { display: none; }
}

html:not(.is-embed) .app-layout > .page,
html:not(.is-embed) .page:has(> .set-tabs) { min-width: 0; max-width: 100%; }

/* значок раздела всегда слева от заголовка, не «плавает» сверху */
html:not(.is-embed) .page-head:has(> .head-ico) { flex-direction: row; align-items: center; justify-content: flex-start; gap: 14px; }

html:not(.is-embed) .page-head:has(> .head-ico) > div:not(.head-ico) { min-width: 0; }

html.is-embed:where(:not(.in-os)) .mod-title { display: none !important; }

@media (min-width: 721px) {
  html:not(.is-embed) .page:has(> .set-tabs) > .set-tabs ~ :not(.notice):first-of-type { margin-top: 20px; }

  html:not(.is-embed) .page:has(> .set-tabs) > .set-tabs ~ .page-head { margin-top: 20px; }
}

@media (max-width: 720px) {
  html:not(.is-embed) .page:has(> .set-tabs) > .mod-title { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 10px; }

  html:not(.is-embed) .page:has(> .page-head ~ .set-tabs) > .page-head { order: 3; }
}

/* кнопки «Сохранить» — в неподвижной панели внизу контентной части */
html:not(.is-embed) .form-bar { position: sticky; bottom: 0; z-index: 20; display: flex; gap: 10px; justify-content: flex-end; margin: 18px -16px 0; padding: 12px 16px calc(12px + var(--sab, 0px)); border-top: .5px solid var(--line-strong); background: rgba(249,249,251,.88); -webkit-backdrop-filter: saturate(1.8) blur(20px); backdrop-filter: saturate(1.8) blur(20px); }

@media (min-width: 721px) {
 html:not(.is-embed) .page:has(> .set-tabs) .form-bar { margin: auto -24px 0 -22px; padding: 12px 24px 12px 22px; }
}

@media (min-width: 721px) and (max-width: 1100px) {
  html:not(.is-embed) .page:has(> .set-tabs) > :not(.set-tabs) { margin-left: 18px; }
}


/* ===== Шапка плоской версии на планшете — как на ПК: лого, отчерк, название модуля, кнопки справа ===== */
@media (min-width: 721px) {
  html[data-pf="apple"] .topbar-title { display: block; flex: 1; }

  html[data-pf="apple"] .topbar-actions { margin-left: auto; gap: 4px; }

  html[data-pf="apple"] .topbar-actions .btn span { display: inline; }

  html[data-pf="apple"] .topbar-actions .btn { width: auto; padding: 0 12px; }
}

/* кнопочная панель в окнах: заметно отделена, без обрезки рамкой карточки */
html.is-embed:where(:not(.in-os)):not(.is-modal) form.card > .form-bar.auto-bar { margin: 18px -26px -26px; border-radius: 0; }

html.is-embed:where(:not(.in-os)):not(.is-modal) form:not(.card) > .form-bar.auto-bar { margin: 18px 0 0; }

html.is-embed:where(:not(.in-os)) form.card:has(> .form-bar.auto-bar) { overflow: visible; }

html.is-embed:where(:not(.in-os)) .set-tabs .set-title { display: none !important; }

@media (min-width: 721px) {
  html[data-pf="apple"] .topbar-title { display: none; }

  html[data-pf="apple"] .topbar-actions { margin-left: auto; }

  html:not(.is-embed) .set-tabs .set-title { display: block; padding: 8px 12px 6px; font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -.025em; color: var(--text); }

  html:not(.is-embed) .set-tabs .set-title + .set-group { padding-top: 10px !important; }
}

@media (max-width: 720px) {
  html:not(.is-embed) .page:has(> .set-tabs) > .mod-title { font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -.03em; margin: 4px 0 12px; }
}

@media (min-width: 721px) {
 html:not(.is-embed) .set-tabs .set-title.is-long { font-size: 22px; letter-spacing: -.02em; }
}

@media (min-width: 721px) {
 html:not(.is-embed) .set-tabs .set-title.is-long { font-size: 20px; line-height: 1.2; }
 html:not(.is-embed) .set-tabs .set-title { display: -webkit-box; }
}

@media (min-width: 721px) and (max-width: 1100px) {
 html:not(.is-embed) .set-tabs .set-title.is-long { font-size: 17.5px; letter-spacing: -.01em; }
}


/* заголовок модуля: мельче и мягче */
@media (min-width: 721px) {
  html:not(.is-embed) .set-tabs .set-title { font-size: 21px; font-weight: 650; letter-spacing: -.015em; color: var(--text-2, #4b5160); padding: 6px 12px 4px; }

  html:not(.is-embed) .set-tabs .set-title.is-long { font-size: 17px; }
}

@media (max-width: 720px) {
  html:not(.is-embed) .page:has(> .set-tabs) > .mod-title { font-size: 26px; font-weight: 650; letter-spacing: -.02em; color: var(--text-2, #4b5160); margin: 2px 0 10px; }
}

html:not(.is-embed) .set-tabs .set-title,
html:not(.is-embed) .page:has(> .set-tabs) > .mod-title { color: #6b7385; font-weight: 600; }

@media (max-width: 720px) {
  html:not(.is-embed) .page > .set-tabs.sc-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); }

  html:not(.is-embed) .page > .set-tabs.sc-l { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 44px), transparent); }

  html:not(.is-embed) .page > .set-tabs.sc-l.sc-r { -webkit-mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 44px), transparent); }
}

/* телефон: кнопки шапки прижаты вправо, как в остальных плоских версиях */
@media (max-width: 720px) {
 html[data-pf="apple"] .topbar-actions { margin-left: auto; }
 html[data-pf="apple"] .topbar-title { display: none; }
}


/* ===== Модальные окна и окна правки: единый белый блок «шапка + тело + панель кнопок», без серой подложки и карточки-в-окне ===== */
html.is-embed:where(:not(.in-os)).is-modal,
html.is-embed:where(:not(.in-os)).is-modal body { background: var(--surface, #fff); }

html.is-embed:where(:not(.in-os)).is-modal .page { padding: 0; background: transparent; }

html.is-embed:where(:not(.in-os)).is-modal .page > .card,
html.is-embed:where(:not(.in-os)).is-modal .page > form.card,
html.is-embed:where(:not(.in-os)).is-modal .page > .card.section { background: transparent; border: 0; box-shadow: none; border-radius: 0; padding: 18px 22px 0; margin: 0; }

html.is-embed:where(:not(.in-os)).is-modal .page > .page-head,
html.is-embed:where(:not(.in-os)).is-modal .page > .notice { margin-left: 22px; margin-right: 22px; }

html.is-embed:where(:not(.in-os)).is-modal .page > form { display: flex; flex-direction: column; min-height: 100vh; }

html.is-embed:where(:not(.in-os)).is-modal .form-bar,
html.is-embed:where(:not(.in-os)).is-modal .form-bar.auto-bar { position: sticky; bottom: 0; margin: auto -22px 0; padding: 12px 22px; border-radius: 0; border-top: .5px solid var(--line-strong); background: var(--surface-2, #f5f6f9); -webkit-backdrop-filter: none; backdrop-filter: none; }

html.is-embed:where(:not(.in-os)).is-modal .page > .card + .card { border-top: .5px solid var(--line); }

html[data-pf="apple"].is-embed:where(:not(.in-os)).is-modal,
html[data-pf="apple"].is-embed:where(:not(.in-os)).is-modal body:not(.dsk):not(.login-page) { background: #fff; }

html.is-embed:where(:not(.in-os)).is-modal .page { display: flex; flex-direction: column; min-height: 100vh; }

html.is-embed:where(:not(.in-os)).is-modal .page > form { flex: 1; min-height: 0; }

html.is-embed:where(:not(.in-os)).is-modal .page > .form-bar { margin-top: auto; }

html.is-embed:where(:not(.in-os)).is-modal .form-bar .btn-cancel { background: var(--fill, #ececf0); color: var(--text, #1c1c1e); border: 0; }

html.is-embed:where(:not(.in-os)).is-modal .form-bar .btn-cancel:hover { background: var(--fill-2, #e0e0e6); }

html.is-embed:where(:not(.in-os)).is-modal .page,
html[data-pf="apple"].is-embed:where(:not(.in-os)).is-modal body .page,
html[data-pf="apple"].is-embed:where(:not(.in-os)).is-modal body:not(.has-bar) .app-layout { padding-bottom: 0 !important; }

body:has(.fm-panel) .tabbar { display: none !important; }


/* телефон: нижнее меню видно всегда (выход на главный экран без сохранения); панель «Сохранить» и редактор лежат над ним */
@media (max-width: 900px) {
  html[data-pf="apple"]:not(.is-embed) { --tabbar-h: calc(64px + var(--sab, 0px)); }

  html[data-pf="apple"]:not(.is-embed):not(.nav-open) .form-bar { bottom: var(--tabbar-h); padding-bottom: 12px; }

  html[data-pf="apple"]:not(.is-embed):not(.nav-open) .ed-bar { bottom: var(--tabbar-h); z-index: 56; }

  html[data-pf="apple"]:not(.is-embed) body:has(.ed-bar) .page,
html[data-pf="apple"]:not(.is-embed) body:has(.ed-bar) .app-layout { padding-bottom: calc(130px + var(--sab, 0px)); }
}


/* телефон: в строке подразделов нет заголовка модуля (он крупно над плитками); чат оставляет нижнее меню, закрывается его кнопкой «Чат» */
@media (max-width: 720px) {
  html:not(.is-embed) .set-tabs .set-title { display: none !important; }
}

@media (max-width: 900px) {
  html[data-pf="apple"]:not(.is-embed) .chat-panel,
html[data-pf="apple"]:not(.is-embed) .chat-panel.is-full { bottom: var(--tabbar-h, 64px); z-index: 56; }

  html[data-pf="apple"] body.chat-docked .tabbar [data-chat-toggle],
html[data-pf="apple"] body.chat-full .tabbar [data-chat-toggle] { color: var(--ap); }
}

@media (max-width: 900px) {
 html[data-pf="apple"] body.chat-docked .tabbar .tab.active:not([data-chat-toggle]),
html[data-pf="apple"] body.chat-full .tabbar .tab.active:not([data-chat-toggle]) { color: var(--faint); }
}

@media (min-width: 721px) and (max-width: 900px) {
  html:not(.is-embed),
html[data-pf="apple"]:not(.is-embed) { --tabbar-h: 0px; --sidebar-w: 212px; --topbar-h: 64px; }

  html:not(.is-embed) .topbar .nav-toggle,
html[data-pf="apple"]:not(.is-embed) .topbar .nav-toggle { display: none; }

  html:not(.is-embed) .sidebar-backdrop { display: none !important; }

  html:not(.is-embed) .sidebar { position: sticky; z-index: 5; top: var(--topbar-h); left: auto; bottom: auto; height: calc(100dvh - var(--topbar-h)); width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); transform: none !important; padding: 16px 10px 24px; box-shadow: none; }

  html:not(.is-embed) .topbar-title { display: block; }

  html[data-pf="apple"]:not(.is-embed) .tabbar { display: none !important; }

  html[data-pf="apple"]:not(.is-embed) body:not(.has-bar) .app-layout,
html[data-pf="apple"]:not(.is-embed) body:not(.has-bar) .page { padding-bottom: 0; }

  html[data-pf="apple"]:not(.is-embed) body:not(.has-bar) .page { padding-bottom: 40px; }

  html[data-pf="apple"]:not(.is-embed):not(.nav-open) .form-bar,
html[data-pf="apple"]:not(.is-embed):not(.nav-open) .ed-bar { bottom: 0; }

  html[data-pf="apple"]:not(.is-embed) .chat-panel,
html[data-pf="apple"]:not(.is-embed) .chat-panel.is-full { bottom: 0; }
}

@media (min-width: 721px) and (max-width: 1100px) and (orientation: portrait) {
  html:not(.is-embed) .page:has(> .set-tabs) { display: block !important; padding-right: 16px; }

  html:not(.is-embed) .page:has(> .set-tabs) > .mod-title { display: block; font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 10px; }

  html:not(.is-embed) .page:has(> .set-tabs) > .set-tabs { display: flex; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; position: static; height: auto; padding: 4px 0 8px; gap: 6px; background: transparent !important; border: 0 !important; border-radius: 0; margin: 0 0 10px; }

  html:not(.is-embed) .page:has(> .set-tabs) > .set-tabs .set-group,
html:not(.is-embed) .page:has(> .set-tabs) > .set-tabs .set-title { display: none !important; }

  html[data-pf="apple"]:not(.is-embed):not(.zz) .page:has(> .set-tabs) > .set-tabs a { flex: none; white-space: nowrap; border: 1px solid var(--line); background: var(--surface) !important; padding: 7px 14px; border-radius: 99px; }

  html[data-pf="apple"]:not(.is-embed):not(.zz) .page:has(> .set-tabs) > .set-tabs a.is-active { background: var(--ap) !important; color: #fff; border-color: transparent; }

  html:not(.is-embed) .page:has(> .set-tabs) > :not(.set-tabs) { margin-left: 0; }

  html:not(.is-embed) .page:has(> .set-tabs) .form-bar { margin: 18px -16px 0; padding: 12px 16px; }
}

@media (min-width: 901px) and (max-width: 1100px) and (orientation: portrait) {
  html:not(.is-embed) { --sidebar-w: 212px; }
}


/* окно ОС уже 721px: форма-фильтр (поиск) в разделе с подменю не растягивается на всю высоту окна */
html.is-embed:where(:not(.in-os)) .page:has(> .set-tabs) > form.toolbar { min-height: 0 !important; }

html.is-embed:where(:not(.in-os)) .page:has(> .set-tabs) > form.toolbar > * { flex: 0 0 auto; }


/* телефон: в нижней части бокового меню вместо группы «Настройки» (дубль кнопки в шапке) — только профиль и выход */
.nav-userblock { display: none; }

@media (max-width: 720px) {
  html:not(.is-embed) .sidebar .nav-fold { display: none; }

  html:not(.is-embed) .sidebar .nav-userblock { display: block; }

  .nav-userblock form { margin: 0; }

  .nav-userblock button.nav-item { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
}

/* единая панель: «Отмена» и «Сохранить» всегда справа, без дубля старых правил sticky */
html:not(.is-embed) .form-bar { justify-content: flex-end; }


