/* MOB_UI2_V1 — шапка на телефоне, меню ☰ плитками, настройка «Шапка / Меню / Скрыть».
   Подключается из _kc_header.html (единственный источник шапки). */

/* iOS: долгий тап по кнопкам шапки — наша панель, а не предпросмотр ссылки Safari */
.kc-nav a, #kcThemeBtn, #kcBurgerBtn, .kc-av {
  -webkit-touch-callout: none;
  -webkit-user-select: none; user-select: none;
  -webkit-user-drag: none;
}

/* то же для карточек и строк с собственным меню по долгому тапу (кабинеты, АРМ) */
[data-ctx], [data-ctx] a { -webkit-touch-callout: none; }

/* ---------- шапка на телефоне: кнопки не обрезаются слева, лента листается ---------- */
@media (max-width: 700px) {
  .kc-header { gap: 4px; padding-left: 6px; padding-right: 8px; }
  .kc-header > a[href="/kc/games/"] { display: none !important; }
  .kc-nav {
    flex: 1 1 0; min-width: 0;
    justify-content: flex-start;          /* center обрезал первые кнопки («Заявки») */
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
    scrollbar-width: none; gap: 0; padding: 0;
  }
  .kc-nav::-webkit-scrollbar { display: none; }
  .kc-nav a {
    flex: 0 0 auto; min-width: 50px; padding: 5px 4px 4px; border-radius: 10px;
    justify-content: center;
  }
  .kc-nav a.active { background: var(--accent-soft, rgba(88,166,255,.12)); border-bottom-color: transparent; }
  .kc-nav-ico .kc-ic { width: 19px; height: 19px; }
  .kc-nav-label { font-size: 9.5px !important; letter-spacing: 0; }
  /* затухание края — видно, что лента листается */
  .kc-nav.kn2-l { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 22px); mask-image: linear-gradient(90deg, transparent 0, #000 22px); }
  .kc-nav.kn2-r { -webkit-mask-image: linear-gradient(270deg, transparent 0, #000 22px); mask-image: linear-gradient(270deg, transparent 0, #000 22px); }
  .kc-nav.kn2-l.kn2-r {
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%);
  }
  /* кнопка темы переезжает в меню ☰ — в шапке место под ещё одну кнопку */
  .kc-header.kn2 #kcThemeBtn { display: none !important; }
}

/* ---------- меню ☰: плитки вместо длинного списка ---------- */
#kcBurgerMenu.kb2 {
  width: 336px; max-width: calc(100vw - 16px); min-width: 0;
  padding: 10px; border-radius: 16px; overflow: hidden auto;
  background: var(--bg2, #161b22); border: 1px solid var(--border, #30363d);
  box-shadow: 0 22px 60px rgba(0,0,0,.5);
  max-height: calc(100vh - 76px); max-height: calc(100dvh - 76px);
}
#kcBurgerMenu.kb2 > .kb2-src { display: none !important; }
.kb2-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
#kcBurgerMenu.kb2 a.kb2-t {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 7px; min-height: 74px; padding: 10px 4px 9px; border-radius: 12px; border: 1px solid transparent;
  background: var(--bg3, #1c2128); color: var(--text, #e6edf3);
  font: 600 12px/1.2 Inter, system-ui, sans-serif; text-align: center; text-decoration: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  transition: background .12s, border-color .12s, transform .08s;
}
#kcBurgerMenu.kb2 a.kb2-t:hover { border-color: var(--accent, #58a6ff); background: var(--bg3, #1c2128); color: var(--text, #e6edf3); }
#kcBurgerMenu.kb2 a.kb2-t:active { transform: scale(.97); }
#kcBurgerMenu.kb2 a.kb2-t.active { background: var(--accent-soft, rgba(88,166,255,.12)); color: var(--accent, #58a6ff); }
#kcBurgerMenu.kb2 a.kb2-t .kc-ic { width: 22px; height: 22px; margin: 0; opacity: 1; color: var(--accent, #58a6ff); vertical-align: 0; }
.kb2-l { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; max-width: 100%; overflow: hidden; overflow-wrap: anywhere; }
.kb2-b {
  position: absolute; top: 6px; right: 8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: #f0883e; color: #fff; font: 700 11px/18px Inter, system-ui, sans-serif; text-align: center;
}
.kb2-empty { grid-column: 1 / -1; padding: 14px 8px; text-align: center; font-size: 12.5px; color: var(--text2, #8b949e); }
.kb2-ft { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border, #30363d); }
#kcBurgerMenu.kb2 .kb2-ft > a, #kcBurgerMenu.kb2 .kb2-ft > button, #kcBurgerMenu.kb2 .kb2-ft form > button {
  flex: 1 1 0; min-width: 0; height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 8px; margin: 0; border-radius: 10px; border: 1px solid var(--border, #30363d); background: transparent;
  color: var(--text, #e6edf3); font: 600 12.5px Inter, system-ui, sans-serif; text-decoration: none; cursor: pointer; width: auto;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#kcBurgerMenu.kb2 .kb2-ft form { min-width: 0; display: grid; margin: 0; padding: 0; }
#kcBurgerMenu.kb2 .kb2-ft form > button { width: 100%; }
#kcBurgerMenu.kb2 .kb2-ft .kc-ic { width: 16px; height: 16px; margin: 0; flex: none; }
#kcBurgerMenu.kb2 .kb2-ft .kb2-out { color: var(--red, #f85149); }
#kcBurgerMenu.kb2 .kb2-ft > a:hover, #kcBurgerMenu.kb2 .kb2-ft > button:hover { border-color: var(--accent, #58a6ff); background: transparent; color: var(--text, #e6edf3); }
.kb2-me { display: flex; align-items: center; gap: 8px; margin: 8px 2px 0; font-size: 12px; color: var(--text2, #8b949e); }
.kb2-me b { color: var(--text, #e6edf3); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb2-pal { margin-left: auto; display: flex; gap: 7px; align-items: center; }
.kb2-pal button { width: 20px; height: 20px; padding: 0; border-radius: 50%; border: 2px solid var(--bg2, #161b22); outline: 1px solid var(--border, #30363d); background: var(--sw); cursor: pointer; }
.kb2-pal button.on { outline: 2px solid var(--text, #e6edf3); }
@media (max-width: 700px) {
  #kcBurgerMenu.kb2 { position: fixed; left: 8px; right: 8px; top: var(--kb2-top, 60px); width: auto; max-width: none;
    max-height: calc(100vh - var(--kb2-top, 60px) - 12px); max-height: calc(100dvh - var(--kb2-top, 60px) - 12px); }
  #kcBurgerMenu.kb2 a.kb2-t { min-height: 78px; font-size: 12.5px; }
}

/* ---------- панель настройки меню ---------- */
.kn2-scrim { position: fixed; inset: 0; z-index: 10000; background: rgba(1,4,9,.55); opacity: 0; visibility: hidden; transition: opacity .16s, visibility .16s; }
.kn2-scrim.show { opacity: 1; visibility: visible; }
.kn2-panel {
  position: fixed; z-index: 10001; width: 380px; max-width: calc(100vw - 16px);
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); display: flex; flex-direction: column;
  background: var(--bg2, #161b22); color: var(--text, #e6edf3); border: 1px solid var(--border, #30363d); border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,.55); font-family: Inter, system-ui, sans-serif;
  opacity: 0; visibility: hidden; transform: translateY(-6px); transition: opacity .16s, transform .18s, visibility .16s;
}
.kn2-panel.show { opacity: 1; visibility: visible; transform: none; }
.kn2-hd { display: flex; align-items: center; gap: 10px; padding: 14px 16px 6px; }
.kn2-hd b { font-size: 15px; font-weight: 700; flex: 1; }
.kn2-x { width: 32px; height: 32px; border-radius: 9px; border: 0; background: transparent; color: var(--text2, #8b949e); font-size: 20px; line-height: 1; cursor: pointer; }
.kn2-x:hover { background: var(--bg3, #1c2128); color: var(--text, #e6edf3); }
.kn2-note { padding: 0 16px 10px; font-size: 12.5px; line-height: 1.45; color: var(--text2, #8b949e); }
.kn2-list { overflow: auto; padding: 0 8px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.kn2-g { padding: 12px 8px 4px; font: 700 11px Inter, system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; color: var(--text3, #6e7681); }
.kn2-row { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 4px 8px; border-radius: 10px; }
.kn2-row + .kn2-row { border-top: 1px solid var(--border-soft, rgba(110,118,129,.2)); border-radius: 0; }
.kn2-row .kc-ic { width: 18px; height: 18px; flex: none; color: var(--accent, #58a6ff); }
.kn2-row.is-hid .kc-ic, .kn2-row.is-hid .kn2-lb { opacity: .45; }
.kn2-lb { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kn2-seg { display: inline-flex; flex: none; padding: 2px; gap: 2px; border-radius: 9px; background: var(--bg, #0d1117); border: 1px solid var(--border, #30363d); }
.kn2-seg button {
  min-width: 56px; height: 30px; padding: 0 8px; border: 0; border-radius: 7px; background: transparent;
  color: var(--text2, #8b949e); font: 600 12px Inter, system-ui, sans-serif; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.kn2-seg button.on { background: var(--accent, #58a6ff); color: #fff; }
.kn2-seg button.on[data-s="hid"] { background: var(--bg4, #30363d); color: var(--text, #e6edf3); }
.kn2-seg button:disabled { opacity: .3; cursor: default; }
.kn2-ft { display: flex; align-items: center; gap: 8px; padding: 12px 16px 14px; border-top: 1px solid var(--border, #30363d); margin-top: 6px; }
.kn2-ft span { flex: 1; font-size: 12px; color: var(--text2, #8b949e); }
.kn2-ft button { height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border, #30363d); background: transparent; color: var(--text, #e6edf3); font: 600 13px Inter, system-ui, sans-serif; cursor: pointer; }
.kn2-ft button.pri { background: var(--accent, #58a6ff); border-color: var(--accent, #58a6ff); color: #fff; }
@media (max-width: 700px) {
  .kn2-panel { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; max-width: none;
    max-height: 86vh; max-height: 86dvh; border-radius: 18px 18px 0 0; border-width: 1px 0 0; transform: translateY(24px);
    padding-bottom: env(safe-area-inset-bottom, 0); }
  .kn2-seg button { min-width: 58px; height: 34px; }
}
/* на странице «Управление → Меню и шапка» панель встроена в страницу */
.kn2-inline { position: static; width: auto; max-width: 560px; max-height: none; opacity: 1; visibility: visible; transform: none; box-shadow: none; z-index: auto; }
.kn2-inline .kn2-list { overflow: visible; }
.kn2-inline .kn2-x { display: none; }
@media (max-width: 700px) { .kn2-inline { border-width: 1px; border-radius: 16px; padding-bottom: 0; } }
@media (prefers-reduced-motion: reduce) { .kn2-panel, .kn2-scrim, #kcBurgerMenu.kb2 a.kb2-t { transition: none; } }
