/* LOCAL PATCH mobile-theme t29u: the #theme switch docked in the phone header (see theme-dock.js). Desktop (rail) is unchanged. */
@media (max-width: 860px) {
  #shell header.top > #theme.theme-dock {
    display: flex; flex: 0 0 auto; align-self: center; gap: 0; padding: 2px; margin: 0;
    height: 41px; border: 0; border-radius: 10px; background: light-dark(#e8e8ed, #1c1c1e);
  }
  #shell header.top > #theme.theme-dock button {
    flex: 0 0 auto; width: 36px; height: 37px; padding: 0; display: grid; place-items: center;
    border-radius: 8px; background: transparent; color: var(--mute); box-shadow: none;
  }
  #shell header.top > #theme.theme-dock button svg { width: 17px; height: 17px; }
  #shell header.top > #theme.theme-dock button[aria-pressed="true"] {
    background: light-dark(#ffffff, #636366); color: var(--ink);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .04);
  }
  /* «Расширенный»: search and theme share the row under the date */
  html:not(.ui3) #shell header.top > #theme.theme-dock { order: 3; }
  html:not(.ui3) #shell header.top:has(> #theme.theme-dock) .kbd-btn { flex: 1 1 0; width: auto; min-width: 0; }
  /* «Новый»: the header is a grid (brand | actions / search) — the switch takes the right end of the search row */
  html.ui3 #shell header.top:has(> #theme.theme-dock) { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand actions" "search theme"; }
  html.ui3 #shell header.top > #theme.theme-dock { grid-area: theme; justify-self: end; width: auto; }
  html:not(.ui3) #shell header.top:has(> #theme.theme-dock) .kbd-btn { white-space: nowrap; overflow: hidden; }
}
/* LOCAL PATCH pc-theme t37u: PC «Новый» — the same switch, same look, docked right after search in the header (theme-dock.js). «Расширенный» PC keeps the rail switch. */
@media (min-width: 861px) {
  html.ui3 #shell header.top > #theme.theme-dock {
    display: flex; flex: 0 0 auto; align-self: center; gap: 0; padding: 2px; margin: 0;
    height: 41px; border: 0; border-radius: 10px; background: light-dark(#e8e8ed, #1c1c1e);
  }
  html.ui3 #shell header.top > #theme.theme-dock button {
    flex: 0 0 auto; width: 36px; height: 37px; padding: 0; display: grid; place-items: center;
    border-radius: 8px; background: transparent; color: var(--mute); box-shadow: none;
  }
  html.ui3 #shell header.top > #theme.theme-dock button svg { width: 17px; height: 17px; }
  html.ui3 #shell header.top > #theme.theme-dock button[aria-pressed="true"] {
    background: light-dark(#ffffff, #636366); color: var(--ink);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .04);
  }
}
@media (max-width: 374px) {   /* iPhone SE / 320px: narrower segments so «Поиск по актам» stays on one line */
  #shell header.top > #theme.theme-dock button { width: 30px; }
}

/* LOCAL PATCH tabbar t31u: «Расширенный» phone tab bar has 7 tabs; with equal 49px slots the labels ran together
   («КалендарьЧек-листИнструменты» on iPhone). Each tab now takes its own label width, labels never overlap or get cut,
   and if a narrow phone cannot fit all seven the bar scrolls sideways instead (no tab is dropped). */
@media (max-width: 860px) {
  html:not(.ui3) .tabbar { left: 8px; right: 8px; padding: 4px; gap: 1px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  html:not(.ui3) .tabbar::-webkit-scrollbar { display: none; }
  html:not(.ui3) .tabbar button { flex: 1 0 auto; min-width: 34px; padding: 7px 3px 6px; gap: 3px; font-size: 10px; letter-spacing: 0; scroll-snap-align: center; }
  html:not(.ui3) .tabbar button span { overflow: visible; text-overflow: clip; max-width: none; letter-spacing: -.015em; line-height: 1.2; }
  html:not(.ui3) .tabbar button svg { width: 20px; height: 20px; }
}

/* LOCAL PATCH menu-theme t31u: «Г» menu (Новый) — the chosen theme is visible, same segmented look as the header switch */
.ui3-theme { gap: 2px; padding: 2px; margin: 0 6px; border-radius: 10px; background: light-dark(#e8e8ed, #2c2c2e); }
.ui3-theme button { flex: 1; border: 0 !important; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 13px; padding: 7px 4px; }
.ui3-theme button[aria-pressed="true"] { background: light-dark(#ffffff, #636366); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .04); }
